From d7f84a926e7df88cc1fe6dd74b7a98da0865d969 Mon Sep 17 00:00:00 2001 From: Shpoike Date: Thu, 2 May 2019 04:25:41 +0100 Subject: [PATCH] Support up to parm64 instead of just parms1-16. --- quakespasm/Quake/host_cmd.c | 37 ++++++++++++++++++++++++++++++++----- quakespasm/Quake/pr_cmds.c | 11 ++++++++++- quakespasm/Quake/server.h | 5 +++-- quakespasm/Quake/sv_main.c | 16 +++++++++++++--- 4 files changed, 58 insertions(+), 11 deletions(-) diff --git a/quakespasm/Quake/host_cmd.c b/quakespasm/Quake/host_cmd.c index 8fa6327e..2ad30457 100644 --- a/quakespasm/Quake/host_cmd.c +++ b/quakespasm/Quake/host_cmd.c @@ -1139,7 +1139,7 @@ void Host_Savegame_f (void) fprintf (f, "%i\n", SAVEGAME_VERSION); Host_SavegameComment (comment); fprintf (f, "%s\n", comment); - for (i = 0; i < NUM_SPAWN_PARMS; i++) + for (i = 0; i < NUM_BASIC_SPAWN_PARMS; i++) fprintf (f, "%f\n", svs.clients->spawn_parms[i]); fprintf (f, "%d\n", current_skill); fprintf (f, "%s\n", sv.name); @@ -1190,6 +1190,13 @@ void Host_Savegame_f (void) if (sv.particle_precache[i]) fprintf (f, "sv.particle_precache %i \"%s\"\n", i, sv.particle_precache[i]); } + + for (i = NUM_BASIC_SPAWN_PARMS ; i < NUM_TOTAL_SPAWN_PARMS ; i++) + { + if (svs.clients->spawn_parms[i]) + fprintf (f, "spawnparm %i \"%f\"\n", i+1, svs.clients->spawn_parms[i]); + } + fprintf(f, "*/\n"); @@ -1216,7 +1223,7 @@ void Host_Loadgame_f (void) edict_t *ent; int entnum; int version; - float spawn_parms[NUM_SPAWN_PARMS]; + float spawn_parms[NUM_TOTAL_SPAWN_PARMS]; if (cmd_source != src_command) return; @@ -1265,8 +1272,10 @@ void Host_Loadgame_f (void) return; } data = COM_ParseStringNewline (data); - for (i = 0; i < NUM_SPAWN_PARMS; i++) + for (i = 0; i < NUM_BASIC_SPAWN_PARMS; i++) data = COM_ParseFloatNewline (data, &spawn_parms[i]); + for (; i < NUM_TOTAL_SPAWN_PARMS; i++) + spawn_parms[i] = 0; // this silliness is so we can load 1.06 save files, which have float skill values data = COM_ParseFloatNewline(data, &tfloat); current_skill = (int)(tfloat + 0.1); @@ -1361,6 +1370,15 @@ void Host_Loadgame_f (void) if (idx >= 1 && idx < MAX_PARTICLETYPES) sv.particle_precache[idx] = (const char *)Hunk_Strdup (com_token, "particle_precache"); } + else if (!strcmp(com_token, "spawnparm")) + { + int idx; + ext = COM_Parse(ext); + idx = atoi(com_token); + ext = COM_Parse(ext); + if (idx >= 1 && idx <= NUM_TOTAL_SPAWN_PARMS) + spawn_parms[idx-1] = atof(com_token); + } *end = '\n'; ext = end+1; } @@ -1404,7 +1422,7 @@ void Host_Loadgame_f (void) free (start); start = NULL; - for (i = 0; i < NUM_SPAWN_PARMS; i++) + for (i = 0; i < NUM_TOTAL_SPAWN_PARMS; i++) svs.clients->spawn_parms[i] = spawn_parms[i]; PR_SwitchQCVM(NULL); @@ -1803,8 +1821,17 @@ void Host_Spawn_f (void) ent->v.netname = PR_SetEngineString(host_client->name); // copy spawn parms out of the client_t - for (i=0 ; i< NUM_SPAWN_PARMS ; i++) + for (i=0 ; i< NUM_BASIC_SPAWN_PARMS ; i++) (&pr_global_struct->parm1)[i] = host_client->spawn_parms[i]; + if (pr_checkextension.value) + { //extended spawn parms + for ( ; i< NUM_TOTAL_SPAWN_PARMS ; i++) + { + ddef_t *g = ED_FindGlobal(va("parm%i", i+1)); + if (g) + qcvm->globals[g->ofs] = host_client->spawn_parms[i]; + } + } // call the spawn function pr_global_struct->time = qcvm->time; pr_global_struct->self = EDICT_TO_PROG(sv_player); diff --git a/quakespasm/Quake/pr_cmds.c b/quakespasm/Quake/pr_cmds.c index ebe0b63e..1f496e2e 100644 --- a/quakespasm/Quake/pr_cmds.c +++ b/quakespasm/Quake/pr_cmds.c @@ -1687,8 +1687,17 @@ static void PF_sv_setspawnparms (void) // copy spawn parms out of the client_t client = svs.clients + (i-1); - for (i = 0; i < NUM_SPAWN_PARMS; i++) + for (i = 0; i < NUM_BASIC_SPAWN_PARMS; i++) (&pr_global_struct->parm1)[i] = client->spawn_parms[i]; + if (pr_checkextension.value) + { //extended spawn parms + for ( ; i< NUM_TOTAL_SPAWN_PARMS ; i++) + { + ddef_t *g = ED_FindGlobal(va("parm%i", i+1)); + if (g) + qcvm->globals[g->ofs] = client->spawn_parms[i]; + } + } } /* diff --git a/quakespasm/Quake/server.h b/quakespasm/Quake/server.h index 47a3d2d4..24380987 100644 --- a/quakespasm/Quake/server.h +++ b/quakespasm/Quake/server.h @@ -101,7 +101,8 @@ typedef struct #define NUM_PING_TIMES 16 -#define NUM_SPAWN_PARMS 16 +#define NUM_BASIC_SPAWN_PARMS 16 +#define NUM_TOTAL_SPAWN_PARMS 64 typedef struct client_s { @@ -130,7 +131,7 @@ typedef struct client_s int num_pings; // ping_times[num_pings%NUM_PING_TIMES] // spawn parms are carried from level to level - float spawn_parms[NUM_SPAWN_PARMS]; + float spawn_parms[NUM_TOTAL_SPAWN_PARMS]; // client known data for deltas int old_frags; diff --git a/quakespasm/Quake/sv_main.c b/quakespasm/Quake/sv_main.c index 71a38098..8b7c4437 100644 --- a/quakespasm/Quake/sv_main.c +++ b/quakespasm/Quake/sv_main.c @@ -1763,7 +1763,7 @@ void SV_ConnectClient (int clientnum) int edictnum; struct qsocket_s *netconnection; int i; - float spawn_parms[NUM_SPAWN_PARMS]; + float spawn_parms[NUM_TOTAL_SPAWN_PARMS]; client = svs.clients + clientnum; @@ -1806,8 +1806,13 @@ void SV_ConnectClient (int clientnum) { // call the progs to get default spawn parms for the new client PR_ExecuteProgram (pr_global_struct->SetNewParms); - for (i=0 ; ispawn_parms[i] = (&pr_global_struct->parm1)[i]; + for ( ; i< NUM_TOTAL_SPAWN_PARMS ; i++) + { + ddef_t *g = ED_FindGlobal(va("parm%i", i+1)); + client->spawn_parms[i] = g?qcvm->globals[g->ofs]:0; + } } SV_SendServerinfo (client); @@ -2933,8 +2938,13 @@ void SV_SaveSpawnparms (void) // call the progs to get default spawn parms for the new client pr_global_struct->self = EDICT_TO_PROG(host_client->edict); PR_ExecuteProgram (pr_global_struct->SetChangeParms); - for (j=0 ; jspawn_parms[j] = (&pr_global_struct->parm1)[j]; + for ( ; i< NUM_TOTAL_SPAWN_PARMS ; i++) + { + ddef_t *g = ED_FindGlobal(va("parm%i", i+1)); + host_client->spawn_parms[i] = g?qcvm->globals[g->ofs]:0; + } } }