Page 1 of 1

Find the hidden error - GAME!

Posted: 08 May 2007, 19:36
by TradeMark
Can you find the hidden error which causes crashes randomly when using high amount of units with this script?

Winner gets free lollipop!

Code: Select all

#define TA			// This is a TA script

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

piece  base, body, aim, emitnano;

static-var  Static_Var_1, Static_Var_2, statechg_DesiredState, statechg_StateChanging;


Activatescr()
{
	sleep 1;
}

Deactivatescr()
{
	sleep 1;
}

SmokeUnit(healthpercent, sleeptime, smoketype)
{
	while( get BUILD_PERCENT_LEFT )
	{
		sleep 400;
	}
	while( TRUE )
	{
		healthpercent = get HEALTH;
		if( healthpercent < 66 )
		{
			smoketype = 256 | 2;
			if( Rand( 1, 66 ) < healthpercent )
			{
				smoketype = 256 | 1;
			}
			emit-sfx smoketype from aim;
		}
		sleeptime = healthpercent * 50;
		if( sleeptime < 200 )
		{
			sleeptime = 200;
		}
		sleep sleeptime;
	}
}

Go()
{
	call-script Activatescr();
	turn aim to y-axis Static_Var_1 speed <160.000000>;
	wait-for-turn aim around y-axis;
	set INBUILDSTANCE to 1;
}

Stop()
{
	set INBUILDSTANCE to 0;
	call-script Deactivatescr();
}

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()
{
	call-script InitState();
	start-script SmokeUnit();
	Static_Var_1 = 0;
	Static_Var_2 = 5000;
}

RestoreAfterDelay()
{
	sleep Static_Var_2;
	turn aim to y-axis <0.000000> speed <100.000000>;
	wait-for-turn aim around y-axis;
}

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

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

StartBuilding(Func_Var_1)
{
	Static_Var_1 = Func_Var_1;
	start-script RequestState(0);
}

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

QueryNanoPiece(piecenum)
{
	piecenum = emitnano;
}

TargetHeading(Func_Var_1)
{
	Static_Var_1 = 0 - Func_Var_1;
}

SweetSpot(piecenum)
{
	piecenum = aim;
}

Killed(severity, corpsetype)
{
	if( severity <= 25 )
	{
		corpsetype = 1;
		explode base type BITMAPONLY | BITMAP1;
		explode aim type BITMAPONLY | BITMAP3;
		return (0);
	}
	if( severity <= 50 )
	{
		corpsetype = 2;
		explode base type FALL | BITMAP1;
		explode aim type FALL | BITMAP3;
		return (0);
	}
	if( severity <= 99 )
	{
		corpsetype = 3;
		explode base type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
		explode aim type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
		return (0);
	}
	corpsetype = 3;
	explode base type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
	explode aim type SHATTER | EXPLODE_ON_HIT | BITMAP3;
}
Seriously, thats armnanotc script, and ive noticed that it causes spring crash very often when im using many nanotowers at once.

