1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-29 22:45:34 +00:00

[General] Use new SimpleCreatureStats struct in BaseActor

This commit is contained in:
David Cernat 2017-04-30 18:44:59 +03:00
parent 0e8d115794
commit e8e0090b9b
7 changed files with 28 additions and 36 deletions

View file

@ -33,8 +33,6 @@ void ActorFunctions::InitializeActorList(unsigned short pid) noexcept
writeActorList.cell.blank();
writeActorList.baseActors.clear();
writeActorList.guid = player->guid;
tempActor.creatureStats = new ESM::CreatureStats();
}
unsigned int ActorFunctions::GetActorListSize() noexcept
@ -100,32 +98,32 @@ double ActorFunctions::GetActorRotZ(unsigned int i) noexcept
double ActorFunctions::GetActorHealthBase(unsigned int i) noexcept
{
return readActorList->baseActors.at(i).creatureStats->mDynamic[0].mBase;
return readActorList->baseActors.at(i).creatureStats.mDynamic[0].mBase;
}
double ActorFunctions::GetActorHealthCurrent(unsigned int i) noexcept
{
return readActorList->baseActors.at(i).creatureStats->mDynamic[0].mCurrent;
return readActorList->baseActors.at(i).creatureStats.mDynamic[0].mCurrent;
}
double ActorFunctions::GetActorMagickaBase(unsigned int i) noexcept
{
return readActorList->baseActors.at(i).creatureStats->mDynamic[1].mBase;
return readActorList->baseActors.at(i).creatureStats.mDynamic[1].mBase;
}
double ActorFunctions::GetActorMagickaCurrent(unsigned int i) noexcept
{
return readActorList->baseActors.at(i).creatureStats->mDynamic[1].mCurrent;
return readActorList->baseActors.at(i).creatureStats.mDynamic[1].mCurrent;
}
double ActorFunctions::GetActorFatigueBase(unsigned int i) noexcept
{
return readActorList->baseActors.at(i).creatureStats->mDynamic[2].mBase;
return readActorList->baseActors.at(i).creatureStats.mDynamic[2].mBase;
}
double ActorFunctions::GetActorFatigueCurrent(unsigned int i) noexcept
{
return readActorList->baseActors.at(i).creatureStats->mDynamic[2].mCurrent;
return readActorList->baseActors.at(i).creatureStats.mDynamic[2].mCurrent;
}
void ActorFunctions::SetActorListCell(const char* cellDescription) noexcept
@ -174,32 +172,32 @@ void ActorFunctions::SetActorRotation(double x, double y, double z) noexcept
void ActorFunctions::SetActorHealthBase(double value) noexcept
{
tempActor.creatureStats->mDynamic[0].mBase = value;
tempActor.creatureStats.mDynamic[0].mBase = value;
}
void ActorFunctions::SetActorHealthCurrent(double value) noexcept
{
tempActor.creatureStats->mDynamic[0].mCurrent = value;
tempActor.creatureStats.mDynamic[0].mCurrent = value;
}
void ActorFunctions::SetActorMagickaBase(double value) noexcept
{
tempActor.creatureStats->mDynamic[1].mBase = value;
tempActor.creatureStats.mDynamic[1].mBase = value;
}
void ActorFunctions::SetActorMagickaCurrent(double value) noexcept
{
tempActor.creatureStats->mDynamic[1].mCurrent = value;
tempActor.creatureStats.mDynamic[1].mCurrent = value;
}
void ActorFunctions::SetActorFatigueBase(double value) noexcept
{
tempActor.creatureStats->mDynamic[2].mBase = value;
tempActor.creatureStats.mDynamic[2].mBase = value;
}
void ActorFunctions::SetActorFatigueCurrent(double value) noexcept
{
tempActor.creatureStats->mDynamic[2].mCurrent = value;
tempActor.creatureStats.mDynamic[2].mCurrent = value;
}
void ActorFunctions::AddActor() noexcept
@ -207,7 +205,6 @@ void ActorFunctions::AddActor() noexcept
writeActorList.baseActors.push_back(tempActor);
tempActor = emptyActor;
tempActor.creatureStats = new ESM::CreatureStats();
}
void ActorFunctions::SendActorList() noexcept

