# HG changeset patch # User truebrain # Date 1214861273 0 # Node ID 8e553098ad05c88e24a19ccb9949b76a6f0740d5 # Parent fc7b43610af259ce26b28427919f88c71704cfac (svn r13668) [NoAI] -Add: execute 'game_start.scr' on game-start or scenario load, to allow you to load AIs on game-start [NoAI] -Fix: -vnull acts a bit more like a dedicated server, to avoid weird complexity on several places diff -r fc7b43610af2 -r 8e553098ad05 bin/scripts/game_start.scr.example --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/scripts/game_start.scr.example Mon Jun 30 21:27:53 2008 +0000 @@ -0,0 +1,2 @@ +start_ai MyAI + diff -r fc7b43610af2 -r 8e553098ad05 src/genworld.cpp --- a/src/genworld.cpp Mon Jun 30 19:35:57 2008 +0000 +++ b/src/genworld.cpp Mon Jun 30 21:27:53 2008 +0000 @@ -25,6 +25,7 @@ #include "settings_type.h" #include "newgrf_storage.h" #include "water.h" +#include "blitter/factory.hpp" #include "tilehighlight_func.h" #include "table/sprites.h" @@ -291,7 +292,7 @@ _gw.thread = NULL; } - if (_network_dedicated || + if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() == 0 || (_gw.thread = ThreadObject::New(&_GenerateWorld, NULL)) == NULL) { DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode"); _gw.threaded = false; diff -r fc7b43610af2 -r 8e553098ad05 src/openttd.cpp --- a/src/openttd.cpp Mon Jun 30 19:35:57 2008 +0000 +++ b/src/openttd.cpp Mon Jun 30 21:27:53 2008 +0000 @@ -694,14 +694,17 @@ static void MakeNewGameDone() { /* In a dedicated server, the server does not play */ - if (_network_dedicated) { + if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() == 0) { SetLocalPlayer(PLAYER_SPECTATOR); + IConsoleCmdExec("exec scripts/game_start.scr 0"); return; } /* Create a single player */ DoStartupNewPlayer(false); + IConsoleCmdExec("exec scripts/game_start.scr 0"); + SetLocalPlayer(PLAYER_FIRST); _current_player = _local_player; DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE); @@ -906,6 +909,8 @@ /* Update the local player for a loaded game. It is either always * player #1 (eg 0) or in the case of a dedicated server a spectator */ SetLocalPlayer(_network_dedicated ? PLAYER_SPECTATOR : PLAYER_FIRST); + /* Execute the game-start script */ + IConsoleCmdExec("exec scripts/game_start.scr 0"); /* Decrease pause counter (was increased from opening load dialog) */ DoCommandP(0, 0, 0, NULL, CMD_PAUSE); #ifdef ENABLE_NETWORK