@@ -35,12 +35,14 @@ static void Save_CHTS()
* 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);
}
@@ -280,12 +280,13 @@ static void SaveLoad_PLYR_common(Company
/* Write economy */
SlObject(&cprops->cur_economy, _company_economy_desc);
/* Write old economy entries. */
if (cprops->num_valid_stat_ent > lengthof(cprops->old_economy)) SlErrorCorrupt("Too many old economy entries");
for (i = 0; i < cprops->num_valid_stat_ent; i++) {
SlObject(&cprops->old_economy[i], _company_economy_desc);
/* Write each livery entry. */
int num_liveries = IsSavegameVersionBefore(63) ? LS_END - 4 : (IsSavegameVersionBefore(85) ? LS_END - 2: LS_END);
@@ -123,13 +123,18 @@ void InitializeOldNames()
static void Load_NAME()
int index;
while ((index = SlIterateArray()) != -1) {
if (index >= NUM_OLD_STRINGS) SlErrorCorrupt("Invalid old name index");
if (SlGetFieldLength() > (uint)LEN_OLD_STRINGS) SlErrorCorrupt("Invalid old name length");
SlArray(&_old_name_array[LEN_OLD_STRINGS * index], SlGetFieldLength(), SLE_UINT8);
/* Make sure the old name is null terminated */
_old_name_array[LEN_OLD_STRINGS * index + LEN_OLD_STRINGS - 1] = '\0';
/** Chunk handlers related to strings. */
extern const ChunkHandler _name_chunk_handlers[] = {
{ 'NAME', NULL, Load_NAME, NULL, NULL, CH_ARRAY | CH_LAST},
Status change: