File diff r25654:e264fd698eb2 → r25655:1030dcb7eb52
src/saveload/oldloader.cpp
Show inline comments
 
@@ -53,13 +53,13 @@ static byte ReadByteFromFile(LoadgameSta
 

	
 
		/* Read some new bytes from the file */
 
		int count = (int)fread(ls->buffer, 1, BUFFER_SIZE, ls->file);
 

	
 
		/* We tried to read, but there is nothing in the file anymore.. */
 
		if (count == 0) {
 
			DEBUG(oldloader, 0, "Read past end of file, loading failed");
 
			Debug(oldloader, 0, "Read past end of file, loading failed");
 
			throw std::exception();
 
		}
 

	
 
		ls->buffer_count = count;
 
		ls->buffer_cur   = 0;
 
	}
 
@@ -129,13 +129,13 @@ bool LoadChunk(LoadgameState *ls, void *
 
						/* Call function, with 'i' as parameter to tell which item we
 
						 * are going to read */
 
						if (!chunk->proc(ls, i)) return false;
 
						break;
 

	
 
					case OC_ASSERT:
 
						DEBUG(oldloader, 4, "Assert point: 0x%X / 0x%X", ls->total_read, (uint)(size_t)chunk->ptr + _bump_assert_value);
 
						Debug(oldloader, 4, "Assert point: 0x{:X} / 0x{:X}", ls->total_read, (uint)(size_t)chunk->ptr + _bump_assert_value);
 
						if (ls->total_read != (size_t)chunk->ptr + _bump_assert_value) throw std::exception();
 
					default: break;
 
				}
 
			} else {
 
				uint64 res = 0;
 

	
 
@@ -270,21 +270,21 @@ static SavegameType DetermineOldSavegame
 
typedef bool LoadOldMainProc(LoadgameState *ls);
 

	
 
bool LoadOldSaveGame(const std::string &file)
 
{
 
	LoadgameState ls;
 

	
 
	DEBUG(oldloader, 3, "Trying to load a TTD(Patch) savegame");
 
	Debug(oldloader, 3, "Trying to load a TTD(Patch) savegame");
 

	
 
	InitLoading(&ls);
 

	
 
	/* Open file */
 
	ls.file = FioFOpenFile(file, "rb", NO_DIRECTORY);
 

	
 
	if (ls.file == nullptr) {
 
		DEBUG(oldloader, 0, "Cannot open file '%s'", file.c_str());
 
		Debug(oldloader, 0, "Cannot open file '{}'", file);
 
		return false;
 
	}
 

	
 
	SavegameType type = DetermineOldSavegameType(ls.file, nullptr, nullptr);
 

	
 
	LoadOldMainProc *proc = nullptr;