From 5fc362d5d72a0aecbd5a64520b105650f8f2d794 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 1 Mar 2004 03:49:14 +0000 Subject: [PATCH 1/1] upgraded network protocol to DP5, now sends precise entity angles (except for EF_LOWPRECISION entities), this increases normal entity data by 3 bytes (18 bytes for origin+angles, was 15 bytes in DP4, still 9 bytes for EF_LOWPRECISION origin+angles), upgraded a few other parts of protocol to precise angles and/or floats as well (client data updates now use float for punchvector and velocity ) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3940 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_input.c | 2 +- cl_parse.c | 68 +++++++++++++++++++++++++++++++------------------- cl_particles.c | 3 +-- common.c | 8 +----- common.h | 4 +-- protocol.c | 42 ++++++++++++++++++++++--------- protocol.h | 1 + sv_main.c | 6 ++--- todo | 5 ++-- view.c | 3 +-- 10 files changed, 84 insertions(+), 58 deletions(-) diff --git a/cl_input.c b/cl_input.c index 2948b61a..c3fef756 100644 --- a/cl_input.c +++ b/cl_input.c @@ -390,7 +390,7 @@ void CL_SendMove(usercmd_t *cmd) for (i = 0;i < 3;i++) MSG_WriteFloat (&buf, cl.viewangles[i]); } - else if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES4) + else if (cl.protocol == PROTOCOL_DARKPLACES1 || cl.protocol == PROTOCOL_DARKPLACES4 || cl.protocol == PROTOCOL_DARKPLACES5) { for (i=0 ; i<3 ; i++) MSG_WritePreciseAngle (&buf, cl.viewangles[i]); diff --git a/cl_parse.c b/cl_parse.c index 04879f66..e3d70dd8 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -151,8 +151,7 @@ void CL_ParseStartSoundPacket(int largesoundindex) if (ent >= MAX_EDICTS) Host_Error ("CL_ParseStartSoundPacket: ent = %i", ent); - for (i = 0;i < 3;i++) - pos[i] = MSG_ReadCoord (); + MSG_ReadVector(pos); S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation); } @@ -335,9 +334,9 @@ void CL_ParseServerInfo (void) // hack for unmarked Nehahra movie demos which had a custom protocol if (i == PROTOCOL_QUAKE && cls.demoplayback && demo_nehahra.integer) i = PROTOCOL_NEHAHRAMOVIE; - if (i != PROTOCOL_QUAKE && i != PROTOCOL_DARKPLACES1 && i != PROTOCOL_DARKPLACES2 && i != PROTOCOL_DARKPLACES3 && i != PROTOCOL_DARKPLACES4 && i != PROTOCOL_NEHAHRAMOVIE) + if (i != PROTOCOL_QUAKE && i != PROTOCOL_DARKPLACES1 && i != PROTOCOL_DARKPLACES2 && i != PROTOCOL_DARKPLACES3 && i != PROTOCOL_DARKPLACES4 && i != PROTOCOL_DARKPLACES5 && i != PROTOCOL_NEHAHRAMOVIE) { - Host_Error("CL_ParseServerInfo: Server is protocol %i, not %i (Quake), %i (DP1), %i (DP2), %i (DP3), %i (DP4), or %i (Nehahra movie)", i, PROTOCOL_QUAKE, PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_NEHAHRAMOVIE); + Host_Error("CL_ParseServerInfo: Server is protocol %i, not %i (Quake), %i (DP1), %i (DP2), %i (DP3), %i (DP4), %i (DP5), or %i (Nehahra movie)", i, PROTOCOL_QUAKE, PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_DARKPLACES5, PROTOCOL_NEHAHRAMOVIE); return; } cl.protocol = i; @@ -765,25 +764,46 @@ void CL_ParseClientdata (int bits) cl.idealpitch = 0; VectorCopy (cl.mvelocity[0], cl.mvelocity[1]); - for (i=0 ; i<3 ; i++) + if (cl.protocol == PROTOCOL_DARKPLACES5) { - if (bits & (SU_PUNCH1<angles[0]); + if (bits & E_ANGLE2) + MSG_WriteAngle(msg, ent->angles[1]); + if (bits & E_ANGLE3) + MSG_WriteAngle(msg, ent->angles[2]); } else { @@ -172,13 +178,13 @@ void EntityState_Write(entity_state_t *ent, sizebuf_t *msg, entity_state_t *delt MSG_WriteFloat(msg, org[1]); if (bits & E_ORIGIN3) MSG_WriteFloat(msg, org[2]); + if (bits & E_ANGLE1) + MSG_WritePreciseAngle(msg, ent->angles[0]); + if (bits & E_ANGLE2) + MSG_WritePreciseAngle(msg, ent->angles[1]); + if (bits & E_ANGLE3) + MSG_WritePreciseAngle(msg, ent->angles[2]); } - if (bits & E_ANGLE1) - MSG_WriteAngle(msg, ent->angles[0]); - if (bits & E_ANGLE2) - MSG_WriteAngle(msg, ent->angles[1]); - if (bits & E_ANGLE3) - MSG_WriteAngle(msg, ent->angles[2]); if (bits & E_MODEL1) MSG_WriteByte(msg, ent->modelindex & 0xFF); if (bits & E_MODEL2) @@ -277,12 +283,24 @@ void EntityState_ReadUpdate(entity_state_t *e, int number) e->origin[2] = MSG_ReadFloat(); } } - if (bits & E_ANGLE1) - e->angles[0] = MSG_ReadAngle(); - if (bits & E_ANGLE2) - e->angles[1] = MSG_ReadAngle(); - if (bits & E_ANGLE3) - e->angles[2] = MSG_ReadAngle(); + if (cl.protocol == PROTOCOL_DARKPLACES5 && !(e->flags & RENDER_LOWPRECISION)) + { + if (bits & E_ANGLE1) + e->angles[0] = MSG_ReadPreciseAngle(); + if (bits & E_ANGLE2) + e->angles[1] = MSG_ReadPreciseAngle(); + if (bits & E_ANGLE3) + e->angles[2] = MSG_ReadPreciseAngle(); + } + else + { + if (bits & E_ANGLE1) + e->angles[0] = MSG_ReadAngle(); + if (bits & E_ANGLE2) + e->angles[1] = MSG_ReadAngle(); + if (bits & E_ANGLE3) + e->angles[2] = MSG_ReadAngle(); + } if (bits & E_MODEL1) e->modelindex = (e->modelindex & 0xFF00) | (unsigned int) MSG_ReadByte(); if (bits & E_MODEL2) diff --git a/protocol.h b/protocol.h index 4d140b45..717d9916 100644 --- a/protocol.h +++ b/protocol.h @@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // so here I jump to 3500 #define PROTOCOL_DARKPLACES3 3500 #define PROTOCOL_DARKPLACES4 3501 +#define PROTOCOL_DARKPLACES5 3502 // model effects #define EF_ROCKET 1 // leave a trail diff --git a/sv_main.c b/sv_main.c index d695f3bf..71b57193 100644 --- a/sv_main.c +++ b/sv_main.c @@ -272,7 +272,7 @@ void SV_SendServerinfo (client_t *client) MSG_WriteString (&client->message,message); MSG_WriteByte (&client->message, svc_serverinfo); - MSG_WriteLong (&client->message, PROTOCOL_DARKPLACES4); + MSG_WriteLong (&client->message, PROTOCOL_DARKPLACES5); MSG_WriteByte (&client->message, svs.maxclients); if (!coop.integer && deathmatch.integer) @@ -1295,9 +1295,9 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) if (bits & (SU_PUNCH1<v->punchangle[i]); // PROTOCOL_DARKPLACES if (bits & (SU_PUNCHVEC1<v->velocity[i]/16); + MSG_WriteFloat(msg, ent->v->velocity[i]); } // [always sent] if (bits & SU_ITEMS) diff --git a/todo b/todo index bf15b682..27e946d5 100644 --- a/todo +++ b/todo @@ -34,12 +34,13 @@ -n darkplaces: segfault reading memory in windows when starting a new server from menu (yummyluv) -n darkplaces: server is starting before the "port" cvar is set by commandline and scripts? (yummyluv) -n darkplaces: typing ip in join game menu should show 'trying' and 'no response' after a while, or 'no network' if networking is not initialized (yummyluv) +0 darkplaces: fix view blends, they're not working d darkplaces: fixed SV_TouchAreaGrid to not crash if SV_IncreaseEdicts is called during a touch function, by making a list of edicts to touch and then running through the list afterward (KGB|romi) d darkplaces: moved R_ShadowVolumeLighting to r_shadow.c d darkplaces: added RENDER_LIGHT flag to entity_render_t to make rtlighting optional per entity d darkplaces: cleaned up rtlight handling, merging most code between world rtlights and dlights d darkplaces: safety checked lightmap access in Mod_Q1BSP_RecursiveLightPoint as one map Sajt uses was crashing (Sajt) -0 darkplaces: upgrade network protocol to send precise angles, and make EF_LOWPRECISION downgrade both origin and angles (Urre) +-n darkplaces: upgrade network protocol to send precise angles, and make EF_LOWPRECISION downgrade both origin and angles (Urre, Wazat for Battlemech, FrikaC, mashakos, RenegadeC, Sajt) 0 darkplaces: figure out why cubemap upload scaling crashes (Urre) 0 darkplaces: make screenshots save to screenshots/fniggium%04i.tga in GAME_FNIGGIUM (Sajt) 0 darkplaces: make screenshots save to screenshots directory (Sajt) @@ -295,7 +296,7 @@ d darkplaces: q1bsp trace bug: scrags frequently fly through ceilings - this nee 0 sv_user.qc: figure out why looking up/down slows movement and fix it (Vermeulen) 1 darkplaces: add DP_CLIENTCAMERA extension (.entity clientcamera; sets which entity the client views from) (Wazat for Battlemech, SeienAbunae) 1 darkplaces: add DP_EF_CLIENTLOCKANGLES extension (prevents client from turning view, takes angles from entity) (Wazat for Battlemech, SeienAbunae) -1 darkplaces: add DP_EF_PRECISEANGLES extension (sends short angles instead of byte) (Wazat for Battlemech, FrikaC, mashakos, RenegadeC, Sajt) +f darkplaces: add DP_EF_PRECISEANGLES extension (sends short angles instead of byte), failed because network protocol was upgraded by default (Wazat for Battlemech, FrikaC, mashakos, RenegadeC, Sajt) 1 darkplaces: add DP_QC_ENDFRAME extension/documentation and post it on wiki (tell Uffe, SeienAbunae) 1 darkplaces: add DP_SV_READCLIENTINPUT extension (.vector clientinput; works like .movement but for mouse or any other similar controllers) (Wazat for Battlemech, FrikaC, SeienAbunae) 1 darkplaces: add EndGame function (called on server shutdown or level change) (SeienAbunae, Nexuiz) diff --git a/view.c b/view.c index 49879479..570e4609 100644 --- a/view.c +++ b/view.c @@ -214,8 +214,7 @@ void V_ParseDamage (void) armor = MSG_ReadByte (); blood = MSG_ReadByte (); - for (i=0 ; i<3 ; i++) - from[i] = MSG_ReadCoord (); + MSG_ReadVector(from); count = blood*0.5 + armor*0.5; if (count < 10) -- 2.39.2