1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 18:06:43 +00:00

[Client] Reorder methods and don't set variables that are no longer used

This commit is contained in:
David Cernat 2017-04-08 10:58:25 +03:00
parent d3f3fb5d05
commit f52fc19762
3 changed files with 53 additions and 54 deletions

View file

@ -52,11 +52,11 @@ void Cell::updateLocal()
worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex; worldObject.refNumIndex = ptr.getCellRef().getRefNum().mIndex;
worldObject.mpNum = ptr.getCellRef().getMpNum(); worldObject.mpNum = ptr.getCellRef().getMpNum();
worldObject.pos = actor->position; worldObject.pos = actor->position;
worldObject.direction = actor->direction;
worldObject.drawState = actor->drawState; worldObject.drawState = actor->drawState;
worldObject.movementFlags = actor->movementFlags;
worldObject.headPitch = actor->headPitch; worldObject.headPitch = actor->headPitch;
worldObject.headYaw = actor->headYaw; worldObject.headYaw = actor->headYaw;
worldObject.hasAnimation = actor->hasAnimation; worldObject.hasAnimation = actor->hasAnimation;
worldObject.hasAnimStates = actor->hasAnimStates; worldObject.hasAnimStates = actor->hasAnimStates;
worldObject.hasMovement = actor->hasMovement; worldObject.hasMovement = actor->hasMovement;
@ -101,6 +101,61 @@ void Cell::updateDedicated(float dt)
} }
} }
void Cell::readCellFrame(WorldEvent& worldEvent)
{
WorldObject worldObject;
for (unsigned int i = 0; i < worldEvent.objectChanges.count; i++)
{
worldObject = worldEvent.objectChanges.objects.at(i);
std::string mapIndex = Main::get().getCellController()->generateMapIndex(worldObject);
// If this key doesn't exist, create it
if (dedicatedActors.count(mapIndex) == 0)
{
MWWorld::Ptr ptrFound = store->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
if (!ptrFound) return;
DedicatedActor *actor = new DedicatedActor();
actor->cell = worldEvent.cell;
actor->setPtr(ptrFound);
dedicatedActors[mapIndex] = actor;
Main::get().getCellController()->setDedicatedActorRecord(mapIndex, getDescription());
LOG_APPEND(Log::LOG_INFO, "- Initialized DedicatedActor %s", mapIndex.c_str());
}
// If this now exists, set its details
if (dedicatedActors.count(mapIndex) > 0)
{
DedicatedActor *actor = dedicatedActors[mapIndex];
actor->position = worldObject.pos;
actor->drawState = worldObject.drawState;
actor->hasAnimation = worldObject.hasAnimation;
actor->hasAnimStates = worldObject.hasAnimStates;
actor->hasMovement = worldObject.hasMovement;
if (actor->hasAnimation)
{
actor->animation = worldObject.animation;
}
if (actor->hasAnimStates)
{
actor->animStates = worldObject.animStates;
}
if (actor->hasMovement)
{
actor->movement = worldObject.movement;
}
}
}
}
void Cell::initializeLocalActors() void Cell::initializeLocalActors()
{ {
ESM::Cell esmCell = *store->getCell(); ESM::Cell esmCell = *store->getCell();
@ -148,62 +203,6 @@ void Cell::uninitializeDedicatedActors()
dedicatedActors.clear(); dedicatedActors.clear();
} }
void Cell::readCellFrame(WorldEvent& worldEvent)
{
WorldObject worldObject;
for (unsigned int i = 0; i < worldEvent.objectChanges.count; i++)
{
worldObject = worldEvent.objectChanges.objects.at(i);
std::string mapIndex = Main::get().getCellController()->generateMapIndex(worldObject);
// If this key doesn't exist, create it
if (dedicatedActors.count(mapIndex) == 0)
{
MWWorld::Ptr ptrFound = store->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
if (!ptrFound) return;
DedicatedActor *actor = new DedicatedActor();
actor->cell = worldEvent.cell;
actor->setPtr(ptrFound);
dedicatedActors[mapIndex] = actor;
Main::get().getCellController()->setDedicatedActorRecord(mapIndex, getDescription());
LOG_APPEND(Log::LOG_INFO, "- Initialized DedicatedActor %s", mapIndex.c_str());
}
// If this now exists, set its details
if (dedicatedActors.count(mapIndex) > 0)
{
DedicatedActor *actor = dedicatedActors[mapIndex];
actor->position = worldObject.pos;
actor->direction = worldObject.direction;
actor->drawState = worldObject.drawState;
actor->movementFlags = worldObject.movementFlags;
actor->hasAnimation = worldObject.hasAnimation;
actor->hasAnimStates = worldObject.hasAnimStates;
actor->hasMovement = worldObject.hasMovement;
if (actor->hasAnimation)
{
actor->animation = worldObject.animation;
}
if (actor->hasAnimStates)
{
actor->animStates = worldObject.animStates;
}
if (actor->hasMovement)
{
actor->movement = worldObject.movement;
}
}
}
}
LocalActor *Cell::getLocalActor(std::string actorIndex) LocalActor *Cell::getLocalActor(std::string actorIndex)
{ {
return localActors.at(actorIndex); return localActors.at(actorIndex);

View file

@ -18,12 +18,12 @@ namespace mwmp
void updateLocal(); void updateLocal();
void updateDedicated(float dt); void updateDedicated(float dt);
void readCellFrame(mwmp::WorldEvent& worldEvent);
void initializeLocalActors(); void initializeLocalActors();
void uninitializeLocalActors(); void uninitializeLocalActors();
void uninitializeDedicatedActors(); void uninitializeDedicatedActors();
void readCellFrame(mwmp::WorldEvent& worldEvent);
virtual LocalActor *getLocalActor(std::string actorIndex); virtual LocalActor *getLocalActor(std::string actorIndex);
virtual DedicatedActor *getDedicatedActor(std::string actorIndex); virtual DedicatedActor *getDedicatedActor(std::string actorIndex);

View file

@ -15,7 +15,7 @@ using namespace std;
DedicatedActor::DedicatedActor() DedicatedActor::DedicatedActor()
{ {
movementFlags = 0;
} }
DedicatedActor::~DedicatedActor() DedicatedActor::~DedicatedActor()