2023-11-24 23:35:01 +08:00
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
2024-09-21 22:22:06 +08:00
|
|
|
#define RGBA_ABGR(n) (((n >> 24) & 0x000000FF) | ((n >> 8) & 0x0000FF00) | ((n << 8) & 0x00FF0000) | ((n << 24) & 0xFF000000))
|
|
|
|
|
|
|
|
//----------------------------------------------------
|
|
|
|
|
2023-11-24 23:35:01 +08:00
|
|
|
CGangZonePool::CGangZonePool()
|
|
|
|
{
|
|
|
|
for (WORD wZone = 0; wZone < MAX_GANG_ZONES; wZone++)
|
|
|
|
{
|
2024-09-21 21:56:34 +08:00
|
|
|
m_bSlotState[wZone] = FALSE;
|
2023-11-24 23:35:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-21 21:56:34 +08:00
|
|
|
WORD CGangZonePool::New(float fMinX, float fMinY, float fMaxX, float fMaxY)
|
|
|
|
{
|
|
|
|
WORD wZone = 0;
|
|
|
|
while (wZone < MAX_GANG_ZONES)
|
|
|
|
{
|
|
|
|
if (!m_bSlotState[wZone]) break;
|
|
|
|
wZone++;
|
|
|
|
}
|
|
|
|
if (wZone == MAX_GANG_ZONES) return 0xFFFF;
|
|
|
|
m_fGangZone[wZone][0] = fMinX;
|
|
|
|
m_fGangZone[wZone][1] = fMinY;
|
|
|
|
m_fGangZone[wZone][2] = fMaxX;
|
|
|
|
m_fGangZone[wZone][3] = fMaxY;
|
|
|
|
m_bSlotState[wZone] = TRUE;
|
|
|
|
return wZone;
|
|
|
|
}
|
2024-09-21 22:00:57 +08:00
|
|
|
|
|
|
|
void CGangZonePool::Delete(WORD wZone)
|
|
|
|
{
|
|
|
|
m_bSlotState[wZone] = FALSE;
|
|
|
|
RakNet::BitStream bsParams;
|
|
|
|
bsParams.Write(wZone);
|
|
|
|
pNetGame->BroadcastData(RPC_ScrRemoveGangZone, &bsParams, INVALID_PLAYER_ID, 2);
|
|
|
|
}
|
|
|
|
|
2024-09-21 22:22:06 +08:00
|
|
|
void CGangZonePool::ShowForPlayer(PLAYERID playerId, WORD wZone, DWORD dwColor)
|
|
|
|
{
|
|
|
|
RakNet::BitStream bsParams;
|
|
|
|
bsParams.Write(wZone);
|
|
|
|
bsParams.Write(m_fGangZone[wZone][0]);
|
|
|
|
bsParams.Write(m_fGangZone[wZone][1]);
|
|
|
|
bsParams.Write(m_fGangZone[wZone][2]);
|
|
|
|
bsParams.Write(m_fGangZone[wZone][3]);
|
|
|
|
dwColor = RGBA_ABGR(dwColor);
|
|
|
|
bsParams.Write(dwColor);
|
|
|
|
pNetGame->SendToPlayer(RPC_ScrAddGangZone, &bsParams, playerId, 2);
|
|
|
|
}
|
|
|
|
|
2024-09-21 22:22:45 +08:00
|
|
|
void CGangZonePool::ShowForAll(WORD wZone, DWORD dwColor)
|
|
|
|
{
|
|
|
|
RakNet::BitStream bsParams;
|
|
|
|
bsParams.Write(wZone);
|
|
|
|
bsParams.Write(m_fGangZone[wZone][0]);
|
|
|
|
bsParams.Write(m_fGangZone[wZone][1]);
|
|
|
|
bsParams.Write(m_fGangZone[wZone][2]);
|
|
|
|
bsParams.Write(m_fGangZone[wZone][3]);
|
|
|
|
dwColor = RGBA_ABGR(dwColor);
|
|
|
|
bsParams.Write(dwColor);
|
|
|
|
pNetGame->BroadcastData(RPC_ScrAddGangZone, &bsParams, INVALID_PLAYER_ID, 2);
|
|
|
|
}
|
|
|
|
|
2024-09-21 22:23:09 +08:00
|
|
|
void CGangZonePool::HideForPlayer(PLAYERID playerId, WORD wZone)
|
|
|
|
{
|
|
|
|
RakNet::BitStream bsParams;
|
|
|
|
bsParams.Write(wZone);
|
|
|
|
pNetGame->SendToPlayer(RPC_ScrRemoveGangZone, &bsParams, playerId, 2);
|
|
|
|
}
|
|
|
|
|
2024-09-21 22:23:33 +08:00
|
|
|
void CGangZonePool::HideForAll(WORD wZone)
|
|
|
|
{
|
|
|
|
RakNet::BitStream bsParams;
|
|
|
|
bsParams.Write(wZone);
|
|
|
|
pNetGame->BroadcastData(RPC_ScrRemoveGangZone, &bsParams, INVALID_PLAYER_ID, 2);
|
|
|
|
}
|
|
|
|
|
2024-09-21 22:23:53 +08:00
|
|
|
void CGangZonePool::FlashForPlayer(PLAYERID playerId, WORD wZone, DWORD dwColor)
|
|
|
|
{
|
|
|
|
RakNet::BitStream bsParams;
|
|
|
|
bsParams.Write(wZone);
|
|
|
|
dwColor = RGBA_ABGR(dwColor);
|
|
|
|
bsParams.Write(dwColor);
|
|
|
|
pNetGame->SendToPlayer(RPC_ScrFlashGangZone, &bsParams, playerId, 2);
|
|
|
|
}
|
|
|
|
|
2024-09-21 22:24:16 +08:00
|
|
|
void CGangZonePool::FlashForAll(WORD wZone, DWORD dwColor)
|
|
|
|
{
|
|
|
|
RakNet::BitStream bsParams;
|
|
|
|
bsParams.Write(wZone);
|
|
|
|
dwColor = RGBA_ABGR(dwColor);
|
|
|
|
bsParams.Write(dwColor);
|
|
|
|
pNetGame->BroadcastData(RPC_ScrFlashGangZone, &bsParams, INVALID_PLAYER_ID, 2);
|
|
|
|
}
|
|
|
|
|
2024-09-21 22:24:44 +08:00
|
|
|
void CGangZonePool::StopFlashForPlayer(PLAYERID playerId, WORD wZone)
|
|
|
|
{
|
|
|
|
RakNet::BitStream bsParams;
|
|
|
|
bsParams.Write(wZone);
|
|
|
|
pNetGame->SendToPlayer(RPC_ScrStopFlashGangZone, &bsParams, playerId, 2);
|
|
|
|
}
|
|
|
|
|