Skip to content

Commit

Permalink
Compile: Fixed some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlikely4r committed Jan 12, 2025
1 parent e1cb2dd commit ae2078b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 92 deletions.
69 changes: 0 additions & 69 deletions playerbot/PlayerbotCommandServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

INSTANTIATE_SINGLETON_1(PlayerbotCommandServer);

#ifdef CMANGOS

#include <boost/bind.hpp>
#include <boost/smart_ptr.hpp>
#include <boost/asio.hpp>
Expand Down Expand Up @@ -94,70 +92,3 @@ void PlayerbotCommandServer::Start()
std::thread serverThread(Run);
serverThread.detach();
}
#endif

#ifdef MANGOS
bool ReadLine(ACE_SOCK_Stream& client_stream, std::string* buffer, std::string* line)
{
// Do the real reading from fd until buffer has '\n'.
std::string::iterator pos;
while ((pos = find(buffer->begin(), buffer->end(), '\n')) == buffer->end())
{
char buf[33];
size_t n = client_stream.recv_n(buf, 1, 0);
if (n == -1)
return false;

buf[n] = 0;
*buffer += buf;
}

*line = std::string(buffer->begin(), pos);
*buffer = std::string(pos + 1, buffer->end());
return true;
}

class PlayerbotCommandServerThread: public ACE_Task <ACE_MT_SYNCH>
{
public:
int svc(void) {
if (!sPlayerbotAIConfig.commandServerPort) {
return 0;
}

std::ostringstream s; s << "Starting Playerbot Command Server on port " << sPlayerbotAIConfig.commandServerPort;
sLog.outString(s.str().c_str());

ACE_INET_Addr server(sPlayerbotAIConfig.commandServerPort);
ACE_SOCK_Acceptor client_responder(server);

while (true)
{
ACE_SOCK_Stream client_stream;
ACE_Time_Value timeout(5);
ACE_INET_Addr client;
if (-1 != client_responder.accept(client_stream, &client, &timeout))
{
string buffer, request;
while (ReadLine(client_stream, &buffer, &request))
{
string response = sRandomPlayerbotMgr.HandleRemoteCommand(request) + "\n";
client_stream.send_n(response.c_str(), response.size(), 0);
request = "";
}
client_stream.close();
}
}

return 0;
}
};


void PlayerbotCommandServer::Start()
{
PlayerbotCommandServerThread *thread = new PlayerbotCommandServerThread();
thread->activate();
}

#endif
46 changes: 23 additions & 23 deletions playerbot/RandomPlayerbotMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3085,7 +3085,7 @@ bool RandomPlayerbotMgr::HandlePlayerbotConsoleCommand(ChatHandler* handler, cha
ss << "char db ping: " << sRandomPlayerbotMgr.GetDatabaseDelay("CharacterDatabase") << "\n";
ss << "Sessions online: " << sWorld.GetActiveSessionCount();

sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());

Player* requester = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
if (requester)
Expand Down Expand Up @@ -3350,7 +3350,7 @@ void RandomPlayerbotMgr::PrintStats(uint32 requesterGuid)
{
Player* requester = GetPlayer(requesterGuid);
std::stringstream ss; ss << GetPlayerbotsAmount() << " Random Bots online";
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

std::map<uint32, int> alliance, horde;
Expand Down Expand Up @@ -3479,7 +3479,7 @@ void RandomPlayerbotMgr::PrintStats(uint32 requesterGuid)
});

ss.str(""); ss << "Bots level:";
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

uint32 maxLevel = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL);
Expand All @@ -3493,56 +3493,56 @@ void RandomPlayerbotMgr::PrintStats(uint32 requesterGuid)
if (!from) from = 1;

ss.str(""); ss << " " << from << ".." << to << ": " << alliance[i] << " alliance, " << horde[i] << " horde";
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }
}

ss.str(""); ss << "Bots race:";
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

for (uint8 race = RACE_HUMAN; race < MAX_RACES; ++race)
{
if (perRace[race])
{
ss.str(""); ss << " " << ChatHelper::formatRace(race) << ": " << perRace[race];
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }
}
}

ss.str(""); ss << "Bots class:";
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

for (uint8 cls = CLASS_WARRIOR; cls < MAX_CLASSES; ++cls)
{
if (perClass[cls])
{
ss.str(""); ss << " " << ChatHelper::formatClass(cls) << ": " << perClass[cls];
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }
}
}

ss.str(""); ss << "Bots role:";
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " tank: " << tank << ", heal: " << heal << ", dps: " << dps;
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << "Bots status:";
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " Active: " << active;
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " Moving: " << moving;
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

//sLog.outString("Bots to:");
Expand All @@ -3553,43 +3553,43 @@ void RandomPlayerbotMgr::PrintStats(uint32 requesterGuid)
//sLog.outString(" revive: %d", revive);

ss.str(""); ss << " On taxi: " << taxi;
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " On mount: " << mounted;
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " In combat: " << combat;
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " Dead: " << dead;
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " AFK: " << afk;
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << "Bots questing:";
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " Picking quests: " << stateCount[(uint8)TravelState::TRAVEL_STATE_TRAVEL_PICK_UP_QUEST] + stateCount[(uint8)TravelState::TRAVEL_STATE_WORK_PICK_UP_QUEST];
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " Doing quests: " << stateCount[(uint8)TravelState::TRAVEL_STATE_TRAVEL_DO_QUEST] + stateCount[(uint8)TravelState::TRAVEL_STATE_WORK_DO_QUEST];
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " Completing quests: " << stateCount[(uint8)TravelState::TRAVEL_STATE_TRAVEL_HAND_IN_QUEST] + stateCount[(uint8)TravelState::TRAVEL_STATE_WORK_HAND_IN_QUEST];
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());
if (requester) { requester->SendMessageToPlayer(ss.str()); }

ss.str(""); ss << " Idling: " << stateCount[(uint8)TravelState::TRAVEL_STATE_IDLE];
sLog.outString(ss.str().c_str());
sLog.outString("s%", ss.str().c_str());

This comment has been minimized.

Copy link
@Exxenoz

Exxenoz Jan 12, 2025

Member

The format specifier should be %s instead of s%.

if (requester) { requester->SendMessageToPlayer(ss.str()); }
}

Expand Down

0 comments on commit ae2078b

Please sign in to comment.