- Fixed a number of places in p_acs.cpp that did not do byte swapping but should have.

SVN r2523 (trunk)
This commit is contained in:
Randy Heit 2010-08-12 22:15:32 +00:00
parent c3fa9a54a0
commit 7d40b8a9a4

View file

@ -1085,8 +1085,8 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
if (Format == ACS_Old) if (Format == ACS_Old)
{ {
StringTable = ((DWORD *)Data)[1]; StringTable = LittleLong(((DWORD *)Data)[1]);
StringTable += ((DWORD *)(Data + StringTable))[0] * 12 + 4; StringTable += LittleLong(((DWORD *)(Data + StringTable))[0]) * 12 + 4;
} }
else else
{ {
@ -1397,8 +1397,8 @@ void FBehavior::LoadScriptsDirectory ()
switch (Format) switch (Format)
{ {
case ACS_Old: case ACS_Old:
scripts.dw = (DWORD *)(Data + ((DWORD *)Data)[1]); // FIXME: Has this been byte-swapped before-hand? scripts.dw = (DWORD *)(Data + LittleLong(((DWORD *)Data)[1]));
NumScripts = scripts.dw[0]; NumScripts = LittleLong(scripts.dw[0]);
if (NumScripts != 0) if (NumScripts != 0)
{ {
scripts.dw++; scripts.dw++;
@ -1760,7 +1760,7 @@ const char *FBehavior::LookupString (DWORD index) const
if (index >= list[0]) if (index >= list[0])
return NULL; // Out of range for this list; return NULL; // Out of range for this list;
return (const char *)(Data + list[1+index]); return (const char *)(Data + LittleLong(list[1+index]));
} }
else else
{ {
@ -4615,12 +4615,12 @@ int DLevelScript::RunScript ()
break; break;
case PCD_GOTO: case PCD_GOTO:
pc = activeBehavior->Ofs2PC (*pc); pc = activeBehavior->Ofs2PC (LittleLong(*pc));
break; break;
case PCD_IFGOTO: case PCD_IFGOTO:
if (STACK(1)) if (STACK(1))
pc = activeBehavior->Ofs2PC (*pc); pc = activeBehavior->Ofs2PC (LittleLong(*pc));
else else
pc++; pc++;
sp--; sp--;
@ -4798,7 +4798,7 @@ int DLevelScript::RunScript ()
case PCD_IFNOTGOTO: case PCD_IFNOTGOTO:
if (!STACK(1)) if (!STACK(1))
pc = activeBehavior->Ofs2PC (*pc); pc = activeBehavior->Ofs2PC (LittleLong(*pc));
else else
pc++; pc++;
sp--; sp--;
@ -4832,7 +4832,7 @@ int DLevelScript::RunScript ()
case PCD_CASEGOTO: case PCD_CASEGOTO:
if (STACK(1) == NEXTWORD) if (STACK(1) == NEXTWORD)
{ {
pc = activeBehavior->Ofs2PC (*pc); pc = activeBehavior->Ofs2PC (LittleLong(*pc));
sp--; sp--;
} }
else else
@ -4853,7 +4853,7 @@ int DLevelScript::RunScript ()
SDWORD caseval = pc[mid*2]; SDWORD caseval = pc[mid*2];
if (caseval == STACK(1)) if (caseval == STACK(1))
{ {
pc = activeBehavior->Ofs2PC (pc[mid*2+1]); pc = activeBehavior->Ofs2PC (LittleLong(pc[mid*2+1]));
sp--; sp--;
break; break;
} }