SOLVED - Crash

Toranks

Active member
At the end of this video Openbor crashes. The relevant part of the log is this:

Code:
debug:nativeWidth, nativeHeight, bpp, Hz  1920, 1080, 24, 144
OpenBoR v3.0 Build 7142 (commit hash: 9dcd966), Compile Date: Dec  8 2019

[...]

RAM Status:
Total Ram:  8523898880 Bytes (  8129 MB )
 Free Ram:  5363539968 Bytes (  5115 MB )
 Used Ram:   356847616 Bytes (   340 MB )

Level Loading:   'data/levels/55lvl.txt'
Total Ram:  8523898880 Bytes (  8129 MB )
 Free Ram:  5363539968 Bytes (  5115 MB )
 Used Ram:   356847616 Bytes (   340 MB )


Level Loaded:    'data/levels/55lvl.txt'
Total Ram:  8523898880 Bytes (  8129 MB )
 Free Ram:  5355515904 Bytes (  5107 MB )
 Used Ram:   363077632 Bytes (   346 MB )
Total sprites mapped: 16940

Function need a valid entity handle, the other 2 integer parameters are optional: performattack(entity, int anim, int resetable)
Script function 'performattack' returned an exception, check the manual for details.
 parameters: <VT_EMPTY>   Unitialized, 344,  
 
********** An Error Occurred **********
*            Shutting Down            *

There's an exception while executing script 'updateentityscript' data/chars/misc/grab/grab1.txtTotal Ram:  8523898880 Bytes (  8129 MB )
 Free Ram:  5294628864 Bytes (  5049 MB )
 Used Ram:   365293568 Bytes (   348 MB )

Release level data...........
Level Unloading: 'data/levels/55lvl.txt'
Total Ram:  8523898880 Bytes (  8129 MB )
 Free Ram:  5294624768 Bytes (  5049 MB )
 Used Ram:   365293568 Bytes (   348 MB )

RAM Status:
Total Ram:  8523898880 Bytes (  8129 MB )
 Free Ram:  5298528256 Bytes (  5053 MB )
 Used Ram:   361390080 Bytes (   344 MB )

Done!

Release graphics data........	Done!
Release game data............

[UNLOADS...]
Unload 'doorIN' ............Done.

Release game data............	Done!
Release timer................	Done!
Release input hardware.......	Done!
Release sound system.........	Done!
Release FileCaching System...	Done!

**************** Done *****************

There's an exception while executing script 'updateentityscript' data/chars/misc/grab/grab1.txt

Can anybody help me to identify the cause?
"updateentityscript" is not in this file or any other in the game.
All performattacks commands on entities are well, the problem is in the script.
The exact moment of the crash is probably an enemy grabbing me but not finding an entity to grab. This is the function of the entity grab1
On the video, the enemy girl do a jump + attemp to grab me on the last second. I am doing a normal attack with bbox (I can be grabbed).
I'm using 4 alpha, this crash never happen to me with the original openbor executable of the game (4153)

 
The moment is the end of the video, you can see a freeze and a black screen at the end.

Grab1.txt file:

Code:
name			grab1
type			obstacle

scroll			1
health			300
speed			0
nomove			1 1
facing			1
noquake			1
shadow			0
falldie			1
antigrab		10
offscreenkill 	        30000
subject_to_wall		0
subject_to_platform 	0
subject_to_obstacle 	0
subject_to_hole 	0
subject_to_gravity 	0
diesound        data/sounds/empty.wav
setlayer	999999998

lifebarstatus 150 20 0 1 0 2 5
lifeposition 120  240
nameposition -200 -200
nolife 1



