added lms gametype, updated standard gametype check and made players keep their score between rounds

This commit is contained in:
oy 2012-02-15 01:40:34 +01:00
parent 0f456aebee
commit b0bf7115c9
12 changed files with 118 additions and 25 deletions

View file

@ -154,7 +154,9 @@ void CServerBrowser::Filter()
else if(g_Config.m_BrFilterPure &&
(str_comp(m_ppServerlist[i]->m_Info.m_aGameType, "DM") != 0 &&
str_comp(m_ppServerlist[i]->m_Info.m_aGameType, "TDM") != 0 &&
str_comp(m_ppServerlist[i]->m_Info.m_aGameType, "CTF") != 0))
str_comp(m_ppServerlist[i]->m_Info.m_aGameType, "CTF") != 0 &&
str_comp(m_ppServerlist[i]->m_Info.m_aGameType, "SUR") != 0 &&
str_comp(m_ppServerlist[i]->m_Info.m_aGameType, "LMS") != 0))
{
Filtered = 1;
}
@ -354,21 +356,6 @@ void CServerBrowser::SetInfo(CServerEntry *pEntry, const CServerInfo &Info)
pEntry->m_Info = Info;
pEntry->m_Info.m_Favorite = Fav;
pEntry->m_Info.m_NetAddr = pEntry->m_Addr;
// all these are just for nice compability
if(pEntry->m_Info.m_aGameType[0] == '0' && pEntry->m_Info.m_aGameType[1] == 0)
str_copy(pEntry->m_Info.m_aGameType, "DM", sizeof(pEntry->m_Info.m_aGameType));
else if(pEntry->m_Info.m_aGameType[0] == '1' && pEntry->m_Info.m_aGameType[1] == 0)
str_copy(pEntry->m_Info.m_aGameType, "TDM", sizeof(pEntry->m_Info.m_aGameType));
else if(pEntry->m_Info.m_aGameType[0] == '2' && pEntry->m_Info.m_aGameType[1] == 0)
str_copy(pEntry->m_Info.m_aGameType, "CTF", sizeof(pEntry->m_Info.m_aGameType));
/*if(!request)
{
pEntry->m_Info.latency = (time_get()-pEntry->request_time)*1000/time_freq();
RemoveRequest(pEntry);
}*/
pEntry->m_GotInfo = 1;
}

View file

