Script is crashing Spring when exiting

Script is crashing Spring when exiting

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Script is crashing Spring when exiting

Post by PauloMorfeo »

I decompiled the script of the TllWindTrap and compiled it again. Now, everytime i have a Wind Trap in the game, once i Shift-Esc, Spring crashes.

Not serious, since it seems to only happen when exiting, but here is the code:

Code: Select all

#define TA			// This is a TA script

#include "sfxtype.h"
#include "exptype.h"

piece  base, body, lights, dish1, dish2, dish3, dish4, dish5;

static-var  Static_Var_1, Static_Var_2, Static_Var_3, statechg_DesiredState, statechg_StateChanging,
            Static_Var_6, Static_Var_7, Static_Var_8;


HitByWeapon(Func_Var_1, Func_Var_2, Func_Var_3)
{
	Func_Var_3 = get HEALTH;
	if( Func_Var_3 <= 60 )
	{
		if( Static_Var_6 == 0 )
		{
			Static_Var_6 = 1;
			hide dish1;
			explode dish1 type FALL | SHATTER | SMOKE | BITMAP2;
		}
	}
	if( Func_Var_3 <= 50 )
	{
		if( Static_Var_7 == 0 )
		{
			Static_Var_7 = 1;
			hide dish2;
			explode dish2 type FALL | SHATTER | SMOKE | BITMAP2;
		}
	}
	if( Func_Var_3 <= 35 )
	{
		if( Static_Var_8 == 0 )
		{
			Static_Var_8 = 1;
			hide dish4;
			explode dish4 type FALL | SHATTER | SMOKE | BITMAP2;
		}
	}
	signal 16;
	set-signal-mask 16;
	set ACTIVATION to 0;
	sleep 16000;
	set ACTIVATION to 1;
}

SmokeUnit(healthpercent, sleeptime, smoketype)
{
	Static_Var_6 = 0;
	Static_Var_7 = 0;
	Static_Var_8 = 0;
	while( get BUILD_PERCENT_LEFT )
	{
		sleep 400;
	}
	while( TRUE )
	{
		healthpercent = get HEALTH;
		if( healthpercent >= 40 )
		{
			if( Static_Var_8 == 1 )
			{
				Static_Var_8 = 0;
				show dish4;
			}
		}
		if( healthpercent >= 60 )
		{
			if( Static_Var_7 == 1 )
			{
				Static_Var_7 = 0;
				show dish2;
			}
		}
		if( healthpercent >= 75 )
		{
			if( Static_Var_6 == 1 )
			{
				Static_Var_6 = 0;
				show dish1;
			}
		}
		if( healthpercent < 66 )
		{
			smoketype = 256 | 2;
			if( Rand( 1, 66 ) < healthpercent )
			{
				smoketype = 256 | 1;
			}
			emit-sfx smoketype from base;
		}
		sleeptime = healthpercent * 50;
		if( sleeptime < 200 )
		{
			sleeptime = 200;
		}
		sleep sleeptime;
	}
}

Go()
{
	set ARMORED to 0;
	dont-cache lights;
	dont-cache dish1;
	dont-cache dish2;
	dont-cache dish3;
	dont-cache dish4;
	dont-cache dish5;
	turn dish1 to x-axis <-45.000000> speed <40.000000>;
	turn dish2 to x-axis <-45.000000> speed <40.000000>;
	turn dish3 to x-axis <-45.000000> speed <40.000000>;
	turn dish4 to x-axis <-45.000000> speed <40.000000>;
	turn dish5 to x-axis <-45.000000> speed <40.000000>;
}

Stop()
{
	turn dish1 to x-axis <0.000000> speed <40.000000>;
	turn dish2 to x-axis <0.000000> speed <40.000000>;
	turn dish3 to x-axis <0.000000> speed <40.000000>;
	turn dish4 to x-axis <0.000000> speed <40.000000>;
	turn dish5 to x-axis <0.000000> speed <40.000000>;
	cache lights;
	cache dish1;
	cache dish2;
	cache dish3;
	cache dish4;
	cache dish5;
	set ARMORED to 1;
}

InitState()
{
	statechg_DesiredState = TRUE;
	statechg_StateChanging = FALSE;
}

RequestState(requestedstate, currentstate)
{
	if( statechg_StateChanging )
	{
		statechg_DesiredState = requestedstate;
		return (0);
	}
	statechg_StateChanging = TRUE;
	currentstate = statechg_DesiredState;
	statechg_DesiredState = requestedstate;
	while( statechg_DesiredState != currentstate )
	{
		if( statechg_DesiredState == 0 )
		{
			call-script Go();
			currentstate = 0;
		}
		if( statechg_DesiredState == 1 )
		{
			call-script Stop();
			currentstate = 1;
		}
	}
	statechg_StateChanging = FALSE;
}

