forked from github/server
gamedate: no negative turns allowed.
feed the beast assert.
This commit is contained in:
parent
29061fa4ba
commit
bf935f5bb7
5 changed files with 5 additions and 5 deletions
|
@ -921,7 +921,7 @@ static int init_data(const char *filename, const char *catalog)
|
|||
if (l) {
|
||||
return l;
|
||||
}
|
||||
if (turn < 0) {
|
||||
if (turn <= 0) {
|
||||
turn = first_turn();
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -27,8 +27,7 @@ const gamedate *get_gamedate(int turn, gamedate * gd)
|
|||
int t = turn - first_turn();
|
||||
|
||||
assert(gd);
|
||||
if (t < 0)
|
||||
t = turn;
|
||||
assert(t >= 0);
|
||||
|
||||
gd->week = t % weeks_per_month; /* 0 - weeks_per_month-1 */
|
||||
gd->month = (t / weeks_per_month + first_month) % months_per_year; /* 0 - months_per_year-1 */
|
||||
|
|
|
@ -96,7 +96,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
struct settings global;
|
||||
|
||||
bool lomem = false;
|
||||
int turn = -1;
|
||||
int turn = 0;
|
||||
|
||||
const char *parameters[MAXPARAMS] = {
|
||||
"LOCALE",
|
||||
|
|
|
@ -4183,6 +4183,7 @@ static void reset_game(void)
|
|||
|
||||
void turn_begin(void)
|
||||
{
|
||||
assert(turn >= 0);
|
||||
++turn;
|
||||
reset_game();
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ void test_log_stderr(int flags) {
|
|||
|
||||
static void test_reset(void) {
|
||||
int i;
|
||||
turn = 0;
|
||||
turn = 1;
|
||||
default_locale = 0;
|
||||
|
||||
if (errno) {
|
||||
|
|
Loading…
Reference in a new issue