@ -207,7 +207,7 @@ void CControls::OnRender()
bool CControls::OnMouseMove(float x, float y)
{
if((m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED) ||
if((m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&(GAMESTATEFLAG_PAUSED|GAMESTATEFLAG_ROUNDOVER|GAMESTATEFLAG_GAMEOVER)) ||
(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_pChat->IsActive()))
return false;

View file

@ -274,6 +274,8 @@ void CHud::RenderScoreHud()
float ScoreWidthMax = max(max(aScoreWidth[0], aScoreWidth[1]), TextRender()->TextWidth(0, 14.0f, "10", -1));
float Split = 3.0f, ImageSize = 16.0f, PosSize = 16.0f;
// todo: add core hud for LMS
for(int t = 0; t < 2; t++)
{
// draw box

View file

@ -314,7 +314,9 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
{
if( str_comp(pItem->m_aGameType, "DM") == 0 ||
str_comp(pItem->m_aGameType, "TDM") == 0 ||
str_comp(pItem->m_aGameType, "CTF") == 0)
str_comp(pItem->m_aGameType, "CTF") == 0 ||
str_comp(pItem->m_aGameType, "LMS") == 0 ||
str_comp(pItem->m_aGameType, "SUR") == 0)
{
// pure server
}

View file

@ -887,7 +887,8 @@ void CGameClient::OnNewSnapshot()
Client()->GetServerInfo(&CurrentServerInfo);
if(CurrentServerInfo.m_aGameType[0] != '0')
{
if(str_comp(CurrentServerInfo.m_aGameType, "DM") != 0 && str_comp(CurrentServerInfo.m_aGameType, "TDM") != 0 && str_comp(CurrentServerInfo.m_aGameType, "CTF") != 0)
if(str_comp(CurrentServerInfo.m_aGameType, "DM") != 0 && str_comp(CurrentServerInfo.m_aGameType, "TDM") != 0 && str_comp(CurrentServerInfo.m_aGameType, "CTF") != 0 &&
str_comp(CurrentServerInfo.m_aGameType, "LMS") != 0 && str_comp(CurrentServerInfo.m_aGameType, "SUR") != 0)
m_ServerMode = SERVERMODE_MOD;
else if(mem_comp(&StandardTuning, &m_Tuning, sizeof(CTuningParams)) == 0)
m_ServerMode = SERVERMODE_PURE;

View file

@ -13,6 +13,7 @@
#include "entities/character.h"
#include "gamemodes/ctf.h"
#include "gamemodes/dm.h"
#include "gamemodes/lms.h"
#include "gamemodes/mod.h"
#include "gamemodes/sur.h"
#include "gamemodes/tdm.h"
@ -371,8 +372,9 @@ void CGameContext::CheckPureTuning()
if( str_comp(m_pController->GetGameType(), "DM")==0 ||
str_comp(m_pController->GetGameType(), "TDM")==0 ||
str_comp(m_pController->GetGameType(), "SUR")==0 ||
str_comp(m_pController->GetGameType(), "CTF")==0)
str_comp(m_pController->GetGameType(), "CTF")==0 ||
str_comp(m_pController->GetGameType(), "LMS")==0 ||
str_comp(m_pController->GetGameType(), "SUR")==0)
{
CTuningParams p;
if(mem_comp(&p, &m_Tuning, sizeof(p)) != 0)
@ -1446,6 +1448,8 @@ void CGameContext::OnInit()
m_pController = new CGameControllerMOD(this);
else if(str_comp(g_Config.m_SvGametype, "ctf") == 0)
m_pController = new CGameControllerCTF(this);
else if(str_comp(g_Config.m_SvGametype, "lms") == 0)
m_pController = new CGameControllerLMS(this);
else if(str_comp(g_Config.m_SvGametype, "sur") == 0)
m_pController = new CGameControllerSUR(this);
else if(str_comp(g_Config.m_SvGametype, "tdm") == 0)

View file

@ -26,6 +26,7 @@ IGameController::IGameController(CGameContext *pGameServer)
m_GameStateTimer = TIMER_INFINITE;
m_GameStartTick = Server()->Tick();
m_MatchCount = 0;
m_RoundCount = 0;
m_SuddenDeath = 0;
m_aTeamscore[TEAM_RED] = 0;
m_aTeamscore[TEAM_BLUE] = 0;
@ -388,8 +389,11 @@ void IGameController::OnReset()
GameServer()->m_apPlayers[i]->m_RespawnDisabled = false;
GameServer()->m_apPlayers[i]->Respawn();
GameServer()->m_apPlayers[i]->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2;
GameServer()->m_apPlayers[i]->m_Score = 0;
GameServer()->m_apPlayers[i]->m_ScoreStartTick = Server()->Tick();
if(m_RoundCount == 0)
{
GameServer()->m_apPlayers[i]->m_Score = 0;
GameServer()->m_apPlayers[i]->m_ScoreStartTick = Server()->Tick();
}
GameServer()->m_apPlayers[i]->m_IsReadyToPlay = true;
}
}
@ -584,6 +588,7 @@ void IGameController::StartMatch()
{
ResetGame();
m_RoundCount = 0;
m_aTeamscore[TEAM_RED] = 0;
m_aTeamscore[TEAM_BLUE] = 0;
@ -603,6 +608,8 @@ void IGameController::StartRound()
{
ResetGame();
++m_RoundCount;
// start countdown if there're enough players, otherwise abort to warmup
if(HasEnoughPlayers())
SetGameState(IGS_START_COUNTDOWN);

View file

@ -97,6 +97,7 @@ protected:
// game
int m_GameStartTick;
int m_MatchCount;
int m_RoundCount;
int m_SuddenDeath;
int m_aTeamscore[NUM_TEAMS];

View file

@ -0,0 +1,70 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <engine/shared/config.h>
#include <game/server/entities/character.h>
#include <game/server/gamecontext.h>
#include <game/server/player.h>
#include "lms.h"
CGameControllerLMS::CGameControllerLMS(CGameContext *pGameServer) : IGameController(pGameServer)
{
m_pGameType = "LMS";
m_GameFlags = GAMEFLAG_SURVIVAL;
}
// event
int CGameControllerLMS::OnCharacterDeath(CCharacter *pVictim, CPlayer *pKiller, int Weapon)
{
// update spectator modes for dead players in survival
if(m_GameFlags&GAMEFLAG_SURVIVAL)
{
for(int i = 0; i < MAX_CLIENTS; ++i)
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_DeadSpecMode)
GameServer()->m_apPlayers[i]->UpdateDeadSpecMode();
}
return 0;
}
// game
void CGameControllerLMS::DoWincheckRound()
{
// check for time based win
if(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_GameStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60)
{
for(int i = 0; i < MAX_CLIENTS; ++i)
{
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS &&
(!GameServer()->m_apPlayers[i]->m_RespawnDisabled ||
(GameServer()->m_apPlayers[i]->GetCharacter() && GameServer()->m_apPlayers[i]->GetCharacter()->IsAlive())))
GameServer()->m_apPlayers[i]->m_Score++;
}
EndRound();
}
else
{
// check for survival win
CPlayer *pAlivePlayer = 0;
int AlivePlayerCount = 0;
for(int i = 0; i < MAX_CLIENTS; ++i)
{
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS &&
(!GameServer()->m_apPlayers[i]->m_RespawnDisabled ||
(GameServer()->m_apPlayers[i]->GetCharacter() && GameServer()->m_apPlayers[i]->GetCharacter()->IsAlive())))
{
++AlivePlayerCount;
pAlivePlayer = GameServer()->m_apPlayers[i];
}
}
if(AlivePlayerCount == 0) // no winner
EndRound();
else if(AlivePlayerCount == 1) // 1 winner
{
pAlivePlayer->m_Score++;
EndRound();
}
}
}

View file

@ -0,0 +1,19 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef GAME_SERVER_GAMEMODES_LMS_H
#define GAME_SERVER_GAMEMODES_LMS_H
#include <game/server/gamecontroller.h>
class CGameControllerLMS : public IGameController
{
public:
CGameControllerLMS(class CGameContext *pGameServer);
// event
virtual int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon);
// game
virtual void DoWincheckRound();
};
#endif