Create()
{
	dont-shade dish1;
	dont-shade dish2;
	dont-shade dish3;
	dont-shade dish4;
	dont-shade dish5;
	dont-shade lights;
	Static_Var_2 = 3640;
	Static_Var_3 = 0;
	call-script InitState();
	start-script SmokeUnit();
}

Activate()
{
	start-script RequestState(0);
}

Deactivate()
{
	start-script RequestState(1);
}

SetSpeed(Func_Var_1)
{
}

SetDirection(Func_Var_1)
{
}

SweetSpot(piecenum)
{
	piecenum = body;
}

Killed(severity, corpsetype)
{
	if( severity <= 25 )
	{
		corpsetype = 1;
		explode body type BITMAPONLY | BITMAP1;
		explode lights type BITMAPONLY | BITMAP2;
		explode dish3 type BITMAPONLY | BITMAP3;
	}
	if( severity <= 50 )
	{
		corpsetype = 2;
		explode body type BITMAPONLY | BITMAP1;
		explode dish3 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP2;
		explode lights type BITMAPONLY | BITMAP3;
		return (0);
	}
	if( severity <= 99 )
	{
		corpsetype = 3;
		explode dish3 type BITMAPONLY | BITMAP1;
		explode body type SHATTER | BITMAP2;
		explode dish2 type BITMAPONLY | BITMAP3;
		return (0);
	}
	corpsetype = 3;
	explode dish2 type BITMAPONLY | BITMAP1;
	explode body type SHATTER | BITMAP2;
	explode dish4 type BITMAPONLY | BITMAP3;
}
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

That's a really horrible script anyhow.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

There has ben a horrible crashbug in spring that happens when you close it after the desktop has re-appeared that emsses with future OpenGL programs, and browsers. For example if the server exits it doesnt happen but if I shift+esc it crashes after I've returned to desktop and lingers in the background. I knwo this isnt an isolated incident because others have commented on ti in the threads about it I started and I've notice other people have to end task spring.exe in task manager too when playing in the lobby.

When this happens screensavers dont start properly or get all distorted, activeX objects in browsers and other media plugins wont start and freeze the browser, Java programs tend to lock up (I have to end task spring before Netbeans will finish its loading sequence and display any GUI), and it prevents new instances of spring initializing.

Whatsmore, if I try to endtask it using the mouse rather than the keyboard, 7 times out of ten my entire OS freezes up and I can move the mouse but nothing will respond, no buttons can be clicked, the entire GUI just freezes and becomes unresponsive with no change, and it doesnt unfreeze untill spring.exe has exited, which requires a shutdown procedure and by the time it unfreezes it's too late to abort. This is why sometimes I randomly dissapear before starting a game.

The thing is that this shows up in th debugger under a release build yet I've never manged to compile my own spring.exe and get the same result, I'd do it now but I cant update my svn copy without breaking my AI compile process with the change in interface version and I dont wanna haveto deal withmultiple sourcedirectories again.......
User avatar
VonGratz
Posts: 471
Joined: 03 May 2005, 05:25

Post by VonGratz »

Hi!Try this...
VonGratz :wink:

piece base ,body ,lights ,dish1 ,dish2 ,dish3 ,dish4 ,dish5 ;

