Snapshot checking
This commit is contained in:
parent
a1b4168b30
commit
97bf9a517e
@ -1,4 +1,4 @@
|
||||
import os, sys, subprocess
|
||||
import os, sys, subprocess, time
|
||||
|
||||
##Fix for long command line - http://scons.org/wiki/LongCmdLinesOnWin32
|
||||
class ourSpawn:
|
||||
@ -93,6 +93,7 @@ env.Append(CPPPATH=['src/', 'data/', 'generated/'])
|
||||
env.Append(CCFLAGS=['-w', '-std=c99', '-fkeep-inline-functions'])
|
||||
env.Append(LIBS=['pthread', 'm', 'bz2'])
|
||||
env.Append(CPPDEFINES={"_POSIX_C_SOURCE": "200112L"})
|
||||
env.Append(CPPDEFINES={"SNAPSHOT_ID": int(time.time())})
|
||||
env.Append(CPPDEFINES=["USE_SDL", "LUACONSOLE", "GRAVFFT", "_GNU_SOURCE", "USE_STDINT"])
|
||||
|
||||
if GetOption("ptw32-static"):
|
||||
|
@ -21,6 +21,10 @@
|
||||
#define BETA
|
||||
#define SNAPSHOT
|
||||
#define BUILD_NUM 155
|
||||
|
||||
#ifndef SNAPSHOT_ID
|
||||
#define SNAPSHOT_ID 0
|
||||
#endif
|
||||
//VersionInfoEnd
|
||||
|
||||
#if defined(SNAPSHOT)
|
||||
|
@ -155,9 +155,7 @@ void Client::Tick()
|
||||
json::Number betaBuild = betaVersion["Build"];
|
||||
json::String betaFile = betaVersion["File"];
|
||||
|
||||
json::Number snapshotMajor = snapshotVersion["Major"];
|
||||
json::Number snapshotMinor = snapshotVersion["Minor"];
|
||||
json::Number snapshotBuild = snapshotVersion["Build"];
|
||||
json::Number snapshotSnapshot = snapshotVersion["Snapshot"];
|
||||
json::String snapshotFile = snapshotVersion["File"];
|
||||
|
||||
if(stableMajor.Value()>SAVE_VERSION || (stableMinor.Value()>MINOR_VERSION && stableMajor.Value()==SAVE_VERSION) || stableBuild.Value()>BUILD_NUM)
|
||||
@ -175,10 +173,10 @@ void Client::Tick()
|
||||
#endif
|
||||
|
||||
#ifdef SNAPSHOT
|
||||
if(snapshotMajor.Value()>SAVE_VERSION || (snapshotMinor.Value()>MINOR_VERSION && snapshotMajor.Value()==SAVE_VERSION) || snapshotBuild.Value()>BUILD_NUM)
|
||||
if(snapshotSnapshot.Value() > SNAPSHOT_ID)
|
||||
{
|
||||
updateAvailable = true;
|
||||
updateInfo = UpdateInfo(snapshotMajor.Value(), snapshotMinor.Value(), snapshotBuild.Value(), snapshotFile.Value(), UpdateInfo::Snapshot);
|
||||
updateInfo = UpdateInfo(snapshotSnapshot.Value(), snapshotFile.Value(), UpdateInfo::Snapshot);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -35,9 +35,11 @@ public:
|
||||
int Major;
|
||||
int Minor;
|
||||
int Build;
|
||||
int Time;
|
||||
BuildType Type;
|
||||
UpdateInfo() : Major(0), Minor(0), Build(0), File(""), Type(Stable) {}
|
||||
UpdateInfo(int major, int minor, int build, std::string file, BuildType type) : Major(major), Minor(minor), Build(build), File(file), Type(type) {}
|
||||
UpdateInfo() : Major(0), Minor(0), Build(0), Time(0), File(""), Type(Stable) {}
|
||||
UpdateInfo(int major, int minor, int build, std::string file, BuildType type) : Major(major), Minor(minor), Build(build), Time(0), File(file), Type(type) {}
|
||||
UpdateInfo(int time, std::string file, BuildType type) : Major(0), Minor(0), Build(0), Time(time), File(file), Type(type) {}
|
||||
};
|
||||
|
||||
class ClientListener;
|
||||
|
@ -20,6 +20,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -68,6 +70,7 @@
|
||||
#define PCLOSE close
|
||||
#endif
|
||||
|
||||
char * userAgent;
|
||||
static int http_up = 0;
|
||||
static long http_timeout = 15;
|
||||
static int http_use_proxy = 0;
|
||||
@ -180,6 +183,15 @@ void http_init(char *proxy)
|
||||
free(host);
|
||||
free(port);
|
||||
}
|
||||
std::stringstream userAgentBuilder;
|
||||
userAgentBuilder << "PowderToy/" << SAVE_VERSION << "." << MINOR_VERSION << " ";
|
||||
userAgentBuilder << "(" << IDENT_PLATFORM << "; " << IDENT_BUILD << "; M0) ";
|
||||
userAgentBuilder << "TPTPP/" << SAVE_VERSION << "." << MINOR_VERSION << "." << BUILD_NUM << IDENT_RELTYPE << "." << SNAPSHOT_ID;
|
||||
std::string newUserAgent = userAgentBuilder.str();
|
||||
userAgent = new char[newUserAgent.length()+1];
|
||||
std::copy(newUserAgent.begin(), newUserAgent.end(), userAgent);
|
||||
userAgent[newUserAgent.length()] = 0;
|
||||
//"User-Agent: PowderToy/%d.%d (%s; %s; M%d) TPTPP/%d.%d.%d%s.%d\n", SAVE_VERSION, MINOR_VERSION, IDENT_PLATFORM, IDENT_BUILD, 0, SAVE_VERSION, MINOR_VERSION, BUILD_NUM, IDENT_RELTYPE, SNAPSHOT_ID
|
||||
}
|
||||
|
||||
void http_done(void)
|
||||
@ -468,7 +480,7 @@ int http_async_req_status(void *ctx)
|
||||
if (cx->txdl)
|
||||
{
|
||||
// generate POST
|
||||
cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 141 + 128 + cx->txdl + cx->thlen);
|
||||
cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 126 + strlen(userAgent) + cx->txdl + cx->thlen);
|
||||
cx->tptr = 0;
|
||||
cx->tlen = 0;
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "POST %s HTTP/1.1\n", cx->path);
|
||||
@ -484,7 +496,7 @@ int http_async_req_status(void *ctx)
|
||||
cx->thlen = 0;
|
||||
}
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Content-Length: %d\n", cx->txdl);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "User-Agent: PowderToy/%d.%d (%s; %s; M%d) TPTPP/%d.%d.%d%s\n", SAVE_VERSION, MINOR_VERSION, IDENT_PLATFORM, IDENT_BUILD, 0, SAVE_VERSION, MINOR_VERSION, BUILD_NUM, IDENT_RELTYPE);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "User-Agent: %s\n", userAgent);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
|
||||
memcpy(cx->tbuf+cx->tlen, cx->txd, cx->txdl);
|
||||
cx->tlen += cx->txdl;
|
||||
@ -495,7 +507,7 @@ int http_async_req_status(void *ctx)
|
||||
else
|
||||
{
|
||||
// generate GET
|
||||
cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 100 + 128 + cx->thlen);
|
||||
cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 93 + strlen(userAgent) + cx->thlen);
|
||||
cx->tptr = 0;
|
||||
cx->tlen = 0;
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "GET %s HTTP/1.1\n", cx->path);
|
||||
@ -510,7 +522,7 @@ int http_async_req_status(void *ctx)
|
||||
}
|
||||
if (!cx->keep)
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n");
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "User-Agent: PowderToy/%d.%d (%s; %s; M%d) TPTPP/%d.%d.%d%s\n", SAVE_VERSION, MINOR_VERSION, IDENT_PLATFORM, IDENT_BUILD, 0, SAVE_VERSION, MINOR_VERSION, BUILD_NUM, IDENT_RELTYPE);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "User-Agent: %s\n", userAgent);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
|
||||
}
|
||||
cx->state = HTS_XMIT;
|
||||
|
@ -28,7 +28,7 @@ ConfirmPrompt::ConfirmPrompt(std::string title, std::string message, ConfirmDial
|
||||
messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
|
||||
AddComponent(messageLabel);
|
||||
|
||||
Size.Y += messageLabel->Size.Y;
|
||||
Size.Y += messageLabel->Size.Y+12;
|
||||
Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2;
|
||||
|
||||
class CloseAction: public ui::ButtonAction
|
||||
|
Loading…
Reference in New Issue
Block a user