Fix NPC/Monster rendering for OTBM

This commit is contained in:
niczkx
2012-08-07 03:12:44 -06:00
parent a2db210012
commit 6feaeff8cc
7 changed files with 46 additions and 18 deletions

View File

@@ -23,6 +23,7 @@
#include "string.h"
#include "format.h"
#include <boost/algorithm/string.hpp>
#include <ctype.h>
namespace stdext {
@@ -113,6 +114,31 @@ void trim(std::string& str)
boost::trim(str);
}
char upchar(char c)
{
#if defined(__GNUC__) && __GNUC__ >= 3
return ::toupper(c); // use the one from global scope "ctype.h"
#else
if((c >= 97 && c <= 122) || (c <= -1 && c >= -32))
c -= 32;
return c;
#endif
}
void ucwords(std::string& str)
{
uint32 strLen = str.length();
if(strLen == 0)
return;
str[0] = upchar(str[0]);
for(uint32 i = 1; i < strLen; ++i) {
if(str[i - 1] == ' ')
str[i] = upchar(str[i]);
}
}
bool ends_with(const std::string& str, const std::string& test)
{
return boost::ends_with(str, test);

View File

@@ -46,6 +46,8 @@ std::string utf8_to_latin1(uchar *utf8);
void tolower(std::string& str);
void toupper(std::string& str);
void trim(std::string& str);
void ucwords(std::string& str);
char upchar(char c);
bool ends_with(const std::string& str, const std::string& test);
bool starts_with(const std::string& str, const std::string& test);
void replace_all(std::string& str, const std::string& search, const std::string& replacement);