mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Show failure reason in message box when network savegame load fails
See: #412
This commit is contained in:
parent
edd8b29794
commit
7c78b22c48
@ -646,7 +646,8 @@ bool ClientNetworkGameSocketHandler::IsConnected()
|
||||
* DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p
|
||||
************/
|
||||
|
||||
extern bool SafeLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = nullptr);
|
||||
extern bool SafeLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir,
|
||||
struct LoadFilter *lf = nullptr, std::string *error_detail = nullptr);
|
||||
|
||||
NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FULL(Packet *p)
|
||||
{
|
||||
@ -941,14 +942,20 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
|
||||
|
||||
/* The map is done downloading, load it */
|
||||
ClearErrorMessages();
|
||||
bool load_success = SafeLoad({}, SLO_LOAD, DFT_GAME_FILE, GM_NORMAL, NO_DIRECTORY, lf);
|
||||
std::string error_detail;
|
||||
bool load_success = SafeLoad({}, SLO_LOAD, DFT_GAME_FILE, GM_NORMAL, NO_DIRECTORY, lf, &error_detail);
|
||||
|
||||
/* Long savegame loads shouldn't affect the lag calculation! */
|
||||
this->last_packet = std::chrono::steady_clock::now();
|
||||
|
||||
if (!load_success) {
|
||||
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
|
||||
ShowErrorMessage(STR_NETWORK_ERROR_SAVEGAMEERROR, INVALID_STRING_ID, WL_CRITICAL);
|
||||
StringID detail = INVALID_STRING_ID;
|
||||
if (!error_detail.empty()) {
|
||||
detail = STR_JUST_RAW_STRING;
|
||||
SetDParamStr(0, error_detail.c_str());
|
||||
}
|
||||
ShowErrorMessage(STR_NETWORK_ERROR_SAVEGAMEERROR, detail, WL_CRITICAL);
|
||||
return NETWORK_RECV_STATUS_SAVEGAME;
|
||||
}
|
||||
/* If the savegame has successfully loaded, ALL windows have been removed,
|
||||
|
@ -1161,8 +1161,10 @@ static void MakeNewEditorWorld()
|
||||
* @param newgm switch to this mode of loading fails due to some unknown error
|
||||
* @param subdir default directory to look for filename, set to 0 if not needed
|
||||
* @param lf Load filter to use, if nullptr: use filename + subdir.
|
||||
* @param error_detail Optional string to fill with detaied error information.
|
||||
*/
|
||||
bool SafeLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = nullptr)
|
||||
bool SafeLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir,
|
||||
struct LoadFilter *lf = nullptr, std::string *error_detail = nullptr)
|
||||
{
|
||||
assert(fop == SLO_LOAD);
|
||||
assert(dft == DFT_GAME_FILE || (lf == nullptr && dft == DFT_OLD_GAME_FILE));
|
||||
@ -1174,6 +1176,7 @@ bool SafeLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileTy
|
||||
case SL_OK: return true;
|
||||
|
||||
case SL_REINIT:
|
||||
if (error_detail != nullptr) *error_detail = GetSaveLoadErrorString();
|
||||
if (_network_dedicated) {
|
||||
/*
|
||||
* We need to reinit a network map...
|
||||
@ -1198,6 +1201,7 @@ bool SafeLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileTy
|
||||
return false;
|
||||
|
||||
default:
|
||||
if (error_detail != nullptr) *error_detail = GetSaveLoadErrorString();
|
||||
_game_mode = ogm;
|
||||
return false;
|
||||
}
|
||||
|
@ -129,7 +129,8 @@ static void *_dedicated_video_mem;
|
||||
/* Whether a fork has been done. */
|
||||
bool _dedicated_forks;
|
||||
|
||||
extern bool SafeLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = nullptr);
|
||||
extern bool SafeLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir,
|
||||
struct LoadFilter *lf = nullptr, std::string *error_detail = nullptr);
|
||||
|
||||
static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user