mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 12:11:25 +00:00
- added some fudging so that the Dehacked parser can properly deal with ConsumeAmmo.
This is a parameterized code pointer, so checking state functions for names won't work. Additionally, the handling was not correct for weapons with an ammo use other than 1.
This commit is contained in:
parent
525351c695
commit
1c4d48f5f2
2 changed files with 20 additions and 3 deletions
|
@ -237,7 +237,6 @@ static AmmoPerAttack AmmoPerAttacks[] = {
|
|||
{ NAME_A_FireBFG, -1}, // uses deh.BFGCells
|
||||
{ NAME_A_FireOldBFG, 1},
|
||||
{ NAME_A_FireRailgun, 1},
|
||||
{ NAME_MBF21_ConsumeAmmo, 1}, // MBF21
|
||||
{ NAME_None, 0}
|
||||
};
|
||||
|
||||
|
@ -2588,12 +2587,16 @@ static int PatchCodePtrs (int dummy)
|
|||
{
|
||||
FString symname;
|
||||
|
||||
|
||||
if ((Line2[0] == 'A' || Line2[0] == 'a') && Line2[1] == '_')
|
||||
symname = Line2;
|
||||
else
|
||||
symname.Format("A_%s", Line2);
|
||||
|
||||
// Hack alert: If A_ConsumeAmmo is used we need to handle the ammo use differently.
|
||||
// Since this is a parameterized code pointer the AmmoPerAttack check cannot find it easily without some help.
|
||||
if (symname.CompareNoCase("A_ConsumeAmmo") == 0)
|
||||
state->StateFlags |= STF_CONSUMEAMMO;
|
||||
|
||||
// Let's consider as aliases some redundant MBF pointer
|
||||
bool ismbfcp = false;
|
||||
for (unsigned int i = 0; i < MBFCodePointers.Size(); i++)
|
||||
|
@ -3571,8 +3574,8 @@ void FinishDehPatch ()
|
|||
}
|
||||
else
|
||||
{
|
||||
bool handled = false;
|
||||
weap->BoolVar(NAME_bDehAmmo) = true;
|
||||
weap->IntVar(NAME_AmmoUse1) = 0;
|
||||
// to allow proper checks in CheckAmmo we have to find the first attack pointer in the Fire sequence
|
||||
// and set its default ammo use as the weapon's AmmoUse1.
|
||||
|
||||
|
@ -3587,6 +3590,13 @@ void FinishDehPatch ()
|
|||
break; // State has already been checked so we reached a loop
|
||||
}
|
||||
StateVisited[state] = true;
|
||||
if (state->StateFlags & STF_CONSUMEAMMO)
|
||||
{
|
||||
// If A_ConsumeAmmo is being used we have to rely on the existing AmmoUse1 value.
|
||||
handled = true;
|
||||
state->StateFlags &= ~STF_CONSUMEAMMO;
|
||||
break;
|
||||
}
|
||||
for(unsigned j = 0; AmmoPerAttacks[j].func != NAME_None; j++)
|
||||
{
|
||||
if (AmmoPerAttacks[j].ptr == nullptr)
|
||||
|
@ -3601,12 +3611,18 @@ void FinishDehPatch ()
|
|||
int use = AmmoPerAttacks[j].ammocount;
|
||||
if (use < 0) use = deh.BFGCells;
|
||||
weap->IntVar(NAME_AmmoUse1) = use;
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
state = state->GetNextState();
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
weap->IntVar(NAME_AmmoUse1) = 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
WeaponNames.Clear();
|
||||
|
|
|
@ -72,6 +72,7 @@ enum EStateFlags
|
|||
STF_SAMEFRAME = 16, // Ignore Frame (except when spawning actor)
|
||||
STF_CANRAISE = 32, // Allows a monster to be resurrected without waiting for an infinate frame
|
||||
STF_DEHACKED = 64, // Modified by Dehacked
|
||||
STF_CONSUMEAMMO = 128, // Needed by the Dehacked parser.
|
||||
};
|
||||
|
||||
enum EStateType : int // this must ensure proper alignment.
|
||||
|
|
Loading…
Reference in a new issue