// Draw a list of players on a team. void EATeamPlayerNames(int x, int y, const float scale, const x_align_t x_align, const y_align_t y_align, const x_align_t x_origin, const y_align_t y_origin, const short padding, const short limit, const byte team, const bool force_opaque) { byte drawn = 0; for (size_t i = 0;i < sortedPlayers().size();i++) { // Make sure we're not overrunning our limit. if (limit != 0 && drawn >= limit) { break; } player_t* player = sortedPlayers()[i]; if (inTeamPlayer(player, team)) { int color = CR_GREY; if (sv_gametype == GM_TEAMDM || sv_gametype == GM_CTF) { if (player->userinfo.team == TEAM_BLUE) { if (player->flags[it_redflag]) { color = CR_RED; } else if (player->flags[it_blueflag]) { color = CR_BLUE; } else if (player->ready) { color = CR_GREEN; } else if (player->id == displayplayer().id) { color = CR_GOLD; } } else if (player->userinfo.team == TEAM_RED) { if (player->flags[it_blueflag]) { color = CR_BLUE; } else if (player->flags[it_redflag]) { color = CR_RED; } else if (player->ready) { color = CR_GREEN; } else if (player->id == displayplayer().id) { color = CR_GOLD; } } } else { if (player->id == displayplayer().id) { color = CR_GOLD; } } hud::DrawText(x, y, scale, x_align, y_align, x_origin, y_origin, player->userinfo.netname.c_str(), color, force_opaque); y += 7 + padding; drawn += 1; } } }
// Draw a list of players in the game. void EAPlayerNames(int x, int y, const float scale, const x_align_t x_align, const y_align_t y_align, const x_align_t x_origin, const y_align_t y_origin, const short padding, const short limit, const bool force_opaque) { byte drawn = 0; for (size_t i = 0;i < sortedPlayers().size();i++) { // Make sure we're not overrunning our limit. if (limit != 0 && drawn >= limit) { break; } player_t* player = sortedPlayers()[i]; if (ingamePlayer(player)) { int color = CR_GREY; if (player->id == displayplayer().id) { color = CR_GOLD; } hud::DrawText(x, y, scale, x_align, y_align, x_origin, y_origin, player->userinfo.netname.c_str(), color, force_opaque); y += 7 + padding; drawn += 1; } } }
// Return a string that contains the current team score or personal // frags of the individual player. Optionally returns the "limit" // as well. std::string PersonalScore(int& color) { color = CR_GREY; std::ostringstream buffer; player_t *plyr = &displayplayer(); if (sv_gametype == GM_DM) { buffer << plyr->fragcount; if (sv_fraglimit.asInt() > 0) { buffer << "/" << sv_fraglimit.asInt(); } } else if (sv_gametype == GM_TEAMDM || sv_gametype == GM_CTF) { color = teamTextColor(plyr->userinfo.team); buffer << TEAMpoints[plyr->userinfo.team]; if (sv_gametype == GM_TEAMDM) { if (sv_fraglimit.asInt() > 0) { buffer << "/" << sv_fraglimit.asInt(); } } else { if (sv_scorelimit.asInt() > 0) { buffer << "/" << sv_scorelimit.asInt(); } } } return buffer.str(); }
// // [Toke - CTF] CTF_MoveFlag // Moves the flag that is linked to a player // void CTF_MoveFlags () { // denis - flag is now a boolean for(size_t i = 0; i < NUMFLAGS; i++) { if(CTFdata[i].flagger && CTFdata[i].actor) { player_t &player = idplayer(CTFdata[i].flagger); AActor *flag = CTFdata[i].actor; if(!player.mo || &player == &displayplayer()) { flag->UnlinkFromWorld (); return; } extern fixed_t tmfloorz; extern fixed_t tmceilingz; unsigned an = player.mo->angle >> ANGLETOFINESHIFT; fixed_t x = (player.mo->x + FixedMul (-2*FRACUNIT, finecosine[an])); fixed_t y = (player.mo->y + FixedMul (-2*FRACUNIT, finesine[an])); P_CheckPosition (player.mo, player.mo->x, player.mo->y); flag->UnlinkFromWorld (); flag->x = x; flag->y = y; flag->z = player.mo->z; flag->floorz = tmfloorz; flag->ceilingz = tmceilingz; flag->LinkToWorld (); } }
// // CL_PredictSpying // // Handles calling the thinker routines for the player being spied with spynext. // static void CL_PredictSpying() { player_t *player = &displayplayer(); if (consoleplayer_id == displayplayer_id) return; predicting = false; P_PlayerThink(player); P_CalcHeight(player); }
/* Original redscreen palette method - replaces ZDoom method - ML */ void ST_doPaletteStuff(void) { int palette; byte* pal; float cnt; int bzc; float blend[4]; player_t *plyr = &displayplayer(); blend[0] = blend[1] = blend[2] = blend[3] = 0; SV_AddBlend (BaseBlendR / 255.0f, BaseBlendG / 255.0f, BaseBlendB / 255.0f, BaseBlendA, blend); if (!r_underwater && memcmp (blend, st_zdpalette, sizeof(blend))) { memcpy (st_zdpalette, blend, sizeof(blend)); V_SetBlend ((int)(blend[0] * 255.0f), (int)(blend[1] * 255.0f), (int)(blend[2] * 255.0f), (int)(blend[3] * 256.0f)); } if (r_underwater) { palette = 0; if (plyr->powers[pw_ironfeet] > 4*32 || plyr->powers[pw_ironfeet]&8) SV_AddBlend (0.0f, 1.0f, 0.0f, 0.125f, blend); if (plyr->bonuscount) { cnt = (float)(plyr->bonuscount << 3); SV_AddBlend (0.8431f, 0.7294f, 0.2706f, cnt > 128 ? 0.5f : cnt / 255.0f, blend); } if (plyr->damagecount < 114) cnt = damageToAlpha[(int)(plyr->damagecount*r_painintensity)]; else cnt = damageToAlpha[(int)(113*r_painintensity)]; if (plyr->powers[pw_strength]) { // slowly fade the berzerk out int bzc = 128 - ((plyr->powers[pw_strength]>>3) & (~0x1f)); if (bzc > cnt) cnt = bzc; } if (cnt) { if (cnt > 237) cnt = 237; SV_AddBlend (1.0f, 0.0f, 0.0f, cnt / 255.0f, blend); } }
// Return a string that contains the name of the player being spectated, // or a blank string if you are looking out of your own viewpoint. std::string SpyPlayerName(int& color) { color = CR_GREY; player_t *plyr = &displayplayer(); if (plyr == &consoleplayer()) { return ""; } if (sv_gametype == GM_TEAMDM || sv_gametype == GM_CTF) { color = teamTextColor(plyr->userinfo.team); } return plyr->userinfo.netname; }
// Draw a list of spectators. void EASpectatorNames(int x, int y, const float scale, const x_align_t x_align, const y_align_t y_align, const x_align_t x_origin, const y_align_t y_origin, const short padding, short skip, const short limit, const bool force_opaque) { byte drawn = 0; for (size_t i = 0;i < sortedPlayers().size();i++) { // Make sure we're not overrunning our limit. if (limit != 0 && drawn >= limit) { break; } player_t* player = sortedPlayers()[i]; if (spectatingPlayer(player)) { if (skip <= 0) { int color = CR_GREY; if (sv_gametype == GM_TEAMDM || sv_gametype == GM_CTF) { if (player->ready) { color = CR_GREEN; } else if (player->id == displayplayer().id) { color = CR_GOLD; } } else { if (player->id == displayplayer().id) { color = CR_GOLD; } } hud::DrawText(x, y, scale, x_align, y_align, x_origin, y_origin, player->userinfo.netname.c_str(), color, force_opaque); y += 7 + padding; drawn += 1; } else { skip -= 1; } } } }
void ST_nameDraw (int y) { player_t *plyr = &displayplayer(); if (plyr == &consoleplayer()) return; char *string = plyr->userinfo.netname; size_t x = (screen->width - V_StringWidth (string)*CleanXfac) >> 1; if (level.time < NameUp) screen->DrawTextClean (CR_GREEN, x, y, string); else screen->DrawTextCleanLuc (CR_GREEN, x, y, string); }
int ST_calcPainOffset(void) { int health; static int lastcalc; static int oldhealth = -1; health = displayplayer().health; if(health < -1) health = -1; else if(health > 100) health = 100; if (health != oldhealth) { lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101); oldhealth = health; } return lastcalc; }
// Returns a string that contains the current warmup state. std::string Warmup(int& color) { color = CR_GREY; player_t *dp = &displayplayer(); player_t *cp = &consoleplayer(); ::Warmup::status_t wstatus = warmup.get_status(); if (wstatus == ::Warmup::WARMUP) { if (dp->spectator) return "Warmup: You are spectating"; else if (dp->ready) { color = CR_GREEN; if (dp == cp) return "Warmup: You are ready"; else return "Warmup: This player is ready"; } else { color = CR_RED; if (dp == cp) return "Warmup: You are not ready"; else return "Warmup: This player is not ready"; } } else if (wstatus == ::Warmup::COUNTDOWN || wstatus == ::Warmup::FORCE_COUNTDOWN) { color = CR_GOLD; return "Match is about to start..."; } return ""; }
// // D_Display // draw current display, possibly wiping it from the previous // void D_Display (void) { if (nodrawers) return; // for comparative timing / profiling BEGIN_STAT(D_Display); // [RH] change the screen mode if needed if (setmodeneeded) { // Change screen mode. if (!V_SetResolution (NewWidth, NewHeight, NewBits)) I_FatalError ("Could not change screen mode"); // Recalculate various view parameters. setsizeneeded = true; // Trick status bar into rethinking its position st_scale.Callback (); // Refresh the console. C_NewModeAdjust (); } // [AM] Moved to below setmodeneeded so we have accurate screen size info. if (gamestate == GS_LEVEL && viewactive && consoleplayer().camera) { if (consoleplayer().camera->player) R_SetFOV(consoleplayer().camera->player->fov, setmodeneeded || setsizeneeded); else R_SetFOV(90.0f, setmodeneeded || setsizeneeded); } // change the view size if needed if (setsizeneeded) { R_ExecuteSetViewSize (); setmodeneeded = false; } I_BeginUpdate (); // [RH] Allow temporarily disabling wipes if (NoWipe) { NoWipe--; wipegamestate = gamestate; } else if (gamestate != wipegamestate && gamestate != GS_FULLCONSOLE) { wipegamestate = gamestate; Wipe_Start(); wiping_screen = true; } switch (gamestate) { case GS_FULLCONSOLE: case GS_DOWNLOAD: case GS_CONNECTING: case GS_CONNECTED: C_DrawConsole (); M_Drawer (); I_FinishUpdate (); return; case GS_LEVEL: if (!gametic) break; // denis - freshen the borders (ffs..) R_DrawViewBorder (); // erase old menu stuff if (viewactive) R_RenderPlayerView (&displayplayer()); if (automapactive) AM_Drawer (); C_DrawMid (); C_DrawGMid(); CTF_DrawHud (); ST_Drawer (); HU_Drawer (); break; case GS_INTERMISSION: if (viewactive) R_RenderPlayerView (&displayplayer()); C_DrawMid (); CTF_DrawHud (); WI_Drawer (); HU_Drawer (); break; case GS_FINALE: F_Drawer (); break; case GS_DEMOSCREEN: D_PageDrawer (); break; default: break; } // draw pause pic if (paused && !menuactive) { patch_t *pause = W_CachePatch ("M_PAUSE"); int y; y = (automapactive && !viewactive) ? 4 : viewwindowy + 4; screen->DrawPatchCleanNoMove (pause, (screen->width-(pause->width())*CleanXfac)/2, y); } // [RH] Draw icon, if any if (D_DrawIcon) { int lump = W_CheckNumForName (D_DrawIcon); D_DrawIcon = NULL; if (lump >= 0) { patch_t *p = W_CachePatch (lump); screen->DrawPatchIndirect (p, 160-p->width()/2, 100-p->height()/2); } NoWipe = 10; } if (wiping_screen) Wipe_Drawer(); C_DrawConsole(); // draw console M_Drawer(); // menu is drawn even on top of everything I_FinishUpdate(); // page flip or blit buffer END_STAT(D_Display); }
void ST_Ticker (void) { st_randomnumber = M_Random(); ST_updateWidgets(); st_oldhealth = displayplayer().health; }
void ST_updateWidgets(void) { static int largeammo = 1994; // means "n/a" int i; player_t *plyr = &displayplayer(); // must redirect the pointer if the ready weapon has changed. // if (w_ready.data != plyr->readyweapon) // { if (weaponinfo[plyr->readyweapon].ammo == am_noammo) w_ready.num = &largeammo; else w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo]; //{ // static int tic=0; // static int dir=-1; // if (!(tic&15)) // plyr->ammo[weaponinfo[plyr->readyweapon].ammo]+=dir; // if (plyr->ammo[weaponinfo[plyr->readyweapon].ammo] == -100) // dir = 1; // tic++; // } w_ready.data = plyr->readyweapon; st_health = plyr->health; st_armor = plyr->armorpoints; for(i = 0; i < 4; i++) { st_ammo[i] = plyr->ammo[i]; st_maxammo[i] = plyr->maxammo[i]; } for(i = 0; i < 6; i++) { // denis - longwinded so compiler optimization doesn't skip it (fault in my gcc?) if(plyr->weaponowned[i+1]) st_weaponowned[i] = 1; else st_weaponowned[i] = 0; } st_current_ammo = plyr->ammo[weaponinfo[plyr->readyweapon].ammo]; // if (*w_ready.on) // STlib_updateNum(&w_ready, true); // refresh weapon change // } // update keycard multiple widgets for (i=0;i<3;i++) { keyboxes[i] = plyr->cards[i] ? i : -1; // [RH] show multiple keys per box, too if (plyr->cards[i+3]) keyboxes[i] = (keyboxes[i] == -1) ? i+3 : i+6; } // refresh everything if this is him coming back to life ST_updateFaceWidget(); // used by w_arms[] widgets st_armson = st_statusbaron && sv_gametype == GM_COOP; // used by w_frags widget st_fragson = sv_gametype != GM_COOP && st_statusbaron; // [Toke - CTF] if (sv_gametype == GM_CTF) st_fragscount = TEAMpoints[plyr->userinfo.team]; // denis - todo - scoring for ctf else st_fragscount = plyr->fragcount; // [RH] Just use cumulative total if (sv_gametype == GM_CTF) { switch(CTFdata[it_blueflag].state) { case flag_home: st_flagboxbluon = true; break; case flag_carried: st_flagboxbluon = false; break; case flag_dropped: CTFdata[it_blueflag].sb_tick++; if (CTFdata[it_blueflag].sb_tick == 10) CTFdata[it_blueflag].sb_tick = 0; if (CTFdata[it_blueflag].sb_tick < 8) st_flagboxbluon = false; else st_flagboxbluon = true; break; default: break; } switch(CTFdata[it_redflag].state) { case flag_home: st_flagboxredon = true; break; case flag_carried: st_flagboxredon = false; break; case flag_dropped: CTFdata[it_redflag].sb_tick++; if (CTFdata[it_redflag].sb_tick == 10) CTFdata[it_redflag].sb_tick = 0; if (CTFdata[it_redflag].sb_tick < 8) st_flagboxredon = false; else st_flagboxredon = true; break; default: break; } } // get rid of chat window if up because of message if (!--st_msgcounter) st_chat = st_oldchat; }
// // This is a not-very-pretty routine which handles // the face states and their timing. // the precedence of expressions is: // dead > evil grin > turned head > straight ahead // void ST_updateFaceWidget(void) { int i; angle_t badguyangle; angle_t diffang; static int lastattackdown = -1; static int priority = 0; BOOL doevilgrin; player_t *plyr = &displayplayer(); if (priority < 10) { // dead if (!plyr->health) { priority = 9; st_faceindex = ST_DEADFACE; st_facecount = 1; } } if (priority < 9) { if (plyr->bonuscount) { // picking up bonus doevilgrin = false; for (i=0;i<NUMWEAPONS;i++) { if (oldweaponsowned[i] != plyr->weaponowned[i]) { doevilgrin = true; oldweaponsowned[i] = plyr->weaponowned[i]; } } if (doevilgrin) { // evil grin if just picked up weapon priority = 8; st_facecount = ST_EVILGRINCOUNT; st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET; } } } if (priority < 8) { if (plyr->damagecount && plyr->attacker && plyr->attacker != plyr->mo) { // being attacked priority = 7; if (st_oldhealth - plyr->health > ST_MUCHPAIN) { st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; } else { badguyangle = R_PointToAngle2(plyr->mo->x, plyr->mo->y, plyr->attacker->x, plyr->attacker->y); if (badguyangle > plyr->mo->angle) { // whether right or left diffang = badguyangle - plyr->mo->angle; i = diffang > ANG180; } else { // whether left or right diffang = plyr->mo->angle - badguyangle; i = diffang <= ANG180; } // confusing, aint it? st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset(); if (diffang < ANG45) { // head-on st_faceindex += ST_RAMPAGEOFFSET; } else if (i) { // turn face right st_faceindex += ST_TURNOFFSET; } else { // turn face left st_faceindex += ST_TURNOFFSET+1; } } } } if (priority < 7) { // getting hurt because of your own damn stupidity if (plyr->damagecount) { if (st_oldhealth - plyr->health > ST_MUCHPAIN) { priority = 7; st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; } else { priority = 6; st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; } } } if (priority < 6) { // rapid firing if (plyr->attackdown) { if (lastattackdown==-1) lastattackdown = ST_RAMPAGEDELAY; else if (!--lastattackdown) { priority = 5; st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; st_facecount = 1; lastattackdown = 1; } } else lastattackdown = -1; } if (priority < 5) { // invulnerability if ((plyr->cheats & CF_GODMODE) || plyr->powers[pw_invulnerability]) { priority = 4; st_faceindex = ST_GODFACE; st_facecount = 1; } } // look left or look right if the facecount has timed out if (!st_facecount) { st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3); st_facecount = ST_STRAIGHTFACECOUNT; priority = 0; } st_facecount--; }
// // [Toke - CTF] CL_CTFEvent // Deals with CTF specific network data // void CL_CTFEvent (void) { flag_score_t event = (flag_score_t)MSG_ReadByte(); if(event == SCORE_NONE) // CTF state refresh { CTF_Connect(); return; } flag_t flag = (flag_t)MSG_ReadByte(); player_t &player = idplayer(MSG_ReadByte()); int points = MSG_ReadLong(); if(validplayer(player)) player.points = points; for(size_t i = 0; i < NUMFLAGS; i++) TEAMpoints[i] = MSG_ReadLong (); switch(event) { default: case SCORE_NONE: case SCORE_REFRESH: case SCORE_KILL: case SCORE_BETRAYAL: case SCORE_CARRIERKILL: break; case SCORE_GRAB: case SCORE_FIRSTGRAB: case SCORE_MANUALRETURN: if(validplayer(player)) { CTF_CarryFlag(player, flag); if (player.id == displayplayer().id) player.bonuscount = BONUSADD; } break; case SCORE_CAPTURE: if (validplayer(player)) { player.flags[flag] = 0; } CTFdata[flag].flagger = 0; CTFdata[flag].state = flag_home; if(CTFdata[flag].actor) CTFdata[flag].actor->Destroy(); break; case SCORE_RETURN: if (validplayer(player)) { player.flags[flag] = 0; } CTFdata[flag].flagger = 0; CTFdata[flag].state = flag_home; if(CTFdata[flag].actor) CTFdata[flag].actor->Destroy(); break; case SCORE_DROP: if (validplayer(player)) { player.flags[flag] = 0; } CTFdata[flag].flagger = 0; CTFdata[flag].state = flag_dropped; if(CTFdata[flag].actor) CTFdata[flag].actor->Destroy(); break; } // [AM] Play CTF sound, moved from server. CTF_Sound(flag, event); }
// Return a "spread" of personal frags or team points that the // current player or team is ahead or behind by. std::string PersonalSpread(int& color) { color = CR_BRICK; player_t *plyr = &displayplayer(); if (sv_gametype == GM_DM) { // Seek the highest number of frags. byte ingame = 0; size_t maxother = 0; short maxfrags = -32768; for (size_t i = 0;i < players.size();i++) { if (!validplayer(players[i])) { continue; } if (!players[i].ingame() || players[i].spectator) { continue; } if (players[i].fragcount == maxfrags) { maxother++; } if (players[i].fragcount > maxfrags) { maxfrags = players[i].fragcount; maxother = 0; } ingame += 1; } // A spread needs two players to make sense. if (ingame <= 1) { return ""; } // Return the correct spread. if (maxfrags == plyr->fragcount && maxother > 0) { // We have the maximum number of frags but we share the // throne with someone else. But at least we can take // a little shortcut here. color = CR_GREEN; return "+0"; } std::ostringstream buffer; if (maxfrags == plyr->fragcount) { // We have the maximum number of frags. Calculate how // far above the other players we are. short nextfrags = -32768; for (size_t i = 0;i < players.size();i++) { if (!validplayer(players[i])) { continue; } if (!players[i].ingame() || players[i].spectator) { continue; } if (players[i].id == plyr->id) { continue; } if (players[i].fragcount > nextfrags) { nextfrags = players[i].fragcount; } } color = CR_GREEN; buffer << "+" << maxfrags - nextfrags; return buffer.str(); } // We are behind the leader. buffer << (plyr->fragcount - maxfrags); return buffer.str(); } else if (sv_gametype == GM_TEAMDM || sv_gametype == GM_CTF) { // Team spreads are significantly easier. Just compare two numbers. // FIXME: Not if we have more than two teams! std::ostringstream buffer; switch (plyr->userinfo.team) { case TEAM_BLUE: if (TEAMpoints[TEAM_BLUE] >= TEAMpoints[TEAM_RED]) { color = CR_GREEN; buffer << "+"; } buffer << (TEAMpoints[TEAM_BLUE] - TEAMpoints[TEAM_RED]); break; case TEAM_RED: if (TEAMpoints[TEAM_RED] >= TEAMpoints[TEAM_BLUE]) { color = CR_GREEN; buffer << "+"; } buffer << (TEAMpoints[TEAM_RED] - TEAMpoints[TEAM_BLUE]); break; default: // No valid team? Something is wrong... return ""; } return buffer.str(); } // We're not in an appropriate gamemode. return ""; }
// // D_Display // draw current display, possibly wiping it from the previous // void D_Display (void) { BOOL wipe; if (nodrawers) return; // for comparative timing / profiling BEGIN_STAT(D_Display); if (gamestate == GS_LEVEL && viewactive && consoleplayer().camera) R_SetFOV (consoleplayer().camera->player ? consoleplayer().camera->player->fov : 90.0f); // [RH] change the screen mode if needed if (setmodeneeded) { int oldwidth = screen->width; int oldheight = screen->height; int oldbits = DisplayBits; // Change screen mode. if (!V_SetResolution (NewWidth, NewHeight, NewBits)) if (!V_SetResolution (oldwidth, oldheight, oldbits)) I_FatalError ("Could not change screen mode"); // Recalculate various view parameters. setsizeneeded = true; // Trick status bar into rethinking its position st_scale.Callback (); // Refresh the console. C_NewModeAdjust (); } // change the view size if needed if (setsizeneeded) { R_ExecuteSetViewSize (); setmodeneeded = false; } I_BeginUpdate (); // [RH] Allow temporarily disabling wipes if (NoWipe) { NoWipe--; wipe = false; wipegamestate = gamestate; } else if (gamestate != wipegamestate && gamestate != GS_FULLCONSOLE) { // save the current screen if about to wipe wipe = true; wipe_StartScreen (); wipegamestate = gamestate; } else { wipe = false; } switch (gamestate) { case GS_FULLCONSOLE: case GS_DOWNLOAD: case GS_CONNECTING: C_DrawConsole (); M_Drawer (); I_FinishUpdate (); return; case GS_LEVEL: if (!gametic) break; // denis - freshen the borders (ffs..) R_DrawViewBorder (); // erase old menu stuff if (viewactive) R_RenderPlayerView (&displayplayer()); if (automapactive) AM_Drawer (); C_DrawMid (); CTF_DrawHud (); ST_Drawer (); HU_Drawer (); break; case GS_INTERMISSION: if (viewactive) R_RenderPlayerView (&displayplayer()); C_DrawMid (); CTF_DrawHud (); WI_Drawer (); HU_Drawer (); break; case GS_FINALE: F_Drawer (); break; case GS_DEMOSCREEN: D_PageDrawer (); break; default: break; } // draw pause pic if (paused && !menuactive) { patch_t *pause = W_CachePatch ("M_PAUSE"); int y; y = (automapactive && !viewactive) ? 4 : viewwindowy + 4; screen->DrawPatchCleanNoMove (pause, (screen->width-(pause->width())*CleanXfac)/2, y); } // [RH] Draw icon, if any if (D_DrawIcon) { int lump = W_CheckNumForName (D_DrawIcon); D_DrawIcon = NULL; if (lump >= 0) { patch_t *p = W_CachePatch (lump); screen->DrawPatchIndirect (p, 160-p->width()/2, 100-p->height()/2); } NoWipe = 10; } static bool live_wiping = false; if (!wipe) { if(live_wiping) { // wipe update online (multiple calls, not just looping here) C_DrawConsole (); wipe_EndScreen(); live_wiping = !wipe_ScreenWipe (1); M_Drawer (); // menu is drawn even on top of wipes I_FinishUpdate (); // page flip or blit buffer } else { // normal update C_DrawConsole (); // draw console M_Drawer (); // menu is drawn even on top of everything I_FinishUpdate (); // page flip or blit buffer } } else { if(!connected) { // wipe update offline int wipestart, wipecont, nowtime, tics; BOOL done; C_DrawConsole (); wipe_EndScreen (); I_FinishUpdateNoBlit (); extern int canceltics; wipestart = I_GetTime (); wipecont = wipestart - 1; do { do { nowtime = I_GetTime (); tics = nowtime - wipecont; } while (!tics); wipecont = nowtime; I_BeginUpdate (); done = wipe_ScreenWipe (tics); M_Drawer (); // menu is drawn even on top of wipes I_FinishUpdate (); // page flip or blit buffer } while (!done); if(!connected) canceltics += I_GetTime () - wipestart; } else { // wipe update online live_wiping = true; // wipe update online (multiple calls, not just looping here) C_DrawConsole (); wipe_EndScreen(); live_wiping = !wipe_ScreenWipe (1); M_Drawer (); // menu is drawn even on top of wipes I_FinishUpdate (); // page flip or blit buffer } } END_STAT(D_Display); }
// // P_SpawnPlayer // Called when a player is spawned on the level. // Most of the player structure stays unchanged // between levels. // void P_SpawnPlayer (player_t &player, mapthing2_t *mthing) { // denis - clients should not control spawning if(!serverside) return; // [RH] Things 4001-? are also multiplayer starts. Just like 1-4. // To make things simpler, figure out which player is being // spawned here. player_t *p = &player; // not playing? if(!p->ingame()) return; if (p->playerstate == PST_REBORN || p->playerstate == PST_ENTER) { G_PlayerReborn (*p); // [AM] If we're "reborn" as a spectator, don't touch the keepinventory // flag, but otherwise turn it off. if (!p->spectator) p->keepinventory = false; } AActor *mobj = new AActor (mthing->x << FRACBITS, mthing->y << FRACBITS, ONFLOORZ, MT_PLAYER); // set color translations for player sprites // [RH] Different now: MF_TRANSLATION is not used. mobj->translation = translationtables + 256*p->id; mobj->angle = ANG45 * (mthing->angle/45); mobj->pitch = mobj->roll = 0; mobj->player = p; mobj->health = p->health; // [RH] Set player sprite based on skin if(p->userinfo.skin >= numskins) p->userinfo.skin = 0; mobj->sprite = skins[p->userinfo.skin].sprite; p->fov = 90.0f; p->mo = p->camera = mobj->ptr(); p->playerstate = PST_LIVE; p->refire = 0; p->damagecount = 0; p->bonuscount = 0; p->extralight = 0; p->fixedcolormap = 0; p->viewheight = VIEWHEIGHT; p->xviewshift = 0; p->attacker = AActor::AActorPtr(); consoleplayer().camera = displayplayer().mo; // Set up some special spectator stuff if (p->spectator) { mobj->translucency = 0; p->mo->flags |= MF_SPECTATOR; p->mo->flags2 |= MF2_FLY; p->mo->flags &= ~MF_SOLID; } // [RH] Allow chasecam for demo watching if ((demoplayback || demonew) && chasedemo) p->cheats = CF_CHASECAM; // setup gun psprite P_SetupPsprites (p); // give all cards in death match mode if (sv_gametype != GM_COOP) { for (int i = 0; i < NUMCARDS; i++) p->cards[i] = true; } if (consoleplayer().camera == p->mo) { // wake up the status bar ST_Start (); } // [RH] If someone is in the way, kill them P_TeleportMove (mobj, mobj->x, mobj->y, mobj->z, true); // [BC] Do script stuff if (serverside) { if (level.behavior != NULL) { if (p->playerstate == PST_ENTER) { level.behavior->StartTypedScripts (SCRIPT_Enter, p->mo); } else if (p->playerstate == PST_REBORN) { level.behavior->StartTypedScripts (SCRIPT_Respawn, p->mo); } } } }
// // D_Display // draw current display, possibly wiping it from the previous // void D_Display (void) { if (nodrawers) return; // for comparative timing / profiling BEGIN_STAT(D_Display); // [RH] change the screen mode if needed if (setmodeneeded) { // Change screen mode. if (!V_SetResolution (NewWidth, NewHeight, NewBits)) I_FatalError ("Could not change screen mode"); // Recalculate various view parameters. setsizeneeded = true; // Trick status bar into rethinking its position st_scale.Callback (); // Refresh the console. C_NewModeAdjust (); } // [AM] Moved to below setmodeneeded so we have accurate screen size info. if (gamestate == GS_LEVEL && viewactive && consoleplayer().camera) { if (consoleplayer().camera->player) R_SetFOV(consoleplayer().camera->player->fov, setmodeneeded || setsizeneeded); else R_SetFOV(90.0f, setmodeneeded || setsizeneeded); } // change the view size if needed if (setsizeneeded) { R_ExecuteSetViewSize (); setmodeneeded = false; } I_BeginUpdate (); // [RH] Allow temporarily disabling wipes if (NoWipe) { NoWipe--; wipegamestate = gamestate; } else if (gamestate != wipegamestate && gamestate != GS_FULLCONSOLE) { wipegamestate = gamestate; Wipe_Start(); wiping_screen = true; } switch (gamestate) { case GS_FULLCONSOLE: case GS_DOWNLOAD: case GS_CONNECTING: case GS_CONNECTED: C_DrawConsole (); M_Drawer (); I_FinishUpdate (); return; case GS_LEVEL: if (!gametic) break; V_DoPaletteEffects(); if (viewactive) R_RenderPlayerView(&displayplayer()); if (automapactive) AM_Drawer(); V_RestorePalettes(); R_DrawViewBorder(); C_DrawMid (); C_DrawGMid(); CTF_DrawHud (); ST_Drawer (); HU_Drawer (); break; case GS_INTERMISSION: if (viewactive) R_RenderPlayerView(&displayplayer()); C_DrawMid (); CTF_DrawHud (); WI_Drawer (); HU_Drawer (); break; case GS_FINALE: F_Drawer (); break; case GS_DEMOSCREEN: D_PageDrawer (); break; default: break; } // draw pause pic if (paused && !menuactive) { const Texture* texture = R_LoadTexture("M_PAUSE"); int x = (screen->width - texture->getWidth() * CleanXfac) / 2; int y = (automapactive && !viewactive) ? 4 : viewwindowy + 4; screen->DrawTextureCleanNoMove(texture, x, y); } // [RH] Draw icon, if any if (D_DrawIcon) { texhandle_t texhandle = texturemanager.getHandle(D_DrawIcon, Texture::TEX_PATCH); const Texture* texture = texturemanager.getTexture(texhandle); D_DrawIcon = NULL; int x = 160 - texture->getWidth() / 2; int y = 100 - texture->getHeight() / 2; screen->DrawTextureIndirect(texture, x, y); NoWipe = 10; } if (wiping_screen) Wipe_Drawer(); C_DrawConsole(); // draw console M_Drawer(); // menu is drawn even on top of everything I_FinishUpdate(); // page flip or blit buffer END_STAT(D_Display); }
// Draw a list of targets. Thanks to GhostlyDeath for the original function. void EATargets(int x, int y, const float scale, const x_align_t x_align, const y_align_t y_align, const x_align_t x_origin, const y_align_t y_origin, const short padding, const short limit, const bool force_opaque) { if (gamestate != GS_LEVEL) { // We're not in the game. return; } if(!displayplayer().mo) { // For some reason, the displayed player doesn't have a mobj, so // if we let this function run we're going to crash. return; } if (!hud_targetnames) { // We don't want to see target names. return; } if (!consoleplayer().spectator && !sv_allowtargetnames) { // The server doesn't want us to use target names. return; } std::vector<TargetInfo_t> Targets; // What players should be drawn? for (size_t i = 0; i < players.size();i++) { if (players[i].spectator || !players[i].mo || players[i].mo->health <= 0) continue; // We don't care about the player whose eyes we are looking through. if (&(players[i]) == &(displayplayer())) continue; if (!P_ActorInFOV(displayplayer().mo, players[i].mo, 45.0f, 512*FRACUNIT)) continue; // Pick a decent color for the player name. int color; if (sv_gametype == GM_TEAMDM || sv_gametype == GM_CTF) { // In teamgames, we want to use team colors for targets. color = teamTextColor(players[i].userinfo.team); } else { color = CR_GREY; } // Ok, make the temporary player info then add it TargetInfo_t temp = { &players[i], P_AproxDistance2(displayplayer().mo, players[i].mo) >> FRACBITS, color }; Targets.push_back(temp); } // GhostlyDeath -- Now Sort (hopefully I got my selection sort working!) for (size_t i = 0; i < Targets.size(); i++) { for (size_t j = i + 1; j < Targets.size(); j++) { if (Targets[j].Distance < Targets[i].Distance) { player_t* PlayPtr = Targets[i].PlayPtr; int Distance = Targets[i].Distance; int Color = Targets[i].Color; Targets[i].PlayPtr = Targets[j].PlayPtr; Targets[i].Distance = Targets[j].Distance; Targets[i].Color = Targets[j].Color; Targets[j].PlayPtr = PlayPtr; Targets[j].Distance = Distance; Targets[j].Color = Color; } } } // [AM] New ElementArray drawing function byte drawn = 0; for (size_t i = 0;i < Targets.size();i++) { // Make sure we're not overrunning our limit. if (limit != 0 && drawn >= limit) { break; } if (Targets[i].PlayPtr == &(consoleplayer())) { // You're looking at yourself. hud::DrawText(x, y, scale, x_align, y_align, x_origin, y_origin, "You", Targets[i].Color); } else { hud::DrawText(x, y, scale, x_align, y_align, x_origin, y_origin, Targets[i].PlayPtr->userinfo.netname.c_str(), Targets[i].Color); } y += 7 + padding; drawn += 1; } }