diff options
Diffstat (limited to 'src/baseq2/p_hud.c')
-rw-r--r-- | src/baseq2/p_hud.c | 297 |
1 files changed, 128 insertions, 169 deletions
diff --git a/src/baseq2/p_hud.c b/src/baseq2/p_hud.c index c3c7ab2..060e969 100644 --- a/src/baseq2/p_hud.c +++ b/src/baseq2/p_hud.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -29,15 +29,15 @@ INTERMISSION ====================================================================== */ -void MoveClientToIntermission (edict_t *ent) +void MoveClientToIntermission(edict_t *ent) { if (deathmatch->value || coop->value) ent->client->showscores = qtrue; - VectorCopy (level.intermission_origin, ent->s.origin); - ent->client->ps.pmove.origin[0] = level.intermission_origin[0]*8; - ent->client->ps.pmove.origin[1] = level.intermission_origin[1]*8; - ent->client->ps.pmove.origin[2] = level.intermission_origin[2]*8; - VectorCopy (level.intermission_angle, ent->client->ps.viewangles); + VectorCopy(level.intermission_origin, ent->s.origin); + ent->client->ps.pmove.origin[0] = level.intermission_origin[0] * 8; + ent->client->ps.pmove.origin[1] = level.intermission_origin[1] * 8; + ent->client->ps.pmove.origin[2] = level.intermission_origin[2] * 8; + VectorCopy(level.intermission_angle, ent->client->ps.viewangles); ent->client->ps.pmove.pm_type = PM_FREEZE; ent->client->ps.gunindex = 0; ent->client->ps.blend[3] = 0; @@ -62,15 +62,14 @@ void MoveClientToIntermission (edict_t *ent) // add the layout - if (deathmatch->value || coop->value) - { - DeathmatchScoreboardMessage (ent, NULL); - gi.unicast (ent, qtrue); + if (deathmatch->value || coop->value) { + DeathmatchScoreboardMessage(ent, NULL); + gi.unicast(ent, qtrue); } } -void BeginIntermission (edict_t *targ) +void BeginIntermission(edict_t *targ) { int i, n; edict_t *ent, *client; @@ -81,8 +80,7 @@ void BeginIntermission (edict_t *targ) game.autosaved = qfalse; // respawn any dead clients - for (i=0 ; i<maxclients->value ; i++) - { + for (i = 0 ; i < maxclients->value ; i++) { client = g_edicts + 1 + i; if (!client->inuse) continue; @@ -93,28 +91,21 @@ void BeginIntermission (edict_t *targ) level.intermissiontime = level.time; level.changemap = targ->map; - if (strstr(level.changemap, "*")) - { - if (coop->value) - { - for (i=0 ; i<maxclients->value ; i++) - { + if (strstr(level.changemap, "*")) { + if (coop->value) { + for (i = 0 ; i < maxclients->value ; i++) { client = g_edicts + 1 + i; if (!client->inuse) continue; // strip players of all keys between units - for (n = 0; n < MAX_ITEMS; n++) - { + for (n = 0; n < MAX_ITEMS; n++) { if (itemlist[n].flags & IT_KEY) client->client->pers.inventory[n] = 0; } } } - } - else - { - if (!deathmatch->value) - { + } else { + if (!deathmatch->value) { level.exitintermission = 1; // go immediately to the next level return; } @@ -123,34 +114,31 @@ void BeginIntermission (edict_t *targ) level.exitintermission = 0; // find an intermission spot - ent = G_Find (NULL, FOFS(classname), "info_player_intermission"); - if (!ent) - { // the map creator forgot to put in an intermission point... - ent = G_Find (NULL, FOFS(classname), "info_player_start"); + ent = G_Find(NULL, FOFS(classname), "info_player_intermission"); + if (!ent) { + // the map creator forgot to put in an intermission point... + ent = G_Find(NULL, FOFS(classname), "info_player_start"); if (!ent) - ent = G_Find (NULL, FOFS(classname), "info_player_deathmatch"); - } - else - { // chose one of four spots + ent = G_Find(NULL, FOFS(classname), "info_player_deathmatch"); + } else { + // chose one of four spots i = rand() & 3; - while (i--) - { - ent = G_Find (ent, FOFS(classname), "info_player_intermission"); + while (i--) { + ent = G_Find(ent, FOFS(classname), "info_player_intermission"); if (!ent) // wrap around the list - ent = G_Find (ent, FOFS(classname), "info_player_intermission"); + ent = G_Find(ent, FOFS(classname), "info_player_intermission"); } } - VectorCopy (ent->s.origin, level.intermission_origin); - VectorCopy (ent->s.angles, level.intermission_angle); + VectorCopy(ent->s.origin, level.intermission_origin); + VectorCopy(ent->s.angles, level.intermission_angle); // move all clients to the intermission point - for (i=0 ; i<maxclients->value ; i++) - { + for (i = 0 ; i < maxclients->value ; i++) { client = g_edicts + 1 + i; if (!client->inuse) continue; - MoveClientToIntermission (client); + MoveClientToIntermission(client); } } @@ -161,7 +149,7 @@ DeathmatchScoreboardMessage ================== */ -void DeathmatchScoreboardMessage (edict_t *ent, edict_t *killer) +void DeathmatchScoreboardMessage(edict_t *ent, edict_t *killer) { char entry[1024]; char string[1400]; @@ -178,21 +166,18 @@ void DeathmatchScoreboardMessage (edict_t *ent, edict_t *killer) // sort the clients by score total = 0; - for (i=0 ; i<game.maxclients ; i++) - { + for (i = 0 ; i < game.maxclients ; i++) { cl_ent = g_edicts + 1 + i; if (!cl_ent->inuse || game.clients[i].resp.spectator) continue; score = game.clients[i].resp.score; - for (j=0 ; j<total ; j++) - { + for (j = 0 ; j < total ; j++) { if (score > sortedscores[j]) break; } - for (k=total ; k>j ; k--) - { - sorted[k] = sorted[k-1]; - sortedscores[k] = sortedscores[k-1]; + for (k = total ; k > j ; k--) { + sorted[k] = sorted[k - 1]; + sortedscores[k] = sortedscores[k - 1]; } sorted[j] = i; sortedscores[j] = score; @@ -208,14 +193,13 @@ void DeathmatchScoreboardMessage (edict_t *ent, edict_t *killer) if (total > 12) total = 12; - for (i=0 ; i<total ; i++) - { + for (i = 0 ; i < total ; i++) { cl = &game.clients[sorted[i]]; cl_ent = g_edicts + 1 + sorted[i]; - picnum = gi.imageindex ("i_fixme"); - x = (i>=6) ? 160 : 0; - y = 32 + 32 * (i%6); + picnum = gi.imageindex("i_fixme"); + x = (i >= 6) ? 160 : 0; + y = 32 + 32 * (i % 6); // add a dogtag if (cl_ent == ent) @@ -224,30 +208,29 @@ void DeathmatchScoreboardMessage (edict_t *ent, edict_t *killer) tag = "tag2"; else tag = NULL; - if (tag) - { - Q_snprintf (entry, sizeof(entry), - "xv %i yv %i picn %s ",x+32, y, tag); + if (tag) { + Q_snprintf(entry, sizeof(entry), + "xv %i yv %i picn %s ", x + 32, y, tag); j = strlen(entry); if (stringlength + j > 1024) break; - strcpy (string + stringlength, entry); + strcpy(string + stringlength, entry); stringlength += j; } // send the layout - Q_snprintf (entry, sizeof(entry), - "client %i %i %i %i %i %i ", - x, y, sorted[i], cl->resp.score, cl->ping, (level.framenum - cl->resp.enterframe)/600); + Q_snprintf(entry, sizeof(entry), + "client %i %i %i %i %i %i ", + x, y, sorted[i], cl->resp.score, cl->ping, (level.framenum - cl->resp.enterframe) / 600); j = strlen(entry); if (stringlength + j > 1024) break; - strcpy (string + stringlength, entry); + strcpy(string + stringlength, entry); stringlength += j; } - gi.WriteByte (svc_layout); - gi.WriteString (string); + gi.WriteByte(svc_layout); + gi.WriteString(string); } @@ -259,10 +242,10 @@ Draw instead of help message. Note that it isn't that hard to overflow the 1400 byte message limit! ================== */ -void DeathmatchScoreboard (edict_t *ent) +void DeathmatchScoreboard(edict_t *ent) { - DeathmatchScoreboardMessage (ent, ent->enemy); - gi.unicast (ent, qtrue); + DeathmatchScoreboardMessage(ent, ent->enemy); + gi.unicast(ent, qtrue); } @@ -273,7 +256,7 @@ Cmd_Score_f Display the scoreboard ================== */ -void Cmd_Score_f (edict_t *ent) +void Cmd_Score_f(edict_t *ent) { ent->client->showinventory = qfalse; ent->client->showhelp = qfalse; @@ -281,14 +264,13 @@ void Cmd_Score_f (edict_t *ent) if (!deathmatch->value && !coop->value) return; - if (ent->client->showscores) - { + if (ent->client->showscores) { ent->client->showscores = qfalse; return; } ent->client->showscores = qtrue; - DeathmatchScoreboard (ent); + DeathmatchScoreboard(ent); } @@ -299,7 +281,7 @@ HelpComputer Draw help computer. ================== */ -void HelpComputer (edict_t *ent) +void HelpComputer(edict_t *ent) { char string[1024]; char *sk; @@ -314,25 +296,25 @@ void HelpComputer (edict_t *ent) sk = "hard+"; // send the layout - Q_snprintf (string, sizeof(string), - "xv 32 yv 8 picn help " // background - "xv 202 yv 12 string2 \"%s\" " // skill - "xv 0 yv 24 cstring2 \"%s\" " // level name - "xv 0 yv 54 cstring2 \"%s\" " // help 1 - "xv 0 yv 110 cstring2 \"%s\" " // help 2 - "xv 50 yv 164 string2 \" kills goals secrets\" " - "xv 50 yv 172 string2 \"%3i/%3i %i/%i %i/%i\" ", - sk, - level.level_name, - game.helpmessage1, - game.helpmessage2, - level.killed_monsters, level.total_monsters, - level.found_goals, level.total_goals, - level.found_secrets, level.total_secrets); - - gi.WriteByte (svc_layout); - gi.WriteString (string); - gi.unicast (ent, qtrue); + Q_snprintf(string, sizeof(string), + "xv 32 yv 8 picn help " // background + "xv 202 yv 12 string2 \"%s\" " // skill + "xv 0 yv 24 cstring2 \"%s\" " // level name + "xv 0 yv 54 cstring2 \"%s\" " // help 1 + "xv 0 yv 110 cstring2 \"%s\" " // help 2 + "xv 50 yv 164 string2 \" kills goals secrets\" " + "xv 50 yv 172 string2 \"%3i/%3i %i/%i %i/%i\" ", + sk, + level.level_name, + game.helpmessage1, + game.helpmessage2, + level.killed_monsters, level.total_monsters, + level.found_goals, level.total_goals, + level.found_secrets, level.total_secrets); + + gi.WriteByte(svc_layout); + gi.WriteString(string); + gi.unicast(ent, qtrue); } @@ -343,27 +325,25 @@ Cmd_Help_f Display the current help message ================== */ -void Cmd_Help_f (edict_t *ent) +void Cmd_Help_f(edict_t *ent) { // this is for backwards compatability - if (deathmatch->value) - { - Cmd_Score_f (ent); + if (deathmatch->value) { + Cmd_Score_f(ent); return; } ent->client->showinventory = qfalse; ent->client->showscores = qfalse; - if (ent->client->showhelp && (ent->client->pers.game_helpchanged == game.helpchanged)) - { + if (ent->client->showhelp && (ent->client->pers.game_helpchanged == game.helpchanged)) { ent->client->showhelp = qfalse; return; } ent->client->showhelp = qtrue; ent->client->pers.helpchanged = 0; - HelpComputer (ent); + HelpComputer(ent); } @@ -374,7 +354,7 @@ void Cmd_Help_f (edict_t *ent) G_SetStats =============== */ -void G_SetStats (edict_t *ent) +void G_SetStats(edict_t *ent) { gitem_t *item; int index, cells; @@ -389,47 +369,39 @@ void G_SetStats (edict_t *ent) // // ammo // - if (!ent->client->ammo_index /* || !ent->client->pers.inventory[ent->client->ammo_index] */) - { + if (!ent->client->ammo_index /* || !ent->client->pers.inventory[ent->client->ammo_index] */) { ent->client->ps.stats[STAT_AMMO_ICON] = 0; ent->client->ps.stats[STAT_AMMO] = 0; - } - else - { + } else { item = &itemlist[ent->client->ammo_index]; - ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex (item->icon); + ent->client->ps.stats[STAT_AMMO_ICON] = gi.imageindex(item->icon); ent->client->ps.stats[STAT_AMMO] = ent->client->pers.inventory[ent->client->ammo_index]; } - + // // armor // - power_armor_type = PowerArmorType (ent); - if (power_armor_type) - { - cells = ent->client->pers.inventory[ITEM_INDEX(FindItem ("cells"))]; - if (cells == 0) - { // ran out of cells for power armor + power_armor_type = PowerArmorType(ent); + if (power_armor_type) { + cells = ent->client->pers.inventory[ITEM_INDEX(FindItem("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"); + 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); + } 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->pers.inventory[index]; - } - else - { + } else { ent->client->ps.stats[STAT_ARMOR_ICON] = 0; ent->client->ps.stats[STAT_ARMOR] = 0; } @@ -437,8 +409,7 @@ void G_SetStats (edict_t *ent) // // pickup message // - if (level.time > ent->client->pickup_msg_time) - { + if (level.time > ent->client->pickup_msg_time) { ent->client->ps.stats[STAT_PICKUP_ICON] = 0; ent->client->ps.stats[STAT_PICKUP_STRING] = 0; } @@ -446,28 +417,19 @@ void G_SetStats (edict_t *ent) // // 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] = (ent->client->quad_framenum - level.framenum)/10; - } - else if (ent->client->invincible_framenum > level.framenum) - { - ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex ("p_invulnerability"); - ent->client->ps.stats[STAT_TIMER] = (ent->client->invincible_framenum - level.framenum)/10; - } - 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] = (ent->client->enviro_framenum - level.framenum)/10; - } - 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] = (ent->client->breather_framenum - level.framenum)/10; - } - else - { + if (ent->client->quad_framenum > level.framenum) { + ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex("p_quad"); + ent->client->ps.stats[STAT_TIMER] = (ent->client->quad_framenum - level.framenum) / 10; + } else if (ent->client->invincible_framenum > level.framenum) { + ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex("p_invulnerability"); + ent->client->ps.stats[STAT_TIMER] = (ent->client->invincible_framenum - level.framenum) / 10; + } 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] = (ent->client->enviro_framenum - level.framenum) / 10; + } 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] = (ent->client->breather_framenum - level.framenum) / 10; + } else { ent->client->ps.stats[STAT_TIMER_ICON] = 0; ent->client->ps.stats[STAT_TIMER] = 0; } @@ -478,7 +440,7 @@ void G_SetStats (edict_t *ent) if (ent->client->pers.selected_item == -1) ent->client->ps.stats[STAT_SELECTED_ICON] = 0; else - ent->client->ps.stats[STAT_SELECTED_ICON] = gi.imageindex (itemlist[ent->client->pers.selected_item].icon); + ent->client->ps.stats[STAT_SELECTED_ICON] = gi.imageindex(itemlist[ent->client->pers.selected_item].icon); ent->client->ps.stats[STAT_SELECTED_ITEM] = ent->client->pers.selected_item; @@ -487,16 +449,13 @@ void G_SetStats (edict_t *ent) // ent->client->ps.stats[STAT_LAYOUTS] = 0; - if (deathmatch->value) - { + if (deathmatch->value) { if (ent->client->pers.health <= 0 || level.intermissiontime || ent->client->showscores) ent->client->ps.stats[STAT_LAYOUTS] |= 1; if (ent->client->showinventory && ent->client->pers.health > 0) ent->client->ps.stats[STAT_LAYOUTS] |= 2; - } - else - { + } else { if (ent->client->showscores || ent->client->showhelp) ent->client->ps.stats[STAT_LAYOUTS] |= 1; if (ent->client->showinventory && ent->client->pers.health > 0) @@ -511,11 +470,11 @@ void G_SetStats (edict_t *ent) // // help icon / current weapon if not shown // - if (ent->client->pers.helpchanged && (level.framenum&8) ) - ent->client->ps.stats[STAT_HELPICON] = gi.imageindex ("i_help"); - else if ( (ent->client->pers.hand == CENTER_HANDED || ent->client->ps.fov > 91) - && ent->client->pers.weapon) - ent->client->ps.stats[STAT_HELPICON] = gi.imageindex (ent->client->pers.weapon->icon); + if (ent->client->pers.helpchanged && (level.framenum & 8)) + ent->client->ps.stats[STAT_HELPICON] = gi.imageindex("i_help"); + else if ((ent->client->pers.hand == CENTER_HANDED || ent->client->ps.fov > 91) + && ent->client->pers.weapon) + ent->client->ps.stats[STAT_HELPICON] = gi.imageindex(ent->client->pers.weapon->icon); else ent->client->ps.stats[STAT_HELPICON] = 0; @@ -527,7 +486,7 @@ void G_SetStats (edict_t *ent) G_CheckChaseStats =============== */ -void G_CheckChaseStats (edict_t *ent) +void G_CheckChaseStats(edict_t *ent) { int i; gclient_t *cl; @@ -546,12 +505,12 @@ void G_CheckChaseStats (edict_t *ent) G_SetSpectatorStats =============== */ -void G_SetSpectatorStats (edict_t *ent) +void G_SetSpectatorStats(edict_t *ent) { gclient_t *cl = ent->client; if (!cl->chase_target) - G_SetStats (ent); + G_SetStats(ent); cl->ps.stats[STAT_SPECTATOR] = 1; @@ -563,8 +522,8 @@ void G_SetSpectatorStats (edict_t *ent) cl->ps.stats[STAT_LAYOUTS] |= 2; if (cl->chase_target && cl->chase_target->inuse) - cl->ps.stats[STAT_CHASE] = CS_PLAYERSKINS + - (cl->chase_target - g_edicts) - 1; + cl->ps.stats[STAT_CHASE] = CS_PLAYERSKINS + + (cl->chase_target - g_edicts) - 1; else cl->ps.stats[STAT_CHASE] = 0; } |