mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Basic slider implementation
This commit is contained in:
parent
6f05f0f2c8
commit
7dfc888552
@ -33,15 +33,30 @@ void NPCManager::init() {
|
|||||||
void NPCManager::addNPC(std::vector<Chunk*> viewableChunks, int32_t id) {
|
void NPCManager::addNPC(std::vector<Chunk*> viewableChunks, int32_t id) {
|
||||||
BaseNPC* npc = NPCs[id];
|
BaseNPC* npc = NPCs[id];
|
||||||
|
|
||||||
// create struct
|
switch (npc->npcClass) {
|
||||||
INITSTRUCT(sP_FE2CL_NPC_ENTER, enterData);
|
case NPC_BUS:
|
||||||
enterData.NPCAppearanceData = npc->appearanceData;
|
INITSTRUCT(sP_FE2CL_TRANSPORTATION_ENTER, enterBusData);
|
||||||
|
enterBusData.AppearanceData = { 3, npc->appearanceData.iNPC_ID, npc->appearanceData.iNPCType, npc->appearanceData.iX, npc->appearanceData.iY, npc->appearanceData.iZ };
|
||||||
|
|
||||||
for (Chunk* chunk : viewableChunks) {
|
for (Chunk* chunk : viewableChunks) {
|
||||||
for (CNSocket* sock : chunk->players) {
|
for (CNSocket* sock : chunk->players) {
|
||||||
// send to socket
|
// send to socket
|
||||||
sock->sendPacket((void*)&enterData, P_FE2CL_NPC_ENTER, sizeof(sP_FE2CL_NPC_ENTER));
|
sock->sendPacket((void*)&enterBusData, P_FE2CL_TRANSPORTATION_ENTER, sizeof(sP_FE2CL_TRANSPORTATION_ENTER));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// create struct
|
||||||
|
INITSTRUCT(sP_FE2CL_NPC_ENTER, enterData);
|
||||||
|
enterData.NPCAppearanceData = npc->appearanceData;
|
||||||
|
|
||||||
|
for (Chunk* chunk : viewableChunks) {
|
||||||
|
for (CNSocket* sock : chunk->players) {
|
||||||
|
// send to socket
|
||||||
|
sock->sendPacket((void*)&enterData, P_FE2CL_NPC_ENTER, sizeof(sP_FE2CL_NPC_ENTER));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,21 +81,38 @@ void NPCManager::removeNPC(int32_t id) {
|
|||||||
Chunk* chunk = ChunkManager::chunks[pos];
|
Chunk* chunk = ChunkManager::chunks[pos];
|
||||||
chunk->NPCs.erase(id);
|
chunk->NPCs.erase(id);
|
||||||
|
|
||||||
// create struct
|
switch (entity->npcClass) {
|
||||||
INITSTRUCT(sP_FE2CL_NPC_EXIT, exitData);
|
case NPC_BUS:
|
||||||
exitData.iNPC_ID = id;
|
INITSTRUCT(sP_FE2CL_TRANSPORTATION_EXIT, exitBusData);
|
||||||
|
exitBusData.eTT = 3;
|
||||||
|
exitBusData.iT_ID = id;
|
||||||
|
|
||||||
// remove it from the clients
|
for (Chunk* chunk : ChunkManager::grabChunks(pos)) {
|
||||||
for (Chunk* chunk : ChunkManager::grabChunks(pos)) {
|
for (CNSocket* sock : chunk->players) {
|
||||||
for (CNSocket* sock : chunk->players) {
|
// send to socket
|
||||||
// send to socket
|
sock->sendPacket((void*)&exitBusData, P_FE2CL_TRANSPORTATION_EXIT, sizeof(sP_FE2CL_TRANSPORTATION_EXIT));
|
||||||
sock->sendPacket((void*)&exitData, P_FE2CL_NPC_EXIT, sizeof(sP_FE2CL_NPC_EXIT));
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
case NPC_MOB:
|
||||||
|
// remove from mob list if it's a mob
|
||||||
|
if (MobManager::Mobs.find(id) != MobManager::Mobs.end())
|
||||||
|
MobManager::Mobs.erase(id);
|
||||||
|
// fall through
|
||||||
|
default:
|
||||||
|
// create struct
|
||||||
|
INITSTRUCT(sP_FE2CL_NPC_EXIT, exitData);
|
||||||
|
exitData.iNPC_ID = id;
|
||||||
|
|
||||||
// remove from mob list if it's a mob
|
// remove it from the clients
|
||||||
if (MobManager::Mobs.find(id) != MobManager::Mobs.end())
|
for (Chunk* chunk : ChunkManager::grabChunks(pos)) {
|
||||||
MobManager::Mobs.erase(id);
|
for (CNSocket* sock : chunk->players) {
|
||||||
|
// send to socket
|
||||||
|
sock->sendPacket((void*)&exitData, P_FE2CL_NPC_EXIT, sizeof(sP_FE2CL_NPC_EXIT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// finally, remove it from the map and free it
|
// finally, remove it from the map and free it
|
||||||
NPCs.erase(id);
|
NPCs.erase(id);
|
||||||
|
@ -26,6 +26,7 @@ void PlayerManager::init() {
|
|||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_LAUNCHER, PlayerManager::launchPlayer);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_LAUNCHER, PlayerManager::launchPlayer);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_ZIPLINE, PlayerManager::ziplinePlayer);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_ZIPLINE, PlayerManager::ziplinePlayer);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_MOVEPLATFORM, PlayerManager::movePlatformPlayer);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_MOVEPLATFORM, PlayerManager::movePlatformPlayer);
|
||||||
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_MOVETRANSPORTATION, PlayerManager::moveSliderPlayer);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_SLOPE, PlayerManager::moveSlopePlayer);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_SLOPE, PlayerManager::moveSlopePlayer);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GOTO, PlayerManager::gotoPlayer);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GOTO, PlayerManager::gotoPlayer);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_PC_SET_VALUE, PlayerManager::setSpecialPlayer);
|
REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_PC_SET_VALUE, PlayerManager::setSpecialPlayer);
|
||||||
@ -78,7 +79,6 @@ void PlayerManager::removePlayer(CNSocket* key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::removePlayerFromChunks(std::vector<Chunk*> chunks, CNSocket* sock) {
|
void PlayerManager::removePlayerFromChunks(std::vector<Chunk*> chunks, CNSocket* sock) {
|
||||||
INITSTRUCT(sP_FE2CL_NPC_EXIT, exitData);
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_EXIT, exitPlayer);
|
INITSTRUCT(sP_FE2CL_PC_EXIT, exitPlayer);
|
||||||
|
|
||||||
// for chunks that need the player to be removed from
|
// for chunks that need the player to be removed from
|
||||||
@ -86,8 +86,20 @@ void PlayerManager::removePlayerFromChunks(std::vector<Chunk*> chunks, CNSocket*
|
|||||||
|
|
||||||
// remove NPCs
|
// remove NPCs
|
||||||
for (int32_t id : chunk->NPCs) {
|
for (int32_t id : chunk->NPCs) {
|
||||||
exitData.iNPC_ID = id;
|
BaseNPC* npc = NPCManager::NPCs[id];
|
||||||
sock->sendPacket((void*)&exitData, P_FE2CL_NPC_EXIT, sizeof(sP_FE2CL_NPC_EXIT));
|
switch (npc->npcClass) {
|
||||||
|
case NPC_BUS:
|
||||||
|
INITSTRUCT(sP_FE2CL_TRANSPORTATION_EXIT, exitBusData);
|
||||||
|
exitBusData.eTT = 3;
|
||||||
|
exitBusData.iT_ID = id;
|
||||||
|
sock->sendPacket((void*)&exitBusData, P_FE2CL_TRANSPORTATION_EXIT, sizeof(sP_FE2CL_TRANSPORTATION_EXIT));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
INITSTRUCT(sP_FE2CL_NPC_EXIT, exitData);
|
||||||
|
exitData.iNPC_ID = id;
|
||||||
|
sock->sendPacket((void*)&exitData, P_FE2CL_NPC_EXIT, sizeof(sP_FE2CL_NPC_EXIT));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove players from eachother
|
// remove players from eachother
|
||||||
@ -104,14 +116,24 @@ void PlayerManager::removePlayerFromChunks(std::vector<Chunk*> chunks, CNSocket*
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::addPlayerToChunks(std::vector<Chunk*> chunks, CNSocket* sock) {
|
void PlayerManager::addPlayerToChunks(std::vector<Chunk*> chunks, CNSocket* sock) {
|
||||||
INITSTRUCT(sP_FE2CL_NPC_ENTER, enterData);
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_NEW, newPlayer);
|
INITSTRUCT(sP_FE2CL_PC_NEW, newPlayer);
|
||||||
|
|
||||||
for (Chunk* chunk : chunks) {
|
for (Chunk* chunk : chunks) {
|
||||||
// add npcs
|
// add npcs
|
||||||
for (int32_t id : chunk->NPCs) {
|
for (int32_t id : chunk->NPCs) {
|
||||||
enterData.NPCAppearanceData = NPCManager::NPCs[id]->appearanceData;
|
BaseNPC* npc = NPCManager::NPCs[id];
|
||||||
sock->sendPacket((void*)&enterData, P_FE2CL_NPC_ENTER, sizeof(sP_FE2CL_NPC_ENTER));
|
switch (npc->npcClass) {
|
||||||
|
case NPC_BUS:
|
||||||
|
INITSTRUCT(sP_FE2CL_TRANSPORTATION_ENTER, enterBusData);
|
||||||
|
enterBusData.AppearanceData = { 3, npc->appearanceData.iNPC_ID, npc->appearanceData.iNPCType, npc->appearanceData.iX, npc->appearanceData.iY, npc->appearanceData.iZ };
|
||||||
|
sock->sendPacket((void*)&enterBusData, P_FE2CL_TRANSPORTATION_ENTER, sizeof(sP_FE2CL_TRANSPORTATION_ENTER));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
INITSTRUCT(sP_FE2CL_NPC_ENTER, enterData);
|
||||||
|
enterData.NPCAppearanceData = NPCManager::NPCs[id]->appearanceData;
|
||||||
|
sock->sendPacket((void*)&enterData, P_FE2CL_NPC_ENTER, sizeof(sP_FE2CL_NPC_ENTER));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add players
|
// add players
|
||||||
@ -525,6 +547,37 @@ void PlayerManager::movePlatformPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
sendToViewable(sock, (void*)&platResponse, P_FE2CL_PC_MOVEPLATFORM, sizeof(sP_FE2CL_PC_MOVEPLATFORM));
|
sendToViewable(sock, (void*)&platResponse, P_FE2CL_PC_MOVEPLATFORM, sizeof(sP_FE2CL_PC_MOVEPLATFORM));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerManager::moveSliderPlayer(CNSocket* sock, CNPacketData* data) {
|
||||||
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_MOVETRANSPORTATION))
|
||||||
|
return; // ignore the malformed packet
|
||||||
|
|
||||||
|
sP_CL2FE_REQ_PC_MOVETRANSPORTATION* sliderData = (sP_CL2FE_REQ_PC_MOVETRANSPORTATION*)data->buf;
|
||||||
|
updatePlayerPosition(sock, sliderData->iX, sliderData->iY, sliderData->iZ, sliderData->iAngle);
|
||||||
|
|
||||||
|
uint64_t tm = getTime();
|
||||||
|
|
||||||
|
INITSTRUCT(sP_FE2CL_PC_MOVETRANSPORTATION, sliderResponse);
|
||||||
|
|
||||||
|
sliderResponse.iPC_ID = players[sock].plr->iID;
|
||||||
|
sliderResponse.iCliTime = sliderData->iCliTime;
|
||||||
|
sliderResponse.iSvrTime = tm;
|
||||||
|
sliderResponse.iX = sliderData->iX;
|
||||||
|
sliderResponse.iY = sliderData->iY;
|
||||||
|
sliderResponse.iZ = sliderData->iZ;
|
||||||
|
sliderResponse.iAngle = sliderData->iAngle;
|
||||||
|
sliderResponse.fVX = sliderData->fVX;
|
||||||
|
sliderResponse.fVY = sliderData->fVY;
|
||||||
|
sliderResponse.fVZ = sliderData->fVZ;
|
||||||
|
sliderResponse.iLcX = sliderData->iLcX;
|
||||||
|
sliderResponse.iLcY = sliderData->iLcY;
|
||||||
|
sliderResponse.iLcZ = sliderData->iLcZ;
|
||||||
|
sliderResponse.iSpeed = sliderData->iSpeed;
|
||||||
|
sliderResponse.cKeyValue = sliderData->cKeyValue;
|
||||||
|
sliderResponse.iT_ID = sliderData->iT_ID;
|
||||||
|
|
||||||
|
sendToViewable(sock, (void*)&sliderResponse, P_FE2CL_PC_MOVETRANSPORTATION, sizeof(sP_FE2CL_PC_MOVETRANSPORTATION));
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerManager::moveSlopePlayer(CNSocket* sock, CNPacketData* data) {
|
void PlayerManager::moveSlopePlayer(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_SLOPE))
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_SLOPE))
|
||||||
return; // ignore the malformed packet
|
return; // ignore the malformed packet
|
||||||
|
@ -44,6 +44,7 @@ namespace PlayerManager {
|
|||||||
void launchPlayer(CNSocket* sock, CNPacketData* data);
|
void launchPlayer(CNSocket* sock, CNPacketData* data);
|
||||||
void ziplinePlayer(CNSocket* sock, CNPacketData* data);
|
void ziplinePlayer(CNSocket* sock, CNPacketData* data);
|
||||||
void movePlatformPlayer(CNSocket* sock, CNPacketData* data);
|
void movePlatformPlayer(CNSocket* sock, CNPacketData* data);
|
||||||
|
void moveSliderPlayer(CNSocket* sock, CNPacketData* data);
|
||||||
void moveSlopePlayer(CNSocket* sock, CNPacketData* data);
|
void moveSlopePlayer(CNSocket* sock, CNPacketData* data);
|
||||||
void gotoPlayer(CNSocket* sock, CNPacketData* data);
|
void gotoPlayer(CNSocket* sock, CNPacketData* data);
|
||||||
void setSpecialPlayer(CNSocket* sock, CNPacketData* data);
|
void setSpecialPlayer(CNSocket* sock, CNPacketData* data);
|
||||||
|
@ -15,6 +15,10 @@ void TransportManager::init() {
|
|||||||
|
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION, transportRegisterLocationHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION, transportRegisterLocationHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_WARP_USE_TRANSPORTATION, transportWarpHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_WARP_USE_TRANSPORTATION, transportWarpHandler);
|
||||||
|
|
||||||
|
BaseNPC* bus = new BaseNPC(220447, 162431, -3650, 1, NPC_BUS);
|
||||||
|
NPCManager::NPCs[bus->appearanceData.iNPC_ID] = bus;
|
||||||
|
ChunkManager::addNPC(bus->appearanceData.iX, bus->appearanceData.iY, bus->appearanceData.iNPC_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportManager::transportRegisterLocationHandler(CNSocket* sock, CNPacketData* data) {
|
void TransportManager::transportRegisterLocationHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user