mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
[Client] Clean up handling of draw states
This commit is contained in:
parent
301fff7fe5
commit
77952440f6
4 changed files with 17 additions and 29 deletions
|
@ -301,19 +301,23 @@ void Cell::readAttack(ActorList& actorList)
|
|||
|
||||
if (dedicatedActors.count(mapIndex) > 0)
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Reading ActorAttack about %s", mapIndex.c_str());
|
||||
|
||||
DedicatedActor *actor = dedicatedActors[mapIndex];
|
||||
actor->attack = baseActor.attack;
|
||||
|
||||
// Set the correct drawState here if we've somehow we've missed a previous
|
||||
// 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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ using namespace std;
|
|||
|
||||
DedicatedActor::DedicatedActor()
|
||||
{
|
||||
drawState = 0;
|
||||
drawState = MWMechanics::DrawState_::DrawState_Nothing;
|
||||
movementFlags = 0;
|
||||
animation.groupname = "";
|
||||
sound = "";
|
||||
|
@ -133,12 +133,7 @@ void DedicatedActor::setAnimFlags()
|
|||
|
||||
MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr);
|
||||
|
||||
if (drawState == 0)
|
||||
ptrCreatureStats->setDrawState(DrawState_Nothing);
|
||||
else if (drawState == 1)
|
||||
ptrCreatureStats->setDrawState(DrawState_Weapon);
|
||||
else if (drawState == 2)
|
||||
ptrCreatureStats->setDrawState(DrawState_Spell);
|
||||
ptrCreatureStats->setDrawState(static_cast<MWMechanics::DrawState_>(drawState));
|
||||
|
||||
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0);
|
||||
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0);
|
||||
|
|
|
@ -258,14 +258,10 @@ void DedicatedPlayer::setAnimFlags()
|
|||
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);
|
||||
|
||||
ptrCreatureStats->setDrawState(static_cast<MWMechanics::DrawState_>(drawState));
|
||||
|
||||
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0);
|
||||
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 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 wasFlying = false;
|
||||
|
||||
MWMechanics::DrawState_ currentDrawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState();
|
||||
static MWMechanics::DrawState_ lastDrawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState();
|
||||
drawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState();
|
||||
static char lastDrawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState();
|
||||
|
||||
if (wasRunning != isRunning ||
|
||||
wasSneaking != isSneaking || wasForceJumping != isForceJumping ||
|
||||
wasForceMoveJumping != isForceMoveJumping || lastDrawState != currentDrawState ||
|
||||
wasForceMoveJumping != isForceMoveJumping || lastDrawState != drawState ||
|
||||
wasJumping || isJumping || wasFlying != isFlying ||
|
||||
forceUpdate)
|
||||
{
|
||||
|
@ -642,7 +642,7 @@ void LocalPlayer::updateAnimFlags(bool forceUpdate)
|
|||
wasRunning = isRunning;
|
||||
wasForceJumping = isForceJumping;
|
||||
wasForceMoveJumping = isForceMoveJumping;
|
||||
lastDrawState = currentDrawState;
|
||||
lastDrawState = drawState;
|
||||
|
||||
wasFlying = isFlying;
|
||||
wasJumping = isJumping;
|
||||
|
@ -659,13 +659,6 @@ void LocalPlayer::updateAnimFlags(bool forceUpdate)
|
|||
|
||||
#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)
|
||||
updatePosition(true); // fix position after jump;
|
||||
|
||||
|
|
Loading…
Reference in a new issue