mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Get rid of PlayerView. For good.
This commit is contained in:
parent
d2e776b672
commit
5cbb8538c0
@ -136,7 +136,7 @@ void BuddyManager::reqBuddyByName(CNSocket* sock, CNPacketData* data) {
|
||||
CNSocket* otherSock = nullptr;
|
||||
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
Player* plr = pair.second.plr;
|
||||
Player* plr = pair.second;
|
||||
if (strcmp(U16toU8(plr->PCStyle.szFirstName).c_str(), U16toU8(pkt->szFirstName).c_str()) == 0
|
||||
&& strcmp(U16toU8(plr->PCStyle.szLastName).c_str(), U16toU8(pkt->szLastName).c_str()) == 0
|
||||
&& !playerHasBuddyWithID(plrReq, plr->iID)) {
|
||||
|
@ -32,15 +32,15 @@ void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
std::cerr << "OpenFusion: SHARD UNIMPLM ERR. PacketType: " << Defines::p2str(CL2FE, data->type) << " (" << data->type << ")" << std::endl;
|
||||
|
||||
if (PlayerManager::players.find(sock) != PlayerManager::players.end())
|
||||
PlayerManager::players[sock].lastHeartbeat = getTime();
|
||||
PlayerManager::players[sock]->lastHeartbeat = getTime();
|
||||
}
|
||||
|
||||
void CNShardServer::keepAliveTimer(CNServer* serv, time_t currTime) {
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
if (pair.second.lastHeartbeat != 0 && currTime - pair.second.lastHeartbeat > settings::TIMEOUT) {
|
||||
if (pair.second->lastHeartbeat != 0 && currTime - pair.second->lastHeartbeat > settings::TIMEOUT) {
|
||||
// if the client hasn't responded in 60 seconds, its a dead connection so throw it out
|
||||
pair.first->kill();
|
||||
} else if (pair.second.lastHeartbeat != 0 && currTime - pair.second.lastHeartbeat > settings::TIMEOUT/2) {
|
||||
} else if (pair.second->lastHeartbeat != 0 && currTime - pair.second->lastHeartbeat > settings::TIMEOUT/2) {
|
||||
// if the player hasn't responded in 30 seconds, send a live check
|
||||
INITSTRUCT(sP_FE2CL_REQ_LIVE_CHECK, data);
|
||||
pair.first->sendPacket((void*)&data, P_FE2CL_REQ_LIVE_CHECK, sizeof(sP_FE2CL_REQ_LIVE_CHECK));
|
||||
@ -55,7 +55,7 @@ void CNShardServer::periodicSaveTimer(CNServer* serv, time_t currTime) {
|
||||
std::cout << "[INFO] Saving " << PlayerManager::players.size() << " players to DB..." << std::endl;
|
||||
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
Database::updatePlayer(pair.second.plr);
|
||||
Database::updatePlayer(pair.second);
|
||||
}
|
||||
|
||||
TableData::flush();
|
||||
|
@ -260,10 +260,9 @@ void summonWCommand(std::string full, std::vector<std::string>& args, CNSocket*
|
||||
}
|
||||
|
||||
void unsummonWCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||
PlayerView& plrv = PlayerManager::players[sock];
|
||||
Player* plr = plrv.plr;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
BaseNPC* npc = NPCManager::getNearestNPC(plrv.currentChunks, plr->x, plr->y, plr->z);
|
||||
BaseNPC* npc = NPCManager::getNearestNPC(*plr->currentChunks, plr->x, plr->y, plr->z);
|
||||
|
||||
if (npc == nullptr) {
|
||||
ChatManager::sendServerMessage(sock, "/unsummonW: No NPCs found nearby");
|
||||
@ -317,10 +316,9 @@ void toggleAiCommand(std::string full, std::vector<std::string>& args, CNSocket*
|
||||
}
|
||||
|
||||
void npcRotateCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||
PlayerView& plrv = PlayerManager::players[sock];
|
||||
Player* plr = plrv.plr;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
BaseNPC* npc = NPCManager::getNearestNPC(plrv.currentChunks, plr->x, plr->y, plr->z);
|
||||
BaseNPC* npc = NPCManager::getNearestNPC(*plr->currentChunks, plr->x, plr->y, plr->z);
|
||||
|
||||
if (npc == nullptr) {
|
||||
ChatManager::sendServerMessage(sock, "[NPCR] No NPCs found nearby");
|
||||
@ -379,8 +377,7 @@ void instanceCommand(std::string full, std::vector<std::string>& args, CNSocket*
|
||||
}
|
||||
|
||||
void npcInstanceCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||
PlayerView& plrv = PlayerManager::players[sock];
|
||||
Player* plr = plrv.plr;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (args.size() < 2) {
|
||||
ChatManager::sendServerMessage(sock, "[NPCI] Instance ID must be specified");
|
||||
@ -388,7 +385,7 @@ void npcInstanceCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
return;
|
||||
}
|
||||
|
||||
BaseNPC* npc = NPCManager::getNearestNPC(plrv.currentChunks, plr->x, plr->y, plr->z);
|
||||
BaseNPC* npc = NPCManager::getNearestNPC(*plr->currentChunks, plr->x, plr->y, plr->z);
|
||||
|
||||
if (npc == nullptr) {
|
||||
ChatManager::sendServerMessage(sock, "[NPCI] No NPCs found nearby");
|
||||
@ -516,7 +513,7 @@ void notifyCommand(std::string full, std::vector<std::string>& args, CNSocket* s
|
||||
void playersCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||
ChatManager::sendServerMessage(sock, "[ADMIN] Players on the server:");
|
||||
for (auto pair : PlayerManager::players)
|
||||
ChatManager::sendServerMessage(sock, PlayerManager::getPlayerName(pair.second.plr));
|
||||
ChatManager::sendServerMessage(sock, PlayerManager::getPlayerName(pair.second));
|
||||
}
|
||||
|
||||
void flushCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||
@ -599,7 +596,7 @@ void ChatManager::menuChatHandler(CNSocket* sock, CNPacketData* data) {
|
||||
INITSTRUCT(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, resp);
|
||||
|
||||
U8toU16(fullChat, (char16_t*)&resp.szFreeChat, sizeof(resp.szFreeChat));
|
||||
resp.iPC_ID = PlayerManager::players[sock].plr->iID;
|
||||
resp.iPC_ID = PlayerManager::getPlayer(sock)->iID;
|
||||
resp.iEmoteCode = chat->iEmoteCode;
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_MENUCHAT_MESSAGE_SUCC));
|
||||
@ -641,7 +638,9 @@ void ChatManager::sendServerMessage(CNSocket* sock, std::string msg) {
|
||||
void ChatManager::announcementHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_GM_REQ_PC_ANNOUNCE))
|
||||
return; // ignore malformed packet
|
||||
if (PlayerManager::getPlayer(sock)->accountLevel > 30)
|
||||
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
if (plr->accountLevel > 30)
|
||||
return; // only players with account level less than 30 (GM) are allowed to use this command
|
||||
sP_CL2FE_GM_REQ_PC_ANNOUNCE* announcement = (sP_CL2FE_GM_REQ_PC_ANNOUNCE*)data->buf;
|
||||
|
||||
@ -649,18 +648,17 @@ void ChatManager::announcementHandler(CNSocket* sock, CNPacketData* data) {
|
||||
msg.iAnnounceType = announcement->iAnnounceType;
|
||||
msg.iDuringTime = announcement->iDuringTime;
|
||||
memcpy(msg.szAnnounceMsg, announcement->szAnnounceMsg, sizeof(msg.szAnnounceMsg));
|
||||
std::map<CNSocket*, PlayerView>::iterator it;
|
||||
std::map<CNSocket*, Player*>::iterator it;
|
||||
|
||||
switch (announcement->iAreaType) {
|
||||
case 0: // area
|
||||
break; // stubbed for now
|
||||
case 0: // area (all players in viewable chunks)
|
||||
PlayerManager::sendToViewable(sock, (void*)&msg, P_FE2CL_GM_REP_PC_ANNOUNCE, sizeof(sP_FE2CL_GM_REP_PC_ANNOUNCE));
|
||||
break;
|
||||
case 1: // shard
|
||||
break; //stubbed for now
|
||||
case 2: // world
|
||||
break; // stubbed for now
|
||||
case 3: // global
|
||||
|
||||
// send announced messqage to ALL players
|
||||
case 3: // global (all players)
|
||||
for (it = PlayerManager::players.begin(); it != PlayerManager::players.end(); it++) {
|
||||
CNSocket* allSock = it->first;
|
||||
allSock->sendPacket((void*)&msg, P_FE2CL_GM_REP_PC_ANNOUNCE, sizeof(sP_FE2CL_GM_REP_PC_ANNOUNCE));
|
||||
|
@ -23,7 +23,7 @@ void ChunkManager::populateNewChunk(Chunk* chunk, ChunkPos pos) {// add the new
|
||||
continue;
|
||||
|
||||
for (CNSocket *s : c->players)
|
||||
PlayerManager::players[s].currentChunks.push_back(chunk);
|
||||
PlayerManager::getPlayer(s)->currentChunks->push_back(chunk);
|
||||
|
||||
for (int32_t id : c->NPCs)
|
||||
NPCManager::NPCs[id]->currentChunks.push_back(chunk);
|
||||
@ -67,7 +67,7 @@ void ChunkManager::addPlayer(int posX, int posY, uint64_t instanceID, CNSocket*
|
||||
Chunk* chunk = chunks[pos];
|
||||
|
||||
if (newChunkUsed)
|
||||
PlayerManager::players[sock].currentChunks.push_back(chunk);
|
||||
PlayerManager::getPlayer(sock)->currentChunks->push_back(chunk);
|
||||
|
||||
chunk->players.insert(sock);
|
||||
|
||||
@ -142,9 +142,9 @@ void ChunkManager::destroyChunk(ChunkPos chunkPos) {
|
||||
|
||||
// remove from players
|
||||
for (CNSocket* sock : otherChunk->players) {
|
||||
PlayerView* plyr = &PlayerManager::players[sock];
|
||||
if (std::find(plyr->currentChunks.begin(), plyr->currentChunks.end(), chunk) != plyr->currentChunks.end()) {
|
||||
plyr->currentChunks.erase(std::remove(plyr->currentChunks.begin(), plyr->currentChunks.end(), chunk), plyr->currentChunks.end());
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
if (std::find(plr->currentChunks->begin(), plr->currentChunks->end(), chunk) != plr->currentChunks->end()) {
|
||||
plr->currentChunks->erase(std::remove(plr->currentChunks->begin(), plr->currentChunks->end(), chunk), plr->currentChunks->end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,17 +44,17 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
sP_CL2FE_REQ_ITEM_MOVE* itemmove = (sP_CL2FE_REQ_ITEM_MOVE*)data->buf;
|
||||
INITSTRUCT(sP_FE2CL_PC_ITEM_MOVE_SUCC, resp);
|
||||
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
// sanity check
|
||||
if (plr.plr->Equip[itemmove->iFromSlotNum].iType != 0 && itemmove->eFrom == 0 && itemmove->eTo == 0) {
|
||||
if (plr->Equip[itemmove->iFromSlotNum].iType != 0 && itemmove->eFrom == 0 && itemmove->eTo == 0) {
|
||||
// this packet should never happen unless it is a weapon, tell the client to do nothing and do nothing ourself
|
||||
resp.eTo = itemmove->eFrom;
|
||||
resp.iToSlotNum = itemmove->iFromSlotNum;
|
||||
resp.ToSlotItem = plr.plr->Equip[itemmove->iToSlotNum];
|
||||
resp.ToSlotItem = plr->Equip[itemmove->iToSlotNum];
|
||||
resp.eFrom = itemmove->eTo;
|
||||
resp.iFromSlotNum = itemmove->iToSlotNum;
|
||||
resp.FromSlotItem = plr.plr->Equip[itemmove->iFromSlotNum];
|
||||
resp.FromSlotItem = plr->Equip[itemmove->iFromSlotNum];
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_PC_ITEM_MOVE_SUCC, sizeof(sP_FE2CL_PC_ITEM_MOVE_SUCC));
|
||||
return;
|
||||
@ -68,13 +68,13 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
sItemBase *fromItem;
|
||||
switch ((SlotType)itemmove->eFrom) {
|
||||
case SlotType::EQUIP:
|
||||
fromItem = &plr.plr->Equip[itemmove->iFromSlotNum];
|
||||
fromItem = &plr->Equip[itemmove->iFromSlotNum];
|
||||
break;
|
||||
case SlotType::INVENTORY:
|
||||
fromItem = &plr.plr->Inven[itemmove->iFromSlotNum];
|
||||
fromItem = &plr->Inven[itemmove->iFromSlotNum];
|
||||
break;
|
||||
case SlotType::BANK:
|
||||
fromItem = &plr.plr->Bank[itemmove->iFromSlotNum];
|
||||
fromItem = &plr->Bank[itemmove->iFromSlotNum];
|
||||
break;
|
||||
default:
|
||||
std::cout << "[WARN] MoveItem submitted unknown Item Type?! " << itemmove->eFrom << std::endl;
|
||||
@ -85,13 +85,13 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
sItemBase* toItem;
|
||||
switch ((SlotType)itemmove->eTo) {
|
||||
case SlotType::EQUIP:
|
||||
toItem = &plr.plr->Equip[itemmove->iToSlotNum];
|
||||
toItem = &plr->Equip[itemmove->iToSlotNum];
|
||||
break;
|
||||
case SlotType::INVENTORY:
|
||||
toItem = &plr.plr->Inven[itemmove->iToSlotNum];
|
||||
toItem = &plr->Inven[itemmove->iToSlotNum];
|
||||
break;
|
||||
case SlotType::BANK:
|
||||
toItem = &plr.plr->Bank[itemmove->iToSlotNum];
|
||||
toItem = &plr->Bank[itemmove->iToSlotNum];
|
||||
break;
|
||||
default:
|
||||
std::cout << "[WARN] MoveItem submitted unknown Item Type?! " << itemmove->eTo << std::endl;
|
||||
@ -139,7 +139,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (itemmove->eFrom == (int)SlotType::EQUIP || itemmove->eTo == (int)SlotType::EQUIP) {
|
||||
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, equipChange);
|
||||
|
||||
equipChange.iPC_ID = plr.plr->iID;
|
||||
equipChange.iPC_ID = plr->iID;
|
||||
if (itemmove->eTo == (int)SlotType::EQUIP) {
|
||||
equipChange.iEquipSlotNum = itemmove->iToSlotNum;
|
||||
equipChange.EquipSlotItem = resp.FromSlotItem;
|
||||
@ -149,14 +149,14 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
}
|
||||
|
||||
// unequip vehicle if equip slot 8 is 0
|
||||
if (plr.plr->Equip[8].iID == 0)
|
||||
plr.plr->iPCState = 0;
|
||||
if (plr->Equip[8].iID == 0)
|
||||
plr->iPCState = 0;
|
||||
|
||||
// send equip event to other players
|
||||
PlayerManager::sendToViewable(sock, (void*)&equipChange, P_FE2CL_PC_EQUIP_CHANGE, sizeof(sP_FE2CL_PC_EQUIP_CHANGE));
|
||||
|
||||
// set equipment stats serverside
|
||||
setItemStats(plr.plr);
|
||||
setItemStats(plr);
|
||||
}
|
||||
|
||||
// send response
|
||||
@ -174,15 +174,15 @@ void ItemManager::itemDeleteHandler(CNSocket* sock, CNPacketData* data) {
|
||||
sP_CL2FE_REQ_PC_ITEM_DELETE* itemdel = (sP_CL2FE_REQ_PC_ITEM_DELETE*)data->buf;
|
||||
INITSTRUCT(sP_FE2CL_REP_PC_ITEM_DELETE_SUCC, resp);
|
||||
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
resp.eIL = itemdel->eIL;
|
||||
resp.iSlotNum = itemdel->iSlotNum;
|
||||
|
||||
// so, im not sure what this eIL thing does since you always delete items in inventory and not equips
|
||||
plr.plr->Inven[itemdel->iSlotNum].iID = 0;
|
||||
plr.plr->Inven[itemdel->iSlotNum].iType = 0;
|
||||
plr.plr->Inven[itemdel->iSlotNum].iOpt = 0;
|
||||
plr->Inven[itemdel->iSlotNum].iID = 0;
|
||||
plr->Inven[itemdel->iSlotNum].iType = 0;
|
||||
plr->Inven[itemdel->iSlotNum].iOpt = 0;
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_ITEM_DELETE_SUCC, sizeof(sP_FE2CL_REP_PC_ITEM_DELETE_SUCC));
|
||||
}
|
||||
@ -192,9 +192,9 @@ void ItemManager::itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
return; // ignore the malformed packet
|
||||
|
||||
sP_CL2FE_REQ_PC_GIVE_ITEM* itemreq = (sP_CL2FE_REQ_PC_GIVE_ITEM*)data->buf;
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (plr.plr->accountLevel > 50) {
|
||||
if (plr->accountLevel > 50) {
|
||||
// TODO: send fail packet
|
||||
return;
|
||||
}
|
||||
@ -221,7 +221,7 @@ void ItemManager::itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
}
|
||||
resp.Item = itemreq->Item;
|
||||
|
||||
plr.plr->Inven[itemreq->iSlotNum] = itemreq->Item;
|
||||
plr->Inven[itemreq->iSlotNum] = itemreq->Item;
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_GIVE_ITEM_SUCC, sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC));
|
||||
}
|
||||
@ -288,10 +288,12 @@ void ItemManager::itemBankOpenHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_BANK_OPEN))
|
||||
return; // ignore the malformed packet
|
||||
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
// just send bank inventory
|
||||
INITSTRUCT(sP_FE2CL_REP_PC_BANK_OPEN_SUCC, resp);
|
||||
for (int i = 0; i < ABANK_COUNT; i++) {
|
||||
resp.aBank[i] = PlayerManager::players[sock].plr->Bank[i];
|
||||
resp.aBank[i] = plr->Bank[i];
|
||||
}
|
||||
resp.iExtraBank = 1;
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_BANK_OPEN_SUCC, sizeof(sP_FE2CL_REP_PC_BANK_OPEN_SUCC));
|
||||
@ -314,15 +316,15 @@ void ItemManager::itemTradeOfferHandler(CNSocket* sock, CNPacketData* data) {
|
||||
CNSocket* otherSock = sock;
|
||||
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == iID_Check) {
|
||||
if (pair.second->iID == iID_Check) {
|
||||
otherSock = pair.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerView& plr = PlayerManager::players[otherSock];
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (plr.plr->isTrading) {
|
||||
if (plr->isTrading) {
|
||||
INITSTRUCT(sP_FE2CL_REP_PC_TRADE_OFFER_REFUSAL, resp);
|
||||
|
||||
resp.iID_Request = pacdat->iID_To;
|
||||
@ -360,7 +362,7 @@ void ItemManager::itemTradeOfferAcceptHandler(CNSocket* sock, CNPacketData* data
|
||||
CNSocket* otherSock = sock;
|
||||
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == iID_Check) {
|
||||
if (pair.second->iID == iID_Check) {
|
||||
otherSock = pair.first;
|
||||
break;
|
||||
}
|
||||
@ -374,10 +376,10 @@ void ItemManager::itemTradeOfferAcceptHandler(CNSocket* sock, CNPacketData* data
|
||||
|
||||
// Clearing up trade slots
|
||||
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
PlayerView& plr2 = PlayerManager::players[otherSock];
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
Player* plr2 = PlayerManager::getPlayer(otherSock);
|
||||
|
||||
if (plr2.plr->isTrading) {
|
||||
if (plr2->isTrading) {
|
||||
INITSTRUCT(sP_FE2CL_REP_PC_TRADE_OFFER_REFUSAL, resp);
|
||||
|
||||
resp.iID_Request = pacdat->iID_To;
|
||||
@ -389,13 +391,13 @@ void ItemManager::itemTradeOfferAcceptHandler(CNSocket* sock, CNPacketData* data
|
||||
return; // prevent trading with a player already trading
|
||||
}
|
||||
|
||||
plr.plr->isTrading = true;
|
||||
plr2.plr->isTrading = true;
|
||||
plr.plr->isTradeConfirm = false;
|
||||
plr2.plr->isTradeConfirm = false;
|
||||
plr->isTrading = true;
|
||||
plr2->isTrading = true;
|
||||
plr->isTradeConfirm = false;
|
||||
plr2->isTradeConfirm = false;
|
||||
|
||||
memset(&plr.plr->Trade, 0, sizeof(plr.plr->Trade));
|
||||
memset(&plr2.plr->Trade, 0, sizeof(plr2.plr->Trade));
|
||||
memset(&plr->Trade, 0, sizeof(plr->Trade));
|
||||
memset(&plr2->Trade, 0, sizeof(plr2->Trade));
|
||||
|
||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_OFFER_SUCC, sizeof(sP_FE2CL_REP_PC_TRADE_OFFER_SUCC));
|
||||
}
|
||||
@ -422,7 +424,7 @@ void ItemManager::itemTradeOfferRefusalHandler(CNSocket* sock, CNPacketData* dat
|
||||
CNSocket* otherSock = sock;
|
||||
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == iID_Check) {
|
||||
if (pair.second->iID == iID_Check) {
|
||||
otherSock = pair.first;
|
||||
break;
|
||||
}
|
||||
@ -448,21 +450,21 @@ void ItemManager::itemTradeConfirmHandler(CNSocket* sock, CNPacketData* data) {
|
||||
CNSocket* otherSock = sock;
|
||||
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == iID_Check) {
|
||||
if (pair.second->iID == iID_Check) {
|
||||
otherSock = pair.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
PlayerView& plr2 = PlayerManager::players[otherSock];
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
Player* plr2 = PlayerManager::getPlayer(otherSock);
|
||||
|
||||
if (plr2.plr->isTradeConfirm) {
|
||||
if (plr2->isTradeConfirm) {
|
||||
|
||||
plr.plr->isTrading = false;
|
||||
plr2.plr->isTrading = false;
|
||||
plr.plr->isTradeConfirm = false;
|
||||
plr2.plr->isTradeConfirm = false;
|
||||
plr->isTrading = false;
|
||||
plr2->isTrading = false;
|
||||
plr->isTradeConfirm = false;
|
||||
plr2->isTradeConfirm = false;
|
||||
|
||||
// Check if we have enough free slots
|
||||
int freeSlots = 0;
|
||||
@ -471,22 +473,22 @@ void ItemManager::itemTradeConfirmHandler(CNSocket* sock, CNPacketData* data) {
|
||||
int freeSlotsNeeded2 = 0;
|
||||
|
||||
for (int i = 0; i < AINVEN_COUNT; i++) {
|
||||
if (plr.plr->Inven[i].iID == 0)
|
||||
if (plr->Inven[i].iID == 0)
|
||||
freeSlots++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (plr.plr->Trade[i].iID != 0)
|
||||
if (plr->Trade[i].iID != 0)
|
||||
freeSlotsNeeded++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < AINVEN_COUNT; i++) {
|
||||
if (plr2.plr->Inven[i].iID == 0)
|
||||
if (plr2->Inven[i].iID == 0)
|
||||
freeSlots2++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (plr2.plr->Trade[i].iID != 0)
|
||||
if (plr2->Trade[i].iID != 0)
|
||||
freeSlotsNeeded2++;
|
||||
}
|
||||
|
||||
@ -524,27 +526,27 @@ void ItemManager::itemTradeConfirmHandler(CNSocket* sock, CNPacketData* data) {
|
||||
// ^^ this is a must have or else the player won't accept a succ packet for some reason
|
||||
|
||||
for (int i = 0; i < freeSlotsNeeded; i++) {
|
||||
plr.plr->Inven[plr.plr->Trade[i].iInvenNum].iID = 0;
|
||||
plr.plr->Inven[plr.plr->Trade[i].iInvenNum].iType = 0;
|
||||
plr.plr->Inven[plr.plr->Trade[i].iInvenNum].iOpt = 0;
|
||||
plr->Inven[plr->Trade[i].iInvenNum].iID = 0;
|
||||
plr->Inven[plr->Trade[i].iInvenNum].iType = 0;
|
||||
plr->Inven[plr->Trade[i].iInvenNum].iOpt = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < freeSlotsNeeded2; i++) {
|
||||
plr2.plr->Inven[plr2.plr->Trade[i].iInvenNum].iID = 0;
|
||||
plr2.plr->Inven[plr2.plr->Trade[i].iInvenNum].iType = 0;
|
||||
plr2.plr->Inven[plr2.plr->Trade[i].iInvenNum].iOpt = 0;
|
||||
plr2->Inven[plr2->Trade[i].iInvenNum].iID = 0;
|
||||
plr2->Inven[plr2->Trade[i].iInvenNum].iType = 0;
|
||||
plr2->Inven[plr2->Trade[i].iInvenNum].iOpt = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < AINVEN_COUNT; i++) {
|
||||
if (freeSlotsNeeded <= 0)
|
||||
break;
|
||||
|
||||
if (plr2.plr->Inven[i].iID == 0) {
|
||||
if (plr2->Inven[i].iID == 0) {
|
||||
|
||||
plr2.plr->Inven[i].iID = plr.plr->Trade[freeSlotsNeeded - 1].iID;
|
||||
plr2.plr->Inven[i].iType = plr.plr->Trade[freeSlotsNeeded - 1].iType;
|
||||
plr2.plr->Inven[i].iOpt = plr.plr->Trade[freeSlotsNeeded - 1].iOpt;
|
||||
plr.plr->Trade[freeSlotsNeeded - 1].iInvenNum = i;
|
||||
plr2->Inven[i].iID = plr->Trade[freeSlotsNeeded - 1].iID;
|
||||
plr2->Inven[i].iType = plr->Trade[freeSlotsNeeded - 1].iType;
|
||||
plr2->Inven[i].iOpt = plr->Trade[freeSlotsNeeded - 1].iOpt;
|
||||
plr->Trade[freeSlotsNeeded - 1].iInvenNum = i;
|
||||
freeSlotsNeeded--;
|
||||
}
|
||||
}
|
||||
@ -553,12 +555,12 @@ void ItemManager::itemTradeConfirmHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (freeSlotsNeeded2 <= 0)
|
||||
break;
|
||||
|
||||
if (plr.plr->Inven[i].iID == 0) {
|
||||
if (plr->Inven[i].iID == 0) {
|
||||
|
||||
plr.plr->Inven[i].iID = plr2.plr->Trade[freeSlotsNeeded2 - 1].iID;
|
||||
plr.plr->Inven[i].iType = plr2.plr->Trade[freeSlotsNeeded2 - 1].iType;
|
||||
plr.plr->Inven[i].iOpt = plr2.plr->Trade[freeSlotsNeeded2 - 1].iOpt;
|
||||
plr2.plr->Trade[freeSlotsNeeded2 - 1].iInvenNum = i;
|
||||
plr->Inven[i].iID = plr2->Trade[freeSlotsNeeded2 - 1].iID;
|
||||
plr->Inven[i].iType = plr2->Trade[freeSlotsNeeded2 - 1].iType;
|
||||
plr->Inven[i].iOpt = plr2->Trade[freeSlotsNeeded2 - 1].iOpt;
|
||||
plr2->Trade[freeSlotsNeeded2 - 1].iInvenNum = i;
|
||||
freeSlotsNeeded2--;
|
||||
}
|
||||
}
|
||||
@ -569,19 +571,19 @@ void ItemManager::itemTradeConfirmHandler(CNSocket* sock, CNPacketData* data) {
|
||||
resp2.iID_From = pacdat->iID_From;
|
||||
resp2.iID_To = pacdat->iID_To;
|
||||
|
||||
plr.plr->money = plr.plr->money + plr2.plr->moneyInTrade - plr.plr->moneyInTrade;
|
||||
resp2.iCandy = plr.plr->money;
|
||||
plr->money = plr->money + plr2->moneyInTrade - plr->moneyInTrade;
|
||||
resp2.iCandy = plr->money;
|
||||
|
||||
memcpy(resp2.Item, plr2.plr->Trade, sizeof(plr2.plr->Trade));
|
||||
memcpy(resp2.ItemStay, plr.plr->Trade, sizeof(plr.plr->Trade));
|
||||
memcpy(resp2.Item, plr2->Trade, sizeof(plr2->Trade));
|
||||
memcpy(resp2.ItemStay, plr->Trade, sizeof(plr->Trade));
|
||||
|
||||
sock->sendPacket((void*)&resp2, P_FE2CL_REP_PC_TRADE_CONFIRM_SUCC, sizeof(sP_FE2CL_REP_PC_TRADE_CONFIRM_SUCC));
|
||||
|
||||
plr2.plr->money = plr2.plr->money + plr.plr->moneyInTrade - plr2.plr->moneyInTrade;
|
||||
resp2.iCandy = plr2.plr->money;
|
||||
plr2->money = plr2->money + plr->moneyInTrade - plr2->moneyInTrade;
|
||||
resp2.iCandy = plr2->money;
|
||||
|
||||
memcpy(resp2.Item, plr.plr->Trade, sizeof(plr.plr->Trade));
|
||||
memcpy(resp2.ItemStay, plr2.plr->Trade, sizeof(plr2.plr->Trade));
|
||||
memcpy(resp2.Item, plr->Trade, sizeof(plr->Trade));
|
||||
memcpy(resp2.ItemStay, plr2->Trade, sizeof(plr2->Trade));
|
||||
|
||||
otherSock->sendPacket((void*)&resp2, P_FE2CL_REP_PC_TRADE_CONFIRM_SUCC, sizeof(sP_FE2CL_REP_PC_TRADE_CONFIRM_SUCC));
|
||||
} else {
|
||||
@ -592,7 +594,7 @@ void ItemManager::itemTradeConfirmHandler(CNSocket* sock, CNPacketData* data) {
|
||||
resp.iID_From = pacdat->iID_From;
|
||||
resp.iID_To = pacdat->iID_To;
|
||||
|
||||
plr.plr->isTradeConfirm = true;
|
||||
plr->isTradeConfirm = true;
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_CONFIRM, sizeof(sP_FE2CL_REP_PC_TRADE_CONFIRM));
|
||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_CONFIRM, sizeof(sP_FE2CL_REP_PC_TRADE_CONFIRM));
|
||||
@ -621,18 +623,18 @@ void ItemManager::itemTradeConfirmCancelHandler(CNSocket* sock, CNPacketData* da
|
||||
CNSocket* otherSock = sock;
|
||||
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == iID_Check) {
|
||||
if (pair.second->iID == iID_Check) {
|
||||
otherSock = pair.first;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
PlayerView& plr2 = PlayerManager::players[otherSock];
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
Player* plr2 = PlayerManager::getPlayer(otherSock);
|
||||
|
||||
plr.plr->isTrading = false;
|
||||
plr.plr->isTradeConfirm = false;
|
||||
plr2.plr->isTrading = false;
|
||||
plr2.plr->isTradeConfirm = false;
|
||||
plr->isTrading = false;
|
||||
plr->isTradeConfirm = false;
|
||||
plr2->isTrading = false;
|
||||
plr2->isTradeConfirm = false;
|
||||
|
||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_CONFIRM_CANCEL, sizeof(sP_FE2CL_REP_PC_TRADE_CONFIRM_CANCEL));
|
||||
}
|
||||
@ -665,14 +667,14 @@ void ItemManager::itemTradeRegisterItemHandler(CNSocket* sock, CNPacketData* dat
|
||||
CNSocket* otherSock = sock;
|
||||
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == iID_Check) {
|
||||
if (pair.second->iID == iID_Check) {
|
||||
otherSock = pair.first;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
plr.plr->Trade[pacdat->Item.iSlotNum] = pacdat->Item;
|
||||
plr.plr->isTradeConfirm = false;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
plr->Trade[pacdat->Item.iSlotNum] = pacdat->Item;
|
||||
plr->isTradeConfirm = false;
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_ITEM_REGISTER_SUCC, sizeof(sP_FE2CL_REP_PC_TRADE_ITEM_REGISTER_SUCC));
|
||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_ITEM_REGISTER_SUCC, sizeof(sP_FE2CL_REP_PC_TRADE_ITEM_REGISTER_SUCC));
|
||||
@ -690,9 +692,9 @@ void ItemManager::itemTradeUnregisterItemHandler(CNSocket* sock, CNPacketData* d
|
||||
resp.iID_To = pacdat->iID_To;
|
||||
resp.TradeItem = pacdat->Item;
|
||||
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
resp.InvenItem = plr.plr->Trade[pacdat->Item.iSlotNum];
|
||||
plr.plr->isTradeConfirm = false;
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
resp.InvenItem = plr->Trade[pacdat->Item.iSlotNum];
|
||||
plr->isTradeConfirm = false;
|
||||
|
||||
int iID_Check;
|
||||
|
||||
@ -705,7 +707,7 @@ void ItemManager::itemTradeUnregisterItemHandler(CNSocket* sock, CNPacketData* d
|
||||
CNSocket* otherSock = sock;
|
||||
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == iID_Check) {
|
||||
if (pair.second->iID == iID_Check) {
|
||||
otherSock = pair.first;
|
||||
}
|
||||
}
|
||||
@ -713,11 +715,11 @@ void ItemManager::itemTradeUnregisterItemHandler(CNSocket* sock, CNPacketData* d
|
||||
int temp_num = pacdat->Item.iSlotNum;
|
||||
|
||||
if (temp_num >= 0 && temp_num <= 4) {
|
||||
plr.plr->Trade[temp_num].iID = 0;
|
||||
plr.plr->Trade[temp_num].iType = 0;
|
||||
plr.plr->Trade[temp_num].iOpt = 0;
|
||||
plr.plr->Trade[temp_num].iInvenNum = 0;
|
||||
plr.plr->Trade[temp_num].iSlotNum = 0;
|
||||
plr->Trade[temp_num].iID = 0;
|
||||
plr->Trade[temp_num].iType = 0;
|
||||
plr->Trade[temp_num].iOpt = 0;
|
||||
plr->Trade[temp_num].iInvenNum = 0;
|
||||
plr->Trade[temp_num].iSlotNum = 0;
|
||||
}
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_ITEM_UNREGISTER_SUCC, sizeof(sP_FE2CL_REP_PC_TRADE_ITEM_UNREGISTER_SUCC));
|
||||
@ -730,9 +732,9 @@ void ItemManager::itemTradeRegisterCashHandler(CNSocket* sock, CNPacketData* dat
|
||||
|
||||
sP_CL2FE_REQ_PC_TRADE_CASH_REGISTER* pacdat = (sP_CL2FE_REQ_PC_TRADE_CASH_REGISTER*)data->buf;
|
||||
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
if (pacdat->iCandy < 0 || pacdat->iCandy > plr.plr->money)
|
||||
if (pacdat->iCandy < 0 || pacdat->iCandy > plr->money)
|
||||
return; // famous glitch, begone
|
||||
|
||||
INITSTRUCT(sP_FE2CL_REP_PC_TRADE_CASH_REGISTER_SUCC, resp);
|
||||
@ -753,13 +755,13 @@ void ItemManager::itemTradeRegisterCashHandler(CNSocket* sock, CNPacketData* dat
|
||||
CNSocket* otherSock = sock;
|
||||
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == iID_Check) {
|
||||
if (pair.second->iID == iID_Check) {
|
||||
otherSock = pair.first;
|
||||
}
|
||||
}
|
||||
|
||||
plr.plr->moneyInTrade = pacdat->iCandy;
|
||||
plr.plr->isTradeConfirm = false;
|
||||
plr->moneyInTrade = pacdat->iCandy;
|
||||
plr->isTradeConfirm = false;
|
||||
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_CASH_REGISTER_SUCC, sizeof(sP_FE2CL_REP_PC_TRADE_CASH_REGISTER_SUCC));
|
||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_CASH_REGISTER_SUCC, sizeof(sP_FE2CL_REP_PC_TRADE_CASH_REGISTER_SUCC));
|
||||
@ -791,7 +793,7 @@ void ItemManager::itemTradeChatHandler(CNSocket* sock, CNPacketData* data) {
|
||||
CNSocket* otherSock = sock;
|
||||
|
||||
for (auto pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == iID_Check) {
|
||||
if (pair.second->iID == iID_Check) {
|
||||
otherSock = pair.first;
|
||||
}
|
||||
}
|
||||
|
@ -861,7 +861,7 @@ void MobManager::playerTick(CNServer *serv, time_t currTime) {
|
||||
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
CNSocket *sock = pair.first;
|
||||
Player *plr = pair.second.plr;
|
||||
Player *plr = pair.second;
|
||||
bool transmit = false;
|
||||
|
||||
// group ticks
|
||||
@ -1001,8 +1001,8 @@ void MobManager::pcAttackChars(CNSocket *sock, CNPacketData *data) {
|
||||
Player *target = nullptr;
|
||||
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == pktdata[i*2]) {
|
||||
target = pair.second.plr;
|
||||
if (pair.second->iID == pktdata[i*2]) {
|
||||
target = pair.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ void NPCManager::npcWarpTimeMachine(CNSocket* sock, CNPacketData* data) {
|
||||
}
|
||||
|
||||
void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
|
||||
PlayerView& plrv = PlayerManager::players[sock];
|
||||
Player* plr = PlayerManager::getPlayer(sock);
|
||||
// sanity check
|
||||
if (Warps.find(warpId) == Warps.end())
|
||||
return;
|
||||
@ -633,14 +633,14 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
|
||||
|
||||
// if warp requires you to be on a mission, it's gotta be a unique instance
|
||||
if (Warps[warpId].limitTaskID != 0 || instanceID == 14) { // 14 is a special case for the Time Lab
|
||||
instanceID += ((uint64_t)plrv.plr->iIDGroup << 32); // upper 32 bits are leader ID
|
||||
instanceID += ((uint64_t)plr->iIDGroup << 32); // upper 32 bits are leader ID
|
||||
ChunkManager::createInstance(instanceID);
|
||||
}
|
||||
|
||||
if (plrv.plr->iID == plrv.plr->iIDGroup && plrv.plr->groupCnt == 1)
|
||||
if (plr->iID == plr->iIDGroup && plr->groupCnt == 1)
|
||||
PlayerManager::sendPlayerTo(sock, Warps[warpId].x, Warps[warpId].y, Warps[warpId].z, instanceID);
|
||||
else {
|
||||
Player* leaderPlr = PlayerManager::getPlayerFromID(plrv.plr->iIDGroup);
|
||||
Player* leaderPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||
|
||||
for (int i = 0; i < leaderPlr->groupCnt; i++) {
|
||||
Player* otherPlr = PlayerManager::getPlayerFromID(leaderPlr->groupIDs[i]);
|
||||
@ -659,11 +659,11 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
|
||||
resp.iX = Warps[warpId].x;
|
||||
resp.iY = Warps[warpId].y;
|
||||
resp.iZ = Warps[warpId].z;
|
||||
resp.iCandy = plrv.plr->money;
|
||||
resp.iCandy = plr->money;
|
||||
resp.eIL = 4; // do not take away any items
|
||||
PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock);
|
||||
plrv.currentChunks.clear();
|
||||
plrv.plr->instanceID = INSTANCE_OVERWORLD;
|
||||
PlayerManager::removePlayerFromChunks(*plr->currentChunks, sock);
|
||||
plr->currentChunks->clear();
|
||||
plr->instanceID = INSTANCE_OVERWORLD;
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC));
|
||||
}
|
||||
}
|
||||
|
@ -488,8 +488,8 @@ bool doHeal(CNSocket *sock, int32_t *pktdata, sSkillResult_Heal_HP *respdata, in
|
||||
Player *plr = nullptr;
|
||||
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == pktdata[i]) {
|
||||
plr = pair.second.plr;
|
||||
if (pair.second->iID == pktdata[i]) {
|
||||
plr = pair.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -519,8 +519,8 @@ bool doGroupHeal(CNSocket *sock, int32_t *pktdata, sSkillResult_Heal_HP *respdat
|
||||
Player *plr = nullptr;
|
||||
|
||||
for (auto& pair : PlayerManager::players) {
|
||||
if (pair.second.plr->iID == pktdata[0]) {
|
||||
plr = pair.second.plr;
|
||||
if (pair.second->iID == pktdata[0]) {
|
||||
plr = pair.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "ChunkManager.hpp"
|
||||
|
||||
#define ACTIVE_MISSION_COUNT 6
|
||||
|
||||
@ -75,4 +76,8 @@ struct Player {
|
||||
|
||||
bool buddiesSynced;
|
||||
int64_t buddyIDs[50];
|
||||
|
||||
ChunkPos chunkPos;
|
||||
std::vector<Chunk*>* currentChunks;
|
||||
time_t lastHeartbeat;
|
||||
};
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
std::map<CNSocket*, PlayerView> PlayerManager::players;
|
||||
std::map<CNSocket*, Player*> PlayerManager::players;
|
||||
|
||||
void PlayerManager::init() {
|
||||
// register packet types
|
||||
@ -52,11 +52,10 @@ void PlayerManager::addPlayer(CNSocket* key, Player plr) {
|
||||
|
||||
memcpy(p, &plr, sizeof(Player));
|
||||
|
||||
players[key] = PlayerView();
|
||||
players[key].chunkPos = std::make_tuple(0, 0, 0);
|
||||
players[key].currentChunks = std::vector<Chunk*>();
|
||||
players[key].plr = p;
|
||||
players[key].lastHeartbeat = 0;
|
||||
players[key] = p;
|
||||
p->chunkPos = std::make_tuple(0, 0, 0);
|
||||
p->currentChunks = new std::vector<Chunk*>();
|
||||
p->lastHeartbeat = 0;
|
||||
|
||||
key->plr = p;
|
||||
|
||||
@ -65,28 +64,28 @@ void PlayerManager::addPlayer(CNSocket* key, Player plr) {
|
||||
}
|
||||
|
||||
void PlayerManager::removePlayer(CNSocket* key) {
|
||||
PlayerView& view = players[key];
|
||||
uint64_t fromInstance = view.plr->instanceID;
|
||||
Player* plr = getPlayer(key);
|
||||
uint64_t fromInstance = plr->instanceID;
|
||||
|
||||
GroupManager::groupKickPlayer(view.plr);
|
||||
GroupManager::groupKickPlayer(plr);
|
||||
|
||||
// remove player's bullets
|
||||
MobManager::Bullets.erase(view.plr->iID);
|
||||
MobManager::Bullets.erase(plr->iID);
|
||||
|
||||
// save player to DB
|
||||
Database::updatePlayer(view.plr);
|
||||
Database::updatePlayer(plr);
|
||||
|
||||
// remove players from all chunks
|
||||
removePlayerFromChunks(view.currentChunks, key);
|
||||
removePlayerFromChunks(*plr->currentChunks, key);
|
||||
|
||||
// remove from chunk
|
||||
if (ChunkManager::chunks.find(view.chunkPos) != ChunkManager::chunks.end())
|
||||
ChunkManager::chunks[view.chunkPos]->players.erase(key);
|
||||
if (ChunkManager::chunks.find(plr->chunkPos) != ChunkManager::chunks.end())
|
||||
ChunkManager::chunks[plr->chunkPos]->players.erase(key);
|
||||
|
||||
std::cout << getPlayerName(key->plr) << " has left!" << std::endl;
|
||||
|
||||
key->plr = nullptr;
|
||||
delete view.plr;
|
||||
delete plr;
|
||||
players.erase(key);
|
||||
|
||||
// if the player was in a lair, clean it up
|
||||
@ -136,15 +135,15 @@ bool PlayerManager::removePlayerFromChunks(std::vector<Chunk*> chunks, CNSocket*
|
||||
|
||||
// remove players from eachother
|
||||
for (CNSocket* otherSock : chunk->players) {
|
||||
exitPlayer.iID = players[sock].plr->iID;
|
||||
exitPlayer.iID = getPlayer(sock)->iID;
|
||||
otherSock->sendPacket((void*)&exitPlayer, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT));
|
||||
exitPlayer.iID = players[otherSock].plr->iID;
|
||||
exitPlayer.iID = getPlayer(otherSock)->iID;
|
||||
sock->sendPacket((void*)&exitPlayer, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT));
|
||||
}
|
||||
}
|
||||
|
||||
// remove us from that old stinky chunk
|
||||
return ChunkManager::removePlayer(players[sock].chunkPos, sock);
|
||||
return ChunkManager::removePlayer(getPlayer(sock)->chunkPos, sock);
|
||||
}
|
||||
|
||||
void PlayerManager::addPlayerToChunks(std::vector<Chunk*> chunks, CNSocket* sock) {
|
||||
@ -182,8 +181,8 @@ void PlayerManager::addPlayerToChunks(std::vector<Chunk*> chunks, CNSocket* sock
|
||||
if (sock == otherSock)
|
||||
continue;
|
||||
|
||||
Player *otherPlr = players[otherSock].plr;
|
||||
Player *plr = players[sock].plr;
|
||||
Player *otherPlr = getPlayer(otherSock);
|
||||
Player *plr = getPlayer(sock);
|
||||
|
||||
newPlayer.PCAppearanceData.iID = plr->iID;
|
||||
newPlayer.PCAppearanceData.iHP = plr->HP;
|
||||
@ -219,61 +218,63 @@ void PlayerManager::addPlayerToChunks(std::vector<Chunk*> chunks, CNSocket* sock
|
||||
}
|
||||
|
||||
void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z, int angle) {
|
||||
players[sock].plr->angle = angle;
|
||||
getPlayer(sock)->angle = angle;
|
||||
updatePlayerPosition(sock, X, Y, Z);
|
||||
}
|
||||
|
||||
void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
|
||||
PlayerView& view = players[sock];
|
||||
view.plr->x = X;
|
||||
view.plr->y = Y;
|
||||
view.plr->z = Z;
|
||||
updatePlayerChunk(sock, X, Y, view.plr->instanceID);
|
||||
Player* plr = getPlayer(sock);
|
||||
plr->x = X;
|
||||
plr->y = Y;
|
||||
plr->z = Z;
|
||||
updatePlayerChunk(sock, X, Y, plr->instanceID);
|
||||
}
|
||||
|
||||
void PlayerManager::updatePlayerChunk(CNSocket* sock, int X, int Y, uint64_t instanceID) {
|
||||
PlayerView& view = players[sock];
|
||||
ChunkPos newPos = ChunkManager::grabChunk(X, Y, view.plr->instanceID);
|
||||
Player* plr = getPlayer(sock);
|
||||
ChunkPos newPos = ChunkManager::grabChunk(X, Y, plr->instanceID);
|
||||
|
||||
// nothing to be done
|
||||
if (newPos == view.chunkPos)
|
||||
if (newPos == plr->chunkPos)
|
||||
return;
|
||||
|
||||
// add player to chunk
|
||||
ChunkManager::addPlayer(X, Y, view.plr->instanceID, sock);
|
||||
ChunkManager::addPlayer(X, Y, plr->instanceID, sock);
|
||||
std::vector<Chunk*> allChunks = ChunkManager::grabChunks(newPos);
|
||||
|
||||
Chunk *chunk = nullptr;
|
||||
if (ChunkManager::checkChunk(view.chunkPos))
|
||||
chunk = ChunkManager::chunks[view.chunkPos];
|
||||
if (ChunkManager::checkChunk(plr->chunkPos))
|
||||
chunk = ChunkManager::chunks[plr->chunkPos];
|
||||
|
||||
// first, remove all the old npcs & players from the old chunks
|
||||
if (removePlayerFromChunks(ChunkManager::getDeltaChunks(view.currentChunks, allChunks), sock)) {
|
||||
if (removePlayerFromChunks(ChunkManager::getDeltaChunks(*plr->currentChunks, allChunks), sock)) {
|
||||
allChunks.erase(std::remove(allChunks.begin(), allChunks.end(), chunk), allChunks.end());
|
||||
}
|
||||
|
||||
// now, add all the new npcs & players!
|
||||
addPlayerToChunks(ChunkManager::getDeltaChunks(allChunks, view.currentChunks), sock);
|
||||
addPlayerToChunks(ChunkManager::getDeltaChunks(allChunks, *plr->currentChunks), sock);
|
||||
|
||||
view.chunkPos = newPos;
|
||||
view.currentChunks = allChunks;
|
||||
plr->chunkPos = newPos;
|
||||
plr->currentChunks->clear();
|
||||
for (Chunk* c : allChunks) {
|
||||
plr->currentChunks->push_back(c);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I) {
|
||||
PlayerView& plrv = PlayerManager::players[sock];
|
||||
Player* plr = plrv.plr;
|
||||
Player* plr = getPlayer(sock);
|
||||
|
||||
if (plrv.plr->instanceID == 0) {
|
||||
if (plr->instanceID == 0) {
|
||||
// save last uninstanced coords
|
||||
plrv.plr->lastX = plrv.plr->x;
|
||||
plrv.plr->lastY = plrv.plr->y;
|
||||
plrv.plr->lastZ = plrv.plr->z;
|
||||
plrv.plr->lastAngle = plrv.plr->angle;
|
||||
plr->lastX = plr->x;
|
||||
plr->lastY = plr->y;
|
||||
plr->lastZ = plr->z;
|
||||
plr->lastAngle = plr->angle;
|
||||
}
|
||||
|
||||
MissionManager::failInstancedMissions(sock); // fail any instanced missions
|
||||
|
||||
uint64_t fromInstance = plrv.plr->instanceID; // pre-warp instance, saved for post-warp
|
||||
uint64_t fromInstance = plr->instanceID; // pre-warp instance, saved for post-warp
|
||||
|
||||
plr->instanceID = I;
|
||||
if (I != INSTANCE_OVERWORLD) {
|
||||
@ -288,10 +289,10 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I
|
||||
resp.iX = X;
|
||||
resp.iY = Y;
|
||||
resp.iZ = Z;
|
||||
resp.iCandy = plrv.plr->money;
|
||||
resp.iCandy = plr->money;
|
||||
resp.eIL = 4; // do not take away any items
|
||||
PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock);
|
||||
plrv.currentChunks.clear();
|
||||
PlayerManager::removePlayerFromChunks(*plr->currentChunks, sock);
|
||||
plr->currentChunks->clear();
|
||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC));
|
||||
updatePlayerPosition(sock, X, Y, Z);
|
||||
}
|
||||
@ -308,10 +309,10 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z) {
|
||||
pkt.iZ = Z;
|
||||
|
||||
// force player & NPC reload
|
||||
PlayerView& plrv = players[sock];
|
||||
PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock);
|
||||
plrv.currentChunks.clear();
|
||||
plrv.chunkPos = std::make_tuple(0, 0, plrv.plr->instanceID);
|
||||
Player* plr = getPlayer(sock);
|
||||
PlayerManager::removePlayerFromChunks(*plr->currentChunks, sock);
|
||||
plr->currentChunks->clear();
|
||||
plr->chunkPos = std::make_tuple(0, 0, plr->instanceID);
|
||||
sock->sendPacket((void*)&pkt, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC));
|
||||
}
|
||||
|
||||
@ -439,12 +440,12 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
BuddyManager::refreshBuddyList(sock);
|
||||
|
||||
for (auto& pair : PlayerManager::players)
|
||||
if (pair.second.plr->notify)
|
||||
if (pair.second->notify)
|
||||
ChatManager::sendServerMessage(pair.first, "[ADMIN]" + getPlayerName(&plr) + " has joined.");
|
||||
}
|
||||
|
||||
void PlayerManager::sendToViewable(CNSocket* sock, void* buf, uint32_t type, size_t size) {
|
||||
for (Chunk* chunk : players[sock].currentChunks) {
|
||||
for (Chunk* chunk : *getPlayer(sock)->currentChunks) {
|
||||
for (CNSocket* otherSock : chunk->players) {
|
||||
if (otherSock == sock)
|
||||
continue;
|
||||
@ -482,12 +483,14 @@ void PlayerManager::movePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
sP_CL2FE_REQ_PC_MOVE* moveData = (sP_CL2FE_REQ_PC_MOVE*)data->buf;
|
||||
updatePlayerPosition(sock, moveData->iX, moveData->iY, moveData->iZ, moveData->iAngle);
|
||||
|
||||
players[sock].plr->angle = moveData->iAngle;
|
||||
Player* plr = getPlayer(sock);
|
||||
|
||||
plr->angle = moveData->iAngle;
|
||||
uint64_t tm = getTime();
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_MOVE, moveResponse);
|
||||
|
||||
moveResponse.iID = players[sock].plr->iID;
|
||||
moveResponse.iID = plr->iID;
|
||||
moveResponse.cKeyValue = moveData->cKeyValue;
|
||||
|
||||
moveResponse.iX = moveData->iX;
|
||||
@ -516,7 +519,7 @@ void PlayerManager::stopPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_STOP, stopResponse);
|
||||
|
||||
stopResponse.iID = players[sock].plr->iID;
|
||||
stopResponse.iID = getPlayer(sock)->iID;
|
||||
|
||||
stopResponse.iX = stopData->iX;
|
||||
stopResponse.iY = stopData->iY;
|
||||
@ -539,7 +542,7 @@ void PlayerManager::jumpPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_JUMP, jumpResponse);
|
||||
|
||||
jumpResponse.iID = players[sock].plr->iID;
|
||||
jumpResponse.iID = getPlayer(sock)->iID;
|
||||
jumpResponse.cKeyValue = jumpData->cKeyValue;
|
||||
|
||||
jumpResponse.iX = jumpData->iX;
|
||||
@ -568,7 +571,7 @@ void PlayerManager::jumppadPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_JUMPPAD, jumppadResponse);
|
||||
|
||||
jumppadResponse.iPC_ID = players[sock].plr->iID;
|
||||
jumppadResponse.iPC_ID = getPlayer(sock)->iID;
|
||||
jumppadResponse.cKeyValue = jumppadData->cKeyValue;
|
||||
|
||||
jumppadResponse.iX = jumppadData->iX;
|
||||
@ -595,7 +598,7 @@ void PlayerManager::launchPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_LAUNCHER, launchResponse);
|
||||
|
||||
launchResponse.iPC_ID = players[sock].plr->iID;
|
||||
launchResponse.iPC_ID = getPlayer(sock)->iID;
|
||||
|
||||
launchResponse.iX = launchData->iX;
|
||||
launchResponse.iY = launchData->iY;
|
||||
@ -623,7 +626,7 @@ void PlayerManager::ziplinePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_ZIPLINE, ziplineResponse);
|
||||
|
||||
ziplineResponse.iPC_ID = players[sock].plr->iID;
|
||||
ziplineResponse.iPC_ID = getPlayer(sock)->iID;
|
||||
ziplineResponse.iCliTime = ziplineData->iCliTime;
|
||||
ziplineResponse.iSvrTime = tm;
|
||||
ziplineResponse.iX = ziplineData->iX;
|
||||
@ -658,7 +661,7 @@ void PlayerManager::movePlatformPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_MOVEPLATFORM, platResponse);
|
||||
|
||||
platResponse.iPC_ID = players[sock].plr->iID;
|
||||
platResponse.iPC_ID = getPlayer(sock)->iID;
|
||||
platResponse.iCliTime = platformData->iCliTime;
|
||||
platResponse.iSvrTime = tm;
|
||||
platResponse.iX = platformData->iX;
|
||||
@ -690,7 +693,7 @@ void PlayerManager::moveSliderPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_MOVETRANSPORTATION, sliderResponse);
|
||||
|
||||
sliderResponse.iPC_ID = players[sock].plr->iID;
|
||||
sliderResponse.iPC_ID = getPlayer(sock)->iID;
|
||||
sliderResponse.iCliTime = sliderData->iCliTime;
|
||||
sliderResponse.iSvrTime = tm;
|
||||
sliderResponse.iX = sliderData->iX;
|
||||
@ -721,7 +724,7 @@ void PlayerManager::moveSlopePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
INITSTRUCT(sP_FE2CL_PC_SLOPE, slopeResponse);
|
||||
|
||||
slopeResponse.iPC_ID = players[sock].plr->iID;
|
||||
slopeResponse.iPC_ID = getPlayer(sock)->iID;
|
||||
slopeResponse.iCliTime = slopeData->iCliTime;
|
||||
slopeResponse.iSvrTime = tm;
|
||||
slopeResponse.iX = slopeData->iX;
|
||||
@ -809,7 +812,7 @@ void PlayerManager::setSpecialPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
}
|
||||
|
||||
void PlayerManager::heartbeatPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
players[sock].lastHeartbeat = getTime();
|
||||
getPlayer(sock)->lastHeartbeat = getTime();
|
||||
}
|
||||
|
||||
void PlayerManager::exitGame(CNSocket* sock, CNPacketData* data) {
|
||||
@ -893,48 +896,44 @@ void PlayerManager::revivePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
}
|
||||
|
||||
void PlayerManager::enterPlayerVehicle(CNSocket* sock, CNPacketData* data) {
|
||||
PlayerView& plr = PlayerManager::players[sock];
|
||||
Player* plr = getPlayer(sock);
|
||||
|
||||
if (plr.plr->Equip[8].iID > 0 && plr.plr->Equip[8].iTimeLimit>getTimestamp()) {
|
||||
if (plr->Equip[8].iID > 0 && plr->Equip[8].iTimeLimit>getTimestamp()) {
|
||||
INITSTRUCT(sP_FE2CL_PC_VEHICLE_ON_SUCC, response);
|
||||
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_SUCC, sizeof(sP_FE2CL_PC_VEHICLE_ON_SUCC));
|
||||
|
||||
// send to other players
|
||||
plr.plr->iPCState |= 8;
|
||||
plr->iPCState |= 8;
|
||||
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, response2);
|
||||
response2.iPC_ID = plr.plr->iID;
|
||||
response2.iState = plr.plr->iPCState;
|
||||
response2.iPC_ID = plr->iID;
|
||||
response2.iState = plr->iPCState;
|
||||
sendToViewable(sock, (void*)&response2, P_FE2CL_PC_STATE_CHANGE, sizeof(sP_FE2CL_PC_STATE_CHANGE));
|
||||
|
||||
for (Chunk* chunk : players[sock].currentChunks) {
|
||||
for (CNSocket* otherSock : chunk->players) {
|
||||
otherSock->sendPacket((void*)&response2, P_FE2CL_PC_STATE_CHANGE, sizeof(sP_FE2CL_PC_STATE_CHANGE));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
INITSTRUCT(sP_FE2CL_PC_VEHICLE_ON_FAIL, response);
|
||||
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_FAIL, sizeof(sP_FE2CL_PC_VEHICLE_ON_FAIL));
|
||||
|
||||
// check if vehicle didn't expire
|
||||
if (plr.plr->Equip[8].iTimeLimit < getTimestamp()) {
|
||||
plr.plr->toRemoveVehicle.eIL = 0;
|
||||
plr.plr->toRemoveVehicle.iSlotNum = 8;
|
||||
ItemManager::checkItemExpire(sock, plr.plr);
|
||||
if (plr->Equip[8].iTimeLimit < getTimestamp()) {
|
||||
plr->toRemoveVehicle.eIL = 0;
|
||||
plr->toRemoveVehicle.iSlotNum = 8;
|
||||
ItemManager::checkItemExpire(sock, plr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerManager::exitPlayerVehicle(CNSocket* sock, CNPacketData* data) {
|
||||
PlayerView plr = PlayerManager::players[sock];
|
||||
Player* plr = getPlayer(sock);
|
||||
|
||||
if (plr.plr->iPCState & 8) {
|
||||
if (plr->iPCState & 8) {
|
||||
INITSTRUCT(sP_FE2CL_PC_VEHICLE_OFF_SUCC, response);
|
||||
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_OFF_SUCC, sizeof(sP_FE2CL_PC_VEHICLE_OFF_SUCC));
|
||||
|
||||
// send to other players
|
||||
plr.plr->iPCState &= ~8;
|
||||
plr->iPCState &= ~8;
|
||||
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, response2);
|
||||
response2.iPC_ID = plr.plr->iID;
|
||||
response2.iState = plr.plr->iPCState;
|
||||
response2.iPC_ID = plr->iID;
|
||||
response2.iState = plr->iPCState;
|
||||
|
||||
sendToViewable(sock, (void*)&response2, P_FE2CL_PC_STATE_CHANGE, sizeof(sP_FE2CL_PC_STATE_CHANGE));
|
||||
}
|
||||
@ -985,7 +984,7 @@ void PlayerManager::changePlayerGuide(CNSocket *sock, CNPacketData *data) {
|
||||
#pragma region Helper methods
|
||||
Player *PlayerManager::getPlayer(CNSocket* key) {
|
||||
if (players.find(key) != players.end())
|
||||
return players[key].plr;
|
||||
return players[key];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -1019,20 +1018,20 @@ WarpLocation PlayerManager::getRespawnPoint(Player *plr) {
|
||||
}
|
||||
|
||||
bool PlayerManager::isAccountInUse(int accountId) {
|
||||
std::map<CNSocket*, PlayerView>::iterator it;
|
||||
std::map<CNSocket*, Player*>::iterator it;
|
||||
for (it = PlayerManager::players.begin(); it != PlayerManager::players.end(); it++) {
|
||||
if (it->second.plr->accountId == accountId)
|
||||
if (it->second->accountId == accountId)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PlayerManager::exitDuplicate(int accountId) {
|
||||
std::map<CNSocket*, PlayerView>::iterator it;
|
||||
std::map<CNSocket*, Player*>::iterator it;
|
||||
|
||||
// disconnect any duplicate players
|
||||
for (it = players.begin(); it != players.end(); it++) {
|
||||
if (it->second.plr->accountId == accountId) {
|
||||
if (it->second->accountId == accountId) {
|
||||
CNSocket* sock = it->first;
|
||||
|
||||
INITSTRUCT(sP_FE2CL_REP_PC_EXIT_DUPLICATE, resp);
|
||||
@ -1074,15 +1073,15 @@ void PlayerManager::setSpecialState(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
Player *PlayerManager::getPlayerFromID(int32_t iID) {
|
||||
for (auto& pair : PlayerManager::players)
|
||||
if (pair.second.plr->iID == iID)
|
||||
return pair.second.plr;
|
||||
if (pair.second->iID == iID)
|
||||
return pair.second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CNSocket *PlayerManager::getSockFromID(int32_t iID) {
|
||||
for (auto& pair : PlayerManager::players)
|
||||
if (pair.second.plr->iID == iID)
|
||||
if (pair.second->iID == iID)
|
||||
return pair.first;
|
||||
|
||||
return nullptr;
|
||||
|
@ -12,16 +12,8 @@
|
||||
|
||||
struct WarpLocation;
|
||||
|
||||
struct PlayerView {
|
||||
ChunkPos chunkPos;
|
||||
std::vector<Chunk*> currentChunks;
|
||||
Player *plr;
|
||||
time_t lastHeartbeat;
|
||||
};
|
||||
|
||||
|
||||
namespace PlayerManager {
|
||||
extern std::map<CNSocket*, PlayerView> players;
|
||||
extern std::map<CNSocket*, Player*> players;
|
||||
void init();
|
||||
|
||||
void addPlayer(CNSocket* key, Player plr);
|
||||
|
@ -139,7 +139,6 @@ void TransportManager::transportWarpHandler(CNSocket* sock, CNPacketData* data)
|
||||
plr->money -= route.cost;
|
||||
|
||||
TransportLocation target;
|
||||
PlayerView& plrv = PlayerManager::players[sock];
|
||||
switch (route.type) {
|
||||
case 1: // S.C.A.M.P.E.R.
|
||||
target = Locations[route.end];
|
||||
@ -150,9 +149,9 @@ void TransportManager::transportWarpHandler(CNSocket* sock, CNPacketData* data)
|
||||
* Not strictly necessary since there isn't a valid SCAMPER that puts you in the
|
||||
* same map tile you were already in, but we might as well force an NPC reload.
|
||||
*/
|
||||
PlayerManager::removePlayerFromChunks(plrv.currentChunks, sock);
|
||||
plrv.currentChunks.clear();
|
||||
plrv.chunkPos = std::make_tuple(0, 0, plrv.plr->instanceID);
|
||||
PlayerManager::removePlayerFromChunks(*plr->currentChunks, sock);
|
||||
plr->currentChunks->clear();
|
||||
plr->chunkPos = std::make_tuple(0, 0, plr->instanceID);
|
||||
break;
|
||||
case 2: // Monkey Skyway
|
||||
if (SkywayPaths.find(route.mssRouteNum) != SkywayPaths.end()) { // check if route exists
|
||||
|
Loading…
Reference in New Issue
Block a user