mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-12-22 03:10:05 +00:00
Hotfix to stop crashing the server.
This will need to be fixed properly; probably while we implement chunking.
This commit is contained in:
parent
e79f179628
commit
001564a257
@ -210,5 +210,5 @@ public:
|
||||
static void printPacket(CNPacketData *data, int type);
|
||||
virtual void newConnection(CNSocket* cns);
|
||||
virtual void killConnection(CNSocket* cns);
|
||||
virtual void onStep(); // called every 2 seconds
|
||||
virtual void onStep();
|
||||
};
|
||||
|
@ -59,8 +59,6 @@ void MobManager::pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
|
||||
|
||||
mob->appearanceData.iHP -= 100;
|
||||
|
||||
std::cout << "mob health is now " << mob->appearanceData.iHP << std::endl;
|
||||
|
||||
if (mob->appearanceData.iHP <= 0)
|
||||
killMob(sock, mob);
|
||||
|
||||
|
@ -57,22 +57,29 @@ void PlayerManager::removePlayer(CNSocket* key) {
|
||||
PlayerView cachedView = players[key];
|
||||
|
||||
// if players have them in their viewable lists, remove it
|
||||
for (CNSocket* otherSock : players[key].viewable) {
|
||||
players[otherSock].viewable.remove(key); // gone
|
||||
for (auto& pair : players) {
|
||||
if (pair.first == key)
|
||||
continue;
|
||||
|
||||
PlayerView& otherPlayer = pair.second;
|
||||
otherPlayer.viewable.remove(key); // gone
|
||||
|
||||
std::cout << "PlayerId = " << otherPlayer.plr->iID << " removed from " << otherPlayer.plr->iID << "'s viewable list" << std::endl;
|
||||
|
||||
// now send PC_EXIT packet
|
||||
sP_FE2CL_PC_EXIT exitPacket;
|
||||
INITSTRUCT(sP_FE2CL_PC_EXIT, exitPacket);
|
||||
exitPacket.iID = players[key].plr->iID;
|
||||
|
||||
otherSock->sendPacket((void*)&exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT));
|
||||
pair.first->sendPacket((void*)&exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT));
|
||||
}
|
||||
|
||||
std::cout << U16toU8(cachedView.plr->PCStyle.szFirstName) << " " << U16toU8(cachedView.plr->PCStyle.szLastName) << " has left!" << std::endl;
|
||||
std::cout << players.size() << " players" << std::endl;
|
||||
std::cout << U16toU8(cachedView.plr->PCStyle.szFirstName) << " " << U16toU8(cachedView.plr->PCStyle.szLastName) << " (PlayerId = " << key->plr->iID << ") has left!" << std::endl;
|
||||
|
||||
key->plr = nullptr;
|
||||
delete cachedView.plr;
|
||||
players.erase(key);
|
||||
|
||||
std::cout << players.size() << " players" << std::endl;
|
||||
}
|
||||
|
||||
void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z, int angle) {
|
||||
|
Loading…
Reference in New Issue
Block a user