// *** Map Restart *** int G_MapRestart_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) { // Vote request (vote is being initiated) if (arg) { if (trap_Argc() > 2) { if (!Q_stricmp(arg2, "?")) { G_refPrintf(ent, "Usage: ^3%s %s%s\n", ((fRefereeCmd) ? "\\ref" : "\\callvote"), arg, aVoteInfo[dwVoteIndex].pszVoteHelp); return G_INVALID; } } // Vote action (vote has passed) } else { // Restart the map back to warmup Svcmd_ResetMatch_f(qfalse, qtrue); AP("cp \"^1*** Level Restarted! ***\n\""); } return G_OK; }
/* {{{ apache_php_module_main */ int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC) { zend_file_handle file_handle; if (php_request_startup(TSRMLS_C) == FAILURE) { return FAILURE; } /* sending a file handle to another dll is not working so let zend open it. */ if (display_source_mode) { zend_syntax_highlighter_ini syntax_highlighter_ini; php_get_highlight_struct(&syntax_highlighter_ini); if (highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC)){ return OK; } else { return NOT_FOUND; } } else { file_handle.type = ZEND_HANDLE_FILENAME; file_handle.handle.fd = 0; file_handle.filename = SG(request_info).path_translated; file_handle.opened_path = NULL; file_handle.free_filename = 0; (void) php_execute_script(&file_handle TSRMLS_CC); } AP(in_request) = 0; return (OK); }
// Checks whether 3D points p lies inside or outside of the triangle ABC bool includePointTriangle(Vec3r& P, Vec3r& A, Vec3r& B, Vec3r& C) { Vec3r AB(B - A); Vec3r BC(C - B); Vec3r CA(A - C); Vec3r AP(P - A); Vec3r BP(P - B); Vec3r CP(P - C); Vec3r N(AB ^ BC); // triangle's normal N.normalize(); Vec3r J(AB ^ AP), K(BC ^ BP), L(CA ^ CP); J.normalize(); K.normalize(); L.normalize(); if(J * N < 0) return false; // on the right of AB if(K * N < 0) return false; // on the right of BC if(L * N < 0) return false; // on the right of CA return true; }
// *** Load public settings for current mode *** int G_Pub_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) { // Vote request (vote is being initiated) if (arg) { if (trap_Argc() > 2) { G_refPrintf(ent, "Usage: ^3%s %s%s\n", ((fRefereeCmd) ? "\\ref" : "\\callvote"), arg, aVoteInfo[dwVoteIndex].pszVoteHelp); return(G_INVALID); } else if (vote_allow_pub.integer <= 0 && ent && !ent->client->sess.referee) { G_voteDisableMessage(ent, arg); return(G_INVALID); } // Vote action (vote has passed) } else { // Load in pub settings for current gametype G_configSet(g_gametype.integer, qfalse); AP("cpm \"Public Settings Loaded!\n\""); } return(G_OK); }
// *** Match Restart *** int G_MatchReset_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) { // Vote request (vote is being initiated) if (arg) { if (!vote_allow_matchreset.integer && ent && !ent->client->sess.referee) { G_voteDisableMessage(ent, arg); return(G_INVALID); } else if (trap_Argc() != 2 && G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) { return(G_INVALID); } // Vote action (vote has passed) } else { // Restart the map back to warmup Svcmd_ResetMatch_f(qtrue, qtrue); AP("cp \"^1*** Match Reset! ***\n\""); } return(G_OK); }
/** * @brief Checks ready states to start/stop the sequence to get the match rolling. * @return */ qboolean G_readyMatchState(void) { if ((g_doWarmup.integer || (g_gametype.integer == GT_WOLF_LMS && g_lms_lockTeams.integer) || level.warmupTime > (level.time + 10 * 1000)) && g_gamestate.integer == GS_WARMUP && G_checkReady()) { level.ref_allready = qfalse; if (g_doWarmup.integer > 0 || (g_gametype.integer == GT_WOLF_LMS && g_lms_lockTeams.integer)) { teamInfo[TEAM_AXIS].team_lock = qtrue; teamInfo[TEAM_ALLIES].team_lock = qtrue; } return qtrue; } else if (!G_checkReady()) { if (g_gamestate.integer == GS_WARMUP_COUNTDOWN) { AP("cp \"^1COUNTDOWN STOPPED!^7 Back to warmup...\n\""); } level.lastRestartTime = (qboolean)(level.time); trap_SendConsoleCommand(EXEC_APPEND, va("map_restart 0 %i\n", GS_WARMUP)); } return qfalse; }
/** * @brief Swaps active players on teams */ void G_swapTeams(void) { int i; gclient_t *cl; for (i = TEAM_AXIS; i <= TEAM_ALLIES; i++) { G_teamReset(i, qtrue); } for (i = 0; i < level.numConnectedClients; i++) { cl = level.clients + level.sortedClients[i]; if (cl->sess.sessionTeam == TEAM_AXIS) { cl->sess.sessionTeam = TEAM_ALLIES; } else if (cl->sess.sessionTeam == TEAM_ALLIES) { cl->sess.sessionTeam = TEAM_AXIS; } else { continue; } G_UpdateCharacter(cl); ClientUserinfoChanged(level.sortedClients[i]); ClientBegin(level.sortedClients[i]); } AP("cp \"^1Teams have been swapped!\n\""); }
// *** Referee voting *** int G_Referee_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) { // Vote request (vote is being initiated) if(arg) { int pid; if(!vote_allow_referee.integer && ent && !ent->client->sess.referee) { G_voteDisableMessage(ent, arg); return(G_INVALID); } if(!ent->client->sess.referee && level.numPlayingClients < 3) { G_refPrintf(ent, "Sorry, not enough clients in the game to vote for a referee"); return(G_INVALID); } if(ent->client->sess.referee && trap_Argc() == 2) { G_playersMessage(ent); return(G_INVALID); } else if(trap_Argc() == 2) pid = ent - g_entities; else if(G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) return(G_INVALID); else if((pid = ClientNumberFromString(ent, arg2)) == -1) return(G_INVALID); if(level.clients[pid].sess.referee) { G_refPrintf(ent, "[lof]%s [lon]is already a referee!", level.clients[pid].pers.netname); return(-1); } Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid); Com_sprintf(arg2, VOTE_MAXSTRING, "%s", level.clients[pid].pers.netname); // Vote action (vote has passed) } else { // Voting in a new referee gclient_t *cl = &level.clients[atoi(level.voteInfo.vote_value)]; if(cl->pers.connected == CON_DISCONNECTED) { AP("print \"Player left before becoming referee\n\""); } else { cl->sess.referee = RL_REFEREE; // FIXME: Differentiate voted refs from passworded refs cl->sess.spec_invite = TEAM_AXIS | TEAM_ALLIES; AP(va("cp \"%s^7 is now a referee\n\"", cl->pers.netname)); ClientUserinfoChanged( atoi(level.voteInfo.vote_value) ); } } return(G_OK); }
// ************** READY / NOTREADY // // Sets a player's "ready" status. void G_ready_cmd( gentity_t *ent, unsigned int dwCommand, qboolean state ) { char *status[2] = { " NOT", "" }; if ( g_gamestate.integer == GS_PLAYING || g_gamestate.integer == GS_INTERMISSION ) { CP( "cpm \"Match is already in progress!\n\"" ); return; } if ( !state && g_gamestate.integer == GS_WARMUP_COUNTDOWN ) { CP( "cpm \"Countdown started.... ^3notready^7 ignored!\n\"" ); return; } if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) { CP( "cpm \"You must be in the game to be ^3ready^7!\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 if ( ent->client->pers.ready == state ) { CP( va( "print \"You are already%s ready!\n\"", status[state] ) ); } else { ent->client->pers.ready = state; if ( !level.intermissiontime ) { if ( state ) { G_MakeReady( ent ); } else { G_MakeUnready( ent ); } AP( va( "print \"%s^7 is%s ready!\n\"", ent->client->pers.netname, status[state] ) ); AP( va( "cp \"\n%s\n^3is%s ready!\n\"", ent->client->pers.netname, status[state] ) ); } } G_readyMatchState(); }
//....................................................... // New speed up method to Cache time integrals void Bs2JpsiPhi_SignalAlt_MO_v4::CacheAmplitudesAndAngles() { CachedA1 = A0()*A0() * angleFactorA0A0( ) ; CachedA2 = AP()*AP() * angleFactorAPAP( ) ; CachedA3 = AT()*AT() * angleFactorATAT( ) ; CachedA4 = AP()*AT() * angleFactorImAPAT( ) ; CachedA5 = A0()*AP() * angleFactorReA0AP( ) ; CachedA6 = A0()*AT() * angleFactorImA0AT( ) ; CachedA7 = AS()*AS() * angleFactorASAS( ) ; CachedA8 = AS()*AP() * angleFactorReASAP( ) ; CachedA9 = AS()*AT() * angleFactorImASAT( ) ; CachedA10= AS()*A0() * angleFactorReASA0( ) ; }
SNRESULT attachProcess(int target, uint unitId, uint processId) { HINSTANCE hLib = LoadLibrary("PS3TMAPI_NET.DLL"); __cAttachProcess AP = (__cAttachProcess)GetProcAddress(hLib, "SNPS3ProcessAttach"); return (AP(target, unitId, processId)); }
// *** Player Un-Mute *** int G_UnMute_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) { if (fRefereeCmd) { // handled elsewhere return G_NOTFOUND; } // Vote request (vote is being initiated) if (arg) { int pid; if (!vote_allow_muting.integer && ent && !ent->client->sess.referee) { G_voteDisableMessage(ent, arg); return G_INVALID; } else if (G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) { return G_INVALID; } else if ((pid = ClientNumberFromString(ent, arg2)) == -1) { return G_INVALID; } if (!level.clients[pid].sess.muted) { G_refPrintf(ent, "Player is not muted!"); return G_INVALID; } Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid); Com_sprintf(arg2, VOTE_MAXSTRING, "%s", level.clients[pid].pers.netname); // Vote action (vote has passed) } else { int pid = atoi(level.voteInfo.vote_value); // Mute a player if (level.clients[pid].sess.referee != RL_RCON) { trap_SendServerCommand(pid, va("cpm \"^3You have been un-muted\"")); level.clients[pid].sess.muted = qfalse; AP(va("cp \"%s\n^3has been un-muted!\n\"", level.clients[pid].pers.netname)); ClientUserinfoChanged(pid); } else { G_Printf("Cannot un-mute a referee.\n"); } } return G_OK; }
double Bs2JpsiPhi_mistagObservable_alt::Normalisation(DataPoint * measurement, PhaseSpaceBoundary * boundary) { // Get observables into member variables t = measurement->GetObservable( timeName )->GetValue() - timeOffset; ctheta_tr = measurement->GetObservable( cosThetaName )->GetValue(); phi_tr = measurement->GetObservable( phiName )->GetValue(); ctheta_1 = measurement->GetObservable( cosPsiName )->GetValue(); tagFraction = measurement->GetObservable( mistagName )->GetValue(); //tagFraction= 0.5; //PELC // Get time boundaries into member variables IConstraint * timeBound = boundary->GetConstraint("time"); if ( timeBound->GetUnit() == "NameNotFoundError" ) { cerr << "Bound on time not provided" << endl; return 0; } else { tlo = timeBound->GetMinimum(); thi = timeBound->GetMaximum(); } // Recalculate cached values if Physics parameters have changed // Must do this for each of the two resolutions. //PELC // I dont think you can cache any more as normalisation depends upon the mistag which now changes per event. if( true /*! normalisationCacheValid*/ ) { for( tag = -1; tag <= 1; tag ++ ) { resolution = resolution1 ; normalisationCacheValueRes1[tag+1] = this->diffXsecNorm1( ); resolution = resolution2 ; normalisationCacheValueRes2[tag+1] = this->diffXsecNorm1( ); } normalisationCacheValid = true ; } // Return normalisation value according to tag tag = (int)measurement->GetObservable( tagName )->GetValue(); double returnValue = resolution1Fraction*normalisationCacheValueRes1[tag+1] + (1. - resolution1Fraction)*normalisationCacheValueRes2[tag+1] ; if( (returnValue <= 0.) || isnan(returnValue) ) { cout << " Bs2JpsiPhi_mistagObservable_alt::Normalisation() returns <=0 or nan " << endl ; cout << " gamma " << gamma() ; cout << " gl " << gamma_l() ; cout << " gh " << gamma_h() ; cout << " AT " << AT() ; cout << " AP " << AP() ; cout << " A0 " << A0() ; exit(1) ; } return returnValue ; }
// ************** PAUSE / UNPAUSE // // Pause/unpause a match. void G_pause_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fPause) { char *status[2] = { "^5UN", "^1" }; if(team_nocontrols.integer) { G_noTeamControls(ent); return; } if((PAUSE_UNPAUSING >= level.match_pause && !fPause) || (PAUSE_NONE != level.match_pause && fPause)) { CP(va("print \"The match is already %sPAUSED^7!\n\"", status[fPause])); return; } // Alias for referees if(ent->client->sess.referee) G_refPause_cmd(ent, fPause); else { int tteam = G_teamID(ent); if(!G_cmdDebounce(ent, aCommandInfo[dwCommand].pszCommandName)) return; // Trigger the auto-handling of pauses if(fPause) { if(0 == teamInfo[tteam].timeouts) { CP("cpm \"^3Your team has no more timeouts remaining!\n\""); return; } else { teamInfo[tteam].timeouts--; level.match_pause = tteam + 128; G_globalSound("sound/misc/referee.wav"); G_spawnPrintf(DP_PAUSEINFO, level.time + 15000, NULL); AP(va("print \"^3Match is ^1PAUSED^3!\n^7[%s^7: - %d Timeouts Remaining]\n\"", aTeams[tteam], teamInfo[tteam].timeouts)); CP(va("cp \"^3Match is ^1PAUSED^3! (%s^3)\n\"", aTeams[tteam])); level.server_settings |= CV_SVS_PAUSE; trap_SetConfigstring(CS_SERVERTOGGLES, va("%d", level.server_settings)); } } else if(tteam + 128 != level.match_pause) { CP("cpm \"^3Your team didn't call the timeout!\n\""); return; } else { AP("print \"\n^3Match is ^5UNPAUSED^3 ... resuming in 10 seconds!\n\n\""); level.match_pause = PAUSE_UNPAUSING; G_globalSound("sound/osp/prepare.wav"); G_spawnPrintf(DP_UNPAUSING, level.time + 10, NULL); } } }
// *** Player Kick *** int G_Kick_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) { // Vote request (vote is being initiated) if (arg) { int pid; if (!vote_allow_kick.integer && ent && !ent->client->sess.referee) { G_voteDisableMessage(ent, arg); return G_INVALID; } else if (G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) { return G_INVALID; } else if ((pid = ClientNumberFromString(ent, arg2)) == -1) { return G_INVALID; } if (level.clients[pid].sess.referee) { G_refPrintf(ent, "Can't vote to kick referees!"); return G_INVALID; } if (g_entities[pid].r.svFlags & SVF_BOT) { G_refPrintf(ent, "Can't vote to kick bots!"); return G_INVALID; } if (!fRefereeCmd && ent) { if (level.clients[pid].sess.sessionTeam != TEAM_SPECTATOR && level.clients[pid].sess.sessionTeam != ent->client->sess.sessionTeam) { G_refPrintf(ent, "Can't vote to kick players on opposing team!"); return G_INVALID; } } Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid); Com_sprintf(arg2, VOTE_MAXSTRING, "%s", level.clients[pid].pers.netname); // Vote action (vote has passed) } else { // Kick a player trap_SendConsoleCommand(EXEC_APPEND, va("clientkick %d\n", atoi(level.voteInfo.vote_value))); AP(va("cp \"%s\n^3has been kicked!\n\"", level.clients[atoi(level.voteInfo.vote_value)].pers.netname)); } return G_OK; }
// ************** LOCK / UNLOCK // // Locks/unlocks a player's team. void G_lock_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].team_lock == fLock) CP(va("print \"^3Your team is already %sed!\n\"", lock_status[fLock])); else { char *info = va("\"The %s team is now %sed!\n\"", aTeams[tteam], lock_status[fLock]); teamInfo[tteam].team_lock = fLock; AP(va("print %s", info)); AP(va("cp %s", info)); } } else CP(va("print \"Spectators can't %s a team!\n\"", lock_status[fLock])); }
int G_Surrender_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd ) { team_t team; // Vote request (vote is being initiated) if(arg) { if(g_gamestate.integer != GS_PLAYING) { return G_INVALID; } if(!vote_allow_surrender.integer) return G_INVALID; // yada - noone ever seemes to have thought of refs calling this if( !ent|| ent->client->sess.sessionTeam==TEAM_SPECTATOR ){ if(trap_Argc()==2){ G_refPrintf(ent,"Usage: \\%s surrender <team>",fRefereeCmd?"ref":"callvote"); return G_INVALID; } team=TeamFromString(arg2); if( team!=TEAM_AXIS&& team!=TEAM_ALLIES ){ G_refPrintf(ent,"Invalid team specified."); return G_INVALID; } level.voteInfo.voteTeam=team; }else{ team=ent->client->sess.sessionTeam; } Q_strncpyz(arg2, (team == TEAM_AXIS) ? "[AXIS]" : "[ALLIES]", VOTE_MAXSTRING); } // Vote action (vote has passed) else if(g_gamestate.integer == GS_PLAYING){ char cs[MAX_STRING_CHARS]; trap_GetConfigstring(CS_MULTI_MAPWINNER, cs, sizeof(cs)); Info_SetValueForKey(cs, "winner", (level.voteInfo.voteTeam == TEAM_AXIS) ? "1" : "0"); trap_SetConfigstring(CS_MULTI_MAPWINNER, cs); LogExit(va("%s Surrender\n", (level.voteInfo.voteTeam == TEAM_AXIS) ? "Axis" : "Allies")); AP(va("chat \"%s have surrendered!\" -1", (level.voteInfo.voteTeam == TEAM_AXIS) ? "^1AXIS^7" : "^4ALLIES^7")); } return(G_OK); }
// *** Nextmap *** int G_Nextmap_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) { // Vote request (vote is being initiated) if(arg) { if(trap_Argc() > 2) { G_refPrintf(ent, "Usage: ^3%s %s%s\n", ((fRefereeCmd) ? "\\ref" : "\\callvote"), arg, aVoteInfo[dwVoteIndex].pszVoteHelp); return(G_INVALID); } else if(!vote_allow_nextmap.integer && ent && !ent->client->sess.referee) { G_voteDisableMessage(ent, arg); return(G_INVALID); } else { char s[MAX_STRING_CHARS]; if( g_gametype.integer == GT_WOLF_CAMPAIGN ) { trap_Cvar_VariableStringBuffer( "nextcampaign", s, sizeof(s) ); if( !*s ) { G_refPrintf(ent, "'nextcampaign' is not set." ); return(G_INVALID); } } else { trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof(s) ); if( !*s ) { G_refPrintf(ent, "'nextmap' is not set." ); return(G_INVALID); } } } // Vote action (vote has passed) } else { if( g_gametype.integer == GT_WOLF_CAMPAIGN ) { // Load in the nextcampaign trap_SendConsoleCommand(EXEC_APPEND, "vstr nextcampaign\n"); AP("cp \"^3*** Loading nextcampaign! ***\n\""); } else { // Load in the nextmap trap_SendConsoleCommand(EXEC_APPEND, "vstr nextmap\n"); AP("cp \"^3*** Loading nextmap! ***\n\""); } } return(G_OK); }
// pheno: cointoss int G_CoinToss_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd ) { // Vote request (vote is being initiated) if( arg ) { if( !vote_allow_cointoss.integer && ent && !ent->client->sess.referee ) { G_voteDisableMessage( ent, arg ); return ( G_INVALID ); } // Vote action (vote has passed) } else { char *side = rand() % 2 ? "HEADS" : "TAILS"; AP( va( "cp \"Coin toss comes up^3 %s^7!\"", side ) ); AP( va( "cpm \"Coin toss comes up^3 %s^7!\"", side ) ); } return ( G_OK ); }
// *** Player Kick *** int G_Kick_v( gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd ) { // Vote request (vote is being initiated) if( arg ) { int pid; if( !vote_allow_kick.integer && ent && !ent->client->sess.referee ) { G_voteDisableMessage(ent, arg); return G_INVALID; } else if( G_voteDescription(ent, fRefereeCmd, dwVoteIndex) ) { return G_INVALID; } else if( ( pid = ClientNumberFromString( ent, arg2 ) ) == -1 ) { return G_INVALID; } if( level.clients[ pid ].sess.referee ) { G_refPrintf( ent, "Can't vote to kick referees!" ); return G_INVALID; } if(G_shrubbot_permission(&g_entities[pid], SBF_IMMUNITY)) { G_refPrintf( ent, "Can't vote to kick admins!" ); return G_INVALID; } // pheno: prevent ettv slaves from being callvote kicked if( level.clients[pid].sess.ettv && ( g_ettvFlags.integer & ETTV_IMMUNITY ) ) { G_refPrintf( ent, "Can't vote to kick ettv slaves!" ); return G_INVALID; } if( !fRefereeCmd && ent ) { if( level.clients[ pid ].sess.sessionTeam != TEAM_SPECTATOR && level.clients[ pid ].sess.sessionTeam != ent->client->sess.sessionTeam ) { G_refPrintf( ent, "Can't vote to kick players on opposing team!" ); return G_INVALID; } } Com_sprintf( level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid ); Com_sprintf( arg2, VOTE_MAXSTRING, "%s^7", level.clients[pid].pers.netname ); // Vote action (vote has passed) } else { // Kick a player //trap_SendConsoleCommand( EXEC_APPEND, va( "clientkick %d\n", atoi( level.voteInfo.vote_value ) ) ); // tjw: clientkick doesn't work in 2.60 trap_DropClient(atoi(level.voteInfo.vote_value), "You have been kicked", 120); AP( va( "cp \"%s\n^3has been kicked!\n\"", level.clients[ atoi( level.voteInfo.vote_value ) ].pers.netname ) ); } return G_OK; }
/* ================= ClientInactivityTimer Returns qfalse if the client is dropped ================= */ qboolean ClientInactivityTimer(gclient_t *client) { int i; int counter = 0; // suburb, take viewangles for inactivity drop instead of buttons for (i = 0; i < 3; ++i) { if (client->ps.viewangles[i] == client->pers.oldViewangles[i]) { counter++; } } // OSP - modified if ((g_inactivity.integer == 0 && client->sess.sessionTeam != TEAM_SPECTATOR) || (g_spectatorInactivity.integer == 0 && client->sess.sessionTeam == TEAM_SPECTATOR)) { // give everyone some time, so if the operator sets g_inactivity during // gameplay, everyone isn't kicked client->inactivityTime = level.time + 60 * 1000; client->inactivityWarning = qfalse; } else if (counter != 3) { client->inactivityWarning = qfalse; client->inactivityTime = level.time + 1000 * ((client->sess.sessionTeam != TEAM_SPECTATOR) ? g_inactivity.integer : g_spectatorInactivity.integer); } else if (!client->pers.localClient) { if (level.time > client->inactivityTime && client->inactivityWarning) { client->inactivityWarning = qfalse; client->inactivityTime = level.time + 60 * 1000; // Nico, move inactive player to spec instead of kicking them // trap_DropClient( client - level.clients, "Dropped due to inactivity", 0 ); AP(va("cpm \"%s ^7removed from teams due to inactivity! ^z(%i seconds) \n\"", client->pers.netname, g_inactivity.integer)); SetTeam(g_entities + (client - level.clients), "s", -1, -1, qfalse); return qfalse; } if (!client->inactivityWarning && level.time > client->inactivityTime - 10000) { CPx(client - level.clients, "cp \"^310 seconds until inactivity drop!\n\""); CPx(client - level.clients, "print \"^310 seconds until inactivity drop!\n\""); G_Printf("10s inactivity warning issued to: %s\n", client->pers.netname); client->inactivityWarning = qtrue; client->inactivityTime = level.time + 10000; // Just for safety } } // suburb, update viewangles if (counter != 3) { for (i = 0; i < 3; ++i) { client->pers.oldViewangles[i] = client->ps.viewangles[i]; } } return qtrue; }
// *** Un-Referee voting *** int G_Unreferee_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) { // Vote request (vote is being initiated) if(arg) { int pid; if(!vote_allow_referee.integer && ent && !ent->client->sess.referee) { G_voteDisableMessage(ent, arg); return(G_INVALID); } // yada - ent==NULL for console... if( (!ent || ent->client->sess.referee) && trap_Argc() == 2) { G_playersMessage(ent); return(G_INVALID); } else if(ent && trap_Argc() == 2) pid = ent - g_entities; // yada - ent still NULL for console... else if(G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) return(G_INVALID); else if((pid = ClientNumberFromString(ent, arg2)) == -1) return(G_INVALID); if(level.clients[pid].sess.referee == RL_NONE) { G_refPrintf(ent, "[lof]%s [lon]isn't a referee!", level.clients[pid].pers.netname); return(G_INVALID); } if(level.clients[pid].sess.referee == RL_RCON) { G_refPrintf(ent, "[lof]%s's [lon]status cannot be removed", level.clients[pid].pers.netname); return(G_INVALID); } if( level.clients[pid].pers.localClient ) { G_refPrintf(ent, "[lof]%s [lon]^7is the Server Host", level.clients[pid].pers.netname); return(G_INVALID); } Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid); Com_sprintf(arg2, VOTE_MAXSTRING, "%s^7", level.clients[pid].pers.netname); // Vote action (vote has passed) } else { // Stripping of referee status gclient_t *cl = &level.clients[atoi(level.voteInfo.vote_value)]; cl->sess.referee = RL_NONE; if( !cl->sess.shoutcaster ) { // don't remove shoutcaster's invitation cl->sess.spec_invite = 0; } AP(va("cp \"%s^7\nis no longer a referee\n\"", cl->pers.netname)); ClientUserinfoChanged( atoi(level.voteInfo.vote_value) ); } return(G_OK); }
// *** Player PutSpec *** int G_PutSpec_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) { // yada - my ass... this isnt handled elsewhere at all //if( fRefereeCmd ){ // // handled elsewhere // return(G_NOTFOUND); //} // Vote request (vote is being initiated) if(arg) { int pid; if(!vote_allow_putspec.integer && ent && !ent->client->sess.referee) { G_voteDisableMessage(ent, arg); return(G_INVALID); } else if(G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) return(G_INVALID); else if((pid = ClientNumberFromString(ent, arg2)) == -1) return(G_INVALID); if(level.clients[pid].sess.referee) { G_refPrintf(ent, "Can't vote to PutSpec referees!"); return(G_INVALID); } if(G_shrubbot_permission(&g_entities[pid], SBF_IMMUNITY)) { G_refPrintf( ent, "Can't vote to PutSpec admins!" ); return G_INVALID; } if(level.clients[pid].sess.sessionTeam == TEAM_SPECTATOR || level.clients[pid].sess.sessionTeam != ent->client->sess.sessionTeam) { G_refPrintf(ent, "You can only PutSpec players in your own team!"); return G_INVALID; } Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid); Com_sprintf(arg2, VOTE_MAXSTRING, "%s^7", level.clients[pid].pers.netname); // Vote action (vote has passed) } else { int pid = atoi(level.voteInfo.vote_value); SetTeam( &g_entities[pid], "s", qtrue, -1, -1, qfalse ); trap_SendServerCommand( pid, va( "cpm \"^3You have been moved to the Spectators\"") ); AP(va("cp \"%s ^3has been\nmoved to the Spectators!\n\"", level.clients[pid].pers.netname)); ClientUserinfoChanged( pid ); if(g_gamestate.integer == GS_WARMUP || g_gamestate.integer == GS_WARMUP_COUNTDOWN) { G_readyMatchState(); } } return(G_OK); }
/* =========== Custom MODs =========== */ qboolean isCustomMOD(int mod, gentity_t *self, gentity_t *attacker) { // Killed by !kill command if (mod == MOD_ADMKILL) { return qtrue; } else if (mod == MOD_SELFKILL) { int r = rand() % 2; // randomize messages if (r == 0) AP(va("print \"%s ^7slit his throat.\n\"", self->client->pers.netname)); else if (r == 1) AP(va("print \"%s ^7commited suicide.\n\"", self->client->pers.netname)); return qtrue; } else if (mod == MOD_THROWKNIFE) { AP(va("print \"%s ^7was impaled by %s^7s throwing knife.\n\"", self->client->pers.netname, attacker->client->pers.netname)); attacker->client->pers.knifeKills++; write_RoundStats(attacker->client->pers.netname, attacker->client->pers.knifeKills, ROUND_KNIFETHROW); return qtrue; } else if (mod == MOD_CHICKEN) { AP(va("print \"%s ^6was scared to death by ^7%s^7.\n\"", self->client->pers.netname, attacker->client->pers.netname)); self->client->pers.chicken++; write_RoundStats(self->client->pers.netname, self->client->pers.chicken, ROUND_CHICKEN); // Give props to attacker attacker->client->pers.kills++; attacker->client->pers.lifeKills++; write_RoundStats(attacker->client->pers.netname, attacker->client->pers.kills, ROUND_KILLS); write_RoundStats(attacker->client->pers.netname, attacker->client->pers.lifeKills, ROUND_KILLPEAK); return qtrue; } else if (mod == MOD_POISONDMED) { int r = rand() % 2; if (r == 0) AP(va("print \"%s ^7was poisoned by %s^7.\n\"", self->client->pers.netname, attacker->client->pers.netname)); else if (r == 1) AP(va("print \"%s ^7tasted %s^7's poison.\n\"", self->client->pers.netname, attacker->client->pers.netname)); // Stats attacker->client->pers.poison++; write_RoundStats(attacker->client->pers.netname, attacker->client->pers.poison, ROUND_POISON); return qtrue; } else return qfalse; }
// *** Player Mute *** int G_Mute_v(gentity_t *ent, unsigned int dwVoteIndex, char *arg, char *arg2, qboolean fRefereeCmd) { // yada - no its handled here now //if( fRefereeCmd ) // // handled elsewhere // return(G_NOTFOUND); // Vote request (vote is being initiated) if(arg) { int pid; if(!vote_allow_muting.integer && ent && !ent->client->sess.referee) { G_voteDisableMessage(ent, arg); return(G_INVALID); } else if(G_voteDescription(ent, fRefereeCmd, dwVoteIndex)) return(G_INVALID); else if((pid = ClientNumberFromString(ent, arg2)) == -1) return(G_INVALID); if(level.clients[pid].sess.referee) { G_refPrintf(ent, "Can't vote to mute referees!"); return(G_INVALID); } if(G_shrubbot_permission(&g_entities[pid], SBF_IMMUNITY)) { G_refPrintf( ent, "Can't vote to mute admins!" ); return G_INVALID; } if(level.clients[pid].sess.auto_unmute_time != 0) { G_refPrintf(ent, "Player is already muted!"); return(G_INVALID); } Com_sprintf(level.voteInfo.vote_value, VOTE_MAXSTRING, "%d", pid); Com_sprintf(arg2, VOTE_MAXSTRING, "%s^7", level.clients[pid].pers.netname); // Vote action (vote has passed) } else { int pid = atoi(level.voteInfo.vote_value); // Mute a player if( level.clients[pid].sess.referee != RL_RCON ) { trap_SendServerCommand( pid, va( "cpm \"^3You have been muted\"") ); level.clients[pid].sess.auto_unmute_time = -1; AP(va("cp \"%s\n^3has been muted!\n\"", level.clients[pid].pers.netname)); ClientUserinfoChanged( pid ); } else { G_Printf( "Cannot mute a referee.\n" ); } } return(G_OK); }
// Request for ref status or lists ref commands. void G_ref_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fValue) { char arg[MAX_TOKEN_CHARS]; // Roll through ref commands if already a ref if(ent == NULL || ent->client->sess.referee) { voteInfo_t votedata; trap_Argv(1, arg, sizeof(arg)); memcpy( &votedata, &level.voteInfo, sizeof( voteInfo_t ) ); if( Cmd_CallVote_f(ent, 0, qtrue) ) { memcpy( &level.voteInfo, &votedata, sizeof( voteInfo_t ) ); return; } else { memcpy( &level.voteInfo, &votedata, sizeof( voteInfo_t ) ); if(G_refCommandCheck(ent, arg)) { return; } else { G_refHelp_cmd(ent); } } return; } if(ent) { if(!Q_stricmp(refereePassword.string, "none") || !refereePassword.string[0]) { CP("cpm \"Sorry, referee status disabled on this server.\n\""); return; } if(trap_Argc() < 2) { CP("cpm \"Usage: ref [password]\n\""); return; } trap_Argv(1, arg, sizeof(arg)); if(Q_stricmp(arg, refereePassword.string)) { CP("cpm \"Invalid referee password!\n\""); return; } ent->client->sess.referee = 1; ent->client->sess.spec_invite = TEAM_AXIS | TEAM_ALLIES; AP(va("cp \"%s\n^3has become a referee\n\"", ent->client->pers.netname)); ClientUserinfoChanged( ent-g_entities ); } }
/** * @brief Shuffle active players onto teams */ void G_shuffleTeams(void) { int i; team_t cTeam; //, cMedian = level.numNonSpectatorClients / 2; int cnt = 0; int sortClients[MAX_CLIENTS]; gclient_t *cl; G_teamReset(TEAM_AXIS, qtrue); G_teamReset(TEAM_ALLIES, qtrue); for (i = 0; i < level.numConnectedClients; i++) { cl = level.clients + level.sortedClients[i]; if (cl->sess.sessionTeam != TEAM_AXIS && cl->sess.sessionTeam != TEAM_ALLIES) { continue; } sortClients[cnt++] = level.sortedClients[i]; } qsort(sortClients, cnt, sizeof(int), G_SortPlayersByXP); for (i = 0; i < cnt; i++) { cl = level.clients + sortClients[i]; // cTeam = (i % 2) + TEAM_AXIS; cTeam = (((i + 1) % 4) - ((i + 1) % 2)) / 2 + TEAM_AXIS; if (cl->sess.sessionTeam != cTeam) { G_LeaveTank(g_entities + sortClients[i], qfalse); G_RemoveClientFromFireteams(sortClients[i], qtrue, qfalse); if (g_landminetimeout.integer) { G_ExplodeMines(g_entities + sortClients[i]); } G_FadeItems(g_entities + sortClients[i], MOD_SATCHEL); } cl->sess.sessionTeam = cTeam; G_UpdateCharacter(cl); ClientUserinfoChanged(sortClients[i]); ClientBegin(sortClients[i]); } AP("cp \"^1Teams have been shuffled!\n\""); }
void TouchPowerupSatchelBoost(gentity_t *self, gentity_t *player, trace_t *trace) { if(!player->client) { return; } player->client->powerups[PW_SATCHELBOOST] = sr_pw_satchelBoost.integer; AP(va("chat \"%s ^7picked up a ^5Satchel Boost ^7powerup\"", player->client->pers.netname)); self->parent->child = NULL; G_FreeEntity(self); }
void TouchPowerupLowGravity(gentity_t *self, gentity_t *player, trace_t *trace) { if(!player->client) { return; } player->client->powerups[PW_LOWGRAVITY] = level.time + sr_pw_lowGravityDuration.integer; AP(va("chat \"%s ^7picked up a ^5Low Gravity ^7powerup\"", player->client->pers.netname)); self->parent->child = NULL; G_FreeEntity(self); }
void TouchPowerupNoSlow(gentity_t *self, gentity_t *player, trace_t *trace) { if(!player->client) { return; } player->client->powerups[PW_NOSLOW] = level.time + sr_pw_noSlowDuration.integer; AP(va("chat \"%s ^7picked up a ^5No Slow ^7powerup\"", player->client->pers.netname)); self->parent->child = NULL; G_FreeEntity(self); }