From ba5998d53a78f2b2bc9bf8e00fe63e46ac0ce6ca Mon Sep 17 00:00:00 2001 From: dongresource Date: Tue, 22 Sep 2020 20:53:44 +0200 Subject: [PATCH] Added a config option to disable mob movement and combat. This will come in handy when gruntwork starts. Also fixed a bug where the ACCLEVEL setting was read as a boolean. --- config.ini | 3 +++ src/MobManager.cpp | 4 ++++ src/settings.cpp | 4 +++- src/settings.hpp | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config.ini b/config.ini index 62f7eaa..bab26c0 100644 --- a/config.ini +++ b/config.ini @@ -24,6 +24,9 @@ chunksize=40000 # time, in milliseconds, to wait before kicking a non-responsive client # default is 1 minute timeout=60000 +# should mobs move around and fight back? +# can be disabled for easier mob placement +simulatemobs=true # little message players see when they enter the game motd=Welcome to OpenFusion! # NPC json data diff --git a/src/MobManager.cpp b/src/MobManager.cpp index 82d9696..f4d3242 100644 --- a/src/MobManager.cpp +++ b/src/MobManager.cpp @@ -216,6 +216,10 @@ void MobManager::step(time_t currTime) { if (!ChunkManager::inPopulatedChunks(x, y)) continue; + // skip mob movement and combat if disabled + if (!settings::SIMULATEMOBS && pair.second->state != MobState::DEAD) + continue; + switch (pair.second->state) { case MobState::ROAMING: roamingStep(pair.second, currTime); diff --git a/src/settings.cpp b/src/settings.cpp index a19802b..5f50807 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -13,6 +13,7 @@ int settings::SHARDPORT = 8002; std::string settings::SHARDSERVERIP = "127.0.0.1"; time_t settings::TIMEOUT = 60000; int settings::CHUNKSIZE = 40000; +bool settings::SIMULATEMOBS = true; // default spawn point is Sector V (future) int settings::SPAWN_X = 632032; @@ -46,6 +47,7 @@ void settings::init() { DBSAVEINTERVAL = reader.GetInteger("shard", "dbsaveinterval", DBSAVEINTERVAL); TIMEOUT = reader.GetInteger("shard", "timeout", TIMEOUT); CHUNKSIZE = reader.GetInteger("shard", "chunksize", CHUNKSIZE); + SIMULATEMOBS = reader.GetBoolean("shard", "simulatemobs", SIMULATEMOBS); SPAWN_X = reader.GetInteger("shard", "spawnx", SPAWN_X); SPAWN_Y = reader.GetInteger("shard", "spawny", SPAWN_Y); SPAWN_Z = reader.GetInteger("shard", "spawnz", SPAWN_Z); @@ -55,5 +57,5 @@ void settings::init() { MOBJSON = reader.Get("shard", "mobdata", MOBJSON); PATHJSON = reader.Get("shard", "pathdata", PATHJSON); MOTDSTRING = reader.Get("shard", "motd", MOTDSTRING); - ACCLEVEL = reader.GetBoolean("shard", "accountlevel", ACCLEVEL); + ACCLEVEL = reader.GetInteger("shard", "accountlevel", ACCLEVEL); } diff --git a/src/settings.hpp b/src/settings.hpp index 2ec9bcd..19006f3 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -9,6 +9,7 @@ namespace settings { extern std::string SHARDSERVERIP; extern time_t TIMEOUT; extern int CHUNKSIZE; + extern bool SIMULATEMOBS; extern int SPAWN_X; extern int SPAWN_Y; extern int SPAWN_Z;