static void Load_GLOG_common(LoggedAction *&gamelog_action, uint &gamelog_actions) { assert(gamelog_action == NULL); assert(gamelog_actions == 0); GamelogActionType at; while ((at = (GamelogActionType)SlReadByte()) != GLAT_NONE) { gamelog_action = ReallocT(gamelog_action, gamelog_actions + 1); LoggedAction *la = &gamelog_action[gamelog_actions++]; la->at = at; SlObject(la, _glog_action_desc); // has to be saved after 'DATE'! la->change = NULL; la->changes = 0; GamelogChangeType ct; while ((ct = (GamelogChangeType)SlReadByte()) != GLCT_NONE) { la->change = ReallocT(la->change, la->changes + 1); LoggedChange *lc = &la->change[la->changes++]; /* for SLE_STR, pointer has to be valid! so make it NULL */ memset(lc, 0, sizeof(*lc)); lc->ct = ct; assert((uint)ct < GLCT_END); SlObject(lc, _glog_desc[ct]); } } }
static void Load_CHTS() { Cheat *cht = (Cheat*)&_cheats; size_t count = SlGetFieldLength() / 2; for (uint i = 0; i < count; i++) { cht[i].been_used = (SlReadByte() != 0); cht[i].value = (SlReadByte() != 0); } }
/** * Load the cheat values. */ static void Load_CHTS() { Cheat *cht = (Cheat*)&_cheats; size_t count = SlGetFieldLength() / 2; /* Cannot use lengthof because _cheats is of type Cheats, not Cheat */ if (count > sizeof(_cheats) / sizeof(Cheat)) SlErrorCorrupt("Too many cheat values"); for (uint i = 0; i < count; i++) { cht[i].been_used = (SlReadByte() != 0); cht[i].value = (SlReadByte() != 0); } }
static void Load_STNN() { int index; while ((index = SlIterateArray()) != -1) { bool waypoint = (SlReadByte() & FACIL_WAYPOINT) != 0; BaseStation *bst = waypoint ? (BaseStation *)new (index) Waypoint() : new (index) Station(); SlObject(bst, waypoint ? _waypoint_desc : _station_desc); if (!waypoint) { Station *st = Station::From(bst); for (CargoID i = 0; i < NUM_CARGO; i++) { SlObject(&st->goods[i], GetGoodsDesc()); } } if (bst->num_specs != 0) { /* Allocate speclist memory when loading a game */ bst->speclist = CallocT<StationSpecList>(bst->num_specs); for (uint i = 0; i < bst->num_specs; i++) { SlObject(&bst->speclist[i], _station_speclist_desc); } } } }