mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 07:32:00 -04:00
[Client] Update PlayerList to C++11
This commit is contained in:
parent
a110ec1767
commit
08666cabdb
@ -25,9 +25,9 @@ std::map <RakNet::RakNetGUID, DedicatedPlayer *> PlayerList::players;
|
|||||||
|
|
||||||
void PlayerList::update(float dt)
|
void PlayerList::update(float dt)
|
||||||
{
|
{
|
||||||
for (std::map <RakNet::RakNetGUID, DedicatedPlayer *>::iterator it = players.begin(); it != players.end(); it++)
|
for (auto &p : players)
|
||||||
{
|
{
|
||||||
DedicatedPlayer *player = it->second;
|
DedicatedPlayer *player = p.second;
|
||||||
if (player == 0) continue;
|
if (player == 0) continue;
|
||||||
|
|
||||||
player->update(dt);
|
player->update(dt);
|
||||||
@ -165,8 +165,6 @@ void PlayerList::createPlayer(RakNet::RakNetGUID guid)
|
|||||||
LOG_APPEND(Log::LOG_INFO, "- Deleting NPC record");
|
LOG_APPEND(Log::LOG_INFO, "- Deleting NPC record");
|
||||||
npc_store->erase(npc.mId);
|
npc_store->erase(npc.mId);
|
||||||
npc.mId.clear();
|
npc.mId.clear();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
creature.mId = players[guid]->ptr.get<ESM::Creature>()->mBase->mId;
|
creature.mId = players[guid]->ptr.get<ESM::Creature>()->mBase->mId;
|
||||||
creature_store->insert(creature);
|
creature_store->insert(creature);
|
||||||
@ -233,8 +231,8 @@ void PlayerList::disconnectPlayer(RakNet::RakNetGUID guid)
|
|||||||
|
|
||||||
void PlayerList::cleanUp()
|
void PlayerList::cleanUp()
|
||||||
{
|
{
|
||||||
for (std::map <RakNet::RakNetGUID, DedicatedPlayer *>::iterator it = players.begin(); it != players.end(); it++)
|
for (auto &p : players)
|
||||||
delete it->second;
|
delete p.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
DedicatedPlayer *PlayerList::getPlayer(RakNet::RakNetGUID guid)
|
DedicatedPlayer *PlayerList::getPlayer(RakNet::RakNetGUID guid)
|
||||||
@ -244,15 +242,13 @@ DedicatedPlayer *PlayerList::getPlayer(RakNet::RakNetGUID guid)
|
|||||||
|
|
||||||
DedicatedPlayer *PlayerList::getPlayer(const MWWorld::Ptr &ptr)
|
DedicatedPlayer *PlayerList::getPlayer(const MWWorld::Ptr &ptr)
|
||||||
{
|
{
|
||||||
std::map <RakNet::RakNetGUID, DedicatedPlayer *>::iterator it = players.begin();
|
for (auto &p : players)
|
||||||
|
|
||||||
for (; it != players.end(); it++)
|
|
||||||
{
|
{
|
||||||
if (it->second == 0 || it->second->getPtr().mRef == 0)
|
if (p.second == 0 || p.second->getPtr().mRef == 0)
|
||||||
continue;
|
continue;
|
||||||
string refid = ptr.getCellRef().getRefId();
|
string refid = ptr.getCellRef().getRefId();
|
||||||
if (it->second->getPtr().getCellRef().getRefId() == refid)
|
if (p.second->getPtr().getCellRef().getRefId() == refid)
|
||||||
return it->second;
|
return p.second;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -273,14 +269,14 @@ bool PlayerList::isDedicatedPlayer(const MWWorld::Ptr &ptr)
|
|||||||
*/
|
*/
|
||||||
void PlayerList::clearHitAttemptActorId(int actorId)
|
void PlayerList::clearHitAttemptActorId(int actorId)
|
||||||
{
|
{
|
||||||
for (std::map <RakNet::RakNetGUID, DedicatedPlayer *>::iterator it = players.begin(); it != players.end(); it++)
|
for (auto &p : players)
|
||||||
{
|
{
|
||||||
if (it->second == 0 || it->second->getPtr().mRef == 0)
|
if (p.second == 0 || p.second->getPtr().mRef == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MWMechanics::CreatureStats *playerCreatureStats = &it->second->getPtr().getClass().getCreatureStats(it->second->getPtr());
|
MWMechanics::CreatureStats &playerCreatureStats = p.second->getPtr().getClass().getCreatureStats(p.second->getPtr());
|
||||||
|
|
||||||
if (playerCreatureStats->getHitAttemptActorId() == actorId)
|
if (playerCreatureStats.getHitAttemptActorId() == actorId)
|
||||||
playerCreatureStats->setHitAttemptActorId(-1);
|
playerCreatureStats.setHitAttemptActorId(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user