ddnet/src/game/server/gamemodes/DDRace.cpp
GreYFoXGTi 20930ce68b too many stuff to write but the idea is to implement the telelayer&speed thnx to Redix and Sushi Tee
also FrontLayer is ready to be implemented soon

Signed-off-by: GreYFoXGTi <GreYFoXGTi@Gmail.com>
2010-08-10 19:32:32 +03:00

54 lines
1.6 KiB
C++

/*Based on rajh's, Race mod stuff */
#include <engine/server.h>
#include <game/mapitems.h>
#include <game/server/entities/character.h>
#include <game/server/player.h>
#include <game/server/gamecontext.h>
#include "DDRace.h"
CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) : IGameController(pGameServer)
{
m_pGameType = "DDRace";
InitTeleporter();
}
CGameControllerDDRace::~CGameControllerDDRace()
{
delete[] m_pTeleporter;
}
void CGameControllerDDRace::Tick()
{
IGameController::Tick();
}
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);
}
}