mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:23:52 +00:00
[Server] Clean up ActorFunctions by using readActorList pointer
Also rename scriptActorList into writeActorList, and also rename matching methods, for clarity.
This commit is contained in:
parent
b54560a362
commit
0e8d115794
2 changed files with 53 additions and 45 deletions
|
@ -12,124 +12,130 @@
|
|||
|
||||
using namespace mwmp;
|
||||
|
||||
BaseActorList scriptActorList;
|
||||
BaseActorList *readActorList;
|
||||
BaseActorList writeActorList;
|
||||
|
||||
BaseActor tempActor;
|
||||
const BaseActor emptyActor = {};
|
||||
|
||||
static std::string tempCellDescription;
|
||||
|
||||
void ActorFunctions::InitScriptActorList(unsigned short pid) noexcept
|
||||
void ActorFunctions::ReadLastActorList() noexcept
|
||||
{
|
||||
readActorList = mwmp::Networking::getPtr()->getLastActorList();
|
||||
}
|
||||
|
||||
void ActorFunctions::InitializeActorList(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
scriptActorList.cell.blank();
|
||||
scriptActorList.baseActors.clear();
|
||||
scriptActorList.guid = player->guid;
|
||||
writeActorList.cell.blank();
|
||||
writeActorList.baseActors.clear();
|
||||
writeActorList.guid = player->guid;
|
||||
|
||||
tempActor.creatureStats = new ESM::CreatureStats();
|
||||
}
|
||||
|
||||
unsigned int ActorFunctions::GetActorListSize() noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->count;
|
||||
return readActorList->count;
|
||||
}
|
||||
|
||||
unsigned char ActorFunctions::GetLastActorListAction() noexcept
|
||||
unsigned char ActorFunctions::GetActorListAction() noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->action;
|
||||
return readActorList->action;
|
||||
}
|
||||
|
||||
const char *ActorFunctions::GetActorCell(unsigned int i) noexcept
|
||||
{
|
||||
tempCellDescription = mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).cell.getDescription();
|
||||
tempCellDescription = readActorList->baseActors.at(i).cell.getDescription();
|
||||
return tempCellDescription.c_str();
|
||||
}
|
||||
|
||||
const char *ActorFunctions::GetActorRefId(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).refId.c_str();
|
||||
return readActorList->baseActors.at(i).refId.c_str();
|
||||
}
|
||||
|
||||
int ActorFunctions::GetActorRefNumIndex(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).refNumIndex;
|
||||
return readActorList->baseActors.at(i).refNumIndex;
|
||||
}
|
||||
|
||||
int ActorFunctions::GetActorMpNum(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).mpNum;
|
||||
return readActorList->baseActors.at(i).mpNum;
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorPosX(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.pos[0];
|
||||
return readActorList->baseActors.at(i).position.pos[0];
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorPosY(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.pos[1];
|
||||
return readActorList->baseActors.at(i).position.pos[1];
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorPosZ(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.pos[2];
|
||||
return readActorList->baseActors.at(i).position.pos[2];
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorRotX(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.rot[0];
|
||||
return readActorList->baseActors.at(i).position.rot[0];
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorRotY(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.rot[1];
|
||||
return readActorList->baseActors.at(i).position.rot[1];
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorRotZ(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.rot[2];
|
||||
return readActorList->baseActors.at(i).position.rot[2];
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorHealthBase(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).creatureStats->mDynamic[0].mBase;
|
||||
return readActorList->baseActors.at(i).creatureStats->mDynamic[0].mBase;
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorHealthCurrent(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).creatureStats->mDynamic[0].mCurrent;
|
||||
return readActorList->baseActors.at(i).creatureStats->mDynamic[0].mCurrent;
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorMagickaBase(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).creatureStats->mDynamic[1].mBase;
|
||||
return readActorList->baseActors.at(i).creatureStats->mDynamic[1].mBase;
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorMagickaCurrent(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).creatureStats->mDynamic[1].mCurrent;
|
||||
return readActorList->baseActors.at(i).creatureStats->mDynamic[1].mCurrent;
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorFatigueBase(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).creatureStats->mDynamic[2].mBase;
|
||||
return readActorList->baseActors.at(i).creatureStats->mDynamic[2].mBase;
|
||||
}
|
||||
|
||||
double ActorFunctions::GetActorFatigueCurrent(unsigned int i) noexcept
|
||||
{
|
||||
return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).creatureStats->mDynamic[2].mCurrent;
|
||||
return readActorList->baseActors.at(i).creatureStats->mDynamic[2].mCurrent;
|
||||
}
|
||||
|
||||
void ActorFunctions::SetScriptActorListCell(const char* cellDescription) noexcept
|
||||
void ActorFunctions::SetActorListCell(const char* cellDescription) noexcept
|
||||
{
|
||||
scriptActorList.cell = Utils::getCellFromDescription(cellDescription);
|
||||
writeActorList.cell = Utils::getCellFromDescription(cellDescription);
|
||||
}
|
||||
|
||||
void ActorFunctions::SetScriptActorListAction(unsigned char action) noexcept
|
||||
void ActorFunctions::SetActorListAction(unsigned char action) noexcept
|
||||
{
|
||||
scriptActorList.action = action;
|
||||
writeActorList.action = action;
|
||||
}
|
||||
|
||||
void ActorFunctions::SetActorCell(const char* cellDescription) noexcept
|
||||
|
@ -198,7 +204,7 @@ void ActorFunctions::SetActorFatigueCurrent(double value) noexcept
|
|||
|
||||
void ActorFunctions::AddActor() noexcept
|
||||
{
|
||||
scriptActorList.baseActors.push_back(tempActor);
|
||||
writeActorList.baseActors.push_back(tempActor);
|
||||
|
||||
tempActor = emptyActor;
|
||||
tempActor.creatureStats = new ESM::CreatureStats();
|
||||
|
@ -206,25 +212,25 @@ void ActorFunctions::AddActor() noexcept
|
|||
|
||||
void ActorFunctions::SendActorList() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->setActorList(&scriptActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->Send(scriptActorList.guid);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->setActorList(&writeActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->Send(writeActorList.guid);
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorAuthority() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->setActorList(&scriptActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->Send(scriptActorList.guid);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->setActorList(&writeActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->Send(writeActorList.guid);
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorStatsDynamic() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC)->setActorList(&scriptActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC)->Send(scriptActorList.guid);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC)->setActorList(&writeActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC)->Send(writeActorList.guid);
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorCellChange() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->setActorList(&scriptActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->Send(scriptActorList.guid);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->setActorList(&writeActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->Send(writeActorList.guid);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
#define OPENMW_ACTORAPI_HPP
|
||||
|
||||
#define ACTORAPI \
|
||||
{"InitScriptActorList", ActorFunctions::InitScriptActorList},\
|
||||
{"ReadLastActorList", ActorFunctions::ReadLastActorList},\
|
||||
{"InitializeActorList", ActorFunctions::InitializeActorList},\
|
||||
\
|
||||
{"GetActorListSize", ActorFunctions::GetActorListSize},\
|
||||
{"GetLastActorListAction", ActorFunctions::GetLastActorListAction},\
|
||||
{"GetActorListAction", ActorFunctions::GetActorListAction},\
|
||||
\
|
||||
{"GetActorCell", ActorFunctions::GetActorCell},\
|
||||
{"GetActorRefId", ActorFunctions::GetActorRefId},\
|
||||
|
@ -26,8 +27,8 @@
|
|||
{"GetActorFatigueBase", ActorFunctions::GetActorFatigueBase},\
|
||||
{"GetActorFatigueCurrent", ActorFunctions::GetActorFatigueCurrent},\
|
||||
\
|
||||
{"SetScriptActorListCell", ActorFunctions::SetScriptActorListCell},\
|
||||
{"SetScriptActorListAction", ActorFunctions::SetScriptActorListAction},\
|
||||
{"SetActorListCell", ActorFunctions::SetActorListCell},\
|
||||
{"SetActorListAction", ActorFunctions::SetActorListAction},\
|
||||
\
|
||||
{"SetActorCell", ActorFunctions::SetActorCell},\
|
||||
{"SetActorRefId", ActorFunctions::SetActorRefId},\
|
||||
|
@ -55,10 +56,11 @@ class ActorFunctions
|
|||
{
|
||||
public:
|
||||
|
||||
static void InitScriptActorList(unsigned short pid) noexcept;
|
||||
static void ReadLastActorList() noexcept;
|
||||
static void InitializeActorList(unsigned short pid) noexcept;
|
||||
|
||||
static unsigned int GetActorListSize() noexcept;
|
||||
static unsigned char GetLastActorListAction() noexcept;
|
||||
static unsigned char GetActorListAction() noexcept;
|
||||
|
||||
static const char *GetActorCell(unsigned int i) noexcept;
|
||||
static const char *GetActorRefId(unsigned int i) noexcept;
|
||||
|
@ -79,8 +81,8 @@ public:
|
|||
static double GetActorFatigueBase(unsigned int i) noexcept;
|
||||
static double GetActorFatigueCurrent(unsigned int i) noexcept;
|
||||
|
||||
static void SetScriptActorListCell(const char* cellDescription) noexcept;
|
||||
static void SetScriptActorListAction(unsigned char action) noexcept;
|
||||
static void SetActorListCell(const char* cellDescription) noexcept;
|
||||
static void SetActorListAction(unsigned char action) noexcept;
|
||||
|
||||
static void SetActorCell(const char* cellDescription) noexcept;
|
||||
static void SetActorRefId(const char* refId) noexcept;
|
||||
|
|
Loading…
Reference in a new issue