From 3b4b7a05fdc6ff5c74c6a56c58599f1213fa6c31 Mon Sep 17 00:00:00 2001 From: Inuyasha Date: Wed, 6 Apr 2016 19:55:58 -0700 Subject: [PATCH] Better CTF in splitscreen, no death message for spectators --- src/p_inter.c | 66 +++++++++++++++++++++++++++++++++++++++++---------- src/p_mobj.c | 10 ++++---- src/p_spec.c | 4 ++-- src/p_user.c | 4 ++-- 4 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 8fb517d5..c08f1f26 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -27,6 +27,10 @@ #include "m_misc.h" #include "v_video.h" // video flags for CEchos +// CTF player names +#define CTFTEAMCODE(pl) pl->ctfteam ? (pl->ctfteam == 1 ? "\x85" : "\x84") : "" +#define CTFTEAMENDCODE(pl) pl->ctfteam ? "\x80" : "" + void P_ForceFeed(const player_t *player, INT32 attack, INT32 fade, tic_t duration, INT32 period) { BasicFF_t Basicfeed; @@ -574,11 +578,23 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { UINT8 flagteam = (special->type == MT_REDFLAG) ? 1 : 2; const char *flagtext; + char flagcolor; + char plname[MAXPLAYERNAME+4]; if (special->type == MT_REDFLAG) - flagtext = M_GetText("red"); + { + flagtext = M_GetText("Red flag"); + flagcolor = '\x85'; + } else - flagtext = M_GetText("blue"); + { + flagtext = M_GetText("Blue flag"); + flagcolor = '\x84'; + } + snprintf(plname, sizeof(plname), "%s%s%s", + CTFTEAMCODE(player), + player_names[player - players], + CTFTEAMENDCODE(player)); if (player->ctfteam == flagteam) // Player is on the same team as the flag { @@ -592,10 +608,11 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!P_PlayerTouchingSectorSpecial(player, 4, 2 + flagteam)) { - CONS_Printf(M_GetText("%s returned the %s flag to base.\n"), player_names[player-players], flagtext); + CONS_Printf(M_GetText("%s returned the %c%s%c to base.\n"), plname, flagcolor, flagtext, 0x80); - if (players[consoleplayer].ctfteam == player->ctfteam) - S_StartSound(NULL, sfx_hoop1); + // The fuse code plays this sound effect + //if (players[consoleplayer].ctfteam == player->ctfteam) + // S_StartSound(NULL, sfx_hoop1); } } } @@ -608,7 +625,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; player->gotflag |= flagflag; - CONS_Printf(M_GetText("%s picked up the %s flag!\n"), player_names[player-players], flagtext); + CONS_Printf(M_GetText("%s picked up the %c%s%c!\n"), plname, flagcolor, flagtext, 0x80); (*flagmobj) = NULL; // code for dealing with abilities is handled elsewhere now break; @@ -1447,9 +1464,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) P_KillMobj(special, NULL, toucher); } -#define CTFTEAMCODE(pl) pl->ctfteam ? (pl->ctfteam == 1 ? "\x85" : "\x84") : "" -#define CTFTEAMENDCODE(pl) pl->ctfteam ? "\x80" : "" - /** Prints death messages relating to a dying or hit player. * * \param player Affected player. @@ -1472,6 +1486,9 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour if (!player) return; // Impossible! + if (player->spectator) + return; // No messages for dying (crushed) spectators. + if (!netgame) return; // Presumably it's obvious what's happening in splitscreen. @@ -3618,10 +3635,33 @@ void P_PlayerFlagBurst(player_t *player, boolean toss) flag->fuse = cv_flagtime.value * TICRATE; P_SetTarget(&flag->target, player->mo); - if (toss) - CONS_Printf(M_GetText("%s tossed the %s flag.\n"), player_names[player-players], (type == MT_REDFLAG ? "red" : "blue")); - else - CONS_Printf(M_GetText("%s dropped the %s flag.\n"), player_names[player-players], (type == MT_REDFLAG ? "red" : "blue")); + // Flag text + { + char plname[MAXPLAYERNAME+4]; + char *flagtext; + char flagcolor; + + snprintf(plname, sizeof(plname), "%s%s%s", + CTFTEAMCODE(player), + player_names[player - players], + CTFTEAMENDCODE(player)); + + if (type == MT_REDFLAG) + { + flagtext = M_GetText("Red flag"); + flagcolor = '\x85'; + } + else + { + flagtext = M_GetText("Blue flag"); + flagcolor = '\x84'; + } + + if (toss) + CONS_Printf(M_GetText("%s tossed the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); + else + CONS_Printf(M_GetText("%s dropped the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); + } player->gotflag = 0; diff --git a/src/p_mobj.c b/src/p_mobj.c index 42571a5c..ce67f1a5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7149,9 +7149,10 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->type == MT_REDFLAG) { if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The red flag has returned to base.\n")); + CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); - if (players[consoleplayer].ctfteam == 1) + // Assumedly in splitscreen players will be on opposing teams + if (players[consoleplayer].ctfteam == 1 || splitscreen) S_StartSound(NULL, sfx_hoop1); redflag = flagmo; @@ -7159,9 +7160,10 @@ void P_MobjThinker(mobj_t *mobj) else // MT_BLUEFLAG { if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The blue flag has returned to base.\n")); + CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); - if (players[consoleplayer].ctfteam == 2) + // Assumedly in splitscreen players will be on opposing teams + if (players[consoleplayer].ctfteam == 2 || splitscreen) S_StartSound(NULL, sfx_hoop1); blueflag = flagmo; diff --git a/src/p_spec.c b/src/p_spec.c index 76c3484c..37a05946 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3781,7 +3781,7 @@ DoneSection2: HU_SetCEchoDuration(5); HU_DoCEcho(va(M_GetText("%s\\captured the blue flag.\\\\\\\\"), player_names[player-players])); - if (players[consoleplayer].ctfteam == 1) + if (splitscreen || players[consoleplayer].ctfteam == 1) S_StartSound(NULL, sfx_flgcap); else if (players[consoleplayer].ctfteam == 2) S_StartSound(NULL, sfx_lose); @@ -3814,7 +3814,7 @@ DoneSection2: HU_SetCEchoDuration(5); HU_DoCEcho(va(M_GetText("%s\\captured the red flag.\\\\\\\\"), player_names[player-players])); - if (players[consoleplayer].ctfteam == 2) + if (splitscreen || players[consoleplayer].ctfteam == 2) S_StartSound(NULL, sfx_flgcap); else if (players[consoleplayer].ctfteam == 1) S_StartSound(NULL, sfx_lose); diff --git a/src/p_user.c b/src/p_user.c index 6942f2fc..72d99d6d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8456,9 +8456,9 @@ static boolean P_SpectatorJoinGame(player_t *player) displayplayer = consoleplayer; if (changeto == 1) - CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x85', M_GetText("Red Team"), '\x80'); + CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x85', M_GetText("Red team"), '\x80'); else if (changeto == 2) - CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x84', M_GetText("Blue Team"), '\x80'); + CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x84', M_GetText("Blue team"), '\x80'); return true; // no more player->mo, cannot continue. }