changed usage of round to match

This commit is contained in:
oy 2012-02-15 01:39:40 +01:00
parent b374a24c06
commit 97061ab59d
8 changed files with 47 additions and 43 deletions

View file

@ -105,14 +105,14 @@ Objects = [
NetObject("GameInfo", [
NetIntRange("m_GameFlags", 0, 256),
NetIntRange("m_GameStateFlags", 0, 256),
NetTick("m_RoundStartTick"),
NetTick("m_GameStartTick"),
NetIntRange("m_GameStateTimer", 0, 'max_int'),
NetIntRange("m_ScoreLimit", 0, 'max_int'),
NetIntRange("m_TimeLimit", 0, 'max_int'),
NetIntRange("m_RoundNum", 0, 'max_int'),
NetIntRange("m_RoundCurrent", 0, 'max_int'),
NetIntRange("m_MatchNum", 0, 'max_int'),
NetIntRange("m_MatchCurrent", 0, 'max_int'),
]),
NetObject("GameData", [

View file

@ -37,7 +37,7 @@ void CHud::RenderGameTimer()
int Time = 0;
if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit && !(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_WARMUP))
{
Time = m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit*60 - ((Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick)/Client()->GameTickSpeed());
Time = m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit*60 - ((Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_GameStartTick)/Client()->GameTickSpeed());
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
Time = 0;
@ -45,7 +45,7 @@ void CHud::RenderGameTimer()
else if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
Time = m_pClient->m_Snap.m_pGameInfoObj->m_GameStateTimer/Client()->GameTickSpeed();
else
Time = (Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick)/Client()->GameTickSpeed();
Time = (Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_GameStartTick)/Client()->GameTickSpeed();
str_format(Buf, sizeof(Buf), "%d:%02d", Time/60, Time%60);
float FontSize = 10.0f;

View file

@ -104,8 +104,8 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void
{
if(pItem->m_Version < 2 || pItem->m_Synchronized)
{
s_Time = mix((pThis->Client()->PrevGameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(),
(pThis->Client()->GameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(),
s_Time = mix((pThis->Client()->PrevGameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_GameStartTick) / (float)pThis->Client()->GameTickSpeed(),
(pThis->Client()->GameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_GameStartTick) / (float)pThis->Client()->GameTickSpeed(),
pThis->Client()->IntraGameTick());
}
else

View file

@ -70,10 +70,10 @@ void CScoreboard::RenderGoals(float x, float y, float w)
str_format(aBuf, sizeof(aBuf), Localize("Time limit: %d min"), m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit);
TextRender()->Text(0, x+230.0f, y, 20.0f, aBuf, -1);
}
if(m_pClient->m_Snap.m_pGameInfoObj->m_RoundNum && m_pClient->m_Snap.m_pGameInfoObj->m_RoundCurrent)
if(m_pClient->m_Snap.m_pGameInfoObj->m_MatchNum && m_pClient->m_Snap.m_pGameInfoObj->m_MatchCurrent)
{
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s %d/%d", Localize("Round"), m_pClient->m_Snap.m_pGameInfoObj->m_RoundCurrent, m_pClient->m_Snap.m_pGameInfoObj->m_RoundNum);
str_format(aBuf, sizeof(aBuf), "%s %d/%d", Localize("Match"), m_pClient->m_Snap.m_pGameInfoObj->m_MatchCurrent, m_pClient->m_Snap.m_pGameInfoObj->m_MatchNum);
float tw = TextRender()->TextWidth(0, 20.0f, aBuf, -1);
TextRender()->Text(0, x+w-tw-10.0f, y, 20.0f, aBuf, -1);
}

View file

@ -22,8 +22,12 @@ IGameController::IGameController(CGameContext *pGameServer)
// game
m_GameState = GS_GAME;
m_GameStateTimer = TIMER_INFINITE;
m_RoundStartTick = Server()->Tick();
m_GameStartTick = Server()->Tick();
m_MatchCount = 0;
m_StartCountdownReset = false;
m_SuddenDeath = 0;
m_aTeamscore[TEAM_RED] = 0;
m_aTeamscore[TEAM_BLUE] = 0;
if(g_Config.m_SvWarmup)
SetGameState(GS_WARMUP, g_Config.m_SvWarmup);
else
@ -349,10 +353,10 @@ void IGameController::DoWincheck()
{
// check score win condition
if((g_Config.m_SvScorelimit > 0 && (m_aTeamscore[TEAM_RED] >= g_Config.m_SvScorelimit || m_aTeamscore[TEAM_BLUE] >= g_Config.m_SvScorelimit)) ||
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_GameStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
{
if(m_aTeamscore[TEAM_RED] != m_aTeamscore[TEAM_BLUE])
EndRound();
EndMatch();
else
m_SuddenDeath = 1;
}
@ -378,17 +382,17 @@ void IGameController::DoWincheck()
// check score win condition
if((g_Config.m_SvScorelimit > 0 && Topscore >= g_Config.m_SvScorelimit) ||
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_GameStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
{
if(TopscoreCount == 1)
EndRound();
EndMatch();
else
m_SuddenDeath = 1;
}
}
}
void IGameController::EndRound()
void IGameController::EndMatch()
{
SetGameState(GS_GAMEOVER, 10);
}
@ -398,7 +402,7 @@ void IGameController::ResetGame()
GameServer()->m_World.m_ResetRequested = true;
SetGameState(GS_GAME);
m_RoundStartTick = Server()->Tick();
m_GameStartTick = Server()->Tick();
m_SuddenDeath = 0;
}
@ -488,7 +492,7 @@ void IGameController::SetGameState(int GameState, int Seconds)
}
}
void IGameController::StartRound()
void IGameController::StartMatch()
{
ResetGame();
@ -502,7 +506,7 @@ void IGameController::StartRound()
Server()->DemoRecorder_HandleAutoStart();
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "start round type='%s' teamplay='%d'", m_pGameType, m_GameFlags&GAMEFLAG_TEAMS);
str_format(aBuf, sizeof(aBuf), "start match type='%s' teamplay='%d'", m_pGameType, m_GameFlags&GAMEFLAG_TEAMS);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
}
@ -533,18 +537,18 @@ void IGameController::Snap(int SnappingClient)
break;
case GS_GAMEOVER:
pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_GAMEOVER;
pGameInfoObj->m_GameStateTimer = Server()->Tick()-m_RoundStartTick-10*Server()->TickSpeed()+m_GameStateTimer;
pGameInfoObj->m_GameStateTimer = Server()->Tick()-m_GameStartTick-10*Server()->TickSpeed()+m_GameStateTimer;
}
if(m_SuddenDeath)
pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_SUDDENDEATH;
pGameInfoObj->m_RoundStartTick = m_RoundStartTick;
pGameInfoObj->m_GameStartTick = m_GameStartTick;
pGameInfoObj->m_ScoreLimit = g_Config.m_SvScorelimit;
pGameInfoObj->m_TimeLimit = g_Config.m_SvTimelimit;
pGameInfoObj->m_RoundNum = (str_length(g_Config.m_SvMaprotation) && g_Config.m_SvRoundsPerMap) ? g_Config.m_SvRoundsPerMap : 0;
pGameInfoObj->m_RoundCurrent = m_RoundCount+1;
pGameInfoObj->m_MatchNum = (str_length(g_Config.m_SvMaprotation) && g_Config.m_SvMatchesPerMap) ? g_Config.m_SvMatchesPerMap : 0;
pGameInfoObj->m_MatchCurrent = m_MatchCount+1;
}
void IGameController::Tick()
@ -561,7 +565,7 @@ void IGameController::Tick()
if(m_GameStateTimer == 0 || (m_GameStateTimer == TIMER_INFINITE && (!g_Config.m_SvPlayerReadyMode || GetPlayersReadyState())))
{
if(m_GameStateTimer == 0)
StartRound();
StartMatch();
else
SetGameState(GS_STARTCOUNTDOWN, TIMER_STARTCOUNTDOWN);
}
@ -570,25 +574,25 @@ void IGameController::Tick()
if(m_GameStateTimer == 0)
{
if(m_StartCountdownReset)
StartRound();
StartMatch();
else
SetGameState(GS_GAME);
}
else
++m_RoundStartTick;
++m_GameStartTick;
break;
case GS_PAUSED:
if(m_GameStateTimer == 0 || (m_GameStateTimer == TIMER_INFINITE && g_Config.m_SvPlayerReadyMode && GetPlayersReadyState()))
SetGameState(GS_PAUSED, 0);
else
++m_RoundStartTick;
++m_GameStartTick;
break;
case GS_GAMEOVER:
if(m_GameStateTimer == 0)
{
CycleMap();
StartRound();
m_RoundCount++;
StartMatch();
m_MatchCount++;
}
}
}
@ -661,7 +665,7 @@ static bool IsSeparator(char c) { return c == ';' || c == ' ' || c == ',' || c =
void IGameController::ChangeMap(const char *pToMap)
{
str_copy(m_aMapWish, pToMap, sizeof(m_aMapWish));
EndRound();
EndMatch();
}
void IGameController::CycleMap()
@ -673,15 +677,15 @@ void IGameController::CycleMap()
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
str_copy(g_Config.m_SvMap, m_aMapWish, sizeof(g_Config.m_SvMap));
m_aMapWish[0] = 0;
m_RoundCount = 0;
m_MatchCount = 0;
return;
}
if(!str_length(g_Config.m_SvMaprotation))
return;
if(m_RoundCount < g_Config.m_SvRoundsPerMap-1)
if(m_MatchCount < g_Config.m_SvMatchesPerMap-1)
{
if(g_Config.m_SvRoundSwap)
if(g_Config.m_SvMatchSwap)
GameServer()->SwapTeams();
return;
}
@ -732,7 +736,7 @@ void IGameController::CycleMap()
while(IsSeparator(aBuf[i]))
i++;
m_RoundCount = 0;
m_MatchCount = 0;
char aBufMsg[256];
str_format(aBufMsg, sizeof(aBufMsg), "rotating map to %s", &aBuf[i]);

