mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 07:21:12 +00:00
Cleanup
This commit is contained in:
parent
19fd404b7b
commit
bf3f82b9d4
@ -138,19 +138,13 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Activator::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
std::string Activator::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
||||||
{
|
{
|
||||||
std::string model = getModel(ptr);
|
std::string model = getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise
|
||||||
if (model.empty())
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
return std::string();
|
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Creature> &creaturestore = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>();
|
|
||||||
std::string creatureId;
|
std::string creatureId;
|
||||||
|
|
||||||
for (const ESM::Creature &iter : creaturestore)
|
|
||||||
{
|
|
||||||
if (iter.mModel.empty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (Misc::StringUtils::ciEqual(model, "meshes\\" + iter.mModel))
|
for (const ESM::Creature &iter : store.get<ESM::Creature>())
|
||||||
|
{
|
||||||
|
if (!iter.mModel.empty() && Misc::StringUtils::ciEqual(model, "meshes\\" + iter.mModel))
|
||||||
{
|
{
|
||||||
creatureId = !iter.mOriginal.empty() ? iter.mOriginal : iter.mId;
|
creatureId = !iter.mOriginal.empty() ? iter.mOriginal : iter.mId;
|
||||||
break;
|
break;
|
||||||
@ -160,19 +154,12 @@ namespace MWClass
|
|||||||
if (creatureId.empty())
|
if (creatureId.empty())
|
||||||
return std::string();
|
return std::string();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::SoundGenerator> &store = MWBase::Environment::get().getWorld()->getStore().get<ESM::SoundGenerator>();
|
|
||||||
|
|
||||||
int type = getSndGenTypeFromName(name);
|
int type = getSndGenTypeFromName(name);
|
||||||
std::vector<const ESM::SoundGenerator*> sounds;
|
std::vector<const ESM::SoundGenerator*> sounds;
|
||||||
|
|
||||||
MWWorld::Store<ESM::SoundGenerator>::iterator sound = store.begin();
|
for (auto sound = store.get<ESM::SoundGenerator>().begin(); sound != store.get<ESM::SoundGenerator>().end(); ++sound)
|
||||||
|
|
||||||
while (sound != store.end())
|
|
||||||
{
|
|
||||||
if (type == sound->mType && !sound->mCreature.empty() && (Misc::StringUtils::ciEqual(creatureId, sound->mCreature)))
|
if (type == sound->mType && !sound->mCreature.empty() && (Misc::StringUtils::ciEqual(creatureId, sound->mCreature)))
|
||||||
sounds.push_back(&*sound);
|
sounds.push_back(&*sound);
|
||||||
++sound;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sounds.empty())
|
if (!sounds.empty())
|
||||||
return sounds[Misc::Rng::rollDice(sounds.size())]->mSound;
|
return sounds[Misc::Rng::rollDice(sounds.size())]->mSound;
|
||||||
@ -183,24 +170,24 @@ namespace MWClass
|
|||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Activator::getSndGenTypeFromName(const std::string &name) const
|
int Activator::getSndGenTypeFromName(const std::string &name)
|
||||||
{
|
{
|
||||||
if (name == "left")
|
if (name == "left")
|
||||||
return 0;
|
return ESM::SoundGenerator::LeftFoot;
|
||||||
if (name == "right")
|
if (name == "right")
|
||||||
return 1;
|
return ESM::SoundGenerator::RightFoot;
|
||||||
if (name == "swimleft")
|
if (name == "swimleft")
|
||||||
return 2;
|
return ESM::SoundGenerator::SwimLeft;
|
||||||
if (name == "swimright")
|
if (name == "swimright")
|
||||||
return 3;
|
return ESM::SoundGenerator::SwimRight;
|
||||||
if (name == "moan")
|
if (name == "moan")
|
||||||
return 4;
|
return ESM::SoundGenerator::Moan;
|
||||||
if (name == "roar")
|
if (name == "roar")
|
||||||
return 5;
|
return ESM::SoundGenerator::Roar;
|
||||||
if (name == "scream")
|
if (name == "scream")
|
||||||
return 6;
|
return ESM::SoundGenerator::Scream;
|
||||||
if (name == "land")
|
if (name == "land")
|
||||||
return 7;
|
return ESM::SoundGenerator::Land;
|
||||||
|
|
||||||
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ namespace MWClass
|
|||||||
|
|
||||||
virtual MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const;
|
virtual MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
|
static int getSndGenTypeFromName(const std::string &name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -46,8 +48,6 @@ namespace MWClass
|
|||||||
virtual bool isActivator() const;
|
virtual bool isActivator() const;
|
||||||
|
|
||||||
virtual std::string getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const;
|
virtual std::string getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const;
|
||||||
|
|
||||||
virtual int getSndGenTypeFromName(const std::string &name) const;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,9 +688,9 @@ namespace MWClass
|
|||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
|
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
|
||||||
if(world->isUnderwater(ptr.getCell(), pos) || world->isWalkingOnWater(ptr))
|
if(world->isUnderwater(ptr.getCell(), pos) || world->isWalkingOnWater(ptr))
|
||||||
return 2;
|
return ESM::SoundGenerator::SwimLeft;
|
||||||
if(world->isOnGround(ptr))
|
if(world->isOnGround(ptr))
|
||||||
return 0;
|
return ESM::SoundGenerator::LeftFoot;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(name == "right")
|
if(name == "right")
|
||||||
@ -698,23 +698,23 @@ namespace MWClass
|
|||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
|
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
|
||||||
if(world->isUnderwater(ptr.getCell(), pos) || world->isWalkingOnWater(ptr))
|
if(world->isUnderwater(ptr.getCell(), pos) || world->isWalkingOnWater(ptr))
|
||||||
return 3;
|
return ESM::SoundGenerator::SwimRight;
|
||||||
if(world->isOnGround(ptr))
|
if(world->isOnGround(ptr))
|
||||||
return 1;
|
return ESM::SoundGenerator::RightFoot;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(name == "swimleft")
|
if(name == "swimleft")
|
||||||
return 2;
|
return ESM::SoundGenerator::SwimLeft;
|
||||||
if(name == "swimright")
|
if(name == "swimright")
|
||||||
return 3;
|
return ESM::SoundGenerator::SwimRight;
|
||||||
if(name == "moan")
|
if(name == "moan")
|
||||||
return 4;
|
return ESM::SoundGenerator::Moan;
|
||||||
if(name == "roar")
|
if(name == "roar")
|
||||||
return 5;
|
return ESM::SoundGenerator::Roar;
|
||||||
if(name == "scream")
|
if(name == "scream")
|
||||||
return 6;
|
return ESM::SoundGenerator::Scream;
|
||||||
if(name == "land")
|
if(name == "land")
|
||||||
return 7;
|
return ESM::SoundGenerator::Land;
|
||||||
|
|
||||||
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user