script   @script
void main()
{
    	void self = getlocalvar("self");
	void attacker = getentityproperty(self,"parent");
   	void victim2 = getentityproperty(attacker, "opponent");
  	void victim = getentityproperty(victim2, "playerindex");
	int HP = getentityproperty(self,"health");
	int HPmax = getentityproperty(self,"maxhealth");

	int x1 = getentityproperty(attacker,"x");
	int z1 = getentityproperty(attacker,"z");

    	int escape = getentityvar(self, "grabgo"); //johnny madjon

	if(HP>=HPmax && escape == 1){
	changeentityproperty(victim2, "position", x1, z1);
     	performattack(victim2, openborconstant("ANI_FOLLOW15"));
    	setidle(attacker, openborconstant("ANI_IDLE"));
     	bindentity(victim2, NULL());
     	performattack(attacker, openborconstant("ANI_PAIN8"));
	setentityvar(self, "madjon", NULL());
	killentity(self);

	} else if(HP>=HPmax && escape == 2){
	changeentityproperty(victim2, "position", x1, z1);
     	performattack(victim2, openborconstant("ANI_FOLLOW16"));
    	setidle(attacker, openborconstant("ANI_IDLE"));
     	bindentity(victim2, NULL());
    	performattack(attacker, openborconstant("ANI_PAIN8"));
	setentityvar(self, "madjon", NULL());
	killentity(self);

      	} else if(playerkeys(victim, 2, "moveleft")){// Left is pressed?
    	changeentityproperty(self, "health", HP+1);
  	} else if(playerkeys(victim, 2, "moveup")){// Left is pressed?
    	changeentityproperty(self, "health", HP+1);
   	} else if(playerkeys(victim, 2, "movedown")){// Left is pressed?
    	changeentityproperty(self, "health", HP+1);
	} else if(playerkeys(victim, 2, "moveright")){// Right is pressed?
    	changeentityproperty(self, "health", HP+1);
	} else if(playerkeys(victim, 2, "attack")){// Right is pressed?
    	changeentityproperty(self, "health", HP+1);
	} else if(playerkeys(victim, 2, "jump")){// Right is pressed?
    	changeentityproperty(self, "health", HP+1);
	} else if(playerkeys(victim, 2, "special")){// Right is pressed?
    	changeentityproperty(self, "health", HP+2);
      	}
}
@end_script











anim	death
	loop	0
	delay	5
	offset	50 90
	bbox	0 0 0 0
	platform	1 1 1 1 1 1 1 1
	frame	data/chars/misc/grab/empty.gif
	frame	data/chars/misc/grab/empty.gif
		
anim	follow1
	loop	1
	delay	6
	offset	50 90
	bbox	0 0 0 0
	platform	1 1 1 1 1 1 1 1
	frame	data/chars/misc/grab/grab04.gif
	frame	data/chars/misc/grab/grab05.gif
	frame	data/chars/misc/grab/grab04.gif
	frame	data/chars/misc/grab/grab06.gif
		
anim	idle
	loop	0
	delay	15
	offset	90 90
	bbox	0 0 0 0
	platform	1 1 1 1 1 1 1 1
	frame	data/chars/misc/grab/grab00.gif
	frame	data/chars/misc/grab/grab07.gif
	frame	data/chars/misc/grab/grab08.gif
	frame	data/chars/misc/grab/grab00.gif
	frame	data/chars/misc/grab/grab07.gif
	frame	data/chars/misc/grab/grab08.gif
	frame	data/chars/misc/grab/grab00.gif
	frame	data/chars/misc/grab/grab07.gif
	frame	data/chars/misc/grab/grab08.gif
	frame	data/chars/misc/grab/grab00.gif
	frame	data/chars/misc/grab/grab07.gif
	frame	data/chars/misc/grab/grab08.gif
	frame	data/chars/misc/grab/grab00.gif
	frame	data/chars/misc/grab/empty.gif
		
anim	pain
	loop	0
	delay	5
	offset	50 90
	bbox	0 0 0 0
	platform	1 1 1 1 1 1 1 1
	frame	data/chars/misc/grab/empty.gif
	frame	data/chars/misc/grab/empty.gif
		
anim	spawn
@script
	void self = getlocalvar("self");
	void atk = getentityproperty(self,"parent");
  	void vtm = getentityproperty(atk, "opponent");
    	changeentityproperty(self, "health",-5);

	if(getentityproperty(vtm, "type")==openborconstant("TYPE_NPC"))
	{
	killentity(self);
	}
	@end_script	
	loop	0
	delay	5
	offset	50 90
	bbox	0 0 0 0
	platform	1 1 1 1 1 1 1 1
	frame	data/chars/misc/grab/empty.gif
	frame	data/chars/misc/grab/empty.gif
	frame	data/chars/misc/grab/empty.gif
	frame	data/chars/misc/grab/empty.gif
		
#|edited by openBor Stats v 0.53
 
I almost forgotten about this thread

This crash seems to occur in certain situation. There was many things happening just before the crash occurred. It's hard to tell what actually the cause is. You'll have to isolate possible causes and trial n error until you can reproduce the crash.

My best guess is that NPC or grab1 grabbed something which disappears causing crash since script failed to get that something
 
BB is right: the script is referring to something which isn't available anymore, which causes a Null Pointer Exception

Take a look at the code:

