fix gcc issues with new season_t type.

This commit is contained in:
Enno Rehling 2019-08-25 18:14:03 +02:00
parent 8bed3f3329
commit eb95613996
4 changed files with 5 additions and 5 deletions

View File

@ -792,7 +792,7 @@ static void json_calendar(cJSON *json) {
for (i = 0, jmonth = child->child; jmonth; jmonth = jmonth->next, ++i) {
if (jmonth->type == cJSON_Object) {
storms[i] = cJSON_GetObjectItem(jmonth, "storm")->valueint;
month_season[i] = cJSON_GetObjectItem(jmonth, "season")->valueint;
month_season[i] = (season_t) cJSON_GetObjectItem(jmonth, "season")->valueint;
}
else {
log_error("calendar.months[%d] is not an object: %d", i, json->type);

View File

@ -160,8 +160,8 @@ static void test_calendar(CuTest * tc)
CuAssertIntEquals(tc, 99, storms[0]);
CuAssertIntEquals(tc, 22, storms[1]);
CuAssertPtrNotNull(tc, month_season);
CuAssertIntEquals(tc, 1, month_season[0]);
CuAssertIntEquals(tc, 2, month_season[1]);
CuAssertIntEquals(tc, SEASON_SPRING, month_season[0]);
CuAssertIntEquals(tc, SEASON_SUMMER, month_season[1]);
cJSON_Delete(json);
test_teardown();
}

View File

@ -15,7 +15,7 @@ extern "C" {
extern const char *seasonnames[CALENDAR_SEASONS];
extern int months_per_year;
extern int *month_season;
extern season_t *month_season;
extern int first_month;
extern int turn;

View File

@ -71,7 +71,7 @@ static void setup_calendar() {
months_per_year = 4;
weeks_per_month = 2;
free(month_season);
month_season = calloc(months_per_year, sizeof(int));
month_season = calloc(months_per_year, sizeof(season_t));
for (i = 0; i != 4; ++i) {
month_season[i] = (season_t)i;
}