View file

@ -76,14 +76,14 @@ protected:
IServer *Server() const { return m_pServer; }
// game
int m_RoundCount;
int m_RoundStartTick;
int m_GameStartTick;
int m_MatchCount;
int m_SuddenDeath;
int m_aTeamscore[NUM_TEAMS];
void EndRound();
void EndMatch();
void ResetGame();
void StartRound();
void StartMatch();
// info
int m_GameFlags;

View file

@ -89,17 +89,17 @@ void CGameControllerCTF::DoWincheck()
{
// check score win condition
if((g_Config.m_SvScorelimit > 0 && (m_aTeamscore[TEAM_RED] >= g_Config.m_SvScorelimit || m_aTeamscore[TEAM_BLUE] >= g_Config.m_SvScorelimit)) ||
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_GameStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
{
if(m_SuddenDeath)
{
if(m_aTeamscore[TEAM_RED]/100 != m_aTeamscore[TEAM_BLUE]/100)
EndRound();
EndMatch();
}
else
{
if(m_aTeamscore[TEAM_RED] != m_aTeamscore[TEAM_BLUE])
EndRound();
EndMatch();
else
m_SuddenDeath = 1;
}

View file

@ -56,12 +56,12 @@ MACRO_CONFIG_INT(UiColorAlpha, ui_color_alpha, 228, 0, 255, CFGFLAG_CLIENT|CFGFL
MACRO_CONFIG_INT(GfxNoclip, gfx_noclip, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Disable clipping")
// server
MACRO_CONFIG_INT(SvWarmup, sv_warmup, 0, -1, 1000, CFGFLAG_SERVER, "Number of seconds to do warmup before round starts (0 disables, -1 all players ready)")
MACRO_CONFIG_INT(SvWarmup, sv_warmup, 0, -1, 1000, CFGFLAG_SERVER, "Number of seconds to do warmup before match starts (0 disables, -1 all players ready)")
MACRO_CONFIG_STR(SvMotd, sv_motd, 900, "", CFGFLAG_SERVER, "Message of the day to display for the clients")
MACRO_CONFIG_INT(SvTeamdamage, sv_teamdamage, 0, 0, 1, CFGFLAG_SERVER, "Team damage")
MACRO_CONFIG_STR(SvMaprotation, sv_maprotation, 768, "", CFGFLAG_SERVER, "Maps to rotate between")
MACRO_CONFIG_INT(SvRoundsPerMap, sv_rounds_per_map, 1, 1, 100, CFGFLAG_SERVER, "Number of rounds on each map before rotating")
MACRO_CONFIG_INT(SvRoundSwap, sv_round_swap, 1, 0, 1, CFGFLAG_SERVER, "Swap teams between rounds")
MACRO_CONFIG_INT(SvMatchesPerMap, sv_matches_per_map, 1, 1, 100, CFGFLAG_SERVER, "Number of matches on each map before rotating")
MACRO_CONFIG_INT(SvMatchSwap, sv_match_swap, 1, 0, 1, CFGFLAG_SERVER, "Swap teams between matches")
MACRO_CONFIG_INT(SvPowerups, sv_powerups, 1, 0, 1, CFGFLAG_SERVER, "Allow powerups like ninja")
MACRO_CONFIG_INT(SvScorelimit, sv_scorelimit, 20, 0, 1000, CFGFLAG_SERVER, "Score limit (0 disables)")
MACRO_CONFIG_INT(SvTimelimit, sv_timelimit, 0, 0, 1000, CFGFLAG_SERVER, "Time limit in minutes (0 disables)")