forked from mirror/openmw-tes3mp
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
7 changed files with 23 additions and 23 deletions
|
@ -16,7 +16,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
std::string bodyPartLabel(char idx)
|
std::string bodyPartLabel(signed char idx)
|
||||||
{
|
{
|
||||||
const char *bodyPartLabels[] = {
|
const char *bodyPartLabels[] = {
|
||||||
"Head",
|
"Head",
|
||||||
|
@ -47,14 +47,14 @@ std::string bodyPartLabel(char idx)
|
||||||
"Weapon",
|
"Weapon",
|
||||||
"Tail"
|
"Tail"
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((int)idx >= 0 && (int)(idx) <= 26)
|
if ((int)idx >= 0 && (int)(idx) <= 26)
|
||||||
return bodyPartLabels[(int)(idx)];
|
return bodyPartLabels[(int)(idx)];
|
||||||
else
|
else
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string meshPartLabel(char idx)
|
std::string meshPartLabel(signed char idx)
|
||||||
{
|
{
|
||||||
const char *meshPartLabels[] = {
|
const char *meshPartLabels[] = {
|
||||||
"Head",
|
"Head",
|
||||||
|
@ -73,25 +73,25 @@ std::string meshPartLabel(char idx)
|
||||||
"Clavicle",
|
"Clavicle",
|
||||||
"Tail"
|
"Tail"
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MP_Tail)
|
if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MP_Tail)
|
||||||
return meshPartLabels[(int)(idx)];
|
return meshPartLabels[(int)(idx)];
|
||||||
else
|
else
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string meshTypeLabel(char idx)
|
std::string meshTypeLabel(signed char idx)
|
||||||
{
|
{
|
||||||
const char *meshTypeLabels[] = {
|
const char *meshTypeLabels[] = {
|
||||||
"Skin",
|
"Skin",
|
||||||
"Clothing",
|
"Clothing",
|
||||||
"Armor"
|
"Armor"
|
||||||
};
|
};
|
||||||
|
|
||||||
if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MT_Armor)
|
if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MT_Armor)
|
||||||
return meshTypeLabels[(int)(idx)];
|
return meshTypeLabels[(int)(idx)];
|
||||||
else
|
else
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string clothingTypeLabel(int idx)
|
std::string clothingTypeLabel(int idx)
|
||||||
|
@ -108,7 +108,7 @@ std::string clothingTypeLabel(int idx)
|
||||||
"Ring",
|
"Ring",
|
||||||
"Amulet"
|
"Amulet"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (idx >= 0 && idx <= 9)
|
if (idx >= 0 && idx <= 9)
|
||||||
return clothingTypeLabels[idx];
|
return clothingTypeLabels[idx];
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
std::string bodyPartLabel(char idx);
|
std::string bodyPartLabel(signed char idx);
|
||||||
std::string meshPartLabel(char idx);
|
std::string meshPartLabel(signed char idx);
|
||||||
std::string meshTypeLabel(char idx);
|
std::string meshTypeLabel(signed char idx);
|
||||||
std::string clothingTypeLabel(int idx);
|
std::string clothingTypeLabel(int idx);
|
||||||
std::string armorTypeLabel(int idx);
|
std::string armorTypeLabel(int idx);
|
||||||
std::string dialogTypeLabel(int idx);
|
std::string dialogTypeLabel(int idx);
|
||||||
|
|
|
@ -77,8 +77,8 @@ public:
|
||||||
std::string mKey, mTrap; // Key and trap ID names, if any
|
std::string mKey, mTrap; // Key and trap ID names, if any
|
||||||
|
|
||||||
// No idea - occurs ONCE in Morrowind.esm, for an activator
|
// 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.
|
// Track deleted references. 0 - not deleted, 1 - deleted, but respawns, 2 - deleted and does not respawn.
|
||||||
int mDeleted;
|
int mDeleted;
|
||||||
|
|
||||||
|
@ -164,14 +164,14 @@ struct Cell
|
||||||
bool mWaterInt;
|
bool mWaterInt;
|
||||||
int mMapColor;
|
int mMapColor;
|
||||||
int mNAM0;
|
int mNAM0;
|
||||||
|
|
||||||
// References "leased" from another cell (i.e. a different cell
|
// References "leased" from another cell (i.e. a different cell
|
||||||
// introduced this ref, and it has been moved here by a plugin)
|
// introduced this ref, and it has been moved here by a plugin)
|
||||||
CellRefTracker mLeasedRefs;
|
CellRefTracker mLeasedRefs;
|
||||||
MovedCellRefTracker mMovedRefs;
|
MovedCellRefTracker mMovedRefs;
|
||||||
|
|
||||||
void load(ESMReader &esm, MWWorld::ESMStore &store);
|
void load(ESMReader &esm, MWWorld::ESMStore &store);
|
||||||
|
|
||||||
// This method is left in for compatibility with esmtool. Parsing moved references currently requires
|
// 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.
|
// passing ESMStore, bit it does not know about this parameter, so we do it this way.
|
||||||
void load(ESMReader &esm) {};
|
void load(ESMReader &esm) {};
|
||||||
|
@ -209,7 +209,7 @@ struct Cell
|
||||||
reuse one memory location without blanking it between calls.
|
reuse one memory location without blanking it between calls.
|
||||||
*/
|
*/
|
||||||
static bool getNextRef(ESMReader &esm, CellRef &ref);
|
static bool getNextRef(ESMReader &esm, CellRef &ref);
|
||||||
|
|
||||||
/* This fetches an MVRF record, which is used to track moved references.
|
/* This fetches an MVRF record, which is used to track moved references.
|
||||||
* Since they are comparably rare, we use a separate method for this.
|
* Since they are comparably rare, we use a separate method for this.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct Dialogue
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string mId;
|
std::string mId;
|
||||||
char mType;
|
signed char mType;
|
||||||
std::vector<DialInfo> mInfo;
|
std::vector<DialInfo> mInfo;
|
||||||
|
|
||||||
void load(ESMReader &esm);
|
void load(ESMReader &esm);
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace ToUTF8
|
||||||
/// Central European and Eastern European languages that use Latin script,
|
/// Central European and Eastern European languages that use Latin script,
|
||||||
/// such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian,
|
/// such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian,
|
||||||
/// Serbian (Latin script), Romanian and Albanian.
|
/// Serbian (Latin script), Romanian and Albanian.
|
||||||
static char windows_1250[] =
|
static signed char windows_1250[] =
|
||||||
{
|
{
|
||||||
1, 0, 0, 0, 0, 0,
|
1, 0, 0, 0, 0, 0,
|
||||||
1, 1, 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
|
/// Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic
|
||||||
/// and other languages
|
/// and other languages
|
||||||
static char windows_1251[] =
|
static signed char windows_1251[] =
|
||||||
{
|
{
|
||||||
1, 0, 0, 0, 0, 0,
|
1, 0, 0, 0, 0, 0,
|
||||||
1, 1, 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
|
/// 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, 0, 0, 0, 0, 0,
|
||||||
1, 1, 0, 0, 0, 0,
|
1, 1, 0, 0, 0, 0,
|
||||||
|
|
|
@ -216,7 +216,7 @@ void Utf8Encoder::copyFromArray(unsigned char ch, char* &out)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *in = translationArray + ch*6;
|
const signed char *in = translationArray + ch*6;
|
||||||
int len = *(in++);
|
int len = *(in++);
|
||||||
for (int i=0; i<len; i++)
|
for (int i=0; i<len; i++)
|
||||||
*(out++) = *(in++);
|
*(out++) = *(in++);
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace ToUTF8
|
||||||
void copyFromArray2(const char*& chp, char* &out);
|
void copyFromArray2(const char*& chp, char* &out);
|
||||||
|
|
||||||
std::vector<char> mOutput;
|
std::vector<char> mOutput;
|
||||||
char* translationArray;
|
signed char* translationArray;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue