#include "quakedef.h"
-extern cvar_t pausable;
-
int current_skill;
void Mod_Print (void);
+dfunction_t *ED_FindFunction (char *name);
+
/*
==================
Host_Quit_f
==================
*/
-extern void M_Menu_Quit_f (void);
+// LordHavoc: didn't like it asking me if I wanted to quit
+//extern void M_Menu_Quit_f (void);
void Host_Quit_f (void)
{
+ /*
if (key_dest != key_console && cls.state != ca_dedicated)
{
M_Menu_Quit_f ();
return;
}
+ */
CL_Disconnect ();
Host_ShutdownServer(false);
print = SV_ClientPrintf;
print ("host: %s\n", Cvar_VariableString ("hostname"));
- print ("version: %4.2f\n", VERSION);
+ print ("version: %4.2f (build %i)\n", VERSION, buildnumber);
if (tcpipAvailable)
print ("tcp/ip: %s\n", my_tcpip_address);
if (ipxAvailable)
return;
}
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
return;
}
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
return;
}
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
if (sv_player->v.movetype != MOVETYPE_NOCLIP)
return;
}
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
if (sv_player->v.movetype != MOVETYPE_FLY)
cls.demonum = -1; // stop demo loop in case this fails
+// SCR_BeginLoadingPlaque ();
+
CL_Disconnect ();
Host_ShutdownServer(false);
key_dest = key_game; // remove console or menu
- SCR_BeginLoadingPlaque ();
cls.mapstring[0] = 0;
for (i=0 ; i<Cmd_Argc() ; i++)
*/
void Host_Reconnect_f (void)
{
- SCR_BeginLoadingPlaque ();
+// SCR_BeginLoadingPlaque ();
cls.signon = 0; // need new connection messages
}
void Host_Savegame_f (void)
{
char name[256];
- FILE *f;
+ QFile *f;
int i;
char comment[SAVEGAME_COMMENT_LENGTH+1];
COM_DefaultExtension (name, ".sav");
Con_Printf ("Saving game to %s...\n", name);
- f = fopen (name, "w");
+ f = Qopen (name, "w");
if (!f)
{
Con_Printf ("ERROR: couldn't open.\n");
return;
}
- fprintf (f, "%i\n", SAVEGAME_VERSION);
+ Qprintf (f, "%i\n", SAVEGAME_VERSION);
Host_SavegameComment (comment);
- fprintf (f, "%s\n", comment);
+ Qprintf (f, "%s\n", comment);
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
- fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
- fprintf (f, "%d\n", current_skill);
- fprintf (f, "%s\n", sv.name);
- fprintf (f, "%f\n",sv.time);
+ Qprintf (f, "%f\n", svs.clients->spawn_parms[i]);
+ Qprintf (f, "%d\n", current_skill);
+ Qprintf (f, "%s\n", sv.name);
+ Qprintf (f, "%f\n",sv.time);
// write the light styles
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
{
if (sv.lightstyles[i])
- fprintf (f, "%s\n", sv.lightstyles[i]);
+ Qprintf (f, "%s\n", sv.lightstyles[i]);
else
- fprintf (f,"m\n");
+ Qprintf (f,"m\n");
}
for (i=0 ; i<sv.num_edicts ; i++)
{
ED_Write (f, EDICT_NUM(i));
- fflush (f);
+ Qflush (f);
}
- fclose (f);
+ Qclose (f);
Con_Printf ("done.\n");
}
void Host_Loadgame_f (void)
{
char name[MAX_OSPATH];
- FILE *f;
+ QFile *f;
char mapname[MAX_QPATH];
float time, tfloat;
- char str[32768], *start;
+ char buf[32768], *start;
+ char *str;
int i, r;
edict_t *ent;
int entnum;
sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1));
COM_DefaultExtension (name, ".sav");
-
-// we can't call SCR_BeginLoadingPlaque, because too much stack space has
-// been used. The menu calls it before stuffing loadgame command
+
+ // LordHavoc: made SCR_UpdateScreen use a great deal less stack space, no longer an issue
+ //// we can't call SCR_BeginLoadingPlaque, because too much stack space has
+ //// been used. The menu calls it before stuffing loadgame command
// SCR_BeginLoadingPlaque ();
Con_Printf ("Loading game from %s...\n", name);
- f = fopen (name, "r");
+ f = Qopen (name, "rz");
if (!f)
{
Con_Printf ("ERROR: couldn't open.\n");
return;
}
- fscanf (f, "%i\n", &version);
+ str = Qgetline (f);
+ sscanf (str, "%i\n", &version);
if (version != SAVEGAME_VERSION)
{
- fclose (f);
+ Qclose (f);
Con_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION);
return;
}
- fscanf (f, "%s\n", str);
- for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
- fscanf (f, "%f\n", &spawn_parms[i]);
+ str = Qgetline (f);
+ for (i=0 ; i<NUM_SPAWN_PARMS ; i++) {
+ str = Qgetline (f);
+ sscanf (str, "%f\n", &spawn_parms[i]);
+ }
// this silliness is so we can load 1.06 save files, which have float skill values
- fscanf (f, "%f\n", &tfloat);
+ str = Qgetline (f);
+ sscanf (str, "%f\n", &tfloat);
current_skill = (int)(tfloat + 0.1);
Cvar_SetValue ("skill", (float)current_skill);
- fscanf (f, "%s\n",mapname);
- fscanf (f, "%f\n",&time);
+ strcpy (mapname, Qgetline (f));
+
+ str = Qgetline (f);
+ sscanf (str, "%f\n",&time);
CL_Disconnect_f ();
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
{
- fscanf (f, "%s\n", str);
- sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
+ str = Qgetline (f);
+ sv.lightstyles[i] = Hunk_AllocName (strlen(str)+1, "lightstyles");
strcpy (sv.lightstyles[i], str);
}
// load the edicts out of the savegame file
entnum = -1; // -1 is the globals
- while (!feof(f))
+ while (!Qeof(f))
{
- for (i=0 ; i<sizeof(str)-1 ; i++)
+ for (i=0 ; i<sizeof(buf)-1 ; i++)
{
- r = fgetc (f);
+ r = Qgetc (f);
if (r == EOF || !r)
break;
- str[i] = r;
+ buf[i] = r;
if (r == '}')
{
i++;
break;
}
}
- if (i == sizeof(str)-1)
+ if (i == sizeof(buf)-1)
Sys_Error ("Loadgame buffer overflow");
- str[i] = 0;
- start = str;
- start = COM_Parse(str);
+ buf[i] = 0;
+ start = buf;
+ start = COM_Parse(buf);
if (!com_token[0])
break; // end of file
if (strcmp(com_token,"{"))
sv.num_edicts = entnum;
sv.time = time;
- fclose (f);
+ Qclose (f);
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
svs.clients->spawn_parms[i] = spawn_parms[i];
void Host_Version_f (void)
{
- Con_Printf ("Version %4.2f\n", VERSION);
+ Con_Printf ("Version %4.2f (build %i)\n", VERSION, buildnumber);
Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
}
-#ifdef IDGODS
-void Host_Please_f (void)
-{
- client_t *cl;
- int j;
-
- if (cmd_source != src_command)
- return;
-
- if ((Cmd_Argc () == 3) && strcmp(Cmd_Argv(1), "#") == 0)
- {
- j = atof(Cmd_Argv(2)) - 1;
- if (j < 0 || j >= svs.maxclients)
- return;
- if (!svs.clients[j].active)
- return;
- cl = &svs.clients[j];
- if (cl->privileged)
- {
- cl->privileged = false;
- cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET);
- cl->edict->v.movetype = MOVETYPE_WALK;
- noclip_anglehack = false;
- }
- else
- cl->privileged = true;
- }
-
- if (Cmd_Argc () != 2)
- return;
-
- for (j=0, cl = svs.clients ; j<svs.maxclients ; j++, cl++)
- {
- if (!cl->active)
- continue;
- if (strcasecmp(cl->name, Cmd_Argv(1)) == 0)
- {
- if (cl->privileged)
- {
- cl->privileged = false;
- cl->edict->v.flags = (int)cl->edict->v.flags & ~(FL_GODMODE|FL_NOTARGET);
- cl->edict->v.movetype = MOVETYPE_WALK;
- noclip_anglehack = false;
- }
- else
- cl->privileged = true;
- break;
- }
- }
-}
-#endif
-
-
void Host_Say(qboolean teamonly)
{
client_t *client;
client_t *save;
int j;
char *p;
- char text[64];
+ char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
if (cmd_source == src_command)
{
{
int top, bottom;
int playercolor;
+ dfunction_t *f;
+ func_t SV_ChangeTeam;
if (Cmd_Argc() == 1)
{
return;
}
- host_client->colors = playercolor;
- host_client->edict->v.team = bottom + 1;
+ // void(float color) SV_ChangeTeam;
+ if ((f = ED_FindFunction ("SV_ChangeTeam")) && (SV_ChangeTeam = (func_t)(f - pr_functions)))
+ {
+ Con_DPrintf("Calling SV_ChangeTeam\n");
+ pr_global_struct->time = sv.time;
+ pr_globals[0] = playercolor;
+ pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
+ PR_ExecuteProgram (SV_ChangeTeam, "");
+ }
+ else
+ {
+ host_client->colors = playercolor;
+ host_client->edict->v.team = bottom + 1;
-// send notification to all clients
- MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
- MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
- MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
+ // send notification to all clients
+ MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
+ MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
+ MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
+ }
}
/*
if (sv_player->v.health <= 0)
{
- SV_ClientPrintf ("Can't suicide -- allready dead!\n");
+ SV_ClientPrintf ("Can't suicide -- already dead!\n");
return;
}
pr_global_struct->time = sv.time;
pr_global_struct->self = EDICT_TO_PROG(sv_player);
- PR_ExecuteProgram (pr_global_struct->ClientKill);
+ PR_ExecuteProgram (pr_global_struct->ClientKill, "QC function ClientKill is missing");
}
if (host_client->spawned)
{
- Con_Printf ("prespawn not valid -- allready spawned\n");
+ Con_Printf ("prespawn not valid -- already spawned\n");
return;
}
host_client->sendsignon = true;
}
-dfunction_t *ED_FindFunction (char *name);
-
/*
==================
Host_Spawn_f
if (host_client->spawned)
{
- Con_Printf ("Spawn not valid -- allready spawned\n");
+ Con_Printf ("Spawn not valid -- already spawned\n");
return;
}
+ // LordHavoc: moved this above the QC calls at FrikaC's request
+// send all current names, colors, and frag counts
+ SZ_Clear (&host_client->message);
+
// run the entrance script
if (sv.loadgame)
- { // loaded games are fully inited allready
+ { // loaded games are fully inited already
// if this is the last client to be connected, unpause
sv.paused = false;
- if (f = ED_FindFunction ("RestoreGame"))
- if (RestoreGame = (func_t)(f - pr_functions))
+ if ((f = ED_FindFunction ("RestoreGame")))
+ if ((RestoreGame = (func_t)(f - pr_functions)))
{
Con_DPrintf("Calling RestoreGame\n");
pr_global_struct->time = sv.time;
pr_global_struct->self = EDICT_TO_PROG(sv_player);
- PR_ExecuteProgram (RestoreGame);
+ PR_ExecuteProgram (RestoreGame, "");
}
}
else
{
+ eval_t *val;
// set up the edict
ent = host_client->edict;
ent->v.colormap = NUM_FOR_EDICT(ent);
ent->v.team = (host_client->colors & 15) + 1;
ent->v.netname = host_client->name - pr_strings;
+ if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
+ val->_float = host_client->pmodel;
// copy spawn parms out of the client_t
pr_global_struct->time = sv.time;
pr_global_struct->self = EDICT_TO_PROG(sv_player);
- PR_ExecuteProgram (pr_global_struct->ClientConnect);
+ PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
- if ((Sys_FloatTime() - host_client->netconnection->connecttime) <= sv.time)
+ if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time)
Sys_Printf ("%s entered the game\n", host_client->name);
- PR_ExecuteProgram (pr_global_struct->PutClientInServer);
+ PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
}
-// send all current names, colors, and frag counts
- SZ_Clear (&host_client->message);
-
// send time of update
MSG_WriteByte (&host_client->message, svc_time);
MSG_WriteFloat (&host_client->message, sv.time);
return;
}
}
- else if (pr_global_struct->deathmatch && !host_client->privileged)
+ else if (pr_global_struct->deathmatch)
return;
save = host_client;
return;
}
- if (pr_global_struct->deathmatch && !host_client->privileged)
+ if (pr_global_struct->deathmatch)
return;
t = Cmd_Argv(1);
case 's':
if (rogue)
{
- if (val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1))
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_shells1)))
val->_float = v;
}
case 'n':
if (rogue)
{
- if (val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1))
+ if ((val = GETEDICTFIELDVALUE(sv_player, eval_ammo_nails1)))
{
val->_float = v;
if (sv_player->v.weapon <= IT_LIGHTNING)
void PrintFrameName (model_t *m, int frame)
{
- aliashdr_t *hdr;
- maliasframedesc_t *pframedesc;
-
- hdr = (aliashdr_t *)Mod_Extradata (m);
- if (!hdr)
- return;
- pframedesc = &hdr->frames[frame];
-
- Con_Printf ("frame %i: %s\n", frame, pframedesc->name);
+ int data;
+ data = (int) Mod_Extradata(m);
+ if (m->ofs_scenes && data)
+ Con_Printf("frame %i: %s\n", frame, ((animscene_t *) (m->ofs_scenes + data))[frame].name);
+ else
+ Con_Printf("frame %i\n", frame);
}
/*
CL_Disconnect ();
}
-/*
-======================
-Host_PModel_f
-LordHavoc: Intended for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
-======================
-*/
-void Host_PModel_f (void)
-{
- int i;
- eval_t *val;
-
- if (Cmd_Argc () == 1)
- {
- Con_Printf ("usage: pmodel modelnumber\n");
- return;
- }
- i = atoi(Cmd_Argv(1));
-
- if (cmd_source == src_command)
- {
- if (cls.state == ca_connected)
- Cmd_ForwardToServer ();
- return;
- }
-
- if (val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel))
- val->_float = i;
-}
-
//=============================================================================
/*
Cmd_AddCommand ("reconnect", Host_Reconnect_f);
Cmd_AddCommand ("name", Host_Name_f);
Cmd_AddCommand ("version", Host_Version_f);
-#ifdef IDGODS
- Cmd_AddCommand ("please", Host_Please_f);
-#endif
Cmd_AddCommand ("say", Host_Say_f);
Cmd_AddCommand ("say_team", Host_Say_Team_f);
Cmd_AddCommand ("tell", Host_Tell_f);
Cmd_AddCommand ("ping", Host_Ping_f);
Cmd_AddCommand ("load", Host_Loadgame_f);
Cmd_AddCommand ("save", Host_Savegame_f);
- Cmd_AddCommand ("pmodel", Host_PModel_f);
Cmd_AddCommand ("startdemos", Host_Startdemos_f);
Cmd_AddCommand ("demos", Host_Demos_f);