73 void CallLandscapeTick();
 
   75 void DoPaletteAnimations();
 
   82 extern void ShowOSErrorBox(
const char *buf, 
bool system);
 
   99   ShowOSErrorBox(buf, 
false);
 
  110 void CDECL 
error(
const char *s, ...)
 
  119   ShowOSErrorBox(buf, 
true);
 
  152     "Command line options:\n" 
  153     "  -v drv              = Set video driver (see below)\n" 
  154     "  -s drv              = Set sound driver (see below) (param bufsize,hz)\n" 
  155     "  -m drv              = Set music driver (see below)\n" 
  156     "  -b drv              = Set the blitter to use (see below)\n" 
  157     "  -r res              = Set resolution (for instance 800x600)\n" 
  158     "  -h                  = Display this help text\n" 
  159     "  -t year             = Set starting year\n" 
  160     "  -d [[fac=]lvl[,...]]= Debug mode\n" 
  161     "  -e                  = Start Editor\n" 
  162     "  -g [savegame]       = Start new/save game immediately\n" 
  163     "  -G seed             = Set random seed\n" 
  164 #
if defined(ENABLE_NETWORK)
 
  165     "  -n [ip:port#company]= Join network game\n" 
  166     "  -p password         = Password to join server\n" 
  167     "  -P password         = Password to join company\n" 
  168     "  -D [ip][:port]      = Start dedicated server\n" 
  169     "  -l ip[:port]        = Redirect DEBUG()\n" 
  170 #
if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
 
  171     "  -f                  = Fork into the background (dedicated only)\n" 
  174     "  -I graphics_set     = Force the graphics set (see below)\n" 
  175     "  -S sounds_set       = Force the sounds set (see below)\n" 
  176     "  -M music_set        = Force the music set (see below)\n" 
  177     "  -c config_file      = Use 'config_file' instead of 'openttd.cfg'\n" 
  178     "  -x                  = Do not automatically save to config file on exit\n" 
  179     "  -q savegame         = Write some information about the savegame and exit\n" 
  214 #if !defined(WIN32) && !defined(WIN64) 
  221 static void WriteSavegameInfo(
const char *
name)
 
  224   uint32 last_ottd_rev = 0;
 
  225   byte ever_modified = 0;
 
  226   bool removed_newgrfs = 
false;
 
  234   p += 
