Weird integer inflation beyond count. [Runnable demo]

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
Collegia Titanica
Posts: 83
Joined: Thu Jan 25, 2018 1:37 pm

Weird integer inflation beyond count. [Runnable demo]

Post by Collegia Titanica »

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 all

#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 all

					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 all

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 23 times
Last edited by Collegia Titanica on Sat Jan 19, 2019 9:56 am, edited 1 time in total.
User avatar
Enjay
 
 
Posts: 26516
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

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

Post by Enjay »

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]
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

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

Post by _mental_ »

NoExit.acs, line 5

Code: Select all

global str 11:NextLevel;
RS.acs, line 9

Code: Select all

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.
Collegia Titanica
Posts: 83
Joined: Thu Jan 25, 2018 1:37 pm

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

Post by Collegia Titanica »

:O
Post Reply

Return to “Closed Bugs [GZDoom]”