Skip to content

Commit

Permalink
only inform teammates if you have them
Browse files Browse the repository at this point in the history
  • Loading branch information
timbergeron committed Sep 25, 2024
1 parent fc140ad commit baa8cca
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Quake/in_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ void BGM_Resume(void); // woods #mute - music
void Host_Name_Backup_f(void); // woods #smartafk
void Host_Name_Load_Backup_f(void); // woods #smartafk

qboolean IsOneVsOneMatch (void); // woods #detectmatch

#ifdef __APPLE__
/* Mouse acceleration needs to be disabled on OS X */
#define MACOS_X_ACCELERATION_HACK
Expand Down Expand Up @@ -1249,7 +1251,7 @@ void IN_SendKeyEvents (void)
}

// be polite during matches (only) and let teammates know you have alt-tabbed
if (cl.notobserver && cl.matchinp && cl.teamcolor[0])
if (cl.notobserver && cl.matchinp && cl.teamcolor[0] && !IsOneVsOneMatch())
Cmd_ExecuteString("say_team \"back from alt-tab\"", src_command);
}

Expand Down Expand Up @@ -1283,7 +1285,7 @@ void IN_SendKeyEvents (void)
}

// be polite during matches (only) and let teammates know you have alt-tabbed
if (cl.notobserver && cl.matchinp && cl.teamcolor[0])
if (cl.notobserver && cl.matchinp && cl.teamcolor[0] && !IsOneVsOneMatch())
Cmd_ExecuteString("say_team alt-tabbed", src_command);
}

Expand Down
37 changes: 35 additions & 2 deletions Quake/sbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,40 @@ void Sbar_DrawInventory_QE (void)

//=============================================================================

/*===============
IsOneVsOneMatch -- detect if match is 1v1 match #detectmatch
============== */
qboolean IsOneVsOneMatch (void)
{
const int TEAM_RED = 4;
const int TEAM_BLUE = 13;

int redTeamCount = 0;
int blueTeamCount = 0;

for (int i = 0; i < scoreboardlines; i++)
{
int playerIndex = fragsort[i];
scoreboard_t* score = &cl.scores[playerIndex];

if (score->name[0] == '\0') // Skip entries with empty names
continue;

if (score->pants.basic == TEAM_RED) // Count players based on their team
{
redTeamCount++;
}
else if (score->pants.basic == TEAM_BLUE)
{
blueTeamCount++;
}
}

int totalTeamPlayers = redTeamCount + blueTeamCount;

return (totalTeamPlayers <= 2); // accounts for scenarios where a player might leave
}

/*===============
Sbar_DrawFrags -- for proquake, HEAVILY modified (draws match time, and teamscores) replace this entire function // woods #pqteam
============== */
Expand Down Expand Up @@ -2421,5 +2455,4 @@ void Sbar_FinaleOverlay (void)

pic = Draw_CachePic ("gfx/finale.lmp");
Draw_Pic ( (320 - pic->width)/2, 16, pic); //johnfitz -- stretched menus
}

}

0 comments on commit baa8cca

Please sign in to comment.