diff --git a/Quake/in_sdl.c b/Quake/in_sdl.c index b312d365..1e7f5975 100644 --- a/Quake/in_sdl.c +++ b/Quake/in_sdl.c @@ -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 @@ -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); } @@ -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); } diff --git a/Quake/sbar.c b/Quake/sbar.c index 07641e72..d1b3f1f6 100644 --- a/Quake/sbar.c +++ b/Quake/sbar.c @@ -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 ============== */ @@ -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 -} - +} \ No newline at end of file