diff --git a/config.ini b/config.ini index 86c280d..44442a4 100644 --- a/config.ini +++ b/config.ini @@ -19,8 +19,9 @@ dbsaveinterval=240 [shard] port=8002 ip=127.0.0.1 -# distance at which other players and NPCs become visible -chunksize=30000 +# distance at which other players and NPCs become visible. +# this value is used for calculating chunk size +viewdistance=30000 # time, in milliseconds, to wait before kicking a non-responsive client # default is 1 minute timeout=60000 diff --git a/src/ChatManager.cpp b/src/ChatManager.cpp index 367081a..e54e13f 100644 --- a/src/ChatManager.cpp +++ b/src/ChatManager.cpp @@ -279,10 +279,18 @@ void toggleAiCommand(std::string full, std::vector& args, CNSocket* for (auto& pair : MobManager::Mobs) { pair.second->state = MobState::RETREAT; pair.second->target = nullptr; + pair.second->nextMovement = getTime(); - pair.second->roamX = pair.second->spawnX; - pair.second->roamY = pair.second->spawnY; - pair.second->roamZ = pair.second->spawnZ; + // mobs with static paths can chill where they are + if (pair.second->staticPath) { + pair.second->roamX = pair.second->appearanceData.iX; + pair.second->roamY = pair.second->appearanceData.iY; + pair.second->roamZ = pair.second->appearanceData.iZ; + } else { + pair.second->roamX = pair.second->spawnX; + pair.second->roamY = pair.second->spawnY; + pair.second->roamZ = pair.second->spawnZ; + } } } diff --git a/src/ChunkManager.cpp b/src/ChunkManager.cpp index 955efea..8e2319d 100644 --- a/src/ChunkManager.cpp +++ b/src/ChunkManager.cpp @@ -109,7 +109,7 @@ bool ChunkManager::checkChunk(std::tuple chunk) { } std::tuple ChunkManager::grabChunk(int posX, int posY, int instanceID) { - return std::make_tuple(posX / (settings::CHUNKSIZE / 3), posY / (settings::CHUNKSIZE / 3), instanceID); + return std::make_tuple(posX / (settings::VIEWDISTANCE / 3), posY / (settings::VIEWDISTANCE / 3), instanceID); } std::vector ChunkManager::grabChunks(std::tuple chunk) { diff --git a/src/ItemManager.cpp b/src/ItemManager.cpp index cac407b..37beac3 100644 --- a/src/ItemManager.cpp +++ b/src/ItemManager.cpp @@ -5,7 +5,7 @@ #include "NanoManager.hpp" #include "Player.hpp" -#include // for memset() and memcmp() +#include // for memset() #include std::map, Item> ItemManager::ItemData; @@ -911,6 +911,10 @@ void ItemManager::setItemStats(Player* plr) { for (int i = 0; i < 4; i++) { itemStatsDat = ItemManager::getItemData(plr->Equip[i].iID, plr->Equip[i].iType); + if (itemStatsDat == nullptr) { + std::cout << "[WARN] setItemStats(): getItemData() returned NULL" << std::endl; + continue; + } plr->pointDamage += itemStatsDat->pointDamage; plr->groupDamage += itemStatsDat->groupDamage; plr->defense += itemStatsDat->defense; diff --git a/src/NanoManager.cpp b/src/NanoManager.cpp index 21e6f45..99954c2 100644 --- a/src/NanoManager.cpp +++ b/src/NanoManager.cpp @@ -625,9 +625,9 @@ void activePower(CNSocket *sock, CNPacketData *data, return; pkt->iTargetCnt = otherPlr->groupCnt; - } - - resplen = sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) + pkt->iTargetCnt * sizeof(sPAYLOAD); + resplen = sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) + pkt->iTargetCnt * sizeof(sPAYLOAD); + } else + resplen = sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC) + pkt->iTargetCnt * sizeof(sPAYLOAD); // validate response packet if (!validOutVarPacket(sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC), pkt->iTargetCnt, sizeof(sPAYLOAD))) { diff --git a/src/settings.cpp b/src/settings.cpp index dad9ef3..cd0d06d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -12,7 +12,7 @@ int settings::DBSAVEINTERVAL = 240; int settings::SHARDPORT = 8002; std::string settings::SHARDSERVERIP = "127.0.0.1"; time_t settings::TIMEOUT = 60000; -int settings::CHUNKSIZE = 40000; +int settings::VIEWDISTANCE = 40000; bool settings::SIMULATEMOBS = true; // default spawn point is Sector V (future) @@ -47,7 +47,7 @@ void settings::init() { SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1"); DBSAVEINTERVAL = reader.GetInteger("shard", "dbsaveinterval", DBSAVEINTERVAL); TIMEOUT = reader.GetInteger("shard", "timeout", TIMEOUT); - CHUNKSIZE = reader.GetInteger("shard", "chunksize", CHUNKSIZE); + VIEWDISTANCE = reader.GetInteger("shard", "viewdistance", VIEWDISTANCE); SIMULATEMOBS = reader.GetBoolean("shard", "simulatemobs", SIMULATEMOBS); SPAWN_X = reader.GetInteger("shard", "spawnx", SPAWN_X); SPAWN_Y = reader.GetInteger("shard", "spawny", SPAWN_Y); diff --git a/src/settings.hpp b/src/settings.hpp index 915eefd..d53b969 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -8,7 +8,7 @@ namespace settings { extern int SHARDPORT; extern std::string SHARDSERVERIP; extern time_t TIMEOUT; - extern int CHUNKSIZE; + extern int VIEWDISTANCE; extern bool SIMULATEMOBS; extern int SPAWN_X; extern int SPAWN_Y;