mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-21 09:39:56 +00:00
Use `signed char' explicitly where needed. It is important because:
- It is implementation-dependent if plain `char' signed or not. - C standard defines three *distinct* types: char, signed char, and unsigned char. - Assuming that char is always unsigned or signed can lead to compile-time and run-time errors. You can also use int8_t, but then it would be less obvious for developers to never assume that char is always unsigned (or always signed). Conflicts: components/esm/loadcell.hpp
This commit is contained in:
parent
4da11a96a5
commit
df5919f2c5
@ -16,7 +16,7 @@
|
||||
#include <iostream>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
std::string bodyPartLabel(char idx)
|
||||
std::string bodyPartLabel(signed char idx)
|
||||
{
|
||||
const char *bodyPartLabels[] = {
|
||||
"Head",
|
||||
@ -47,14 +47,14 @@ std::string bodyPartLabel(char idx)
|
||||
"Weapon",
|
||||
"Tail"
|
||||
};
|
||||
|
||||
|
||||
if ((int)idx >= 0 && (int)(idx) <= 26)
|
||||
return bodyPartLabels[(int)(idx)];
|
||||
else
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
std::string meshPartLabel(char idx)
|
||||
std::string meshPartLabel(signed char idx)
|
||||
{
|
||||
const char *meshPartLabels[] = {
|
||||
"Head",
|
||||
@ -73,25 +73,25 @@ std::string meshPartLabel(char idx)
|
||||
"Clavicle",
|
||||
"Tail"
|
||||
};
|
||||
|
||||
|
||||
if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MP_Tail)
|
||||
return meshPartLabels[(int)(idx)];
|
||||
else
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
std::string meshTypeLabel(char idx)
|
||||
std::string meshTypeLabel(signed char idx)
|
||||
{
|
||||
const char *meshTypeLabels[] = {
|
||||
"Skin",
|
||||
"Clothing",
|
||||
"Armor"
|
||||
};
|
||||
|
||||
|
||||
if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MT_Armor)
|
||||
return meshTypeLabels[(int)(idx)];
|
||||
else
|
||||
return "Invalid";
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
std::string clothingTypeLabel(int idx)
|
||||
@ -108,7 +108,7 @@ std::string clothingTypeLabel(int idx)
|
||||
"Ring",
|
||||
"Amulet"
|
||||
};
|
||||
|
||||
|
||||
if (idx >= 0 && idx <= 9)
|
||||
return clothingTypeLabels[idx];
|
||||
else
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string bodyPartLabel(char idx);
|
||||
std::string meshPartLabel(char idx);
|
||||
std::string meshTypeLabel(char idx);
|
||||
std::string bodyPartLabel(signed char idx);
|
||||
std::string meshPartLabel(signed char idx);
|
||||
std::string meshTypeLabel(signed char idx);
|
||||
std::string clothingTypeLabel(int idx);
|
||||
std::string armorTypeLabel(int idx);
|
||||
std::string dialogTypeLabel(int idx);
|
||||
|
@ -77,8 +77,8 @@ public:
|
||||
std::string mKey, mTrap; // Key and trap ID names, if any
|
||||
|
||||
// No idea - occurs ONCE in Morrowind.esm, for an activator
|
||||
char mUnam;
|
||||
|
||||
signed char mUnam;
|
||||
|
||||
// Track deleted references. 0 - not deleted, 1 - deleted, but respawns, 2 - deleted and does not respawn.
|
||||
int mDeleted;
|
||||
|
||||
@ -164,14 +164,14 @@ struct Cell
|
||||
bool mWaterInt;
|
||||
int mMapColor;
|
||||
int mNAM0;
|
||||
|
||||
|
||||
// References "leased" from another cell (i.e. a different cell
|
||||
// introduced this ref, and it has been moved here by a plugin)
|
||||
CellRefTracker mLeasedRefs;
|
||||
MovedCellRefTracker mMovedRefs;
|
||||
|
||||
|
||||
void load(ESMReader &esm, MWWorld::ESMStore &store);
|
||||
|
||||
|
||||
// This method is left in for compatibility with esmtool. Parsing moved references currently requires
|
||||
// passing ESMStore, bit it does not know about this parameter, so we do it this way.
|
||||
void load(ESMReader &esm) {};
|
||||
@ -209,7 +209,7 @@ struct Cell
|
||||
reuse one memory location without blanking it between calls.
|
||||
*/
|
||||
static bool getNextRef(ESMReader &esm, CellRef &ref);
|
||||
|
||||
|
||||
/* This fetches an MVRF record, which is used to track moved references.
|
||||
* Since they are comparably rare, we use a separate method for this.
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@ struct Dialogue
|
||||
};
|
||||
|
||||
std::string mId;
|
||||
char mType;
|
||||
signed char mType;
|
||||
std::vector<DialInfo> mInfo;
|
||||
|
||||
void load(ESMReader &esm);
|
||||
|
@ -8,7 +8,7 @@ namespace ToUTF8
|
||||
/// Central European and Eastern European languages that use Latin script,
|
||||
/// such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian,
|
||||
/// Serbian (Latin script), Romanian and Albanian.
|
||||
static char windows_1250[] =
|
||||
static signed char windows_1250[] =
|
||||
{
|
||||
1, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0,
|
||||
@ -270,7 +270,7 @@ static char windows_1250[] =
|
||||
|
||||
/// Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic
|
||||
/// and other languages
|
||||
static char windows_1251[] =
|
||||
static signed char windows_1251[] =
|
||||
{
|
||||
1, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0,
|
||||
@ -531,7 +531,7 @@ static char windows_1251[] =
|
||||
};
|
||||
|
||||
/// Latin alphabet used by English and some other Western languages
|
||||
static char windows_1252[] =
|
||||
static signed char windows_1252[] =
|
||||
{
|
||||
1, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0,
|
||||
|
@ -216,7 +216,7 @@ void Utf8Encoder::copyFromArray(unsigned char ch, char* &out)
|
||||
return;
|
||||
}
|
||||
|
||||
const char *in = translationArray + ch*6;
|
||||
const signed char *in = translationArray + ch*6;
|
||||
int len = *(in++);
|
||||
for (int i=0; i<len; i++)
|
||||
*(out++) = *(in++);
|
||||
|
@ -47,7 +47,7 @@ namespace ToUTF8
|
||||
void copyFromArray2(const char*& chp, char* &out);
|
||||
|
||||
std::vector<char> mOutput;
|
||||
char* translationArray;
|
||||
signed char* translationArray;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user