Simplifys the usage of timer commands. Fixes new year happy spawn.

This commit is contained in:
Learath2 2012-02-14 20:25:34 +02:00
parent 7bd9a687c4
commit d64e1796aa
8 changed files with 30 additions and 63 deletions

View file

@ -199,9 +199,8 @@ MACRO_CONFIG_INT(SvVotePauseTime, sv_vote_pause_time, 10, 0, 360, CFGFLAG_SERVER
MACRO_CONFIG_INT(SvTuneReset, sv_tune_reset, 0, 0, 1, CFGFLAG_SERVER, "Whether tuning is reset after each map change or not")
MACRO_CONFIG_INT(SvDDRaceTuneReset, sv_ddrace_tune_reset, 1, 0, 1, CFGFLAG_SERVER, "Whether DDRace tuning(sv_hit, Sv_Endless_Drag & Sv_Old_Laser) is reset after each map change or not")
MACRO_CONFIG_INT(SvNamelessScore, sv_nameless_score, 0, 0, 1, CFGFLAG_SERVER, "Whether nameless tee has a score or not")
MACRO_CONFIG_INT(SvTimeInBroadcast, sv_time_in_broadcast, 1, 0, 1, CFGFLAG_SERVER, "Whether to display time in broadcast every interval or not by default, later the choice can be changed by players via chat commands")
MACRO_CONFIG_INT(SvTimeInBroadcastInterval, sv_time_in_broadcast_interval, 1, 0, 60, CFGFLAG_SERVER, "How often to update the broadcast time")
MACRO_CONFIG_INT(SvTimeInGameTimer, sv_time_in_gametimer, 0, 0, 1, CFGFLAG_SERVER, "Whether to display time in the round/game timer or not by default, later the choice can be changed by players via chat commands")
MACRO_CONFIG_INT(SvDefaultTimerType, sv_default_timer_type, 0, 0, 1, CFGFLAG_SERVER, "Default way of displaying time either game/round timer or broadcast. 0 = game/round timer, 1 = broadcast")
// these might need some fine tuning

View file

@ -790,68 +790,40 @@ void CGameContext::ConTime(IConsole::IResult *pResult, void *pUserData)
pSelf->SendBroadcast(aBuftime, pResult->m_ClientID);
}
void CGameContext::ConSetBroadcastTime(IConsole::IResult *pResult, void *pUserData)
void CGameContext::ConSetTimerType(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
if (!CheckClientID(pResult->m_ClientID))
return;
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
if (!pPlayer)
return;
if(pResult->NumArguments() == 0) {
if(pResult->NumArguments() == 0)
{
pSelf->Console()->Print(
IConsole::OUTPUT_LEVEL_STANDARD,
"emote",
(pPlayer->m_BroadcastTime) ?
"Time is displayed in broadcast now." :
"Time will not be displayed in broadcast now");
IConsole::OUTPUT_LEVEL_STANDARD,
"timer",
(pPlayer->m_TimerType) ?
"Time is displayed in broadcast now." :
"Time is displayed in game/round timer now");
return;
}
else if(str_comp_nocase(pResult->GetString(0), "on") == 0)
pPlayer->m_BroadcastTime = true;
else if(str_comp_nocase(pResult->GetString(0), "off") == 0)
pPlayer->m_BroadcastTime = false;
else if(str_comp_nocase(pResult->GetString(0), "gametimer") == 0) {
pSelf->SendBroadcast("", pResult->m_ClientID);
pPlayer->m_TimerType = false;
}
else if(str_comp_nocase(pResult->GetString(0), "broadcast") == 0)
pPlayer->m_TimerType = true;
else if(str_comp_nocase(pResult->GetString(0), "toggle") == 0)
pPlayer->m_BroadcastTime = !pPlayer->m_BroadcastTime;
pPlayer->m_TimerType = !pPlayer->m_TimerType;
pSelf->Console()->Print(
IConsole::OUTPUT_LEVEL_STANDARD,
"emote",
(pPlayer->m_BroadcastTime) ?
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,
"timer",
(pPlayer->m_TimerType) ?
"Time is displayed in broadcast now." :
"Time will not be displayed in broadcast now");
}
void CGameContext::ConSetServerGameTime(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
if (!CheckClientID(pResult->m_ClientID))
return;
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
if (!pPlayer)
return;
if(pResult->NumArguments() == 0) {
pSelf->Console()->Print(
IConsole::OUTPUT_LEVEL_STANDARD,
"emote",
(pPlayer->m_GameTimerTime) ?
"Time is displayed in game/round timer now." :
"Time will not be displayed in game/round timer now");
return;
}
else if(str_comp_nocase(pResult->GetString(0), "on") == 0)
pPlayer->m_GameTimerTime = true;
else if(str_comp_nocase(pResult->GetString(0), "off") == 0)
pPlayer->m_GameTimerTime = false;
else if(str_comp_nocase(pResult->GetString(0), "toggle") == 0)
pPlayer->m_GameTimerTime = !pPlayer->m_GameTimerTime;
pSelf->Console()->Print(
IConsole::OUTPUT_LEVEL_STANDARD,
"emote",
(pPlayer->m_GameTimerTime) ?
"Time is displayed in game/round timer now." :
"Time will not be displayed in game/round timer now");
"Time is displayed in game/round timer now.");
}

