]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host_cmd.c
- Fixed PK3 support for Mac OS X
[xonotic/darkplaces.git] / host_cmd.c
index dda37a1f23d328f3b1598121f924ac889066b7cb..882d7e7a4264f66955b8402a67e1482447dd3585 100644 (file)
@@ -75,6 +75,7 @@ void Host_Status_f (void)
                case PROTOCOL_DARKPLACES3: protocolname = "PROTOCOL_DARKPLACES3";break;
                case PROTOCOL_DARKPLACES4: protocolname = "PROTOCOL_DARKPLACES4";break;
                case PROTOCOL_DARKPLACES5: protocolname = "PROTOCOL_DARKPLACES5";break;
+               case PROTOCOL_DARKPLACES6: protocolname = "PROTOCOL_DARKPLACES6";break;
                default: protocolname = "PROTOCOL_UNKNOWN";break;
        }
        print ("protocol: %i (%s)\n", sv.protocol, protocolname);
@@ -636,8 +637,9 @@ void Host_Loadgame_f (void)
 // load the edicts out of the savegame file
        // -1 is the globals
        entnum = -1;
-       while (!FS_Eof (f))
+       for (;;)
        {
+               r = EOF;
                for (i = 0;i < (int)sizeof(buf) - 1;i++)
                {
                        r = FS_Getc (f);
@@ -650,6 +652,8 @@ void Host_Loadgame_f (void)
                                break;
                        }
                }
+               if (r == EOF)
+                       break;
                if (i == sizeof(buf)-1)
                        Host_Error ("Loadgame buffer overflow");
                buf[i] = 0;
@@ -760,6 +764,128 @@ void Host_Name_f (void)
        }
 }
 
+/*
+======================
+Host_Playermodel_f
+======================
+*/
+cvar_t cl_playermodel = {CVAR_SAVE, "_cl_playermodel", ""}; 
+// the old cl_playermodel in cl_main has been renamed to __cl_playermodel
+void Host_Playermodel_f (void)
+{
+       int i, j;
+       char newPath[sizeof(host_client->playermodel)];
+
+       if (Cmd_Argc () == 1)
+       {
+               Con_Printf("\"playermodel\" is \"%s\"\n", cl_playermodel.string);
+               return;
+       }
+
+       if (Cmd_Argc () == 2)
+               strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
+       else
+               strlcpy (newPath, Cmd_Args(), sizeof (newPath));
+
+       for (i = 0, j = 0;newPath[i];i++)
+               if (newPath[i] != '\r' && newPath[i] != '\n')
+                       newPath[j++] = newPath[i];
+       newPath[j] = 0;
+
+       if (cmd_source == src_command)
+       {
+               Cvar_Set ("_cl_playermodel", newPath);
+               if (cls.state == ca_connected)
+                       Cmd_ForwardToServer ();
+               return;
+       }
+
+       /*
+       if (sv.time < host_client->nametime)
+       {
+               SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
+               return;
+       }
+       
+       host_client->nametime = sv.time + 5;
+       */
+
+       // point the string back at updateclient->name to keep it safe
+       strlcpy (host_client->playermodel, newPath, sizeof (host_client->playermodel));
+       if( eval_playermodel )
+               GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PR_SetString(host_client->playermodel);
+       if (strcmp(host_client->old_model, host_client->playermodel))
+       {
+               if (host_client->spawned)
+                       SV_BroadcastPrintf("%s changed model to %s\n", host_client->old_model, host_client->playermodel);
+               strcpy(host_client->old_model, host_client->playermodel);
+               /*// send notification to all clients
+               MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
+               MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
+               MSG_WriteString (&sv.reliable_datagram, host_client->playermodel);*/
+       }
+}
+
+/*
+======================
+Host_Playerskin_f
+======================
+*/
+cvar_t cl_playerskin = {CVAR_SAVE, "_cl_playerskin", ""};
+void Host_Playerskin_f (void)
+{
+       int i, j;
+       char newPath[sizeof(host_client->playerskin)];
+
+       if (Cmd_Argc () == 1)
+       {
+               Con_Printf("\"playerskin\" is \"%s\"\n", cl_playerskin.string);
+               return;
+       }
+
+       if (Cmd_Argc () == 2)
+               strlcpy (newPath, Cmd_Argv(1), sizeof (newPath));
+       else
+               strlcpy (newPath, Cmd_Args(), sizeof (newPath));
+
+       for (i = 0, j = 0;newPath[i];i++)
+               if (newPath[i] != '\r' && newPath[i] != '\n')
+                       newPath[j++] = newPath[i];
+       newPath[j] = 0;
+
+       if (cmd_source == src_command)
+       {
+               Cvar_Set ("_cl_playerskin", newPath);
+               if (cls.state == ca_connected)
+                       Cmd_ForwardToServer ();
+               return;
+       }
+
+       /*
+       if (sv.time < host_client->nametime)
+       {
+               SV_ClientPrintf("You can't change playermodel more than once every 5 seconds!\n");
+               return;
+       }
+       
+       host_client->nametime = sv.time + 5;
+       */
+
+       // point the string back at updateclient->name to keep it safe
+       strlcpy (host_client->playerskin, newPath, sizeof (host_client->playerskin));
+       if( eval_playerskin )
+               GETEDICTFIELDVALUE(host_client->edict, eval_playerskin)->string = PR_SetString(host_client->playerskin);
+       if (strcmp(host_client->old_skin, host_client->playerskin))
+       {
+               if (host_client->spawned)
+                       SV_BroadcastPrintf("%s changed skin to %s\n", host_client->old_skin, host_client->playerskin);
+               strcpy(host_client->old_skin, host_client->playerskin);
+               /*// send notification to all clients
+               MSG_WriteByte (&sv.reliable_datagram, svc_updatepskin);
+               MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
+               MSG_WriteString (&sv.reliable_datagram, host_client->playerskin);*/
+       }
+}
 
 void Host_Version_f (void)
 {
@@ -825,7 +951,7 @@ void Host_Say(qboolean teamonly)
                        SV_ClientPrint(text);
        host_client = save;
 
-       Sys_Print(&text[1]);
+       //Con_Print(&text[1]);
 }
 
 
