diff --git a/src/game/collision.cpp b/src/game/collision.cpp index 5c65c32fa..fcd937d9b 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -37,6 +37,8 @@ void CCollision::Init(class CLayers *pLayers) m_pSwitch = static_cast(m_pLayers->Map()->GetData(m_pLayers->SwitchLayer()->m_Switch)); m_pDoor = new CDoorTile[m_Width*m_Height]; } + else + m_pDoor = 0; if(m_pLayers->FrontLayer()) { m_pFront = static_cast(m_pLayers->Map()->GetData(m_pLayers->FrontLayer()->m_Front)); diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index ee6aa50ca..5c2b9a719 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -994,7 +994,7 @@ void CCharacter::Tick() m_Core.m_HookState = HOOK_RETRACTED; m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; m_Core.m_HookState = HOOK_RETRACTED; - m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleporter[z-1]; + m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleOuts[z-1][rand()%(((CGameControllerDDRace*)GameServer()->m_pController)->m_pNumTele[z-1] - 1)]; m_Core.m_HookPos = m_Core.m_Pos; } int evilz = GameServer()->Collision()->IsEvilTeleport(MapIndex); @@ -1005,7 +1005,7 @@ void CCharacter::Tick() m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; m_Core.m_HookState = HOOK_RETRACTED; GameWorld()->ReleaseHooked(GetPlayer()->GetCID()); - m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleporter[evilz-1]; + m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleOuts[evilz-1][rand()%(((CGameControllerDDRace*)GameServer()->m_pController)->m_pNumTele[evilz-1] - 1)]; m_Core.m_HookPos = m_Core.m_Pos; m_Core.m_Vel = vec2(0,0); } diff --git a/src/game/server/gamemodes/DDRace.cpp b/src/game/server/gamemodes/DDRace.cpp index 606e90490..f0784b3c4 100644 --- a/src/game/server/gamemodes/DDRace.cpp +++ b/src/game/server/gamemodes/DDRace.cpp @@ -15,7 +15,8 @@ CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) : CGameControllerDDRace::~CGameControllerDDRace() { - delete[] m_pTeleporter; + delete[] m_pNumTele; + delete[][] m_pTeleOuts; } void CGameControllerDDRace::Tick() @@ -26,6 +27,7 @@ void CGameControllerDDRace::Tick() void CGameControllerDDRace::InitTeleporter() { int ArraySize = 0; + m_TotalTele = 0; if(GameServer()->Collision()->Layers()->TeleLayer()) { for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++) @@ -38,18 +40,40 @@ void CGameControllerDDRace::InitTeleporter() if(!ArraySize) { - m_pTeleporter = 0x0; + m_pNumTele = 0x0; return; } + int *Count; + m_pNumTele = new int[ArraySize]; + Count = new int[ArraySize]; + m_pTeleOuts = new vec2*[ArraySize]; + mem_zero(m_pTeleOuts, ArraySize*sizeof(vec2)); + mem_zero(m_pNumTele, ArraySize*sizeof(int)); + mem_zero(Count, ArraySize*sizeof(int)); + for (int i = 0; i < ArraySize; ++i) + Count[i] = m_pNumTele[i] = 0; - m_pTeleporter = new vec2[ArraySize]; - mem_zero(m_pTeleporter, ArraySize*sizeof(vec2)); - - // assign the values + // Count for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++) { if(GameServer()->Collision()->TeleLayer()[i].m_Number > 0 && GameServer()->Collision()->TeleLayer()[i].m_Type == TILE_TELEOUT) - m_pTeleporter[GameServer()->Collision()->TeleLayer()[i].m_Number-1] = vec2(i%GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16, i/GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16); + { + m_pNumTele[GameServer()->Collision()->TeleLayer()[i].m_Number-1]++; + Count[GameServer()->Collision()->TeleLayer()[i].m_Number-1]++; + m_TotalTele++; + } + } + for (int i = 0; i < ArraySize; ++i) + { + m_pTeleOuts[i] = new vec2[m_pNumTele[i]]; + mem_zero(m_pTeleOuts[i], m_pNumTele[i]*sizeof(vec2)); + } + for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++) + { + if(GameServer()->Collision()->TeleLayer()[i].m_Number > 0 && GameServer()->Collision()->TeleLayer()[i].m_Type == TILE_TELEOUT) + { + m_pTeleOuts[GameServer()->Collision()->TeleLayer()[i].m_Number-1][--Count[GameServer()->Collision()->TeleLayer()[i].m_Number-1]] = vec2(i%GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16, i/GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16); + } } } diff --git a/src/game/server/gamemodes/DDRace.h b/src/game/server/gamemodes/DDRace.h index 57c59aa98..7fa86b1ae 100644 --- a/src/game/server/gamemodes/DDRace.h +++ b/src/game/server/gamemodes/DDRace.h @@ -17,7 +17,9 @@ public: CGameTeams m_Teams; - vec2 *m_pTeleporter; + int *m_pNumTele; + vec2 **m_pTeleOuts; + int m_TotalTele; void InitTeleporter(); void InitSwitcher();