mirror of
https://github.com/edubart/otclient.git
synced 2025-12-14 04:49:45 +01:00
Fix NPC/Monster rendering for OTBM
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user