[Client] Clean up handling of draw states

0.7.0
David Cernat 6 years ago
parent 301fff7fe5
commit 77952440f6

@ -301,19 +301,23 @@ void Cell::readAttack(ActorList& actorList)
if (dedicatedActors.count(mapIndex) > 0) if (dedicatedActors.count(mapIndex) > 0)
{ {
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Reading ActorAttack about %s", mapIndex.c_str());
DedicatedActor *actor = dedicatedActors[mapIndex]; DedicatedActor *actor = dedicatedActors[mapIndex];
actor->attack = baseActor.attack; actor->attack = baseActor.attack;
// Set the correct drawState here if we've somehow we've missed a previous // Set the correct drawState here if we've somehow we've missed a previous
// AnimFlags packet // AnimFlags packet
if (actor->drawState != 1 && (actor->attack.type == mwmp::Attack::MELEE || actor->attack.type == mwmp::Attack::RANGED)) if (actor->drawState != MWMechanics::DrawState_::DrawState_Weapon &&
(actor->attack.type == mwmp::Attack::MELEE || actor->attack.type == mwmp::Attack::RANGED))
{ {
actor->drawState = 1; actor->drawState = MWMechanics::DrawState_::DrawState_Weapon;
actor->setAnimFlags(); actor->setAnimFlags();
} }
else if (actor->drawState != 2 && (actor->attack.type == mwmp::Attack::MAGIC || actor->attack.type == mwmp::Attack::ITEM_MAGIC)) else if (actor->drawState != MWMechanics::DrawState_::DrawState_Spell &&
(actor->attack.type == mwmp::Attack::MAGIC || actor->attack.type == mwmp::Attack::ITEM_MAGIC))
{ {
actor->drawState = 2; actor->drawState = MWMechanics::DrawState_::DrawState_Spell;
actor->setAnimFlags(); actor->setAnimFlags();
} }

@ -35,7 +35,7 @@ using namespace std;
DedicatedActor::DedicatedActor() DedicatedActor::DedicatedActor()
{ {
drawState = 0; drawState = MWMechanics::DrawState_::DrawState_Nothing;
movementFlags = 0; movementFlags = 0;
animation.groupname = ""; animation.groupname = "";
sound = ""; sound = "";
@ -133,12 +133,7 @@ void DedicatedActor::setAnimFlags()
MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr); MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr);
if (drawState == 0) ptrCreatureStats->setDrawState(static_cast<MWMechanics::DrawState_>(drawState));
ptrCreatureStats->setDrawState(DrawState_Nothing);
else if (drawState == 1)
ptrCreatureStats->setDrawState(DrawState_Weapon);
else if (drawState == 2)
ptrCreatureStats->setDrawState(DrawState_Spell);
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0); ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0);
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0); ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0);

@ -258,14 +258,10 @@ void DedicatedPlayer::setAnimFlags()
cast.cast("Levitate"); cast.cast("Levitate");
} }
if (drawState == 0)
ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Nothing);
else if (drawState == 1)
ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Weapon);
else if (drawState == 2)
ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Spell);
MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr); MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr);
ptrCreatureStats->setDrawState(static_cast<MWMechanics::DrawState_>(drawState));
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0); ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0);
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0); ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0);
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceJump, (movementFlags & CreatureStats::Flag_ForceJump) != 0); ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceJump, (movementFlags & CreatureStats::Flag_ForceJump) != 0);

@ -629,12 +629,12 @@ void LocalPlayer::updateAnimFlags(bool forceUpdate)
static bool wasJumping = false; static bool wasJumping = false;
static bool wasFlying = false; static bool wasFlying = false;
MWMechanics::DrawState_ currentDrawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState(); drawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState();
static MWMechanics::DrawState_ lastDrawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState(); static char lastDrawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState();
if (wasRunning != isRunning || if (wasRunning != isRunning ||
wasSneaking != isSneaking || wasForceJumping != isForceJumping || wasSneaking != isSneaking || wasForceJumping != isForceJumping ||
wasForceMoveJumping != isForceMoveJumping || lastDrawState != currentDrawState || wasForceMoveJumping != isForceMoveJumping || lastDrawState != drawState ||
wasJumping || isJumping || wasFlying != isFlying || wasJumping || isJumping || wasFlying != isFlying ||
forceUpdate) forceUpdate)
{ {
@ -642,7 +642,7 @@ void LocalPlayer::updateAnimFlags(bool forceUpdate)
wasRunning = isRunning; wasRunning = isRunning;
wasForceJumping = isForceJumping; wasForceJumping = isForceJumping;
wasForceMoveJumping = isForceMoveJumping; wasForceMoveJumping = isForceMoveJumping;
lastDrawState = currentDrawState; lastDrawState = drawState;
wasFlying = isFlying; wasFlying = isFlying;
wasJumping = isJumping; wasJumping = isJumping;
@ -659,13 +659,6 @@ void LocalPlayer::updateAnimFlags(bool forceUpdate)
#undef __SETFLAG #undef __SETFLAG
if (currentDrawState == MWMechanics::DrawState_Nothing)
drawState = 0;
else if (currentDrawState == MWMechanics::DrawState_Weapon)
drawState = 1;
else if (currentDrawState == MWMechanics::DrawState_Spell)
drawState = 2;
if (isJumping) if (isJumping)
updatePosition(true); // fix position after jump; updatePosition(true); // fix position after jump;

Loading…
Cancel
Save