1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-27 04:09:41 +00:00

[Client] Fix code style in PlayerList

This commit is contained in:
David Cernat 2019-08-27 09:29:43 +03:00
parent 3e1c96a49c
commit a52d32602d
2 changed files with 26 additions and 25 deletions

View file

@ -21,14 +21,14 @@
using namespace mwmp; using namespace mwmp;
using namespace std; using namespace std;
std::map <RakNet::RakNetGUID, DedicatedPlayer *> PlayerList::players; std::map <RakNet::RakNetGUID, DedicatedPlayer *> PlayerList::playerList;
void PlayerList::update(float dt) void PlayerList::update(float dt)
{ {
for (auto &p : players) for (auto &playerEntry : playerList)
{ {
DedicatedPlayer *player = p.second; DedicatedPlayer *player = playerEntry.second;
if (player == 0) continue; if (player == nullptr) continue;
player->update(dt); player->update(dt);
} }
@ -38,46 +38,47 @@ DedicatedPlayer *PlayerList::newPlayer(RakNet::RakNetGUID guid)
{ {
LOG_APPEND(TimedLog::LOG_INFO, "- Creating new DedicatedPlayer with guid %s", guid.ToString()); LOG_APPEND(TimedLog::LOG_INFO, "- Creating new DedicatedPlayer with guid %s", guid.ToString());
players[guid] = new DedicatedPlayer(guid); playerList[guid] = new DedicatedPlayer(guid);
LOG_APPEND(TimedLog::LOG_INFO, "- There are now %i DedicatedPlayers", players.size()); LOG_APPEND(TimedLog::LOG_INFO, "- There are now %i DedicatedPlayers", playerList.size());
return players[guid]; return playerList[guid];
} }
void PlayerList::deletePlayer(RakNet::RakNetGUID guid) void PlayerList::deletePlayer(RakNet::RakNetGUID guid)
{ {
if (players[guid]->reference) if (playerList[guid]->reference)
players[guid]->deleteReference(); playerList[guid]->deleteReference();
delete players[guid]; delete playerList[guid];
players.erase(guid); playerList.erase(guid);
} }
void PlayerList::cleanUp() void PlayerList::cleanUp()
{ {
for (auto &p : players) for (auto &playerEntry : playerList)
delete p.second; delete playerEntry.second;
} }
DedicatedPlayer *PlayerList::getPlayer(RakNet::RakNetGUID guid) DedicatedPlayer *PlayerList::getPlayer(RakNet::RakNetGUID guid)
{ {
return players[guid]; return playerList[guid];
} }
DedicatedPlayer *PlayerList::getPlayer(const MWWorld::Ptr &ptr) DedicatedPlayer *PlayerList::getPlayer(const MWWorld::Ptr &ptr)
{ {
for (auto &p : players) for (auto &playerEntry : playerList)
{ {
if (p.second == 0 || p.second->getPtr().mRef == 0) if (playerEntry.second == nullptr || playerEntry.second->getPtr().mRef == nullptr)
continue; continue;
string refId = ptr.getCellRef().getRefId(); string refId = ptr.getCellRef().getRefId();
if (p.second->getPtr().getCellRef().getRefId() == refId) if (playerEntry.second->getPtr().getCellRef().getRefId() == refId)
return p.second; return playerEntry.second;
} }
return 0;
return nullptr;
} }
bool PlayerList::isDedicatedPlayer(const MWWorld::Ptr &ptr) bool PlayerList::isDedicatedPlayer(const MWWorld::Ptr &ptr)
@ -89,12 +90,12 @@ bool PlayerList::isDedicatedPlayer(const MWWorld::Ptr &ptr)
if (ptr.getCellRef().getRefNum().mIndex != 0 || ptr.getCellRef().getMpNum() != 0) if (ptr.getCellRef().getRefNum().mIndex != 0 || ptr.getCellRef().getMpNum() != 0)
return false; return false;
return (getPlayer(ptr) != 0); return (getPlayer(ptr) != nullptr);
} }
void PlayerList::enableMarkers(const ESM::Cell& cell) void PlayerList::enableMarkers(const ESM::Cell& cell)
{ {
for (auto &playerEntry : players) for (auto &playerEntry : playerList)
{ {
if (playerEntry.second == nullptr || playerEntry.second->getPtr().mRef == nullptr) if (playerEntry.second == nullptr || playerEntry.second->getPtr().mRef == nullptr)
continue; continue;
@ -114,12 +115,12 @@ void PlayerList::enableMarkers(const ESM::Cell& cell)
*/ */
void PlayerList::clearHitAttemptActorId(int actorId) void PlayerList::clearHitAttemptActorId(int actorId)
{ {
for (auto &p : players) for (auto &playerEntry : playerList)
{ {
if (p.second == 0 || p.second->getPtr().mRef == 0) if (playerEntry.second == nullptr || playerEntry.second->getPtr().mRef == nullptr)
continue; continue;
MWMechanics::CreatureStats &playerCreatureStats = p.second->getPtr().getClass().getCreatureStats(p.second->getPtr()); MWMechanics::CreatureStats &playerCreatureStats = playerEntry.second->getPtr().getClass().getCreatureStats(playerEntry.second->getPtr());
if (playerCreatureStats.getHitAttemptActorId() == actorId) if (playerCreatureStats.getHitAttemptActorId() == actorId)
playerCreatureStats.setHitAttemptActorId(-1); playerCreatureStats.setHitAttemptActorId(-1);

View file

@ -43,7 +43,7 @@ namespace mwmp
private: private:
static std::map<RakNet::RakNetGUID, DedicatedPlayer *> players; static std::map<RakNet::RakNetGUID, DedicatedPlayer *> playerList;
}; };
} }