MantisBT - Zandronum
View Issue Details
0001844Zandronum[All Projects] Bugpublic2014-06-17 18:412024-04-08 17:24
Zom-B 
 
lowcrashalways
resolvedfixed 
MicrosoftWindowsXP/Vista/7
1.2 
3.23.2 
0001844: DMflags2 shotgun crashes when shotgun actor is replaced
I have a mod where in DECORATE the Shotgun actor is replaced with ShellBox and the DoomPlayer actor is overridden with only custom weapons in Player.StartItem and Player.StartItem. The KeyConf file uses the new class which is evident in the game.

When dmflags2 has bit 2048 (Start with Shotgun), it bugs out at startup.
Make a resource file (pk3)

Put in DECORATE:

ACTOR MarineClass : DoomPlayer
{
    Player.WeaponSlot 2, Pistol
    Player.StartItem "Pistol"
}

ACTOR MShotgunButAmmo : ShellBox Replaces Shotgun
{
}

Put in KEYCONF:

clearplayerclasses
addplayerclass MarineClass


Start Zandromun with the DOOM2.wad and this pk3, and with dmflags2=2048
Access Violation, decorate, DMFLAG, shotgun, weapon
child of 0001845closed Dusk make sv_shotgunstart work in all games and gamemodes 
zip CrashReport.zip (19,718) 2014-06-17 18:41
https://zandronum.com/tracker/file_download.php?file_id=1232&type=bug
? MOD.pk3 (384) 2014-06-17 18:47
https://zandronum.com/tracker/file_download.php?file_id=1233&type=bug
Issue History
2014-06-17 18:41Zom-BNew Issue
2014-06-17 18:41Zom-BFile Added: CrashReport.zip
2014-06-17 18:47Zom-BFile Added: MOD.pk3
2014-06-18 00:37DuskAssigned To => Dusk
2014-06-18 00:37DuskStatusnew => assigned
2014-06-18 13:18DuskNote Added: 0009572
2014-06-18 13:18DuskStatusassigned => needs review
2014-06-18 13:19DuskRelationship addedchild of 0001845
2014-06-21 14:46Torr SamahoNote Added: 0009618
2014-06-21 14:46Torr SamahoStatusneeds review => feedback
2014-06-21 15:49Zom-BNote Added: 0009622
2014-06-21 15:49Zom-BStatusfeedback => assigned
2014-06-21 15:49Zom-BNote Edited: 0009622bug_revision_view_page.php?bugnote_id=9622#r5094
2014-06-21 19:04DuskNote Added: 0009628
2014-06-21 19:04DuskStatusassigned => needs review
2014-06-21 19:04DuskNote Edited: 0009628bug_revision_view_page.php?bugnote_id=9628#r5100
2014-06-22 06:51Torr SamahoNote Added: 0009639
2014-06-22 06:53Torr SamahoNote Edited: 0009639
2014-06-22 06:53Torr SamahoNote Edited: 0009639bug_revision_view_page.php?bugnote_id=9639#r5117
2014-06-22 06:53Torr SamahoNote Revision Dropped: 9639: 0005116
2014-06-22 06:53Torr SamahoNote Revision Dropped: 9639: 0005115
2014-06-22 06:53Torr SamahoStatusneeds review => feedback
2014-06-22 10:31DuskNote Added: 0009646
2014-07-05 20:06Torr SamahoProduct Version2.0-beta => 1.2
2024-03-19 17:05Ru5tK1ngNote Added: 0023430
2024-03-19 17:05Ru5tK1ngAssigned ToDusk =>
2024-03-19 17:05Ru5tK1ngStatusfeedback => needs review
2024-04-07 20:30Ru5tK1ngNote Added: 0023527
2024-04-07 20:30Ru5tK1ngStatusneeds review => resolved
2024-04-07 20:30Ru5tK1ngTarget Version => 3.2
2024-04-07 20:30Ru5tK1ngStatusresolved => feedback
2024-04-07 20:30Ru5tK1ngResolutionopen => reopened
2024-04-07 20:30Ru5tK1ngStatusfeedback => needs testing
2024-04-08 17:24Ru5tK1ngNote Added: 0023547
2024-04-08 17:24Ru5tK1ngStatusneeds testing => resolved
2024-04-08 17:24Ru5tK1ngResolutionreopened => fixed
2024-04-08 17:24Ru5tK1ngFixed in Version => 3.2

