Rename server's GetController() method into GetPlayerController()

coverity_scan^2
David Cernat 8 years ago
parent d2212ef80b
commit bda1f867fd

@ -26,9 +26,9 @@ Networking::Networking(RakNet::RakPeerInterface *peer)
this->peer = peer;
players = Players::GetPlayers();
controller = new PlayerPacketController(peer);
playerController = new PlayerPacketController(peer);
controller->SetStream(0, &bsOut); // set send stream
playerController->SetStream(0, &bsOut); // set send stream
running = true;
exitCode = 0;
@ -41,7 +41,7 @@ Networking::~Networking()
Script::Call<Script::CallbackIdentity("OnServerExit")>(false);
sThis = 0;
delete controller;
delete playerController;
LOG_QUIT();
}
@ -57,18 +57,18 @@ void Networking::Update(RakNet::Packet *packet)
(void)ignoredGUID;
}
controller->SetStream(&bsIn, 0);
playerController->SetStream(&bsIn, 0);
if (player == 0)
{
controller->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
playerController->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
Players::NewPlayer(packet->guid);
player = Players::GetPlayer(packet->guid);
controller->GetPacket(ID_USER_MYID)->Send(Players::GetPlayer(packet->guid), false);
playerController->GetPacket(ID_USER_MYID)->Send(Players::GetPlayer(packet->guid), false);
return;
}
PlayerPacket *myPacket = controller->GetPacket(packet->data[0]);
PlayerPacket *myPacket = playerController->GetPacket(packet->data[0]);
if (packet->data[0] == ID_HANDSHAKE)
{
@ -116,7 +116,7 @@ void Networking::Update(RakNet::Packet *packet)
if (!result)
{
controller->GetPacket(ID_USER_DISCONNECTED)->Send(Players::GetPlayer(packet->guid), false);
playerController->GetPacket(ID_USER_DISCONNECTED)->Send(Players::GetPlayer(packet->guid), false);
Players::DeletePlayer(packet->guid);
return;
}
@ -263,7 +263,7 @@ void Networking::Update(RakNet::Packet *packet)
}
myPacket->Send(player, true);
controller->GetPacket(ID_GAME_DYNAMICSTATS)->RequestData(player->GetAttack()->target);
playerController->GetPacket(ID_GAME_DYNAMICSTATS)->RequestData(player->GetAttack()->target);
}
break;
}
@ -308,8 +308,8 @@ void Networking::Update(RakNet::Packet *packet)
//packetResurrect.Read(player);
player->CreatureStats()->mDead = false;
myPacket->Send(player, true);
controller->GetPacket(ID_GAME_POS)->RequestData(player->guid);
controller->GetPacket(ID_GAME_CELL)->RequestData(player->guid);
playerController->GetPacket(ID_GAME_POS)->RequestData(player->guid);
playerController->GetPacket(ID_GAME_CELL)->RequestData(player->guid);
Script::Call<Script::CallbackIdentity("OnPlayerResurrect")>(player->GetID());
@ -378,23 +378,23 @@ void Networking::Update(RakNet::Packet *packet)
void Networking::NewPlayer(RakNet::RakNetGUID guid)
{
controller->GetPacket(ID_GAME_BASE_INFO)->RequestData(guid);
controller->GetPacket(ID_GAME_DYNAMICSTATS)->RequestData(guid);
controller->GetPacket(ID_GAME_POS)->RequestData(guid);
controller->GetPacket(ID_GAME_CELL)->RequestData(guid);
controller->GetPacket(ID_GAME_EQUIPMENT)->RequestData(guid);
playerController->GetPacket(ID_GAME_BASE_INFO)->RequestData(guid);
playerController->GetPacket(ID_GAME_DYNAMICSTATS)->RequestData(guid);
playerController->GetPacket(ID_GAME_POS)->RequestData(guid);
playerController->GetPacket(ID_GAME_CELL)->RequestData(guid);
playerController->GetPacket(ID_GAME_EQUIPMENT)->RequestData(guid);
for (TPlayers::iterator pl = players->begin(); pl != players->end(); pl++) //sending other players to new player
{
if (pl->first == guid) continue;
controller->GetPacket(ID_GAME_BASE_INFO)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_DYNAMICSTATS)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_ATTRIBUTE)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_SKILL)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_POS)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_CELL)->Send(pl->second, guid);
controller->GetPacket(ID_GAME_EQUIPMENT)->Send(pl->second, guid);
playerController->GetPacket(ID_GAME_BASE_INFO)->Send(pl->second, guid);
playerController->GetPacket(ID_GAME_DYNAMICSTATS)->Send(pl->second, guid);
playerController->GetPacket(ID_GAME_ATTRIBUTE)->Send(pl->second, guid);
playerController->GetPacket(ID_GAME_SKILL)->Send(pl->second, guid);
playerController->GetPacket(ID_GAME_POS)->Send(pl->second, guid);
playerController->GetPacket(ID_GAME_CELL)->Send(pl->second, guid);
playerController->GetPacket(ID_GAME_EQUIPMENT)->Send(pl->second, guid);
}
}
@ -407,13 +407,13 @@ void Networking::DisconnectPlayer(RakNet::RakNetGUID guid)
if (!player)
return;
Script::Call<Script::CallbackIdentity("OnPlayerDisconnect")>(player->GetID());
controller->GetPacket(ID_USER_DISCONNECTED)->Send(player, true);
playerController->GetPacket(ID_USER_DISCONNECTED)->Send(player, true);
Players::DeletePlayer(guid);
}
PlayerPacketController *Networking::GetController() const
PlayerPacketController *Networking::GetPlayerController() const
{
return controller;
return playerController;
}
const Networking &Networking::Get()

