]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cheats.qc
Step 6: complete
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cheats.qc
index b9928f0b91213da871dbd68baacb0c3c7dd5f46f..e92a6082a77d2486c562cd7e03604558ed363714 100644 (file)
@@ -33,7 +33,7 @@ void CopyBody(entity this, float keepvelocity);
 
 float CheatImpulse(entity this, int imp) { return 0; }
 float CheatCommand(entity this, int argc) { return 0; }
-float CheatFrame() { return 0; }
+float CheatFrame(entity this) { return 0; }
 void CheatInit() { cheatcount_total = world.cheatcount; }
 void CheatShutdown() { }
 void Drag_MoveDrag(entity from, entity to) { }
@@ -110,7 +110,7 @@ void info_autoscreenshot_findtarget(entity this)
        e = find(world, targetname, this.target);
        if(!e)
        {
-               objerror("Missing target. FAIL!");
+               objerror(this, "Missing target. FAIL!");
                return;
        }
        vector a = vectoangles(e.origin - this.origin);
@@ -123,7 +123,7 @@ spawnfunc(info_autoscreenshot)
 {
        if(++num_autoscreenshot > autocvar_g_max_info_autoscreenshot)
        {
-               objerror("Too many info_autoscreenshot entitites. FAIL!");
+               objerror(this, "Too many info_autoscreenshot entitites. FAIL!");
                return;
        }
        if(this.target != "")
@@ -295,7 +295,6 @@ float CheatCommand(entity this, int argc)
        {
                float effectnum, f;
                vector start, end;
-               entity oldself;
 
                case "pointparticles":
                        IS_CHEAT(this, 0, argc, 0);
@@ -552,11 +551,11 @@ float CheatCommand(entity this, int argc)
                                {
                                        start = '0 0 0';
                                        effectnum = 0;
-                                       for(oldself = world; (oldself = find(oldself, classname, "dragbox_box")); )
+                                       for(entity ent = world; (ent = find(ent, classname, "dragbox_box")); )
                                        {
-                                               if(e.cnt <= 0 && oldself.cnt == 0 || e.cnt == oldself.cnt)
+                                               if(e.cnt <= 0 && ent.cnt == 0 || e.cnt == ent.cnt)
                                                {
-                                                       start = start + oldself.origin;
+                                                       start = start + ent.origin;
                                                        ++effectnum;
                                                }
                                        }
@@ -583,12 +582,12 @@ float CheatCommand(entity this, int argc)
                                                        // these need race_place
                                                        // counting...
                                                        effectnum = 1;
-                                                       for(oldself = world; (oldself = find(oldself, classname, "dragpoint")); )
-                                                       if(oldself.cnt == 0)
+                                                       for(entity ent = world; (ent = find(ent, classname, "dragpoint")); )
+                                                       if(ent.cnt == 0)
                                                        {
-                                                               if(vlen(oldself.origin - start) < vlen(e.origin - start))
+                                                               if(vlen2(ent.origin - start) < vlen2(e.origin - start))
                                                                        ++effectnum;
-                                                               else if(vlen(oldself.origin - start) == vlen(e.origin - start) && etof(oldself) < etof(e))
+                                                               else if(vlen2(ent.origin - start) == vlen2(e.origin - start) && etof(ent) < etof(e))
                                                                        ++effectnum;
                                                        }
                                                        fputs(f, strcat("\"race_place\" \"", ftos(effectnum), "\"\n"));
@@ -719,8 +718,8 @@ float Drag_IsDragging(entity dragger);
 void Drag_MoveDrag(entity from, entity to);
 .entity dragentity;
 
-float CheatFrame()
-{SELFPARAM();
+float CheatFrame(entity this)
+{
        BEGIN_CHEAT_FUNCTION();
 
        // Dragging can be used as either a cheat, or a function for some objects. If sv_cheats is active,