virtual void Update(float frametime) { if (!gpGlobals->maxClients) return; if (framecount_start < 0) return; if (!C_SDKPlayer::GetLocalSDKPlayer()) return; // Don't start testing until the player is spawned so that we get actual ingame data. if (!C_SDKPlayer::GetLocalSDKPlayer()->IsAlive()) return; float minimum_start_time = 10; float tracking_duration = 10; if (!framecount_start && gpGlobals->curtime > minimum_start_time) { start_time = gpGlobals->curtime; framecount_start = gpGlobals->framecount; } if (framecount_start && gpGlobals->curtime > tracking_duration + start_time) { if (gpGlobals->framecount - framecount_start < tracking_duration * da_target_fps.GetFloat()) { ConVarRef("da_pretty_pixels").SetValue(false); ConVarRef("da_ssao").SetValue(false); } framecount_start = -1; } }
void OnGameFrameStart() { g_MapzoneEdit.Update(); if (!g_Timer.GotCaughtCheating()) { ConVarRef cheatsRef = ConVarRef("sv_cheats"); if (cheatsRef.GetBool()) { g_Timer.SetCheating(true); g_Timer.Stop(false); } } }
void CSDKModeManager::LevelInit( const char *newmap ) { g_pClientMode->LevelInit( newmap ); ConVarRef cl_detail_max_sway("cl_detail_max_sway"); ConVarRef cl_detail_avoid_radius("cl_detail_avoid_radius"); ConVarRef cl_detail_avoid_force("cl_detail_avoid_force"); ConVarRef cl_detail_avoid_recover_speed("cl_detail_avoid_recover_speed"); // HACK: the detail sway convars are archive, and default to 0. Existing CS:S players thus have no detail // prop sway. We'll force them to DoD's default values for now. if ( !cl_detail_max_sway.GetFloat() && !cl_detail_avoid_radius.GetFloat() && !cl_detail_avoid_force.GetFloat() && !cl_detail_avoid_recover_speed.GetFloat() ) { cl_detail_max_sway.SetValue( "5" ); cl_detail_avoid_radius.SetValue( "64" ); cl_detail_avoid_force.SetValue( "0.4" ); cl_detail_avoid_recover_speed.SetValue( "0.25" ); } if (UseVR()) { #ifdef _DEBUG ConVarRef("vr_force_windowed").SetValue(true); #endif ConVarRef("vr_first_person_uses_world_model").SetValue(false); ConVarRef("vr_moveaim_reticle_yaw_limit").SetValue(15); ConVarRef("vr_moveaim_reticle_yaw_limit_zoom").SetValue(15); ConVarRef("vr_viewmodel_offset_forward").SetValue(5); ConVarRef("vr_zoom_multiplier").SetValue(1.4f); } AB_Input_LevelInit(); }
//================================================================================= // Callback for the 'webspec' protocol // Manages spectator connections & sending Initial messages to new spectators //================================================================================= int webspec_callback(struct libwebsocket_context *ctx, struct libwebsocket *wsi, enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len) { switch (reason) { case LWS_CALLBACK_ESTABLISHED: { Msg("[WS] New connection\n"); // New connection ws_spectators.AddToTail(wsi); // Send basic game info to let client set up // MapName, Server name (may remove), current team names char *buffer = (char*)malloc(MAX_BUFFER_SIZE); char *mapName = (char*) STRING(gpGlobals->mapname); ConVarRef hostNameCVar = ConVarRef("hostname"); string_t hostname; if (hostNameCVar.IsValid()) hostname = MAKE_STRING(hostNameCVar.GetString()); else hostname = MAKE_STRING("WebSpec Demo Server"); //Can't imagine when hostname would be invalid, but this is Source int length = snprintf(buffer, MAX_BUFFER_SIZE, "%c%s:%s:%s:%s", WSPacket_Init, mapName, STRING(hostname), STRING(ws_teamName[1]), STRING(ws_teamName[0])); SendPacketToOne(buffer, length, wsi); free(buffer); //Send connected players IPlayerInfo *playerInfo; for (int i=1; i<=gpGlobals->maxClients; i++) { playerInfo = playerInfoManager->GetPlayerInfo(engine->PEntityOfEntIndex(i)); if (playerInfo != NULL && playerInfo->IsConnected()) { buffer = (char *)malloc(MAX_BUFFER_SIZE); int userid = playerInfo->GetUserID(); int teamid = playerInfo->GetTeamIndex(); int health = playerInfo->GetHealth(); int maxHealth = playerInfo->GetMaxHealth(); bool alive = !playerInfo->IsDead(); string_t playerName = MAKE_STRING(playerInfo->GetName()); //Pointer magic to get TF2 class CBaseEntity *playerEntity = serverGameEnts->EdictToBaseEntity(engine->PEntityOfEntIndex(i)); int playerClass = *MakePtr(int*, playerEntity, WSOffsets::pCTFPlayer__m_iClass); float uberCharge = 0.0f; if (playerClass == TFClass_Medic) { //Way more pointer magic to get ubercharge from medigun CBaseCombatCharacter *playerCombatCharacter = CBaseEntity_MyCombatCharacterPointer(playerEntity); CBaseCombatWeapon *slot1Weapon = CBaseCombatCharacter_Weapon_GetSlot(playerCombatCharacter, 1); uberCharge = *MakePtr(float*, slot1Weapon, WSOffsets::pCWeaponMedigun__m_flChargeLevel); } int length = snprintf(buffer, MAX_BUFFER_SIZE, "%c%d:%d:%d:%d:%d:%d:0:%d:%s", 'C', userid, teamid, playerClass, health, maxHealth, alive, Round(uberCharge*100.0f), STRING(playerName)); SendPacketToOne(buffer, length, wsi); free(buffer); } } break; }
void AppendPlayerInformation(ISteamHTTP *pSteamHttp, HTTPRequestHandle httpRequest, CSteamAPIContext *pSteamAPIContext, CBasePlayer *pPlayer, bool bAnonymous) { // Local DS time_t rawtime; struct tm* timeinfo; time(&rawtime); timeinfo = localtime(&rawtime); char* local_ds = asctime(timeinfo); char* newLine = strstr(local_ds, "\n"); if (newLine) { *newLine = 0; } pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "localdatetime", local_ds); // Build DS char build_ds[64]; Q_snprintf(build_ds, sizeof(build_ds), "%s,%s", __DATE__, __TIME__); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "builddatetime", build_ds); // DxLevel pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "dxlevel", ConVarRef("mat_dxlevel").GetString()); if (pPlayer) { // Position char player_position[32]; Vector player_pos = pPlayer->GetLocalOrigin(); Q_snprintf(player_position, sizeof(player_position), "%.2f,%.2f,%.2f", player_pos.x, player_pos.y, player_pos.z); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "position", player_position); // Angles char player_angles[32]; QAngle player_ang = pPlayer->GetLocalAngles(); Q_snprintf(player_angles, sizeof(player_angles), "%.2f,%.2f,%.2f", player_ang.x, player_ang.y, player_ang.z); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "angles", player_angles); // Health char player_health[16]; Q_snprintf(player_health, sizeof(player_health), "%i", pPlayer->GetHealth()); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "health", player_health); // Weapon CBaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon(); if (pWeapon) { pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "weapon", pWeapon->GetClassname()); } } // Cheats char cheats_enabled[8]; Q_snprintf(cheats_enabled, sizeof(cheats_enabled), "%i", (ConVarRef("sv_cheats").GetBool() || ConVarRef("developer").GetBool())); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "cheats", cheats_enabled); // Map #ifdef CLIENT_DLL char mapname[256]; V_FileBase(engine->GetLevelName(), mapname, sizeof(mapname)); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "level", mapname); #else pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "level", gpGlobals->mapname.ToCStr()); #endif if (pSteamAPIContext) { // Language pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "language", pSteamAPIContext->SteamUtils()->GetSteamUILanguage()); } // Platform char * platform = "unknown"; if (IsPC()) platform = "pc"; if (IsOSX()) platform = "osx"; if (IsLinux()) platform = "linux"; if (IsX360()) platform = "360"; if (IsPS3()) platform = "ps3"; pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "platform", platform); // Player ID if (bAnonymous == false) { if (ae_uniqueplayerid.GetInt() == 0) GenerateUniquePlayerId(pSteamAPIContext); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "playerid", ae_uniqueplayerid.GetString()); } }