1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 23:15:36 +00:00

Merge pull request #3063 from akortunov/master

Code cleanup, part 2
This commit is contained in:
Bret Curtis 2021-04-14 10:03:07 +02:00 committed by GitHub
commit 4f72fa2615
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 23 additions and 31 deletions

View file

@ -11,6 +11,7 @@ namespace ESSImport
{ {
out.mId = Misc::StringUtils::lowerCase(scpt.mSCHD.mName.toString()); out.mId = Misc::StringUtils::lowerCase(scpt.mSCHD.mName.toString());
out.mRunning = scpt.mRunning; out.mRunning = scpt.mRunning;
out.mTargetRef.unset(); // TODO: convert target reference of global script
convertSCRI(scpt.mSCRI, out.mLocals); convertSCRI(scpt.mSCRI, out.mLocals);
} }

View file

@ -19,6 +19,7 @@ namespace ESSImport
item.mCount = contItem.mCount; item.mCount = contItem.mCount;
item.mRelativeEquipmentSlot = -1; item.mRelativeEquipmentSlot = -1;
item.mLockLevel = 0; item.mLockLevel = 0;
item.mRefNum.unset();
unsigned int itemCount = std::abs(item.mCount); unsigned int itemCount = std::abs(item.mCount);
bool separateStacks = false; bool separateStacks = false;

View file

@ -986,20 +986,6 @@ int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base
mMetaData.setRecord (0, Record<MetaData> (RecordBase::State_ModifiedOnly, nullptr, &metaData)); mMetaData.setRecord (0, Record<MetaData> (RecordBase::State_ModifiedOnly, nullptr, &metaData));
} }
// Fix uninitialized master data index
for (std::vector<ESM::Header::MasterData>::const_iterator masterData = mReader->getGameFiles().begin();
masterData != mReader->getGameFiles().end(); ++masterData)
{
std::map<std::string, int>::iterator nameResult = mContentFileNames.find(masterData->name);
if (nameResult != mContentFileNames.end())
{
ESM::Header::MasterData& hackedMasterData = const_cast<ESM::Header::MasterData&>(*masterData);
hackedMasterData.index = nameResult->second;
}
}
return mReader->getRecordCount(); return mReader->getRecordCount();
} }

View file

