mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Merge pull request #250 from yuan227301/opt_warning
[optimization] Fixed several compilation warnings
This commit is contained in:
@@ -673,6 +673,7 @@ Engine* AiFactory::createNonCombatEngine(Player* player, PlayerbotAI* const faca
|
|||||||
|
|
||||||
void AiFactory::AddDefaultDeadStrategies(Player* player, PlayerbotAI* const facade, Engine* deadEngine)
|
void AiFactory::AddDefaultDeadStrategies(Player* player, PlayerbotAI* const facade, Engine* deadEngine)
|
||||||
{
|
{
|
||||||
|
(void)facade; // unused and remove warning
|
||||||
deadEngine->addStrategies("dead", "stay", "chat", "default", "follow", nullptr);
|
deadEngine->addStrategies("dead", "stay", "chat", "default", "follow", nullptr);
|
||||||
|
|
||||||
if (sRandomPlayerbotMgr->IsRandomBot(player) && !player->GetGroup())
|
if (sRandomPlayerbotMgr->IsRandomBot(player) && !player->GetGroup())
|
||||||
|
|||||||
@@ -259,17 +259,17 @@ ItemIds ChatHelper::parseItems(std::string const text)
|
|||||||
uint8 pos = 0;
|
uint8 pos = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
uint32 i = text.find("Hitem:", pos);
|
auto i = text.find("Hitem:", pos);
|
||||||
if (i == -1)
|
if (i == std::string::npos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pos = i + 6;
|
pos = i + 6;
|
||||||
uint32 endPos = text.find(':', pos);
|
auto endPos = text.find(':', pos);
|
||||||
if (endPos == -1)
|
if (endPos == std::string::npos)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
std::string const idC = text.substr(pos, endPos - pos);
|
std::string const idC = text.substr(pos, endPos - pos);
|
||||||
uint32 id = atol(idC.c_str());
|
auto id = atol(idC.c_str());
|
||||||
pos = endPos;
|
pos = endPos;
|
||||||
if (id)
|
if (id)
|
||||||
itemIds.insert(id);
|
itemIds.insert(id);
|
||||||
@@ -383,6 +383,8 @@ std::string const ChatHelper::FormatChat(ChatMsg chat)
|
|||||||
return "whisper";
|
return "whisper";
|
||||||
case CHAT_MSG_RAID:
|
case CHAT_MSG_RAID:
|
||||||
return "raid";
|
return "raid";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "unknown";
|
return "unknown";
|
||||||
@@ -406,13 +408,13 @@ GuidVector ChatHelper::parseGameobjects(std::string const text)
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// extract GO guid
|
// extract GO guid
|
||||||
uint32 i = text.find("Hfound:", pos); // base H = 11
|
auto i = text.find("Hfound:", pos); // base H = 11
|
||||||
if (i == -1) // break if error
|
if (i == std::string::npos) // break if error
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pos = i + 7; //start of window in text 11 + 7 = 18
|
pos = i + 7; //start of window in text 11 + 7 = 18
|
||||||
uint32 endPos = text.find(':', pos); // end of window in text 22
|
auto endPos = text.find(':', pos); // end of window in text 22
|
||||||
if (endPos == -1) //break if error
|
if (endPos == std::string::npos) //break if error
|
||||||
break;
|
break;
|
||||||
|
|
||||||
std::istringstream stream(text.substr(pos, endPos - pos));
|
std::istringstream stream(text.substr(pos, endPos - pos));
|
||||||
@@ -422,7 +424,7 @@ GuidVector ChatHelper::parseGameobjects(std::string const text)
|
|||||||
// extract GO entry
|
// extract GO entry
|
||||||
pos = endPos + 1;
|
pos = endPos + 1;
|
||||||
endPos = text.find(':', pos); // end of window in text
|
endPos = text.find(':', pos); // end of window in text
|
||||||
if (endPos == -1) //break if error
|
if (endPos == std::string::npos) //break if error
|
||||||
break;
|
break;
|
||||||
|
|
||||||
std::string const entryC = text.substr(pos, endPos - pos); // get std::string const within window i.e entry
|
std::string const entryC = text.substr(pos, endPos - pos); // get std::string const within window i.e entry
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ PlayerbotAIBase::PlayerbotAIBase(bool isBotAI) : nextAICheckDelay(0), _isBotAI(i
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerbotAIBase::UpdateAIInternal(uint32 elapsed, bool minimal)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerbotAIBase::UpdateAI(uint32 elapsed, bool minimal)
|
void PlayerbotAIBase::UpdateAI(uint32 elapsed, bool minimal)
|
||||||
{
|
{
|
||||||
if (nextAICheckDelay > elapsed)
|
if (nextAICheckDelay > elapsed)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class PlayerbotAIBase
|
|||||||
void IncreaseNextCheckDelay(uint32 delay);
|
void IncreaseNextCheckDelay(uint32 delay);
|
||||||
void YieldThread(bool delay = false);
|
void YieldThread(bool delay = false);
|
||||||
virtual void UpdateAI(uint32 elapsed, bool minimal = false);
|
virtual void UpdateAI(uint32 elapsed, bool minimal = false);
|
||||||
virtual void UpdateAIInternal(uint32 elapsed, bool minimal = false);
|
virtual void UpdateAIInternal(uint32 elapsed, bool minimal = false) = 0;
|
||||||
bool IsActive();
|
bool IsActive();
|
||||||
bool IsBotAI() const;
|
bool IsBotAI() const;
|
||||||
|
|
||||||
|
|||||||
@@ -144,16 +144,15 @@ WorldPosition::operator bool() const
|
|||||||
return GetMapId() != 0 || GetPositionX() != 0 || GetPositionY() != 0 || GetPositionZ() != 0;
|
return GetMapId() != 0 || GetPositionX() != 0 || GetPositionY() != 0 || GetPositionZ() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldPosition::operator==(WorldPosition const& p1)
|
bool operator==(WorldPosition const& p1, const WorldPosition &p2)
|
||||||
{
|
{
|
||||||
return GetMapId() == GetMapId() && GetPositionX() == p1.GetPositionX() &&
|
return p1.GetMapId() == p2.GetMapId() && p2.GetPositionX() == p1.GetPositionX() &&
|
||||||
GetPositionY() == p1.GetPositionY() && GetPositionZ() == p1.GetPositionZ() && GetOrientation() == p1.GetOrientation();
|
p2.GetPositionY() == p1.GetPositionY() && p2.GetPositionZ() == p1.GetPositionZ() && p2.GetOrientation() == p1.GetOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldPosition::operator!=(WorldPosition const& p1)
|
bool operator!=(WorldPosition const& p1, const WorldPosition &p2)
|
||||||
{
|
{
|
||||||
return GetMapId() != GetMapId() || GetPositionX() != p1.GetPositionX() || GetPositionY() != p1.GetPositionY() ||
|
return !(p1 == p2);
|
||||||
GetPositionZ() != p1.GetPositionZ() || GetOrientation() != p1.GetOrientation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldPosition& WorldPosition::operator+=(WorldPosition const& p1)
|
WorldPosition& WorldPosition::operator+=(WorldPosition const& p1)
|
||||||
|
|||||||
@@ -113,9 +113,10 @@ class WorldPosition : public WorldLocation
|
|||||||
|
|
||||||
//Getters
|
//Getters
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
bool operator==(WorldPosition const& p1);
|
friend bool operator==(WorldPosition const& p1, const WorldPosition &p2);
|
||||||
bool operator!=(WorldPosition const& p1);
|
friend bool operator!=(WorldPosition const& p1, const WorldPosition &p2);
|
||||||
|
|
||||||
|
WorldPosition& operator=(WorldPosition const&) = default;
|
||||||
WorldPosition& operator+=(WorldPosition const& p1);
|
WorldPosition& operator+=(WorldPosition const& p1);
|
||||||
WorldPosition& operator-=(WorldPosition const& p1);
|
WorldPosition& operator-=(WorldPosition const& p1);
|
||||||
|
|
||||||
@@ -515,6 +516,7 @@ class TravelDestination
|
|||||||
{
|
{
|
||||||
points = points1; radiusMin = radiusMin1; radiusMax = radiusMax1;
|
points = points1; radiusMin = radiusMin1; radiusMax = radiusMax1;
|
||||||
}
|
}
|
||||||
|
virtual ~TravelDestination() = default;
|
||||||
|
|
||||||
void addPoint(WorldPosition* pos)
|
void addPoint(WorldPosition* pos)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class RpgHelper : public AiObject
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RpgHelper(PlayerbotAI* botAI) : AiObject(botAI) { }
|
RpgHelper(PlayerbotAI* botAI) : AiObject(botAI) { }
|
||||||
|
virtual ~RpgHelper() = default;
|
||||||
void OnExecute(std::string nextAction = "rpg");
|
void OnExecute(std::string nextAction = "rpg");
|
||||||
void BeforeExecute();
|
void BeforeExecute();
|
||||||
void AfterExecute(bool doDelay = true, bool waitForGroup = false);
|
void AfterExecute(bool doDelay = true, bool waitForGroup = false);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ float ExpectedGroupDpsValue::Calculate()
|
|||||||
basic_gs = (level + 5) * 4;
|
basic_gs = (level + 5) * 4;
|
||||||
} else if (level <= 70) {
|
} else if (level <= 70) {
|
||||||
basic_gs = (85 + (level - 60) * 3) * 4;
|
basic_gs = (85 + (level - 60) * 3) * 4;
|
||||||
} else if (level <= 80) {
|
} else {
|
||||||
basic_gs = (155 + (level - 70) * 4) * 4;
|
basic_gs = (155 + (level - 70) * 4) * 4;
|
||||||
}
|
}
|
||||||
float gap = mixedGearScore - basic_gs;
|
float gap = mixedGearScore - basic_gs;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Formation : public AiNamedObject
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Formation(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) { }
|
Formation(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) { }
|
||||||
|
virtual ~Formation() = default;
|
||||||
virtual std::string const GetTargetName() { return ""; }
|
virtual std::string const GetTargetName() { return ""; }
|
||||||
virtual WorldLocation GetLocation() { return NullLocation; }
|
virtual WorldLocation GetLocation() { return NullLocation; }
|
||||||
virtual float GetMaxDistance() { return sPlayerbotAIConfig->followDistance; }
|
virtual float GetMaxDistance() { return sPlayerbotAIConfig->followDistance; }
|
||||||
|
|||||||
Reference in New Issue
Block a user