Posted: 08 May 2007, 19:53
by rattle
Not really no. Try recompiling it as TAK script (#define TAK + TAK icon in scriptor) and see if it changes anything.

Posted: 08 May 2007, 20:36
by Neddie
The issue is probably the large spikes of synced data you have to send due to the nanolathe, though I'm no expert. Oh, and there are more efficent ways to assist construction than with nanoturrets.

Posted: 08 May 2007, 20:42
by Peet
That TA state script set is rather pointless, especially considering that there's no activation animation.

Posted: 08 May 2007, 20:46
by Tobi
neddiedrow wrote:The issue is probably the large spikes of synced data you have to send due to the nanolathe, though I'm no expert. Oh, and there are more efficent ways to assist construction than with nanoturrets.
It's a widespread myth, but nanolathe being synced does not mean any data has to be sent over the net for it. The only practical thing it means is that the amount of nanolathe particles can't be reduced to fit below your max particle count.

Posted: 08 May 2007, 21:07
by Neddie
Well, then this entire thread has no point. I can't see any errors in the script, and none of the emergent factors would bear on the problem!

Posted: 08 May 2007, 21:59
by rattle
Same. The script is fine as it is.
P3374H wrote:That TA state script set is rather pointless
Yeah. If someone could engligthen us what it's actually good for...

Posted: 09 May 2007, 00:26
by Dragon45
Make sure you're not SHATTER 'ing any point objects.

Posted: 09 May 2007, 10:06
by zwzsg
That was a TA issue, not a Spring one, afaik, Dragon45. And he never mentionned crashes when his nanoturret die, but when they are built in masses.



I was about to complain about how that script is uber ugly, then I unscripted a Cavedog ArmCK and it was almost as ugly. Try this simplified script:

Code: Select all

#define TA// This is a TA script

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

piecebase, body, aim, emitnano;


SmokeUnit()
{
	var healthpercent, sleeptime, smoketype;
	while( get BUILD_PERCENT_LEFT )
	{
		sleep 400;
	}
	while( TRUE )
	{
		healthpercent = get HEALTH;
		if( healthpercent < 66 )
		{
			smoketype = SFXTYPE_BLACKSMOKE;
			if( Rand( 1, 66 ) < healthpercent )
			{
				smoketype = SFXTYPE_WHITESMOKE;
			}
			emit-sfx smoketype from hull;
		}
		sleeptime = healthpercent * 50;
		if( sleeptime < 200 )
		{
			sleeptime = 200;
		}
		sleep sleeptime;
	}
}

Create()
{
	set INBUILDSTANCE to TRUE;
	start-script SmokeUnit();
}

StartBuilding(heading)
{
	turn aim to y-axis heading now;
}

QueryNanoPiece(piecenum)
{
	piecenum = emitnano;
}

SweetSpot(piecenum)
{
	piecenum=aim;
}

Killed(severity, corpsetype)
{
	if(severity<=25)
	{
		corpsetype=1;
		explode base type BITMAPONLY | BITMAP1;
		explode aim type BITMAPONLY | BITMAP3;
		return;
	}
	if(severity<=50)
	{
		corpsetype=2;
		explode base type FALL | BITMAP1;
		explode aim type FALL | BITMAP3;
		return;
	}
	corpsetype=3;
	explode base type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | 	BITMAP1;
	explode aim type SHATTER | EXPLODE_ON_HIT | BITMAP3;
	return;
}

Posted: 09 May 2007, 10:12
by KDR_11k
The BITMAP flags are ignored by Spring and EXPLODE_ON_HIT means "do 20 damage to other units".

Posted: 09 May 2007, 10:52
by TradeMark
Tobi wrote:
neddiedrow wrote:The issue is probably the large spikes of synced data you have to send due to the nanolathe, though I'm no expert. Oh, and there are more efficent ways to assist construction than with nanoturrets.
It's a widespread myth, but nanolathe being synced does not mean any data has to be sent over the net for it. The only practical thing it means is that the amount of nanolathe particles can't be reduced to fit below your max particle count.
So my spring crashes because those particles cant fit to my memory? I use low particle count anyways. But i havent noticed less crashes when ive used full particle count.

Posted: 09 May 2007, 11:02
by Neddie
The point is that the nanoturrets can't be the cause. Next!

Posted: 09 May 2007, 11:04
by TradeMark
It must be. :shock:

It happens so many times to me. When i start building with nanos, and then click -> spring crash.

Posted: 09 May 2007, 11:07
by Tobi
Post infolog.txt w/ stacktrace?

Posted: 09 May 2007, 11:10
by TradeMark
I dont save them anymore, because i was told they were useless.

Posted: 09 May 2007, 11:24
by Tobi
Ah, because you spammed them on mantis yeah, didn't include any information regarding which mod/map, how to reproduce etc. and many (if not all) of them didn't contain a stacktrace at all...

Posted: 09 May 2007, 23:14
by rattle
In regard to this someone should make a locked sticky thread about good and bad bug reporting. :)

Posted: 10 May 2007, 00:03
by Tobi