detect crashes

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 097.
Note: Core 097 is no longer officially supported.

Moderator: POL Developer

Post Reply
phao
Grandmaster Poster
Posts: 129
Joined: Fri Aug 31, 2007 2:25 pm
Location: Brazil

detect crashes

Post by phao »

how can I detect a crash in start script? to see if the last pol close was made by a crash or by ctrl-C ??

and, saveworldstate() function save every prop in datafiles?
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

You could save a global property just before calling Shutdown(). Then, in start.src that property is read, and if it returns error (unset property), you know POL crashed. If property exists, you have to erase it.

As far as I know, CTRL+C is reserved command and thus you cannot manipulate its actions. You could however create a script shutdownalias.src into scripts/console/, add a command, say, CTRL+X, and use that instead of hardcoded shutdown.

Scriptwise the whole setting would look like this.

A new line to /config/console.cfg

Code: Select all

CMD ^X shutdownalias Forces shutdown.
/scripts/console/shutdownalias.src

Code: Select all

use uo;

program shutdownalias( )
    
    SetGlobalProperty("CleanShutdown", 1);
    Shutdown();
    
endprogram
A new line to /scripts/start.src

Code: Select all

// Inside the program block...
if (GetGlobalProperty("CleanShutdown"))
    Print("POL did not crash.");
    EraseGlobalProperty("CleanShutdown");
else
    Print("POL crashed!");
endif
And before every other Shutdown() function call..

Code: Select all

SetGlobalProperty("CleanShutdown", 1);
I do not use this myself, and thus cannot guarantee that it would work for sure. Anyhow this should give you an idea.
phao
Grandmaster Poster
Posts: 129
Joined: Fri Aug 31, 2007 2:25 pm
Location: Brazil

Post by phao »

lol, take a look on that:
console.cfg

Code: Select all

Commands
{
	CMD w exitpol POL safe exit
	CMD u [unlock]
	CMD l [lock]
}
console output:

Code: Select all

Console is locked.  Press 'u' to unlock.
Console is now unlocked.
Console is locked.  Press 'u' to unlock.
Console is now unlocked.
every "Console is locked. Press 'u' to unlock." message is an 'w' keypress I am doing.
Post Reply