r4647 - in trunk/data/qcsrc: client server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Oct 6 12:58:41 EDT 2008
Author: div0
Date: 2008-10-06 12:58:41 -0400 (Mon, 06 Oct 2008)
New Revision: 4647
Modified:
trunk/data/qcsrc/client/Main.qc
trunk/data/qcsrc/client/main.qh
trunk/data/qcsrc/client/ons.qc
trunk/data/qcsrc/client/teamradar.qc
trunk/data/qcsrc/server/cl_client.qc
trunk/data/qcsrc/server/ent_cs.qc
Log:
updated entcs, less of a bandwidth hog
Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc 2008-10-06 13:21:54 UTC (rev 4646)
+++ trunk/data/qcsrc/client/Main.qc 2008-10-06 16:58:41 UTC (rev 4647)
@@ -37,9 +37,6 @@
{
};
-// let's make this a general data buffer...
-float using_gps;
-
#ifdef USE_FTE
float __engine_check;
#endif
@@ -82,7 +79,6 @@
menu_visible = FALSE;
menu_show = menu_show_error;
menu_action = menu_sub_null;
- using_gps = false;
maxclients = 255; // we later get the real maxclients to speed up stuff
//ctf_temp_1 = "";
// localcmd("alias order \"cmd order $*\""); enable if ctf-command thingy is used
@@ -102,8 +98,6 @@
gametype = 0;
- gps_start = world;
-
// sbar_fields uses strunzone on the titles!
for(i = 0; i < MAX_SBAR_FIELDS; ++i)
sbar_title[i] = strzone("(null)");
@@ -349,11 +343,10 @@
// BEGIN OPTIONAL CSQC FUNCTIONS
void Ent_ReadEntCS()
{
- entity gps;
- using_gps = true;
-
InterpolateOrigin_Undo();
+ self.classname = "entcs_receiver";
+ self.sv_entnum = ReadByte() - 1;
self.origin_x = ReadShort();
self.origin_y = ReadShort();
self.origin_z = ReadShort();
@@ -361,33 +354,10 @@
self.origin_z = self.angles_x = self.angles_z = 0;
InterpolateOrigin_Note();
-
- for(gps = gps_start; gps; gps = gps.chain)
- {
- if(gps == self)
- break;
- }
- if(!gps)
- {
- self.chain = gps_start;
- gps_start = self;
- }
}
-void Ent_RemoveONS()
+void Ent_RemoveEntCS()
{
- if(gps_start == self)
- gps_start = self.chain;
- else
- {
- local entity ent;
- ent = gps_start;
-
- while(ent.chain != self && ent.chain != world)
- ent = ent.chain;
- if(ent.chain == self)
- ent.chain = self.chain;
- }
}
void Ent_Remove();
@@ -494,7 +464,7 @@
// The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
void(float bIsNewEntity) CSQC_Ent_Update =
{
- float msg, t;
+ float t;
t = ReadByte();
#ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
if(self.enttype)
@@ -506,20 +476,7 @@
#endif
self.enttype = t;
if(self.enttype == ENT_CLIENT_ENTCS)
- {
- self.sv_entnum = ReadByte()-1;
-
- for(msg = ReadByte(); msg != ENTCS_MSG_END; msg = ReadByte())
- {
- switch(msg)
- {
- case ENTCS_MSG_ONS_GPS: Ent_ReadEntCS(); break;
- case ENTCS_MSG_ONS_REMOVE: Ent_RemoveONS(); break;
- default:
- error("unknown ENTCS_MSG type\n");
- }
- }
- }
+ Ent_ReadEntCS();
else if(self.enttype == ENT_CLIENT_SCORES)
Ent_ReadPlayerScore();
else if(self.enttype == ENT_CLIENT_TEAMSCORES)
@@ -545,21 +502,7 @@
{
if(self.enttype == ENT_CLIENT_ENTCS)
{
- if(using_gps) //gametype == GAME_ONSLAUGHT)
- {
- if(gps_start == self)
- gps_start = self.chain;
- else
- {
- local entity ent;
- ent = gps_start;
-
- while(ent.chain != self && ent.chain != world)
- ent = ent.chain;
- if(ent.chain == self)
- ent.chain = self.chain;
- }
- }
+ Ent_RemoveEntCS();
} else if(self.enttype == ENT_CLIENT_SCORES)
{
if(self.owner)
Modified: trunk/data/qcsrc/client/main.qh
===================================================================
--- trunk/data/qcsrc/client/main.qh 2008-10-06 13:21:54 UTC (rev 4646)
+++ trunk/data/qcsrc/client/main.qh 2008-10-06 16:58:41 UTC (rev 4647)
@@ -41,7 +41,6 @@
float drawfont;
float postinit;
float gametype;
-entity gps_start;
//float sorted_players;
//float sorted_teams;
Modified: trunk/data/qcsrc/client/ons.qc
===================================================================
--- trunk/data/qcsrc/client/ons.qc 2008-10-06 13:21:54 UTC (rev 4646)
+++ trunk/data/qcsrc/client/ons.qc 2008-10-06 16:58:41 UTC (rev 4647)
@@ -51,7 +51,8 @@
drawplayer(coord, input_angles, '1 1 1');
local entity tm;
- for(tm = gps_start; tm != world; tm = tm.chain)
+ for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
+ if(GetPlayerColor(tm.sv_entnum) == color)
{
//print(strcat("GPS: ", ftos(tm.sv_entnum), " - ", vtos(tm.origin), "\n"));
drawplayer(mapcoords(tm.origin), tm.angles, rgb);
Modified: trunk/data/qcsrc/client/teamradar.qc
===================================================================
--- trunk/data/qcsrc/client/teamradar.qc 2008-10-06 13:21:54 UTC (rev 4646)
+++ trunk/data/qcsrc/client/teamradar.qc 2008-10-06 16:58:41 UTC (rev 4647)
@@ -141,7 +141,7 @@
void() teamradar_view =
{
- local float color;
+ local float color, color2;
local vector rgb;
local entity tm;
float scale2d, normalsize, bigsize;
@@ -233,8 +233,12 @@
draw_teamradar_background(cl_teamradar_background_alpha);
for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm.teamradar_time, tm.teamradar_color, tm.alpha);
- for(tm = gps_start; tm != world; tm = tm.chain)
- draw_teamradar_player(tm.origin, tm.angles, rgb);
+ for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
+ {
+ color2 = GetPlayerColor(tm.sv_entnum);
+ //if(color == COLOR_SPECTATOR || color == color2)
+ draw_teamradar_player(tm.origin, tm.angles, GetTeamRGB(color2));
+ }
draw_teamradar_player(pmove_org, input_angles, '1 1 1');
drawresetcliparea();
Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc 2008-10-06 13:21:54 UTC (rev 4646)
+++ trunk/data/qcsrc/server/cl_client.qc 2008-10-06 16:58:41 UTC (rev 4647)
@@ -1209,7 +1209,7 @@
ctf_clientconnect();
}*/
- if(entcs_start)
+ if(teams_matter)
attach_entcs();
bot_relinkplayerlist();
@@ -1279,7 +1279,7 @@
bot_clientdisconnect();
- if(entcs_start)
+ if(teams_matter)
detach_entcs();
if(cvar("sv_eventlog"))
Modified: trunk/data/qcsrc/server/ent_cs.qc
===================================================================
--- trunk/data/qcsrc/server/ent_cs.qc 2008-10-06 13:21:54 UTC (rev 4646)
+++ trunk/data/qcsrc/server/ent_cs.qc 2008-10-06 16:58:41 UTC (rev 4647)
@@ -13,102 +13,80 @@
// it did when I added this) But you have to use .Version
// Capital V
-entity entcs_start;
-.entity entcs_next;
+.entity entcs;
void entcs_init()
{
print("Initializing ClientSide information entities\n");
- entcs_start = spawn();
- entcs_start.solid = SOLID_NOT;
- entcs_start.entcs_next = world;
};
-entity get_entcs_ent()
+float entcs_customize()
{
- entity entcs;
- entcs = spawn();
- entcs.entcs_next = entcs_start.entcs_next;
- entcs_start.entcs_next = entcs;
- return entcs;
-};
-
-void entcs_ons(entity to)
-{
- if(to == self.owner || self.team != to.team || self.owner.classname != "player" || to.classname != "player" || self.owner.deadflag != DEAD_NO)
- {
- WriteByte(MSG_ENTITY, ENTCS_MSG_ONS_REMOVE); // looks like a waste to me
- return;
- }
- WriteByte(MSG_ENTITY, ENTCS_MSG_ONS_GPS);
- WriteShort(MSG_ENTITY, self.owner.origin_x);
- WriteShort(MSG_ENTITY, self.owner.origin_y);
- WriteShort(MSG_ENTITY, self.owner.origin_z);
- WriteByte(MSG_ENTITY, self.owner.angles_y * 256.0 / 360);
+ entity o;
+ o = self.owner;
+ if(o.deadflag != DEAD_NO)
+ return FALSE;
+ if(o.classname != "player")
+ return FALSE;
+ if(other == o)
+ return FALSE;
+ if(other.classname == "player")
+ if(o.team != other.team)
+ return FALSE;
+ return TRUE;
}
-void entcs_common_self()
-{
-}
-
float entcs_send(entity to)
{
+ entity o;
+ o = self.owner;
WriteByte(MSG_ENTITY, ENT_CLIENT_ENTCS);
- WriteByte(MSG_ENTITY, self.health); // serves as entitynumber
-
- if(to == self.owner)
- {
- entcs_common_self();
- }
-
- if(teams_matter)
- entcs_ons(to);
-
- WriteByte(MSG_ENTITY, ENTCS_MSG_END);
+ WriteByte(MSG_ENTITY, num_for_edict(o));
+ WriteShort(MSG_ENTITY, o.origin_x);
+ WriteShort(MSG_ENTITY, o.origin_y);
+ WriteShort(MSG_ENTITY, o.origin_z);
+ WriteByte(MSG_ENTITY, o.angles_y * 256.0 / 360);
return TRUE;
};
void entcs_think()
{
- self.team = self.owner.team;
- self.Version++;
- setorigin(self, self.owner.origin);
self.nextthink = time;
+
+ entity o;
+ o = self.owner;
+
+ if(o.origin != self.origin || o.angles != self.angles)
+ {
+ self.origin = o.origin;
+ self.angles = o.angles;
+ self.SendFlags |= 1;
+ }
};
entity attach_entcs()
{
- local float num;
local entity ent;
- num = num_for_edict(self);
- ent = get_entcs_ent();
-
- ent.classname = "entcs_sender";
- ent.health = num;
- setorigin(ent, self.origin);
+ ent = spawn();
+ ent.classname = "entcs_sender_v2";
ent.owner = self;
ent.think = entcs_think;
ent.nextthink = time;
ent.effects = EF_NODEPTHTEST | EF_LOWPRECISION;
ent.model = "entcs_sender";
ent.modelindex = 1;
- setsize(ent, '0 0 0', '0 0 0');
ent.SendEntity = entcs_send;
+ ent.customizeentityforclient = entcs_customize;
+
+ self.entcs = ent;
+
return ent;
};
void detach_entcs()
{
- local float num;
- local entity ent, n;
- num = num_for_edict(self);
- for(ent = entcs_start; ent.entcs_next.owner != self && ent.entcs_next != world; ent = ent.entcs_next);
- if(ent.entcs_next != world && ent.entcs_next.owner == self)
- {
- n = ent.entcs_next.entcs_next;
- remove(ent.entcs_next);
- ent.entcs_next = n;
- }
+ remove(self.entcs);
+ self.entcs = world;
};
More information about the nexuiz-commits
mailing list