int QDECL CG_SortFireTeam(const void *a, const void *b) { clientInfo_t *ca, *cb; int cna, cnb; cna = *(int *)a; cnb = *(int *)b; ca = &cgs.clientinfo[cna]; cb = &cgs.clientinfo[cnb]; // not on our team, so shove back if (!CG_IsOnSameFireteam(cnb, cg.clientNum)) { return -1; } if (!CG_IsOnSameFireteam(cna, cg.clientNum)) { return 1; } // leader comes first if (CG_IsFireTeamLeader(cna)) { return -1; } if (CG_IsFireTeamLeader(cnb)) { return 1; } // then higher ranks if (ca->rank > cb->rank) { return -1; } if (cb->rank > ca->rank) { return 1; } // then score //if ( ca->score > cb->score ) { // return -1; //} //if ( cb->score > ca->score ) { // return 1; //} // not atm return 0; }
int QDECL CG_SortFireTeam(const void *a, const void *b) { int cna, cnb; cna = *(int *)a; cnb = *(int *)b; // Not on our team, so shove back if (!CG_IsOnSameFireteam(cnb, cg.clientNum)) { return -1; } if (!CG_IsOnSameFireteam(cna, cg.clientNum)) { return 1; } // Leader comes first if (CG_IsFireTeamLeader(cna)) { return -1; } if (CG_IsFireTeamLeader(cnb)) { return 1; } return 0; }
void CG_Fireteams_MenuText_Draw(panel_button_t *button) { float y = button->rect.y; int i; switch (cgs.ftMenuMode) { case 0: if (cgs.ftMenuPos == -1) { for (i = 0; ftMenuRootStrings[i]; i++) { const char *str; if (i < 5) { if (!CG_FireteamHasClass(i, qtrue)) { continue; } } if (cg_quickMessageAlt.integer) { str = va("%i. %s", (i + 1) % 10, ftMenuRootStrings[i]); } else { str = va("%s. %s", ftMenuRootStringsAlphachars[i], ftMenuRootStrings[i]); } CG_Text_Paint_Ext(button->rect.x, y, button->font->scalex, button->font->scaley, button->font->colour, str, 0, 0, button->font->style, button->font->font); y += button->rect.h; } } else { if (cgs.ftMenuPos < 0 || cgs.ftMenuPos > 4) { return; } else { const char **strings = ftMenuStrings[cgs.ftMenuPos]; for (i = 0; strings[i]; i++) { const char *str; if (cg_quickMessageAlt.integer) { str = va("%i. %s", (i + 1) % 10, strings[i]); } else { str = va("%s. %s", (ftMenuStringsAlphachars[cgs.ftMenuPos])[i], strings[i]); } CG_Text_Paint_Ext(button->rect.x, y, button->font->scalex, button->font->scaley, button->font->colour, str, 0, 0, button->font->style, button->font->font); y += button->rect.h; } } } break; case 1: if (!CG_IsOnFireteam(cg.clientNum)) { for (i = 0; ftOffMenuList[i]; i++) { const char *str; if (i == 0 && !CG_CountFireteamsByTeam(cgs.clientinfo[cg.clientNum].team)) { continue; } if (cg_quickMessageAlt.integer) { str = va("%i. %s", (i + 1) % 10, ftOffMenuList[i]); } else { str = va("%s. %s", ftOffMenuListAlphachars[i], ftOffMenuList[i]); } CG_Text_Paint_Ext(button->rect.x, y, button->font->scalex, button->font->scaley, button->font->colour, str, 0, 0, button->font->style, button->font->font); y += button->rect.h; } } else { if (!CG_IsFireTeamLeader(cg.clientNum)) { for (i = 0; ftOnMenuList[i]; i++) { const char *str; if (i == 0 && !CG_CountPlayersNF()) { continue; } if (cg_quickMessageAlt.integer) { str = va("%i. %s", (i + 1) % 10, ftOnMenuList[i]); } else { str = va("%s. %s", ftOnMenuListAlphachars[i], ftOnMenuList[i]); } CG_Text_Paint_Ext(button->rect.x, y, button->font->scalex, button->font->scaley, button->font->colour, str, 0, 0, button->font->style, button->font->font); y += button->rect.h; } } else { for (i = 0; ftLeaderMenuList[i]; i++) { const char *str; if (i == 2 && !CG_CountPlayersNF()) { continue; } if ((i == 3 || i == 4) && !CG_CountPlayersSF()) { continue; } if (cg_quickMessageAlt.integer) { str = va("%i. %s", (i + 1) % 10, ftLeaderMenuList[i]); } else { str = va("%s. %s", ftLeaderMenuListAlphachars[i], ftLeaderMenuList[i]); } CG_Text_Paint_Ext(button->rect.x, y, button->font->scalex, button->font->scaley, button->font->colour, str, 0, 0, button->font->style, button->font->font); y += button->rect.h; } } } break; case 2: if (!CG_CountFireteamsByTeam(cgs.clientinfo[cg.clientNum].team) || CG_IsOnFireteam(cg.clientNum)) { cgs.ftMenuMode = 1; break; } CG_DrawFireteamsByTeam(button, cgs.clientinfo[cg.clientNum].team); break; case 3: if (!CG_CountPlayersNF()) { cgs.ftMenuMode = 1; break; } CG_DrawPlayerNF(button, &cgs.ftMenuModeEx); break; case 4: switch (cgs.ftMenuPos) { case 2: if (!CG_CountPlayersNF()) { cgs.ftMenuMode = 1; break; } CG_DrawPlayerNF(button, &cgs.ftMenuModeEx); break; case 3: case 4: if (!CG_CountPlayersSF()) { cgs.ftMenuMode = 1; break; } CG_DrawPlayerSF(button, &cgs.ftMenuModeEx); break; } break; } }
qboolean CG_FireteamCheckExecKey(int key, qboolean doaction) { if (key == K_ESCAPE) { return qtrue; } if ((key & K_CHAR_FLAG)) { return qfalse; } key &= ~K_CHAR_FLAG; switch (cgs.ftMenuMode) { case 0: if (cgs.ftMenuPos == -1) { if (cg_quickMessageAlt.integer) { if (key >= '0' && key <= '9') { int i = ((key - '0') + 9) % 10; if (i < 5) { if (!CG_FireteamHasClass(i, qtrue)) { return qfalse; } } if (i > 7) { return qfalse; } if (doaction) { if (i < 5) { cgs.ftMenuPos = i; } else if (i == 5) { CG_QuickFireteamMessage_f(); } else { trap_SendClientCommand(va ("vsay_buddy -1 %s %s", CG_BuildSelectedFirteamString(), ftMenuRootStringsMsg[i])); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } } return qtrue; } } else { int i; if (key >= 'a' || key <= 'z') { for (i = 0; ftMenuRootStrings[i]; i++) { if (key == tolower(*ftMenuRootStringsAlphachars[i])) { if (i < 5) { if (!CG_FireteamHasClass(i, qtrue)) { return qfalse; } } if (doaction) { if (i < 5) { cgs.ftMenuPos = i; } else if (i == 5) { CG_QuickFireteamMessage_f(); } else { trap_SendClientCommand(va ("vsay_buddy -1 %s %s", CG_BuildSelectedFirteamString(), ftMenuRootStringsMsg[i])); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } } return qtrue; } } } } } else { if (cgs.ftMenuPos < 0 || cgs.ftMenuPos > 4) { return qfalse; } if (cg_quickMessageAlt.integer) { if (key >= '0' && key <= '9') { int i = ((key - '0') + 9) % 10; int x; const char **strings = ftMenuStrings[cgs.ftMenuPos]; for (x = 0; strings[x]; x++) { if (x == i) { if (doaction) { trap_SendClientCommand(va ("vsay_buddy %i %s %s", cgs.ftMenuPos, CG_BuildSelectedFirteamString(), (ftMenuStringsMsg[cgs.ftMenuPos])[i])); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } return qtrue; } } } } else { int i; const char **strings = ftMenuStrings[cgs.ftMenuPos]; if (key >= 'a' || key <= 'z') { for (i = 0; strings[i]; i++) { if (key == tolower(*ftMenuStringsAlphachars[cgs.ftMenuPos][i])) { if (doaction) { trap_SendClientCommand(va ("vsay_buddy %i %s %s", cgs.ftMenuPos, CG_BuildSelectedFirteamString(), (ftMenuStringsMsg[cgs.ftMenuPos])[i])); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } return qtrue; } } } } } break; case 1: { int i = -1, x; if (cg_quickMessageAlt.integer) { if (key >= '0' && key <= '9') { i = ((key - '0') + 9) % 10; } } else { const char **strings; if (!CG_IsOnFireteam(cg.clientNum)) { strings = ftOffMenuListAlphachars; } else { if (!CG_IsFireTeamLeader(cg.clientNum)) { strings = ftOnMenuListAlphachars; } else { strings = ftLeaderMenuListAlphachars; } } if (key >= 'a' || key <= 'z') { for (x = 0; strings[x]; x++) { if (key == tolower(*strings[x])) { i = x; break; } } } } if (i == -1) { break; } if (!CG_IsOnFireteam(cg.clientNum)) { if (i >= 2) { break; } if (i == 0 && !CG_CountFireteamsByTeam(cgs.clientinfo[cg.clientNum].team)) { return qfalse; } if (doaction) { if (i == 1) { trap_SendConsoleCommand("fireteam create\n"); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } else { cgs.ftMenuMode = 2; cgs.ftMenuModeEx = 0; cgs.ftMenuPos = i; } } return qtrue; } else { if (!CG_IsFireTeamLeader(cg.clientNum)) { if (i >= 2) { break; } if (i == 0 && !CG_CountPlayersNF()) { break; } if (doaction) { if (i == 1) { trap_SendConsoleCommand("fireteam leave\n"); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } else { cgs.ftMenuMode = 3; cgs.ftMenuModeEx = 0; cgs.ftMenuPos = i; } } return qtrue; } else { if (i >= 5) { break; } if (i == 2 && !CG_CountPlayersNF()) { break; } if ((i == 3 || i == 4) && !CG_CountPlayersSF()) { break; } if (doaction) { if (i == 0) { trap_SendConsoleCommand("fireteam disband\n"); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } else if (i == 1) { trap_SendConsoleCommand("fireteam leave\n"); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } else { cgs.ftMenuMode = 4; cgs.ftMenuModeEx = 0; cgs.ftMenuPos = i; } } return qtrue; } } } break; case 2: { int i; for (i = 0; i < MAX_FIRETEAMS; i++) { if (!cg.fireTeams[i].inuse) { continue; } if (cgs.clientinfo[cg.fireTeams[i].leader].team != cgs.clientinfo[cg.clientNum].team) { continue; } if (cg_quickMessageAlt.integer) { if (key >= '0' && key <= '9') { if (((key - '0') + 9) % 10 == cg.fireTeams[i].ident) { if (doaction) { trap_SendConsoleCommand(va("fireteam apply %i", i + 1)); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } return qtrue; } } } else { if (key >= 'a' || key <= 'z') { if (key - 'a' == cg.fireTeams[i].ident) { if (doaction) { trap_SendConsoleCommand(va("fireteam apply %i", i + 1)); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } return qtrue; } } } } } break; case 3: { int i = -1, x; if (cg_quickMessageAlt.integer) { if (key >= '0' && key <= '9') { i = ((key - '0') + 9) % 10; } } else { if (key >= 'a' || key <= 'g') { i = key - 'a'; } if (key == 'n') { i = 9; } if (key == 'p') { i = 0; } } if (i == -1) { break; } if (CG_CountPlayersNF() > (cgs.ftMenuModeEx + 1) * 8) { if (i == 0) { cgs.ftMenuModeEx++; } } if (cgs.ftMenuModeEx) { if (i == 9) { cgs.ftMenuModeEx--; } } x = CG_PlayerNFFromPos(i, &cgs.ftMenuModeEx); if (x != -1) { if (doaction) { trap_SendConsoleCommand(va("fireteam propose %i", x + 1)); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } return qtrue; } break; } break; case 4: { int i = -1, x; if (cg_quickMessageAlt.integer) { if (key >= '0' && key <= '9') { i = ((key - '0') + 9) % 10; } } else { if (key >= 'a' || key <= 'g') { i = key - 'a'; } if (key == 'n') { i = 9; } if (key == 'p') { i = 8; } } if (i == -1) { break; } switch (cgs.ftMenuPos) { case 2: if (CG_CountPlayersNF() > (cgs.ftMenuModeEx + 1) * 8) { if (i == 9) { if (doaction) { cgs.ftMenuModeEx++; } return qtrue; } } if (cgs.ftMenuModeEx) { if (i == 8) { if (doaction) { cgs.ftMenuModeEx--; } return qtrue; } } x = CG_PlayerNFFromPos(i, &cgs.ftMenuModeEx); if (x != -1) { if (doaction) { trap_SendConsoleCommand(va("fireteam invite %i", x + 1)); CG_EventHandling(CGAME_EVENT_NONE, qfalse); } return qtrue; } break; case 3: case 4: if (CG_CountPlayersSF() > (cgs.ftMenuModeEx + 1) * 8) { if (i == 0) { cgs.ftMenuModeEx++; } } if (cgs.ftMenuModeEx) { if (i == 9) { cgs.ftMenuModeEx--; } } x = CG_PlayerSFFromPos(i, &cgs.ftMenuModeEx); if (x != -1) { if (doaction) { switch (cgs.ftMenuPos) { case 4: trap_SendConsoleCommand(va("fireteam warn %i", x + 1)); CG_EventHandling(CGAME_EVENT_NONE, qfalse); break; case 3: trap_SendConsoleCommand(va("fireteam kick %i", x + 1)); CG_EventHandling(CGAME_EVENT_NONE, qfalse); break; } } return qtrue; } break; } } break; } return qfalse; }
// Parses fireteam servercommand void CG_ParseFireteams() { int i, j; char *s; const char *p; int clnts[2]; qboolean onFireteam2; qboolean isLeader2; // qboolean onFireteam = CG_IsOnFireteam( cg.clientNum ) ? qtrue : qfalse; // qboolean isLeader = CG_IsFireTeamLeader( cg.clientNum ) ? qtrue : qfalse; for (i = 0; i < MAX_CLIENTS; i++) { cgs.clientinfo[i].fireteamData = NULL; } for (i = 0; i < MAX_FIRETEAMS; i++) { char hexbuffer[11] = "0x00000000"; p = CG_ConfigString(CS_FIRETEAMS + i); /* s = Info_ValueForKey(p, "n"); if(!s || !*s) { cg.fireTeams[i].inuse = qfalse; continue; } else { cg.fireTeams[i].inuse = qtrue; }*/ // Q_strncpyz(cg.fireTeams[i].name, s, 32); // CG_Printf("Fireteam: %s\n", cg.fireTeams[i].name); j = atoi(Info_ValueForKey(p, "id")); if (j == -1) { cg.fireTeams[i].inuse = qfalse; continue; } else { cg.fireTeams[i].inuse = qtrue; cg.fireTeams[i].ident = j; } s = Info_ValueForKey(p, "l"); cg.fireTeams[i].leader = atoi(s); s = Info_ValueForKey(p, "c"); Q_strncpyz(hexbuffer + 2, s, 9); sscanf(hexbuffer, "%x", &clnts[1]); Q_strncpyz(hexbuffer + 2, s + 8, 9); sscanf(hexbuffer, "%x", &clnts[0]); for (j = 0; j < MAX_CLIENTS; j++) { if (COM_BitCheck(clnts, j)) { cg.fireTeams[i].joinOrder[j] = qtrue; cgs.clientinfo[j].fireteamData = &cg.fireTeams[i]; // CG_Printf("%s\n", cgs.clientinfo[j].name); } else { cg.fireTeams[i].joinOrder[j] = qfalse; } } } CG_SortClientFireteam(); onFireteam2 = CG_IsOnFireteam(cg.clientNum) ? qtrue : qfalse; isLeader2 = CG_IsFireTeamLeader(cg.clientNum) ? qtrue : qfalse; }