seprintf(p, 
lastof(buf), 
"NewGRF ver:   0x%08X\n", last_ottd_rev);
 
  237   if (removed_newgrfs) {
 
  246       p += 
seprintf(p, 
lastof(buf), 
"%08X %s %s\n", c->ident.grfid, md5sum, c->filename);
 
  252 #if !defined(WIN32) && !defined(WIN64) 
  268   const char *t = strchr(s, 
'x');
 
  274   res->width  = 
max(strtoul(s, NULL, 0), 64UL);
 
  275   res->height = 
max(strtoul(t + 1, NULL, 0), 64UL);
 
  300 #ifdef ENABLE_NETWORK 
  322   _game_mode = GM_MENU;
 
  349 void MakeNewgameSettingsLive()
 
  377 void OpenBrowser(
const char *url)
 
  380   if (strstr(url, 
"http://") != url && strstr(url, 
"https://") != url) 
return;
 
  382   extern void OSOpenBrowser(
const char *url);
 
  407       save_config_ptr(save_config_ptr), 
save_config(true)
 
  444 #if defined(ENABLE_NETWORK) 
  460 #ifdef ENABLE_NETWORK 
  462       const char *port = NULL;
 
  463       const char *company = NULL;
 
  469       if (company != NULL) {
 
  474           if (join_as >= MAX_COMPANIES) {
 
  480       if (port != NULL) rport = atoi(port);
 
  493 #if defined(UNIX) && !defined(__MORPHOS__) 
  494 extern void DedicatedFork();
 
  506 #if defined(ENABLE_NETWORK) 
  512 #if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32) 
  537   char *musicdriver = NULL;
 
  538   char *sounddriver = NULL;
 
  539   char *videodriver = NULL;
 
  540   char *blitter = NULL;
 
  541   char *graphics_set = NULL;
 
  542   char *sounds_set = NULL;
 
  543   char *music_set = NULL;
 
  546   bool save_config = 
false;
 
  548 #if defined(ENABLE_NETWORK) 
  549   bool dedicated = 
false;
 
  550   char *debuglog_conn = NULL;
 
  552   extern bool _dedicated_forks;
 
  553   _dedicated_forks = 
false;
 
  556   _game_mode = GM_MENU;
 
  564   while ((i = mgo.
GetOpt()) != -1) {
 
  566     case 'I': 
free(graphics_set); graphics_set = 
stredup(mgo.
opt); 
break;
 
  569     case 'm': 
free(musicdriver); musicdriver = 
stredup(mgo.
opt); 
break;
 
  570     case 's': 
free(sounddriver); sounddriver = 
stredup(mgo.
opt); 
break;
 
  571     case 'v': 
free(videodriver); videodriver = 
stredup(mgo.
opt); 
break;
 
  573 #if defined(ENABLE_NETWORK) 
  581       videodriver = 
stredup(
"dedicated");
 
  585       if (mgo.
opt != NULL) {
 
  588         const char *temp = NULL;
 
  589         const char *port = NULL;
 
  595     case 'f': _dedicated_forks = 
true; 
break;
 
  600       debuglog_conn = mgo.
opt;
 
  620       if (mgo.
opt != NULL) {
 
  646         goto exit_noshutdown;
 
  656         fprintf(stderr, 
"Failed to open savegame\n");
 
  661           fprintf(stderr, 
"%s\n", buf);
 
  663         goto exit_noshutdown;
 
  666       WriteSavegameInfo(title);
 
  668       goto exit_noshutdown;
 
  680   if (i == -2 || mgo.
numleft > 0) {
 
  693     goto exit_noshutdown;
 
  696 #if defined(WINCE) && defined(_DEBUG) 
  704 #if defined(ENABLE_NETWORK) 
  705   if (dedicated) 
DEBUG(net, 0, 
"Starting dedicated version %s", _openttd_revision);
 
  706   if (_dedicated_forks && !dedicated) _dedicated_forks = 
false;
 
  708 #if defined(UNIX) && !defined(__MORPHOS__) 
  710   if (_dedicated_forks) DedicatedFork();
 
  748       ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_GRAPHICS_NOT_FOUND);
 
  758   DEBUG(misc, 1, 
"Loading blitter...");
 
  772         usererror(
"Failed to autoprobe blitter") :
 
  773         usererror(
"Failed to select requested blitter '%s'; does it exist?", blitter);
 
  789 #if defined(ENABLE_NETWORK) 
  791     const char *not_used = NULL;
 
  792     const char *port = NULL;
 
  798     if (port != NULL) rport = atoi(port);
 
  819       usererror(
"Failed to find a sounds set. Please acquire a sounds set for OpenTTD. See section 4.1 of readme.txt.");
 
  821       ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_SOUNDS_NOT_FOUND);
 
  832       usererror(
"Failed to find a music set. Please acquire a music set for OpenTTD. See section 4.1 of readme.txt.");
 
  834       ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_BASE_MUSIC_NOT_FOUND);
 
  905 #ifdef ENABLE_NETWORK 
  907   if (_log_fd != NULL) {
 
  915 void HandleExitGameRequest()
 
  917   if (_game_mode == GM_MENU || _game_mode == GM_BOOTSTRAP) { 
 
  927 static void MakeNewGameDone()
 
  951 #ifdef ENABLE_NETWORK 
  966 static void MakeNewGame(
bool from_heightmap, 
bool reset_settings)
 
  968   _game_mode = GM_NORMAL;
 
  976 static void MakeNewEditorWorldDone()
 
  981 static void MakeNewEditorWorld()
 
  983   _game_mode = GM_EDITOR;
 
 1010     case SL_OK: 
return true;
 
 1013 #ifdef ENABLE_NETWORK 
 1021         DEBUG(net, 0, 
"Loading game failed, so a new (random) game will be started!");
 
 1022         MakeNewGame(
false, 
true);
 
 1034         case GM_EDITOR: MakeNewEditorWorld(); 
break;
 
 1046 #ifdef ENABLE_NETWORK 
 1065           MakeNewgameSettingsLive();
 
 1068         NetworkServerStart();
 
 1081       MakeNewEditorWorld();
 
 1086 #ifdef ENABLE_NETWORK 
 1113 #ifdef ENABLE_NETWORK 
 1123 #ifdef ENABLE_NETWORK 
 1128       MakeNewGame(
true, 
true);
 
 1181     default: NOT_REACHED();
 
 1196   if (_debug_desync_level <= 1) 
return;
 
 1212       DEBUG(desync, 2, 
"town cache mismatch: town %i", (
int)t->
index);
 
 1226   FOR_ALL_COMPANIES(c) {
 
 1228       DEBUG(desync, 2, 
"infrastructure cache mismatch: company %i", (
int)c->
index);
 
 1235   FOR_ALL_ROADSTOPS(rs) {
 
 1249     for (
const Vehicle *u = v; u != NULL; u = u->
Next()) length++;
 
 1251     NewGRFCache        *grf_cache = CallocT<NewGRFCache>(length);
 
 1252     VehicleCache       *veh_cache = CallocT<VehicleCache>(length);
 
 1254     TrainCache         *tra_cache = CallocT<TrainCache>(length);
 
 1257     for (
const Vehicle *u = v; u != NULL; u = u->
Next()) {
 
 1259       grf_cache[length] = u->grf_cache;
 
 1260       veh_cache[length] = u->vcache;
 
 1284     for (
const Vehicle *u = v; u != NULL; u = u->
Next()) {
 
 1286       if (memcmp(&grf_cache[length], &u->grf_cache, 
sizeof(
NewGRFCache)) != 0) {
 
 1287         DEBUG(desync, 2, 
"newgrf cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (
int)v->
type, v->
index, (
int)v->
owner, v->
unitnumber, length);
 
 1289       if (memcmp(&veh_cache[length], &u->vcache, 
sizeof(
VehicleCache)) != 0) {
 
 1290         DEBUG(desync, 2, 
"vehicle cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (
int)v->
type, v->
index, (
int)v->
owner, v->
unitnumber, length);
 
 1295             DEBUG(desync, 2, 
"train ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->
index, (
int)v->
owner, v->
unitnumber, length);
 
 1298             DEBUG(desync, 2, 
"train cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->
index, (
int)v->
owner, v->
unitnumber, length);
 
 1303             DEBUG(desync, 2, 
"road vehicle ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->
index, (
int)v->
owner, v->
unitnumber, length);
 
 1327   FOR_ALL_STATIONS(st) {
 
 1347 #ifndef DEBUG_DUMP_COMMANDS 
 1357   if (_game_mode == GM_EDITOR) {
 
 1361     CallLandscapeTick();
 
 1370       char name[MAX_PATH];
 
 1386     CallLandscapeTick();
 
 1389 #ifndef DEBUG_DUMP_COMMANDS 
 1420     static int _autosave_ctr = 0;
 
 1428   DEBUG(sl, 2, 
"Autosaving to '%s'", buf);
 
 1436   if (_game_mode == GM_BOOTSTRAP) {
 
 1437 #ifdef ENABLE_NETWORK 
 1460   IncreaseSpriteLRU();
 
 1461   InteractiveRandom();
 
 1463   extern int _caret_timer;
 
 1467 #ifdef ENABLE_NETWORK 
 1485   static uint check_message = 0;