Notes
(0009572)
Dusk   
2014-06-18 13:18   
'https://bitbucket.org/Torr_Samaho/zandronum-stable/pull-request/51 [^]'
(0009618)
Torr Samaho   
2014-06-21 14:46   
The part of your patch which prevents the crash reported here (aka the ( pInventory->IsKindOf( RUNTIME_CLASS( AWeapon ) ) check) looks fine. If you separate it from the rest, I'll pull it.
(0009622)
Zom-B   
2014-06-21 15:49   
i merely reported it for completeness (and because bugs I encounter are rarely reproducible). Don't sweat it. There are FAR more pressing bugs, like 0001469

(0009628)
Dusk   
2014-06-21 19:04   
How is this then?

(0009639)
Torr Samaho   
2014-06-22 06:51   
(edited on: 2014-06-22 06:53)
Are you sure that

if (( ammo = shotgun->Ammo1 ) != NULL )
    ammo->Amount = shotgun->AmmoGive1 * 2;

is guaranteed to work? In similar code, like the LMS stuff, we always use

if ( pWeapon->Ammo1 )
{
    pInventory = player->mo->FindInventory( pWeapon->Ammo1->GetClass( ));
    if ( pInventory != NULL )
        pInventory->Amount = ...


The way you define and initialize shotgunclass is not totally straight forward to read. IMO the code would be much more readable if definition and initialization are combined to
const PClass* shotgunclass = PClass::FindClass( "Shotgun" )->ActorInfo->GetReplacement()->Class

, moved inside the scope that checks DF2_COOP_SHOTGUNSTART and a new scope for the "is weapon" check is created.

Also, if you insist on changing the behavior of the flag to make it work in non-coop game modes, fine. But then the "COOP" in the internal flag name doesn't make any sense anymore and needs to be removed.

(0009646)
Dusk   
2014-06-22 10:31   
Quote

Are you sure that

 if (( ammo = shotgun->Ammo1 ) != NULL )
     ammo->Amount = shotgun->AmmoGive1 * 2;

 is guaranteed to work? In similar code, like the LMS stuff, we always use

ZDoom seems to do this.. see for instance g_hexen/a_fighteraxe.cpp:


g_hexen/a_fighteraxe.cpp:79: if (player->ReadyWeapon->Ammo1->Amount)
g_hexen/a_fighteraxe.cpp:103: if (player->ReadyWeapon->Ammo1->Amount <= 0)
g_hexen/a_fighteraxe.cpp:127: if (player->ReadyWeapon->Ammo1->Amount)
g_hexen/a_fighteraxe.cpp:151: if (player->ReadyWeapon->Ammo1->Amount <= 0)
g_hexen/a_fighteraxe.cpp:175: if (player->ReadyWeapon->Ammo1->Amount)
g_hexen/a_fighteraxe.cpp:210: if (player->ReadyWeapon->Ammo1->Amount > 0)
g_hexen/a_fighteraxe.cpp:311: if ((weapon->Ammo1 == NULL || weapon->Ammo1->Amount == 0) &&


It worked just fine for me when I tested it offline and online.

Quote
Also, if you insist on changing the behavior of the flag to make it work in non-coop game modes, fine.

It doesn't make any sense to me to keep it coop-only. I think there was a ticket somewhere in here that proposed to make it available to all game modes but I cannot find it right now..

I'll work on the readability.
(0023430)
Ru5tK1ng   
2024-03-19 17:05   
This should fix the crash:'https://foss.heptapod.net/zandronum/zandronum-stable/-/merge_requests/72 [^]'
(0023527)
Ru5tK1ng   
2024-04-07 20:30   
Change was merged in:'https://foss.heptapod.net/zandronum/zandronum-stable/-/commit/00afb8d1543a5faa796719fd478e05af7d8aeca6 [^]'
(0023547)
Ru5tK1ng   
2024-04-08 17:24   
Tested with the latest beta and the crash no longer occurs with the example wad.