@@ -1130,6 +1256,7 @@ void Host_Spawn_f (void)
        client_t *client;
        func_t RestoreGame;
        mfunction_t *f;
+       int stats[MAX_CL_STATS];
 
        if (cmd_source == src_command)
        {
@@ -1184,7 +1311,7 @@ void Host_Spawn_f (void)
                PR_ExecuteProgram (pr_global_struct->ClientConnect, "QC function ClientConnect is missing");
 
                if ((Sys_DoubleTime() - host_client->connecttime) <= sv.time)
-                       Sys_Printf("%s entered the game\n", host_client->name);
+                       Con_Printf("%s entered the game\n", host_client->name);
 
                PR_ExecuteProgram (pr_global_struct->PutClientInServer, "QC function PutClientInServer is missing");
        }
@@ -1244,7 +1371,7 @@ void Host_Spawn_f (void)
        MSG_WriteAngle (&host_client->message, host_client->edict->v->angles[1], sv.protocol);
        MSG_WriteAngle (&host_client->message, 0, sv.protocol);
 
-       SV_WriteClientdataToMessage (host_client->edict, &host_client->message);
+       SV_WriteClientdataToMessage (host_client, host_client->edict, &host_client->message, stats);
 
        MSG_WriteByte (&host_client->message, svc_signonnum);
        MSG_WriteByte (&host_client->message, 3);
@@ -1657,7 +1784,7 @@ void Host_Startdemos_f (void)
                Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
                c = MAX_DEMOS;
        }
-       Con_DPrintf("%i demo(s) in loop\n", c);
+       Con_Printf("%i demo(s) in loop\n", c);
 
        for (i=1 ; i<c+1 ; i++)
                strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof (cls.demos[i-1]));
@@ -1801,6 +1928,15 @@ void Host_InitCommands (void)
                Cvar_RegisterVariable (&cl_pmodel);
                Cmd_AddCommand ("pmodel", Host_PModel_f);
        }
+       // FIXME: Do this only for GAME_NEXUIZ?
+       else if (gamemode == GAME_NEXUIZ) 
+       {
+               Cvar_RegisterVariable (&cl_playermodel);
+               Cmd_AddCommand ("playermodel", Host_Playermodel_f);
+               Cvar_RegisterVariable (&cl_playerskin);
+               Cmd_AddCommand ("playerskin", Host_Playerskin_f);
+       }
+
        Cmd_AddCommand ("prespawn", Host_PreSpawn_f);
        Cmd_AddCommand ("spawn", Host_Spawn_f);
        Cmd_AddCommand ("begin", Host_Begin_f);