From: TimePath Date: Fri, 13 Nov 2015 05:25:43 +0000 (+1100) Subject: Net: float/vector IO X-Git-Tag: xonotic-v0.8.2~1669 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=34ce4dd900fae362a89a911eede489d2476f9c40;p=xonotic%2Fxonotic-data.pk3dir.git Net: float/vector IO --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 985489b81..4a01f1c68 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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); } } diff --git a/qcsrc/common/minigames/cl_minigames.qc b/qcsrc/common/minigames/cl_minigames.qc index 769b70c33..3ea50caad 100644 --- a/qcsrc/common/minigames/cl_minigames.qc +++ b/qcsrc/common/minigames/cl_minigames.qc @@ -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 diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index 73e2a2bb1..f69fc15b5 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -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); \ diff --git a/qcsrc/dpdefs/csprogsdefs.qh b/qcsrc/dpdefs/csprogsdefs.qh index 6f9c9d637..b9bcec58e 100644 --- a/qcsrc/dpdefs/csprogsdefs.qh +++ b/qcsrc/dpdefs/csprogsdefs.qh @@ -29,6 +29,4 @@ #pragma noref 0 -#define ReadFloat() ReadCoord() - #endif diff --git a/qcsrc/dpdefs/progsdefs.qh b/qcsrc/dpdefs/progsdefs.qh index 5a93a2444..535c3b6f7 100644 --- a/qcsrc/dpdefs/progsdefs.qh +++ b/qcsrc/dpdefs/progsdefs.qh @@ -23,6 +23,4 @@ #pragma noref 0 -#define WriteFloat(to, f) WriteCoord(to, f) - #endif diff --git a/qcsrc/lib/net.qh b/qcsrc/lib/net.qh index 07385b092..3daa1cede 100644 --- a/qcsrc/lib/net.qh +++ b/qcsrc/lib/net.qh @@ -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)