HTTP update alert

This commit is contained in:
James R 2020-04-12 20:37:46 -07:00
parent 48b2112af7
commit 032adadd86
2 changed files with 40 additions and 1 deletions

View file

@ -455,3 +455,39 @@ HMS_fetch_servers (msg_server_t *list, int room_number)
HMS_end(hms);
}
const char *
HMS_compare_mod_version (void)
{
static char buffer[16];
struct HMS_buffer *hms;
char *version;
char *version_name;
hms = HMS_connect("versions/%d", MODID);
if (HMS_do(hms))
{
version = strtok(hms->buffer, " ");
version_name = strtok(0, "\n");
if (version && version_name)
{
if (atoi(version) != MODVERSION)
{
strlcpy(buffer, version_name, sizeof buffer);
version_name = buffer;
}
else
version_name = NULL;
}
}
else
version_name = NULL;
HMS_end(hms);
return version_name;
}

View file

@ -105,6 +105,7 @@ void HMS_unlist (void);
void HMS_update (void);
void HMS_list_servers (void);
void HMS_fetch_servers (msg_server_t *list, int room);
const char * HMS_compare_mod_version (void);
// ================================ DEFINITIONS ===============================
@ -568,7 +569,9 @@ const char *GetMODVersion(void)
static msg_t msg;
if (HMS_in_use())
return NULL;
{
return HMS_compare_mod_version();
}
// we must be connected to the master server before writing to it
if (MS_Connect(GetMasterServerIP(), GetMasterServerPort(), 0))