mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
of course delete[] makes problems for me with 2D array even when i loop on 1D 1st .... so here's my alternative
Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
parent
526e36f8a0
commit
31892f7475
|
@ -994,7 +994,8 @@ void CCharacter::Tick()
|
||||||
m_Core.m_HookState = HOOK_RETRACTED;
|
m_Core.m_HookState = HOOK_RETRACTED;
|
||||||
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
|
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
|
||||||
m_Core.m_HookState = HOOK_RETRACTED;
|
m_Core.m_HookState = HOOK_RETRACTED;
|
||||||
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleOuts[z-1][rand()%(((CGameControllerDDRace*)GameServer()->m_pController)->m_pNumTele[z-1] - 1)];
|
int Num = (((CGameControllerDDRace*)GameServer()->m_pController)->m_pNumTele[z-1] - 1);
|
||||||
|
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTele2D[z-1][(!Num)?Num:rand() % Num];
|
||||||
m_Core.m_HookPos = m_Core.m_Pos;
|
m_Core.m_HookPos = m_Core.m_Pos;
|
||||||
}
|
}
|
||||||
int evilz = GameServer()->Collision()->IsEvilTeleport(MapIndex);
|
int evilz = GameServer()->Collision()->IsEvilTeleport(MapIndex);
|
||||||
|
@ -1005,7 +1006,8 @@ void CCharacter::Tick()
|
||||||
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
|
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
|
||||||
m_Core.m_HookState = HOOK_RETRACTED;
|
m_Core.m_HookState = HOOK_RETRACTED;
|
||||||
GameWorld()->ReleaseHooked(GetPlayer()->GetCID());
|
GameWorld()->ReleaseHooked(GetPlayer()->GetCID());
|
||||||
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleOuts[evilz-1][rand()%(((CGameControllerDDRace*)GameServer()->m_pController)->m_pNumTele[evilz-1] - 1)];
|
int Num = (((CGameControllerDDRace*)GameServer()->m_pController)->m_pNumTele[z-1] - 1);
|
||||||
|
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTele2D[evilz-1][(!Num)?Num:rand() % Num];
|
||||||
m_Core.m_HookPos = m_Core.m_Pos;
|
m_Core.m_HookPos = m_Core.m_Pos;
|
||||||
m_Core.m_Vel = vec2(0,0);
|
m_Core.m_Vel = vec2(0,0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) :
|
||||||
|
|
||||||
CGameControllerDDRace::~CGameControllerDDRace()
|
CGameControllerDDRace::~CGameControllerDDRace()
|
||||||
{
|
{
|
||||||
|
delete[] m_pTele1D;
|
||||||
delete[] m_pNumTele;
|
delete[] m_pNumTele;
|
||||||
delete[] m_pTeleOuts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameControllerDDRace::Tick()
|
void CGameControllerDDRace::Tick()
|
||||||
|
@ -26,31 +26,29 @@ void CGameControllerDDRace::Tick()
|
||||||
|
|
||||||
void CGameControllerDDRace::InitTeleporter()
|
void CGameControllerDDRace::InitTeleporter()
|
||||||
{
|
{
|
||||||
int ArraySize = 0;
|
m_ArraySize = 0;
|
||||||
m_TotalTele = 0;
|
m_TotalTele = 0;
|
||||||
if(GameServer()->Collision()->Layers()->TeleLayer())
|
if(GameServer()->Collision()->Layers()->TeleLayer())
|
||||||
{
|
{
|
||||||
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
|
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
|
||||||
{
|
{
|
||||||
// get the array size
|
// get the array size
|
||||||
if(GameServer()->Collision()->TeleLayer()[i].m_Number > ArraySize)
|
if(GameServer()->Collision()->TeleLayer()[i].m_Number > m_ArraySize)
|
||||||
ArraySize = GameServer()->Collision()->TeleLayer()[i].m_Number;
|
m_ArraySize = GameServer()->Collision()->TeleLayer()[i].m_Number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ArraySize)
|
if(!m_ArraySize)
|
||||||
{
|
{
|
||||||
m_pNumTele = 0x0;
|
m_pNumTele = 0x0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int *Count;
|
int *Count;
|
||||||
m_pNumTele = new int[ArraySize];
|
m_pNumTele = new int[m_ArraySize];
|
||||||
Count = new int[ArraySize];
|
Count = new int[m_ArraySize];
|
||||||
m_pTeleOuts = new vec2*[ArraySize];
|
mem_zero(m_pNumTele, m_ArraySize*sizeof(int));
|
||||||
mem_zero(m_pTeleOuts, ArraySize*sizeof(vec2));
|
mem_zero(Count, m_ArraySize*sizeof(int));
|
||||||
mem_zero(m_pNumTele, ArraySize*sizeof(int));
|
for (int i = 0; i < m_ArraySize; ++i)
|
||||||
mem_zero(Count, ArraySize*sizeof(int));
|
|
||||||
for (int i = 0; i < ArraySize; ++i)
|
|
||||||
Count[i] = m_pNumTele[i] = 0;
|
Count[i] = m_pNumTele[i] = 0;
|
||||||
|
|
||||||
// Count
|
// Count
|
||||||
|
@ -63,16 +61,19 @@ void CGameControllerDDRace::InitTeleporter()
|
||||||
m_TotalTele++;
|
m_TotalTele++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < ArraySize; ++i)
|
m_pTele1D = new vec2[m_TotalTele];
|
||||||
|
mem_zero(m_pTele1D, m_TotalTele*sizeof(vec2));
|
||||||
|
m_pTele2D = &m_pTele1D;
|
||||||
|
for (int i = 0; i < m_ArraySize; ++i)
|
||||||
{
|
{
|
||||||
m_pTeleOuts[i] = new vec2[m_pNumTele[i]];
|
m_pTele2D[i] = new vec2[m_pNumTele[i]];
|
||||||
mem_zero(m_pTeleOuts[i], m_pNumTele[i]*sizeof(vec2));
|
mem_zero(m_pTele2D[i], m_pNumTele[i]*sizeof(vec2));
|
||||||
}
|
}
|
||||||
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
|
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)
|
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);
|
m_pTele2D[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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,10 @@ public:
|
||||||
CGameTeams m_Teams;
|
CGameTeams m_Teams;
|
||||||
|
|
||||||
int *m_pNumTele;
|
int *m_pNumTele;
|
||||||
vec2 **m_pTeleOuts;
|
vec2 *m_pTele1D;
|
||||||
|
vec2 **m_pTele2D;
|
||||||
int m_TotalTele;
|
int m_TotalTele;
|
||||||
|
int m_ArraySize;
|
||||||
|
|
||||||
void InitTeleporter();
|
void InitTeleporter();
|
||||||
void InitSwitcher();
|
void InitSwitcher();
|
||||||
|
|
Loading…
Reference in a new issue