/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */ /* Based on Race mod stuff and tweaked by GreYFoX@GTi and others to fit our DDRace needs. */ #include #include #include #include #include #include #include "DDRace.h" #include "gamemode.h" #if defined(CONF_SQL) #include #endif CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) : IGameController(pGameServer), m_Teams(pGameServer), m_pInitResult(nullptr) { m_pGameType = g_Config.m_SvTestingCommands ? TEST_NAME : GAME_NAME; InitTeleporter(); } CGameControllerDDRace::~CGameControllerDDRace() { // Nothing to clean } void CGameControllerDDRace::Tick() { IGameController::Tick(); #if defined(CONF_SQL) m_Teams.ProcessSaveTeam(); if(m_pInitResult != nullptr && m_pInitResult.use_count() == 1) { if(m_pInitResult->m_Done) { m_CurrentRecord = m_pInitResult->m_CurrentRecord; } m_pInitResult = nullptr; } #endif } void CGameControllerDDRace::InitTeleporter() { if (!GameServer()->Collision()->Layers()->TeleLayer()) return; int Width = GameServer()->Collision()->Layers()->TeleLayer()->m_Width; int Height = GameServer()->Collision()->Layers()->TeleLayer()->m_Height; for (int i = 0; i < Width * Height; i++) { int Number = GameServer()->Collision()->TeleLayer()[i].m_Number; int Type = GameServer()->Collision()->TeleLayer()[i].m_Type; if (Number > 0) { if (Type == TILE_TELEOUT) { m_TeleOuts[Number - 1].push_back( vec2(i % Width * 32 + 16, i / Width * 32 + 16)); } else if (Type == TILE_TELECHECKOUT) { m_TeleCheckOuts[Number - 1].push_back( vec2(i % Width * 32 + 16, i / Width * 32 + 16)); } } } }