| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include "g_local.h" |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
static vec3_t playerMins = {-15, -15, -24}; |
| 28 |
static vec3_t playerMaxs = {15, 15, 32}; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
void SP_info_player_deathmatch( gentity_t *ent ) { |
| 38 |
int i; |
| 39 |
|
| 40 |
G_SpawnInt( "nobots", "0", &i); |
| 41 |
if ( i ) { |
| 42 |
ent->flags |= FL_NO_BOTS; |
| 43 |
} |
| 44 |
G_SpawnInt( "nohumans", "0", &i ); |
| 45 |
if ( i ) { |
| 46 |
ent->flags |= FL_NO_HUMANS; |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
void SP_info_player_start(gentity_t *ent) { |
| 54 |
ent->classname = "info_player_deathmatch"; |
| 55 |
SP_info_player_deathmatch( ent ); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
void SP_info_player_intermission( gentity_t *ent ) { |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
qboolean SpotWouldTelefrag( gentity_t *spot ) { |
| 82 |
int i, num; |
| 83 |
int touch[MAX_GENTITIES]; |
| 84 |
gentity_t *hit; |
| 85 |
vec3_t mins, maxs; |
| 86 |
|
| 87 |
VectorAdd( spot->s.origin, playerMins, mins ); |
| 88 |
VectorAdd( spot->s.origin, playerMaxs, maxs ); |
| 89 |
num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES ); |
| 90 |
|
| 91 |
for (i=0 ; i<num ; i++) { |
| 92 |
hit = &g_entities[touch[i]]; |
| 93 |
|
| 94 |
if ( hit->client) { |
| 95 |
return qtrue; |
| 96 |
} |
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
return qfalse; |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
#define MAX_SPAWN_POINTS 128 |
| 111 |
gentity_t *SelectNearestDeathmatchSpawnPoint( vec3_t from ) { |
| 112 |
gentity_t *spot; |
| 113 |
vec3_t delta; |
| 114 |
float dist, nearestDist; |
| 115 |
gentity_t *nearestSpot; |
| 116 |
|
| 117 |
nearestDist = 999999; |
| 118 |
nearestSpot = NULL; |
| 119 |
spot = NULL; |
| 120 |
|
| 121 |
while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) { |
| 122 |
|
| 123 |
VectorSubtract( spot->s.origin, from, delta ); |
| 124 |
dist = VectorLength( delta ); |
| 125 |
if ( dist < nearestDist ) { |
| 126 |
nearestDist = dist; |
| 127 |
nearestSpot = spot; |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
return nearestSpot; |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
#define MAX_SPAWN_POINTS 128 |
| 143 |
gentity_t *SelectRandomDeathmatchSpawnPoint(qboolean isbot) { |
| 144 |
gentity_t *spot; |
| 145 |
int count; |
| 146 |
int selection; |
| 147 |
gentity_t *spots[MAX_SPAWN_POINTS]; |
| 148 |
|
| 149 |
count = 0; |
| 150 |
spot = NULL; |
| 151 |
|
| 152 |
while((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL && count < MAX_SPAWN_POINTS) |
| 153 |
{ |
| 154 |
if(SpotWouldTelefrag(spot)) |
| 155 |
continue; |
| 156 |
|
| 157 |
if(((spot->flags & FL_NO_BOTS) && isbot) || |
| 158 |
((spot->flags & FL_NO_HUMANS) && !isbot)) |
| 159 |
{ |
| 160 |
|
| 161 |
continue; |
| 162 |
} |
| 163 |
|
| 164 |
spots[count] = spot; |
| 165 |
count++; |
| 166 |
} |
| 167 |
|
| 168 |
if ( !count ) { |
| 169 |
return G_Find( NULL, FOFS(classname), "info_player_deathmatch"); |
| 170 |
} |
| 171 |
|
| 172 |
selection = rand() % count; |
| 173 |
return spots[ selection ]; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
gentity_t *SelectRandomFurthestSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles, qboolean isbot ) { |
| 184 |
gentity_t *spot; |
| 185 |
vec3_t delta; |
| 186 |
float dist; |
| 187 |
float list_dist[MAX_SPAWN_POINTS]; |
| 188 |
gentity_t *list_spot[MAX_SPAWN_POINTS]; |
| 189 |
int numSpots, rnd, i, j; |
| 190 |
|
| 191 |
numSpots = 0; |
| 192 |
spot = NULL; |
| 193 |
|
| 194 |
while((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) |
| 195 |
{ |
| 196 |
if(SpotWouldTelefrag(spot)) |
| 197 |
continue; |
| 198 |
|
| 199 |
if(((spot->flags & FL_NO_BOTS) && isbot) || |
| 200 |
((spot->flags & FL_NO_HUMANS) && !isbot)) |
| 201 |
{ |
| 202 |
|
| 203 |
continue; |
| 204 |
} |
| 205 |
|
| 206 |
VectorSubtract( spot->s.origin, avoidPoint, delta ); |
| 207 |
dist = VectorLength( delta ); |
| 208 |
|
| 209 |
for (i = 0; i < numSpots; i++) |
| 210 |
{ |
| 211 |
if(dist > list_dist[i]) |
| 212 |
{ |
| 213 |
if (numSpots >= MAX_SPAWN_POINTS) |
| 214 |
numSpots = MAX_SPAWN_POINTS - 1; |
| 215 |
|
| 216 |
for(j = numSpots; j > i; j--) |
| 217 |
{ |
| 218 |
list_dist[j] = list_dist[j-1]; |
| 219 |
list_spot[j] = list_spot[j-1]; |
| 220 |
} |
| 221 |
|
| 222 |
list_dist[i] = dist; |
| 223 |
list_spot[i] = spot; |
| 224 |
|
| 225 |
numSpots++; |
| 226 |
break; |
| 227 |
} |
| 228 |
} |
| 229 |
|
| 230 |
if(i >= numSpots && numSpots < MAX_SPAWN_POINTS) |
| 231 |
{ |
| 232 |
list_dist[numSpots] = dist; |
| 233 |
list_spot[numSpots] = spot; |
| 234 |
numSpots++; |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
if(!numSpots) |
| 239 |
{ |
| 240 |
spot = G_Find(NULL, FOFS(classname), "info_player_deathmatch"); |
| 241 |
|
| 242 |
if (!spot) |
| 243 |
G_Error( "Couldn't find a spawn point" ); |
| 244 |
|
| 245 |
VectorCopy (spot->s.origin, origin); |
| 246 |
origin[2] += 9; |
| 247 |
VectorCopy (spot->s.angles, angles); |
| 248 |
return spot; |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
rnd = random() * (numSpots / 2); |
| 253 |
|
| 254 |
VectorCopy (list_spot[rnd]->s.origin, origin); |
| 255 |
origin[2] += 9; |
| 256 |
VectorCopy (list_spot[rnd]->s.angles, angles); |
| 257 |
|
| 258 |
return list_spot[rnd]; |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
gentity_t *SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles, qboolean isbot ) { |
| 269 |
return SelectRandomFurthestSpawnPoint( avoidPoint, origin, angles, isbot ); |
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
} |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
gentity_t *SelectInitialSpawnPoint( vec3_t origin, vec3_t angles, qboolean isbot ) { |
| 309 |
gentity_t *spot; |
| 310 |
|
| 311 |
spot = NULL; |
| 312 |
|
| 313 |
while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) |
| 314 |
{ |
| 315 |
if(((spot->flags & FL_NO_BOTS) && isbot) || |
| 316 |
((spot->flags & FL_NO_HUMANS) && !isbot)) |
| 317 |
{ |
| 318 |
continue; |
| 319 |
} |
| 320 |
|
| 321 |
if((spot->spawnflags & 0x01)) |
| 322 |
break; |
| 323 |
} |
| 324 |
|
| 325 |
if (!spot || SpotWouldTelefrag(spot)) |
| 326 |
return SelectSpawnPoint(vec3_origin, origin, angles, isbot); |
| 327 |
|
| 328 |
VectorCopy (spot->s.origin, origin); |
| 329 |
origin[2] += 9; |
| 330 |
VectorCopy (spot->s.angles, angles); |
| 331 |
|
| 332 |
return spot; |
| 333 |
} |
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
gentity_t *SelectSpectatorSpawnPoint( vec3_t origin, vec3_t angles ) { |
| 342 |
FindIntermissionPoint(); |
| 343 |
|
| 344 |
VectorCopy( level.intermission_origin, origin ); |
| 345 |
VectorCopy( level.intermission_angle, angles ); |
| 346 |
|
| 347 |
return NULL; |
| 348 |
} |
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
void InitBodyQue (void) { |
| 364 |
int i; |
| 365 |
gentity_t *ent; |
| 366 |
|
| 367 |
level.bodyQueIndex = 0; |
| 368 |
for (i=0; i<BODY_QUEUE_SIZE ; i++) { |
| 369 |
ent = G_Spawn(); |
| 370 |
ent->classname = "bodyque"; |
| 371 |
ent->neverFree = qtrue; |
| 372 |
level.bodyQue[i] = ent; |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
void BodySink( gentity_t *ent ) { |
| 384 |
if ( level.time - ent->timestamp > 6500 ) { |
| 385 |
|
| 386 |
trap_UnlinkEntity( ent ); |
| 387 |
ent->physicsObject = qfalse; |
| 388 |
return; |
| 389 |
} |
| 390 |
ent->nextthink = level.time + 100; |
| 391 |
ent->s.pos.trBase[2] -= 1; |
| 392 |
} |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
void CopyToBodyQue( gentity_t *ent ) { |
| 403 |
#ifdef MISSIONPACK |
| 404 |
gentity_t *e; |
| 405 |
int i; |
| 406 |
#endif |
| 407 |
gentity_t *body; |
| 408 |
int contents; |
| 409 |
|
| 410 |
trap_UnlinkEntity (ent); |
| 411 |
|
| 412 |
|
| 413 |
contents = trap_PointContents( ent->s.origin, -1 ); |
| 414 |
if ( contents & CONTENTS_NODROP ) { |
| 415 |
return; |
| 416 |
} |
| 417 |
|
| 418 |
|
| 419 |
body = level.bodyQue[ level.bodyQueIndex ]; |
| 420 |
level.bodyQueIndex = (level.bodyQueIndex + 1) % BODY_QUEUE_SIZE; |
| 421 |
|
| 422 |
body->s = ent->s; |
| 423 |
body->s.eFlags = EF_DEAD; |
| 424 |
#ifdef MISSIONPACK |
| 425 |
if ( ent->s.eFlags & EF_KAMIKAZE ) { |
| 426 |
body->s.eFlags |= EF_KAMIKAZE; |
| 427 |
|
| 428 |
|
| 429 |
for (i = 0; i < level.num_entities; i++) { |
| 430 |
e = &g_entities[i]; |
| 431 |
if (!e->inuse) |
| 432 |
continue; |
| 433 |
if (e->activator != ent) |
| 434 |
continue; |
| 435 |
if (strcmp(e->classname, "kamikaze timer")) |
| 436 |
continue; |
| 437 |
e->activator = body; |
| 438 |
break; |
| 439 |
} |
| 440 |
} |
| 441 |
#endif |
| 442 |
body->s.powerups = 0; |
| 443 |
body->s.loopSound = 0; |
| 444 |
body->s.number = body - g_entities; |
| 445 |
body->timestamp = level.time; |
| 446 |
body->physicsObject = qtrue; |
| 447 |
body->physicsBounce = 0; |
| 448 |
if ( body->s.groundEntityNum == ENTITYNUM_NONE ) { |
| 449 |
body->s.pos.trType = TR_GRAVITY; |
| 450 |
body->s.pos.trTime = level.time; |
| 451 |
VectorCopy( ent->client->ps.velocity, body->s.pos.trDelta ); |
| 452 |
} else { |
| 453 |
body->s.pos.trType = TR_STATIONARY; |
| 454 |
} |
| 455 |
body->s.event = 0; |
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
switch ( body->s.legsAnim & ~ANIM_TOGGLEBIT ) { |
| 460 |
case BOTH_DEATH1: |
| 461 |
case BOTH_DEAD1: |
| 462 |
body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD1; |
| 463 |
break; |
| 464 |
case BOTH_DEATH2: |
| 465 |
case BOTH_DEAD2: |
| 466 |
body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD2; |
| 467 |
break; |
| 468 |
case BOTH_DEATH3: |
| 469 |
case BOTH_DEAD3: |
| 470 |
default: |
| 471 |
body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD3; |
| 472 |
break; |
| 473 |
} |
| 474 |
|
| 475 |
body->r.svFlags = ent->r.svFlags; |
| 476 |
VectorCopy (ent->r.mins, body->r.mins); |
| 477 |
VectorCopy (ent->r.maxs, body->r.maxs); |
| 478 |
VectorCopy (ent->r.absmin, body->r.absmin); |
| 479 |
VectorCopy (ent->r.absmax, body->r.absmax); |
| 480 |
|
| 481 |
body->clipmask = CONTENTS_SOLID | CONTENTS_PLAYERCLIP; |
| 482 |
body->r.contents = CONTENTS_CORPSE; |
| 483 |
body->r.ownerNum = ent->s.number; |
| 484 |
|
| 485 |
body->nextthink = level.time + 5000; |
| 486 |
body->think = BodySink; |
| 487 |
|
| 488 |
body->die = body_die; |
| 489 |
|
| 490 |
|
| 491 |
if ( ent->health <= GIB_HEALTH ) { |
| 492 |
body->takedamage = qfalse; |
| 493 |
} else { |
| 494 |
body->takedamage = qtrue; |
| 495 |
} |
| 496 |
|
| 497 |
|
| 498 |
VectorCopy ( body->s.pos.trBase, body->r.currentOrigin ); |
| 499 |
trap_LinkEntity (body); |
| 500 |
} |
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
void SetClientViewAngle( gentity_t *ent, vec3_t angle ) { |
| 512 |
int i; |
| 513 |
|
| 514 |
|
| 515 |
for (i=0 ; i<3 ; i++) { |
| 516 |
int cmdAngle; |
| 517 |
|
| 518 |
cmdAngle = ANGLE2SHORT(angle[i]); |
| 519 |
ent->client->ps.delta_angles[i] = cmdAngle - ent->client->pers.cmd.angles[i]; |
| 520 |
} |
| 521 |
VectorCopy( angle, ent->s.angles ); |
| 522 |
VectorCopy (ent->s.angles, ent->client->ps.viewangles); |
| 523 |
} |
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
void ClientRespawn( gentity_t *ent ) { |
| 531 |
|
| 532 |
CopyToBodyQue (ent); |
| 533 |
ClientSpawn(ent); |
| 534 |
} |
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
int TeamCount( int ignoreClientNum, team_t team ) { |
| 544 |
int i; |
| 545 |
int count = 0; |
| 546 |
|
| 547 |
for ( i = 0 ; i < level.maxclients ; i++ ) { |
| 548 |
if ( i == ignoreClientNum ) { |
| 549 |
continue; |
| 550 |
} |
| 551 |
if ( level.clients[i].pers.connected == CON_DISCONNECTED ) { |
| 552 |
continue; |
| 553 |
} |
| 554 |
if ( level.clients[i].sess.sessionTeam == team ) { |
| 555 |
count++; |
| 556 |
} |
| 557 |
} |
| 558 |
|
| 559 |
return count; |
| 560 |
} |
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
int TeamLeader( int team ) { |
| 570 |
int i; |
| 571 |
|
| 572 |
for ( i = 0 ; i < level.maxclients ; i++ ) { |
| 573 |
if ( level.clients[i].pers.connected == CON_DISCONNECTED ) { |
| 574 |
continue; |
| 575 |
} |
| 576 |
if ( level.clients[i].sess.sessionTeam == team ) { |
| 577 |
if ( level.clients[i].sess.teamLeader ) |
| 578 |
return i; |
| 579 |
} |
| 580 |
} |
| 581 |
|
| 582 |
return -1; |
| 583 |
} |
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
team_t PickTeam( int ignoreClientNum ) { |
| 593 |
int counts[TEAM_NUM_TEAMS]; |
| 594 |
|
| 595 |
counts[TEAM_BLUE] = TeamCount( ignoreClientNum, TEAM_BLUE ); |
| 596 |
counts[TEAM_RED] = TeamCount( ignoreClientNum, TEAM_RED ); |
| 597 |
|
| 598 |
if ( counts[TEAM_BLUE] > counts[TEAM_RED] ) { |
| 599 |
return TEAM_RED; |
| 600 |
} |
| 601 |
if ( counts[TEAM_RED] > counts[TEAM_BLUE] ) { |
| 602 |
return TEAM_BLUE; |
| 603 |
} |
| 604 |
|
| 605 |
if ( level.teamScores[TEAM_BLUE] > level.teamScores[TEAM_RED] ) { |
| 606 |
return TEAM_RED; |
| 607 |
} |
| 608 |
return TEAM_BLUE; |
| 609 |
} |
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
static void ClientCleanName(const char *in, char *out, int outSize) |
| 637 |
{ |
| 638 |
int outpos = 0, colorlessLen = 0, spaces = 0; |
| 639 |
|
| 640 |
|
| 641 |
for(; *in == ' '; in++); |
| 642 |
|
| 643 |
for(; *in && outpos < outSize - 1; in++) |
| 644 |
{ |
| 645 |
out[outpos] = *in; |
| 646 |
|
| 647 |
if(*in == ' ') |
| 648 |
{ |
| 649 |
|
| 650 |
if(spaces > 2) |
| 651 |
continue; |
| 652 |
|
| 653 |
spaces++; |
| 654 |
} |
| 655 |
else if(outpos > 0 && out[outpos - 1] == Q_COLOR_ESCAPE) |
| 656 |
{ |
| 657 |
if(Q_IsColorString(&out[outpos - 1])) |
| 658 |
{ |
| 659 |
colorlessLen--; |
| 660 |
|
| 661 |
if(ColorIndex(*in) == 0) |
| 662 |
{ |
| 663 |
|
| 664 |
|
| 665 |
outpos--; |
| 666 |
continue; |
| 667 |
} |
| 668 |
} |
| 669 |
else |
| 670 |
{ |
| 671 |
spaces = 0; |
| 672 |
colorlessLen++; |
| 673 |
} |
| 674 |
} |
| 675 |
else |
| 676 |
{ |
| 677 |
spaces = 0; |
| 678 |
colorlessLen++; |
| 679 |
} |
| 680 |
|
| 681 |
outpos++; |
| 682 |
} |
| 683 |
|
| 684 |
out[outpos] = '\0'; |
| 685 |
|
| 686 |
|
| 687 |
if( *out == '\0' || colorlessLen == 0) |
| 688 |
Q_strncpyz(out, "UnnamedPlayer", outSize ); |
| 689 |
} |
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
void ClientUserinfoChanged( int clientNum ) { |
| 704 |
gentity_t *ent; |
| 705 |
int teamTask, teamLeader, health; |
| 706 |
char *s; |
| 707 |
char model[MAX_QPATH]; |
| 708 |
char headModel[MAX_QPATH]; |
| 709 |
char oldname[MAX_STRING_CHARS]; |
| 710 |
gclient_t *client; |
| 711 |
char c1[MAX_INFO_STRING]; |
| 712 |
char c2[MAX_INFO_STRING]; |
| 713 |
char redTeam[MAX_INFO_STRING]; |
| 714 |
char blueTeam[MAX_INFO_STRING]; |
| 715 |
char userinfo[MAX_INFO_STRING]; |
| 716 |
|
| 717 |
ent = g_entities + clientNum; |
| 718 |
client = ent->client; |
| 719 |
|
| 720 |
trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) ); |
| 721 |
|
| 722 |
|
| 723 |
if ( !Info_Validate(userinfo) ) { |
| 724 |
strcpy (userinfo, "\\name\\badinfo"); |
| 725 |
|
| 726 |
trap_DropClient(clientNum, "Invalid userinfo"); |
| 727 |
} |
| 728 |
|
| 729 |
|
| 730 |
s = Info_ValueForKey( userinfo, "cg_predictItems" ); |
| 731 |
if ( !atoi( s ) ) { |
| 732 |
client->pers.predictItemPickup = qfalse; |
| 733 |
} else { |
| 734 |
client->pers.predictItemPickup = qtrue; |
| 735 |
} |
| 736 |
|
| 737 |
|
| 738 |
Q_strncpyz ( oldname, client->pers.netname, sizeof( oldname ) ); |
| 739 |
s = Info_ValueForKey (userinfo, "name"); |
| 740 |
ClientCleanName( s, client->pers.netname, sizeof(client->pers.netname) ); |
| 741 |
|
| 742 |
if ( client->sess.sessionTeam == TEAM_SPECTATOR ) { |
| 743 |
if ( client->sess.spectatorState == SPECTATOR_SCOREBOARD ) { |
| 744 |
Q_strncpyz( client->pers.netname, "scoreboard", sizeof(client->pers.netname) ); |
| 745 |
} |
| 746 |
} |
| 747 |
|
| 748 |
if ( client->pers.connected == CON_CONNECTED ) { |
| 749 |
if ( strcmp( oldname, client->pers.netname ) ) { |
| 750 |
trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " renamed to %s\n\"", oldname, |
| 751 |
client->pers.netname) ); |
| 752 |
} |
| 753 |
} |
| 754 |
|
| 755 |
|
| 756 |
#ifdef MISSIONPACK |
| 757 |
if (client->ps.powerups[PW_GUARD]) { |
| 758 |
client->pers.maxHealth = 200; |
| 759 |
} else { |
| 760 |
health = atoi( Info_ValueForKey( userinfo, "handicap" ) ); |
| 761 |
client->pers.maxHealth = health; |
| 762 |
if ( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 ) { |
| 763 |
client->pers.maxHealth = 100; |
| 764 |
} |
| 765 |
} |
| 766 |
#else |
| 767 |
health = atoi( Info_ValueForKey( userinfo, "handicap" ) ); |
| 768 |
client->pers.maxHealth = health; |
| 769 |
if ( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 ) { |
| 770 |
client->pers.maxHealth = 100; |
| 771 |
} |
| 772 |
#endif |
| 773 |
client->ps.stats[STAT_MAX_HEALTH] = client->pers.maxHealth; |
| 774 |
|
| 775 |
|
| 776 |
if( g_gametype.integer >= GT_TEAM ) { |
| 777 |
Q_strncpyz( model, Info_ValueForKey (userinfo, "team_model"), sizeof( model ) ); |
| 778 |
Q_strncpyz( headModel, Info_ValueForKey (userinfo, "team_headmodel"), sizeof( headModel ) ); |
| 779 |
} else { |
| 780 |
Q_strncpyz( model, Info_ValueForKey (userinfo, "model"), sizeof( model ) ); |
| 781 |
Q_strncpyz( headModel, Info_ValueForKey (userinfo, "headmodel"), sizeof( headModel ) ); |
| 782 |
} |
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
#ifdef MISSIONPACK |
| 806 |
if (g_gametype.integer >= GT_TEAM && !(ent->r.svFlags & SVF_BOT)) { |
| 807 |
client->pers.teamInfo = qtrue; |
| 808 |
} else { |
| 809 |
s = Info_ValueForKey( userinfo, "teamoverlay" ); |
| 810 |
if ( ! *s || atoi( s ) != 0 ) { |
| 811 |
client->pers.teamInfo = qtrue; |
| 812 |
} else { |
| 813 |
client->pers.teamInfo = qfalse; |
| 814 |
} |
| 815 |
} |
| 816 |
#else |
| 817 |
|
| 818 |
s = Info_ValueForKey( userinfo, "teamoverlay" ); |
| 819 |
if ( ! *s || atoi( s ) != 0 ) { |
| 820 |
client->pers.teamInfo = qtrue; |
| 821 |
} else { |
| 822 |
client->pers.teamInfo = qfalse; |
| 823 |
} |
| 824 |
#endif |
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
teamTask = atoi(Info_ValueForKey(userinfo, "teamtask")); |
| 837 |
|
| 838 |
teamLeader = client->sess.teamLeader; |
| 839 |
|
| 840 |
|
| 841 |
Q_strncpyz(c1, Info_ValueForKey( userinfo, "color1" ), sizeof( c1 )); |
| 842 |
Q_strncpyz(c2, Info_ValueForKey( userinfo, "color2" ), sizeof( c2 )); |
| 843 |
|
| 844 |
Q_strncpyz(redTeam, Info_ValueForKey( userinfo, "g_redteam" ), sizeof( redTeam )); |
| 845 |
Q_strncpyz(blueTeam, Info_ValueForKey( userinfo, "g_blueteam" ), sizeof( blueTeam )); |
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
if (ent->r.svFlags & SVF_BOT) |
| 850 |
{ |
| 851 |
s = va("n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\c1\\%s\\c2\\%s\\hc\\%i\\w\\%i\\l\\%i\\skill\\%s\\tt\\%d\\tl\\%d", |
| 852 |
client->pers.netname, client->sess.sessionTeam, model, headModel, c1, c2, |
| 853 |
client->pers.maxHealth, client->sess.wins, client->sess.losses, |
| 854 |
Info_ValueForKey( userinfo, "skill" ), teamTask, teamLeader ); |
| 855 |
} |
| 856 |
else |
| 857 |
{ |
| 858 |
s = va("n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\g_redteam\\%s\\g_blueteam\\%s\\c1\\%s\\c2\\%s\\hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\tl\\%d", |
| 859 |
client->pers.netname, client->sess.sessionTeam, model, headModel, redTeam, blueTeam, c1, c2, |
| 860 |
client->pers.maxHealth, client->sess.wins, client->sess.losses, teamTask, teamLeader); |
| 861 |
} |
| 862 |
|
| 863 |
trap_SetConfigstring( CS_PLAYERS+clientNum, s ); |
| 864 |
|
| 865 |
|
| 866 |
G_LogPrintf( "ClientUserinfoChanged: %i %s\n", clientNum, s ); |
| 867 |
} |
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) { |
| 891 |
char *value; |
| 892 |
|
| 893 |
gclient_t *client; |
| 894 |
char userinfo[MAX_INFO_STRING]; |
| 895 |
gentity_t *ent; |
| 896 |
|
| 897 |
ent = &g_entities[ clientNum ]; |
| 898 |
|
| 899 |
trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) ); |
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
value = Info_ValueForKey (userinfo, "ip"); |
| 906 |
if ( G_FilterPacket( value ) ) { |
| 907 |
return "You are banned from this server."; |
| 908 |
} |
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
if ( !isBot && (strcmp(value, "localhost") != 0)) { |
| 914 |
|
| 915 |
value = Info_ValueForKey (userinfo, "password"); |
| 916 |
if ( g_password.string[0] && Q_stricmp( g_password.string, "none" ) && |
| 917 |
strcmp( g_password.string, value) != 0) { |
| 918 |
return "Invalid password"; |
| 919 |
} |
| 920 |
} |
| 921 |
|
| 922 |
if (ent->inuse) { |
| 923 |
G_LogPrintf("Forcing disconnect on active client: %i\n", clientNum); |
| 924 |
|
| 925 |
ClientDisconnect(clientNum); |
| 926 |
} |
| 927 |
|
| 928 |
ent->client = level.clients + clientNum; |
| 929 |
client = ent->client; |
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
memset( client, 0, sizeof(*client) ); |
| 934 |
|
| 935 |
client->pers.connected = CON_CONNECTING; |
| 936 |
|
| 937 |
|
| 938 |
value = Info_ValueForKey( userinfo, "ip" ); |
| 939 |
if ( !strcmp( value, "localhost" ) ) { |
| 940 |
client->pers.localClient = qtrue; |
| 941 |
} |
| 942 |
|
| 943 |
if( isBot ) { |
| 944 |
ent->r.svFlags |= SVF_BOT; |
| 945 |
ent->inuse = qtrue; |
| 946 |
if( !G_BotConnect( clientNum, !firstTime ) ) { |
| 947 |
return "BotConnectfailed"; |
| 948 |
} |
| 949 |
} |
| 950 |
|
| 951 |
|
| 952 |
if ( firstTime || level.newSession ) { |
| 953 |
G_InitSessionData( client, userinfo ); |
| 954 |
} |
| 955 |
G_ReadSessionData( client ); |
| 956 |
|
| 957 |
|
| 958 |
G_LogPrintf( "ClientConnect: %i\n", clientNum ); |
| 959 |
ClientUserinfoChanged( clientNum ); |
| 960 |
|
| 961 |
|
| 962 |
if ( firstTime ) { |
| 963 |
trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " connected\n\"", client->pers.netname) ); |
| 964 |
} |
| 965 |
|
| 966 |
if ( g_gametype.integer >= GT_TEAM && |
| 967 |
client->sess.sessionTeam != TEAM_SPECTATOR ) { |
| 968 |
BroadcastTeamChange( client, -1 ); |
| 969 |
} |
| 970 |
|
| 971 |
|
| 972 |
CalculateRanks(); |
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
return NULL; |
| 980 |
} |
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
void ClientBegin( int clientNum ) { |
| 992 |
gentity_t *ent; |
| 993 |
gclient_t *client; |
| 994 |
int flags; |
| 995 |
|
| 996 |
ent = g_entities + clientNum; |
| 997 |
|
| 998 |
client = level.clients + clientNum; |
| 999 |
|
| 1000 |
if ( ent->r.linked ) { |
| 1001 |
trap_UnlinkEntity( ent ); |
| 1002 |
} |
| 1003 |
G_InitGentity( ent ); |
| 1004 |
ent->touch = 0; |
| 1005 |
ent->pain = 0; |
| 1006 |
ent->client = client; |
| 1007 |
|
| 1008 |
client->pers.connected = CON_CONNECTED; |
| 1009 |
client->pers.enterTime = level.time; |
| 1010 |
client->pers.teamState.state = TEAM_BEGIN; |
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
flags = client->ps.eFlags; |
| 1018 |
memset( &client->ps, 0, sizeof( client->ps ) ); |
| 1019 |
client->ps.eFlags = flags; |
| 1020 |
|
| 1021 |
|
| 1022 |
ClientSpawn( ent ); |
| 1023 |
|
| 1024 |
if ( client->sess.sessionTeam != TEAM_SPECTATOR ) { |
| 1025 |
if ( g_gametype.integer != GT_TOURNAMENT ) { |
| 1026 |
trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname) ); |
| 1027 |
} |
| 1028 |
} |
| 1029 |
G_LogPrintf( "ClientBegin: %i\n", clientNum ); |
| 1030 |
|
| 1031 |
|
| 1032 |
CalculateRanks(); |
| 1033 |
} |
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
void ClientSpawn(gentity_t *ent) { |
| 1045 |
int index; |
| 1046 |
vec3_t spawn_origin, spawn_angles; |
| 1047 |
gclient_t *client; |
| 1048 |
int i; |
| 1049 |
clientPersistant_t saved; |
| 1050 |
clientSession_t savedSess; |
| 1051 |
int persistant[MAX_PERSISTANT]; |
| 1052 |
gentity_t *spawnPoint; |
| 1053 |
gentity_t *tent; |
| 1054 |
int flags; |
| 1055 |
int savedPing; |
| 1056 |
|
| 1057 |
int accuracy_hits, accuracy_shots; |
| 1058 |
int eventSequence; |
| 1059 |
char userinfo[MAX_INFO_STRING]; |
| 1060 |
|
| 1061 |
index = ent - g_entities; |
| 1062 |
client = ent->client; |
| 1063 |
|
| 1064 |
VectorClear(spawn_origin); |
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
if ( client->sess.sessionTeam == TEAM_SPECTATOR ) { |
| 1070 |
spawnPoint = SelectSpectatorSpawnPoint ( |
| 1071 |
spawn_origin, spawn_angles); |
| 1072 |
} else if (g_gametype.integer >= GT_CTF ) { |
| 1073 |
|
| 1074 |
spawnPoint = SelectCTFSpawnPoint ( |
| 1075 |
client->sess.sessionTeam, |
| 1076 |
client->pers.teamState.state, |
| 1077 |
spawn_origin, spawn_angles, |
| 1078 |
!!(ent->r.svFlags & SVF_BOT)); |
| 1079 |
} |
| 1080 |
else |
| 1081 |
{ |
| 1082 |
|
| 1083 |
if ( !client->pers.initialSpawn && client->pers.localClient ) |
| 1084 |
{ |
| 1085 |
client->pers.initialSpawn = qtrue; |
| 1086 |
spawnPoint = SelectInitialSpawnPoint(spawn_origin, spawn_angles, |
| 1087 |
!!(ent->r.svFlags & SVF_BOT)); |
| 1088 |
} |
| 1089 |
else |
| 1090 |
{ |
| 1091 |
|
| 1092 |
spawnPoint = SelectSpawnPoint ( |
| 1093 |
client->ps.origin, |
| 1094 |
spawn_origin, spawn_angles, !!(ent->r.svFlags & SVF_BOT)); |
| 1095 |
} |
| 1096 |
} |
| 1097 |
client->pers.teamState.state = TEAM_ACTIVE; |
| 1098 |
|
| 1099 |
|
| 1100 |
ent->s.eFlags &= ~EF_KAMIKAZE; |
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
flags = ent->client->ps.eFlags & (EF_TELEPORT_BIT | EF_VOTED | EF_TEAMVOTED); |
| 1105 |
flags ^= EF_TELEPORT_BIT; |
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
saved = client->pers; |
| 1110 |
savedSess = client->sess; |
| 1111 |
savedPing = client->ps.ping; |
| 1112 |
|
| 1113 |
accuracy_hits = client->accuracy_hits; |
| 1114 |
accuracy_shots = client->accuracy_shots; |
| 1115 |
for ( i = 0 ; i < MAX_PERSISTANT ; i++ ) { |
| 1116 |
persistant[i] = client->ps.persistant[i]; |
| 1117 |
} |
| 1118 |
eventSequence = client->ps.eventSequence; |
| 1119 |
|
| 1120 |
Com_Memset (client, 0, sizeof(*client)); |
| 1121 |
|
| 1122 |
client->pers = saved; |
| 1123 |
client->sess = savedSess; |
| 1124 |
client->ps.ping = savedPing; |
| 1125 |
|
| 1126 |
client->accuracy_hits = accuracy_hits; |
| 1127 |
client->accuracy_shots = accuracy_shots; |
| 1128 |
client->lastkilled_client = -1; |
| 1129 |
|
| 1130 |
for ( i = 0 ; i < MAX_PERSISTANT ; i++ ) { |
| 1131 |
client->ps.persistant[i] = persistant[i]; |
| 1132 |
} |
| 1133 |
client->ps.eventSequence = eventSequence; |
| 1134 |
|
| 1135 |
client->ps.persistant[PERS_SPAWN_COUNT]++; |
| 1136 |
client->ps.persistant[PERS_TEAM] = client->sess.sessionTeam; |
| 1137 |
|
| 1138 |
client->airOutTime = level.time + 12000; |
| 1139 |
|
| 1140 |
trap_GetUserinfo( index, userinfo, sizeof(userinfo) ); |
| 1141 |
|
| 1142 |
client->pers.maxHealth = atoi( Info_ValueForKey( userinfo, "handicap" ) ); |
| 1143 |
if ( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 ) { |
| 1144 |
client->pers.maxHealth = 100; |
| 1145 |
} |
| 1146 |
|
| 1147 |
client->ps.stats[STAT_MAX_HEALTH] = client->pers.maxHealth; |
| 1148 |
client->ps.eFlags = flags; |
| 1149 |
|
| 1150 |
ent->s.groundEntityNum = ENTITYNUM_NONE; |
| 1151 |
ent->client = &level.clients[index]; |
| 1152 |
ent->takedamage = qtrue; |
| 1153 |
ent->inuse = qtrue; |
| 1154 |
ent->classname = "player"; |
| 1155 |
ent->r.contents = CONTENTS_BODY; |
| 1156 |
ent->clipmask = MASK_PLAYERSOLID; |
| 1157 |
ent->die = player_die; |
| 1158 |
ent->waterlevel = 0; |
| 1159 |
ent->watertype = 0; |
| 1160 |
ent->flags = 0; |
| 1161 |
|
| 1162 |
VectorCopy (playerMins, ent->r.mins); |
| 1163 |
VectorCopy (playerMaxs, ent->r.maxs); |
| 1164 |
|
| 1165 |
client->ps.clientNum = index; |
| 1166 |
|
| 1167 |
client->ps.stats[STAT_WEAPONS] = ( 1 << WP_MACHINEGUN ); |
| 1168 |
if ( g_gametype.integer == GT_TEAM ) { |
| 1169 |
client->ps.ammo[WP_MACHINEGUN] = 50; |
| 1170 |
} else { |
| 1171 |
client->ps.ammo[WP_MACHINEGUN] = 100; |
| 1172 |
} |
| 1173 |
|
| 1174 |
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_GAUNTLET ); |
| 1175 |
client->ps.ammo[WP_GAUNTLET] = -1; |
| 1176 |
client->ps.ammo[WP_GRAPPLING_HOOK] = -1; |
| 1177 |
|
| 1178 |
|
| 1179 |
ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] + 25; |
| 1180 |
|
| 1181 |
G_SetOrigin( ent, spawn_origin ); |
| 1182 |
VectorCopy( spawn_origin, client->ps.origin ); |
| 1183 |
|
| 1184 |
|
| 1185 |
client->ps.pm_flags |= PMF_RESPAWNED; |
| 1186 |
|
| 1187 |
trap_GetUsercmd( client - level.clients, &ent->client->pers.cmd ); |
| 1188 |
SetClientViewAngle( ent, spawn_angles ); |
| 1189 |
|
| 1190 |
client->ps.pm_flags |= PMF_TIME_KNOCKBACK; |
| 1191 |
client->ps.pm_time = 100; |
| 1192 |
|
| 1193 |
client->respawnTime = level.time; |
| 1194 |
client->inactivityTime = level.time + g_inactivity.integer * 1000; |
| 1195 |
client->latched_buttons = 0; |
| 1196 |
|
| 1197 |
|
| 1198 |
client->ps.torsoAnim = TORSO_STAND; |
| 1199 |
client->ps.legsAnim = LEGS_IDLE; |
| 1200 |
|
| 1201 |
if (!level.intermissiontime) { |
| 1202 |
if (ent->client->sess.sessionTeam != TEAM_SPECTATOR) { |
| 1203 |
G_KillBox(ent); |
| 1204 |
|
| 1205 |
client->ps.weapon = WP_MACHINEGUN; |
| 1206 |
client->ps.weaponstate = WEAPON_READY; |
| 1207 |
|
| 1208 |
G_UseTargets(spawnPoint, ent); |
| 1209 |
|
| 1210 |
client->ps.weapon = 1; |
| 1211 |
|
| 1212 |
for (i = WP_NUM_WEAPONS - 1 ; i > 0 ; i--) { |
| 1213 |
if (client->ps.stats[STAT_WEAPONS] & (1 << i)) { |
| 1214 |
client->ps.weapon = i; |
| 1215 |
break; |
| 1216 |
} |
| 1217 |
} |
| 1218 |
|
| 1219 |
VectorCopy(ent->client->ps.origin, ent->r.currentOrigin); |
| 1220 |
|
| 1221 |
tent = G_TempEntity(ent->client->ps.origin, EV_PLAYER_TELEPORT_IN); |
| 1222 |
tent->s.clientNum = ent->s.clientNum; |
| 1223 |
|
| 1224 |
trap_LinkEntity (ent); |
| 1225 |
} |
| 1226 |
} else { |
| 1227 |
|
| 1228 |
MoveClientToIntermission(ent); |
| 1229 |
} |
| 1230 |
|
| 1231 |
|
| 1232 |
client->ps.commandTime = level.time - 100; |
| 1233 |
ent->client->pers.cmd.serverTime = level.time; |
| 1234 |
ClientThink( ent-g_entities ); |
| 1235 |
|
| 1236 |
|
| 1237 |
if ( ent->client->sess.spectatorState != SPECTATOR_FOLLOW ) { |
| 1238 |
ClientEndFrame( ent ); |
| 1239 |
} |
| 1240 |
|
| 1241 |
|
| 1242 |
BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue ); |
| 1243 |
} |
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
void ClientDisconnect( int clientNum ) { |
| 1259 |
gentity_t *ent; |
| 1260 |
gentity_t *tent; |
| 1261 |
int i; |
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
G_RemoveQueuedBotBegin( clientNum ); |
| 1266 |
|
| 1267 |
ent = g_entities + clientNum; |
| 1268 |
if (!ent->client || ent->client->pers.connected == CON_DISCONNECTED) { |
| 1269 |
return; |
| 1270 |
} |
| 1271 |
|
| 1272 |
|
| 1273 |
for ( i = 0 ; i < level.maxclients ; i++ ) { |
| 1274 |
if ( level.clients[i].sess.sessionTeam == TEAM_SPECTATOR |
| 1275 |
&& level.clients[i].sess.spectatorState == SPECTATOR_FOLLOW |
| 1276 |
&& level.clients[i].sess.spectatorClient == clientNum ) { |
| 1277 |
StopFollowing( &g_entities[i] ); |
| 1278 |
} |
| 1279 |
} |
| 1280 |
|
| 1281 |
|
| 1282 |
if ( ent->client->pers.connected == CON_CONNECTED |
| 1283 |
&& ent->client->sess.sessionTeam != TEAM_SPECTATOR ) { |
| 1284 |
tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_OUT ); |
| 1285 |
tent->s.clientNum = ent->s.clientNum; |
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
TossClientItems( ent ); |
| 1290 |
#ifdef MISSIONPACK |
| 1291 |
TossClientPersistantPowerups( ent ); |
| 1292 |
if( g_gametype.integer == GT_HARVESTER ) { |
| 1293 |
TossClientCubes( ent ); |
| 1294 |
} |
| 1295 |
#endif |
| 1296 |
|
| 1297 |
} |
| 1298 |
|
| 1299 |
G_LogPrintf( "ClientDisconnect: %i\n", clientNum ); |
| 1300 |
|
| 1301 |
|
| 1302 |
if ( (g_gametype.integer == GT_TOURNAMENT ) |
| 1303 |
&& !level.intermissiontime |
| 1304 |
&& !level.warmupTime && level.sortedClients[1] == clientNum ) { |
| 1305 |
level.clients[ level.sortedClients[0] ].sess.wins++; |
| 1306 |
ClientUserinfoChanged( level.sortedClients[0] ); |
| 1307 |
} |
| 1308 |
|
| 1309 |
if( g_gametype.integer == GT_TOURNAMENT && |
| 1310 |
ent->client->sess.sessionTeam == TEAM_FREE && |
| 1311 |
level.intermissiontime ) { |
| 1312 |
|
| 1313 |
trap_SendConsoleCommand( EXEC_APPEND, "map_restart 0\n" ); |
| 1314 |
level.restarted = qtrue; |
| 1315 |
level.changemap = NULL; |
| 1316 |
level.intermissiontime = 0; |
| 1317 |
} |
| 1318 |
|
| 1319 |
trap_UnlinkEntity (ent); |
| 1320 |
ent->s.modelindex = 0; |
| 1321 |
ent->inuse = qfalse; |
| 1322 |
ent->classname = "disconnected"; |
| 1323 |
ent->client->pers.connected = CON_DISCONNECTED; |
| 1324 |
ent->client->ps.persistant[PERS_TEAM] = TEAM_FREE; |
| 1325 |
ent->client->sess.sessionTeam = TEAM_FREE; |
| 1326 |
|
| 1327 |
trap_SetConfigstring( CS_PLAYERS + clientNum, ""); |
| 1328 |
|
| 1329 |
CalculateRanks(); |
| 1330 |
|
| 1331 |
if ( ent->r.svFlags & SVF_BOT ) { |
| 1332 |
BotAIShutdownClient( clientNum, qfalse ); |
| 1333 |
} |
| 1334 |
} |
| 1335 |
|
| 1336 |
|