]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/util.qc
Fix memory leaks in ATTRIB(..., strzone(...)) calls.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / util.qc
index 6de59027e38bdc668a9071f398a9bb1955cc73d9..c56ba66e968a67c36ffe34e4b68884cd05c4f999 100644 (file)
@@ -113,29 +113,28 @@ vector angleofs3(vector from, vector from_a, entity to)
 * Update self.tur_shotorg by getting up2date bone info
 * NOTICE this func overwrites the global v_forward, v_right and v_up vectors.
 */
-#define turret_tag_fire_update() self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));v_forward = normalize(v_forward)
-float turret_tag_fire_update_s()
-{
+float turret_tag_fire_update()
+{SELFPARAM();
        if(!self.tur_head)
        {
                error("Call to turret_tag_fire_update with self.tur_head missing!\n");
                self.tur_shotorg = '0 0 0';
-               return FALSE;
+               return false;
        }
 
        self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire"));
        v_forward = normalize(v_forward);
 
-       return TRUE;
+       return true;
 }
 
 /*
 * Railgun-like beam, but has thickness and suppots slowing of target
 */
 void FireImoBeam (vector start, vector end, vector smin, vector smax,
-                                 float bforce, float f_dmg, float f_velfactor, float deathtype)
+                                 float bforce, float f_dmg, float f_velfactor, int deathtype)
 
-{
+{SELFPARAM();
        vector hitloc, force, endpoint, dir;
        entity ent;
 
@@ -149,7 +148,7 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax,
        // note down which entities were hit so we can damage them later
        while (1)
        {
-               tracebox(start, smin, smax, end, FALSE, self);
+               tracebox(start, smin, smax, end, false, self);
 
                // if it is world we can't hurt it so stop now
                if (trace_ent == world || trace_fraction == 1)
@@ -159,7 +158,7 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax,
                        break;
 
                // make the entity non-solid so we can hit the next one
-               trace_ent.railgunhit = TRUE;
+               trace_ent.railgunhit = true;
                trace_ent.railgunhitloc = end;
                trace_ent.railgunhitsolidbackup = trace_ent.solid;
 
@@ -172,23 +171,23 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax,
        endpoint = trace_endpos;
 
        // find all the entities the railgun hit and restore their solid state
-       ent = findfloat(world, railgunhit, TRUE);
+       ent = findfloat(world, railgunhit, true);
        while (ent)
        {
                // restore their solid type
                ent.solid = ent.railgunhitsolidbackup;
-               ent = findfloat(ent, railgunhit, TRUE);
+               ent = findfloat(ent, railgunhit, true);
        }
 
        // find all the entities the railgun hit and hurt them
-       ent = findfloat(world, railgunhit, TRUE);
+       ent = findfloat(world, railgunhit, true);
        while (ent)
        {
                // get the details we need to call the damage function
                hitloc = ent.railgunhitloc;
                ent.railgunhitloc = '0 0 0';
                ent.railgunhitsolidbackup = SOLID_NOT;
-               ent.railgunhit = FALSE;
+               ent.railgunhit = false;
 
                // apply the damage
                if (ent.takedamage)
@@ -199,15 +198,14 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax,
                }
 
                // advance to the next entity
-               ent = findfloat(ent, railgunhit, TRUE);
+               ent = findfloat(ent, railgunhit, true);
        }
        trace_endpos = endpoint;
 }
 
 #ifdef TURRET_DEBUG
-void SUB_Remove();
 void marker_think()
-{
+{SELFPARAM();
        if(self.cnt)
        if(self.cnt < time)
        {
@@ -225,11 +223,8 @@ void marker_think()
 
 void mark_error(vector where,float lifetime)
 {
-       entity err;
-
-       err = spawn();
-       err.classname = "error_marker";
-       setmodel(err,"models/marker.md3");
+       entity err = new(error_marker);
+       setmodel(err, MDL_MARKER);
        setorigin(err,where);
        err.movetype = MOVETYPE_NONE;
        err.think = marker_think;
@@ -241,11 +236,8 @@ void mark_error(vector where,float lifetime)
 
 void mark_info(vector where,float lifetime)
 {
-       entity err;
-
-       err = spawn();
-       err.classname = "info_marker";
-       setmodel(err,"models/marker.md3");
+       entity err = spawn(info_marker);
+       setmodel(err, MDL_MARKER);
        setorigin(err,where);
        err.movetype = MOVETYPE_NONE;
        err.think = marker_think;
@@ -257,11 +249,8 @@ void mark_info(vector where,float lifetime)
 
 entity mark_misc(vector where,float lifetime)
 {
-       entity err;
-
-       err = spawn();
-       err.classname = "mark_misc";
-       setmodel(err,"models/marker.md3");
+       entity err = spawn(mark_misc);
+       setmodel(err, MDL_MARKER);
        setorigin(err,where);
        err.movetype = MOVETYPE_NONE;
        err.think = marker_think;
@@ -272,6 +261,8 @@ entity mark_misc(vector where,float lifetime)
        return err;
 }
 
+MODEL(TUR_C512, "models/turrets/c512.md3");
+
 /*
 * Paint a v_color colord circle on target onwho
 * that fades away over f_time
@@ -281,7 +272,7 @@ void paint_target(entity onwho, float f_size, vector v_color, float f_time)
        entity e;
 
        e = spawn();
-       setmodel(e, "models/turrets/c512.md3"); // precision set above
+       setmodel(e, MDL_TUR_C512); // precision set above
        e.scale = (f_size/512);
        //setsize(e, '0 0 0', '0 0 0');
        //setattachment(e,onwho,"");
@@ -300,7 +291,7 @@ void paint_target2(entity onwho, float f_size, vector v_color, float f_time)
        entity e;
 
        e = spawn();
-       setmodel(e, "models/turrets/c512.md3"); // precision set above
+       setmodel(e, MDL_TUR_C512); // precision set above
        e.scale = (f_size/512);
        setsize(e, '0 0 0', '0 0 0');
 
@@ -319,7 +310,7 @@ void paint_target3(vector where, float f_size, vector v_color, float f_time)
 {
        entity e;
        e = spawn();
-       setmodel(e, "models/turrets/c512.md3"); // precision set above
+       setmodel(e, MDL_TUR_C512); // precision set above
        e.scale = (f_size/512);
        setsize(e, '0 0 0', '0 0 0');
        setorigin(e,where+ '0 0 1');