mserv.h 2.7 KB
Newer Older
Alam Ed Arias committed
1 2 3
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team.
James R. committed
4
// Copyright (C) 1999-2020 by Sonic Team Junior.
5
// Copyright (C)      2020 by James R.
Alam Ed Arias committed
6 7 8 9 10 11 12 13 14 15 16
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file  mserv.h
/// \brief Header file for the master server routines

#ifndef _MSERV_H_
#define _MSERV_H_

17 18
#include "i_threads.h"

Alam Ed Arias committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
// lowered from 32 due to menu changes
#define NUM_LIST_ROOMS 16

#if defined(_MSC_VER)
#pragma pack(1)
#endif

typedef union
{
	char buffer[16]; // information such as password
	UINT32 signature;
} ATTRPACK msg_header_t;

// Keep this structure 8 bytes aligned (current size is 80)
typedef struct
{
	msg_header_t header;
	char ip[16];
	char port[8];
	char name[32];
	INT32 room;
	char version[8]; // format is: x.yy.z (like 1.30.2 or 1.31)
} ATTRPACK msg_server_t;

typedef struct
{
	msg_header_t header;
	INT32 id;
	char name[32];
	char motd[255];
} ATTRPACK msg_rooms_t;

typedef struct
{
	msg_header_t header;
	char ipstart[16];
	char ipend[16];
	char endstamp[32];
	char reason[255];
	INT32 hostonly;
} ATTRPACK msg_ban_t;

#if defined(_MSC_VER)
#pragma pack()
#endif

// ================================ GLOBALS ===============================

extern consvar_t cv_masterserver, cv_servername;
68
extern consvar_t cv_masterserver_update_rate;
69
extern consvar_t cv_masterserver_timeout;
70
extern consvar_t cv_masterserver_debug;
James R. committed
71
extern consvar_t cv_masterserver_token;
Alam Ed Arias committed
72 73 74 75

// < 0 to not connect (usually -1) (offline mode)
// == 0 to show all rooms, not a valid hosting room
// anything else is whatever room the MS assigns to that number (online mode)
76
extern INT16 ms_RoomId;
Alam Ed Arias committed
77

78 79 80 81 82 83 84 85
#ifdef HAVE_THREADS
extern int           ms_QueryId;
extern I_mutex       ms_QueryId_mutex;

extern msg_server_t *ms_ServerList;
extern I_mutex       ms_ServerList_mutex;
#endif

Alam Ed Arias committed
86 87 88 89 90
void RegisterServer(void);
void UnregisterServer(void);

void MasterClient_Ticker(void);

91 92
msg_server_t *GetShortServersList(INT32 room, int id);
INT32 GetRoomsList(boolean hosting, int id);
Alam Ed Arias committed
93
#ifdef UPDATE_ALERT
94
char *GetMODVersion(int id);
Alam Ed Arias committed
95 96 97 98 99 100
void GetMODVersion_Console(void);
#endif
extern msg_rooms_t room_list[NUM_LIST_ROOMS+1];

void AddMServCommands(void);

101
/* HTTP */
102
void HMS_set_api (char *api);
103
int  HMS_fetch_rooms (int joining, int id);
104
int  HMS_register (void);
105
int  HMS_unlist (void);
106 107
int  HMS_update (void);
void HMS_list_servers (void);
108
msg_server_t * HMS_fetch_servers (msg_server_t *list, int room, int id);
109 110
int  HMS_compare_mod_version (char *buffer, size_t size_of_buffer);

Alam Ed Arias committed
111
#endif