Add debug command line switch to quit after fixed number of days
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "linkgraph/linkgraph.h"
|
||||
#include "saveload/saveload.h"
|
||||
#include "console_func.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
@@ -32,6 +33,7 @@ uint16 _tick_counter; ///< Ever incrementing (and sometimes wrapping) tick coun
|
||||
uint8 _tick_skip_counter; ///< Counter for ticks, when only vehicles are moving and nothing else happens
|
||||
uint32 _scaled_tick_counter; ///< Tick counter in daylength-scaled ticks
|
||||
DateTicksScaled _scaled_date_ticks; ///< Date as ticks in daylength-scaled ticks
|
||||
uint32 _quit_after_days; ///< Quit after this many days of run time
|
||||
|
||||
/**
|
||||
* Set the date.
|
||||
@@ -280,6 +282,13 @@ static void OnNewDay()
|
||||
/* Refresh after possible snowline change */
|
||||
SetWindowClassesDirty(WC_TOWN_VIEW);
|
||||
IConsoleCmdExec("exec scripts/on_newday.scr 0");
|
||||
|
||||
if (_quit_after_days > 0) {
|
||||
if (--_quit_after_days == 0) {
|
||||
DEBUG(misc, 0, "Quitting as day limit reached");
|
||||
_exit_game = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -22,6 +22,7 @@ extern uint16 _tick_counter;
|
||||
extern uint8 _tick_skip_counter;
|
||||
extern uint32 _scaled_tick_counter;
|
||||
extern DateTicksScaled _scaled_date_ticks;
|
||||
extern uint32 _quit_after_days;
|
||||
|
||||
void SetDate(Date date, DateFract fract);
|
||||
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
||||
|
@@ -569,6 +569,7 @@ static const OptionData _options[] = {
|
||||
GETOPT_SHORT_NOVAL('x'),
|
||||
GETOPT_SHORT_VALUE('q'),
|
||||
GETOPT_SHORT_NOVAL('h'),
|
||||
GETOPT_SHORT_VALUE('J'),
|
||||
GETOPT_END()
|
||||
};
|
||||
|
||||
@@ -717,6 +718,7 @@ int openttd_main(int argc, char *argv[])
|
||||
case 'G': scanner->generation_seed = atoi(mgo.opt); break;
|
||||
case 'c': free(_config_file); _config_file = stredup(mgo.opt); break;
|
||||
case 'x': scanner->save_config = false; break;
|
||||
case 'J': _quit_after_days = Clamp(atoi(mgo.opt), 0, INT_MAX); break;
|
||||
case 'h':
|
||||
i = -2; // Force printing of help.
|
||||
break;
|
||||
|
Reference in New Issue
Block a user