Skip to content

Commit

Permalink
CVARS: Added server/mod information variables
Browse files Browse the repository at this point in the history
  • Loading branch information
deurk committed May 9, 2020
1 parent 97d4512 commit 1b79904
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ char *VersionStringFull (void)
static char str[256];

if (!str[0]) {
if (GIT_COMMIT) {
if (!strlen(GIT_COMMIT)) {
snprintf(str, sizeof(str), SERVER_NAME " " VERSION_NUMBER);
} else {
snprintf(str, sizeof(str), SERVER_NAME " " VERSION_NUMBER " (build " GIT_COMMIT "/" QW_PLATFORM_SHORT ")");
snprintf(str, sizeof(str), SERVER_NAME " " VERSION_NUMBER " (build " GIT_COMMIT "-" QW_PLATFORM_SHORT ")");
}
}

Expand Down
43 changes: 35 additions & 8 deletions src/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,24 @@ void SV_InitLocal (void)
//extern cvar_t pm_slidefix;
extern cvar_t pm_ktjump;
//extern cvar_t pm_bunnyspeedcap;

// qws = QuakeWorld Server information
static cvar_t qws_name = { "qws_name", SERVER_NAME, CVAR_ROM };
static cvar_t qws_fullname = { "qws_fullname", SERVER_FULLNAME, CVAR_ROM };
static cvar_t qws_version = { "qws_version", VERSION_NUMBER, CVAR_ROM };
static cvar_t qws_buildnum = { "qws_buildnum", (GIT_COMMIT ? GIT_COMMIT : "unknown"), CVAR_ROM };
static cvar_t qws_platform = { "qws_platform", QW_PLATFORM_SHORT, CVAR_ROM };
static cvar_t qws_builddate = { "qws_builddate", BUILD_DATE, CVAR_ROM };
static cvar_t qws_homepage = { "qws_homepage", HOMEPAGE_URL, CVAR_ROM };
// qwm = QuakeWorld Mod information placeholders
static cvar_t qwm_name = { "qwm_name", "" };
static cvar_t qwm_fullname = { "qwm_fullname", "" };
static cvar_t qwm_version = { "qwm_version", "" };
static cvar_t qwm_buildnum = { "qwm_buildnum", "" };
static cvar_t qwm_platform = { "qwm_platform", "" };
static cvar_t qwm_builddate = { "qwm_builddate", "" };
static cvar_t qwm_homepage = { "qwm_homepage", "" };

packet_t *packet_freeblock; // initialise delayed packet free block

SV_InitOperatorCommands ();
Expand Down Expand Up @@ -3430,6 +3448,21 @@ void SV_InitLocal (void)

Cvar_Register (&sv_reliable_sound);

Cvar_Register (&qws_name);
Cvar_Register (&qws_fullname);
Cvar_Register (&qws_version);
Cvar_Register (&qws_buildnum);
Cvar_Register (&qws_platform);
Cvar_Register (&qws_builddate);
Cvar_Register (&qws_homepage);
Cvar_Register (&qwm_name);
Cvar_Register (&qwm_fullname);
Cvar_Register (&qwm_version);
Cvar_Register (&qwm_buildnum);
Cvar_Register (&qwm_platform);
Cvar_Register (&qwm_builddate);
Cvar_Register (&qwm_homepage);

// QW262 -->
Cmd_AddCommand ("svadmin", SV_Admin_f);
// <-- QW262
Expand Down Expand Up @@ -3486,11 +3519,6 @@ void SV_InitLocal (void)
Info_SetValueForStarKey (svs.info, "*version", SERVER_NAME " " VERSION_NUMBER, MAX_SERVERINFO_STRING);
Info_SetValueForStarKey (svs.info, "*z_ext", va("%i", SERVER_EXTENSIONS), MAX_SERVERINFO_STRING);

Info_SetValueForStarKey (svs.info, "mvdsvver", VERSION_NUMBER, MAX_SERVERINFO_STRING);
//Info_SetValueForStarKey (svs.info, "mvdsvbuild", GIT_COMMIT, MAX_SERVERINFO_STRING);
//Info_SetValueForStarKey (svs.info, "mvdsvdate", BUILD_DATE, MAX_SERVERINFO_STRING);
//Info_SetValueForStarKey (svs.info, "mvdsvurl", HOMEPAGE_URL, MAX_SERVERINFO_STRING);

// init fraglog stuff
svs.logsequence = 1;
svs.logtime = realtime;
Expand Down Expand Up @@ -3717,7 +3745,7 @@ void COM_Init (void)
Cvar_Register (&version);
Cvar_Register (&sys_simulation);

Cvar_SetROM(&version, VersionStringFull());
Cvar_SetROM(&version, SERVER_NAME " " VERSION_NUMBER);
}

//Free hunk memory up to host_hunklevel
Expand Down Expand Up @@ -3764,7 +3792,7 @@ void Host_Init (int argc, char **argv, int default_memsize)

Host_InitMemory (default_memsize);

Con_Printf ("============= Starting " SERVER_NAME " =============\n");
Con_Printf ("============= Starting %s =============\n", VersionStringFull());

Cbuf_Init ();
Cmd_Init ();
Expand Down Expand Up @@ -3799,7 +3827,6 @@ void Host_Init (int argc, char **argv, int default_memsize)

Con_Printf ("%4.1f megabyte heap\n", (float)hunk_size / (1024 * 1024));
Con_Printf ("QuakeWorld Initialized\n");
Con_Printf (VersionStringFull());

Cbuf_InsertText ("exec server.cfg\n");

Expand Down
3 changes: 2 additions & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define VERSION_NUMBER "0.33-beta"
#define VERSION_NUM 0.32
#define SERVER_NAME "MVDSV"
#define HOMEPAGE_URL "https://github.com/deurk/mvdsv"
#define SERVER_FULLNAME "MVDSV: MultiView Demo SerVer"
#define HOMEPAGE_URL "https://mvdsv.deurk.net"
#define BUILD_DATE __DATE__ ", " __TIME__
#define GIT_COMMIT ""

Expand Down

0 comments on commit 1b79904

Please sign in to comment.