#DEFINE SMOKEPIECE1 base
#INCLUDE "StateChg.h"
#INCLUDE "exptype.h"
#INCLUDE "Hitweap.h"
#INCLUDE "smokeunit.h"
#INCLUDE "exptype.h"
Go()
{
SET ARMORED TO FALSE ;
DONT-CACHE lights;
DONT-CACHE dish1;
DONT-CACHE dish2;
DONT-CACHE dish3;
DONT-CACHE dish4;
DONT-CACHE dish5;
TURN dish1 to x-axis <-45> SPEED <40>;
TURN dish2 to x-axis <-45> SPEED <40>;
TURN dish3 to x-axis <-45> SPEED <40>;
TURN dish4 to x-axis <-45> SPEED <40>;
TURN dish5 to x-axis <-45> SPEED <40>;
}
Stop()
{
TURN dish1 to x-axis <0> SPEED <40>;
TURN dish2 to x-axis <0> SPEED <40>;
TURN dish3 to x-axis <0> SPEED <40>;
TURN dish4 to x-axis <0> SPEED <40>;
TURN dish5 to x-axis <0> SPEED <40>;
CACHE lights;
CACHE dish1;
CACHE dish2;
CACHE dish3;
CACHE dish4;
CACHE dish5;
SET ARMORED TO TRUE ;
}
#DEFINE ACTIVATECMD CALL-SCRIPT Go();
#DEFINE DEACTIVATECMD CALL-SCRIPT Stop();
#INCLUDE "StateChg.h"
Create()
{
DONT-SHADE dish1;
DONT-SHADE dish2;
DONT-SHADE dish3;
DONT-SHADE dish4;
DONT-SHADE dish5;
DONT-SHADE lights;
Var_Static02 = 0;
CALL-SCRIPT InitState();
START-SCRIPT SmokeUnit();
}
Activate()
{
START-SCRIPT RequestState( ACTIVE );
}
Deactivate()
{
START-SCRIPT RequestState( INACTIVE );
}
SetSpeed(the_speed)
{
}
SetDirection(dir)
{
}
SweetSpot(piecenum)
{
piecenum = body;
}
Killed(severity,corpsetype)
{
IF (severity <= 25 )
{
corpsetype = 1 ;
EXPLODE body type BITMAPONLY | BITMAP1;
EXPLODE lights type BITMAPONLY | BITMAP2;
EXPLODE dish3 type BITMAPONLY | BITMAP3;
}
IF (severity <= 50 )
{
corpsetype = 2 ;
EXPLODE body type BITMAPONLY | BITMAP1;
EXPLODE dish3 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP2;
EXPLODE lights type BITMAPONLY | BITMAP3;
RETURN ( 0 );
}
IF (severity <= 99 )
{
corpsetype = 3 ;
EXPLODE dish3 type BITMAPONLY | BITMAP1;
EXPLODE body type SHATTER | BITMAP2;
EXPLODE dish2 type BITMAPONLY | BITMAP3;
RETURN ( 0 );
}
corpsetype = 3 ;
EXPLODE dish2 type BITMAPONLY | BITMAP1;
EXPLODE body type SHATTER | BITMAP2;
EXPLODE dish4 type BITMAPONLY | BITMAP3;
}
User avatar
PauloMorfeo
Posts: 2004
Joined: 15 Dec 2004, 20:53

Post by PauloMorfeo »

VonGratz wrote:Hi!Try this...
It doesn't crashes Spring anymore. What was wrong with the other one?

Anyway, when compiling your script, scriptor gives some compilation errors:
Scriptor wrote:Compiling Bos...
Compiling StateChg.h
Compiling exptype.h
Compiling Hitweap.h
Error (18): Unknown identifier base [ C:\Documents and Settings\Paulo\Ambiente de trabalho\Scriptor_v1(RC1)\include\Hitweap.h ]
Error (19): Unknown identifier base [ C:\Documents and Settings\Paulo\Ambiente de trabalho\Scriptor_v1(RC1)\include\Hitweap.h ]
Error (21): Unknown identifier base [ C:\Documents and Settings\Paulo\Ambiente de trabalho\Scriptor_v1(RC1)\include\Hitweap.h ]
Error (22): Unknown identifier base [ C:\Documents and Settings\Paulo\Ambiente de trabalho\Scriptor_v1(RC1)\include\Hitweap.h ]
Error (24): Unknown identifier base [ C:\Documents and Settings\Paulo\Ambiente de trabalho\Scriptor_v1(RC1)\include\Hitweap.h ]
Error (25): Unknown identifier base [ C:\Documents and Settings\Paulo\Ambiente de trabalho\Scriptor_v1(RC1)\include\Hitweap.h ]
Compiling smokeunit.h
Compiling SFXtype.h
Compiling EXPtype.h
Error (159): Unknown identifier base [ C:\Documents and Settings\Paulo\Ambiente de trabalho\Scriptor_v1(RC1)\include\smokeunit.h ]
Compiling exptype.h
Compiling StateChg.h
Error (70): Unknown identifier Go [ C:\Documents and Settings\Paulo\Ambiente de trabalho\Scriptor_v1(RC1)\include\StateChg.h ]
Error (76): Unknown identifier Stop [ C:\Documents and Settings\Paulo\Ambiente de trabalho\Scriptor_v1(RC1)\include\StateChg.h ]
Error (54): Unknown Identifier Var_Static02 [ C:\jog\TASpring\mods\Testes.sdd\Scripts\TllWindTrap.bos ]

One or more errors occured while compiling the script.
So i don't really know which script i am better off using...
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Write it from scratch, you've got basic programming skills and you don't need more to get the hang of bos scripting.

The script kills the compiler here when compiling in TAK mode (probably because of duplicated includes) or spits out missing var errors when compiling in TA mode. What ever, it's not that hard to recreate, you'll want to know how to do your own scripts anyway if you plan on improving the TLL race. :)
User avatar
VonGratz
Posts: 471
Joined: 03 May 2005, 05:25

Post by VonGratz »

Pick up the original Cavedog head files (*.h) and put in Scriptor..
VonGratz :wink:
Post Reply

Return to “Engine”