Skip to content

Commit

Permalink
Merge ddbdafc into 2868fe1
Browse files Browse the repository at this point in the history
  • Loading branch information
PargeLenis authored Feb 10, 2023
2 parents 2868fe1 + ddbdafc commit 237622f
Show file tree
Hide file tree
Showing 642 changed files with 49,851 additions and 15 deletions.
4 changes: 2 additions & 2 deletions dockercontainer/DockerFile-mangosd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN mkdir /mangoserver/build
WORKDIR /mangoserver/build

#Install mangos
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/mangos -DBUILD_MANGOSD=1 -DBUILD_REALMD=0 -DBUILD_TOOLS=0
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/mangos -DBUILD_MANGOSD=1 -DBUILD_REALMD=0 -DBUILD_TOOLS=0 -DPLAYERBOTS=0
RUN make -j4
RUN make install

Expand All @@ -25,7 +25,7 @@ RUN apt-get -y update && apt-get -y upgrade
RUN apt-get -y install libmysqlclient20 openssl

COPY --from=build-step /mangos /mangos
COPY --from=build-step /etc/mangosd.conf.dist ../etc/mangosd.conf.dist
COPY --from=build-step /etc/*.conf.dist /mangos/etc/
WORKDIR /mangos/bin
RUN chmod +x mangosd

Expand Down
1 change: 0 additions & 1 deletion src/game/AuctionHouseBot/AuctionHouseBot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,6 @@ void AuctionBotBuyer::PrepareListOfEntry(AHB_Buyer_Config& config)

bool AuctionBotBuyer::IsBuyableEntry(uint32 buyoutPrice, double InGame_BuyPrice, double MaxBuyablePrice, uint32 MinBuyPrice, uint32 MaxChance, uint32 ChanceRatio)
{
double ratio = 0;
uint32 Chance = 0;

if (buyoutPrice <= MinBuyPrice)
Expand Down
2 changes: 1 addition & 1 deletion src/game/ChatCommands/RACommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ bool ChatHandler::HandleQuitCommand(char* /*args*/)
// processed in RASocket
SendSysMessage(LANG_QUIT_WRONG_USE_ERROR);
return true;
}
}
7 changes: 7 additions & 0 deletions src/game/Object/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,13 @@ bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) cons
// time.
void Item::SendTimeUpdate(Player* owner)
{
#ifdef ENABLE_PLAYERBOTS
if (!owner || !owner->IsInWorld() || owner->GetPlayerbotAI())
{
return;
}
#endif

uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION);
if (!duration)
{
Expand Down
40 changes: 40 additions & 0 deletions src/game/Object/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
#include "LuaEngine.h"
#endif /* ENABLE_ELUNA */

#ifdef ENABLE_PLAYERBOTS
#include "playerbot.h"
#endif

#include <cmath>

#define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS)
Expand Down Expand Up @@ -437,6 +441,11 @@ UpdateMask Player::updateVisualBits;

Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_achievementMgr(this), m_reputationMgr(this)
{
#ifdef ENABLE_PLAYERBOTS
m_playerbotAI = 0;
m_playerbotMgr = 0;
#endif

m_transport = 0;

m_speakTime = 0;
Expand Down Expand Up @@ -628,6 +637,10 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_

m_lastFallTime = 0;
m_lastFallZ = 0;
#ifdef ENABLE_PLAYERBOTS
m_playerbotAI = NULL;
m_playerbotMgr = NULL;
#endif

m_cachedGS = 0;
}
Expand Down Expand Up @@ -669,6 +682,21 @@ Player::~Player()
delete ItemSetEff[x];
}

#ifdef ENABLE_PLAYERBOTS
if (m_playerbotAI) {
{
delete m_playerbotAI;
}
m_playerbotAI = 0;
}
if (m_playerbotMgr) {
{
delete m_playerbotMgr;
}
m_playerbotMgr = 0;
}
#endif

// clean up player-instance binds, may unload some instance saves
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr)
Expand Down Expand Up @@ -1627,6 +1655,18 @@ void Player::Update(uint32 update_diff, uint32 p_time)
{
TeleportTo(m_teleport_dest, m_teleport_options);
}

