static void Save_GLOG() { const LoggedAction *laend = &_gamelog_action[_gamelog_actions]; size_t length = 0; for (const LoggedAction *la = _gamelog_action; la != laend; la++) { const LoggedChange *lcend = &la->change[la->changes]; for (LoggedChange *lc = la->change; lc != lcend; lc++) { assert((uint)lc->ct < lengthof(_glog_desc)); length += SlCalcObjLength(lc, _glog_desc[lc->ct]) + 1; } length += 4; } length++; SlSetLength(length); for (LoggedAction *la = _gamelog_action; la != laend; la++) { SlWriteByte(la->at); SlObject(la, _glog_action_desc); const LoggedChange *lcend = &la->change[la->changes]; for (LoggedChange *lc = la->change; lc != lcend; lc++) { SlWriteByte(lc->ct); assert((uint)lc->ct < GLCT_END); SlObject(lc, _glog_desc[lc->ct]); } SlWriteByte(GLCT_NONE); } SlWriteByte(GLAT_NONE); }
static void Save_MAPH() { SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; TileIndex size = MapSize(); SlSetLength(size); for (TileIndex i = 0; i != size;) { for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _main_map.m[i++].height; SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); } }
static void Save_MAP2() { SmallStackSafeStackAlloc<uint16, MAP_SL_BUF_SIZE> buf; TileIndex size = MapSize(); SlSetLength(size * sizeof(uint16)); for (TileIndex i = 0; i != size;) { for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _main_map.m[i++].m2; SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT16); } }
/** * Save the cheat values. */ static void Save_CHTS() { /* Cannot use lengthof because _cheats is of type Cheats, not Cheat */ byte count = sizeof(_cheats) / sizeof(Cheat); Cheat *cht = (Cheat*) &_cheats; Cheat *cht_last = &cht[count]; SlSetLength(count * 2); for (; cht != cht_last; cht++) { SlWriteByte(cht->been_used); SlWriteByte(cht->value); } }
/** * Save the ANIT chunk. */ static void Save_ANIT() { SlSetLength(_animated_tile_count * sizeof(*_animated_tile_list)); SlArray(_animated_tile_list, _animated_tile_count, SLE_UINT32); }