@ -27,7 +27,7 @@ namespace mwmp
void StopServer(int code);
PlayerPacketController *GetController() const;
PlayerPacketController *GetPlayerController() const;
static const Networking &Get();
static Networking *GetPtr();
@ -37,7 +37,7 @@ namespace mwmp
RakNet::BitStream bsOut;
TPlayers *players;
PlayerPacketController *controller;
PlayerPacketController *playerController;
bool running;
int exitCode;

@ -15,7 +15,7 @@ void CharClassFunctions::SendClass(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CHARCLASS)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CHARCLASS)->Send(player, false);
}
void CharClassFunctions::SetDefaultClass(unsigned short pid, const char *id) noexcept

@ -15,9 +15,9 @@ void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool
DEBUG_PRINTF("System: %s", message);
mwmp::Networking::Get().GetController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, false);
if (broadcast)
mwmp::Networking::Get().GetController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, true);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, true);
}
void ScriptFunctions::CleanChat(unsigned short pid)

@ -18,7 +18,7 @@ void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) no
player->guiMessageBox.label = label;
player->guiMessageBox.type = Player::GUIMessageBox::MessageBox;
mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
}
void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept
@ -31,7 +31,7 @@ void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *labe
player->guiMessageBox.buttons = buttons;
player->guiMessageBox.type = Player::GUIMessageBox::CustomMessageBox;
mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
}
void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label) noexcept
@ -43,7 +43,7 @@ void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label) no
player->guiMessageBox.label = label;
player->guiMessageBox.type = Player::GUIMessageBox::InputDialog;
mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
}
void GUIFunctions::SetMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state) noexcept

@ -65,6 +65,6 @@ void ItemFunctions::SendEquipment(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, false);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, true);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, true);
}

@ -454,14 +454,14 @@ void StatsFunctions::SetCharGenStage(unsigned short pid, int start, int end) noe
player->CharGenStage()->current = start;
player->CharGenStage()->end = end;
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CHARGEN)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CHARGEN)->Send(player, false);
}
void StatsFunctions::Resurrect(unsigned short pid)
{
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_RESURRECT)->RequestData(player->guid);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_RESURRECT)->RequestData(player->guid);
}
void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
@ -469,16 +469,16 @@ void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_BASE_INFO)->Send(player, false);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_BASE_INFO)->Send(player, true);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_BASE_INFO)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_BASE_INFO)->Send(player, true);
}
void StatsFunctions::SendDynamicStats(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(player, false);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(player, true);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(player, true);
}
void StatsFunctions::SendAttributes(unsigned short pid) noexcept
@ -486,8 +486,8 @@ void StatsFunctions::SendAttributes(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_ATTRIBUTE)->Send(player, false);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_ATTRIBUTE)->Send(player, true);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_ATTRIBUTE)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_ATTRIBUTE)->Send(player, true);
}
void StatsFunctions::SendSkills(unsigned short pid) noexcept
@ -495,8 +495,8 @@ void StatsFunctions::SendSkills(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_SKILL)->Send(player, false);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_SKILL)->Send(player, true);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_SKILL)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_SKILL)->Send(player, true);
}
void StatsFunctions::SendLevel(unsigned short pid) noexcept
@ -504,6 +504,6 @@ void StatsFunctions::SendLevel(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_LEVEL)->Send(player, false);
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_LEVEL)->Send(player, true);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_LEVEL)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_LEVEL)->Send(player, true);
}

@ -58,7 +58,7 @@ void TranslocationFunctions::SetPos(unsigned short pid, double x, double y, doub
player->Position()->pos[1] = y;
player->Position()->pos[2] = z;
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_POS)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_POS)->Send(player, false);
}
void TranslocationFunctions::SetCell(unsigned short pid, const char *name) noexcept
@ -80,7 +80,7 @@ void TranslocationFunctions::SetCell(unsigned short pid, const char *name) noexc
player->GetCell()->mName = name;
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CELL)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CELL)->Send(player, false);
}
const char* TranslocationFunctions::GetCell(unsigned short pid) noexcept
@ -111,7 +111,7 @@ void TranslocationFunctions::SetExterior(unsigned short pid, int x, int y) noexc
player->GetCell()->mCellId.mIndex.mX = x;
player->GetCell()->mCellId.mIndex.mY = y;
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CELL)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CELL)->Send(player, false);
}
int TranslocationFunctions::GetExteriorX(unsigned short pid) noexcept
@ -183,5 +183,5 @@ void TranslocationFunctions::SetAngle(unsigned short pid, double x, double y, do
player->Position()->rot[1] = y;
player->Position()->rot[2] = z;
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_POS)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_POS)->Send(player, false);
}

@ -17,7 +17,7 @@ void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept
player->month = -1;
player->day = -1;
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_TIME)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_TIME)->Send(player, false);
}
void WorldFunctions::SetMonth(unsigned short pid, int month) noexcept
@ -29,7 +29,7 @@ void WorldFunctions::SetMonth(unsigned short pid, int month) noexcept
player->month = month;
player->day = -1;
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_TIME)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_TIME)->Send(player, false);
}
@ -42,5 +42,5 @@ void WorldFunctions::SetDay(unsigned short pid, int day) noexcept
player->month = -1;
player->day = day;
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_TIME)->Send(player, false);
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_TIME)->Send(player, false);
}

Loading…
Cancel
Save