]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Net: float/vector IO
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 13 Nov 2015 05:25:43 +0000 (16:25 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Fri, 13 Nov 2015 05:25:43 +0000 (16:25 +1100)
qcsrc/client/main.qc
qcsrc/common/minigames/cl_minigames.qc
qcsrc/common/minigames/sv_minigames.qc
qcsrc/dpdefs/csprogsdefs.qh
qcsrc/dpdefs/progsdefs.qh
qcsrc/lib/net.qh

index 985489b81e37118cd05c011c26788173529ea884..4a01f1c685841b1f361e47ce8ad49885547651be 100644 (file)
@@ -752,7 +752,7 @@ NET_HANDLE(ENT_CLIENT_SPAWNEVENT, bool is_new)
 
 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
-void CSQC_Ent_Update(float bIsNewEntity)
+void CSQC_Ent_Update(bool isnew)
 {
        SELFPARAM();
        this.sourceLocLine = __LINE__;
@@ -773,22 +773,22 @@ void CSQC_Ent_Update(float bIsNewEntity)
        }
 
 #ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
-       if(this.enttype)
+       if (this.enttype)
        {
-               if(t != this.enttype || bIsNewEntity)
+               if (t != this.enttype || isnew)
                {
                        LOG_INFOF("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n", num_for_edict(this), this.entnum, this.enttype, t);
                        Ent_Remove();
                        clearentity(this);
-                       bIsNewEntity = 1;
+                       isnew = true;
                }
        }
        else
        {
-               if(!bIsNewEntity)
+               if (!isnew)
                {
                        LOG_INFOF("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n", num_for_edict(this), this.entnum, t);
-                       bIsNewEntity = 1;
+                       isnew = true;
                }
        }
 #endif
@@ -797,15 +797,14 @@ void CSQC_Ent_Update(float bIsNewEntity)
        FOREACH(LinkedEntities, it.m_id == t, LAMBDA(
                this.classname = it.netname;
                if (autocvar_developer_csqcentities)
-            LOG_INFOF("CSQC_Ent_Update(%d) with this=%i {.entnum=%d, .enttype=%d} t=%s (%d)\n", bIsNewEntity, this, this.entnum, this.enttype, it.netname, t);
-               done = it.m_read(this, bIsNewEntity);
+            LOG_INFOF("CSQC_Ent_Update(%d) at %f with this=%i {.entnum=%d, .enttype=%d} t=%s (%d)\n", isnew, savetime, this, this.entnum, this.enttype, this.classname, t);
+               done = it.m_read(this, isnew);
                break;
        ));
        time = savetime;
        if (!done)
        {
-               //error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), this.enttype));
-               error(sprintf("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n", this.enttype, num_for_edict(this), this.classname));
+               LOG_FATALF("CSQC_Ent_Update(%d) at %f with this=%i {.entnum=%d, .enttype=%d} t=%s (%d)\n", isnew, savetime, this, this.entnum, this.enttype, this.classname, t);
        }
 }
 
index 769b70c3316c80c0bf11b5cb023444afb88c2842..3ea50caad3d0554bb5f1b7b4e389b29bf6052d6b 100644 (file)
@@ -153,8 +153,6 @@ void minigame_player_entremove()
                deactivate_minigame();
 }
 
-vector ReadVector2D() { vector v; v_x = ReadCoord(); v_y = ReadCoord(); v_z = 0; return v; }
-vector ReadVector() { vector v; v_x = ReadCoord(); v_y = ReadCoord(); v_z = ReadCoord(); return v; }
 string() ReadString_Raw = #366;
 string ReadString_Zoned() { return strzone(ReadString_Raw()); }
 #define ReadString ReadString_Zoned
index 73e2a2bb1d1567d1d13b208ac81731797b1cd2c5..f69fc15b548c39ef99759700247db76dfdfedd5f 100644 (file)
@@ -51,8 +51,6 @@ void minigame_rmplayer(entity minigame_session, entity player)
 
 
 #define FIELD(Flags, Type,Name) if ( sf & (Flags) ) Write##Type(MSG_ENTITY, self.Name);
-#define WriteVector(to,Name) WriteCoord(to,Name##_x); WriteCoord(to,Name##_y); WriteCoord(to,Name##_z)
-#define WriteVector2D(to,Name) WriteCoord(to,Name##_x); WriteCoord(to,Name##_y)
 #define MSLE(Name,Fields) \
        else if ( self.classname == #Name ) { \
                if ( sf & MINIG_SF_CREATE ) WriteString(MSG_ENTITY,self.owner.netname); \
index 6f9c9d637ff3a927faae655e701e09d7c73d22a9..b9bcec58e60c6df31679667ea4a7ded1397333b5 100644 (file)
@@ -29,6 +29,4 @@
 
 #pragma noref 0
 
-#define ReadFloat() ReadCoord()
-
 #endif
index 5a93a2444c472d555b643fa18a601b4b0b8e76b4..535c3b6f7c3504e8ba3113a385ec7e489bcb29fa 100644 (file)
@@ -23,6 +23,4 @@
 
 #pragma noref 0
 
-#define WriteFloat(to, f) WriteCoord(to, f)
-
 #endif
index 07385b092da1cbdac01a3803b91d84262b96b97a..3daa1cede585acd12b5d982afa396635e03d2281 100644 (file)
@@ -184,6 +184,10 @@ STATIC_INIT(RegisterTempEntities_renumber)
                        return v;
                }
 
+               #define ReadFloat() ReadCoord()
+        vector ReadVector() { vector v; v.x = ReadFloat(); v_y = ReadFloat(); v.z = ReadFloat(); return v; }
+               vector ReadVector2D() { vector v; v.x = ReadFloat(); v.y = ReadFloat(); v.z = 0; return v; }
+
                float ReadApproxPastTime()
                {
                        float dt = ReadByte();
@@ -215,6 +219,10 @@ STATIC_INIT(RegisterTempEntities_renumber)
                        WriteInt24_t(dst, val.z);
                }
 
+        #define WriteFloat(to, f) WriteCoord(to, f)
+               #define WriteVector(to, v) do { WriteFloat(to, v.x); WriteFloat(to, v.y); WriteFloat(to, v.z); } while (0)
+        #define WriteVector2D(to, v) do { WriteFloat(to, v.x); WriteFloat(to, v.y); } while (0)
+
                // this will use the value:
                //   128
                // accuracy near zero is APPROXPASTTIME_MAX/(256*255)