forked from Mirrors/openclonk
fix: Version information from masterserver is correctly parsed
PeterW changed some stuff about the INI parser. I adjusted the parsing of the version info from the masterserver to fit his change and let the C4Network2RefClient inherit from the C4Network2UpdateClient (as refclient does the same as updateclient only more) while I was at it.
parent
21ccfe946f
commit
1956c37923
|
@ -936,7 +936,7 @@ IDS_MSG_TRYLEAGUESIGNUP=Liga-Anmeldung für Spieler %s...
|
|||
IDS_MSG_UPDATEFAILED=Update fehlgeschlagen.
|
||||
IDS_MSG_UPDATEINPROGRESS=Update-Vorgang läuft noch. Bitte warten.
|
||||
IDS_MSG_UPDATENOTAVAILABLE=Das Update ist eventuell noch nicht für dieses Betriebssystem verfügbar.
|
||||
IDS_MSG_NEWRELEASEAVAILABLE=Neue Version verfügbar. Bitte von der Download-Seite herunterladen und installieren.
|
||||
IDS_MSG_NEWRELEASEAVAILABLE=Für die neue Version ist kein Update-Paket verfügbar. Bitte lade die neue Version von der Download-Seite herunter.
|
||||
IDS_MSG_USINGPLR=Mit %s spielen
|
||||
IDS_MSG_USINGPLR_DESC=Diesen Spieler benutzen um das Spiel fortzusetzen
|
||||
IDS_MSG_WASKICKEDFROMTHECHANNEL=%s wurde aus dem Chat-Kanal geworfen (%s).
|
||||
|
|
|
@ -936,7 +936,7 @@ IDS_MSG_TRYLEAGUESIGNUP=League login for player %s...
|
|||
IDS_MSG_UPDATEFAILED=Update failed.
|
||||
IDS_MSG_UPDATEINPROGRESS=Update still in progress. Please wait.
|
||||
IDS_MSG_UPDATENOTAVAILABLE=The update is possibly not yet available for this operating system.
|
||||
IDS_MSG_NEWRELEASEAVAILABLE=New version available. Please download and install it from the downloads page.
|
||||
IDS_MSG_NEWRELEASEAVAILABLE=For the new version there is no update package available. Please download and install the new version from the downloads page.
|
||||
IDS_MSG_USINGPLR=Using %s
|
||||
IDS_MSG_USINGPLR_DESC=Use this player to continue the savegame
|
||||
IDS_MSG_WASKICKEDFROMTHECHANNEL=%s was kicked from the channel (%s).
|
||||
|
|
|
@ -173,12 +173,9 @@ bool C4UpdateDlg::DoUpdate(const char *szUpdateURL, C4GUI::Screen *pScreen)
|
|||
{
|
||||
if(szUpdateURL == NULL || strlen(szUpdateURL) == 0)
|
||||
{
|
||||
if (pScreen->ShowMessageModal(LoadResStr("IDS_MSG_NEWRELEASEAVAILABLE"), LoadResStr("IDS_TYPE_UPDATE"), C4GUI::MessageDialog::btnYesNo, C4GUI::Ico_Ex_Update))
|
||||
{
|
||||
RedirectToDownloadPage();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
pScreen->ShowMessageModal(LoadResStr("IDS_MSG_NEWRELEASEAVAILABLE"), LoadResStr("IDS_TYPE_UPDATE"),C4GUI::MessageDialog::btnOK, C4GUI::Ico_Ex_Update);
|
||||
RedirectToDownloadPage();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Determine local filename for update group
|
||||
|
@ -388,51 +385,4 @@ bool C4UpdateDlg::CheckForUpdates(C4GUI::Screen *pScreen, bool fAutomatic)
|
|||
}
|
||||
|
||||
|
||||
// *** C4Network2UpdateClient
|
||||
|
||||
bool C4Network2UpdateClient::QueryUpdateURL()
|
||||
{
|
||||
// Perform an Query query
|
||||
return Query(NULL, false);
|
||||
}
|
||||
|
||||
bool C4Network2UpdateClient::GetUpdateURL(StdStrBuf *pUpdateURL)
|
||||
{
|
||||
// Sanity check
|
||||
if (isBusy() || !isSuccess()) return false;
|
||||
// Parse response
|
||||
try
|
||||
{
|
||||
CompileFromBuf<StdCompilerINIRead>(mkNamingAdapt(
|
||||
mkNamingAdapt(*pUpdateURL,"UpdateURL"),
|
||||
C4ENGINENAME), ResultString);
|
||||
}
|
||||
catch (StdCompiler::Exception *pExc)
|
||||
{
|
||||
SetError(pExc->Msg.getData());
|
||||
return false;
|
||||
}
|
||||
// done; version OK!
|
||||
return true;
|
||||
}
|
||||
|
||||
{
|
||||
// Sanity check
|
||||
if (isBusy() || !isSuccess()) return false;
|
||||
// Parse response
|
||||
try
|
||||
{
|
||||
CompileFromBuf<StdCompilerINIRead>(mkNamingAdapt(
|
||||
mkNamingAdapt(*pVersion,"Version"),
|
||||
C4ENGINENAME), ResultString);
|
||||
}
|
||||
catch (StdCompiler::Exception *pExc)
|
||||
{
|
||||
SetError(pExc->Msg.getData());
|
||||
return false;
|
||||
}
|
||||
// done; version OK!
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // WITH_AUTOMATIC_UPDATE
|
||||
|
|
|
@ -59,18 +59,5 @@ public:
|
|||
static void RedirectToDownloadPage(); // open browser with download page
|
||||
};
|
||||
|
||||
// Loads current update url string (mini-HTTP-client)
|
||||
class C4Network2UpdateClient : public C4Network2HTTPClient
|
||||
{
|
||||
protected:
|
||||
virtual int32_t GetDefaultPort() { return C4NetStdPortHTTP; }
|
||||
public:
|
||||
C4Network2UpdateClient() : C4Network2HTTPClient() {}
|
||||
|
||||
bool QueryUpdateURL();
|
||||
bool GetUpdateURL(StdStrBuf *pUpdateURL);
|
||||
bool GetVersion(StdStrBuf *pVersion);
|
||||
};
|
||||
|
||||
#endif // WITH_AUTOMATIC_UPDATE
|
||||
#endif // INC_C4UpdateDialogs
|
||||
|
|
|
@ -545,13 +545,58 @@ bool C4Network2HTTPClient::SetServer(const char *szServerAddress)
|
|||
return true;
|
||||
}
|
||||
|
||||
// *** C4Network2UpdateClient
|
||||
|
||||
bool C4Network2UpdateClient::QueryUpdateURL()
|
||||
{
|
||||
// Perform an Query query
|
||||
return Query(NULL, false);
|
||||
}
|
||||
|
||||
bool C4Network2UpdateClient::GetUpdateURL(StdStrBuf *pUpdateURL)
|
||||
{
|
||||
// Sanity check
|
||||
if (isBusy() || !isSuccess()) return false;
|
||||
// Parse response
|
||||
try
|
||||
{
|
||||
CompileFromBuf<StdCompilerINIRead>(mkNamingAdapt(
|
||||
mkNamingAdapt(mkParAdapt(*pUpdateURL, StdCompiler::RCT_All), "UpdateURL", ""),
|
||||
C4ENGINENAME), ResultString);
|
||||
}
|
||||
catch (StdCompiler::Exception *pExc)
|
||||
{
|
||||
SetError(pExc->Msg.getData());
|
||||
return false;
|
||||
}
|
||||
// done; version OK!
|
||||
return true;
|
||||
}
|
||||
|
||||
bool C4Network2UpdateClient::GetVersion(StdStrBuf *pVersion)
|
||||
{
|
||||
// Sanity check
|
||||
if (isBusy() || !isSuccess()) return false;
|
||||
// Parse response
|
||||
try
|
||||
{
|
||||
CompileFromBuf<StdCompilerINIRead>(mkNamingAdapt(
|
||||
mkNamingAdapt(mkParAdapt(*pVersion, StdCompiler::RCT_All), "Version", ""),
|
||||
C4ENGINENAME), ResultString);
|
||||
}
|
||||
catch (StdCompiler::Exception *pExc)
|
||||
{
|
||||
SetError(pExc->Msg.getData());
|
||||
return false;
|
||||
}
|
||||
// done; version OK!
|
||||
return true;
|
||||
}
|
||||
|
||||
// *** C4Network2RefClient
|
||||
|
||||
bool C4Network2RefClient::QueryReferences()
|
||||
{
|
||||
// invalidate version
|
||||
fUrlSet = false;
|
||||
// Perform an Query query
|
||||
return Query(NULL, false);
|
||||
}
|
||||
|
@ -560,8 +605,6 @@ bool C4Network2RefClient::GetReferences(C4Network2Reference **&rpReferences, int
|
|||
{
|
||||
// Sanity check
|
||||
if (isBusy() || !isSuccess()) return false;
|
||||
// Parse response
|
||||
fUrlSet = false;
|
||||
// local update test
|
||||
try
|
||||
{
|
||||
|
@ -569,13 +612,6 @@ bool C4Network2RefClient::GetReferences(C4Network2Reference **&rpReferences, int
|
|||
StdCompilerINIRead Comp;
|
||||
Comp.setInput(ResultString);
|
||||
Comp.Begin();
|
||||
// get current version and update url
|
||||
Comp.Value(mkNamingAdapt(
|
||||
mkNamingAdapt(UpdateURL,"UpdateURL"),
|
||||
C4ENGINENAME));
|
||||
Comp.Value(mkNamingAdapt(
|
||||
mkNamingAdapt(mkParAdapt(Version, StdCompiler::RCT_All), "Version", ""),
|
||||
C4ENGINENAME));
|
||||
// Read reference count
|
||||
Comp.Value(mkNamingCountAdapt(rRefCount, "Reference"));
|
||||
// Create reference array and initialize
|
||||
|
@ -596,25 +632,7 @@ bool C4Network2RefClient::GetReferences(C4Network2Reference **&rpReferences, int
|
|||
// Set source ip
|
||||
for (int i = 0; i < rRefCount; i++)
|
||||
rpReferences[i]->SetSourceIP(getServerAddress().sin_addr);
|
||||
// validate version
|
||||
if (Version.getData() != NULL) fUrlSet = true;
|
||||
// Done
|
||||
ResetError();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool C4Network2RefClient::GetUpdateURL(StdStrBuf *pUpdateURL)
|
||||
{
|
||||
// call only after GetReferences
|
||||
if (!fUrlSet) return false;
|
||||
*pUpdateURL = UpdateURL;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool C4Network2RefClient::GetVersion(StdStrBuf *pVersion)
|
||||
{
|
||||
// call only after GetReferences
|
||||
if (!fUrlSet) return false;
|
||||
*pVersion = Version;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -188,22 +188,29 @@ private:
|
|||
|
||||
};
|
||||
|
||||
// Loads references (mini-HTTP-client)
|
||||
class C4Network2RefClient : public C4Network2HTTPClient
|
||||
// Loads current update url string (mini-HTTP-client)
|
||||
class C4Network2UpdateClient : public C4Network2HTTPClient
|
||||
{
|
||||
private:
|
||||
StdStrBuf UpdateURL;
|
||||
StdStrBuf Version;
|
||||
bool fUrlSet;
|
||||
protected:
|
||||
virtual int32_t GetDefaultPort() { return C4NetStdPortRefServer; }
|
||||
virtual int32_t GetDefaultPort() { return C4NetStdPortHTTP; }
|
||||
public:
|
||||
C4Network2RefClient() : C4Network2HTTPClient(), fUrlSet(false) {}
|
||||
C4Network2UpdateClient() : C4Network2HTTPClient() {}
|
||||
|
||||
bool QueryReferences();
|
||||
bool GetReferences(C4Network2Reference **&rpReferences, int32_t &rRefCount);
|
||||
bool GetUpdateURL(StdStrBuf *pUpdateURL); // call only after GetReferences
|
||||
bool QueryUpdateURL();
|
||||
bool GetUpdateURL(StdStrBuf *pUpdateURL);
|
||||
bool GetVersion(StdStrBuf *pVersion);
|
||||
};
|
||||
|
||||
// Loads references + current update url string (mini-HTTP-client)
|
||||
class C4Network2RefClient : public C4Network2UpdateClient
|
||||
{
|
||||
protected:
|
||||
virtual int32_t GetDefaultPort() { return C4NetStdPortRefServer; }
|
||||
public:
|
||||
C4Network2RefClient() : C4Network2UpdateClient() {}
|
||||
|
||||
bool QueryReferences();
|
||||
bool GetReferences(C4Network2Reference **&rpReferences, int32_t &rRefCount);
|
||||
};
|
||||
|
||||
#endif // C4NETWORK2REFERENCE_H
|
||||
|
|
Loading…
Reference in New Issue