Difference between revisions of "Player face grins after restoring save file"

From DoomWiki.org

[checked revision][checked revision]
m (-move template)
Line 1: Line 1:
{{Request move|Player face grins after restoring save file}}
 
 
The [[status bar face]] momentarily displays a malicious grin whenever the [[player]] obtains a new [[weapon]].  After a saved game is loaded, however, the grin also appears the first time any item is picked up, weapon or otherwise.
 
The [[status bar face]] momentarily displays a malicious grin whenever the [[player]] obtains a new [[weapon]].  After a saved game is loaded, however, the grin also appears the first time any item is picked up, weapon or otherwise.
  

Revision as of 18:31, 29 September 2015

The status bar face momentarily displays a malicious grin whenever the player obtains a new weapon. After a saved game is loaded, however, the grin also appears the first time any item is picked up, weapon or otherwise.

Technical

The malicious grin is triggered during the function ST_updateFaceWidget in st_stuff.c:

   if (plyr->bonuscount)
   {
       // picking up bonus
       doevilgrin = false;
   
       for (i=0;i<NUMWEAPONS;i++)
       {
           if (oldweaponsowned[i] != plyr->weaponowned[i])
           {
               doevilgrin = true;
               oldweaponsowned[i] = plyr->weaponowned[i];
           }
       }
       if (doevilgrin) 
       {
           // evil grin if just picked up weapon
           priority = 8;
           st_facecount = ST_EVILGRINCOUNT;
           st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;
       }
   }

The bonuscount field is initially set to zero upon creation of the player thing (P_SpawnPlayer in p_mobj.c), but can be assigned a nonzero value by picking up almost any beneficial object (see the function P_TouchSpecialThing in p_inter.c). Because the variable oldweaponsowned is local to st_stuff.c, its value cannot be recorded in the savefile, so it contains uninitialized "junk" values the first time the above conditional statement is executed. Therefore, the bolded test is virtually guaranteed to return TRUE and produce a grinning face in that instance.

This bug can also manifest itself when the idkfa or idfa cheat code is invoked, because the cheats give weapons to the player by directly updating plyr->weaponowned, bypassing the status bar face completely (see the function ST_Responder in st_stuff.c). The next time the player collects any item, the status bar will then "notice" the change in weapons owned and the grinning face will be displayed at that time, even if the new item being collected is a weapon already possessed or an unrelated thing like a health bonus.