1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 03:15:32 +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.mRunning = scpt.mRunning;
out.mTargetRef.unset(); // TODO: convert target reference of global script
convertSCRI(scpt.mSCRI, out.mLocals);
}

View file

@ -19,6 +19,7 @@ namespace ESSImport
item.mCount = contItem.mCount;
item.mRelativeEquipmentSlot = -1;
item.mLockLevel = 0;
item.mRefNum.unset();
unsigned int itemCount = std::abs(item.mCount);
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));
}
// 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();
}

View file

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

View file

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

View file

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

View file

@ -363,11 +363,11 @@ void NiSkinPartition::read(NIFStream *nif)
void NiSkinPartition::Partition::read(NIFStream *nif)
{
unsigned short numVertices = nif->getUShort();
unsigned short numTriangles = nif->getUShort();
unsigned short numBones = nif->getUShort();
unsigned short numStrips = nif->getUShort();
unsigned short bonesPerVertex = nif->getUShort();
size_t numVertices = nif->getUShort();
size_t numTriangles = nif->getUShort();
size_t numBones = nif->getUShort();
size_t numStrips = nif->getUShort();
size_t bonesPerVertex = nif->getUShort();
if (numBones)
nif->getUShorts(bones, numBones);
@ -395,7 +395,7 @@ void NiSkinPartition::Partition::read(NIFStream *nif)
if (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]);
}
else if (numTriangles)

View file

@ -400,7 +400,7 @@ namespace SceneUtil
class LightStateAttributePerObjectUniform : public osg::StateAttribute
{
public:
LightStateAttributePerObjectUniform() {}
LightStateAttributePerObjectUniform() : mLightManager(nullptr) {}
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)
@ -613,7 +613,7 @@ namespace SceneUtil
class LightManagerCullCallback : public osg::NodeCallback
{
public:
LightManagerCullCallback(LightManager* lightManager) : mLightManager(lightManager) {}
LightManagerCullCallback(LightManager* lightManager) : mLightManager(lightManager), mLastFrameNumber(0) {}
void operator()(osg::Node* node, osg::NodeVisitor* nv) override
{
@ -861,7 +861,7 @@ namespace SceneUtil
if (ffp)
{
initFFP(LightManager::mFFPMaxLights);
initFFP(mFFPMaxLights);
return;
}
@ -903,6 +903,10 @@ namespace SceneUtil
, mLightingMask(copy.mLightingMask)
, mSun(copy.mSun)
, mLightingMethod(copy.mLightingMethod)
, mPointLightRadiusMultiplier(copy.mPointLightRadiusMultiplier)
, mPointLightFadeEnd(copy.mPointLightFadeEnd)
, mPointLightFadeStart(copy.mPointLightFadeStart)
, mMaxLights(copy.mMaxLights)
{
}
@ -1040,7 +1044,7 @@ namespace SceneUtil
auto* stateset = getOrCreateStateSet();
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->addUniform(new osg::Uniform(osg::Uniform::FLOAT_MAT4, "LightBuffer", getMaxLights()));
@ -1049,7 +1053,7 @@ namespace SceneUtil
void LightManager::initSingleUBO(int targetLights)
{
setLightingMethod(LightingMethod::SingleUBO);
setMaxLights(std::clamp(targetLights, mMaxLightsLowerLimit, LightManager::mMaxLightsUpperLimit));
setMaxLights(std::clamp(targetLights, mMaxLightsLowerLimit, mMaxLightsUpperLimit));
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.z = mMouseZ;
pack_evt.zrel = 0;
pack_evt.timestamp = 0;
if(evt.type == SDL_MOUSEMOTION)
{

View file

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