// Checks to see if a specified team is allowing players to join. qboolean G_teamJoinCheck(int team_num, gentity_t *ent) { int cnt = TeamCount(-1, team_num); // Sanity check if (cnt == 0) { G_teamReset(team_num); teamInfo[team_num].team_lock = qfalse; } // Check for locked teams if (team_num == TEAM_AXIS || team_num == TEAM_ALLIES) { if ((int)ent->client->sess.sessionTeam == team_num) { return qtrue; } // Check for full teams if (team_maxplayers.integer > 0 && team_maxplayers.integer <= cnt) { G_printFull(va("The %s team is full!", aTeams[team_num]), ent); return qfalse; // Check for locked teams } else if (teamInfo[team_num].team_lock && (!(ent->client->pers.invite & team_num))) { G_printFull(va("The %s team is LOCKED!", aTeams[team_num]), ent); return qfalse; } } return qtrue; }
/** * @brief Checks to see if a specified team is allowing players to join. * @param[in] team_num * @param[in] ent * @return */ qboolean G_teamJoinCheck(team_t team_num, gentity_t *ent) { int cnt = TeamCount(-1, team_num); // Sanity check if (cnt == 0) { G_teamReset(team_num, qtrue); teamInfo[team_num].team_lock = qfalse; } // Check for locked teams if ((team_num == TEAM_AXIS || team_num == TEAM_ALLIES)) { if (ent->client->sess.sessionTeam == team_num) { return qtrue; } if (g_gametype.integer != GT_WOLF_LMS) { // Check for full teams if (team_maxplayers.integer > 0 && team_maxplayers.integer <= cnt) { G_printFull(va("The %s team is full!", aTeams[team_num]), ent); return qfalse; // Check for locked teams } else if (teamInfo[team_num].team_lock && (!(ent->client->pers.invite & team_num))) { G_printFull(va("The %s team is LOCKED!", aTeams[team_num]), ent); return qfalse; } } else { if (team_maxplayers.integer > 0 && team_maxplayers.integer <= cnt) { G_printFull(va("The %s team is full!", aTeams[team_num]), ent); return qfalse; } else if (g_gamestate.integer == GS_PLAYING && g_lms_lockTeams.integer && (!(ent->client->pers.invite & team_num))) { G_printFull(va("The %s team is LOCKED!", aTeams[team_num]), ent); return qfalse; } } } return qtrue; }
// Changes team spectator lock status void G_refSpeclockTeams_cmd(gentity_t *ent, qboolean fLock) { char *status; // Ensure proper locking G_updateSpecLock(TEAM_AXIS, (TeamCount(-1, TEAM_AXIS)) ? fLock : qfalse); G_updateSpecLock(TEAM_ALLIES, (TeamCount(-1, TEAM_ALLIES)) ? fLock : qfalse); status = va("Referee has ^3SPECTATOR %sLOCKED^7 teams", ((fLock) ? "" : "UN")); G_printFull(status, ent); // Update viewers as necessary // G_pollMultiPlayers(); if (fLock) { level.server_settings |= CV_SVS_LOCKSPECS; } else { level.server_settings &= ~CV_SVS_LOCKSPECS; } trap_SetConfigstring(CS_SERVERTOGGLES, va("%d", level.server_settings)); }
// ************** SPECINVITE // // Sends an invitation to a player to spectate a team. void G_specinvite_cmd(gentity_t * ent, unsigned int dwCommand, qboolean fLock) { int tteam, pid; gentity_t *player; char arg[MAX_TOKEN_CHARS]; if(team_nocontrols.integer) { G_noTeamControls(ent); return; } if(!G_cmdDebounce(ent, aCommandInfo[dwCommand].pszCommandName)) { return; } tteam = G_teamID(ent); if(tteam == TEAM_AXIS || tteam == TEAM_ALLIES) { if(!teamInfo[tteam].spec_lock) { CP("cpm \"Your team isn't locked from spectators!\n\""); return; } // Find the player to invite. trap_Argv(1, arg, sizeof(arg)); if((pid = ClientNumberFromString(ent, arg)) == -1) { return; } player = g_entities + pid; // Can't invite self if(player->client == ent->client) { CP("cpm \"You can't specinvite yourself!\n\""); return; } // Can't invite an active player. if(player->client->sess.sessionTeam != TEAM_SPECTATOR) { CP("cpm \"You can't specinvite a non-spectator!\n\""); return; } player->client->sess.spec_invite |= tteam; // Notify sender/recipient CP(va("print \"%s^7 has been sent a spectator invitation.\n\"", player->client->pers.netname)); G_printFull(va("*** You've been invited to spectate the %s team!", aTeams[tteam]), player); } else { CP("cpm \"Spectators can't specinvite players!\n\""); } }
// ************** SPECLOCK / SPECUNLOCK // // Locks/unlocks a player's team from spectators. void G_speclock_cmd( gentity_t *ent, unsigned int dwCommand, qboolean fLock ) { int tteam; if ( team_nocontrols.integer ) { G_noTeamControls( ent ); return; } if ( !G_cmdDebounce( ent, aCommandInfo[dwCommand].pszCommandName ) ) { return; } tteam = G_teamID( ent ); if ( tteam == TEAM_AXIS || tteam == TEAM_ALLIES ) { if ( teamInfo[tteam].spec_lock == fLock ) { CP( va( "print \"\n^3Your team is already %sed from spectators!\n\n\"", lock_status[fLock] ) ); } else { G_printFull( va( "The %s team is now %sed from spectators", aTeams[tteam], lock_status[fLock] ), NULL ); G_updateSpecLock( tteam, fLock ); if ( fLock ) { CP( "cpm \"Use ^3specinvite^7 to invite people to spectate.\n\"" ); } } } else { CP( va( "print \"Spectators can't %s a team from spectators!\n\"", lock_status[fLock] ) ); } }
// ************** TEAMREADY // // Sets a player's team "ready" status. void G_teamready_cmd(gentity_t *ent, unsigned int dwCommand, qboolean state) { int i, tteam = G_teamID(ent); gclient_t *cl; // forty - in mod flood protection if (ClientIsFlooding(ent, qfalse)) { CP("print \"^1Spam Protection: ^7dropping teamready\n\""); return; } if (g_gamestate.integer == GS_PLAYING || g_gamestate.integer == GS_INTERMISSION) { CP("cpm \"Match is already in progress!\n\""); return; } if (ent->client->sess.sessionTeam == TEAM_SPECTATOR) { CP("cpm \"Spectators can't ready a team!\n\""); return; } // Can't ready until enough players. if (level.numPlayingClients < match_minplayers.integer) { CP("cpm \"Not enough players to start match!\n\""); return; } if (!G_cmdDebounce(ent, aCommandInfo[dwCommand].pszCommandName)) { return; } // Move them to correct ready state for (i = 0; i < level.numPlayingClients; i++) { cl = level.clients + level.sortedClients[i]; if (cl->sess.sessionTeam == tteam) { cl->pers.ready = qtrue; G_MakeReady(ent); } } G_printFull(va("%s readied the %s team!", ent->client->pers.netname, aTeams[tteam]), NULL); G_readyMatchState(); }
// Changes team lock status void G_refLockTeams_cmd(gentity_t *ent, qboolean fLock) { char *status; teamInfo[TEAM_AXIS].team_lock = (TeamCount(-1, TEAM_AXIS)) ? fLock : qfalse; teamInfo[TEAM_ALLIES].team_lock = (TeamCount(-1, TEAM_ALLIES)) ? fLock : qfalse; status = va("Referee has ^3%sLOCKED^7 teams", ((fLock) ? "" : "UN")); G_printFull(status, ent); G_refPrintf(ent, "You have %sLOCKED teams\n", ((fLock) ? "" : "UN")); if( fLock ) { level.server_settings |= CV_SVS_LOCKTEAMS; } else { level.server_settings &= ~CV_SVS_LOCKTEAMS; } trap_SetConfigstring(CS_SERVERTOGGLES, va("%d", level.server_settings)); }
// Changes team lock status void G_refLockTeams_cmd(gentity_t * ent, qboolean fLock) { char *status; teamInfo[TEAM_AXIS].team_lock = (TeamCount(-1, TEAM_AXIS)) ? fLock : qfalse; teamInfo[TEAM_ALLIES].team_lock = (TeamCount(-1, TEAM_ALLIES)) ? fLock : qfalse; status = va("Referee has ^3%sLOCKED^7 teams", ((fLock) ? "" : "UN")); // CHRUKER: b041 - Was only sending this to ent, but it should be broadcasted G_printFull(status, NULL); G_refPrintf(ent, "You have %sLOCKED teams", ((fLock) ? "" : "UN")); // CHRUKER: b047 - Removed unneeded linebreak if(fLock) { level.server_settings |= CV_SVS_LOCKTEAMS; } else { level.server_settings &= ~CV_SVS_LOCKTEAMS; } trap_SetConfigstring(CS_SERVERTOGGLES, va("%d", level.server_settings)); }
void G_delayPrint(gentity_t *dpent) { int think_next = 0; qboolean fFree = qtrue; switch (dpent->spawnflags) { case DP_PAUSEINFO: { if (level.match_pause > PAUSE_UNPAUSING) { int cSeconds = match_timeoutlength.integer * 1000 - (level.time - dpent->timestamp); if (cSeconds > 1000) { AP(va("cp \"^3Match resuming in ^1%d^3 seconds!\n\"", cSeconds / 1000)); think_next = level.time + 15000; fFree = qfalse; } else { level.match_pause = PAUSE_UNPAUSING; AP("print \"^3Match resuming in 10 seconds!\n\""); G_globalSound("sound/osp/prepare.wav"); G_spawnPrintf(DP_UNPAUSING, level.time + 10, NULL); } } break; } case DP_UNPAUSING: { if (level.match_pause == PAUSE_UNPAUSING) { int cSeconds = 11 * 1000 - (level.time - dpent->timestamp); if (cSeconds > 1000) { AP(va("cp \"^3Match resuming in ^1%d^3 seconds!\n\"", cSeconds / 1000)); think_next = level.time + 1000; fFree = qfalse; } else { level.match_pause = PAUSE_NONE; G_globalSound("sound/osp/fight.wav"); G_printFull("^1FIGHT!", NULL); trap_SetConfigstring(CS_LEVEL_START_TIME, va("%i", level.startTime + level.timeDelta)); level.server_settings &= ~CV_SVS_PAUSE; trap_SetConfigstring(CS_SERVERTOGGLES, va("%d", level.server_settings)); } } break; } #ifdef FEATURE_MULTIVIEW case DP_MVSPAWN: { int i; gentity_t *ent; for (i = 0; i < level.numConnectedClients; i++) { ent = g_entities + level.sortedClients[i]; if (ent->client->pers.mvReferenceList == 0) { continue; } if (ent->client->sess.sessionTeam != TEAM_SPECTATOR) { continue; } G_smvRegenerateClients(ent, ent->client->pers.mvReferenceList); } break; } #endif default: break; } dpent->nextthink = think_next; if (fFree) { dpent->think = 0; G_FreeEntity(dpent); } }