[Server] Bring Actor functions in line with Object functions, part 1

The last received ActorList can now be copied into the write-only ActorList that can be sent in packets. Changing the pid of the write-only ActorList can now be done separately from clearing its contents.
remotes/1728160796594174844/tmp_0.7.0-alpha
David Cernat 7 years ago
parent f0d4f1bbe5
commit 8f745df055

@ -32,16 +32,25 @@ void ActorFunctions::ReadCellActorList(const char* cellDescription) noexcept
readActorList = serverCell->getActorList();
}
void ActorFunctions::InitializeActorList(unsigned short pid) noexcept
void ActorFunctions::ClearActorList() noexcept
{
writeActorList.cell.blank();
writeActorList.baseActors.clear();
}
void ActorFunctions::SetActorListPid(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
writeActorList.cell.blank();
writeActorList.baseActors.clear();
writeActorList.guid = player->guid;
}
void ActorFunctions::CopyLastActorListToStore() noexcept
{
writeActorList = *readActorList;
}
unsigned int ActorFunctions::GetActorListSize() noexcept
{
return readActorList->count;
@ -439,3 +448,10 @@ void ActorFunctions::SendActorCellChange() noexcept
actorPacket->Send(writeActorList.guid);
}
// All methods below are deprecated versions of methods from above
void ActorFunctions::InitializeActorList(unsigned short pid) noexcept
{
ClearActorList();
SetActorListPid(pid);
}

@ -4,7 +4,11 @@
#define ACTORAPI \
{"ReadLastActorList", ActorFunctions::ReadLastActorList},\
{"ReadCellActorList", ActorFunctions::ReadCellActorList},\
{"InitializeActorList", ActorFunctions::InitializeActorList},\
\
{"ClearActorList", ActorFunctions::ClearActorList},\
{"SetActorListPid", ActorFunctions::SetActorListPid},\
\
{"CopyLastActorListToStore", ActorFunctions::CopyLastActorListToStore},\
\
{"GetActorListSize", ActorFunctions::GetActorListSize},\
{"GetActorListAction", ActorFunctions::GetActorListAction},\
@ -86,7 +90,9 @@
{"SendActorStatsDynamic", ActorFunctions::SendActorStatsDynamic},\
{"SendActorEquipment", ActorFunctions::SendActorEquipment},\
{"SendActorAI", ActorFunctions::SendActorAI},\
{"SendActorCellChange", ActorFunctions::SendActorCellChange}
{"SendActorCellChange", ActorFunctions::SendActorCellChange},\
\
{"InitializeActorList", ActorFunctions::InitializeActorList}
class ActorFunctions
{
@ -113,12 +119,26 @@ public:
/**
* \brief Clear the data from the last actor list sent by the server.
*
* This is used to initialize the sending of new Actor packets.
* \return void
*/
static void ClearActorList() noexcept;
/**
* \brief Set the pid attached to the ActorList.
*
* \param pid The player ID to whom the actor list should be attached.
* \return void
*/
static void InitializeActorList(unsigned short pid) noexcept;
static void SetActorListPid(unsigned short pid) noexcept;
/**
* \brief Take the contents of the read-only actor list last received by the
* server from a player and move its contents to the stored object list
* that can be sent by the server.
*
* \return void
*/
static void CopyLastActorListToStore() noexcept;
/**
* \brief Get the number of indexes in the read actor list.
@ -704,6 +724,11 @@ public:
* \return void
*/
static void SendActorCellChange() noexcept;
// All methods below are deprecated versions of methods from above
static void InitializeActorList(unsigned short pid) noexcept;
};

Loading…
Cancel
Save