View file

@ -23,8 +23,7 @@ CHAT_COMMAND("showothers", "?i", CFGFLAG_CHAT|CFGFLAG_SERVER, ConShowOthers, thi
CHAT_COMMAND("saytime", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTime, this, "Privately messages you your current time in this current running race")
CHAT_COMMAND("saytimeall", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSayTimeAll, this, "Publicly messages everyone your current time in this current running race")
CHAT_COMMAND("time", "", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTime, this, "Privately shows you your current time in this current running race in the broadcast message")
CHAT_COMMAND("broadcasttime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetBroadcastTime, this, "Personal Setting of showing time in the broadcast, broadcasttime s, where s = on for on, off for off, toggle for toggle and nothing to show current status")
CHAT_COMMAND("gametimertime", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetServerGameTime, this, "Personal Setting of showing time in the round/game timer, servergametime s, where s = on for on off for off, toggle for toggle and nothing to show current status")
CHAT_COMMAND("timer", "?s", CFGFLAG_CHAT|CFGFLAG_SERVER, ConSetTimerType, this, "Personal Setting of showing time in either broadcast or game/round timer, timer s, where s = broadcast for broadcast, gametimer for game/round timer, toggle for toggle and nothing to show current status")
#if defined(CONF_SQL)
CHAT_COMMAND("times", "?s?i", CFGFLAG_CHAT|CFGFLAG_SERVER, ConTimes, this, "/times ?s?i shows last 5 times of the server or of a player beginning with name s starting with time i (i = 1 by default)")

View file

@ -1008,7 +1008,7 @@ void CCharacter::HandleBroadcast()
GameServer()->SendBroadcast(aBroadcast, m_pPlayer->GetCID());
m_LastBroadcast = Server()->Tick();
}
else if (m_pPlayer->m_BroadcastTime && m_DDRaceState == DDRACE_STARTED && m_LastBroadcast + Server()->TickSpeed() * g_Config.m_SvTimeInBroadcastInterval <= Server()->Tick())
else if (m_pPlayer->m_TimerType && m_DDRaceState == DDRACE_STARTED && m_LastBroadcast + Server()->TickSpeed() * g_Config.m_SvTimeInBroadcastInterval <= Server()->Tick())
{
char aBuftime[64];
int IntTime = (int)((float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed()));

View file

@ -239,8 +239,7 @@ private:
static void ConSayTime(IConsole::IResult *pResult, void *pUserData);
static void ConSayTimeAll(IConsole::IResult *pResult, void *pUserData);
static void ConTime(IConsole::IResult *pResult, void *pUserData);
static void ConSetBroadcastTime(IConsole::IResult *pResult, void *pUserData);
static void ConSetServerGameTime(IConsole::IResult *pResult, void *pUserData);
static void ConSetTimerType(IConsole::IResult *pResult, void *pUserData);

View file

@ -754,7 +754,7 @@ void IGameController::Snap(int SnappingClient)
CCharacter *pChr;
CPlayer *pPlayer = GameServer()->m_apPlayers[SnappingClient];
if(pPlayer && pPlayer->m_GameTimerTime && SnappingClient >= 0)
if(pPlayer && !pPlayer->m_TimerType && SnappingClient >= 0)
if((pChr = pPlayer->GetCharacter()))
pGameInfoObj->m_RoundStartTick = (pChr->m_DDRaceState == DDRACE_STARTED)?pChr->m_StartTime:m_RoundStartTick;
}

View file

@ -38,9 +38,8 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team)
m_Sent2ndAfkWarning = 0;
m_ChatScore = 0;
m_EyeEmote = true;
m_BroadcastTime = g_Config.m_SvTimeInBroadcast;
m_GameTimerTime = g_Config.m_SvTimeInGameTimer;
m_DefEmote = EMOTE_HAPPY;
m_TimerType = g_Config.m_SvDefaultTimerType;
m_DefEmote = EMOTE_NORMAL;
m_DefEmoteReset = -1;
GameServer()->Score()->PlayerData(ClientID)->Reset();

View file

@ -143,8 +143,7 @@ public:
int m_Sent2ndAfkWarning; // afk timer's 2nd warning after 90% of sv_max_afk_time
char m_pAfkMsg[160];
bool m_EyeEmote;
bool m_BroadcastTime;
bool m_GameTimerTime;
bool m_TimerType;
int m_DefEmote;
int m_DefEmoteReset;
#if defined(CONF_SQL)