]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - pr_edict.c
use sys_ticrate timing on dedicated servers
[xonotic/darkplaces.git] / pr_edict.c
index 11acb1418ebd74db361e6083cf50738809277ffa..2a77bac1d4df77add0a2927f635045d3f2c6103d 100644 (file)
@@ -42,7 +42,7 @@ int           type_size[8] = {1,sizeof(string_t)/4,1,3,1,1,sizeof(func_t)/4,sizeof(void *
 ddef_t *ED_FieldAtOfs(int ofs);
 qboolean ED_ParseEpair(edict_t *ent, ddef_t *key, const char *s);
 
-cvar_t pr_checkextension = {0, "pr_checkextension", "1"};
+cvar_t pr_checkextension = {CVAR_READONLY, "pr_checkextension", "1"};
 cvar_t nomonsters = {0, "nomonsters", "0"};
 cvar_t gamecfg = {0, "gamecfg", "0"};
 cvar_t scratch1 = {0, "scratch1", "0"};
@@ -380,7 +380,7 @@ PR_ValueString
 Returns a string describing *data in a type specific manner
 =============
 */
-int NoCrash_NUM_FOR_EDICT(edict_t *e);
+//int NoCrash_NUM_FOR_EDICT(edict_t *e);
 char *PR_ValueString (etype_t type, eval_t *val)
 {
        static char line[1024]; // LordHavoc: enlarged a bit (was 256)
@@ -454,23 +454,11 @@ char *PR_UglyValueString (etype_t type, eval_t *val)
        switch (type)
        {
        case ev_string:
-               snprintf (line, sizeof (line), "%s", PR_GetString(val->string));
-               break;
-       case ev_entity:
-               snprintf (line, sizeof (line), "%i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)));
-               break;
-       case ev_function:
-               f = pr_functions + val->function;
-               snprintf (line, sizeof (line), "%s", PR_GetString(f->s_name));
-               break;
-       case ev_field:
-               def = ED_FieldAtOfs ( val->_int );
-               // LordHavoc: parse the string a bit to turn special characters
+               // Parse the string a bit to turn special characters
                // (like newline, specifically) into escape codes,
                // this fixes saving games from various mods
-               //sprintf (line, "%s", PR_GetString(def->s_name));
-               s = PR_GetString(def->s_name);
-               for (i = 0;i < sizeof (line) - 2 && *s;)
+               s = PR_GetString (val->string);
+               for (i = 0;i < (int)sizeof(line) - 2 && *s;)
                {
                        if (*s == '\n')
                        {
@@ -488,6 +476,17 @@ char *PR_UglyValueString (etype_t type, eval_t *val)
                }
                line[i] = '\0';
                break;
+       case ev_entity:
+               snprintf (line, sizeof (line), "%i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)));
+               break;
+       case ev_function:
+               f = pr_functions + val->function;
+               snprintf (line, sizeof (line), "%s", PR_GetString(f->s_name));
+               break;
+       case ev_field:
+               def = ED_FieldAtOfs ( val->_int );
+               snprintf (line, sizeof (line), ".%s", PR_GetString(def->s_name));
+               break;
        case ev_void:
                snprintf (line, sizeof (line), "void");
                break;
@@ -801,6 +800,34 @@ void ED_WriteGlobals (qfile_t *f)
        FS_Printf (f,"}\n");
 }
 
+/*
+=============
+ED_EdictSet_f
+
+Console command to set a field of a specified edict
+=============
+*/
+void ED_EdictSet_f(void)
+{
+       edict_t *ed;
+       ddef_t *key;
+
+       if(Cmd_Argc() != 4)
+       {
+               Con_Printf("edictset <edict number> <field> <value>\n");
+               return;
+       }
+       ed = EDICT_NUM(atoi(Cmd_Argv(1)));
+
+       if((key = ED_FindField(Cmd_Argv(2))) == 0)
+       {
+               Con_Printf("Key %s not found !\n", Cmd_Argv(2));
+               return;
+       }
+
+       ED_ParseEpair(ed, key, Cmd_Argv(3));
+}
+
 /*
 =============
 ED_ParseGlobals
@@ -1554,6 +1581,7 @@ void PR_Init (void)
        Cmd_AddCommand ("edict", ED_PrintEdict_f);
        Cmd_AddCommand ("edicts", ED_PrintEdicts);
        Cmd_AddCommand ("edictcount", ED_Count);
+       Cmd_AddCommand ("edictset", ED_EdictSet_f);
        Cmd_AddCommand ("profile", PR_Profile_f);
        Cmd_AddCommand ("pr_fields", PR_Fields_f);
        Cmd_AddCommand ("pr_globals", PR_Globals_f);