mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-01-12 03:30:04 +00:00
added basework for instancing
This commit is contained in:
@@ -47,7 +47,7 @@ void PlayerManager::addPlayer(CNSocket* key, Player plr) {
|
||||
memcpy(p, &plr, sizeof(Player));
|
||||
|
||||
players[key] = PlayerView();
|
||||
players[key].chunkPos = std::make_pair<int, int>(0, 0);
|
||||
players[key].chunkPos = std::make_tuple(0, 0, p->instanceID);
|
||||
players[key].currentChunks = std::vector<Chunk*>();
|
||||
players[key].plr = p;
|
||||
players[key].lastHeartbeat = 0;
|
||||
@@ -191,7 +191,7 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
|
||||
|
||||
void PlayerManager::updatePlayerChunk(CNSocket* sock, int X, int Y) {
|
||||
PlayerView& view = players[sock];
|
||||
std::pair<int, int> newPos = ChunkManager::grabChunk(X, Y);
|
||||
std::tuple<int, int, int> newPos = ChunkManager::grabChunk(X, Y, view.plr->instanceID);
|
||||
|
||||
// nothing to be done
|
||||
if (newPos == view.chunkPos)
|
||||
@@ -206,7 +206,7 @@ void PlayerManager::updatePlayerChunk(CNSocket* sock, int X, int Y) {
|
||||
// now, add all the new npcs & players!
|
||||
addPlayerToChunks(ChunkManager::getDeltaChunks(allChunks, view.currentChunks), sock);
|
||||
|
||||
ChunkManager::addPlayer(X, Y, sock); // takes care of adding the player to the chunk if it exists or not
|
||||
ChunkManager::addPlayer(X, Y, view.plr->instanceID, sock); // takes care of adding the player to the chunk if it exists or not
|
||||
view.chunkPos = newPos;
|
||||
view.currentChunks = allChunks;
|
||||
}
|
||||
@@ -309,6 +309,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
response.PCLoadData2CL.iFirstUseFlag2 = UINT64_MAX;
|
||||
|
||||
plr.SerialKey = enter->iEnterSerialKey;
|
||||
plr.instanceID = INSTANCE_OVERWORLD; // TODO: load this from the database (as long as it's not a unique instance)
|
||||
|
||||
motd.iType = 1;
|
||||
U8toU16(settings::MOTDSTRING, (char16_t*)motd.szSystemMsg);
|
||||
@@ -647,7 +648,7 @@ void PlayerManager::gotoPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
// force player & NPC reload
|
||||
PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock);
|
||||
plrv.currentChunks.clear();
|
||||
plrv.chunkPos = std::make_pair<int, int>(0, 0);
|
||||
plrv.chunkPos = std::make_tuple(0, 0, plrv.plr->instanceID);
|
||||
|
||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user