mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-12-24 13:45:47 +00:00
Minor changes; based on russian opensource patch.
This commit is contained in:
parent
c7d7e6126f
commit
283fc0086e
5 changed files with 35 additions and 40 deletions
|
@ -141,7 +141,7 @@ unsigned hash(const std::string &string)
|
|||
unsigned hash = 5381;
|
||||
|
||||
for (int i = 0; i < string.size(); i++)
|
||||
hash = ((hash << 5) + hash) + string[i];
|
||||
hash = ((hash << 5) + hash) + (unsigned char)string[i];
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
@ -197,26 +197,32 @@ bool isVectorInRect(const Vector &vec, const Vector &coord1, const Vector &coord
|
|||
return (vec.x > coord1.x && vec.x < coord2.x && vec.y > coord1.y && vec.y < coord2.y);
|
||||
}
|
||||
|
||||
static char charToUpper(char c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z') c = c - 'a' + 'A';
|
||||
if ((unsigned char)c >= 0xE0 && (unsigned char)c <= 0xFF)
|
||||
c = c - 0xE0 + 0xC0;
|
||||
return c;
|
||||
}
|
||||
|
||||
static char charToLower(char c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z') c = c-'A' + 'a';
|
||||
if ((unsigned char)c >= 0xC0 && (unsigned char)c <= 0xDF)
|
||||
c = c-0xC0+0xE0;
|
||||
return c;
|
||||
}
|
||||
|
||||
void stringToUpper(std::string &s)
|
||||
{
|
||||
for (int i = 0; i < s.size(); i++)
|
||||
{
|
||||
if (s[i] >= 'a' && s[i] <= 'z')
|
||||
{
|
||||
s[i] = s[i]-'a' + 'A';
|
||||
}
|
||||
}
|
||||
s[i] = charToUpper(s[i]);
|
||||
}
|
||||
|
||||
void stringToLower(std::string &s)
|
||||
{
|
||||
for (int i = 0; i < s.size(); i++)
|
||||
{
|
||||
if (s[i] >= 'A' && s[i] <= 'Z')
|
||||
{
|
||||
s[i] = s[i]-'A' + 'a';
|
||||
}
|
||||
}
|
||||
s[i] = charToLower(s[i]);
|
||||
}
|
||||
|
||||
void stringToLowerUserData(std::string &s)
|
||||
|
@ -246,9 +252,9 @@ int nocasecmp(const std::string &s1, const std::string &s2)
|
|||
//stop when either string's end has been reached
|
||||
while ( (it1!=s1.end()) && (it2!=s2.end()) )
|
||||
{
|
||||
if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
|
||||
if(charToUpper(*it1) != charToUpper(*it2)) //letters differ?
|
||||
// return -1 to indicate smaller than, 1 otherwise
|
||||
return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1;
|
||||
return (charToUpper(*it1) < charToUpper(*it2)) ? -1 : 1;
|
||||
//proceed to the next character in each string
|
||||
++it1;
|
||||
++it2;
|
||||
|
@ -261,18 +267,6 @@ int nocasecmp(const std::string &s1, const std::string &s2)
|
|||
}
|
||||
#endif // #if !HAVE_STRCASECMP
|
||||
|
||||
std::string upperCase(const std::string &s1)
|
||||
{
|
||||
std::string ret;
|
||||
std::string::const_iterator it1=s1.begin();
|
||||
while (it1 != s1.end())
|
||||
{
|
||||
ret += ::toupper(*it1);
|
||||
++it1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool exists(const std::string &f, bool makeFatal, bool skipVFS)
|
||||
{
|
||||
bool e = false;
|
||||
|
|
|
@ -220,7 +220,6 @@ static inline int nocasecmp(const char *s1, const char *s2)
|
|||
#else
|
||||
int nocasecmp(const std::string &s1, const std::string &s2);
|
||||
#endif
|
||||
std::string upperCase(const std::string &s1);
|
||||
Vector getNearestPointOnLine(Vector start, Vector end, Vector point);
|
||||
bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius=1, Vector* closest=0);
|
||||
void sizePowerOf2Texture(int &v);
|
||||
|
|
|
@ -241,6 +241,7 @@ public:
|
|||
BB_MAKE_WRITE_OP(float);
|
||||
BB_MAKE_WRITE_OP(double);
|
||||
BB_MAKE_WRITE_OP(int);
|
||||
BB_MAKE_WRITE_OP(unsigned int);
|
||||
|
||||
ByteBuffer &operator<<(bool value)
|
||||
{
|
||||
|
@ -272,6 +273,7 @@ public:
|
|||
BB_MAKE_READ_OP(float);
|
||||
BB_MAKE_READ_OP(double);
|
||||
BB_MAKE_READ_OP(int);
|
||||
BB_MAKE_READ_OP(unsigned int);
|
||||
|
||||
ByteBuffer &operator>>(bool &value)
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ bool GLFont::Create (const char *file_name, int tex, bool loadTexture)
|
|||
vfclose(fh);
|
||||
#endif
|
||||
|
||||
int dummy;
|
||||
ByteBuffer::uint32 dummy;
|
||||
|
||||
// Read the header from file
|
||||
header.tex = tex;
|
||||
|
@ -197,7 +197,7 @@ int GLFont::GetEndChar (void)
|
|||
return header.end_char;
|
||||
}
|
||||
//*******************************************************************
|
||||
void GLFont::GetCharSize (int c, std::pair<int, int> *size)
|
||||
void GLFont::GetCharSize (unsigned int c, std::pair<int, int> *size)
|
||||
{
|
||||
//Make sure character is in range
|
||||
if (c < header.start_char || c > header.end_char)
|
||||
|
@ -218,7 +218,7 @@ void GLFont::GetCharSize (int c, std::pair<int, int> *size)
|
|||
}
|
||||
}
|
||||
//*******************************************************************
|
||||
int GLFont::GetCharWidth (int c)
|
||||
int GLFont::GetCharWidth (unsigned int c)
|
||||
{
|
||||
//Make sure in range
|
||||
if (c < header.start_char || c > header.end_char)
|
||||
|
@ -242,7 +242,7 @@ int GLFont::GetCharWidth (int c)
|
|||
}
|
||||
}
|
||||
//*******************************************************************
|
||||
int GLFont::GetCharHeight (int c)
|
||||
int GLFont::GetCharHeight (unsigned int c)
|
||||
{
|
||||
//Make sure in range
|
||||
if (c < header.start_char || c > header.end_char)
|
||||
|
@ -268,7 +268,7 @@ void GLFont::Begin (void)
|
|||
void GLFont::GetStringSize (const std::string &text, std::pair<int, int> *size)
|
||||
{
|
||||
unsigned int i;
|
||||
char c;
|
||||
unsigned char c;
|
||||
GLFontChar *glfont_char;
|
||||
float width;
|
||||
|
||||
|
@ -282,7 +282,7 @@ void GLFont::GetStringSize (const std::string &text, std::pair<int, int> *size)
|
|||
for (i = 0; i < text.size(); i++)
|
||||
{
|
||||
//Make sure character is in range
|
||||
c = (char)text[i];
|
||||
c = (unsigned char)text[i];
|
||||
|
||||
if (c < header.start_char || c > header.end_char)
|
||||
continue;
|
||||
|
|
|
@ -36,9 +36,9 @@ private:
|
|||
//glFont header structure
|
||||
struct
|
||||
{
|
||||
int tex;
|
||||
int tex_width, tex_height;
|
||||
int start_char, end_char;
|
||||
unsigned int tex;
|
||||
unsigned int tex_width, tex_height;
|
||||
unsigned int start_char, end_char;
|
||||
GLFontChar *chars;
|
||||
} header;
|
||||
|
||||
|
@ -70,9 +70,9 @@ public:
|
|||
int GetEndChar (void);
|
||||
|
||||
//Character size retrieval methods
|
||||
void GetCharSize (int c, std::pair<int, int> *size);
|
||||
int GetCharWidth (int c);
|
||||
int GetCharHeight (int c);
|
||||
void GetCharSize (unsigned int c, std::pair<int, int> *size);
|
||||
int GetCharWidth (unsigned int c);
|
||||
int GetCharHeight (unsigned int c);
|
||||
|
||||
void GetStringSize (const std::string &text, std::pair<int, int> *size);
|
||||
|
||||
|
|
Loading…
Reference in a new issue