]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
changed PF_WARNING to not do a return
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 26 Jul 2006 05:16:42 +0000 (05:16 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 26 Jul 2006 05:16:42 +0000 (05:16 +0000)
changed PF_WARNING define to VM_Warning function
changed Con_Printf warnings in QC builtins to VM_Warning calls

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6529 d7cf8633-e32d-0410-b094-e92efae38249

clvm_cmds.c
mvm_cmds.c
progsvm.h
prvm_cmds.c
svvm_cmds.c

index 7c3ae0a75895925b388ed32734fff4ab0597eb84..64e8025d66808b4f55321144910b04df94725bd6 100644 (file)
 //4 feature darkplaces csqc: add builtin to clientside qc for reading triangles of model meshes (useful to orient a ui along a triangle of a model mesh)
 //4 feature darkplaces csqc: add builtins to clientside qc for gl calls
 
-#ifndef PF_WARNING
-#define PF_WARNING(s) do{Con_Printf(s);PRVM_PrintState();return;}while(0)
-#endif
-
 //[515]: really need new list ?
 char *vm_cl_extensions =
 "DP_CON_SET "
@@ -145,9 +141,15 @@ void VM_CL_setorigin (void)
 
        e = PRVM_G_EDICT(OFS_PARM0);
        if (e == prog->edicts)
-               PF_WARNING("setorigin: can not modify world entity\n");
+       {
+               VM_Warning("setorigin: can not modify world entity\n");
+               return;
+       }
        if (e->priv.required->free)
-               PF_WARNING("setorigin: can not modify free entity\n");
+       {
+               VM_Warning("setorigin: can not modify free entity\n");
+               return;
+       }
        org = PRVM_G_VECTOR(OFS_PARM1);
        VectorCopy (org, e->fields.client->origin);
 }
@@ -196,9 +198,15 @@ void VM_CL_setsize (void)
 
        e = PRVM_G_EDICT(OFS_PARM0);
        if (e == prog->edicts)
-               PF_WARNING("setsize: can not modify world entity\n");
+       {
+               VM_Warning("setsize: can not modify world entity\n");
+               return;
+       }
        if (e->priv.server->free)
-               PF_WARNING("setsize: can not modify free entity\n");
+       {
+               VM_Warning("setsize: can not modify free entity\n");
+               return;
+       }
        min = PRVM_G_VECTOR(OFS_PARM1);
        max = PRVM_G_VECTOR(OFS_PARM2);
 
@@ -225,13 +233,22 @@ void VM_CL_sound (void)
        attenuation = PRVM_G_FLOAT(OFS_PARM4);
 
        if (volume < 0 || volume > 255)
-               PF_WARNING("VM_CL_sound: volume must be in range 0-1\n");
+       {
+               VM_Warning("VM_CL_sound: volume must be in range 0-1\n");
+               return;
+       }
 
        if (attenuation < 0 || attenuation > 4)
-               PF_WARNING("VM_CL_sound: attenuation must be in range 0-4\n");
+       {
+               VM_Warning("VM_CL_sound: attenuation must be in range 0-4\n");
+               return;
+       }
 
        if (channel < 0 || channel > 7)
-               PF_WARNING("VM_CL_sound: channel must be in range 0-7\n");
+       {
+               VM_Warning("VM_CL_sound: channel must be in range 0-7\n");
+               return;
+       }
 
        S_StartSound(32768 + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), entity->fields.client->origin, volume, attenuation);
 }
@@ -315,12 +332,15 @@ void VM_CL_precache_model (void)
                        if(!cl.csqc_model_precache[i])
                                break;
                if(i == MAX_MODELS)
-                       PF_WARNING("VM_CL_precache_model: no free models\n");
+               {
+                       VM_Warning("VM_CL_precache_model: no free models\n");
+                       return;
+               }
                cl.csqc_model_precache[i] = (model_t*)m;
                PRVM_G_FLOAT(OFS_RETURN) = -(i+1);
                return;
        }
-       Con_Printf("VM_CL_precache_model: model \"%s\" not found\n", name);
+       VM_Warning("VM_CL_precache_model: model \"%s\" not found\n", name);
 }
 
 int CSQC_EntitiesInBox (vec3_t mins, vec3_t maxs, int maxlist, prvm_edict_t **list)
@@ -411,9 +431,15 @@ void VM_CL_droptofloor (void)
 
        ent = PRVM_PROG_TO_EDICT(prog->globals.client->self);
        if (ent == prog->edicts)
