]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_cmds.c
changed strzone, stuffcmd, and localcmd to be able to take multiple strings
[xonotic/darkplaces.git] / prvm_cmds.c
index 45cfb89dee7b59ccf8e6f5da5e9c3d70650fe010..c0cc2c2a6630cef9848eda058a59efca6fa20e4a 100644 (file)
@@ -152,7 +152,7 @@ void VM_objerror (void)
        }
        else
                // objerror has to display the object fields -> else call
-               PRVM_ERROR ("VM_objecterror: self not defined !\n");
+               PRVM_ERROR ("VM_objecterror: self not defined !");
 }
 
 /*
@@ -466,15 +466,16 @@ VM_localcmd
 
 Sends text over to the client's execution buffer
 
-[localcmd (string) or]
-cmd (string)
+[localcmd (string, ...) or]
+cmd (string, ...)
 =================
 */
 void VM_localcmd (void)
 {
+       char string[VM_STRINGTEMP_LENGTH];
        VM_SAFEPARMCOUNT(1,VM_localcmd);
-
-       Cbuf_AddText(PRVM_G_STRING(OFS_PARM0));
+       VM_VarString(0, string, sizeof(string));
+       Cbuf_AddText(string);
 }
 
 /*
@@ -508,7 +509,7 @@ void VM_cvar_string(void)
        name = PRVM_G_STRING(OFS_PARM0);
 
        if(!name)
-               PRVM_ERROR("VM_cvar_string: %s: null string\n", PRVM_NAME);
+               PRVM_ERROR("VM_cvar_string: %s: null string", PRVM_NAME);
 
        VM_CheckEmptyString(name);
 
@@ -539,7 +540,7 @@ void VM_cvar_defstring (void)
        name = PRVM_G_STRING(OFS_PARM0);
 
        if(!name)
-               PRVM_ERROR("VM_cvar_defstring: %s: null string\n", PRVM_NAME);
+               PRVM_ERROR("VM_cvar_defstring: %s: null string", PRVM_NAME);
 
        VM_CheckEmptyString(name);
 
@@ -708,7 +709,7 @@ void VM_ftoi(void)
 
        ent = PRVM_G_FLOAT(OFS_PARM0);
        if(PRVM_PROG_TO_EDICT(ent)->priv.required->free)
-               PRVM_ERROR ("VM_ftoe: %s tried to access a freed entity (entity %i)!\n", PRVM_NAME, ent);
+               PRVM_ERROR ("VM_ftoe: %s tried to access a freed entity (entity %i)!", PRVM_NAME, ent);
 
        PRVM_G_INT(OFS_RETURN) = ent;
 }
@@ -753,9 +754,9 @@ void VM_remove (void)
                PRVM_ED_Free (ed);
        }
 //     if (ed == prog->edicts)
-//             PRVM_ERROR ("remove: tried to remove world\n");
+//             PRVM_ERROR ("remove: tried to remove world");
 //     if (PRVM_NUM_FOR_EDICT(ed) <= sv.maxclients)
-//             Host_Error("remove: tried to remove a client\n");
+//             Host_Error("remove: tried to remove a client");
 }
 
 /*
@@ -864,7 +865,7 @@ void VM_findchain (void)
 
        // is the same like !(prog->flag & PRVM_FE_CHAIN) - even if the operator precedence is another
        if(!prog->flag & PRVM_FE_CHAIN)
-               PRVM_ERROR("VM_findchain: %s doesnt have a chain field !\n", PRVM_NAME);
+               PRVM_ERROR("VM_findchain: %s doesnt have a chain field !", PRVM_NAME);
 
        chain_of = PRVM_ED_FindField("chain")->ofs;
 
@@ -918,7 +919,7 @@ void VM_findchainfloat (void)
        VM_SAFEPARMCOUNT(2, VM_findchainfloat);
 
        if(!prog->flag & PRVM_FE_CHAIN)
-               PRVM_ERROR("VM_findchainfloat: %s doesnt have a chain field !\n", PRVM_NAME);
+               PRVM_ERROR("VM_findchainfloat: %s doesnt have a chain field !", PRVM_NAME);
 
        chain_of = PRVM_ED_FindField("chain")->ofs;
 
@@ -1000,7 +1001,7 @@ void VM_findchainflags (void)
        VM_SAFEPARMCOUNT(2, VM_findchainflags);
 
        if(!prog->flag & PRVM_FE_CHAIN)
-               PRVM_ERROR("VM_findchainflags: %s doesnt have a chain field !\n", PRVM_NAME);
+               PRVM_ERROR("VM_findchainflags: %s doesnt have a chain field !", PRVM_NAME);
 
        chain_of = PRVM_ED_FindField("chain")->ofs;
 
@@ -1068,7 +1069,7 @@ void VM_crash(void)
 {
        VM_SAFEPARMCOUNT(0, VM_crash);
 
-       PRVM_ERROR("Crash called by %s\n",PRVM_NAME);
+       PRVM_ERROR("Crash called by %s",PRVM_NAME);
 }
 
 /*
@@ -1362,7 +1363,7 @@ void VM_min (void)
                PRVM_G_FLOAT(OFS_RETURN) = f;
        }
        else
-               PRVM_ERROR("VM_min: %s must supply at least 2 floats\n", PRVM_NAME);
+               PRVM_ERROR("VM_min: %s must supply at least 2 floats", PRVM_NAME);
 }
 
 /*
@@ -1389,7 +1390,7 @@ void VM_max (void)
                PRVM_G_FLOAT(OFS_RETURN) = f;
        }
        else
-               PRVM_ERROR("VM_max: %s must supply at least 2 floats\n", PRVM_NAME);
+               PRVM_ERROR("VM_max: %s must supply at least 2 floats", PRVM_NAME);
 }
 
 /*
@@ -1724,7 +1725,7 @@ void VM_strcat(void)
        char *s;
 
        if(prog->argc < 1)
-               PRVM_ERROR("VM_strcat wrong parameter count (min. 1 expected ) !\n");
+               PRVM_ERROR("VM_strcat wrong parameter count (min. 1 expected ) !");
 
        s = VM_GetTempString();
        VM_VarString(0, s, VM_STRINGTEMP_LENGTH);
@@ -1786,17 +1787,17 @@ VM_strzone
 string strzone(string s)
 =========
 */
