Skip to content

Commit

Permalink
-Internal: Linux fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlikely4r committed Dec 30, 2022
1 parent 878e02b commit b2940f2
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 104 deletions.
2 changes: 1 addition & 1 deletion playerbot/GuildTaskMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster)
if (secLevel == PlayerbotSecurityLevel::PLAYERBOT_SECURITY_DENY_ALL || (secLevel == PlayerbotSecurityLevel::PLAYERBOT_SECURITY_TALK && reason != DenyReason::PLAYERBOT_DENY_FAR))
{
sLog.outDebug("%s / %s: skipping guild task update - not enough security level, reason = %u",
guild->GetName().c_str(), player->GetName(), reason);
guild->GetName().c_str(), player->GetName(), (uint8)reason);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion playerbot/PerformanceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
}

if (i->first != PERF_MON_TOTAL)
sLog.outString("%7.3f%% %10.3fs | %6u .. %6u (%9.4f of %10u) - %s : %s"
sLog.outString("%7.3f%% %10.3fs | %6u .. %6u (%9.4d of %10u) - %s : %s"
, tPerc
, tTime / 1000.0f
, tMin
Expand Down
2 changes: 1 addition & 1 deletion playerbot/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5081,7 +5081,7 @@ void PlayerbotAI::EnchantItemT(uint32 spellid, uint8 slot, Item* item)
uint32 enchantid = spellInfo->EffectMiscValue[0];
if (!enchantid)
{
sLog.outError("%s: Invalid enchantid " , enchantid , " report to devs", bot->GetName());
sLog.outError("%u: Invalid enchantid %s %s" , enchantid , " report to devs", bot->GetName());
return;
}

Expand Down
5 changes: 4 additions & 1 deletion playerbot/PlayerbotAIAware.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#pragma once
#include <string>

class PlayerbotAI;

using namespace std;

namespace ai
{
class PlayerbotAIAware
{
public:
PlayerbotAIAware(PlayerbotAI* const ai) : ai(ai) { }
virtual std::string getName() { return std::string(); }
virtual string getName() { return string(); }
protected:
PlayerbotAI* ai;
};
Expand Down
33 changes: 30 additions & 3 deletions playerbot/PlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,10 @@ void PlayerbotFactory::InitEquipment(bool incremental)
quality--;
}

quality = ITEM_QUALITY_POOR;

uint32 attempts = 0;
uint32 searchLevel = level;
do
{
// pick random shirt
Expand Down Expand Up @@ -1329,9 +1332,33 @@ void PlayerbotFactory::InitEquipment(bool incremental)
vector<uint32> ids;
for (uint32 q = quality; q < ITEM_QUALITY_ARTIFACT; ++q)
{
vector<uint32> newItems = sRandomItemMgr.Query(level, bot->getClass(), uint8(specId), slot, q);
if (newItems.size())
ids.insert(ids.begin(), newItems.begin(), newItems.end());
uint32 searchLevel = level;
bool hasProperLevel = false;
while (!hasProperLevel && searchLevel > 0)
{
vector<uint32> newItems = sRandomItemMgr.Query(searchLevel, bot->getClass(), uint8(specId), slot, q);
if (newItems.size())
ids.insert(ids.begin(), newItems.begin(), newItems.end());

uint32 properLevel = 0;

for (auto id : ids)
{
ItemPrototype const* proto = sObjectMgr.GetItemPrototype(id);

if (proto->ItemLevel > sPlayerbotAIConfig.randomGearMaxLevel)
continue;

hasProperLevel = true;
break;
}

if (!hasProperLevel)
{
ids.clear();
searchLevel--;
}
}

// add one hand weapons for tanks
if ((specId == 3 || specId == 5) && slot == EQUIPMENT_SLOT_MAINHAND)
Expand Down
1 change: 1 addition & 0 deletions playerbot/RandomPlayerbotMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "TravelMgr.h"
#include <iomanip>
#include <float.h>

using namespace ai;
using namespace MaNGOS;
Expand Down
4 changes: 1 addition & 3 deletions playerbot/TravelMgr.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#pragma once


#include "TravelMgr.h"
#include <numeric>
#include <iomanip>

#include "strategy/values/SharedValueContext.h"
#include "PathFinder.h"
#include "TravelNode.h"
#include "PlayerbotAI.h"

using namespace ai;
using namespace MaNGOS;
Expand Down
8 changes: 4 additions & 4 deletions playerbot/TravelMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "strategy/AiObject.h"
#include <boost/functional/hash.hpp>
#include "WorldPosition.h"
#include "GuidPosition.h"

namespace ai
{
Expand Down Expand Up @@ -48,7 +48,7 @@ namespace ai
uint32 getExpireDelay() { return expireDelay; }
uint32 getCooldownDelay() { return cooldownDelay; }

virtual Quest const* GetQuestTemplate() { return NULL; }
virtual Quest const* GetQuestTemplate() { return nullptr; }

virtual bool isActive(Player* bot) { return false; }

Expand Down Expand Up @@ -83,7 +83,7 @@ namespace ai
public:
NullTravelDestination(uint32 cooldownDelay1 = 5 * 60 * 1000) : TravelDestination() { cooldownDelay = cooldownDelay1;};

virtual Quest const* GetQuestTemplate() { return NULL; }
virtual Quest const* GetQuestTemplate() { return nullptr; }

virtual bool isActive(Player* bot) { return false; }

Expand Down Expand Up @@ -195,7 +195,7 @@ namespace ai
virtual bool isActive(Player* bot);

virtual string getName() { return "ExploreTravelDestination"; }
virtual int32 getEntry() { return NULL; }
virtual int32 getEntry() { return 0; }
virtual string getTitle() { return title; }
virtual void setTitle(std::string newTitle) { title = newTitle; }
virtual uint32 getAreaId() { return areaId; }
Expand Down
2 changes: 0 additions & 2 deletions playerbot/TravelNode.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#pragma once

#include "TravelNode.h"
#include "TravelMgr.h"

Expand Down
2 changes: 2 additions & 0 deletions playerbot/WorldPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
#include "Map.h"
#include "vmap/VMapFactory.h"
#include "MoveMap.h"
#include "World.h"
#include "PathFinder.h"
#include "Grids/CellImpl.h"
#include "ObjectAccessor.h"

#include <numeric>
#include <iomanip>
Expand Down
12 changes: 6 additions & 6 deletions playerbot/playerbot.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#pragma once

std::vector<std::string> split(const std::string &s, char delim);
void split(std::vector<std::string>& dest, const std::string& str, const char* delim);
#ifndef WIN32
int strcmpi(std::string s1, std::string s2);
#endif

#include "Spell.h"
#include "WorldPacket.h"
#include "LootMgr.h"
Expand All @@ -30,3 +24,9 @@ int strcmpi(std::string s1, std::string s2);
#include "PlayerbotDbStore.h"

#define MANGOSBOT_VERSION 2

std::vector<std::string> split(std::string const& s, char delim);
void split(std::vector<std::string>& dest, std::string const& str, char const* delim);
#ifndef WIN32
int strcmpi(std::string s1, std::string s2);
#endif
21 changes: 1 addition & 20 deletions playerbot/strategy/Action.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,4 @@ namespace ai
Event event;
time_t created;
};
}

#define AI_VALUE(type, name) context->GetValue<type>(name)->Get()
#define AI_VALUE2(type, name, param) context->GetValue<type>(name, param)->Get()

#define AI_VALUE_LAZY(type, name) context->GetValue<type>(name)->LazyGet()
#define AI_VALUE2_LAZY(type, name, param) context->GetValue<type>(name, param)->LazyGet()

#define SET_AI_VALUE(type, name, value) context->GetValue<type>(name)->Set(value)
#define SET_AI_VALUE2(type, name, param, value) context->GetValue<type>(name, param)->Set(value)
#define RESET_AI_VALUE(type, name) context->GetValue<type>(name)->Reset()
#define RESET_AI_VALUE2(type, name, param) context->GetValue<type>(name, param)->Reset()

#define PAI_VALUE(type, name) player->GetPlayerbotAI()->GetAiObjectContext()->GetValue<type>(name)->Get()
#define PAI_VALUE2(type, name, param) player->GetPlayerbotAI()->GetAiObjectContext()->GetValue<type>(name, param)->Get()
#define GAI_VALUE(type, name) sSharedValueContext.getGlobalValue<type>(name)->Get()
#define GAI_VALUE2(type, name, param) sSharedValueContext.getGlobalValue<type>(name, param)->Get()

#define MEM_AI_VALUE(type, name) dynamic_cast<MemoryCalculatedValue<type>*>(context->GetUntypedValue(name))
#define LOG_AI_VALUE(type, name) dynamic_cast<LogCalculatedValue<type>*>(context->GetUntypedValue(name))
}
2 changes: 0 additions & 2 deletions playerbot/strategy/AiObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
class Player;
class PlayerbotAI;

using namespace std;

namespace ai
{
class AiObjectContext;
Expand Down
20 changes: 20 additions & 0 deletions playerbot/strategy/AiObjectContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,23 @@ namespace ai
NamedObjectContextList<UntypedValue> valueContexts;
};
}


#define AI_VALUE(type, name) context->GetValue<type>(name)->Get()
#define AI_VALUE2(type, name, param) context->GetValue<type>(name, param)->Get()

#define AI_VALUE_LAZY(type, name) context->GetValue<type>(name)->LazyGet()
#define AI_VALUE2_LAZY(type, name, param) context->GetValue<type>(name, param)->LazyGet()

#define SET_AI_VALUE(type, name, value) context->GetValue<type>(name)->Set(value)
#define SET_AI_VALUE2(type, name, param, value) context->GetValue<type>(name, param)->Set(value)
#define RESET_AI_VALUE(type, name) context->GetValue<type>(name)->Reset()
#define RESET_AI_VALUE2(type, name, param) context->GetValue<type>(name, param)->Reset()

#define PAI_VALUE(type, name) player->GetPlayerbotAI()->GetAiObjectContext()->GetValue<type>(name)->Get()
#define PAI_VALUE2(type, name, param) player->GetPlayerbotAI()->GetAiObjectContext()->GetValue<type>(name, param)->Get()
#define GAI_VALUE(type, name) sSharedValueContext.getGlobalValue<type>(name)->Get()
#define GAI_VALUE2(type, name, param) sSharedValueContext.getGlobalValue<type>(name, param)->Get()

#define MEM_AI_VALUE(type, name) dynamic_cast<MemoryCalculatedValue<type>*>(context->GetUntypedValue(name))
#define LOG_AI_VALUE(type, name) dynamic_cast<LogCalculatedValue<type>*>(context->GetUntypedValue(name))
7 changes: 4 additions & 3 deletions playerbot/strategy/Trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ namespace ai
class Trigger : public AiNamedObject
{
public:
Trigger(PlayerbotAI* ai, string name = "trigger", int checkInterval = 1) : AiNamedObject(ai, name), triggered(false) {
Trigger(PlayerbotAI* ai, string name = "trigger", int checkInterval = 1) : AiNamedObject(ai, name) {
this->triggered = false;
this->checkInterval = checkInterval;
lastCheckTime = time(0) - rand() % checkInterval;
this->lastCheckTime = time(0) - rand() % checkInterval;
}
virtual ~Trigger() {}

Expand All @@ -30,7 +31,7 @@ namespace ai
{
this->param = param;
this->owner = owner;
triggered = true;
this->triggered = true;
}
virtual bool IsActive() { return false; }
virtual NextAction** getHandlers() { return NULL; }
Expand Down
4 changes: 2 additions & 2 deletions playerbot/strategy/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace ai
{
lastCheckTime = now;

PerformanceMonitorOperation *pmo = sPerformanceMonitor.start(PERF_MON_VALUE, this->getName(), this->ai);
PerformanceMonitorOperation *pmo = sPerformanceMonitor.start(PERF_MON_VALUE, AiNamedObject::getName(), this->ai);
value = Calculate();
if (pmo) pmo->finish();
}
Expand Down Expand Up @@ -93,7 +93,7 @@ namespace ai
{
this->lastCheckTime = now;

PerformanceMonitorOperation* pmo = sPerformanceMonitor.start(PERF_MON_VALUE, this->getName(), this->ai);
PerformanceMonitorOperation* pmo = sPerformanceMonitor.start(PERF_MON_VALUE, AiNamedObject::getName(), this->ai);
this->value = this->Calculate();
if (pmo) pmo->finish();
}
Expand Down
Loading

0 comments on commit b2940f2

Please sign in to comment.