-               PF_WARNING("droptofloor: can not modify world entity\n");
+       {
+               VM_Warning("droptofloor: can not modify world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("droptofloor: can not modify free entity\n");
+       {
+               VM_Warning("droptofloor: can not modify free entity\n");
+               return;
+       }
 
        VectorCopy (ent->fields.client->origin, end);
        end[2] -= 256;
@@ -442,7 +468,10 @@ void VM_CL_lightstyle (void)
        i = (int)PRVM_G_FLOAT(OFS_PARM0);
        c = PRVM_G_STRING(OFS_PARM1);
        if (i >= cl.max_lightstyle)
-               PF_WARNING("VM_CL_lightstyle >= MAX_LIGHTSTYLES\n");
+       {
+               VM_Warning("VM_CL_lightstyle >= MAX_LIGHTSTYLES\n");
+               return;
+       }
        strlcpy (cl.lightstyle[i].map,  MSG_ReadString(), sizeof (cl.lightstyle[i].map));
        cl.lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
        cl.lightstyle[i].length = (int)strlen(cl.lightstyle[i].map);
@@ -550,9 +579,15 @@ void VM_CL_changeyaw (void)
 
        ent = PRVM_G_EDICT(OFS_PARM0);
        if (ent == prog->edicts)
-               PF_WARNING("changeyaw: can not modify world entity\n");
+       {
+               VM_Warning("changeyaw: can not modify world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("changeyaw: can not modify free entity\n");
+       {
+               VM_Warning("changeyaw: can not modify free entity\n");
+               return;
+       }
        current = ANGLEMOD(ent->fields.client->angles[1]);
        ideal = PRVM_G_FLOAT(OFS_PARM1);
        speed = PRVM_G_FLOAT(OFS_PARM2);
@@ -593,9 +628,15 @@ void VM_CL_changepitch (void)
 
        ent = PRVM_G_EDICT(OFS_PARM0);
        if (ent == prog->edicts)
-               PF_WARNING("changepitch: can not modify world entity\n");
+       {
+               VM_Warning("changepitch: can not modify world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("changepitch: can not modify free entity\n");
+       {
+               VM_Warning("changepitch: can not modify free entity\n");
+               return;
+       }
        current = ANGLEMOD( ent->fields.client->angles[0] );
        ideal = PRVM_G_FLOAT(OFS_PARM1);
        speed = PRVM_G_FLOAT(OFS_PARM2);
@@ -636,7 +677,10 @@ void VM_CL_tracetoss (void)
 
        ent = PRVM_G_EDICT(OFS_PARM0);
        if (ent == prog->edicts)
-               PF_WARNING("tracetoss: can not use world entity\n");
+       {
+               VM_Warning("tracetoss: can not use world entity\n");
+               return;
+       }
        ignore = PRVM_G_EDICT(OFS_PARM1);
 
 //FIXME
@@ -845,8 +889,8 @@ void VM_R_SetView (void)
        case VF_CL_VIEWANGLES_Z:cl.viewangles[2] = k;
                                                        break;
 
-       default:                                Con_Printf("VM_R_SetView : unknown parm %i\n", c);
-                                                       PRVM_G_FLOAT(OFS_RETURN) = 0;
+       default:                                PRVM_G_FLOAT(OFS_RETURN) = 0;
+                                                       VM_Warning("VM_R_SetView : unknown parm %i\n", c);
                                                        return;
        }
        PRVM_G_FLOAT(OFS_RETURN) = 1;
@@ -921,7 +965,7 @@ void VM_CL_getstatf (void)
        i = (int)PRVM_G_FLOAT(OFS_PARM0);
        if(i < 0 || i >= MAX_CL_STATS)
        {
-               Con_Printf("VM_CL_getstatf: index>=MAX_CL_STATS or index<0\n");
+               VM_Warning("VM_CL_getstatf: index>=MAX_CL_STATS or index<0\n");
                return;
        }
        dat.l = cl.stats[i];
@@ -937,7 +981,7 @@ void VM_CL_getstati (void)
 
        if(index < 0 || index >= MAX_CL_STATS)
        {
-               Con_Printf("VM_CL_getstati: index>=MAX_CL_STATS or index<0\n");
+               VM_Warning("VM_CL_getstati: index>=MAX_CL_STATS or index<0\n");
                return;
        }
        i = cl.stats[index];
@@ -953,7 +997,7 @@ void VM_CL_getstats (void)
        i = (int)PRVM_G_FLOAT(OFS_PARM0);
        if(i < 0 || i > MAX_CL_STATS-4)
        {
-               Con_Printf("VM_CL_getstats: index>MAX_CL_STATS-4 or index<0\n");
+               VM_Warning("VM_CL_getstats: index>MAX_CL_STATS-4 or index<0\n");
                return;
        }
        t = VM_GetTempString();
@@ -982,16 +1026,25 @@ void VM_CL_setmodelindex (void)
        {
                i = -(i+1);
                if(i >= MAX_MODELS)
-                       PF_WARNING("VM_CL_setmodelindex >= MAX_MODELS\n");
+               {
+                       VM_Warning("VM_CL_setmodelindex >= MAX_MODELS\n");
+                       return;
+               }
                m = cl.csqc_model_precache[i];
        }
        else
                if(i >= MAX_MODELS)
-                       PF_WARNING("VM_CL_setmodelindex >= MAX_MODELS\n");
+               {
+                       VM_Warning("VM_CL_setmodelindex >= MAX_MODELS\n");
+                       return;
+               }
                else
                        m = cl.model_precache[i];
        if(!m)
-               PF_WARNING("VM_CL_setmodelindex: null model\n");
+       {
+               VM_Warning("VM_CL_setmodelindex: null model\n");
+               return;
+       }
        t->fields.client->model = PRVM_SetEngineString(m->name);
        t->fields.client->modelindex = i;
 }
@@ -1009,13 +1062,19 @@ void VM_CL_modelnameforindex (void)
        {
                i = -(i+1);
                if(i >= MAX_MODELS)
-                       PF_WARNING("VM_CL_modelnameforindex >= MAX_MODELS\n");
+               {
+                       VM_Warning("VM_CL_modelnameforindex >= MAX_MODELS\n");
+                       return;
+               }
                if(cl.csqc_model_precache[i])
                        PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(cl.csqc_model_precache[i]->name);
                return;
        }
        if(i >= MAX_MODELS)
-               PF_WARNING("VM_CL_modelnameforindex >= MAX_MODELS\n");
+       {
+               VM_Warning("VM_CL_modelnameforindex >= MAX_MODELS\n");
+               return;
+       }
        if(cl.model_precache[i])
                PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(cl.model_precache[i]->name);
 }
@@ -1049,7 +1108,7 @@ void VM_CL_trailparticles (void)
 
        if (entnum >= MAX_EDICTS)
        {
-               Con_Printf("CSQC_ParseBeam: invalid entity number %i\n", entnum);
+               VM_Warning("CSQC_ParseBeam: invalid entity number %i\n", entnum);
                return;
        }
        if (entnum >= cl.max_csqcentities)
@@ -1831,9 +1890,15 @@ void VM_CL_setattachment (void)
        model_t *model;
 
        if (e == prog->edicts)
-               PF_WARNING("setattachment: can not modify world entity\n");
+       {
+               VM_Warning("setattachment: can not modify world entity\n");
+               return;
+       }
        if (e->priv.server->free)
-               PF_WARNING("setattachment: can not modify free entity\n");
+       {
+               VM_Warning("setattachment: can not modify free entity\n");
+               return;
+       }
 
        if (tagentity == NULL)
                tagentity = prog->edicts;
@@ -2069,9 +2134,15 @@ void VM_CL_gettagindex (void)
        int modelindex, tag_index;
 
        if (ent == prog->edicts)
-               PF_WARNING("gettagindex: can't affect world entity\n");
+       {
+               VM_Warning("gettagindex: can't affect world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("gettagindex: can't affect free entity\n");
+       {
+               VM_Warning("gettagindex: can't affect free entity\n");
+               return;
+       }
 
        modelindex = (int)ent->fields.client->modelindex;
        if(modelindex < 0)
@@ -2102,10 +2173,10 @@ void VM_CL_gettaginfo (void)
        switch(returncode)
        {
                case 1:
-                       PF_WARNING("gettagindex: can't affect world entity\n");
+                       VM_Warning("gettagindex: can't affect world entity\n");
                        break;
                case 2:
-                       PF_WARNING("gettagindex: can't affect free entity\n");
+                       VM_Warning("gettagindex: can't affect free entity\n");
                        break;
                case 3:
                        Con_DPrintf("CL_GetTagMatrix(entity #%i): null or non-precached model\n", PRVM_NUM_FOR_EDICT(e));
@@ -2275,7 +2346,7 @@ void VM_CL_selecttraceline (void)
 
        if((csqcents && ignore > cl.num_csqcentities) || (!csqcents && ignore > cl.num_entities))
        {
-               Con_Printf("VM_CL_selecttraceline: out of entities\n");
+               VM_Warning("VM_CL_selecttraceline: out of entities\n");
                return;
        }
        else
index 0cd14d7e871a24af5a82e3aa55e9d960ded7ffdd..657568e191dc2a95bbef91d2d6dc24366d3efb8c 100644 (file)
@@ -51,7 +51,10 @@ void VM_M_precache_sound (void)
        VM_CheckEmptyString (s);
 
        if(snd_initialized.integer && !S_PrecacheSound (s,true, true))
-               Con_Printf("VM_precache_sound: Failed to load %s for %s\n", s, PRVM_NAME);
+       {
+               VM_Warning("VM_precache_sound: Failed to load %s for %s\n", s, PRVM_NAME);
+               return;
+       }
 }
 
 /*
@@ -247,14 +250,16 @@ void VM_M_writetofile(void)
        VM_SAFEPARMCOUNT(2, VM_M_writetofile);
 
        file = VM_GetFileHandle( (int)PRVM_G_FLOAT(OFS_PARM0) );
-       if( !file ) {
+       if( !file )
+       {
+               VM_Warning("VM_M_writetofile: invalid or closed file handle\n");
                return;
        }
 
        ent = PRVM_G_EDICT(OFS_PARM1);
        if(ent->priv.required->free)
        {
-               Con_Printf("VM_M_writetofile: %s: entity %i is free !\n", PRVM_NAME, PRVM_EDICT_NUM(OFS_PARM1));
+               VM_Warning("VM_M_writetofile: %s: entity %i is free !\n", PRVM_NAME, PRVM_EDICT_NUM(OFS_PARM1));
                return;
        }
 
@@ -369,7 +374,7 @@ void VM_M_getserverliststat( void )
                PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_sortdescending;
                return;
        default:
-               Con_Printf( "VM_M_getserverliststat: bad type %i!\n", type );
+               VM_Warning( "VM_M_getserverliststat: bad type %i!\n", type );
        }
 }
 
@@ -412,8 +417,9 @@ void VM_M_setserverlistmaskstring( void )
                mask = &serverlist_andmasks[masknr];
        else if( masknr >= 512 && masknr - 512 <= SERVERLIST_ORMASKCOUNT )
                mask = &serverlist_ormasks[masknr - 512 ];
-       else {
-               Con_Printf( "VM_M_setserverlistmaskstring: invalid mask number %i\n", masknr );
+       else
+       {
+               VM_Warning( "VM_M_setserverlistmaskstring: invalid mask number %i\n", masknr );
                return;
        }
 
@@ -436,7 +442,7 @@ void VM_M_setserverlistmaskstring( void )
                        strncpy( mask->info.game, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.game)  );
                        break;
                default:
-                       Con_Printf( "VM_M_setserverlistmaskstring: Bad field number %i passed!\n", field );
+                       VM_Warning( "VM_M_setserverlistmaskstring: Bad field number %i passed!\n", field );
                        return;
        }
 
@@ -467,8 +473,9 @@ void VM_M_setserverlistmasknumber( void )
                mask = &serverlist_andmasks[masknr];
        else if( masknr >= 512 && masknr - 512 <= SERVERLIST_ORMASKCOUNT )
                mask = &serverlist_ormasks[masknr - 512 ];
-       else {
-               Con_Printf( "VM_M_setserverlistmasknumber: invalid mask number %i\n", masknr );
+       else
+       {
+               VM_Warning( "VM_M_setserverlistmasknumber: invalid mask number %i\n", masknr );
                return;
        }
 
@@ -489,7 +496,7 @@ void VM_M_setserverlistmasknumber( void )
                        mask->info.protocol = number;
                        break;
                default:
-                       Con_Printf( "VM_M_setserverlistmasknumber: Bad field number %i passed!\n", field );
+                       VM_Warning( "VM_M_setserverlistmasknumber: Bad field number %i passed!\n", field );
                        return;
        }
 
index 77cf410949b26c829e91aa2eb1c44fe262979f53..94b0387e8419557fbb3bceef137632d351ea2e1a 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -547,6 +547,7 @@ qboolean PRVM_ProgLoaded(int prognr);
 
 int    PRVM_GetProgNr(void);
 
+void VM_Warning(const char *fmt, ...);
 
 // TODO: fill in the params
 //void PRVM_Create();
index c8c178498a758cb31a1f26b001808cc559369eb1..fcc6a5cc9b589db32f55620c8b5e9e468ad0be6d 100644 (file)
@@ -6,6 +6,21 @@
 
 #include "prvm_cmds.h"
 
+// LordHavoc: changed this to NOT use a return statement, so that it can be used in functions that must return a value
+void VM_Warning(const char *fmt, ...)
+{
+       va_list argptr;
+       char msg[MAX_INPUTLINE];
+
+       va_start(argptr,fmt);
+       dpvsnprintf(msg,sizeof(msg),fmt,argptr);
+       va_end(argptr);
+
+       Con_Print(msg);
+       PRVM_PrintState();
+}
+
+
 //============================================================================
 // Common
 
@@ -123,7 +138,7 @@ void VM_error (void)
                PRVM_ED_Print(ed);
        }
 
-       PRVM_ERROR ("%s: Program error in function %s:\n%s\n", PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), string);
+       PRVM_ERROR ("%s: Program error in function %s:\n%s\nTip: read above for entity information\n", PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), string);
 }
 
 /*
@@ -153,7 +168,7 @@ void VM_objerror (void)
        else
                // objerror has to display the object fields -> else call
                PRVM_ERROR ("VM_objecterror: self not defined !");
-       Con_Printf("%s OBJECT ERROR in %s:\n%s\n", PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), string);
+       Con_Printf("%s OBJECT ERROR in %s:\n%s\nTip: read above for entity information\n", PRVM_NAME, PRVM_GetString(prog->xfunction->s_name), string);
 }
 
 /*
@@ -188,7 +203,7 @@ void VM_bprint (void)
 
        if(!sv.active)
        {
-               Con_Printf("VM_bprint: game is not server(%s) !\n", PRVM_NAME);
+               VM_Warning("VM_bprint: game is not server(%s) !\n", PRVM_NAME);
                return;
        }
 
@@ -215,7 +230,7 @@ void VM_sprint (void)
        clientnum = (int)PRVM_G_FLOAT(OFS_PARM0);
        if (!sv.active  || clientnum < 0 || clientnum >= svs.maxclients || !svs.clients[clientnum].active)
        {
-               Con_Printf("VM_sprint: %s: invalid client or server is not active !\n", PRVM_NAME);
+               VM_Warning("VM_sprint: %s: invalid client or server is not active !\n", PRVM_NAME);
                return;
        }
 
@@ -442,8 +457,8 @@ void VM_localsound(void)
 
        if(!S_LocalSound (s))
        {
-               Con_Printf("VM_localsound: Failed to play %s for %s !\n", s, PRVM_NAME);
                PRVM_G_FLOAT(OFS_RETURN) = -4;
+               VM_Warning("VM_localsound: Failed to play %s for %s !\n", s, PRVM_NAME);
                return;
        }
 
@@ -1226,7 +1241,7 @@ void VM_changelevel (void)
 
        if(!sv.active)
        {
-               Con_Printf("VM_changelevel: game is not server (%s)\n", PRVM_NAME);
+               VM_Warning("VM_changelevel: game is not server (%s)\n", PRVM_NAME);
                return;
        }
 
@@ -1344,7 +1359,7 @@ void VM_registercvar (void)
 // check for overlap with a command
        if (Cmd_Exists (name))
        {
-               Con_Printf("VM_registercvar: %s is a command\n", name);
+               VM_Warning("VM_registercvar: %s is a command\n", name);
                return;
        }
 
@@ -1545,8 +1560,8 @@ void VM_fopen(void)
                        break;
        if (filenum >= MAX_VMFILES)
        {
-               Con_Printf("VM_fopen: %s ran out of file handles (%i)\n", PRVM_NAME, MAX_VMFILES);
                PRVM_G_FLOAT(OFS_RETURN) = -2;
+               VM_Warning("VM_fopen: %s ran out of file handles (%i)\n", PRVM_NAME, MAX_VMFILES);
                return;
        }
        mode = (int)PRVM_G_FLOAT(OFS_PARM1);
@@ -1562,8 +1577,8 @@ void VM_fopen(void)
                modestring = "wb";
                break;
        default:
-               Con_Printf("VM_fopen: %s: no such mode %i (valid: 0 = read, 1 = append, 2 = write)\n", PRVM_NAME, mode);
                PRVM_G_FLOAT(OFS_RETURN) = -3;
+               VM_Warning("VM_fopen: %s: no such mode %i (valid: 0 = read, 1 = append, 2 = write)\n", PRVM_NAME, mode);
                return;
        }
        filename = PRVM_G_STRING(OFS_PARM0);
@@ -1574,15 +1589,15 @@ void VM_fopen(void)
 
        if (VM_FILES[filenum] == NULL)
        {
-               if (developer.integer >= 10)
-                       Con_Printf("VM_fopen: %s: %s mode %s failed\n", PRVM_NAME, filename, modestring);
                PRVM_G_FLOAT(OFS_RETURN) = -1;
+               if (developer.integer >= 10)
+                       VM_Warning("VM_fopen: %s: %s mode %s failed\n", PRVM_NAME, filename, modestring);
        }
        else
        {
-               if (developer.integer >= 10)
-                       Con_Printf("VM_fopen: %s: %s mode %s opened as #%i\n", PRVM_NAME, filename, modestring, filenum);
                PRVM_G_FLOAT(OFS_RETURN) = filenum;
+               if (developer.integer >= 10)
+                       VM_Warning("VM_fopen: %s: %s mode %s opened as #%i\n", PRVM_NAME, filename, modestring, filenum);
        }
 }
 
@@ -1603,18 +1618,18 @@ void VM_fclose(void)
        filenum = (int)PRVM_G_FLOAT(OFS_PARM0);
        if (filenum < 0 || filenum >= MAX_VMFILES)
        {
-               Con_Printf("VM_fclose: invalid file handle %i used in %s\n", filenum, PRVM_NAME);
+               VM_Warning("VM_fclose: invalid file handle %i used in %s\n", filenum, PRVM_NAME);
                return;
        }
        if (VM_FILES[filenum] == NULL)
        {
-               Con_Printf("VM_fclose: no such file handle %i (or file has been closed) in %s\n", filenum, PRVM_NAME);
+               VM_Warning("VM_fclose: no such file handle %i (or file has been closed) in %s\n", filenum, PRVM_NAME);
                return;
        }
-       if (developer.integer >= 10)
-               Con_Printf("VM_fclose: %s: #%i closed\n", PRVM_NAME, filenum);
        FS_Close(VM_FILES[filenum]);
        VM_FILES[filenum] = NULL;
+       if (developer.integer >= 10)
+               VM_Warning("VM_fclose: %s: #%i closed\n", PRVM_NAME, filenum);
 }
 
 /*
@@ -1636,12 +1651,12 @@ void VM_fgets(void)
        filenum = (int)PRVM_G_FLOAT(OFS_PARM0);
        if (filenum < 0 || filenum >= MAX_VMFILES)
        {
-               Con_Printf("VM_fgets: invalid file handle %i used in %s\n", filenum, PRVM_NAME);
+               VM_Warning("VM_fgets: invalid file handle %i used in %s\n", filenum, PRVM_NAME);
                return;
        }
        if (VM_FILES[filenum] == NULL)
        {
-               Con_Printf("VM_fgets: no such file handle %i (or file has been closed) in %s\n", filenum, PRVM_NAME);
+               VM_Warning("VM_fgets: no such file handle %i (or file has been closed) in %s\n", filenum, PRVM_NAME);
                return;
        }
        end = 0;
@@ -1688,12 +1703,12 @@ void VM_fputs(void)
        filenum = (int)PRVM_G_FLOAT(OFS_PARM0);
        if (filenum < 0 || filenum >= MAX_VMFILES)
        {
-               Con_Printf("VM_fputs: invalid file handle %i used in %s\n", filenum, PRVM_NAME);
+               VM_Warning("VM_fputs: invalid file handle %i used in %s\n", filenum, PRVM_NAME);
                return;
        }
        if (VM_FILES[filenum] == NULL)
        {
-               Con_Printf("VM_fputs: no such file handle %i (or file has been closed) in %s\n", filenum, PRVM_NAME);
+               VM_Warning("VM_fputs: no such file handle %i (or file has been closed) in %s\n", filenum, PRVM_NAME);
                return;
        }
        VM_VarString(1, string, sizeof(string));
@@ -1847,7 +1862,7 @@ void VM_clcommand (void)
        i = (int)PRVM_G_FLOAT(OFS_PARM0);
        if (!sv.active  || i < 0 || i >= svs.maxclients || !svs.clients[i].active)
        {
-               Con_Printf("VM_clientcommand: %s: invalid client/server is not active !\n", PRVM_NAME);
+               VM_Warning("VM_clientcommand: %s: invalid client/server is not active !\n", PRVM_NAME);
                return;
        }
 
@@ -2117,8 +2132,8 @@ void VM_loadfromfile(void)
        // \ is a windows-ism (so it's naughty to use it, / works on all platforms)
        if ((filename[0] == '.' && filename[1] == '.') || filename[0] == '/' || strrchr(filename, ':') || strrchr(filename, '\\'))
        {
-               Con_Printf("VM_loadfromfile: %s dangerous or non-portable filename \"%s\" not allowed. (contains : or \\ or begins with .. or /)\n", PRVM_NAME, filename);
                PRVM_G_FLOAT(OFS_RETURN) = -4;
+               VM_Warning("VM_loadfromfile: %s dangerous or non-portable filename \"%s\" not allowed. (contains : or \\ or begins with .. or /)\n", PRVM_NAME, filename);
                return;
        }
 
@@ -2195,8 +2210,8 @@ void VM_search_begin(void)
 
        if(handle >= MAX_VMSEARCHES)
        {
-               Con_Printf("VM_search_begin: %s ran out of search handles (%i)\n", PRVM_NAME, MAX_VMSEARCHES);
                PRVM_G_FLOAT(OFS_RETURN) = -2;
+               VM_Warning("VM_search_begin: %s ran out of search handles (%i)\n", PRVM_NAME, MAX_VMSEARCHES);
                return;
        }
 
@@ -2222,12 +2237,12 @@ void VM_search_end(void)
 
        if(handle < 0 || handle >= MAX_VMSEARCHES)
        {
-               Con_Printf("VM_search_end: invalid handle %i used in %s\n", handle, PRVM_NAME);
+               VM_Warning("VM_search_end: invalid handle %i used in %s\n", handle, PRVM_NAME);
                return;
        }
        if(VM_SEARCHLIST[handle] == NULL)
        {
-               Con_Printf("VM_search_end: no such handle %i in %s\n", handle, PRVM_NAME);
+               VM_Warning("VM_search_end: no such handle %i in %s\n", handle, PRVM_NAME);
                return;
        }
 
@@ -2251,12 +2266,12 @@ void VM_search_getsize(void)
 
        if(handle < 0 || handle >= MAX_VMSEARCHES)
        {
-               Con_Printf("VM_search_getsize: invalid handle %i used in %s\n", handle, PRVM_NAME);
+               VM_Warning("VM_search_getsize: invalid handle %i used in %s\n", handle, PRVM_NAME);
                return;
        }
        if(VM_SEARCHLIST[handle] == NULL)
        {
-               Con_Printf("VM_search_getsize: no such handle %i in %s\n", handle, PRVM_NAME);
+               VM_Warning("VM_search_getsize: no such handle %i in %s\n", handle, PRVM_NAME);
                return;
        }
 
@@ -2281,17 +2296,17 @@ void VM_search_getfilename(void)
 
        if(handle < 0 || handle >= MAX_VMSEARCHES)
        {
-               Con_Printf("VM_search_getfilename: invalid handle %i used in %s\n", handle, PRVM_NAME);
+               VM_Warning("VM_search_getfilename: invalid handle %i used in %s\n", handle, PRVM_NAME);
                return;
        }
        if(VM_SEARCHLIST[handle] == NULL)
        {
-               Con_Printf("VM_search_getfilename: no such handle %i in %s\n", handle, PRVM_NAME);
+               VM_Warning("VM_search_getfilename: no such handle %i in %s\n", handle, PRVM_NAME);
                return;
        }
        if(filenum < 0 || filenum >= VM_SEARCHLIST[handle]->numfilenames)
        {
-               Con_Printf("VM_search_getfilename: invalid filenum %i in %s\n", filenum, PRVM_NAME);
+               VM_Warning("VM_search_getfilename: invalid filenum %i in %s\n", filenum, PRVM_NAME);
                return;
        }
 
@@ -2404,8 +2419,8 @@ void VM_drawcharacter(void)
        character = (char) PRVM_G_FLOAT(OFS_PARM1);
        if(character == 0)
        {
-               Con_Printf("VM_drawcharacter: %s passed null character !\n",PRVM_NAME);
                PRVM_G_FLOAT(OFS_RETURN) = -1;
+               VM_Warning("VM_drawcharacter: %s passed null character !\n",PRVM_NAME);
                return;
        }
 
@@ -2416,8 +2431,8 @@ void VM_drawcharacter(void)
 
        if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
        {
-               Con_Printf("VM_drawcharacter: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
                PRVM_G_FLOAT(OFS_RETURN) = -2;
+               VM_Warning("VM_drawcharacter: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
                return;
        }
 
@@ -2426,8 +2441,8 @@ void VM_drawcharacter(void)
 
        if(!scale[0] || !scale[1])
        {
-               Con_Printf("VM_drawcharacter: scale %s is null !\n", (scale[0] == 0) ? ((scale[1] == 0) ? "x and y" : "x") : "y");
                PRVM_G_FLOAT(OFS_RETURN) = -3;
+               VM_Warning("VM_drawcharacter: scale %s is null !\n", (scale[0] == 0) ? ((scale[1] == 0) ? "x and y" : "x") : "y");
                return;
        }
 
@@ -2452,8 +2467,8 @@ void VM_drawstring(void)
        string = PRVM_G_STRING(OFS_PARM1);
        if(!string)
        {
-               Con_Printf("VM_drawstring: %s passed null string !\n",PRVM_NAME);
                PRVM_G_FLOAT(OFS_RETURN) = -1;
+               VM_Warning("VM_drawstring: %s passed null string !\n",PRVM_NAME);
                return;
        }
 
@@ -2466,15 +2481,15 @@ void VM_drawstring(void)
 
        if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
        {
-               Con_Printf("VM_drawstring: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
                PRVM_G_FLOAT(OFS_RETURN) = -2;
+               VM_Warning("VM_drawstring: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
                return;
        }
 
        if(!scale[0] || !scale[1])
        {
-               Con_Printf("VM_drawstring: scale %s is null !\n", (scale[0] == 0) ? ((scale[1] == 0) ? "x and y" : "x") : "y");
                PRVM_G_FLOAT(OFS_RETURN) = -3;
+               VM_Warning("VM_drawstring: scale %s is null !\n", (scale[0] == 0) ? ((scale[1] == 0) ? "x and y" : "x") : "y");
                return;
        }
 
@@ -2503,8 +2518,8 @@ void VM_drawpic(void)
 
        if(!picname)
        {
-               Con_Printf("VM_drawpic: %s passed null picture name !\n", PRVM_NAME);
                PRVM_G_FLOAT(OFS_RETURN) = -1;
+               VM_Warning("VM_drawpic: %s passed null picture name !\n", PRVM_NAME);
                return;
        }
 
@@ -2513,8 +2528,8 @@ void VM_drawpic(void)
        // is pic cached ? no function yet for that
        if(!1)
        {
-               Con_Printf("VM_drawpic: %s: %s not cached !\n", PRVM_NAME, picname);
                PRVM_G_FLOAT(OFS_RETURN) = -4;
+               VM_Warning("VM_drawpic: %s: %s not cached !\n", PRVM_NAME, picname);
                return;
        }
 
@@ -2525,8 +2540,8 @@ void VM_drawpic(void)
 
        if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
        {
-               Con_Printf("VM_drawstring: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
                PRVM_G_FLOAT(OFS_RETURN) = -2;
+               VM_Warning("VM_drawstring: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
                return;
        }
 
@@ -2559,8 +2574,8 @@ void VM_drawfill(void)
 
        if(flag < DRAWFLAG_NORMAL || flag >=DRAWFLAG_NUMFLAGS)
        {
-               Con_Printf("VM_drawstring: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
                PRVM_G_FLOAT(OFS_RETURN) = -2;
+               VM_Warning("VM_drawstring: %s: wrong DRAWFLAG %i !\n",PRVM_NAME,flag);
                return;
        }
 
@@ -2977,7 +2992,7 @@ void VM_R_PolygonBegin (void)
                VM_InitPolygons();
        if(vm_polygonbegin)
        {
-               Con_Printf("VM_R_PolygonBegin: called twice without VM_R_PolygonEnd after first\n");
+               VM_Warning("VM_R_PolygonBegin: called twice without VM_R_PolygonEnd after first\n");
                return;
        }
        if(vm_drawpolygons_num >= vm_polygons_num)
@@ -3019,7 +3034,7 @@ void VM_R_PolygonVertex (void)
 
        if(!vm_polygonbegin)
        {
-               Con_Printf("VM_R_PolygonVertex: VM_R_PolygonBegin wasn't called\n");
+               VM_Warning("VM_R_PolygonVertex: VM_R_PolygonBegin wasn't called\n");
                return;
        }
        coords  = PRVM_G_VECTOR(OFS_PARM0);
@@ -3030,7 +3045,7 @@ void VM_R_PolygonVertex (void)
        p = &vm_polygons[vm_drawpolygons_num];
        if(vm_current_vertices > 4)
        {
-               Con_Printf("VM_R_PolygonVertex: may have 4 vertices max\n");
+               VM_Warning("VM_R_PolygonVertex: may have 4 vertices max\n");
                return;
        }
 
@@ -3061,9 +3076,10 @@ void VM_R_PolygonEnd (void)
 {
        if(!vm_polygonbegin)
        {
-               Con_Printf("VM_R_PolygonEnd: VM_R_PolygonBegin wasn't called\n");
+               VM_Warning("VM_R_PolygonEnd: VM_R_PolygonBegin wasn't called\n");
                return;
        }
+       vm_polygonbegin = false;
        if(vm_current_vertices > 2 || (vm_current_vertices >= 2 && vm_polygons[vm_drawpolygons_num].flags & VM_POLYGON_FLLINES))
        {
                if(vm_polygons[vm_drawpolygons_num].flags & VM_POLYGON_FL2D)    //[515]: don't use qcpolygons memory if 2D
@@ -3072,8 +3088,7 @@ void VM_R_PolygonEnd (void)
                        vm_drawpolygons_num++;
        }
        else
-               Con_Printf("VM_R_PolygonEnd: %i vertices isn't a good choice\n", vm_current_vertices);
-       vm_polygonbegin = false;
+               VM_Warning("VM_R_PolygonEnd: %i vertices isn't a good choice\n", vm_current_vertices);
 }
 
 void VM_AddPolygonsToMeshQueue (void)
@@ -3446,7 +3461,7 @@ void VM_buf_del (void)
                BufStr_ClearBuffer((int)PRVM_G_FLOAT(OFS_PARM0));
        else
        {
-               Con_Printf("VM_buf_del: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
+               VM_Warning("VM_buf_del: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
                return;
        }
 }
@@ -3467,7 +3482,7 @@ void VM_buf_getsize (void)
        if(!b)
        {
                PRVM_G_FLOAT(OFS_RETURN) = -1;
-               Con_Printf("VM_buf_getsize: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
+               VM_Warning("VM_buf_getsize: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
                return;
        }
        else
@@ -3490,19 +3505,19 @@ void VM_buf_copy (void)
        b1 = BUFSTR_BUFFER((int)PRVM_G_FLOAT(OFS_PARM0));
        if(!b1)
        {
-               Con_Printf("VM_buf_copy: invalid source buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
+               VM_Warning("VM_buf_copy: invalid source buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
                return;
        }
        i = (int)PRVM_G_FLOAT(OFS_PARM1);
        if(i == (int)PRVM_G_FLOAT(OFS_PARM0))
        {
-               Con_Printf("VM_buf_copy: source == destination (%i) in %s\n", i, PRVM_NAME);
+               VM_Warning("VM_buf_copy: source == destination (%i) in %s\n", i, PRVM_NAME);
                return;
        }
        b2 = BUFSTR_BUFFER(i);
        if(!b2)
        {
-               Con_Printf("VM_buf_copy: invalid destination buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM1), PRVM_NAME);
+               VM_Warning("VM_buf_copy: invalid destination buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM1), PRVM_NAME);
                return;
        }
 
@@ -3517,7 +3532,7 @@ void VM_buf_copy (void)
                        b2->strings[i] = (char *)Z_Malloc(strlen(b1->strings[i])+1);
                        if(!b2->strings[i])
                        {
-                               Con_Printf("VM_buf_copy: not enough memory for buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM1), PRVM_NAME);
+                               VM_Warning("VM_buf_copy: not enough memory for buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM1), PRVM_NAME);
                                break;
                        }
                        strcpy(b2->strings[i], b1->strings[i]);
@@ -3541,12 +3556,12 @@ void VM_buf_sort (void)
        b = BUFSTR_BUFFER((int)PRVM_G_FLOAT(OFS_PARM0));
        if(!b)
        {
-               Con_Printf("VM_buf_sort: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
+               VM_Warning("VM_buf_sort: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
                return;
        }
        if(b->num_strings <= 0)
        {
-               Con_Printf("VM_buf_sort: tried to sort empty buffer %i in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
+               VM_Warning("VM_buf_sort: tried to sort empty buffer %i in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
                return;
        }
        buf_sortpower = (int)PRVM_G_FLOAT(OFS_PARM1);
@@ -3594,7 +3609,7 @@ void VM_buf_implode (void)
        PRVM_G_INT(OFS_RETURN) = 0;
        if(!b)
        {
-               Con_Printf("VM_buf_implode: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
+               VM_Warning("VM_buf_implode: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
                return;
        }
        if(!b->num_strings)
@@ -3640,13 +3655,13 @@ void VM_bufstr_get (void)
        b = BUFSTR_BUFFER((int)PRVM_G_FLOAT(OFS_PARM0));
        if(!b)
        {
-               Con_Printf("VM_bufstr_get: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
+               VM_Warning("VM_bufstr_get: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
                return;
        }
        strindex = (int)PRVM_G_FLOAT(OFS_PARM1);
        if(strindex < 0 || strindex > MAX_QCSTR_STRINGS)
        {
-               Con_Printf("VM_bufstr_get: invalid string index %i used in %s\n", strindex, PRVM_NAME);
+               VM_Warning("VM_bufstr_get: invalid string index %i used in %s\n", strindex, PRVM_NAME);
                return;
        }
        PRVM_G_INT(OFS_RETURN) = 0;
@@ -3675,19 +3690,19 @@ void VM_bufstr_set (void)
        b = BUFSTR_BUFFER(bufindex);
        if(!b)
        {
-               Con_Printf("VM_bufstr_set: invalid buffer %i used in %s\n", bufindex, PRVM_NAME);
+               VM_Warning("VM_bufstr_set: invalid buffer %i used in %s\n", bufindex, PRVM_NAME);
                return;
        }
        strindex = (int)PRVM_G_FLOAT(OFS_PARM1);
        if(strindex < 0 || strindex > MAX_QCSTR_STRINGS)
        {
-               Con_Printf("VM_bufstr_set: invalid string index %i used in %s\n", strindex, PRVM_NAME);
+               VM_Warning("VM_bufstr_set: invalid string index %i used in %s\n", strindex, PRVM_NAME);
                return;
        }
        news = PRVM_G_STRING(OFS_PARM2);
        if(!news)
        {
-               Con_Printf("VM_bufstr_set: null string used in %s\n", PRVM_NAME);
+               VM_Warning("VM_bufstr_set: null string used in %s\n", PRVM_NAME);
                return;
        }
        if(b->strings[strindex])
@@ -3717,13 +3732,13 @@ void VM_bufstr_add (void)
        PRVM_G_FLOAT(OFS_RETURN) = -1;
        if(!b)
        {
-               Con_Printf("VM_bufstr_add: invalid buffer %i used in %s\n", bufindex, PRVM_NAME);
+               VM_Warning("VM_bufstr_add: invalid buffer %i used in %s\n", bufindex, PRVM_NAME);
                return;
        }
        string = PRVM_G_STRING(OFS_PARM1);
        if(!string)
        {
-               Con_Printf("VM_bufstr_add: null string used in %s\n", PRVM_NAME);
+               VM_Warning("VM_bufstr_add: null string used in %s\n", PRVM_NAME);
                return;
        }
 
@@ -3735,7 +3750,7 @@ void VM_bufstr_add (void)
                strindex = BufStr_FindFreeString(b);
                if(strindex < 0)
                {
-                       Con_Printf("VM_bufstr_add: buffer %i has no free string slots in %s\n", bufindex, PRVM_NAME);
+                       VM_Warning("VM_bufstr_add: buffer %i has no free string slots in %s\n", bufindex, PRVM_NAME);
                        return;
                }
        }
@@ -3744,7 +3759,7 @@ void VM_bufstr_add (void)
        {
                if(b->num_strings == MAX_QCSTR_STRINGS)
                {
-                       Con_Printf("VM_bufstr_add: buffer %i has no free string slots in %s\n", bufindex, PRVM_NAME);
+                       VM_Warning("VM_bufstr_add: buffer %i has no free string slots in %s\n", bufindex, PRVM_NAME);
                        return;
                }
                b->strings[b->num_strings] = NULL;
@@ -3773,13 +3788,13 @@ void VM_bufstr_free (void)
        b = BUFSTR_BUFFER((int)PRVM_G_FLOAT(OFS_PARM0));
        if(!b)
        {
-               Con_Printf("VM_bufstr_free: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
+               VM_Warning("VM_bufstr_free: invalid buffer %i used in %s\n", (int)PRVM_G_FLOAT(OFS_PARM0), PRVM_NAME);
                return;
        }
        i = (int)PRVM_G_FLOAT(OFS_PARM1);
        if(i < 0 || i > MAX_QCSTR_STRINGS)
        {
-               Con_Printf("VM_bufstr_free: invalid string index %i used in %s\n", i, PRVM_NAME);
+               VM_Warning("VM_bufstr_free: invalid string index %i used in %s\n", i, PRVM_NAME);
                return;
        }
        if(b->strings[i])
index c052c6e9ede1a080681ab23d861b039612678acd..9a16e9a84a9e88f4307fd1e3e2277149f6a9fee3 100644 (file)
@@ -3,7 +3,6 @@
 //============================================================================
 // Server
 
-#define PF_WARNING(s) do{Con_Printf(s);PRVM_PrintState();return;}while(0)
 cvar_t sv_aim = {CVAR_SAVE, "sv_aim", "2", "maximum cosine angle for quake's vertical autoaim, a value above 1 completely disables the autoaim, quake used 0.93"}; //"0.93"}; // LordHavoc: disabled autoaim by default
 
 
@@ -156,9 +155,15 @@ void PF_setorigin (void)
 
        e = PRVM_G_EDICT(OFS_PARM0);
        if (e == prog->edicts)
-               PF_WARNING("setorigin: can not modify world entity\n");
+       {
+               VM_Warning("setorigin: can not modify world entity\n");
+               return;
+       }
        if (e->priv.server->free)
-               PF_WARNING("setorigin: can not modify free entity\n");
+       {
+               VM_Warning("setorigin: can not modify free entity\n");
+               return;
+       }
        org = PRVM_G_VECTOR(OFS_PARM1);
        VectorCopy (org, e->fields.server->origin);
        SV_LinkEdict (e, false);
@@ -198,9 +203,15 @@ void PF_setsize (void)
 
        e = PRVM_G_EDICT(OFS_PARM0);
        if (e == prog->edicts)
-               PF_WARNING("setsize: can not modify world entity\n");
+       {
+               VM_Warning("setsize: can not modify world entity\n");
+               return;
+       }
        if (e->priv.server->free)
-               PF_WARNING("setsize: can not modify free entity\n");
+       {
+               VM_Warning("setsize: can not modify free entity\n");
+               return;
+       }
        min = PRVM_G_VECTOR(OFS_PARM1);
        max = PRVM_G_VECTOR(OFS_PARM2);
        SetMinMaxSize (e, min, max, false);
@@ -223,9 +234,15 @@ void PF_setmodel (void)
 
        e = PRVM_G_EDICT(OFS_PARM0);
        if (e == prog->edicts)
-               PF_WARNING("setmodel: can not modify world entity\n");
+       {
+               VM_Warning("setmodel: can not modify world entity\n");
+               return;
+       }
        if (e->priv.server->free)
-               PF_WARNING("setmodel: can not modify free entity\n");
+       {
+               VM_Warning("setmodel: can not modify free entity\n");
+               return;
+       }
        i = SV_ModelIndex(PRVM_G_STRING(OFS_PARM1), 1);
        e->fields.server->model = PRVM_SetEngineString(sv.model_precache[i]);
        e->fields.server->modelindex = i;
@@ -261,7 +278,10 @@ void PF_sprint (void)
        entnum = PRVM_G_EDICTNUM(OFS_PARM0);
 
        if (entnum < 1 || entnum > svs.maxclients || !svs.clients[entnum-1].active)
-               PF_WARNING("tried to centerprint to a non-client\n");
+       {
+               VM_Warning("tried to centerprint to a non-client\n");
+               return;
+       }
 
        client = svs.clients + entnum-1;
        if (!client->netconnection)
@@ -291,7 +311,10 @@ void PF_centerprint (void)
        entnum = PRVM_G_EDICTNUM(OFS_PARM0);
 
        if (entnum < 1 || entnum > svs.maxclients || !svs.clients[entnum-1].active)
-               PF_WARNING("tried to centerprint to a non-client\n");
+       {
+               VM_Warning("tried to centerprint to a non-client\n");
+               return;
+       }
 
        client = svs.clients + entnum-1;
        if (!client->netconnection)
@@ -399,13 +422,22 @@ void PF_sound (void)
        attenuation = PRVM_G_FLOAT(OFS_PARM4);
 
        if (volume < 0 || volume > 255)
-               PF_WARNING("SV_StartSound: volume must be in range 0-1\n");
+       {
+               VM_Warning("SV_StartSound: volume must be in range 0-1\n");
+               return;
+       }
 
        if (attenuation < 0 || attenuation > 4)
-               PF_WARNING("SV_StartSound: attenuation must be in range 0-4\n");
+       {
+               VM_Warning("SV_StartSound: attenuation must be in range 0-4\n");
+               return;
+       }
 
        if (channel < 0 || channel > 7)
-               PF_WARNING("SV_StartSound: channel must be in range 0-7\n");
+       {
+               VM_Warning("SV_StartSound: channel must be in range 0-7\n");
+               return;
+       }
 
        SV_StartSound (entity, channel, sample, volume, attenuation);
 }
@@ -550,7 +582,10 @@ void PF_tracetoss (void)
 
        ent = PRVM_G_EDICT(OFS_PARM0);
        if (ent == prog->edicts)
-               PF_WARNING("tracetoss: can not use world entity\n");
+       {
+               VM_Warning("tracetoss: can not use world entity\n");
+               return;
+       }
        ignore = PRVM_G_EDICT(OFS_PARM1);
 
        trace = SV_Trace_Toss (ent, ignore);
@@ -716,7 +751,10 @@ void PF_stuffcmd (void)
 
        entnum = PRVM_G_EDICTNUM(OFS_PARM0);
        if (entnum < 1 || entnum > svs.maxclients || !svs.clients[entnum-1].active)
-               PF_WARNING("Can't stuffcmd to a non-client\n");
+       {
+               VM_Warning("Can't stuffcmd to a non-client\n");
+               return;
+       }
 
        VM_VarString(1, string, sizeof(string));
 
@@ -831,9 +869,15 @@ void PF_walkmove (void)
 
        ent = PRVM_PROG_TO_EDICT(prog->globals.server->self);
        if (ent == prog->edicts)
-               PF_WARNING("walkmove: can not modify world entity\n");
+       {
+               VM_Warning("walkmove: can not modify world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("walkmove: can not modify free entity\n");
+       {
+               VM_Warning("walkmove: can not modify free entity\n");
+               return;
+       }
        yaw = PRVM_G_FLOAT(OFS_PARM0);
        dist = PRVM_G_FLOAT(OFS_PARM1);
 
@@ -876,9 +920,15 @@ void PF_droptofloor (void)
 
        ent = PRVM_PROG_TO_EDICT(prog->globals.server->self);
        if (ent == prog->edicts)
-               PF_WARNING("droptofloor: can not modify world entity\n");
+       {
+               VM_Warning("droptofloor: can not modify world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("droptofloor: can not modify free entity\n");
+       {
+               VM_Warning("droptofloor: can not modify free entity\n");
+               return;
+       }
 
        VectorCopy (ent->fields.server->origin, end);
        end[2] -= 256;
@@ -981,9 +1031,15 @@ void PF_aim (void)
 
        ent = PRVM_G_EDICT(OFS_PARM0);
        if (ent == prog->edicts)
-               PF_WARNING("aim: can not use world entity\n");
+       {
+               VM_Warning("aim: can not use world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("aim: can not use free entity\n");
+       {
+               VM_Warning("aim: can not use free entity\n");
+               return;
+       }
        speed = PRVM_G_FLOAT(OFS_PARM1);
 
        VectorCopy (ent->fields.server->origin, start);
@@ -1061,9 +1117,15 @@ void PF_changeyaw (void)
 
        ent = PRVM_PROG_TO_EDICT(prog->globals.server->self);
        if (ent == prog->edicts)
-               PF_WARNING("changeyaw: can not modify world entity\n");
+       {
+               VM_Warning("changeyaw: can not modify world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("changeyaw: can not modify free entity\n");
+       {
+               VM_Warning("changeyaw: can not modify free entity\n");
+               return;
+       }
        current = ANGLEMOD(ent->fields.server->angles[1]);
        ideal = ent->fields.server->ideal_yaw;
        speed = ent->fields.server->yaw_speed;
@@ -1108,22 +1170,28 @@ void PF_changepitch (void)
 
        ent = PRVM_G_EDICT(OFS_PARM0);
        if (ent == prog->edicts)
-               PF_WARNING("changepitch: can not modify world entity\n");
+       {
+               VM_Warning("changepitch: can not modify world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("changepitch: can not modify free entity\n");
+       {
+               VM_Warning("changepitch: can not modify free entity\n");
+               return;
+       }
        current = ANGLEMOD( ent->fields.server->angles[0] );
        if ((val = PRVM_GETEDICTFIELDVALUE(ent, eval_idealpitch)))
                ideal = val->_float;
        else
        {
-               PF_WARNING("PF_changepitch: .float idealpitch and .float pitch_speed must be defined to use changepitch\n");
+               VM_Warning("PF_changepitch: .float idealpitch and .float pitch_speed must be defined to use changepitch\n");
                return;
        }
        if ((val = PRVM_GETEDICTFIELDVALUE(ent, eval_pitch_speed)))
                speed = val->_float;
        else
        {
-               PF_WARNING("PF_changepitch: .float idealpitch and .float pitch_speed must be defined to use changepitch\n");
+               VM_Warning("PF_changepitch: .float idealpitch and .float pitch_speed must be defined to use changepitch\n");
                return;
        }
 
@@ -1186,14 +1254,14 @@ sizebuf_t *WriteDest (void)
                entnum = PRVM_NUM_FOR_EDICT(ent);
                if (entnum < 1 || entnum > svs.maxclients || !svs.clients[entnum-1].active || !svs.clients[entnum-1].netconnection)
                {
-                       Con_Printf ("WriteDest: tried to write to non-client\n");
+                       Con_Printf ("WriteDest: tried to write to non-client\n");PRVM_PrintState();
                        return &sv.reliable_datagram;
                }
                else
                        return &svs.clients[entnum-1].netconnection->message;
 
        default:
-               Con_Printf ("WriteDest: bad destination\n");
+               Con_Printf ("WriteDest: bad destination\n");PRVM_PrintState();
        case MSG_ALL:
                return &sv.reliable_datagram;
 
@@ -1262,9 +1330,15 @@ void PF_makestatic (void)
 
        ent = PRVM_G_EDICT(OFS_PARM0);
        if (ent == prog->edicts)
-               PF_WARNING("makestatic: can not modify world entity\n");
+       {
+               VM_Warning("makestatic: can not modify world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("makestatic: can not modify free entity\n");
+       {
+               VM_Warning("makestatic: can not modify free entity\n");
+               return;
+       }
 
        large = false;
        if (ent->fields.server->modelindex >= 256 || ent->fields.server->frame >= 256)
@@ -1361,7 +1435,7 @@ void PF_registercvar (void)
 // check for overlap with a command
        if (Cmd_Exists (name))
        {
-               Con_Printf("PF_registercvar: %s is a command\n", name);
+               VM_Warning("PF_registercvar: %s is a command\n", name);
                return;
        }
 
@@ -1494,7 +1568,7 @@ void PF_SV_AddStat (void)
                vm_autosentstats = (autosentstat_t *)Z_Malloc((MAX_CL_STATS-32) * sizeof(autosentstat_t));
                if(!vm_autosentstats)
                {
-                       Con_Printf("PF_SV_AddStat: not enough memory\n");
+                       VM_Warning("PF_SV_AddStat: not enough memory\n");
                        return;
                }
        }
@@ -1505,17 +1579,17 @@ void PF_SV_AddStat (void)
 
        if(i < 0)
        {
-               Con_Printf("PF_SV_AddStat: index may not be less than 32\n");
+               VM_Warning("PF_SV_AddStat: index may not be less than 32\n");
                return;
        }
        if(i >= (MAX_CL_STATS-32))
        {
-               Con_Printf("PF_SV_AddStat: index >= MAX_CL_STATS\n");
+               VM_Warning("PF_SV_AddStat: index >= MAX_CL_STATS\n");
                return;
        }
        if(i > (MAX_CL_STATS-32-4) && type == 1)
        {
-               Con_Printf("PF_SV_AddStat: index > (MAX_CL_STATS-4) with string\n");
+               VM_Warning("PF_SV_AddStat: index > (MAX_CL_STATS-4) with string\n");
                return;
        }
        vm_autosentstats[i].type                = type;
@@ -1538,14 +1612,26 @@ void PF_copyentity (void)
        prvm_edict_t *in, *out;
        in = PRVM_G_EDICT(OFS_PARM0);
        if (in == prog->edicts)
-               PF_WARNING("copyentity: can not read world entity\n");
+       {
+               VM_Warning("copyentity: can not read world entity\n");
+               return;
+       }
        if (in->priv.server->free)
-               PF_WARNING("copyentity: can not read free entity\n");
+       {
+               VM_Warning("copyentity: can not read free entity\n");
+               return;
+       }
        out = PRVM_G_EDICT(OFS_PARM1);
        if (out == prog->edicts)
-               PF_WARNING("copyentity: can not modify world entity\n");
+       {
+               VM_Warning("copyentity: can not modify world entity\n");
+               return;
+       }
        if (out->priv.server->free)
-               PF_WARNING("copyentity: can not modify free entity\n");
+       {
+               VM_Warning("copyentity: can not modify free entity\n");
+               return;
+       }
        memcpy(out->fields.server, in->fields.server, prog->progs->entityfields * 4);
 }
 
@@ -1605,11 +1691,17 @@ void PF_effect (void)
        const char *s;
        s = PRVM_G_STRING(OFS_PARM1);
        if (!s || !s[0])
-               PF_WARNING("effect: no model specified\n");
+       {
+               VM_Warning("effect: no model specified\n");
+               return;
+       }
 
        i = SV_ModelIndex(s, 1);
        if (!i)
-               PF_WARNING("effect: model not precached\n");
+       {
+               VM_Warning("effect: model not precached\n");
+               return;
+       }
        SV_StartEffect(PRVM_G_VECTOR(OFS_PARM0), i, (int)PRVM_G_FLOAT(OFS_PARM2), (int)PRVM_G_FLOAT(OFS_PARM3), (int)PRVM_G_FLOAT(OFS_PARM4));
 }
 
@@ -2234,9 +2326,15 @@ void PF_setattachment (void)
        model_t *model;
 
        if (e == prog->edicts)
-               PF_WARNING("setattachment: can not modify world entity\n");
+       {
+               VM_Warning("setattachment: can not modify world entity\n");
+               return;
+       }
        if (e->priv.server->free)
-               PF_WARNING("setattachment: can not modify free entity\n");
+       {
+               VM_Warning("setattachment: can not modify free entity\n");
+               return;
+       }
 
        if (tagentity == NULL)
                tagentity = prog->edicts;
@@ -2410,9 +2508,15 @@ void PF_gettagindex (void)
        int modelindex, tag_index;
 
        if (ent == prog->edicts)
-               PF_WARNING("gettagindex: can't affect world entity\n");
+       {
+               VM_Warning("gettagindex: can't affect world entity\n");
+               return;
+       }
        if (ent->priv.server->free)
-               PF_WARNING("gettagindex: can't affect free entity\n");
+       {
+               VM_Warning("gettagindex: can't affect free entity\n");
+               return;
+       }
 
        modelindex = (int)ent->fields.server->modelindex;
        tag_index = 0;
@@ -2441,10 +2545,10 @@ void PF_gettaginfo (void)
        switch(returncode)
        {
                case 1:
-                       PF_WARNING("gettagindex: can't affect world entity\n");
+                       VM_Warning("gettagindex: can't affect world entity\n");
                        break;
                case 2:
-                       PF_WARNING("gettagindex: can't affect free entity\n");
+                       VM_Warning("gettagindex: can't affect free entity\n");
                        break;
                case 3:
                        Con_DPrintf("SV_GetTagMatrix(entity #%i): null or non-precached model\n", PRVM_NUM_FOR_EDICT(e));
@@ -2465,9 +2569,15 @@ void PF_dropclient (void)
        client_t *oldhostclient;
        clientnum = PRVM_G_EDICTNUM(OFS_PARM0) - 1;
        if (clientnum < 0 || clientnum >= svs.maxclients)
-               PF_WARNING("dropclient: not a client\n");
+       {
+               VM_Warning("dropclient: not a client\n");
+               return;
+       }
        if (!svs.clients[clientnum].active)
-               PF_WARNING("dropclient: that client slot is not connected\n");
+       {
+               VM_Warning("dropclient: that client slot is not connected\n");
+               return;
+       }
        oldhostclient = host_client;
        host_client = svs.clients + clientnum;
        SV_DropClient(false);