View file

@ -326,7 +326,6 @@ void Cell::uninitializeLocalActors()
for (std::map<std::string, LocalActor *>::iterator it = localActors.begin(); it != localActors.end(); ++it)
{
Main::get().getCellController()->removeLocalActorRecord(it->first);
delete it->second->creatureStats;
delete it->second;
}
@ -338,7 +337,6 @@ void Cell::uninitializeDedicatedActors()
for (std::map<std::string, DedicatedActor *>::iterator it = dedicatedActors.begin(); it != dedicatedActors.end(); ++it)
{
Main::get().getCellController()->removeDedicatedActorRecord(it->first);
delete it->second->creatureStats;
delete it->second;
}

View file

@ -29,9 +29,6 @@ DedicatedActor::DedicatedActor()
animation.groupname = "";
sound = "";
creatureStats = new ESM::CreatureStats();
creatureStats->blank();
hasStatsDynamicData = false;
hasChangedCell = true;
@ -145,7 +142,7 @@ void DedicatedActor::setStatsDynamic()
for (int i = 0; i < 3; ++i)
{
value.readState(creatureStats->mDynamic[i]);
value.readState(creatureStats.mDynamic[i]);
ptrCreatureStats->setDynamic(i, value);
}
}

View file

@ -32,8 +32,6 @@ LocalActor::LocalActor()
attack.type = Attack::MELEE;
attack.shouldSend = false;
creatureStats = new ESM::CreatureStats();
}
LocalActor::~LocalActor()
@ -165,9 +163,9 @@ void LocalActor::updateStatsDynamic(bool forceUpdate)
oldMagicka = magicka;
oldFatigue = fatigue;
health.writeState(creatureStats->mDynamic[0]);
magicka.writeState(creatureStats->mDynamic[1]);
fatigue.writeState(creatureStats->mDynamic[2]);
health.writeState(creatureStats.mDynamic[0]);
magicka.writeState(creatureStats.mDynamic[1]);
fatigue.writeState(creatureStats.mDynamic[2]);
statTimer = 0;

View file

@ -2,7 +2,6 @@
#define OPENMW_BASEACTOR_HPP
#include <components/esm/loadcell.hpp>
#include <components/esm/creaturestats.hpp>
#include <components/openmw-mp/Base/BaseStructs.hpp>
@ -28,8 +27,6 @@ namespace mwmp
ESM::Cell cell;
ESM::CreatureStats *creatureStats;
unsigned int movementFlags;
char drawState;
bool isFlying;
@ -37,6 +34,8 @@ namespace mwmp
std::string response;
std::string sound;
SimpleCreatureStats creatureStats;
Animation animation;
Attack attack;
};

View file

@ -1,6 +1,8 @@
#ifndef OPENMW_BASESTRUCTS_HPP
#define OPENMW_BASESTRUCTS_HPP
#include <components/esm/statstate.hpp>
#include <RakNetTypes.h>
namespace mwmp
@ -48,6 +50,11 @@ namespace mwmp
int count;
bool persist;
};
struct SimpleCreatureStats
{
ESM::StatState<float> mDynamic[3];
};
}
#endif //OPENMW_BASESTRUCTS_HPP

View file

@ -34,18 +34,14 @@ void PacketActorStatsDynamic::Packet(RakNet::BitStream *bs, bool send)
{
actor = actorList->baseActors.at(i);
}
else
{
actor.creatureStats = new ESM::CreatureStats();
}
RW(actor.refId, send);
RW(actor.refNumIndex, send);
RW(actor.mpNum, send);
RW(actor.creatureStats->mDynamic[0], send); // health
RW(actor.creatureStats->mDynamic[1], send); // magic
RW(actor.creatureStats->mDynamic[2], send); // fatigue
RW(actor.creatureStats.mDynamic[0], send); // health
RW(actor.creatureStats.mDynamic[1], send); // magic
RW(actor.creatureStats.mDynamic[2], send); // fatigue
if (!send)
{