mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 01:11:44 +00:00
I wonder how this feature is going to come back to bite me in the ass later
git-svn-id: https://svn.eduke32.com/eduke32@417 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
dc0dea7c09
commit
a68248896c
2 changed files with 71 additions and 60 deletions
|
@ -893,7 +893,7 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game
|
|||
struct hostent *h;
|
||||
char *host = "eduke32.sourceforge.net";
|
||||
char *req = "GET http://eduke32.sourceforge.net/VERSION HTTP/1.0\r\n\r\n";
|
||||
char tempbuf[2048],ver[16];
|
||||
char tempbuf[2048],otherbuf[16],ver[16];
|
||||
|
||||
#ifdef _WIN32
|
||||
if (wsainitialized == 0)
|
||||
|
@ -901,7 +901,7 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game
|
|||
WSADATA ws;
|
||||
|
||||
if (WSAStartup(0x101,&ws) == SOCKET_ERROR) {
|
||||
initprintf("mmulti: Winsock error in getexternaladdress() (%d)\n",errno);
|
||||
initprintf("update: Winsock error in getversionfromwebsite() (%d)\n",errno);
|
||||
return(0);
|
||||
}
|
||||
wsainitialized = 1;
|
||||
|
@ -909,7 +909,7 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game
|
|||
#endif
|
||||
|
||||
if ((h=gethostbyname(host)) == NULL) {
|
||||
initprintf("mmulti: gethostbyname() error in getexternaladdress() (%d)\n",h_errno);
|
||||
initprintf("update: gethostbyname() error in getversionfromwebsite() (%d)\n",h_errno);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -923,18 +923,18 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game
|
|||
mysock = socket(PF_INET, SOCK_STREAM, 0);
|
||||
|
||||
if (mysock == INVALID_SOCKET) {
|
||||
initprintf("mmulti: socket() error in getexternaladdress() (%d)\n",errno);
|
||||
initprintf("update: socket() error in getversionfromwebsite() (%d)\n",errno);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (connect(mysock, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr)) == SOCKET_ERROR) {
|
||||
initprintf("mmulti: connect() error in getexternaladdress() (%d)\n",errno);
|
||||
initprintf("update: connect() error in getversionfromwebsite() (%d)\n",errno);
|
||||
return(0);
|
||||
}
|
||||
|
||||
bytes_sent = send(mysock, req, strlen(req), 0);
|
||||
if (bytes_sent == SOCKET_ERROR) {
|
||||
initprintf("mmulti: send() error in getexternaladdress() (%d)\n",errno);
|
||||
initprintf("update: send() error in getversionfromwebsite() (%d)\n",errno);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -942,20 +942,31 @@ int getversionfromwebsite(char *buffer) // FIXME: this probably belongs in game
|
|||
recv(mysock, (char *)&tempbuf, sizeof(tempbuf), 0);
|
||||
closesocket(mysock);
|
||||
|
||||
for (i=0;(unsigned)i<strlen(tempbuf);i++) // HACK: all of this needs to die a fiery death; we just skip to the content
|
||||
{ // instead of actually parsing any of the http headers
|
||||
if (i > 4)
|
||||
if (tempbuf[i-1] == '\n' && tempbuf[i-2] == '\r' && tempbuf[i-3] == '\n' && tempbuf[i-4] == '\r')
|
||||
{
|
||||
while (j < 9)
|
||||
memcpy(&otherbuf,&tempbuf,sizeof(otherbuf));
|
||||
|
||||
strtok(otherbuf," ");
|
||||
if (atol(strtok(NULL," ")) == 200)
|
||||
{
|
||||
for (i=0;(unsigned)i<strlen(tempbuf);i++) // HACK: all of this needs to die a fiery death; we just skip to the content
|
||||
{ // instead of actually parsing any of the http headers
|
||||
if (i > 4)
|
||||
if (tempbuf[i-1] == '\n' && tempbuf[i-2] == '\r' && tempbuf[i-3] == '\n' && tempbuf[i-4] == '\r')
|
||||
{
|
||||
ver[j] = tempbuf[i];
|
||||
i++, j++;
|
||||
while (j < 9)
|
||||
{
|
||||
ver[j] = tempbuf[i];
|
||||
i++, j++;
|
||||
}
|
||||
ver[j] = '\0';
|
||||
break;
|
||||
}
|
||||
ver[j] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if (j)
|
||||
{
|
||||
strcpy(buffer,ver);
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
strcpy(buffer,ver);
|
||||
return(1);
|
||||
return(0);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#define TIMERUPDATESIZ 32
|
||||
|
||||
#define BUILDDATE 20061213
|
||||
#define BUILDDATE 20061212
|
||||
|
||||
long cameradist = 0, cameraclock = 0;
|
||||
char playerswhenstarted;
|
||||
|
@ -9410,49 +9410,8 @@ static void Startup(long argc, char **argv)
|
|||
netparam = NULL;
|
||||
netparamcount = 0;
|
||||
|
||||
initprintf("%ld\n",time(NULL));
|
||||
|
||||
if (numplayers > 1)
|
||||
initprintf("Multiplayer initialized.\n");
|
||||
#ifdef _WIN32
|
||||
else if (checkforupdates == 1)
|
||||
{
|
||||
i = time(NULL);
|
||||
|
||||
if (i > lastupdatecheck+86400)
|
||||
{
|
||||
#include <shellapi.h>
|
||||
extern int getversionfromwebsite(char *buffer);
|
||||
|
||||
if (getversionfromwebsite(tempbuf))
|
||||
{
|
||||
lastupdatecheck = i;
|
||||
|
||||
if (atol(tempbuf) > BUILDDATE)
|
||||
{
|
||||
if (wm_ynbox("EDuke32","A new version of EDuke32 is available. "
|
||||
"Would you like to download it now?"))
|
||||
{
|
||||
SHELLEXECUTEINFOA sinfo;
|
||||
char *p = "http://www.eduke32.com/";
|
||||
|
||||
Bmemset(&sinfo, 0, sizeof(sinfo));
|
||||
sinfo.cbSize = sizeof(sinfo);
|
||||
sinfo.fMask = SEE_MASK_CLASSNAME;
|
||||
sinfo.lpVerb = "open";
|
||||
sinfo.lpFile = p;
|
||||
sinfo.nShow = SW_SHOWNORMAL;
|
||||
sinfo.lpClass = "http";
|
||||
|
||||
if(!ShellExecuteExA(&sinfo))
|
||||
initprintf("Error launching browser!\n");
|
||||
gameexit(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
screenpeek = myconnectindex;
|
||||
ps[myconnectindex].palette = (char *) &palette[0];
|
||||
|
@ -9802,6 +9761,47 @@ void app_main(int argc,char **argv)
|
|||
if (i) checkforupdates = 1;
|
||||
else checkforupdates = 0;
|
||||
}
|
||||
|
||||
if (checkforupdates == 1)
|
||||
{
|
||||
i = time(NULL);
|
||||
|
||||
if (i > lastupdatecheck+86400)
|
||||
{
|
||||
#include <shellapi.h>
|
||||
extern int getversionfromwebsite(char *buffer);
|
||||
|
||||
if (getversionfromwebsite(tempbuf))
|
||||
{
|
||||
lastupdatecheck = i;
|
||||
|
||||
if (atol(tempbuf) > BUILDDATE)
|
||||
{
|
||||
if (wm_ynbox("EDuke32","A new version of EDuke32 is available. "
|
||||
"Would you like to download it now?"))
|
||||
{
|
||||
SHELLEXECUTEINFOA sinfo;
|
||||
char *p = "http://www.eduke32.com/";
|
||||
|
||||
Bmemset(&sinfo, 0, sizeof(sinfo));
|
||||
sinfo.cbSize = sizeof(sinfo);
|
||||
sinfo.fMask = SEE_MASK_CLASSNAME;
|
||||
sinfo.lpVerb = "open";
|
||||
sinfo.lpFile = p;
|
||||
sinfo.nShow = SW_SHOWNORMAL;
|
||||
sinfo.lpClass = "http";
|
||||
|
||||
if(!ShellExecuteExA(&sinfo))
|
||||
initprintf("Error launching browser!\n");
|
||||
CONFIG_SetupMouse();
|
||||
CONFIG_SetupJoystick();
|
||||
CONFIG_WriteSetup();
|
||||
gameexit(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (preinitengine())
|
||||
|
|
Loading…
Reference in a new issue