diff --git a/config.ini b/config.ini index 1df6030..b6e412c 100644 --- a/config.ini +++ b/config.ini @@ -12,7 +12,7 @@ port=8002 # you'll want to change this one ip=192.168.1.183 # distance at which other players and NPCs become visible -view=1000 +view=20000 # little message players see when they enter the game motd=Welcome to OpenFusion! diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index 44aa96f..2d8f694 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -87,9 +87,9 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) { } } - std::list cachedview(players[sock].viewable); // copies the viewable - - for (CNSocket* otherSock : cachedview) { + std::list::iterator i = players[sock].viewable.begin(); + while (i != players[sock].viewable.end()) { + CNSocket* otherSock = *i; if (std::find(noView.begin(), noView.end(), otherSock) != noView.end()) { // sock shouldn't be visible, send PC_EXIT packet & remove them @@ -102,15 +102,16 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) { otherSock->sendPacket(new CNPacketData((void*)exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), otherSock->getFEKey())); sock->sendPacket(new CNPacketData((void*)exitPacketOther, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), sock->getFEKey())); - players[sock].viewable.remove(otherSock); + players[sock].viewable.erase(i++); players[otherSock].viewable.remove(sock); + continue; } + + ++i; } - cachedview = players[sock].viewable; - for (CNSocket* otherSock : yesView) { - if (std::find(cachedview.begin(), cachedview.end(), otherSock) == cachedview.end()) { + if (std::find(players[sock].viewable.begin(), players[sock].viewable.end(), otherSock) == players[sock].viewable.end()) { // this needs to be added to the viewable players, send PC_ENTER sP_FE2CL_PC_NEW* newPlayer = (sP_FE2CL_PC_NEW*)xmalloc(sizeof(sP_FE2CL_PC_NEW)); // current connection to other player