summaryrefslogtreecommitdiff
path: root/src/hexen/p_enemy.c
diff options
context:
space:
mode:
authorSimon Howard2014-11-27 15:28:58 -0500
committerSimon Howard2014-11-27 15:28:58 -0500
commit5eeef20d70fc978372058371d29821dc27b019a5 (patch)
tree0d9478aedd9e0f3ada6a2f86395a64c824b53ffd /src/hexen/p_enemy.c
parent3e70ef4cf909ba4254258e176f92ab6c931993cb (diff)
downloadchocolate-doom-5eeef20d70fc978372058371d29821dc27b019a5.tar.gz
chocolate-doom-5eeef20d70fc978372058371d29821dc27b019a5.tar.bz2
chocolate-doom-5eeef20d70fc978372058371d29821dc27b019a5.zip
hexen: Store minotaur start time as little endian.
The minotaur uses the first four bytes of the mobj_t args[] array to store its spawn time; after a certain amount of time has passed the minotaur self-destructs. But the level time was being copied from the leveltime variable without any endian conversion taking place. For compatibility with Vanilla Hexen savegames we need to store the start time in little endian format. This fixes the first issue noted in #477 (thanks Quasar).
Diffstat (limited to 'src/hexen/p_enemy.c')
-rw-r--r--src/hexen/p_enemy.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/hexen/p_enemy.c b/src/hexen/p_enemy.c
index 9219f339..1ad87032 100644
--- a/src/hexen/p_enemy.c
+++ b/src/hexen/p_enemy.c
@@ -1108,16 +1108,33 @@ void A_MinotaurFade2(mobj_t * actor)
void A_MinotaurLook(mobj_t * actor);
-void A_MinotaurRoam(mobj_t * actor)
+// Check the age of the minotaur and stomp it after MAULATORTICS of time
+// have passed. Returns false if killed.
+static boolean CheckMinotaurAge(mobj_t *mo)
{
- unsigned int *starttime = (unsigned int *) actor->args;
+ unsigned int starttime;
+
+ // The start time is stored in the mobj_t structure, but it is stored
+ // in little endian format. For Vanilla savegame compatibility we must
+ // swap it to the native endianness.
+ memcpy(&starttime, mo->args, sizeof(unsigned int));
+
+ if (leveltime - LONG(starttime) >= MAULATORTICS)
+ {
+ P_DamageMobj(mo, NULL, NULL, 10000);
+ return false;
+ }
+ return true;
+}
+
+void A_MinotaurRoam(mobj_t * actor)
+{
actor->flags &= ~MF_SHADOW; // In case pain caused him to
actor->flags &= ~MF_ALTSHADOW; // skip his fade in.
- if ((leveltime - *starttime) >= MAULATORTICS)
+ if (!CheckMinotaurAge(actor))
{
- P_DamageMobj(actor, NULL, NULL, 10000);
return;
}
@@ -1231,14 +1248,11 @@ void A_MinotaurLook(mobj_t * actor)
void A_MinotaurChase(mobj_t * actor)
{
- unsigned int *starttime = (unsigned int *) actor->args;
-
actor->flags &= ~MF_SHADOW; // In case pain caused him to
actor->flags &= ~MF_ALTSHADOW; // skip his fade in.
- if ((leveltime - *starttime) >= MAULATORTICS)
+ if (!CheckMinotaurAge(actor))
{
- P_DamageMobj(actor, NULL, NULL, 10000);
return;
}