[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.

https://gfycat.com/PoliticalUnfinishedBilby

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);
  While(TRUE)
  {
   int SustainedDamage = OldHealth - GetActorProperty(0, APROP_Health);
//DamageTaken[PlayerNumber()]
    If(SustainedDamage > 0)
    {
      DamageTaken += SustainedDamage;
      If(DamageTaken > D_DMGCAP) DamageTaken = D_DMGCAP;
    }
   SetHudSize(1920,1080,0);
   If(GetCvar("ERS")){
    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);
    Delay(1);
  }
}


Zscript:
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);

      ChangeLevel("INTERMAP",0,CHANGELEVEL_NOINTERMISSION,CurrentSkill);   
}
Attachments
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII.pk3
(5.62 KiB) Downloaded 11 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]
Attachments
CrashReport.zip
from g3.8pre-232-g395d61391
(22.72 KiB) Downloaded 10 times
User avatar
Enjay
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.
_mental_
 
 
 
Joined: 07 Aug 2011

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

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

:O
Collegia Titanica
 
Joined: 25 Jan 2018
Discord: 2834


Return to Closed Bugs

Who is online

Users browsing this forum: Discord [Bot], Gutawer, JadedLexi and 1 guest