diff --git a/game/game/definitions/particlesdefinitions.cpp b/game/game/definitions/particlesdefinitions.cpp index b87156bd7..bab19aa5e 100644 --- a/game/game/definitions/particlesdefinitions.cpp +++ b/game/game/definitions/particlesdefinitions.cpp @@ -16,7 +16,7 @@ ParticlesDefinitions::~ParticlesDefinitions() { vm->clearReferences(Daedalus::IC_Pfx); } -const ParticleFx* ParticlesDefinitions::get(std::string_view name) { +const ParticleFx* ParticlesDefinitions::get(std::string_view name, bool relaxed) { if(name.empty()) return nullptr; @@ -24,7 +24,7 @@ const ParticleFx* ParticlesDefinitions::get(std::string_view name) { name = name.substr(0,name.size()-4); std::lock_guard guard(sync); - return implGet(name); + return implGet(name,relaxed); } const ParticleFx* ParticlesDefinitions::get(const ParticleFx* base, const VisualFx::Key* key) { @@ -34,13 +34,13 @@ const ParticleFx* ParticlesDefinitions::get(const ParticleFx* base, const Visual return implGet(*base,*key); } -const ParticleFx* ParticlesDefinitions::implGet(std::string_view name) { +const ParticleFx* ParticlesDefinitions::implGet(std::string_view name, bool relaxed) { auto cname = std::string(name); auto it = pfx.find(cname); if(it!=pfx.end()) return it->second.get(); Daedalus::GEngineClasses::C_ParticleFX decl={}; - if(!implGet(name,decl)) + if(!implGet(name,decl,relaxed)) return nullptr; std::unique_ptr p{new ParticleFx(decl,name)}; auto elt = pfx.insert(std::make_pair(std::move(cname),std::move(p))); @@ -60,7 +60,8 @@ const ParticleFx* ParticlesDefinitions::implGet(const ParticleFx& base, const Vi } bool ParticlesDefinitions::implGet(std::string_view name, - Daedalus::GEngineClasses::C_ParticleFX& ret) { + Daedalus::GEngineClasses::C_ParticleFX& ret, + bool relaxed) { if(!vm || name.empty()) return false; @@ -68,7 +69,8 @@ bool ParticlesDefinitions::implGet(std::string_view name, std::snprintf(buf,sizeof(buf),"%.*s",int(name.size()),name.data()); auto id = vm->getDATFile().getSymbolIndexByName(buf); if(id==size_t(-1)) { - Log::e("invalid particle system: \"",buf,"\""); + if(!relaxed) + Log::e("invalid particle system: \"",buf,"\""); return false; } diff --git a/game/game/definitions/particlesdefinitions.h b/game/game/definitions/particlesdefinitions.h index 7759b7b9e..9ef06eb07 100644 --- a/game/game/definitions/particlesdefinitions.h +++ b/game/game/definitions/particlesdefinitions.h @@ -15,7 +15,7 @@ class ParticlesDefinitions final { ParticlesDefinitions(); ~ParticlesDefinitions(); - const ParticleFx* get(std::string_view name); + const ParticleFx* get(std::string_view name, bool relaxed); const ParticleFx* get(const ParticleFx* base, const VisualFx::Key* key); private: @@ -25,8 +25,8 @@ class ParticlesDefinitions final { std::unordered_map> pfx; std::unordered_map> pfxKey; - const ParticleFx* implGet(std::string_view name); + const ParticleFx* implGet(std::string_view name, bool relaxed); const ParticleFx* implGet(const ParticleFx& base, const VisualFx::Key& key); - bool implGet(std::string_view name, Daedalus::GEngineClasses::C_ParticleFX &ret); + bool implGet(std::string_view name, Daedalus::GEngineClasses::C_ParticleFX &ret, bool relaxed); }; diff --git a/game/gothic.cpp b/game/gothic.cpp index c79ee5c2d..789fe0c8c 100644 --- a/game/gothic.cpp +++ b/game/gothic.cpp @@ -259,8 +259,8 @@ const VisualFx* Gothic::loadVisualFx(std::string_view name) { return vfxDef->get(name); } -const ParticleFx* Gothic::loadParticleFx(std::string_view name) { - return particleDef->get(name); +const ParticleFx* Gothic::loadParticleFx(std::string_view name, bool relaxed) { + return particleDef->get(name,relaxed); } const ParticleFx* Gothic::loadParticleFx(const ParticleFx* base, const VisualFx::Key* key) { diff --git a/game/gothic.h b/game/gothic.h index cf40554e3..4469e4e89 100644 --- a/game/gothic.h +++ b/game/gothic.h @@ -75,7 +75,7 @@ class Gothic final { SoundFx* loadSoundFx (std::string_view name); SoundFx* loadSoundWavFx(std::string_view name); - auto loadParticleFx(std::string_view name) -> const ParticleFx*; + auto loadParticleFx(std::string_view name, bool relaxed=false) -> const ParticleFx*; auto loadParticleFx(const ParticleFx* base, const VisualFx::Key* key) -> const ParticleFx*; auto loadVisualFx (std::string_view name) -> const VisualFx*; diff --git a/game/world/world.cpp b/game/world/world.cpp index cb2c422cd..4f0882af5 100644 --- a/game/world/world.cpp +++ b/game/world/world.cpp @@ -720,7 +720,7 @@ Sound World::addHitEffect(std::string_view src, std::string_view dst, std::strin auto ret = Sound(*this,::Sound::T_Regular,buf,pos3,2500.f,false); std::snprintf(buf,sizeof(buf),"CPFX_%.*s_%.*s_%.*s", int(scheme.size()),scheme.data(), int(src.size()),src.data(), int(dst.size()),dst.data()); - if(Gothic::inst().loadParticleFx(buf)==nullptr) { + if(Gothic::inst().loadParticleFx(buf,true)==nullptr) { if(dst=="ME") std::snprintf(buf,sizeof(buf),"CPFX_%.*s_%s",int(scheme.size()),scheme.data(),"METAL"); else if(dst=="WO") @@ -730,6 +730,9 @@ Sound World::addHitEffect(std::string_view src, std::string_view dst, std::strin else return ret; } + if(Gothic::inst().loadParticleFx(buf,true)==nullptr) + return ret; + Effect e(PfxEmitter(*this,buf),""); e.setObjMatrix(pos); e.setActive(true);