/* ============== JoinTeam2 ============== Player joined Team B via menu */ void JoinTeam2 (edict_t *ent) { if (!CanJoin (ent, TEAM_B)) return; if (ent->client->pers.team) TDM_LeftTeam (ent, true); ent->client->pers.team = TEAM_B; JoinedTeam (ent, false, true); }
/* ============== ToggleChaseCam ============== Player hit Spectator menu option or used chase command. */ void ToggleChaseCam (edict_t *ent) { if (ent->client->pers.team) { TDM_LeftTeam (ent, true); TDM_TeamsChanged (); if (tdm_match_status == MM_TIMEOUT && teaminfo[TEAM_A].players == 0 && teaminfo[TEAM_B].players == 0) TDM_ResumeGame (); respawn (ent); } if (ent->client->chase_target) DisableChaseCam (ent); else GetChaseTarget(ent); PMenu_Close (ent); }
/* ============== TDM_Disconnected ============== A player disconnected, do things. */ void TDM_Disconnected (edict_t *ent) { qboolean removeTimeout; removeTimeout = false; //have to check this right up here since we nuke the teamplayer just below! if (tdm_match_status == MM_TIMEOUT && level.tdm_timeout_caller && level.tdm_timeout_caller->client == ent) removeTimeout = true; //we remove this up here so TDM_LeftTeam doesn't try to resume if we become implicit timeout caller TDM_RemoveStatsLink (ent); if (ent->client->pers.team) { if (tdm_match_status >= MM_PLAYING && tdm_match_status != MM_SCOREBOARD) { //do joincode stuff if a team player disconnects - save all their client info ent->client->resp.teamplayerinfo->saved_client = gi.TagMalloc (sizeof(gclient_t), TAG_GAME); *ent->client->resp.teamplayerinfo->saved_client = *ent->client; ent->client->resp.teamplayerinfo->saved_entity = gi.TagMalloc (sizeof(edict_t), TAG_GAME); *ent->client->resp.teamplayerinfo->saved_entity = *ent; if (TDM_Is1V1() && g_1v1_timeout->value > 0) { edict_t *ghost; //may have already been set by a player or previous client disconnect if (tdm_match_status != MM_TIMEOUT) { edict_t *opponent; //timeout is called implicitly in 1v1 games or the other player would auto win level.timeout_end_framenum = level.realframenum + SECS_TO_FRAMES(g_1v1_timeout->value); level.last_tdm_match_status = tdm_match_status; tdm_match_status = MM_TIMEOUT; level.tdm_timeout_caller = ent->client->resp.teamplayerinfo; gi.bprintf (PRINT_CHAT, "%s disconnected and has %s to reconnect.\n", level.tdm_timeout_caller->name, TDM_SecsToString (g_1v1_timeout->value)); //show the opponent their options opponent = TDM_FindPlayerForTeam (TEAM_A); if (opponent) gi.cprintf (opponent, PRINT_HIGH, "Your opponent has disconnected. You can allow them %s to reconnect, or you can force a forfeit by typing 'win' in the console.\n", TDM_SecsToString (g_1v1_timeout->value)); opponent = TDM_FindPlayerForTeam (TEAM_B); if (opponent) gi.cprintf (opponent, PRINT_HIGH, "Your opponent has disconnected. You can allow them %s to reconnect, or you can force a forfeit by typing 'win' in the console.\n", TDM_SecsToString (g_1v1_timeout->value)); } //show a "ghost" player where the player was ghost = G_Spawn (); VectorCopy (ent->s.origin, ghost->s.origin); VectorCopy (ent->s.origin, ghost->old_origin); VectorCopy (ent->s.angles, ghost->s.angles); ghost->s.effects = EF_SPHERETRANS; ghost->s.modelindex = 255; ghost->s.modelindex2 = 255; ghost->s.skinnum = ent - g_edicts - 1; ghost->s.frame = ent->s.frame; ghost->count = ent->s.number; ghost->classname = "ghost"; ghost->target_ent = ent; ghost->enttype = ENT_GHOST; gi.linkentity (ghost); } } if (removeTimeout) TDM_ResumeGame (); TDM_LeftTeam (ent, false); } TDM_TeamsChanged (); if (tdm_match_status == MM_WARMUP && teaminfo[TEAM_SPEC].players == 0 && teaminfo[TEAM_A].players == 0 && teaminfo[TEAM_B].players == 0) { if (vote.active) TDM_RemoveVote (); //reset the map if it's been running for over 7 days to workaround time precision bugs in the engine, fixes 0000208 if (time (NULL) - level.spawntime > (86400 * 7)) { char command[256]; Com_sprintf (command, sizeof(command), "gamemap \"%s\"\n", level.mapname); gi.AddCommandString (command); } } else TDM_CheckVote (); //zero for connecting clients on server browsers ent->client->ps.stats[STAT_FRAGS] = 0; }