Changeset - r28663:7d36f239a076
[Not reviewed]
master
0 1 0
Rubidium - 10 months ago 2024-02-02 17:18:23
rubidium@openttd.org
Codechange: use std::unique_ptr for managing SaveLoadParams
1 file changed with 4 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/saveload/saveload.cpp
Show inline comments
 
@@ -198,10 +198,10 @@ struct SaveLoadParams {
 
	int array_index, last_array_index;   ///< in the case of an array, the current and last positions
 
	bool expect_table_header;            ///< In the case of a table, if the header is saved/loaded.
 

	
 
	MemoryDumper *dumper;                ///< Memory dumper to write the savegame to.
 
	std::unique_ptr<MemoryDumper> dumper; ///< Memory dumper to write the savegame to.
 
	std::shared_ptr<SaveFilter> sf; ///< Filter to write the savegame to.
 

	
 
	ReadBuffer *reader;                  ///< Savegame reading buffer.
 
	std::unique_ptr<ReadBuffer> reader; ///< Savegame reading buffer.
 
	std::shared_ptr<LoadFilter> lf; ///< Filter to read the savegame from.
 

	
 
	StringID error_str;                  ///< the translatable error message to show
 
@@ -2711,14 +2711,9 @@ static void ResetSaveloadData()
 
 */
 
static inline void ClearSaveLoadState()
 
{
 
	delete _sl.dumper;
 
	_sl.dumper = nullptr;
 

	
 
	_sl.sf = nullptr;
 

	
 
	delete _sl.reader;
 
	_sl.reader = nullptr;
 

	
 
	_sl.lf = nullptr;
 
}
 

	
 
@@ -2835,7 +2830,7 @@ static SaveOrLoadResult DoSave(std::shar
 
{
 
	assert(!_sl.saveinprogress);
 

	
 
	_sl.dumper = new MemoryDumper();
 
	_sl.dumper = std::make_unique<MemoryDumper>();
 
	_sl.sf = writer;
 

	
 
	_sl_version = SAVEGAME_VERSION;
 
@@ -2942,7 +2937,7 @@ static SaveOrLoadResult DoLoad(std::shar
 
	}
 

	
 
	_sl.lf = fmt->init_load(_sl.lf);
 
	_sl.reader = new ReadBuffer(_sl.lf);
 
	_sl.reader = std::make_unique<ReadBuffer>(_sl.lf);
 
	_next_offs = 0;
 

	
 
	if (!load_check) {
0 comments (0 inline, 0 general)