Skip to content

Commit

Permalink
Fixed some compiling issues (TrinityCore#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meltie2013 committed Nov 14, 2021
1 parent 5f767e8 commit d6cf069
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
16 changes: 0 additions & 16 deletions src/modules/Bots/playerbot/Helpers.cpp
Expand Up @@ -2,7 +2,6 @@
#include "playerbot.h"
#include "Util.h"
#include <algorithm>
#include <functional>
#include <cctype>
#include <locale>

Expand Down Expand Up @@ -77,18 +76,3 @@ uint64 extractGuid(WorldPacket& packet)
}
return guid;
}

// Same function in Util.h
//std::string &ltrim(std::string &s) {
// s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
// return s;
//}

std::string &rtrim(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
return s;
}

std::string &trim(std::string &s) {
return ltrim(rtrim(s));
}
2 changes: 1 addition & 1 deletion src/modules/Bots/playerbot/PlayerbotAI.cpp
Expand Up @@ -15,6 +15,7 @@
#include "PlayerbotAI.h"
#include "PlayerbotFactory.h"
#include "PlayerbotSecurity.h"
#include "Util.h"
#include "Group.h"
#include "Pet.h"
#include "SpellAuras.h"
Expand All @@ -29,7 +30,6 @@ vector<string>& split(const string &s, char delim, vector<string> &elems);
vector<string> split(const string &s, char delim);
char * strstri (string str1, string str2);
uint64 extractGuid(WorldPacket& packet);
std::string &trim(std::string &s);

uint32 PlayerbotChatHandler::extractQuestId(string str)
{
Expand Down
21 changes: 18 additions & 3 deletions src/shared/Utilities/Util.h
Expand Up @@ -32,6 +32,7 @@
#include <vector>
#include <algorithm>
#include <cctype>
#include <functional>

/**
* @brief
Expand Down Expand Up @@ -115,13 +116,27 @@ inline uint32 secsToTimeBitFields(time_t secs)
}


inline std::string ltrim(std::string& s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
inline std::string& ltrim(std::string& s)
{
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch)
{
return !std::isspace(ch);
}));
}));

return s;
}

inline std::string& rtrim(std::string& s)
{
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
return s;
}

inline std::string& trim(std::string& s)
{
return ltrim(rtrim(s));
}

/**
* @brief Return a random number in the range min..max; (max-min) must be smaller than 32768.
*
Expand Down

0 comments on commit d6cf069

Please sign in to comment.