]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host_cmd.c
optimized AngleVectors calls (pass NULL for vectors that should not be generated)
[xonotic/darkplaces.git] / host_cmd.c
index d2411048a8f5e11d0e68b64bb2eefe9783bd6bcc..f9f3225681ec4db763e4e19ec9132bd3b2c931b6 100644 (file)
@@ -26,6 +26,8 @@ int   current_skill;
 
 void Mod_Print (void);
 
+dfunction_t *ED_FindFunction (char *name);
+
 /*
 ==================
 Host_Quit_f
@@ -78,7 +80,7 @@ void Host_Status_f (void)
                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)
@@ -593,7 +595,7 @@ void Host_Loadgame_f (void)
        for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
        {
                fscanf (f, "%s\n", str);
-               sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
+               sv.lightstyles[i] = Hunk_AllocName (strlen(str)+1, "lightstyles");
                strcpy (sv.lightstyles[i], str);
        }
 
@@ -706,7 +708,7 @@ void Host_Name_f (void)
        
 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");
 }
 
@@ -793,7 +795,7 @@ void Host_Tell_f(void)
        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)
        {
@@ -848,6 +850,8 @@ void Host_Color_f(void)
 {
        int             top, bottom;
        int             playercolor;
+       dfunction_t *f;
+       func_t  SV_ChangeTeam;
        
        if (Cmd_Argc() == 1)
        {
@@ -883,13 +887,25 @@ void Host_Color_f(void)
                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);
+       }
 }
 
 /*
@@ -907,13 +923,13 @@ void Host_Kill_f (void)
 
        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");
 }
 
 
@@ -969,7 +985,7 @@ void Host_PreSpawn_f (void)
 
        if (host_client->spawned)
        {
-               Con_Printf ("prespawn not valid -- allready spawned\n");
+               Con_Printf ("prespawn not valid -- already spawned\n");
                return;
        }
        
@@ -979,8 +995,6 @@ void Host_PreSpawn_f (void)
        host_client->sendsignon = true;
 }
 
-dfunction_t *ED_FindFunction (char *name);
-
 /*
 ==================
 Host_Spawn_f
@@ -1002,13 +1016,17 @@ void Host_Spawn_f (void)
 
        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;
 
@@ -1018,7 +1036,7 @@ void Host_Spawn_f (void)
                        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
@@ -1043,18 +1061,15 @@ void Host_Spawn_f (void)
 
                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)
                        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);
@@ -1454,15 +1469,12 @@ void Host_Viewframe_f (void)
 
 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);
 }
 
 /*