-//string(string s) strzone = #118; // makes a copy of a string into the string zone and returns it, this is often used to keep around a tempstring for longer periods of time (tempstrings are replaced often)
+//string(string s, ...) strzone = #118; // makes a copy of a string into the string zone and returns it, this is often used to keep around a tempstring for longer periods of time (tempstrings are replaced often)
 void VM_strzone(void)
 {
-       const char *in;
        char *out;
+       char string[VM_STRINGTEMP_LENGTH];
 
        VM_SAFEPARMCOUNT(1,VM_strzone);
 
-       in = PRVM_G_STRING(OFS_PARM0);
-       PRVM_G_INT(OFS_RETURN) = PRVM_AllocString(strlen(in) + 1, &out);
-       strcpy(out, in);
+       VM_VarString(0, string, sizeof(string));
+       PRVM_G_INT(OFS_RETURN) = PRVM_AllocString(strlen(string) + 1, &out);
+       strcpy(out, string);
 }
 
 /*
@@ -1854,7 +1855,7 @@ float tokenize(string s)
 //this function originally written by KrimZon, made shorter by LordHavoc
 //20040203: rewritten by LordHavoc (no longer uses allocations)
 int num_tokens = 0;
-char *tokens[256], tokenbuf[4096];
+char *tokens[256], tokenbuf[MAX_INPUTLINE];
 void VM_tokenize (void)
 {
        size_t pos;
@@ -2070,13 +2071,13 @@ void VM_parseentitydata(void)
     // get edict and test it
        ent = PRVM_G_EDICT(OFS_PARM0);
        if (ent->priv.required->free)
-               PRVM_ERROR ("VM_parseentitydata: %s: Can only set already spawned entities (entity %i is free)!\n", PRVM_NAME, PRVM_NUM_FOR_EDICT(ent));
+               PRVM_ERROR ("VM_parseentitydata: %s: Can only set already spawned entities (entity %i is free)!", PRVM_NAME, PRVM_NUM_FOR_EDICT(ent));
 
        data = PRVM_G_STRING(OFS_PARM1);
 
     // parse the opening brace
        if (!COM_ParseToken(&data, false) || com_token[0] != '{' )
-               PRVM_ERROR ("VM_parseentitydata: %s: Couldn't parse entity data:\n%s\n", PRVM_NAME, data );
+               PRVM_ERROR ("VM_parseentitydata: %s: Couldn't parse entity data:\n%s", PRVM_NAME, data );
 
        PRVM_ED_ParseEdict (data, ent);
 }
@@ -2108,7 +2109,7 @@ void VM_loadfromfile(void)
        }
 
        // not conform with VM_fopen
-       data = (char *)FS_LoadFile(filename, tempmempool, false);
+       data = (char *)FS_LoadFile(filename, tempmempool, false, NULL);
        if (data == NULL)
                PRVM_G_FLOAT(OFS_RETURN) = -1;
 
@@ -2340,7 +2341,7 @@ void VM_precache_pic(void)
        PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
 
        if(!s)
-               PRVM_ERROR ("VM_precache_pic: %s: NULL\n", PRVM_NAME);
+               PRVM_ERROR ("VM_precache_pic: %s: NULL", PRVM_NAME);
 
        VM_CheckEmptyString (s);
 
@@ -2365,7 +2366,7 @@ void VM_freepic(void)
        s = PRVM_G_STRING(OFS_PARM0);
 
        if(!s)
-               PRVM_ERROR ("VM_freepic: %s: NULL\n");
+               PRVM_ERROR ("VM_freepic: %s: NULL");
 
        VM_CheckEmptyString (s);
 
@@ -2607,7 +2608,7 @@ void VM_getimagesize(void)
        p = PRVM_G_STRING(OFS_PARM0);
 
        if(!p)
-               PRVM_ERROR("VM_getimagepos: %s passed null picture name !\n", PRVM_NAME);
+               PRVM_ERROR("VM_getimagepos: %s passed null picture name !", PRVM_NAME);
 
        VM_CheckEmptyString (p);