#ifdef ENABLE_PLAYERBOTS
if (m_playerbotAI)
{
m_playerbotAI->UpdateAI(p_time);
}
if (m_playerbotMgr)
{
m_playerbotMgr->UpdateAI(p_time);
}
#endif

}

void Player::SetDeathState(DeathState s)
Expand Down
23 changes: 23 additions & 0 deletions src/game/Object/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class Item;

struct AreaTrigger;

#ifdef ENABLE_PLAYERBOTS
class PlayerbotAI;
class PlayerbotMgr;
#endif

typedef std::deque<Mail*> PlayerMails;

#define PLAYER_MAX_SKILLS 127
Expand Down Expand Up @@ -1626,6 +1631,9 @@ class Player : public Unit
/*********************************************************/

bool LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder);
#ifdef ENABLE_PLAYERBOTS
bool MinimalLoadFromDB(QueryResult *result, uint32 guid);
#endif

static uint32 GetZoneIdFromDB(ObjectGuid guid);
static uint32 GetLevelFromDB(ObjectGuid guid);
Expand Down Expand Up @@ -2628,6 +2636,17 @@ class Player : public Unit
void SetTitle(CharTitlesEntry const* title, bool lost = false);

bool canSeeSpellClickOn(Creature const* creature) const;

#ifdef ENABLE_PLAYERBOTS
//EquipmentSets& GetEquipmentSets() { return m_EquipmentSets; }
void SetPlayerbotAI(PlayerbotAI* ai) { assert(!m_playerbotAI && !m_playerbotMgr); m_playerbotAI = ai; }
PlayerbotAI* GetPlayerbotAI() { return m_playerbotAI; }
void SetPlayerbotMgr(PlayerbotMgr* mgr) { assert(!m_playerbotAI && !m_playerbotMgr); m_playerbotMgr = mgr; }
PlayerbotMgr* GetPlayerbotMgr() { return m_playerbotMgr; }
void SetBotDeathTimer() { m_deathTimer = 0; }
//PlayerTalentMap& GetTalentMap(uint8 spec) { return m_talents[spec]; }
#endif

protected:

uint32 m_contestedPvPTimer;
Expand Down Expand Up @@ -2908,6 +2927,10 @@ class Player : public Unit
GridReference<Player> m_gridRef;
MapReference m_mapRef;

#ifdef ENABLE_PLAYERBOTS
PlayerbotAI* m_playerbotAI;
PlayerbotMgr* m_playerbotMgr;
#endif
// Homebind coordinates
uint32 m_homebindMapId;
uint16 m_homebindAreaId;
Expand Down
80 changes: 76 additions & 4 deletions src/game/Server/WorldSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#endif /*ENABLE_ELUNA*/
#ifdef ENABLE_PLAYERBOTS
#include "playerbot.h"
#endif

// Warden
#include "WardenWin.h"
Expand Down Expand Up @@ -162,6 +165,19 @@ char const* WorldSession::GetPlayerName() const
/// Send a packet to the client
void WorldSession::SendPacket(WorldPacket const* packet)
{
#ifdef ENABLE_PLAYERBOTS
if (GetPlayer()) {
if (GetPlayer()->GetPlayerbotAI())
{
GetPlayer()->GetPlayerbotAI()->HandleBotOutgoingPacket(*packet);
}
else if (GetPlayer()->GetPlayerbotMgr())
{
GetPlayer()->GetPlayerbotMgr()->HandleMasterOutgoingPacket(*packet);
}
}
#endif

if (!m_Socket)
{
return;
Expand Down Expand Up @@ -267,6 +283,12 @@ bool WorldSession::Update(PacketFilter& updater)
}

// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
#ifdef ENABLE_PLAYERBOTS
if (_player && _player->GetPlayerbotMgr())
{
_player->GetPlayerbotMgr()->HandleMasterIncomingPacket(*packet);
}
#endif
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGEDOUT:
if (!_player && !m_playerRecentlyLogout)
Expand Down Expand Up @@ -349,6 +371,13 @@ bool WorldSession::Update(PacketFilter& updater)
delete packet;
}

