Changeset - r25695:08b2e668e823
[Not reviewed]
master
0 1 0
Patric Stout - 3 years ago 2021-06-12 11:23:19
truebrain@openttd.org
Change: switch SL_DEQUE and SL_REFLIST length field to a gamma

The current SaveLoad is a bit inconsistent how long a length field
is. Sometimes it is a 32bit, sometimes a gamma. Make it consistent
across the board by making them all gammas.
1 file changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/saveload/saveload.cpp
Show inline comments
 
@@ -1261,7 +1261,7 @@ public:
 

	
 
		const SlStorageT *list = static_cast<const SlStorageT *>(storage);
 

	
 
		int type_size = SlCalcConvFileLen(SLE_FILE_U32); // Size of the length of the list.
 
		int type_size = SlGetArrayLength(list->size());
 
		int item_size = SlCalcConvFileLen(cmd == SL_VAR ? conv : (VarType)SLE_FILE_U32);
 
		return list->size() * item_size + type_size;
 
	}
 
@@ -1290,7 +1290,7 @@ public:
 

	
 
		switch (_sl.action) {
 
			case SLA_SAVE:
 
				SlWriteUint32((uint32)list->size());
 
				SlWriteArrayLength(list->size());
 

	
 
				for (auto &item : *list) {
 
					SlSaveLoadMember(cmd, &item, conv);
 
@@ -1301,8 +1301,8 @@ public:
 
			case SLA_LOAD: {
 
				size_t length;
 
				switch (cmd) {
 
					case SL_VAR: length = SlReadUint32(); break;
 
					case SL_REF: length = IsSavegameVersionBefore(SLV_69) ? SlReadUint16() : SlReadUint32(); break;
 
					case SL_VAR: length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? SlReadUint32() : SlReadArrayLength(); break;
 
					case SL_REF: length = IsSavegameVersionBefore(SLV_69) ? SlReadUint16() : IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? SlReadUint32() : SlReadArrayLength(); break;
 
					default: NOT_REACHED();
 
				}
 

	
0 comments (0 inline, 0 general)