Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Technocrat on Thu 26/11/2009 21:21:49

Title: Intentionally causing crashes...
Post by: Technocrat on Thu 26/11/2009 21:21:49
Bit of an odd question perhaps, but for the purpose of a game, I'm looking to cause the game to crash when then user does something. Not just "close down and pretend it's a crash", but a proper, error-message creating crash, for authenticity's sake.

A lot of the time when I'm making something in the script that'll lead to a mistake, the game refuses to compile. I've managed to cause stack overflow errors, but what other kinds of interesting problems can I deliberately cause and how, for variety's sake?
Title: Re: Intentionally causing crashes...
Post by: Calin Leafshade on Thu 26/11/2009 21:25:41
A missing event handler will compile but error.

Title: Re: Intentionally causing crashes...
Post by: suicidal pencil on Thu 26/11/2009 22:12:14
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=39326.0
Title: Re: Intentionally causing crashes...
Post by: Ryan Timothy B on Thu 26/11/2009 22:48:03
I'm not sure why you'd want to intentionally crash AGS.  If it's for a game, I would find it quite annoying and/or unprofessional.  But I imagine you have your reasons...
Title: Re: Intentionally causing crashes...
Post by: Gilbert on Fri 27/11/2009 01:02:20
Well, it's been done in games already. As far as I remember, at least one AGS game (I forget which) did this as a joke when you beat the game. There may be more.

But since those games were made with earlier versions of AGS the same method may not be applicable now (due to scripting system changes and improved error handling and such).

One particular trick you can use is to try to do illegal stuff such that the editor isn't smart enough to spot at compile time. A very simple way is to access an array with an out-of-bound index. Since if you put the index directly into the script the game may not compile (I'm not sure about this) you may indirectly use a variable as the index instead.

Something like:

int blah[2];
int bigindex=10;
blah[bigindex]=4;

This should crash the game, as since V2.7 array bound checks are implemented (before V2.7 the engine will just go on, corrupting memory and would possibly cause undesired fatal effects).
Title: Re: Intentionally causing crashes...
Post by: Wonkyth on Fri 27/11/2009 01:26:59
I assume that the AbortGame() method is out of the question?
Title: Re: Intentionally causing crashes...
Post by: Technocrat on Fri 27/11/2009 11:14:09
Of course, a game crashing when you don't expect it to is annoying, but in this case there's a good reason for it (I promise!)

Some interesting ideas, merci beaucoup! Looks like I've got some crashes to engneer...
Title: Re: Intentionally causing crashes...
Post by: Charity on Sat 28/11/2009 08:30:40
You could do an infinite while loop, though it'll lock up before crashing, which might be annoying.  Or is that the same as a stack overflow?
Title: Re: Intentionally causing crashes...
Post by: suicidal pencil on Sun 29/11/2009 01:17:11
Quote from: Lyaer on Sat 28/11/2009 08:30:40
You could do an infinite while loop, though it'll lock up before crashing, which might be annoying.  Or is that the same as a stack overflow?

No. A stack overflow is when too much memory is used in the call stack.

Like so:

function sub1()
{
 sub1();
}


Calling that function will result in an infinite recursion loop, and a Stack Overflow.