Skip to content

Commit

Permalink
CSQC: Load and announce csprogs.dat.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsvensson committed Nov 13, 2024
1 parent 6259901 commit e73228a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ typedef struct

entity_state_t static_entities[512];
int static_entity_count;
#ifdef FTE_PEXT_CSQC
unsigned int csqcchecksum;
#endif
} server_t;

#define NUM_SPAWN_PARMS 16
Expand Down
31 changes: 31 additions & 0 deletions src/sv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,33 @@ static unsigned SV_CheckModel(char *mdl)
return crc;
}

#ifdef FTE_PEXT_CSQC
static void SV_LoadCSQC(void)
{
extern cvar_t sv_csqc_progname;
int size;

byte *file = FS_LoadTempFile(sv_csqc_progname.string, &size);
if (file)
{
char text[64];
sv.csqcchecksum = Com_BlockChecksum(file, size);
sprintf(text, "0x%x", sv.csqcchecksum);
Info_SetValueForStarKey(svs.info, "*csprogs", text, MAX_SERVERINFO_STRING);
sprintf(text, "0x%x", (unsigned int)size);
Info_SetValueForStarKey(svs.info, "*csprogssize", text, MAX_SERVERINFO_STRING);
Info_SetValueForStarKey(svs.info, "*csprogsname", sv_csqc_progname.string, MAX_SERVERINFO_STRING);
}
else
{
sv.csqcchecksum = 0;
Info_SetValueForStarKey(svs.info, "*csprogs", "", MAX_SERVERINFO_STRING);
Info_SetValueForStarKey(svs.info, "*csprogssize", "", MAX_SERVERINFO_STRING);
Info_SetValueForStarKey(svs.info, "*csprogsname", "", MAX_SERVERINFO_STRING);
}
}
#endif

/*
================
SV_SpawnServer
Expand Down Expand Up @@ -339,6 +366,10 @@ void SV_SpawnServer(char *mapname, qbool devmap, char* entityfile, qbool loading

sv.time = 1.0;

#ifdef FTE_PEXT_CSQC
SV_LoadCSQC();
#endif

// load progs to get entity field count
// which determines how big each edict is
// and allocate edicts
Expand Down
8 changes: 8 additions & 0 deletions src/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ cvar_t sv_pext_mvdsv_serversideweapon = { "sv_pext_mvdsv_serversideweapon", "1"

cvar_t sv_extlimits = { "sv_extlimits", "2" };

#ifdef FTE_PEXT_CSQC
cvar_t sv_csqc_progname = { "sv_csqc_progname", "csprogs.dat" };
#endif

qbool sv_error = false;

client_t *WatcherId = NULL; // QW262
Expand Down Expand Up @@ -3529,6 +3533,10 @@ void SV_InitLocal (void)

Cvar_Register(&sv_mod_extensions);

#ifdef FTE_PEXT_CSQC
Cvar_Register (&sv_csqc_progname);
#endif

// QW262 -->
Cmd_AddCommand ("svadmin", SV_Admin_f);
// <-- QW262
Expand Down
19 changes: 17 additions & 2 deletions src/sv_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,17 @@ static void Cmd_New_f (void)
if (!gamedir[0])
gamedir = "qw";

#ifdef FTE_PEXT_CSQC
if (sv.csqcchecksum && !(sv_client->fteprotocolextensions & FTE_PEXT_CSQC))
{
SV_ClientPrintf(sv_client, PRINT_HIGH, "\n\n\n\n"
"This server is using CSQC - you are missing out due to your choice of outdated client / protocol!\n"
"Please upgrade to one of the following:\n"
"> ezQuake (https://www.ezquake.com) (hardcoded KTX support)\n"
"> FTEQW (http://fte.triptohell.info/)\n");
}
#endif

#ifdef FTE_PEXT_FLOATCOORDS
if (msg_coordsize > 2 && !(sv_client->fteprotocolextensions & FTE_PEXT_FLOATCOORDS))
{
Expand Down Expand Up @@ -1416,10 +1427,14 @@ static void Cmd_Download_f(void)

if (sv_client->special)
allow_dl = true; // NOTE: user used techlogin, allow dl anything in quake dir in such case!
else if (!strstr(name, "/"))
allow_dl = false; // should be in subdir
else if (!(int)allow_download.value)
allow_dl = false; // global allow check
#ifdef FTE_PEXT_CSQC
else if (!strncmp(name, "csprogs.dat", 11))
allow_dl = true; // we always allow csprogs.dat to be downloaded (if downloads are permitted).
#endif
else if (!strstr(name, "/"))
allow_dl = false; // should be in subdir
else if (!strncmp(name, "skins/", 6))
allow_dl = allow_download_skins.value; // skins
else if (!strncmp(name, "progs/", 6))
Expand Down

0 comments on commit e73228a

Please sign in to comment.