Skip to content

Commit 068fa6c

Browse files
committed
pfx fixup
1 parent ddb8cf8 commit 068fa6c

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

game/game/definitions/particlesdefinitions.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ ParticlesDefinitions::~ParticlesDefinitions() {
1616
vm->clearReferences(Daedalus::IC_Pfx);
1717
}
1818

19-
const ParticleFx* ParticlesDefinitions::get(std::string_view name) {
19+
const ParticleFx* ParticlesDefinitions::get(std::string_view name, bool relaxed) {
2020
if(name.empty())
2121
return nullptr;
2222

2323
while(FileExt::hasExt(name,"PFX"))
2424
name = name.substr(0,name.size()-4);
2525

2626
std::lock_guard<std::recursive_mutex> guard(sync);
27-
return implGet(name);
27+
return implGet(name,relaxed);
2828
}
2929

3030
const ParticleFx* ParticlesDefinitions::get(const ParticleFx* base, const VisualFx::Key* key) {
@@ -34,13 +34,13 @@ const ParticleFx* ParticlesDefinitions::get(const ParticleFx* base, const Visual
3434
return implGet(*base,*key);
3535
}
3636

37-
const ParticleFx* ParticlesDefinitions::implGet(std::string_view name) {
37+
const ParticleFx* ParticlesDefinitions::implGet(std::string_view name, bool relaxed) {
3838
auto cname = std::string(name);
3939
auto it = pfx.find(cname);
4040
if(it!=pfx.end())
4141
return it->second.get();
4242
Daedalus::GEngineClasses::C_ParticleFX decl={};
43-
if(!implGet(name,decl))
43+
if(!implGet(name,decl,relaxed))
4444
return nullptr;
4545
std::unique_ptr<ParticleFx> p{new ParticleFx(decl,name)};
4646
auto elt = pfx.insert(std::make_pair(std::move(cname),std::move(p)));
@@ -60,15 +60,17 @@ const ParticleFx* ParticlesDefinitions::implGet(const ParticleFx& base, const Vi
6060
}
6161

6262
bool ParticlesDefinitions::implGet(std::string_view name,
63-
Daedalus::GEngineClasses::C_ParticleFX& ret) {
63+
Daedalus::GEngineClasses::C_ParticleFX& ret,
64+
bool relaxed) {
6465
if(!vm || name.empty())
6566
return false;
6667

6768
char buf[256] = {};
6869
std::snprintf(buf,sizeof(buf),"%.*s",int(name.size()),name.data());
6970
auto id = vm->getDATFile().getSymbolIndexByName(buf);
7071
if(id==size_t(-1)) {
71-
Log::e("invalid particle system: \"",buf,"\"");
72+
if(!relaxed)
73+
Log::e("invalid particle system: \"",buf,"\"");
7274
return false;
7375
}
7476

game/game/definitions/particlesdefinitions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ParticlesDefinitions final {
1515
ParticlesDefinitions();
1616
~ParticlesDefinitions();
1717

18-
const ParticleFx* get(std::string_view name);
18+
const ParticleFx* get(std::string_view name, bool relaxed);
1919
const ParticleFx* get(const ParticleFx* base, const VisualFx::Key* key);
2020

2121
private:
@@ -25,8 +25,8 @@ class ParticlesDefinitions final {
2525
std::unordered_map<std::string, std::unique_ptr<ParticleFx>> pfx;
2626
std::unordered_map<const VisualFx::Key*, std::unique_ptr<ParticleFx>> pfxKey;
2727

28-
const ParticleFx* implGet(std::string_view name);
28+
const ParticleFx* implGet(std::string_view name, bool relaxed);
2929
const ParticleFx* implGet(const ParticleFx& base, const VisualFx::Key& key);
3030

31-
bool implGet(std::string_view name, Daedalus::GEngineClasses::C_ParticleFX &ret);
31+
bool implGet(std::string_view name, Daedalus::GEngineClasses::C_ParticleFX &ret, bool relaxed);
3232
};

game/gothic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ const VisualFx* Gothic::loadVisualFx(std::string_view name) {
259259
return vfxDef->get(name);
260260
}
261261

262-
const ParticleFx* Gothic::loadParticleFx(std::string_view name) {
263-
return particleDef->get(name);
262+
const ParticleFx* Gothic::loadParticleFx(std::string_view name, bool relaxed) {
263+
return particleDef->get(name,relaxed);
264264
}
265265

266266
const ParticleFx* Gothic::loadParticleFx(const ParticleFx* base, const VisualFx::Key* key) {

game/gothic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Gothic final {
7575
SoundFx* loadSoundFx (std::string_view name);
7676
SoundFx* loadSoundWavFx(std::string_view name);
7777

78-
auto loadParticleFx(std::string_view name) -> const ParticleFx*;
78+
auto loadParticleFx(std::string_view name, bool relaxed=false) -> const ParticleFx*;
7979
auto loadParticleFx(const ParticleFx* base, const VisualFx::Key* key) -> const ParticleFx*;
8080
auto loadVisualFx (std::string_view name) -> const VisualFx*;
8181

game/world/world.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ Sound World::addHitEffect(std::string_view src, std::string_view dst, std::strin
720720
auto ret = Sound(*this,::Sound::T_Regular,buf,pos3,2500.f,false);
721721

722722
std::snprintf(buf,sizeof(buf),"CPFX_%.*s_%.*s_%.*s", int(scheme.size()),scheme.data(), int(src.size()),src.data(), int(dst.size()),dst.data());
723-
if(Gothic::inst().loadParticleFx(buf)==nullptr) {
723+
if(Gothic::inst().loadParticleFx(buf,true)==nullptr) {
724724
if(dst=="ME")
725725
std::snprintf(buf,sizeof(buf),"CPFX_%.*s_%s",int(scheme.size()),scheme.data(),"METAL");
726726
else if(dst=="WO")
@@ -730,6 +730,9 @@ Sound World::addHitEffect(std::string_view src, std::string_view dst, std::strin
730730
else
731731
return ret;
732732
}
733+
if(Gothic::inst().loadParticleFx(buf,true)==nullptr)
734+
return ret;
735+
733736
Effect e(PfxEmitter(*this,buf),"");
734737
e.setObjMatrix(pos);
735738
e.setActive(true);

0 commit comments

Comments
 (0)