mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-03 07:17:59 +03: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
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",
|
||||||
|
@ -54,7 +54,7 @@ std::string bodyPartLabel(char idx)
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string meshPartLabel(char idx)
|
std::string meshPartLabel(signed char idx)
|
||||||
{
|
{
|
||||||
const char *meshPartLabels[] = {
|
const char *meshPartLabels[] = {
|
||||||
"Head",
|
"Head",
|
||||||
|
@ -80,7 +80,7 @@ std::string meshPartLabel(char idx)
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string meshTypeLabel(char idx)
|
std::string meshTypeLabel(signed char idx)
|
||||||
{
|
{
|
||||||
const char *meshTypeLabels[] = {
|
const char *meshTypeLabels[] = {
|
||||||
"Skin",
|
"Skin",
|
||||||
|
|
|
@ -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,7 +77,7 @@ 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;
|
||||||
|
|
|
@ -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…
Add table
Add a link
Reference in a new issue