[User error] Weird integer inflation beyond count. [Runnable demo]

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Weird integer inflation beyond count. [Runnable demo]

Postby Collegia Titanica » Sat Jan 19, 2019 9:12 am

Large project stripped down to the very core of the problem;

This sample code tracks how much damage you've taken during the map, overrides the normal exit with a -nointermission mapchange to Intermap where Important stats are displayed. The result of this DamageTaken is important for a calculation.

Problem: When I click the exit switch, I can instantly see the number jumping from like 15 to 2402011050124102 and my score is ruined because of this. Gfy included.


To see the DamageTaken attribute, type "ERS 1" in console

Code: Select allExpand view
#library "RS"
#Import "NoExit.acs"
#include "zcommon.acs"

#define D_DMGCAP      99999 // The total damaage is capped to this number

// -----------------------------------------------------------------------------

global int 11:DamageTaken;

// -----------------------------------------------------------------------------

Script "Damage Taken" Enter

   IF(!StrIcmp(CurrentMap,"INTERMAP") == 0 )    DamageTaken = 0;         //Values get reset to 0 in every level except on Intermap

  int OldHealth = GetActorProperty(0, APROP_Health);
   int SustainedDamage = OldHealth - GetActorProperty(0, APROP_Health);
    If(SustainedDamage > 0)
      DamageTaken += SustainedDamage;
      If(DamageTaken > D_DMGCAP) DamageTaken = D_DMGCAP;
    HudMessage(s:"Damage Received: ",d:DamageTaken;      // Display Damage Received [Debug]
            HUDMSG_PLAIN , 115, CR_GREEN,
            380.0, 40.0, 0);   }
    OldHealth = GetActorProperty(0, APROP_Health);

Code: Select allExpand view
               for (int i = 0; i < level.Lines.Size(); i++)            // iterate through all lines in the current map
                  Line l = level.Lines[i];                        // get current line
                  int spec = l.special;                           // get the special assigned to the current line
                  if ( spec == 243 || spec == 244 )                  // if the line is an Exit_Normal line (243), overwrite it with an ACS script (7777)                                                         
                     l.special = 226;                           // special 226 = ACS_ExecuteAlways
                                                            // set the args
                     l.args[0] = 7777;
                     l.args[1] = 0;
                     l.args[2] = 0;
                     l.args[3] = 0;
                     l.args[4] = 0;

                  l.flags |= Line.ML_REPEAT_SPECIAL;               // be sure to make the line repeatable

Script 7777:
Code: Select allExpand view
Script 7777 (void)
      CurrentSkill = GameSkill();
      NextLevel = strParam(n:PRINTNAME_NEXTLEVEL);
   str   NextSecret = strParam(n:PRINTNAME_NEXTSECRET);

(5.62 KiB) Downloaded 12 times
Last edited by Collegia Titanica on Sat Jan 19, 2019 10:56 am, edited 1 time in total.
Collegia Titanica
Joined: 25 Jan 2018
Discord: 2834

Re: Weird integer inflation beyond count. [Runnable demo]

Postby Enjay » Sat Jan 19, 2019 9:34 am

I don't know if this is relevant or not, but with gzdoom-g3.8pre-232-g395d61391 if I puke script 7777 from the console before starting to play, or run to the map01 exit without taking any damage, the game will crash (any method seems to work: simply avoiding being hit, killing all monsters from the console, running with -nomonsters).

However, if I ensure that I have taken some damage before running script 7777 (either via the console or the exit line) then the game does not crash.

[edit] gzdoom-g3.8pre-238-gdf6669b32 also crashes, as does gzdoom-x64-g3.8pre-238-gdf6669b32 but the latter only once gave me the option of saving a crash report. [/edit]
from g3.8pre-232-g395d61391
(22.72 KiB) Downloaded 11 times
User avatar
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
Joined: 15 Jul 2003
Location: Scotland

Re: Weird integer inflation beyond count. [Runnable demo]

Postby _mental_ » Sun Jan 20, 2019 4:28 am

NoExit.acs, line 5
Code: Select allExpand view
global str 11:NextLevel;

RS.acs, line 9
Code: Select allExpand view
global int 11:DamageTaken;

I'll give your a hint: to increase level of fun even more use the same index for all global variables regardless of their types and purpose.
Joined: 07 Aug 2011

Re: Weird integer inflation beyond count. [Runnable demo]

Postby Collegia Titanica » Sun Jan 20, 2019 9:28 am

Collegia Titanica
Joined: 25 Jan 2018
Discord: 2834

Return to Closed Bugs

Who is online

Users browsing this forum: Awario [RSS], Cherno, phantombeta, yura_111 and 1 guest