Changeset - r20773:6411a759aea6
[Not reviewed]
master
0 1 0
frosch - 11 years ago 2013-10-06 12:10:33
frosch@openttd.org
(svn r25817) -Fix [FS5750-ish]: Handle savegames which contain GS translations for languages with empty name more gently.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/saveload/game_sl.cpp
Show inline comments
 
@@ -103,82 +103,82 @@ static void Load_GSDT()
 
	Game::Load(_game_saveload_version);
 

	
 
	if ((CompanyID)SlIterateArray() != (CompanyID)-1) SlErrorCorrupt("Too many GameScript configs");
 
}
 

	
 
static void Save_GSDT()
 
{
 
	SlSetArrayIndex(0);
 
	SlAutolength((AutolengthProc *)SaveReal_GSDT, NULL);
 
}
 

	
 
extern GameStrings *_current_data;
 

	
 
static const char *_game_saveload_string;
 
static uint _game_saveload_strings;
 

	
 
static const SaveLoad _game_language_header[] = {
 
	SLEG_STR(_game_saveload_string, SLE_STR),
 
	SLEG_VAR(_game_saveload_strings, SLE_UINT32),
 
	 SLE_END()
 
};
 

	
 
static const SaveLoad _game_language_string[] = {
 
	SLEG_STR(_game_saveload_string, SLE_STR | SLF_ALLOW_CONTROL),
 
	 SLE_END()
 
};
 

	
 
static void SaveReal_GSTR(LanguageStrings *ls)
 
{
 
	_game_saveload_string  = ls->language;
 
	_game_saveload_strings = ls->lines.Length();
 

	
 
	SlObject(NULL, _game_language_header);
 
	for (uint i = 0; i < _game_saveload_strings; i++) {
 
		_game_saveload_string = ls->lines[i];
 
		SlObject(NULL, _game_language_string);
 
	}
 
}
 

	
 
static void Load_GSTR()
 
{
 
	delete _current_data;
 
	_current_data = new GameStrings();
 

	
 
	while (SlIterateArray() != -1) {
 
		_game_saveload_string = NULL;
 
		SlObject(NULL, _game_language_header);
 

	
 
		LanguageStrings *ls = new LanguageStrings(_game_saveload_string);
 
		LanguageStrings *ls = new LanguageStrings(_game_saveload_string != NULL ? _game_saveload_string : "");
 
		for (uint i = 0; i < _game_saveload_strings; i++) {
 
			SlObject(NULL, _game_language_string);
 
			*ls->lines.Append() = strdup(_game_saveload_string != NULL ? _game_saveload_string : "");
 
		}
 

	
 
		*_current_data->raw_strings.Append() = ls;
 
	}
 

	
 
	/* If there were no strings in the savegame, set GameStrings to NULL */
 
	if (_current_data->raw_strings.Length() == 0) {
 
		delete _current_data;
 
		_current_data = NULL;
 
		return;
 
	}
 

	
 
	_current_data->Compile();
 
	ReconsiderGameScriptLanguage();
 
}
 

	
 
static void Save_GSTR()
 
{
 
	if (_current_data == NULL) return;
 

	
 
	for (uint i = 0; i < _current_data->raw_strings.Length(); i++) {
 
		SlSetArrayIndex(i);
 
		SlAutolength((AutolengthProc *)SaveReal_GSTR, _current_data->raw_strings[i]);
 
	}
 
}
 

	
 
extern const ChunkHandler _game_chunk_handlers[] = {
 
	{ 'GSTR', Save_GSTR, Load_GSTR, NULL, NULL, CH_ARRAY },
 
	{ 'GSDT', Save_GSDT, Load_GSDT, NULL, NULL, CH_ARRAY | CH_LAST},
 
};
0 comments (0 inline, 0 general)