@ -150,6 +150,9 @@ static void gdb_info(pid_t pid)
* So CoverityScan warning is valid only for ancient versions of stdlib. * So CoverityScan warning is valid only for ancient versions of stdlib.
*/ */
strcpy(respfile, "/tmp/gdb-respfile-XXXXXX"); strcpy(respfile, "/tmp/gdb-respfile-XXXXXX");
#ifdef __COVERITY__
umask(0600);
#endif
if((fd=mkstemp(respfile)) >= 0 && (f=fdopen(fd, "w")) != nullptr) if((fd=mkstemp(respfile)) >= 0 && (f=fdopen(fd, "w")) != nullptr)
{ {
fprintf(f, "attach %d\n" fprintf(f, "attach %d\n"

View file

@ -42,7 +42,6 @@ void ESM::Header::load (ESMReader &esm)
MasterData m; MasterData m;
m.name = esm.getHString(); m.name = esm.getHString();
m.size = esm.getHNLong ("DATA"); m.size = esm.getHNLong ("DATA");
m.index = -1;
mMaster.push_back (m); mMaster.push_back (m);
} }

View file

@ -49,7 +49,6 @@ namespace ESM
{ {
std::string name; std::string name;
uint64_t size; uint64_t size;
int index; // Position of the parent file in the global list of loaded files
}; };
GMDT mGameData; // Used in .ess savegames only GMDT mGameData; // Used in .ess savegames only

View file

@ -363,11 +363,11 @@ void NiSkinPartition::read(NIFStream *nif)
void NiSkinPartition::Partition::read(NIFStream *nif) void NiSkinPartition::Partition::read(NIFStream *nif)
{ {
unsigned short numVertices = nif->getUShort(); size_t numVertices = nif->getUShort();
unsigned short numTriangles = nif->getUShort(); size_t numTriangles = nif->getUShort();
unsigned short numBones = nif->getUShort(); size_t numBones = nif->getUShort();
unsigned short numStrips = nif->getUShort(); size_t numStrips = nif->getUShort();
unsigned short bonesPerVertex = nif->getUShort(); size_t bonesPerVertex = nif->getUShort();
if (numBones) if (numBones)
nif->getUShorts(bones, numBones); nif->getUShorts(bones, numBones);
@ -395,7 +395,7 @@ void NiSkinPartition::Partition::read(NIFStream *nif)
if (numStrips) if (numStrips)
{ {
strips.resize(numStrips); strips.resize(numStrips);
for (unsigned short i = 0; i < numStrips; i++) for (size_t i = 0; i < numStrips; i++)
nif->getUShorts(strips[i], stripLengths[i]); nif->getUShorts(strips[i], stripLengths[i]);
} }
else if (numTriangles) else if (numTriangles)

View file

@ -400,7 +400,7 @@ namespace SceneUtil
class LightStateAttributePerObjectUniform : public osg::StateAttribute class LightStateAttributePerObjectUniform : public osg::StateAttribute
{ {
public: public:
LightStateAttributePerObjectUniform() {} LightStateAttributePerObjectUniform() : mLightManager(nullptr) {}
LightStateAttributePerObjectUniform(const std::vector<osg::ref_ptr<osg::Light>>& lights, LightManager* lightManager) : mLights(lights), mLightManager(lightManager) {} LightStateAttributePerObjectUniform(const std::vector<osg::ref_ptr<osg::Light>>& lights, LightManager* lightManager) : mLights(lights), mLightManager(lightManager) {}
LightStateAttributePerObjectUniform(const LightStateAttributePerObjectUniform& copy,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) LightStateAttributePerObjectUniform(const LightStateAttributePerObjectUniform& copy,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY)
@ -613,7 +613,7 @@ namespace SceneUtil
class LightManagerCullCallback : public osg::NodeCallback class LightManagerCullCallback : public osg::NodeCallback
{ {
public: public:
LightManagerCullCallback(LightManager* lightManager) : mLightManager(lightManager) {} LightManagerCullCallback(LightManager* lightManager) : mLightManager(lightManager), mLastFrameNumber(0) {}
void operator()(osg::Node* node, osg::NodeVisitor* nv) override void operator()(osg::Node* node, osg::NodeVisitor* nv) override
{ {
@ -861,7 +861,7 @@ namespace SceneUtil
if (ffp) if (ffp)
{ {
initFFP(LightManager::mFFPMaxLights); initFFP(mFFPMaxLights);
return; return;
} }
@ -903,6 +903,10 @@ namespace SceneUtil
, mLightingMask(copy.mLightingMask) , mLightingMask(copy.mLightingMask)
, mSun(copy.mSun) , mSun(copy.mSun)
, mLightingMethod(copy.mLightingMethod) , mLightingMethod(copy.mLightingMethod)
, mPointLightRadiusMultiplier(copy.mPointLightRadiusMultiplier)
, mPointLightFadeEnd(copy.mPointLightFadeEnd)
, mPointLightFadeStart(copy.mPointLightFadeStart)
, mMaxLights(copy.mMaxLights)
{ {
} }
@ -1040,7 +1044,7 @@ namespace SceneUtil
auto* stateset = getOrCreateStateSet(); auto* stateset = getOrCreateStateSet();
setLightingMethod(LightingMethod::PerObjectUniform); setLightingMethod(LightingMethod::PerObjectUniform);
setMaxLights(std::clamp(targetLights, mMaxLightsLowerLimit, LightManager::mMaxLightsUpperLimit)); setMaxLights(std::clamp(targetLights, mMaxLightsLowerLimit, mMaxLightsUpperLimit));
stateset->setAttributeAndModes(new LightManagerStateAttributePerObjectUniform(this), osg::StateAttribute::ON); stateset->setAttributeAndModes(new LightManagerStateAttributePerObjectUniform(this), osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform(osg::Uniform::FLOAT_MAT4, "LightBuffer", getMaxLights())); stateset->addUniform(new osg::Uniform(osg::Uniform::FLOAT_MAT4, "LightBuffer", getMaxLights()));
@ -1049,7 +1053,7 @@ namespace SceneUtil
void LightManager::initSingleUBO(int targetLights) void LightManager::initSingleUBO(int targetLights)
{ {
setLightingMethod(LightingMethod::SingleUBO); setLightingMethod(LightingMethod::SingleUBO);
setMaxLights(std::clamp(targetLights, mMaxLightsLowerLimit, LightManager::mMaxLightsUpperLimit)); setMaxLights(std::clamp(targetLights, mMaxLightsLowerLimit, mMaxLightsUpperLimit));
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {

View file

@ -368,6 +368,7 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> v
pack_evt.yrel = 0; pack_evt.yrel = 0;
pack_evt.z = mMouseZ; pack_evt.z = mMouseZ;
pack_evt.zrel = 0; pack_evt.zrel = 0;
pack_evt.timestamp = 0;
if(evt.type == SDL_MOUSEMOTION) if(evt.type == SDL_MOUSEMOTION)
{ {

View file

@ -278,8 +278,7 @@ namespace Shader
const osg::StateSet::AttributeList& attributes = stateset->getAttributeList(); const osg::StateSet::AttributeList& attributes = stateset->getAttributeList();
osg::StateSet::AttributeList removedAttributes; osg::StateSet::AttributeList removedAttributes;
osg::ref_ptr<osg::StateSet> removedState; if (osg::ref_ptr<osg::StateSet> removedState = getRemovedState(*stateset))
if (removedState = getRemovedState(*stateset))
removedAttributes = removedState->getAttributeList(); removedAttributes = removedState->getAttributeList();
for (const auto& attributeMap : { attributes, removedAttributes }) for (const auto& attributeMap : { attributes, removedAttributes })
{ {
@ -475,8 +474,7 @@ namespace Shader
writableStateSet->removeAttribute(osg::StateAttribute::PROGRAM); writableStateSet->removeAttribute(osg::StateAttribute::PROGRAM);
osg::ref_ptr<osg::StateSet> removedState; if (osg::ref_ptr<osg::StateSet> removedState = getRemovedState(*writableStateSet))
if (removedState = getRemovedState(*writableStateSet))
{ {
// user data is normally shallow copied so shared with the original stateset // user data is normally shallow copied so shared with the original stateset
osg::ref_ptr<osg::UserDataContainer> writableUserData; osg::ref_ptr<osg::UserDataContainer> writableUserData;