From 17020fc13ad03fbac719c2d1f750e1bef647a8cc Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 15 Oct 2019 07:21:48 +0300 Subject: [PATCH] [Client] Use a template to combine RecordHelper override functions --- apps/openmw/mwmp/DedicatedPlayer.cpp | 6 +- apps/openmw/mwmp/RecordHelper.cpp | 147 --------------------------- apps/openmw/mwmp/RecordHelper.hpp | 31 ++---- 3 files changed, 9 insertions(+), 175 deletions(-) diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index c89f96b40..736f31506 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -165,7 +165,7 @@ void DedicatedPlayer::setBaseInfo() } else { - RecordHelper::overrideNpcRecord(npc); + RecordHelper::overrideRecord(npc); reloadPtr(); } @@ -208,7 +208,7 @@ void DedicatedPlayer::setShapeshift() else { creature.mId = creatureRecordId; - RecordHelper::overrideCreatureRecord(creature); + RecordHelper::overrideRecord(creature); } LOG_APPEND(TimedLog::LOG_INFO, "- Creating reference for %s", creature.mId.c_str()); @@ -223,7 +223,7 @@ void DedicatedPlayer::setShapeshift() deleteReference(); } - RecordHelper::overrideNpcRecord(npc); + RecordHelper::overrideRecord(npc); createReference(npc.mId); reloadPtr(); } diff --git a/apps/openmw/mwmp/RecordHelper.cpp b/apps/openmw/mwmp/RecordHelper.cpp index db33f0008..8073c69d4 100644 --- a/apps/openmw/mwmp/RecordHelper.cpp +++ b/apps/openmw/mwmp/RecordHelper.cpp @@ -1549,150 +1549,3 @@ void RecordHelper::overrideCellRecord(const mwmp::CellRecord& record) world->changeToInteriorCell(recordData.mName, playerPos, true, true); } } - -void RecordHelper::overrideCreatureRecord(const ESM::Creature& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideNpcRecord(const ESM::NPC& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideEnchantmentRecord(const ESM::Enchantment& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overridePotionRecord(const ESM::Potion& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideSpellRecord(const ESM::Spell& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideArmorRecord(const ESM::Armor& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideBookRecord(const ESM::Book& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideClothingRecord(const ESM::Clothing& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideMiscellaneousRecord(const ESM::Miscellaneous& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideWeaponRecord(const ESM::Weapon& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideContainerRecord(const ESM::Container& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideDoorRecord(const ESM::Door& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideActivatorRecord(const ESM::Activator& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideStaticRecord(const ESM::Static& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideIngredientRecord(const ESM::Ingredient& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideApparatusRecord(const ESM::Apparatus& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideLockpickRecord(const ESM::Lockpick& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideProbeRecord(const ESM::Probe& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideRepairRecord(const ESM::Repair& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideLightRecord(const ESM::Light& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} - -void RecordHelper::overrideCellRecord(const ESM::Cell& record) -{ - MWBase::World *world = MWBase::Environment::get().getWorld(); - - world->getModifiableStore().overrideRecord(record); -} diff --git a/apps/openmw/mwmp/RecordHelper.hpp b/apps/openmw/mwmp/RecordHelper.hpp index 7810b9315..31c691e6e 100644 --- a/apps/openmw/mwmp/RecordHelper.hpp +++ b/apps/openmw/mwmp/RecordHelper.hpp @@ -68,32 +68,13 @@ namespace RecordHelper void overrideLightRecord(const mwmp::LightRecord& record); void overrideCellRecord(const mwmp::CellRecord& record); - void overrideCreatureRecord(const ESM::Creature& record); - void overrideNpcRecord(const ESM::NPC& record); + template + void overrideRecord(const RecordType &record) + { + MWBase::World *world = MWBase::Environment::get().getWorld(); - void overrideEnchantmentRecord(const ESM::Enchantment& record); - void overridePotionRecord(const ESM::Potion& record); - void overrideSpellRecord(const ESM::Spell& record); - - void overrideArmorRecord(const ESM::Armor& record); - void overrideBookRecord(const ESM::Book& record); - void overrideClothingRecord(const ESM::Clothing& record); - void overrideMiscellaneousRecord(const ESM::Miscellaneous& record); - void overrideWeaponRecord(const ESM::Weapon& record); - - void overrideContainerRecord(const ESM::Container& record); - void overrideDoorRecord(const ESM::Door& record); - - void overrideActivatorRecord(const ESM::Activator& record); - void overrideStaticRecord(const ESM::Static& record); - - void overrideIngredientRecord(const ESM::Ingredient& record); - void overrideApparatusRecord(const ESM::Apparatus& record); - void overrideLockpickRecord(const ESM::Lockpick& record); - void overrideProbeRecord(const ESM::Probe& record); - void overrideRepairRecord(const ESM::Repair& record); - void overrideLightRecord(const ESM::Light& record); - void overrideCellRecord(const ESM::Cell& record); + world->getModifiableStore().overrideRecord(record); + } }