From 602c697717a3dce3de7b7ef1cb7dabe09235d741 Mon Sep 17 00:00:00 2001 From: GreYFoXGTi Date: Mon, 11 Oct 2010 21:27:35 +0200 Subject: [PATCH] made broadcast update only when needed --- src/engine/shared/config_variables.h | 2 +- src/game/server/entities/character.cpp | 13 +++++++++---- src/game/server/entities/character.h | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 6814c790b..e181971fb 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -117,7 +117,7 @@ MACRO_CONFIG_INT(SvSuicidePenalty, sv_suicide_penalty,0,0,9999,CFGFLAG_SERVER, " MACRO_CONFIG_INT(SvVotePercentage, sv_vote_percentage, 50, 1, 100, CFGFLAG_SERVER, "The percent of people that need to agree or deny for the vote to succeed/fail", 3) MACRO_CONFIG_INT(SvShotgunBulletSound, sv_shotgun_bullet_sound, 0, 0, 1, CFGFLAG_SERVER, "Crazy shotgun bullet sound on/off", 3) -MACRO_CONFIG_INT(SvScoreIP, sv_score_ip, 1, 0, 1, CFGFLAG_SERVER, "Wheather to save also the IP in the score file", 3) +MACRO_CONFIG_INT(SvScoreIP, sv_score_ip, 0, 0, 0, CFGFLAG_SERVER, "Wheather to save also the IP in the score file", 3) MACRO_CONFIG_INT(SvCheckpointSave, sv_checkpoint_save, 1, 0, 1, CFGFLAG_SERVER, "Whether to save checkpoint times to the score file", 3) MACRO_CONFIG_STR(SvScoreFolder, sv_score_folder, 32, "records", CFGFLAG_SERVER, "Folder to save score files to", 3) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index a16292cb8..68199da57 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -655,14 +655,14 @@ void CCharacter::Tick() CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController; std::list < int > Indices = GameServer()->Collision()->GetMapIndices(m_PrevPos, m_Pos); //dbg_msg("Indices","%d",Indices.size()); - if(m_pPlayer->m_ForceBalanced) + /*if(m_pPlayer->m_ForceBalanced) { char Buf[128]; str_format(Buf, sizeof(Buf), "You were moved to %s due to team balancing", Controller->GetTeamName(m_pPlayer->GetTeam())); GameServer()->SendBroadcast(Buf, m_pPlayer->GetCID()); m_pPlayer->m_ForceBalanced = false; - } + }*/ m_Armor=(m_FreezeTime != -1)?10-(m_FreezeTime/15):0; if(m_Input.m_Direction != 0 || m_Input.m_Jump != 0) m_LastMove = Server()->Tick(); @@ -729,18 +729,23 @@ void CCharacter::Tick() str_format(aTmp, sizeof(aTmp), "\n%s\n", g_Config.m_SvBroadcast); strcat(aBuftime, aTmp); } - GameServer()->SendBroadcast(aBuftime, m_pPlayer->GetCID()); + if(Server()->Tick() >= (m_LastBroadcast + Server()->TickSpeed())) + { + GameServer()->SendBroadcast(aBuftime, m_pPlayer->GetCID()); + m_LastBroadcast = Server()->Tick(); + } } else { - if( g_Config.m_SvBroadcast[0] != 0) { + if( g_Config.m_SvBroadcast[0] != 0 && (Server()->Tick() > (m_LastBroadcast + (Server()->TickSpeed() * 9)))) { char aTmp[128],aYourBest[64],aServerBest[64]; str_format(aYourBest, sizeof(aYourBest), "Your Best:'%s%d:%s%d'", ((pData->m_BestTime / 60) < 10)?"0":"", (int)(pData->m_BestTime / 60), (((int)pData->m_BestTime % 60) < 10)?"0":"", (int)pData->m_BestTime % 60); CPlayerData *pData = GameServer()->Score()->PlayerData(m_pPlayer->GetCID()); str_format(aServerBest, sizeof(aServerBest), "Server Best:'%s%d:%s%d'", ((GameServer()->m_pController->m_CurrentRecord / 60) < 10)?"0":"", (int)(GameServer()->m_pController->m_CurrentRecord / 60), (((int)GameServer()->m_pController->m_CurrentRecord % 60) < 10)?"0":"", (int)GameServer()->m_pController->m_CurrentRecord % 60); str_format(aTmp, sizeof(aTmp), "%s\n%s %s", g_Config.m_SvBroadcast, (GameServer()->m_pController->m_CurrentRecord)?aServerBest:"", (pData->m_BestTime)?aYourBest:""); GameServer()->SendBroadcast(aTmp, m_pPlayer->GetCID()); + m_LastBroadcast = Server()->Tick(); } } m_RefreshTime = Server()->Tick(); diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 4fd0fc231..9119ecbd0 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -28,6 +28,7 @@ class CCharacter : public CEntity void HandleFly(); void HandleTiles(int Index); float m_Time; + int m_LastBroadcast; public: //character's size static const int ms_PhysSize = 28;