mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-01-11 03:00:15 +00:00
Get rid of PlayerView. For good.
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user