#ifdef ENABLE_PLAYERBOTS
if (GetPlayer() && GetPlayer()->GetPlayerbotMgr())
{
GetPlayer()->GetPlayerbotMgr()->UpdateSessions(0);
}
#endif

///- Cleanup socket pointer if need
if (m_Socket && m_Socket->IsClosed())
{
Expand Down Expand Up @@ -388,6 +417,19 @@ bool WorldSession::Update(PacketFilter& updater)
return true;
}

#ifdef ENABLE_PLAYERBOTS
void WorldSession::HandleBotPackets()
{
WorldPacket* packet;
while (_recvQueue.next(packet))
{
OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()];
(this->*opHandle.handler)(*packet);
delete packet;
}
}
#endif

/// %Log the player out
void WorldSession::LogoutPlayer(bool Save)
{
Expand All @@ -402,13 +444,28 @@ void WorldSession::LogoutPlayer(bool Save)

if (_player)
{
#ifdef ENABLE_PLAYERBOTS
if (GetPlayer()->GetPlayerbotMgr())
{
GetPlayer()->GetPlayerbotMgr()->LogoutAllBots();
}
#endif

sLog.outChar("Account: %d (IP: %s) Logout Character:[%s] (guid: %u)", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName() , _player->GetGUIDLow());

if (ObjectGuid lootGuid = GetPlayer()->GetLootGuid())
{
DoLootRelease(lootGuid);
}

#ifdef ENABLE_PLAYERBOTS
if (_player->GetPlayerbotMgr())
{
_player->GetPlayerbotMgr()->LogoutAllBots();
}
sRandomPlayerbotMgr.OnPlayerLogout(_player);
#endif

///- If the player just died before logging out, make him appear as a ghost
// FIXME: logout must be delayed in case lost connection with client in time of combat
if (_player->GetDeathTimer())
Expand Down Expand Up @@ -502,11 +559,23 @@ void WorldSession::LogoutPlayer(bool Save)
///- Reset the online field in the account table
// no point resetting online in character table here as Player::SaveToDB() will set it to 1 since player has not been removed from world at this stage
// No SQL injection as AccountID is uint32
#ifdef ENABLE_PLAYERBOTS
if (!GetPlayer()->GetPlayerbotAI())
{
static SqlStatementID id;
// playerbot mod
if (!_player->GetPlayerbotAI())
{
SqlStatement stmt = LoginDatabase.CreateStatement(id, "UPDATE `account` SET `active_realm_id` = ? WHERE `id` = ?");
stmt.PExecute(uint32(0), GetAccountId());
}
}
#else
static SqlStatementID id;

SqlStatement stmt = LoginDatabase.CreateStatement(id, "UPDATE `account` SET `active_realm_id` = ? WHERE `id` = ?");
stmt.PExecute(uint32(0), GetAccountId());

#endif
///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members
if (Guild* guild = sGuildMgr.GetGuildById(_player->GetGuildId()))
{
Expand All @@ -531,7 +600,7 @@ void WorldSession::LogoutPlayer(bool Save)

///- Leave all channels before player delete...
_player->CleanupChannels();

#ifndef ENABLE_PLAYERBOTS
///- If the player is in a group (or invited), remove him. If the group if then only 1 person, disband the group.
_player->UninviteFromGroup();

Expand All @@ -541,7 +610,7 @@ void WorldSession::LogoutPlayer(bool Save)
{
_player->RemoveFromGroup();
}

#endif
///- Send update to group
if (_player->GetGroup())
{
Expand Down Expand Up @@ -582,8 +651,11 @@ void WorldSession::LogoutPlayer(bool Save)
// No SQL injection as AccountId is uint32

static SqlStatementID updChars;

#ifdef ENABLE_PLAYERBOTS
SqlStatement stmt = CharacterDatabase.CreateStatement(updChars, "UPDATE `characters` SET `online` = 0 WHERE `account` = ?");
#else
stmt = CharacterDatabase.CreateStatement(updChars, "UPDATE `characters` SET `online` = 0 WHERE `account` = ?");
#endif
stmt.PExecute(GetAccountId());

DEBUG_LOG("SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
Expand Down
Loading

0 comments on commit 237622f

Please sign in to comment.