2010-07-29 14:53:25 +00:00
|
|
|
/*Based on rajh's, Race mod stuff */
|
2010-07-29 05:21:18 +00:00
|
|
|
#include <engine/server.h>
|
|
|
|
#include <game/mapitems.h>
|
|
|
|
#include <game/server/entities/character.h>
|
|
|
|
#include <game/server/player.h>
|
|
|
|
#include <game/server/gamecontext.h>
|
2010-07-29 14:53:25 +00:00
|
|
|
#include "DDRace.h"
|
2010-07-29 05:21:18 +00:00
|
|
|
|
2010-08-10 04:28:17 +00:00
|
|
|
CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) : IGameController(pGameServer)
|
2010-07-29 05:21:18 +00:00
|
|
|
{
|
|
|
|
m_pGameType = "DDRace";
|
2010-08-10 04:28:17 +00:00
|
|
|
|
|
|
|
InitTeleporter();
|
2010-07-29 05:21:18 +00:00
|
|
|
}
|
|
|
|
|
2010-08-10 04:28:17 +00:00
|
|
|
CGameControllerDDRace::~CGameControllerDDRace()
|
|
|
|
{
|
|
|
|
delete[] m_pTeleporter;
|
|
|
|
}
|
2010-07-29 05:21:18 +00:00
|
|
|
|
2010-07-29 14:53:25 +00:00
|
|
|
void CGameControllerDDRace::Tick()
|
2010-07-29 05:21:18 +00:00
|
|
|
{
|
|
|
|
IGameController::Tick();
|
|
|
|
}
|
2010-08-10 04:28:17 +00:00
|
|
|
|
|
|
|
void CGameControllerDDRace::InitTeleporter()
|
|
|
|
{
|
|
|
|
int ArraySize = 0;
|
|
|
|
if(GameServer()->Collision()->Layers()->TeleLayer())
|
|
|
|
{
|
|
|
|
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
|
|
|
|
{
|
|
|
|
// get the array size
|
|
|
|
if(GameServer()->Collision()->m_pTele[i].m_Number > ArraySize)
|
|
|
|
ArraySize = GameServer()->Collision()->m_pTele[i].m_Number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!ArraySize)
|
|
|
|
{
|
|
|
|
m_pTeleporter = 0x0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pTeleporter = new vec2[ArraySize];
|
|
|
|
mem_zero(m_pTeleporter, ArraySize*sizeof(vec2));
|
|
|
|
|
|
|
|
// assign the values
|
|
|
|
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
|
|
|
|
{
|
|
|
|
if(GameServer()->Collision()->m_pTele[i].m_Number > 0 && GameServer()->Collision()->m_pTele[i].m_Type == TILE_TELEOUT)
|
|
|
|
m_pTeleporter[GameServer()->Collision()->m_pTele[i].m_Number-1] = vec2(i%GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16, i/GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16);
|
|
|
|
}
|
|
|
|
}
|