script  @script
void main()
{
    void self = getlocalvar("self");
void attacker = getentityproperty(self,"parent");
  void victim2 = getentityproperty(attacker, "opponent");
  void victim = getentityproperty(victim2, "playerindex");
int HP = getentityproperty(self,"health");
int HPmax = getentityproperty(self,"maxhealth");

int x1 = getentityproperty(attacker,"x");
int z1 = getentityproperty(attacker,"z");

    int escape = getentityvar(self, "grabgo"); //johnny madjon

if(HP>=HPmax && escape == 1){
changeentityproperty(victim2, "position", x1, z1);
    performattack(victim2, openborconstant("ANI_FOLLOW15"));
    setidle(attacker, openborconstant("ANI_IDLE"));
    bindentity(victim2, NULL());
    performattack(attacker, openborconstant("ANI_PAIN8"));
setentityvar(self, "madjon", NULL());
killentity(self);

} else if(HP>=HPmax && escape == 2){
changeentityproperty(victim2, "position", x1, z1);
    performattack(victim2, openborconstant("ANI_FOLLOW16"));
    setidle(attacker, openborconstant("ANI_IDLE"));
    bindentity(victim2, NULL());
    performattack(attacker, openborconstant("ANI_PAIN8"));
setentityvar(self, "madjon", NULL());
killentity(self);

      } else if(playerkeys(victim, 2, "moveleft")){// Left is pressed?
    changeentityproperty(self, "health", HP+1);
  } else if(playerkeys(victim, 2, "moveup")){// Left is pressed?
    changeentityproperty(self, "health", HP+1);
  } else if(playerkeys(victim, 2, "movedown")){// Left is pressed?
    changeentityproperty(self, "health", HP+1);
} else if(playerkeys(victim, 2, "moveright")){// Right is pressed?
    changeentityproperty(self, "health", HP+1);
} else if(playerkeys(victim, 2, "attack")){// Right is pressed?
    changeentityproperty(self, "health", HP+1);
} else if(playerkeys(victim, 2, "jump")){// Right is pressed?
    changeentityproperty(self, "health", HP+1);
} else if(playerkeys(victim, 2, "special")){// Right is pressed?
    changeentityproperty(self, "health", HP+2);
      }
}
@end_script

On the fist case in red, the script gets the opponent, on the second, it tells to the engine to make the opponent (victim2) to execute a move. But if you pay attention, there is no actuall check - the code just get the opponent and tells it to do something, but without cheking it the opponent is valid.

You can get invalid pointers (like checking if there is an opponent), its not a problem. But telling invalid pointers to to something is a no-no in pretty much all the coding languages I know.

Edit: reading the whole code, I am pretty sure there is no check for the attacker too.

So I would use this:

script  @script
void main()
{
  void self = getlocalvar("self");
  void attacker = getentityproperty(self,"parent");
  void victim2 = getentityproperty(attacker, "opponent");
  void victim = getentityproperty(victim2, "playerindex");
  int HP = getentityproperty(self,"health");
  int HPmax = getentityproperty(self,"maxhealth");

  int x1 = getentityproperty(attacker,"x");
  int z1 = getentityproperty(attacker,"z");

  int escape = getentityvar(self, "grabgo"); //johnny madjon
 
  if (attacker!=NULL() && victim2 !=NULL())
  {// checking if the pointers are valid


if(HP>=HPmax && escape == 1){
changeentityproperty(victim2, "position", x1, z1);
performattack(victim2, openborconstant("ANI_FOLLOW15"));
setidle(attacker, openborconstant("ANI_IDLE"));
bindentity(victim2, NULL());
        performattack(attacker, openborconstant("ANI_PAIN8"));
setentityvar(self, "madjon", NULL());
killentity(self);

} else if(HP>=HPmax && escape == 2){
changeentityproperty(victim2, "position", x1, z1);
        performattack(victim2, openborconstant("ANI_FOLLOW16"));
setidle(attacker, openborconstant("ANI_IDLE"));
        bindentity(victim2, NULL());
performattack(attacker, openborconstant("ANI_PAIN8"));
setentityvar(self, "madjon", NULL());
killentity(self);

} else if(playerkeys(victim, 2, "moveleft")){// Left is pressed?
changeentityproperty(self, "health", HP+1);
} else if(playerkeys(victim, 2, "moveup")){// Left is pressed?
changeentityproperty(self, "health", HP+1);
} else if(playerkeys(victim, 2, "movedown")){// Left is pressed?
changeentityproperty(self, "health", HP+1);
} else if(playerkeys(victim, 2, "moveright")){// Right is pressed?
changeentityproperty(self, "health", HP+1);
} else if(playerkeys(victim, 2, "attack")){// Right is pressed?
changeentityproperty(self, "health", HP+1);
} else if(playerkeys(victim, 2, "jump")){// Right is pressed?
changeentityproperty(self, "health", HP+1);
} else if(playerkeys(victim, 2, "special")){// Right is pressed?
changeentityproperty(self, "health", HP+2);
}
  }// end checking valid pointers
}
@end_script
 
This have partially resolved a different bug with the grabs, and works as good as before.
It probably won't happen again, so I leave the thread as probably resolved. If this bug happens to me again, I'll re-up this topic in the future.
Thanks!
 
Back
Top Bottom