View file

@ -7,7 +7,7 @@
#include <game/server/player.h>
#include "sur.h"
CGameControllerSUR::CGameControllerSUR(class CGameContext *pGameServer) : IGameController(pGameServer)
CGameControllerSUR::CGameControllerSUR(CGameContext *pGameServer) : IGameController(pGameServer)
{
m_pGameType = "SUR";
m_GameFlags = GAMEFLAG_TEAMS|GAMEFLAG_SURVIVAL;

View file

@ -65,7 +65,7 @@ MACRO_CONFIG_INT(SvMatchSwap, sv_match_swap, 1, 0, 1, CFGFLAG_SERVER, "Swap team
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)")
MACRO_CONFIG_STR(SvGametype, sv_gametype, 32, "dm", CFGFLAG_SERVER, "Game type (dm, tdm, sur, ctf)")
MACRO_CONFIG_STR(SvGametype, sv_gametype, 32, "dm", CFGFLAG_SERVER, "Game type (dm, tdm, ctf, lms, sur)")
MACRO_CONFIG_INT(SvTournamentMode, sv_tournament_mode, 0, 0, 1, CFGFLAG_SERVER, "Tournament mode. When enabled, players joins the server as spectator")
MACRO_CONFIG_INT(SvPlayerReadyMode, sv_player_ready_mode, 0, 0, 1, CFGFLAG_SERVER, "When enabled, players can pause/unpause the game and start the game on warmup via their ready state")
MACRO_CONFIG_INT(SvSpamprotection, sv_spamprotection, 1, 0, 1, CFGFLAG_SERVER, "Spam protection")