Debian Codegraph @

code/game/g_active.c

raw ◀ ▶
1 Debian patch touch this file
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 //
23
24 #include "g_local.h"
25
26
27 /*
28 ===============
29 G_DamageFeedback
30
31 Called just before a snapshot is sent to the given player.
32 Totals up all damage and generates both the player_state_t
33 damage values to that client for pain blends and kicks, and
34 global pain sound events for all clients.
35 ===============
36 */
37 void P_DamageFeedback( gentity_t *player ) {
38 gclient_t *client;
39 float count;
40 vec3_t angles;
41
42 client = player->client;
43 if ( client->ps.pm_type == PM_DEAD ) {
44 return;
45 }
46
47 // total points of damage shot at the player this frame
48 count = client->damage_blood + client->damage_armor;
49 if ( count == 0 ) {
50 return; // didn't take any damage
51 }
52
53 if ( count > 255 ) {
54 count = 255;
55 }
56
57 // send the information to the client
58
59 // world damage (falling, slime, etc) uses a special code
60 // to make the blend blob centered instead of positional
61 if ( client->damage_fromWorld ) {
62 client->ps.damagePitch = 255;
63 client->ps.damageYaw = 255;
64
65 client->damage_fromWorld = qfalse;
66 } else {
67 vectoangles( client->damage_from, angles );
68 client->ps.damagePitch = angles[PITCH]/360.0 * 256;
69 client->ps.damageYaw = angles[YAW]/360.0 * 256;
70 }
71
72 // play an apropriate pain sound
73 if ( (level.time > player->pain_debounce_time) && !(player->flags & FL_GODMODE) ) {
74 player->pain_debounce_time = level.time + 700;
75 G_AddEvent( player, EV_PAIN, player->health );
76 client->ps.damageEvent++;
77 }
78
79
80 client->ps.damageCount = count;
81
82 //
83 // clear totals
84 //
85 client->damage_blood = 0;
86 client->damage_armor = 0;
87 client->damage_knockback = 0;
88 }
89
90
91
92 /*
93 =============
94 P_WorldEffects
95
96 Check for lava / slime contents and drowning
97 =============
98 */
99 void P_WorldEffects( gentity_t *ent ) {
100 qboolean envirosuit;
101 int waterlevel;
102
103 if ( ent->client->noclip ) {
104 ent->client->airOutTime = level.time + 12000; // don't need air
105 return;
106 }
107
108 waterlevel = ent->waterlevel;
109
110 envirosuit = ent->client->ps.powerups[PW_BATTLESUIT] > level.time;
111
112 //
113 // check for drowning
114 //
115 if ( waterlevel == 3 ) {
116 // envirosuit give air
117 if ( envirosuit ) {
118 ent->client->airOutTime = level.time + 10000;
119 }
120
121 // if out of air, start drowning
122 if ( ent->client->airOutTime < level.time) {
123 // drown!
124 ent->client->airOutTime += 1000;
125 if ( ent->health > 0 ) {
126 // take more damage the longer underwater
127 ent->damage += 2;
128 if (ent->damage > 15)
129 ent->damage = 15;
130
131 // don't play a normal pain sound
132 ent->pain_debounce_time = level.time + 200;
133
134 G_Damage (ent, NULL, NULL, NULL, NULL,
135 ent->damage, DAMAGE_NO_ARMOR, MOD_WATER);
136 }
137 }
138 } else {
139 ent->client->airOutTime = level.time + 12000;
140 ent->damage = 2;
141 }
142
143 //
144 // check for sizzle damage (move to pmove?)
145 //
146 if (waterlevel &&
147 (ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) {
148 if (ent->health > 0
149 && ent->pain_debounce_time <= level.time ) {
150
151 if ( envirosuit ) {
152 G_AddEvent( ent, EV_POWERUP_BATTLESUIT, 0 );
153 } else {
154 if (ent->watertype & CONTENTS_LAVA) {
155 G_Damage (ent, NULL, NULL, NULL, NULL,
156 30*waterlevel, 0, MOD_LAVA);
157 }
158
159 if (ent->watertype & CONTENTS_SLIME) {
160 G_Damage (ent, NULL, NULL, NULL, NULL,
161 10*waterlevel, 0, MOD_SLIME);
162 }
163 }
164 }
165 }
166 }
167
168
169
170 /*
171 ===============
172 G_SetClientSound
173 ===============
174 */
175 void G_SetClientSound( gentity_t *ent ) {
176 if( ent->s.eFlags & EF_TICKING ) {
177 ent->client->ps.loopSound = G_SoundIndex( "sound/weapons/proxmine/wstbtick.wav");
178 }
179 else
180 if (ent->waterlevel && (ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) {
181 ent->client->ps.loopSound = level.snd_fry;
182 } else {
183 ent->client->ps.loopSound = 0;
184 }
185 }
186
187
188
189 //==============================================================
190
191 /*
192 ==============
193 ClientImpacts
194 ==============
195 */
196 void ClientImpacts( gentity_t *ent, pmove_t *pm ) {
197 int i, j;
198 trace_t trace;
199 gentity_t *other;
200
201 memset( &trace, 0, sizeof( trace ) );
202 for (i=0 ; i<pm->numtouch ; i++) {
203 for (j=0 ; j<i ; j++) {
204 if (pm->touchents[j] == pm->touchents[i] ) {
205 break;
206 }
207 }
208 if (j != i) {
209 continue; // duplicated
210 }
211 other = &g_entities[ pm->touchents[i] ];
212
213 if ( ( ent->r.svFlags & SVF_BOT ) && ( ent->touch ) ) {
214 ent->touch( ent, other, &trace );
215 }
216
217 if ( !other->touch ) {
218 continue;
219 }
220
221 other->touch( other, ent, &trace );
222 }
223
224 }
225
226 /*
227 ============
228 G_TouchTriggers
229
230 Find all trigger entities that ent's current position touches.
231 Spectators will only interact with teleporters.
232 ============
233 */
234 void G_TouchTriggers( gentity_t *ent ) {
235 int i, num;
236 int touch[MAX_GENTITIES];
237 gentity_t *hit;
238 trace_t trace;
239 vec3_t mins, maxs;
240 static vec3_t range = { 40, 40, 52 };
241
242 if ( !ent->client ) {
243 return;
244 }
245
246 //ELIMINATION LMS
247 // dead clients don't activate triggers! The reason our pm_spectators can't do anything
248 if ( ent->client->ps.stats[STAT_HEALTH] <= 0 && ent->client->ps.pm_type != PM_SPECTATOR) {
249 return;
250 }
251
252 VectorSubtract( ent->client->ps.origin, range, mins );
253 VectorAdd( ent->client->ps.origin, range, maxs );
254
255 num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES );
256
257 // can't use ent->absmin, because that has a one unit pad
258 VectorAdd( ent->client->ps.origin, ent->r.mins, mins );
259 VectorAdd( ent->client->ps.origin, ent->r.maxs, maxs );
260
261 for ( i=0 ; i<num ; i++ ) {
262 hit = &g_entities[touch[i]];
263
264 if ( !hit->touch && !ent->touch ) {
265 continue;
266 }
267 if ( !( hit->r.contents & CONTENTS_TRIGGER ) ) {
268 continue;
269 }
270
271 // ignore most entities if a spectator
272 if ( (ent->client->sess.sessionTeam == TEAM_SPECTATOR) || ent->client->ps.pm_type == PM_SPECTATOR ) {
273 if ( hit->s.eType != ET_TELEPORT_TRIGGER &&
274 // this is ugly but adding a new ET_? type will
275 // most likely cause network incompatibilities
276 //We need to stop eliminated players from opening doors somewhere else /Sago007 20070814
277 hit->touch != Touch_DoorTrigger ) {
278 continue;
279 }
280 }
281
282 // use seperate code for determining if an item is picked up
283 // so you don't have to actually contact its bounding box
284 if ( hit->s.eType == ET_ITEM ) {
285 if ( !BG_PlayerTouchesItem( &ent->client->ps, &hit->s, level.time ) ) {
286 continue;
287 }
288 } else {
289 if ( !trap_EntityContact( mins, maxs, hit ) ) {
290 continue;
291 }
292 }
293
294 memset( &trace, 0, sizeof(trace) );
295
296 if ( hit->touch ) {
297 hit->touch (hit, ent, &trace);
298 }
299
300 if ( ( ent->r.svFlags & SVF_BOT ) && ( ent->touch ) ) {
301 ent->touch( ent, hit, &trace );
302 }
303 }
304
305 // if we didn't touch a jump pad this pmove frame
306 if ( ent->client->ps.jumppad_frame != ent->client->ps.pmove_framecount ) {
307 ent->client->ps.jumppad_frame = 0;
308 ent->client->ps.jumppad_ent = 0;
309 }
310 }
311
312 /*
313 =================
314 SpectatorThink
315 =================
316 */
317 void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) {
318 pmove_t pm;
319 gclient_t *client;
320
321 client = ent->client;
322
323 if ( ( g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION) &&
324 client->sess.spectatorState != SPECTATOR_FOLLOW &&
325 g_elimination_lockspectator.integer>1 &&
326 ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
327 Cmd_FollowCycle_f(ent);
328 }
329
330 if ( client->sess.spectatorState != SPECTATOR_FOLLOW ) {
331 client->ps.pm_type = PM_SPECTATOR;
332 client->ps.speed = 400; // faster than normal
333
334 // set up for pmove
335 memset (&pm, 0, sizeof(pm));
336 pm.ps = &client->ps;
337 pm.cmd = *ucmd;
338 pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; // spectators can fly through bodies
339 pm.trace = trap_Trace;
340 pm.pointcontents = trap_PointContents;
341
342 // perform a pmove
343 Pmove (&pm);
344 // save results of pmove
345 VectorCopy( client->ps.origin, ent->s.origin );
346
347 G_TouchTriggers( ent );
348 trap_UnlinkEntity( ent );
349 }
350
351 /* Stopped players from going into follow mode in B5, should be fixed in B9
352 if(ent->client->sess.sessionTeam != TEAM_SPECTATOR && g_gametype.integer>=GT_ELIMINATION && g_gametype.integer<=GT_LMS)
353 return;
354 */
355
356 client->oldbuttons = client->buttons;
357 client->buttons = ucmd->buttons;
358
359 //KK-OAX Changed to keep followcycle functional
360 // attack button cycles through spectators
361 if ( ( client->buttons & BUTTON_ATTACK ) && ! ( client->oldbuttons & BUTTON_ATTACK ) ) {
362 Cmd_FollowCycle_f( ent );
363 }
364
365 if ( ( client->buttons & BUTTON_USE_HOLDABLE ) && ! ( client->oldbuttons & BUTTON_USE_HOLDABLE ) ) {
366 if ( ( g_gametype.integer == GT_ELIMINATION || g_gametype.integer == GT_CTF_ELIMINATION) &&
367 g_elimination_lockspectator.integer>1 &&
368 ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
369 return;
370 }
371 StopFollowing(ent);
372 }
373 }
374
375
376
377 /*
378 =================
379 ClientInactivityTimer
380
381 Returns qfalse if the client is dropped
382 =================
383 */
384 qboolean ClientInactivityTimer( gclient_t *client ) {
385 if ( ! g_inactivity.integer ) {
386 // give everyone some time, so if the operator sets g_inactivity during
387 // gameplay, everyone isn't kicked
388 client->inactivityTime = level.time + 60 * 1000;
389 client->inactivityWarning = qfalse;
390 } else if ( client->pers.cmd.forwardmove ||
391 client->pers.cmd.rightmove ||
392 client->pers.cmd.upmove ||
393 (client->pers.cmd.buttons & BUTTON_ATTACK) ) {
394 client->inactivityTime = level.time + g_inactivity.integer * 1000;
395 client->inactivityWarning = qfalse;
396 } else if ( !client->pers.localClient ) {
397 if ( level.time > client->inactivityTime ) {
398 trap_DropClient( client - level.clients, "Dropped due to inactivity" );
399 return qfalse;
400 }
401 if ( level.time > client->inactivityTime - 10000 && !client->inactivityWarning ) {
402 client->inactivityWarning = qtrue;
403 trap_SendServerCommand( client - level.clients, "cp \"Ten seconds until inactivity drop!\n\"" );
404 }
405 }
406 return qtrue;
407 }
408
409 /*
410 ==================
411 ClientTimerActions
412
413 Actions that happen once a second
414 ==================
415 */
416 void ClientTimerActions( gentity_t *ent, int msec ) {
417 gclient_t *client;
418 int maxHealth;
419
420 client = ent->client;
421 client->timeResidual += msec;
422
423 while ( client->timeResidual >= 1000 ) {
424 client->timeResidual -= 1000;
425
426 //Stop in elimination!!!
427 if (client->ps.pm_flags & PMF_ELIMWARMUP)
428 continue;
429
430 // regenerate
•431 #ifdef HAVE_STAT_PERSISTANT_POWERUP
432 if( bg_itemlist[client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {
433 maxHealth = client->ps.stats[STAT_MAX_HEALTH] / 2;
434 }
•435 else
436 #endif
437 if ( client->ps.powerups[PW_REGEN] ) {
438 maxHealth = client->ps.stats[STAT_MAX_HEALTH];
439 }
440 else {
441 maxHealth = 0;
442 }
443 if( maxHealth ) {
444 if ( ent->health < maxHealth ) {
445 ent->health += 15;
446 if ( ent->health > maxHealth * 1.1 ) {
447 ent->health = maxHealth * 1.1;
448 }
449 G_AddEvent( ent, EV_POWERUP_REGEN, 0 );
450 } else if ( ent->health < maxHealth * 2) {
451 ent->health += 5;
452 if ( ent->health > maxHealth * 2 ) {
453 ent->health = maxHealth * 2;
454 }
455 G_AddEvent( ent, EV_POWERUP_REGEN, 0 );
456 }
457 } else {
458 // count down health when over max
459 if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] ) {
460 ent->health--;
461 }
462 //Start killing players in LMS, if we are in overtime
463 if(g_elimination_roundtime.integer&&g_gametype.integer==GT_LMS && TeamHealthCount( -1, TEAM_FREE ) != ent->health &&(level.roundNumber==level.roundNumberStarted)&&(level.time>=level.roundStartTime+1000*g_elimination_roundtime.integer)) {
464 ent->damage=5;
465 G_Damage (ent, NULL, NULL, NULL, NULL,
466 ent->damage, DAMAGE_NO_ARMOR, MOD_UNKNOWN);
467 }
468 else
469 if ( ent->health < client->ps.stats[STAT_MAX_HEALTH] ) {
470 ent->health+=g_regen.integer;
471 if(ent->health>client->ps.stats[STAT_MAX_HEALTH])
472 ent->health= client->ps.stats[STAT_MAX_HEALTH];
473 }
474 }
475
476 // count down armor when over max
477 if ( client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH] ) {
478 client->ps.stats[STAT_ARMOR]--;
479 }
480 }
•481 #ifdef HAVE_STAT_PERSISTANT_POWERUP
482 if( bg_itemlist[client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_AMMOREGEN ) {
483 int w, max, inc, t, i;
484 int weapList[]={WP_MACHINEGUN,WP_SHOTGUN,WP_GRENADE_LAUNCHER,WP_ROCKET_LAUNCHER,WP_LIGHTNING,WP_RAILGUN,WP_PLASMAGUN,WP_BFG,WP_NAILGUN,WP_PROX_LAUNCHER,WP_CHAINGUN};
485 int weapCount = sizeof(weapList) / sizeof(int);
486 //
487 for (i = 0; i < weapCount; i++) {
488 w = weapList[i];
489
490 switch(w) {
491 case WP_MACHINEGUN: max = 50; inc = 4; t = 1000; break;
492 case WP_SHOTGUN: max = 10; inc = 1; t = 1500; break;
493 case WP_GRENADE_LAUNCHER: max = 10; inc = 1; t = 2000; break;
494 case WP_ROCKET_LAUNCHER: max = 10; inc = 1; t = 1750; break;
495 case WP_LIGHTNING: max = 50; inc = 5; t = 1500; break;
496 case WP_RAILGUN: max = 10; inc = 1; t = 1750; break;
497 case WP_PLASMAGUN: max = 50; inc = 5; t = 1500; break;
498 case WP_BFG: max = 10; inc = 1; t = 4000; break;
499 case WP_NAILGUN: max = 10; inc = 1; t = 1250; break;
500 case WP_PROX_LAUNCHER: max = 5; inc = 1; t = 2000; break;
501 case WP_CHAINGUN: max = 100; inc = 5; t = 1000; break;
502 default: max = 0; inc = 0; t = 1000; break;
503 }
504 client->ammoTimes[w] += msec;
505 if ( client->ps.ammo[w] >= max ) {
506 client->ammoTimes[w] = 0;
507 }
508 if ( client->ammoTimes[w] >= t ) {
509 while ( client->ammoTimes[w] >= t )
510 client->ammoTimes[w] -= t;
511 client->ps.ammo[w] += inc;
512 if ( client->ps.ammo[w] > max ) {
513 client->ps.ammo[w] = max;
514 }
515 }
516 }
517 }
•518 #endif
519 }
520
521 /*
522 ====================
523 ClientIntermissionThink
524 ====================
525 */
526 void ClientIntermissionThink( gclient_t *client ) {
527 client->ps.eFlags &= ~EF_TALK;
528 client->ps.eFlags &= ~EF_FIRING;
529
530 // the level will exit when everyone wants to or after timeouts
531
532 if( g_entities[client->ps.clientNum].r.svFlags & SVF_BOT )
533 return; //Bots cannot mark themself as ready
534
535 // swap and latch button actions
536 client->oldbuttons = client->buttons;
537 client->buttons = client->pers.cmd.buttons;
538 if ( client->buttons & ( BUTTON_ATTACK | BUTTON_USE_HOLDABLE ) & ( client->oldbuttons ^ client->buttons ) ) {
539 // this used to be an ^1 but once a player says ready, it should stick
540 client->readyToExit = 1;
541 }
542 }
543
544
545 /*
546 ================
547 ClientEvents
548
549 Events will be passed on to the clients for presentation,
550 but any server game effects are handled here
551 ================
552 */
553 void ClientEvents( gentity_t *ent, int oldEventSequence ) {
554 int i, j;
555 int event;
556 gclient_t *client;
557 int damage;
558 vec3_t dir;
559 vec3_t origin, angles;
560 // qboolean fired;
561 gitem_t *item;
562 gentity_t *drop;
563
564 client = ent->client;
565
566 if ( oldEventSequence < client->ps.eventSequence - MAX_PS_EVENTS ) {
567 oldEventSequence = client->ps.eventSequence - MAX_PS_EVENTS;
568 }
569 for ( i = oldEventSequence ; i < client->ps.eventSequence ; i++ ) {
570 event = client->ps.events[ i & (MAX_PS_EVENTS-1) ];
571
572 switch ( event ) {
573 case EV_FALL_MEDIUM:
574 case EV_FALL_FAR:
575 if ( ent->s.eType != ET_PLAYER ) {
576 break; // not in the player model
577 }
578 if ( g_dmflags.integer & DF_NO_FALLING ) {
579 break;
580 }
581 if ( event == EV_FALL_FAR ) {
582 damage = 10;
583 } else {
584 damage = 5;
585 }
586 VectorSet (dir, 0, 0, 1);
587 ent->pain_debounce_time = level.time + 200; // no normal pain sound
588 G_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING);
589 break;
590
591 case EV_FIRE_WEAPON:
592 FireWeapon( ent );
593 break;
594
595 case EV_USE_ITEM1: // teleporter
596 // drop flags in CTF
597 item = NULL;
598 j = 0;
599
600 if ( ent->client->ps.powerups[ PW_REDFLAG ] ) {
601 item = BG_FindItemForPowerup( PW_REDFLAG );
602 j = PW_REDFLAG;
603 } else if ( ent->client->ps.powerups[ PW_BLUEFLAG ] ) {
604 item = BG_FindItemForPowerup( PW_BLUEFLAG );
605 j = PW_BLUEFLAG;
606 } else if ( ent->client->ps.powerups[ PW_NEUTRALFLAG ] ) {
607 item = BG_FindItemForPowerup( PW_NEUTRALFLAG );
608 j = PW_NEUTRALFLAG;
609 }
610
611 if ( item ) {
612 drop = Drop_Item( ent, item, 0 );
613 // decide how many seconds it has left
614 drop->count = ( ent->client->ps.powerups[ j ] - level.time ) / 1000;
615 if ( drop->count < 1 ) {
616 drop->count = 1;
617 }
618
619 ent->client->ps.powerups[ j ] = 0;
620 }
621
622 if ( g_gametype.integer == GT_HARVESTER ) {
623 if ( ent->client->ps.generic1 > 0 ) {
624 if ( ent->client->sess.sessionTeam == TEAM_RED ) {
625 item = BG_FindItem( "Blue Cube" );
626 } else {
627 item = BG_FindItem( "Red Cube" );
628 }
629 if ( item ) {
630 for ( j = 0; j < ent->client->ps.generic1; j++ ) {
631 drop = Drop_Item( ent, item, 0 );
632 if ( ent->client->sess.sessionTeam == TEAM_RED ) {
633 drop->spawnflags = TEAM_BLUE;
634 } else {
635 drop->spawnflags = TEAM_RED;
636 }
637 }
638 }
639 ent->client->ps.generic1 = 0;
640 }
641 }
642 SelectSpawnPoint( ent->client->ps.origin, origin, angles );
643 TeleportPlayer( ent, origin, angles );
644 break;
645
646 case EV_USE_ITEM2: // medkit
647 ent->health = ent->client->ps.stats[STAT_MAX_HEALTH] + 25;
648
649 break;
650
651 case EV_USE_ITEM3: // kamikaze
652 // make sure the invulnerability is off
653 ent->client->invulnerabilityTime = 0;
654 // start the kamikze
655 G_StartKamikaze( ent );
656 break;
657
658 case EV_USE_ITEM4: // portal
659 if( ent->client->portalID ) {
660 DropPortalSource( ent );
661 }
662 else {
663 DropPortalDestination( ent );
664 }
665 break;
666 case EV_USE_ITEM5: // invulnerability
667 ent->client->invulnerabilityTime = level.time + 10000;
668 break;
669
670 default:
671 break;
672 }
673 }
674
675 }
676
677 /*
678 ==============
679 StuckInOtherClient
680 ==============
681 */
682 static int StuckInOtherClient(gentity_t *ent) {
683 int i;
684 gentity_t *ent2;
685
686 ent2 = &g_entities[0];
687 for ( i = 0; i < MAX_CLIENTS; i++, ent2++ ) {
688 if ( ent2 == ent ) {
689 continue;
690 }
691 if ( !ent2->inuse ) {
692 continue;
693 }
694 if ( !ent2->client ) {
695 continue;
696 }
697 if ( ent2->health <= 0 ) {
698 continue;
699 }
700 //
701 if (ent2->r.absmin[0] > ent->r.absmax[0])
702 continue;
703 if (ent2->r.absmin[1] > ent->r.absmax[1])
704 continue;
705 if (ent2->r.absmin[2] > ent->r.absmax[2])
706 continue;
707 if (ent2->r.absmax[0] < ent->r.absmin[0])
708 continue;
709 if (ent2->r.absmax[1] < ent->r.absmin[1])
710 continue;
711 if (ent2->r.absmax[2] < ent->r.absmin[2])
712 continue;
713 return qtrue;
714 }
715 return qfalse;
716 }
717
718 void BotTestSolid(vec3_t origin);
719
720 /*
721 ==============
722 SendPendingPredictableEvents
723 ==============
724 */
725 void SendPendingPredictableEvents( playerState_t *ps ) {
726 gentity_t *t;
727 int event, seq;
728 int extEvent, number;
729
730 // if there are still events pending
731 if ( ps->entityEventSequence < ps->eventSequence ) {
732 // create a temporary entity for this event which is sent to everyone
733 // except the client who generated the event
734 seq = ps->entityEventSequence & (MAX_PS_EVENTS-1);
735 event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 );
736 // set external event to zero before calling BG_PlayerStateToEntityState
737 extEvent = ps->externalEvent;
738 ps->externalEvent = 0;
739 // create temporary entity for event
740 t = G_TempEntity( ps->origin, event );
741 number = t->s.number;
742 BG_PlayerStateToEntityState( ps, &t->s, qtrue );
743 t->s.number = number;
744 t->s.eType = ET_EVENTS + event;
745 t->s.eFlags |= EF_PLAYER_EVENT;
746 t->s.otherEntityNum = ps->clientNum;
747 // send to everyone except the client who generated the event
748 t->r.svFlags |= SVF_NOTSINGLECLIENT;
749 t->r.singleClient = ps->clientNum;
750 // set back external event
751 ps->externalEvent = extEvent;
752 }
753 }
754
755 /*
756 ==============
757 ClientThink
758
759 This will be called once for each client frame, which will
760 usually be a couple times for each server frame on fast clients.
761
762 If "g_synchronousClients 1" is set, this will be called exactly
763 once for each server frame, which makes for smooth demo recording.
764 ==============
765 */
766 void ClientThink_real( gentity_t *ent ) {
767 gclient_t *client;
768 pmove_t pm;
769 int oldEventSequence;
770 int msec;
771 usercmd_t *ucmd;
772
773 client = ent->client;
774
775 // don't think if the client is not yet connected (and thus not yet spawned in)
776 if (client->pers.connected != CON_CONNECTED) {
777 return;
778 }
779 // mark the time, so the connection sprite can be removed
780 ucmd = &ent->client->pers.cmd;
781
782 // sanity check the command time to prevent speedup cheating
783 if ( ucmd->serverTime > level.time + 200 ) {
784 ucmd->serverTime = level.time + 200;
785 // G_Printf("serverTime <<<<<\n" );
786 }
787 if ( ucmd->serverTime < level.time - 1000 ) {
788 ucmd->serverTime = level.time - 1000;
789 // G_Printf("serverTime >>>>>\n" );
790 }
791
792 //Here comes the unlagged bit!
793 //unlagged - backward reconciliation #4
794 // frameOffset should be about the number of milliseconds into a frame
795 // this command packet was received, depending on how fast the server
796 // does a G_RunFrame()
797 client->frameOffset = trap_Milliseconds() - level.frameStartTime;
798 //unlagged - backward reconciliation #4
799
800
801 //unlagged - lag simulation #3
802 // if the client wants to simulate outgoing packet loss
803 /* if ( client->pers.plOut ) {
804 // see if a random value is below the threshhold
805 float thresh = (float)client->pers.plOut / 100.0f;
806 if ( random() < thresh ) {
807 // do nothing at all if it is - this is a lost command
808 return;
809 }
810 }*/
811 //unlagged - lag simulation #3
812
813
814 //unlagged - true ping
815 // save the estimated ping in a queue for averaging later
816
817 // we use level.previousTime to account for 50ms lag correction
818 // besides, this will turn out numbers more like what players are used to
819 client->pers.pingsamples[client->pers.samplehead] = level.previousTime + client->frameOffset - ucmd->serverTime;
820 client->pers.samplehead++;
821 if ( client->pers.samplehead >= NUM_PING_SAMPLES ) {
822 client->pers.samplehead -= NUM_PING_SAMPLES;
823 }
824
825 // initialize the real ping
826 if ( g_truePing.integer ) {
827 int i, sum = 0;
828
829 // get an average of the samples we saved up
830 for ( i = 0; i < NUM_PING_SAMPLES; i++ ) {
831 sum += client->pers.pingsamples[i];
832 }
833
834 client->pers.realPing = sum / NUM_PING_SAMPLES;
835 }
836 else {
837 // if g_truePing is off, use the normal ping
838 client->pers.realPing = client->ps.ping;
839 }
840 //unlagged - true ping
841
842
843 //unlagged - lag simulation #2
844 // keep a queue of past commands
845 /* client->pers.cmdqueue[client->pers.cmdhead] = client->pers.cmd;
846 client->pers.cmdhead++;
847 if ( client->pers.cmdhead >= MAX_LATENT_CMDS ) {
848 client->pers.cmdhead -= MAX_LATENT_CMDS;
849 }
850
851 // if the client wants latency in commands (client-to-server latency)
852 if ( client->pers.latentCmds ) {
853 // save the actual command time
854 int time = ucmd->serverTime;
855
856 // find out which index in the queue we want
857 int cmdindex = client->pers.cmdhead - client->pers.latentCmds - 1;
858 while ( cmdindex < 0 ) {
859 cmdindex += MAX_LATENT_CMDS;
860 }
861
862 // read in the old command
863 client->pers.cmd = client->pers.cmdqueue[cmdindex];
864
865 // adjust the real ping to reflect the new latency
866 client->pers.realPing += time - ucmd->serverTime;
867 }*/
868 //unlagged - lag simulation #2
869
870
871 //unlagged - backward reconciliation #4
872 // save the command time *before* pmove_fixed messes with the serverTime,
873 // and *after* lag simulation messes with it :)
874 // attackTime will be used for backward reconciliation later (time shift)
875 client->attackTime = ucmd->serverTime;
876 //unlagged - backward reconciliation #4
877
878
879 //unlagged - smooth clients #1
880 // keep track of this for later - we'll use this to decide whether or not
881 // to send extrapolated positions for this client
882 client->lastUpdateFrame = level.framenum;
883 //unlagged - smooth clients #1
884
885
886 //unlagged - lag simulation #1
887 // if the client is adding latency to received snapshots (server-to-client latency)
888 /*if ( client->pers.latentSnaps ) {
889 // adjust the real ping
890 client->pers.realPing += client->pers.latentSnaps * (1000 / sv_fps.integer);
891 // adjust the attack time so backward reconciliation will work
892 client->attackTime -= client->pers.latentSnaps * (1000 / sv_fps.integer);
893 }*/
894 //unlagged - lag simulation #1
895
896
897 //unlagged - true ping
898 // make sure the true ping is over 0 - with cl_timenudge it can be less
899 if ( client->pers.realPing < 0 ) {
900 client->pers.realPing = 0;
901 }
902 //unlagged - true ping
903
904 msec = ucmd->serverTime - client->ps.commandTime;
905 // following others may result in bad times, but we still want
906 // to check for follow toggles
907 if ( msec < 1 && client->sess.spectatorState != SPECTATOR_FOLLOW ) {
908 return;
909 }
910 if ( msec > 200 ) {
911 msec = 200;
912 }
913
914 if ( pmove_msec.integer < 8 ) {
915 trap_Cvar_Set("pmove_msec", "8");
916 }
917 else if (pmove_msec.integer > 33) {
918 trap_Cvar_Set("pmove_msec", "33");
919 }
920
921 if ( pmove_fixed.integer || client->pers.pmoveFixed ) {
922 ucmd->serverTime = ((ucmd->serverTime + pmove_msec.integer-1) / pmove_msec.integer) * pmove_msec.integer;
923 //if (ucmd->serverTime - client->ps.commandTime <= 0)
924 // return;
925 }
926
927 //
928 // check for exiting intermission
929 //
930 if ( level.intermissiontime ) {
931 ClientIntermissionThink( client );
932 return;
933 }
934
935 // spectators don't do much
936 if ( (client->sess.sessionTeam == TEAM_SPECTATOR) || client->isEliminated ) {
937 if ( client->sess.spectatorState == SPECTATOR_SCOREBOARD ) {
938 return;
939 }
940 SpectatorThink( ent, ucmd );
941 return;
942 }
943
944 // check for inactivity timer, but never drop the local client of a non-dedicated server
945 if ( !ClientInactivityTimer( client ) ) {
946 return;
947 }
948
949 // clear the rewards if time
950 if ( level.time > client->rewardTime ) {
951 client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );
952 }
953
954 if ( client->noclip ) {
955 client->ps.pm_type = PM_NOCLIP;
956 } else if ( client->ps.stats[STAT_HEALTH] <= 0 ) {
957 client->ps.pm_type = PM_DEAD;
958 } else {
959 client->ps.pm_type = PM_NORMAL;
960 }
961
962 client->ps.gravity = g_gravity.value*g_gravityModifier.value;
963
964 // set speed
965 client->ps.speed = g_speed.value;
966
•967 #ifdef HAVE_STAT_PERSISTANT_POWERUP
968 if( bg_itemlist[client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) {
969 client->ps.speed *= 1.5;
970 }
971 else
•972 #endif
973 if ( client->ps.powerups[PW_HASTE] ) {
974 client->ps.speed *= 1.3;
975 }
976
977 // Let go of the hook if we aren't firing
978 if ( client->ps.weapon == WP_GRAPPLING_HOOK &&
979 client->hook && !( ucmd->buttons & BUTTON_ATTACK ) ) {
980 Weapon_HookFree(client->hook);
981 }
982
983 // set up for pmove
984 oldEventSequence = client->ps.eventSequence;
985
986 memset (&pm, 0, sizeof(pm));
987
988 // check for the hit-scan gauntlet, don't let the action
989 // go through as an attack unless it actually hits something
990 if ( client->ps.weapon == WP_GAUNTLET && !( ucmd->buttons & BUTTON_TALK ) &&
991 ( ucmd->buttons & BUTTON_ATTACK ) && client->ps.weaponTime <= 0 ) {
992 pm.gauntletHit = CheckGauntletAttack( ent );
993 }
994
995 if ( ent->flags & FL_FORCE_GESTURE ) {
996 ent->flags &= ~FL_FORCE_GESTURE;
997 ent->client->pers.cmd.buttons |= BUTTON_GESTURE;
998 }
999
1000 // check for invulnerability expansion before doing the Pmove
1001 if (client->ps.powerups[PW_INVULNERABILITY] ) {
1002 if ( !(client->ps.pm_flags & PMF_INVULEXPAND) ) {
1003 vec3_t mins = { -42, -42, -42 };
1004 vec3_t maxs = { 42, 42, 42 };
1005 vec3_t oldmins, oldmaxs;
1006
1007 VectorCopy (ent->r.mins, oldmins);
1008 VectorCopy (ent->r.maxs, oldmaxs);
1009 // expand
1010 VectorCopy (mins, ent->r.mins);
1011 VectorCopy (maxs, ent->r.maxs);
1012 trap_LinkEntity(ent);
1013 // check if this would get anyone stuck in this player
1014 if ( !StuckInOtherClient(ent) ) {
1015 // set flag so the expanded size will be set in PM_CheckDuck
1016 client->ps.pm_flags |= PMF_INVULEXPAND;
1017 }
1018 // set back
1019 VectorCopy (oldmins, ent->r.mins);
1020 VectorCopy (oldmaxs, ent->r.maxs);
1021 trap_LinkEntity(ent);
1022 }
1023 }
1024
1025 pm.ps = &client->ps;
1026 pm.cmd = *ucmd;
1027 if ( pm.ps->pm_type == PM_DEAD ) {
1028 pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY;
1029 }
1030 else if ( ent->r.svFlags & SVF_BOT ) {
1031 pm.tracemask = MASK_PLAYERSOLID | CONTENTS_BOTCLIP;
1032 }
1033 else {
1034 pm.tracemask = MASK_PLAYERSOLID;
1035 }
1036 pm.trace = trap_Trace;
1037 pm.pointcontents = trap_PointContents;
1038 pm.debugLevel = g_debugMove.integer;
1039 pm.noFootsteps = ( g_dmflags.integer & DF_NO_FOOTSTEPS ) > 0;
1040
1041 pm.pmove_fixed = pmove_fixed.integer | client->pers.pmoveFixed;
1042 pm.pmove_msec = pmove_msec.integer;
1043 pm.pmove_float = pmove_float.integer;
1044 pm.pmove_flags = g_dmflags.integer;
1045
1046 VectorCopy( client->ps.origin, client->oldOrigin );
1047
1048 #ifdef MISSIONPACK
1049 if (level.intermissionQueued != 0 && g_singlePlayer.integer) {
1050 if ( level.time - level.intermissionQueued >= 1000 ) {
1051 pm.cmd.buttons = 0;
1052 pm.cmd.forwardmove = 0;
1053 pm.cmd.rightmove = 0;
1054 pm.cmd.upmove = 0;
1055 if ( level.time - level.intermissionQueued >= 2000 && level.time - level.intermissionQueued <= 2500 ) {
1056 trap_SendConsoleCommand( EXEC_APPEND, "centerview\n");
1057 }
1058 ent->client->ps.pm_type = PM_SPINTERMISSION;
1059 }
1060 }
1061 #endif
1062 Pmove (&pm);
1063
1064 // save results of pmove
1065 if ( ent->client->ps.eventSequence != oldEventSequence ) {
1066 ent->eventTime = level.time;
1067 }
1068 //unlagged - smooth clients #2
1069 // clients no longer do extrapolation if cg_smoothClients is 1, because
1070 // skip correction is all handled server-side now
1071 // since that's the case, it makes no sense to store the extra info
1072 // in the client's snapshot entity, so let's save a little bandwidth
1073 /*
1074 if (g_smoothClients.integer) {
1075 BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue );
1076 }
1077 else {
1078 */
1079 BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue );
1080 // }
1081 //unlagged - smooth clients #2
1082 SendPendingPredictableEvents( &ent->client->ps );
1083
1084 if ( !( ent->client->ps.eFlags & EF_FIRING ) ) {
1085 client->fireHeld = qfalse; // for grapple
1086 }
1087
1088 // use the snapped origin for linking so it matches client predicted versions
1089 VectorCopy( ent->s.pos.trBase, ent->r.currentOrigin );
1090
1091 VectorCopy (pm.mins, ent->r.mins);
1092 VectorCopy (pm.maxs, ent->r.maxs);
1093
1094 ent->waterlevel = pm.waterlevel;
1095 ent->watertype = pm.watertype;
1096
1097 // execute client events
1098 ClientEvents( ent, oldEventSequence );
1099
1100 // link entity now, after any personal teleporters have been used
1101 trap_LinkEntity (ent);
1102 if ( !ent->client->noclip ) {
1103 G_TouchTriggers( ent );
1104 }
1105
1106 // NOTE: now copy the exact origin over otherwise clients can be snapped into solid
1107 VectorCopy( ent->client->ps.origin, ent->r.currentOrigin );
1108
1109 //test for solid areas in the AAS file
1110 BotTestAAS(ent->r.currentOrigin);
1111
1112 // touch other objects
1113 ClientImpacts( ent, &pm );
1114
1115 // save results of triggers and client events
1116 if (ent->client->ps.eventSequence != oldEventSequence) {
1117 ent->eventTime = level.time;
1118 }
1119
1120 // swap and latch button actions
1121 client->oldbuttons = client->buttons;
1122 client->buttons = ucmd->buttons;
1123 client->latched_buttons |= client->buttons & ~client->oldbuttons;
1124
1125 // check for respawning
1126 if ( client->ps.stats[STAT_HEALTH] <= 0 ) {
1127 // wait for the attack button to be pressed
1128 // forcerespawn is to prevent users from waiting out powerups
1129 // In Last man standing, we force a quick respawn, since
1130 // the player must be able to loose health
1131 // pressing attack or use is the normal respawn method
1132 if ( ( level.time > client->respawnTime ) &&
1133 ( ( ( g_forcerespawn.integer > 0 ) &&
1134 ( level.time - client->respawnTime > g_forcerespawn.integer * 1000 ) ) ||
1135 ( ( ( g_gametype.integer == GT_LMS ) ||
1136 ( g_gametype.integer == GT_ELIMINATION ) ||
1137 ( g_gametype.integer == GT_CTF_ELIMINATION ) ) &&
1138 ( level.time - client->respawnTime > 0 ) ) ||
1139 ( ucmd->buttons & ( BUTTON_ATTACK | BUTTON_USE_HOLDABLE ) ) ) ) {
1140
1141 ClientRespawn( ent );
1142 }
1143 return;
1144 }
1145
1146 if ( pm.waterlevel <= 1 && pm.ps->groundEntityNum!=ENTITYNUM_NONE && client->lastSentFlyingTime+500>level.time) {
1147 if ( ! (pm.ps->pm_flags & PMF_TIME_KNOCKBACK) ) {
1148 client->lastSentFlying = -1;
1149 }
1150 }
1151
1152 // perform once-a-second actions
1153 ClientTimerActions( ent, msec );
1154 }
1155
1156 /*
1157 ==================
1158 ClientThink
1159
1160 A new command has arrived from the client
1161 ==================
1162 */
1163 void ClientThink( int clientNum ) {
1164 gentity_t *ent;
1165
1166 ent = g_entities + clientNum;
1167 trap_GetUsercmd( clientNum, &ent->client->pers.cmd );
1168
1169 //Unlagged: commented out
1170 // mark the time we got info, so we can display the
1171 // phone jack if they don't get any for a while
1172 //ent->client->lastCmdTime = level.time;
1173
1174 if ( !(ent->r.svFlags & SVF_BOT) && !g_synchronousClients.integer ) {
1175 ClientThink_real( ent );
1176 }
1177 }
1178
1179
1180 void G_RunClient( gentity_t *ent ) {
1181 if ( !(ent->r.svFlags & SVF_BOT) && !g_synchronousClients.integer ) {
1182 return;
1183 }
1184 ent->client->pers.cmd.serverTime = level.time;
1185 ClientThink_real( ent );
1186 }
1187
1188
1189 /*
1190 ==================
1191 SpectatorClientEndFrame
1192
1193 ==================
1194 */
1195 void SpectatorClientEndFrame( gentity_t *ent ) {
1196 gclient_t *cl;
1197 int i, preservedScore[MAX_PERSISTANT]; //for keeping in elimination
1198
1199 // if we are doing a chase cam or a remote view, grab the latest info
1200 if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {
1201 int clientNum, flags;
1202
1203 clientNum = ent->client->sess.spectatorClient;
1204
1205 // team follow1 and team follow2 go to whatever clients are playing
1206 if ( clientNum == -1 ) {
1207 clientNum = level.follow1;
1208 } else if ( clientNum == -2 ) {
1209 clientNum = level.follow2;
1210 }
1211 if ( clientNum >= 0 ) {
1212 cl = &level.clients[ clientNum ];
1213 if ( cl->pers.connected == CON_CONNECTED && cl->sess.sessionTeam != TEAM_SPECTATOR ) {
1214 flags = (cl->ps.eFlags & ~(EF_VOTED | EF_TEAMVOTED)) | (ent->client->ps.eFlags & (EF_VOTED | EF_TEAMVOTED));
1215 //this is here LMS/Elimination goes wrong with player follow
1216 if(ent->client->sess.sessionTeam!=TEAM_SPECTATOR){
1217 for(i = 0; i < MAX_PERSISTANT; i++)
1218 preservedScore[i] = ent->client->ps.persistant[i];
1219 ent->client->ps = cl->ps;
1220 for(i = 0; i < MAX_PERSISTANT; i++)
1221 ent->client->ps.persistant[i] = preservedScore[i];
1222 }
1223 else
1224 ent->client->ps = cl->ps;
1225 ent->client->ps.pm_flags |= PMF_FOLLOW;
1226 ent->client->ps.eFlags = flags;
1227 return;
1228 } else {
1229 // drop them to free spectators unless they are dedicated camera followers
1230 if ( ent->client->sess.spectatorClient >= 0 ) {
1231 ent->client->sess.spectatorState = SPECTATOR_FREE;
1232 ClientBegin( ent->client - level.clients );
1233 }
1234 }
1235 }
1236
1237
1238
1239 }
1240
1241 if ( ent->client->sess.spectatorState == SPECTATOR_SCOREBOARD ) {
1242 ent->client->ps.pm_flags |= PMF_SCOREBOARD;
1243 } else {
1244 ent->client->ps.pm_flags &= ~PMF_SCOREBOARD;
1245 }
1246 }
1247
1248 /*
1249 ==============
1250 ClientEndFrame
1251
1252 Called at the end of each server frame for each connected client
1253 A fast client will have multiple ClientThink for each ClientEdFrame,
1254 while a slow client may have multiple ClientEndFrame between ClientThink.
1255 ==============
1256 */
1257 void ClientEndFrame( gentity_t *ent ) {
1258 int i;
1259 clientPersistant_t *pers;
1260
1261 //unlagged - smooth clients #1
1262 int frames;
1263 //unlagged - smooth clients #1
1264
1265 if ( (ent->client->sess.sessionTeam == TEAM_SPECTATOR) || ent->client->isEliminated ) {
1266 SpectatorClientEndFrame( ent );
1267 return;
1268 }
1269
1270 pers = &ent->client->pers;
1271
1272 // turn off any expired powerups
1273 for ( i = 0 ; i < MAX_POWERUPS ; i++ ) {
1274 if ( ent->client->ps.powerups[ i ] < level.time ) {
1275 ent->client->ps.powerups[ i ] = 0;
1276 }
1277 }
1278
1279 // set powerup for player animation
•1280 #ifdef HAVE_STAT_PERSISTANT_POWERUP
1281 if( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_GUARD ) {
1282 ent->client->ps.powerups[PW_GUARD] = level.time;
1283 }
1284 if( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_SCOUT ) {
1285 ent->client->ps.powerups[PW_SCOUT] = level.time;
1286 }
1287 if( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_DOUBLER ) {
1288 ent->client->ps.powerups[PW_DOUBLER] = level.time;
1289 }
1290 if( bg_itemlist[ent->client->ps.stats[STAT_PERSISTANT_POWERUP]].giTag == PW_AMMOREGEN ) {
1291 ent->client->ps.powerups[PW_AMMOREGEN] = level.time;
1292 }
•1293 #endif
1294 if ( ent->client->invulnerabilityTime > level.time ) {
1295 ent->client->ps.powerups[PW_INVULNERABILITY] = level.time;
1296 }
1297
1298 // save network bandwidth
1299 #if 0
1300 if ( !g_synchronousClients->integer && ent->client->ps.pm_type == PM_NORMAL ) {
1301 // FIXME: this must change eventually for non-sync demo recording
1302 VectorClear( ent->client->ps.viewangles );
1303 }
1304 #endif
1305
1306 //
1307 // If the end of unit layout is displayed, don't give
1308 // the player any normal movement attributes
1309 //
1310 if ( level.intermissiontime ) {
1311 return;
1312 }
1313
1314 // burn from lava, etc
1315 P_WorldEffects (ent);
1316
1317 // apply all the damage taken this frame
1318 P_DamageFeedback (ent);
1319
1320 //Unlagged: Commented out
1321 // add the EF_CONNECTION flag if we haven't gotten commands recently
1322 /*if ( level.time - ent->client->lastCmdTime > 1000 ) {
1323 ent->s.eFlags |= EF_CONNECTION;
1324 } else {
1325 ent->s.eFlags &= ~EF_CONNECTION;
1326 }*/
1327
1328 ent->client->ps.stats[STAT_HEALTH] = ent->health; // FIXME: get rid of ent->health...
1329
1330 G_SetClientSound (ent);
1331
1332 //Unlagged: Always do the else clause
1333 // set the latest infor
1334 /* if (g_smoothClients.integer) {
1335 BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue );
1336 }
1337 else { */
1338 BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue );
1339 // }
1340 SendPendingPredictableEvents( &ent->client->ps );
1341
1342 //unlagged - smooth clients #1
1343 // mark as not missing updates initially
1344 ent->client->ps.eFlags &= ~EF_CONNECTION;
1345
1346 // see how many frames the client has missed
1347 frames = level.framenum - ent->client->lastUpdateFrame - 1;
1348
1349 // don't extrapolate more than two frames
1350 if ( frames > 2 ) {
1351 frames = 2;
1352
1353 // if they missed more than two in a row, show the phone jack
1354 ent->client->ps.eFlags |= EF_CONNECTION;
1355 ent->s.eFlags |= EF_CONNECTION;
1356 }
1357
1358 // did the client miss any frames?
1359 if ( frames > 0 && g_smoothClients.integer ) {
1360 // yep, missed one or more, so extrapolate the player's movement
1361 G_PredictPlayerMove( ent, (float)frames / sv_fps.integer );
1362 // save network bandwidth
1363 SnapVector( ent->s.pos.trBase );
1364 }
1365 //unlagged - smooth clients #1
1366
1367 //unlagged - backward reconciliation #1
1368 // store the client's position for backward reconciliation later
1369 G_StoreHistory( ent );
1370 //unlagged - backward reconciliation #1
1371
1372 // set the bit for the reachability area the client is currently in
1373 // i = trap_AAS_PointReachabilityAreaIndex( ent->client->ps.origin );
1374 // ent->client->areabits[i >> 3] |= 1 << (i & 7);
1375 }
1376
1377