/* ============== TDM_SetupClient ============== Setup the client after an initial connection. Called on first spawn only, not every map. Returns true if a join code was used to respawn a full player, so that PutClientInServer knows about it. */ qboolean TDM_SetupClient (edict_t *ent) { ent->client->pers.team = TEAM_SPEC; TDM_TeamsChanged (); //handled in userinfo updates now //TDM_DownloadPlayerConfig (ent); if (!TDM_ProcessJoinCode (ent, 0)) { if (tdm_match_status == MM_TIMEOUT) { gi.cprintf (ent, PRINT_CHAT, "\nMatch is currently paused and will auto resume in %s.\n", TDM_SecsToString(FRAMES_TO_SECS(level.timeout_end_framenum - level.realframenum))); } else { TDM_ShowTeamMenu (ent); gi.cprintf (ent, PRINT_CHAT, "\nWelcome to OpenTDM!\nType 'commands' in the console for a brief command guide.\n\n"); } } else { if (tdm_match_status == MM_TIMEOUT) { if (TDM_Is1V1()) { //only resume if we have 2 players - it's possible both players dropped, and that is a situation //we need to be able to handle. if (teaminfo[TEAM_A].players == 1 && teaminfo[TEAM_B].players == 1) TDM_ResumeGame (); return true; } } } return false; }
/* =============== G_SetStats =============== */ void G_SetStats (edict_t *ent) { const gitem_t *item; int index, cells; int power_armor_type; cells = 0; ent->client->ps.stats[STAT_ID_VIEW_INDEX] = 0; if (!ent->client->pers.disable_id_view) if (TDM_GetPlayerIdView (ent)) ent->client->ps.stats[STAT_ID_VIEW_INDEX] = CS_TDM_ID_VIEW; // // health // ent->client->ps.stats[STAT_HEALTH_ICON] = level.pic_health; ent->client->ps.stats[STAT_HEALTH] = (ent->health & 0xFFFF); // // ammo // if (!ent->client->ammo_index /* || !ent->client->inventory[ent->client->ammo_index] */) { ent->client->ps.stats[STAT_AMMO_ICON] = 0; ent->client->ps.stats[STAT_AMMO] = 0; } else { item = &itemlist[ent->client->ammo_index]; ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex (item->icon); ent->client->ps.stats[STAT_AMMO] = ent->client->inventory[ent->client->ammo_index]; } // // armor // power_armor_type = PowerArmorType (ent); if (power_armor_type) { cells = ent->client->inventory[ITEM_AMMO_CELLS]; if (cells == 0) { // ran out of cells for power armor ent->flags &= ~FL_POWER_ARMOR; gi.sound(ent, CHAN_ITEM, gi.soundindex("misc/power2.wav"), 1, ATTN_NORM, 0); power_armor_type = 0;; } } index = ArmorIndex (ent); if (power_armor_type && (!index || (level.framenum & 8) ) ) { // flash between power armor and other armor icon ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex ("i_powershield"); ent->client->ps.stats[STAT_ARMOR] = cells; } else if (index) { item = GetItemByIndex (index); ent->client->ps.stats[STAT_ARMOR_ICON] = gi.imageindex (item->icon); ent->client->ps.stats[STAT_ARMOR] = ent->client->inventory[index]; } else { ent->client->ps.stats[STAT_ARMOR_ICON] = 0; ent->client->ps.stats[STAT_ARMOR] = 0; } // // pickup message // if (level.time > ent->client->pickup_msg_time) { ent->client->ps.stats[STAT_PICKUP_ICON] = 0; ent->client->ps.stats[STAT_PICKUP_STRING] = 0; } // // timers // if (ent->client->quad_framenum > level.framenum) { ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_quad"); ent->client->ps.stats[STAT_TIMER] = FRAMES_TO_SECS((ent->client->quad_framenum - level.framenum)); } else if (ent->client->enviro_framenum > level.framenum) { ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_envirosuit"); ent->client->ps.stats[STAT_TIMER] = FRAMES_TO_SECS(ent->client->enviro_framenum - level.framenum); } else if (ent->client->breather_framenum > level.framenum) { ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_rebreather"); ent->client->ps.stats[STAT_TIMER] = FRAMES_TO_SECS(ent->client->breather_framenum - level.framenum); } else { ent->client->ps.stats[STAT_TIMER_ICON] = 0; ent->client->ps.stats[STAT_TIMER] = 0; } if (ent->client->invincible_framenum > level.framenum) { //is the usual timer in use? if (ent->client->ps.stats[STAT_TIMER]) { //yes, show new timer for invuln ent->client->ps.stats[STAT_TIMER_PENT_ICON] = gi.imageindex ("p_invulnerability"); ent->client->ps.stats[STAT_TIMER_PENT] = FRAMES_TO_SECS(ent->client->invincible_framenum - level.framenum); } else { ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_invulnerability"); ent->client->ps.stats[STAT_TIMER] = FRAMES_TO_SECS(ent->client->invincible_framenum - level.framenum); // clear previous timer if there was something if (ent->client->ps.stats[STAT_TIMER_PENT]) { ent->client->ps.stats[STAT_TIMER_PENT_ICON] = 0; ent->client->ps.stats[STAT_TIMER_PENT] = 0; } } } else { ent->client->ps.stats[STAT_TIMER_PENT_ICON] = 0; ent->client->ps.stats[STAT_TIMER_PENT] = 0; } // // selected item // if (ent->client->selected_item == -1 || itemlist[ent->client->selected_item].icon == NULL) ent->client->ps.stats[STAT_SELECTED_ICON] = 0; else ent->client->ps.stats[STAT_SELECTED_ICON] = gi.imageindex (itemlist[ent->client->selected_item].icon); ent->client->ps.stats[STAT_SELECTED_ITEM] = ent->client->selected_item; // // layouts // ent->client->ps.stats[STAT_LAYOUTS] = 0; if (ent->health <= 0 || tdm_match_status == MM_SCOREBOARD || ent->client->showscores || ent->client->pers.menu.active || ent->client->showoldscores || ent->client->showmotd) ent->client->ps.stats[STAT_LAYOUTS] |= 1; ent->client->ps.stats[STAT_GAME_STATUS_STRING_INDEX] = CS_TDM_GAME_STATUS; if (vote.active) ent->client->ps.stats[STAT_VOTE_STRING_INDEX] = CS_TDM_VOTE_STRING; else ent->client->ps.stats[STAT_VOTE_STRING_INDEX] = 0; //if (ent->client->showinventory && ent->health > 0) // ent->client->ps.stats[STAT_LAYOUTS] |= 2; // // frags // G_SetTeamScoreStats (ent); // frags for server browser ent->client->ps.stats[STAT_FRAGS] = ent->client->resp.score; // frags for ingame hud ent->client->ps.stats[STAT_SCORE] = ent->client->resp.score; ent->client->ps.stats[STAT_TIME_REMAINING] = CS_TDM_TIMELIMIT_STRING; if (tdm_match_status == MM_TIMEOUT) ent->client->ps.stats[STAT_TIMEOUT_STRING_INDEX] = CS_TDM_TIMEOUT_STRING; else ent->client->ps.stats[STAT_TIMEOUT_STRING_INDEX] = 0; // // help icon / current weapon if not shown // if ( (ent->client->pers.hand == CENTER_HANDED || ent->client->ps.fov > 90) && ent->client->weapon) ent->client->ps.stats[STAT_HELPICON] = gi.imageindex (ent->client->weapon->icon); else ent->client->ps.stats[STAT_HELPICON] = 0; ent->client->ps.stats[STAT_SPECTATOR] = 0; }