From d50a16a847e8bb3779a16f1bc5cc2dc6cf19b541 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 30 Oct 2012 02:09:57 +0000 Subject: [PATCH] - Fixed: The AmmoPerAttack table was filled with the function pointers before the functions were created, so they were all NULL, and the Dehacked ammo modification loop failed to find any of them in the weapon. The result being that all standard weapons were left with an AmmoUse1 of 0. SVN r3925 (scripting) --- src/d_dehacked.cpp | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index c1e3b2800..8531f1fea 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -164,7 +164,7 @@ static TArray MBFCodePointers; struct AmmoPerAttack { - VMFunction *func; + VMNativeFunction **func; int ammocount; }; @@ -182,17 +182,17 @@ DECLARE_ACTION(A_FireRailgun) // Default ammo use of the various weapon attacks static AmmoPerAttack AmmoPerAttacks[] = { - { A_Punch_VMPtr, 0}, - { A_FirePistol_VMPtr, 1}, - { A_FireShotgun_VMPtr, 1}, - { A_FireShotgun2_VMPtr, 2}, - { A_FireCGun_VMPtr, 1}, - { A_FireMissile_VMPtr, 1}, - { A_Saw_VMPtr, 0}, - { A_FirePlasma_VMPtr, 1}, - { A_FireBFG_VMPtr, -1}, // uses deh.BFGCells - { A_FireOldBFG_VMPtr, 1}, - { A_FireRailgun_VMPtr, 1}, + { &A_Punch_VMPtr, 0}, + { &A_FirePistol_VMPtr, 1}, + { &A_FireShotgun_VMPtr, 1}, + { &A_FireShotgun2_VMPtr, 2}, + { &A_FireCGun_VMPtr, 1}, + { &A_FireMissile_VMPtr, 1}, + { &A_Saw_VMPtr, 0}, + { &A_FirePlasma_VMPtr, 1}, + { &A_FireBFG_VMPtr, -1}, // uses deh.BFGCells + { &A_FireOldBFG_VMPtr, 1}, + { &A_FireRailgun_VMPtr, 1}, { NULL, 0} }; @@ -2481,25 +2481,6 @@ static inline bool CompareLabel (const char *want, const BYTE *have) return *(DWORD *)want == *(DWORD *)have; } -static inline short GetWord (const BYTE *in) -{ - return (in[0] << 8) | (in[1]); -} - -static short *GetWordSpace (void *in, size_t size) -{ - short *ptr; - size_t i; - - ptr = (short *)in; - - for (i = 0; i < size; i++) - { - ptr[i] = GetWord ((BYTE *)in + i*2); - } - return ptr; -} - static int DehUseCount; static void UnloadDehSupp () @@ -2969,7 +2950,7 @@ void FinishDehPatch () StateVisited[state] = true; for(unsigned j = 0; AmmoPerAttacks[j].func != NULL; j++) { - if (state->ActionFunc == AmmoPerAttacks[j].func) + if (state->ActionFunc == *AmmoPerAttacks[j].func) { found = true; int use = AmmoPerAttacks[j].ammocount;