From 02247fe7124367ed0d17fffcf3ae424f61541eb9 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 23 Sep 2014 12:18:18 +0200 Subject: [PATCH 01/30] load and save sound gen records --- apps/opencs/model/doc/saving.cpp | 3 +++ apps/opencs/model/world/data.cpp | 14 ++++++++++++++ apps/opencs/model/world/data.hpp | 6 ++++++ apps/opencs/model/world/universalid.cpp | 2 ++ apps/opencs/model/world/universalid.hpp | 4 +++- components/esm/loadsndg.cpp | 6 ++++++ components/esm/loadsndg.hpp | 2 ++ 7 files changed, 36 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/doc/saving.cpp b/apps/opencs/model/doc/saving.cpp index 9c6932941..9a67a2683 100644 --- a/apps/opencs/model/doc/saving.cpp +++ b/apps/opencs/model/doc/saving.cpp @@ -72,6 +72,9 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje appendStage (new WriteCollectionStage > (mDocument.getData().getBodyParts(), mState)); + appendStage (new WriteCollectionStage > + (mDocument.getData().getSoundGens(), mState)); + appendStage (new WriteDialogueCollectionStage (mDocument, mState, false)); appendStage (new WriteDialogueCollectionStage (mDocument, mState, true)); diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index bb4fa0b43..f349e15dd 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -539,6 +539,16 @@ CSMWorld::IdCollection& CSMWorld::Data::getDebugProfiles() return mDebugProfiles; } +const CSMWorld::IdCollection& CSMWorld::Data::getSoundGens() const +{ + return mSoundGens; +} + +CSMWorld::IdCollection& CSMWorld::Data::getSoundGens() +{ + return mSoundGens; +} + const CSMWorld::Resources& CSMWorld::Data::getResources (const UniversalId& id) const { return mResourcesManager.get (id.getType()); @@ -625,6 +635,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages) case ESM::REC_SPEL: mSpells.load (*mReader, mBase); break; case ESM::REC_ENCH: mEnchantments.load (*mReader, mBase); break; case ESM::REC_BODY: mBodyParts.load (*mReader, mBase); break; + case ESM::REC_SNDG: mSoundGens.load (*mReader, mBase); break; case ESM::REC_CELL: { @@ -775,6 +786,7 @@ bool CSMWorld::Data::hasId (const std::string& id) const getCells().searchId (id)!=-1 || getEnchantments().searchId (id)!=-1 || getBodyParts().searchId (id)!=-1 || + getSoundGens().searchId (id)!=-1 || getReferenceables().searchId (id)!=-1; } @@ -795,6 +807,7 @@ int CSMWorld::Data::count (RecordBase::State state) const count (state, mCells) + count (state, mEnchantments) + count (state, mBodyParts) + + count (state, mSoundGens) + count (state, mReferenceables); } @@ -837,6 +850,7 @@ std::vector CSMWorld::Data::getIds (bool listDeleted) const appendIds (ids, mCells, listDeleted); appendIds (ids, mEnchantments, listDeleted); appendIds (ids, mBodyParts, listDeleted); + appendIds (ids, mSoundGens, listDeleted); appendIds (ids, mReferenceables, listDeleted); std::sort (ids.begin(), ids.end()); diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index d0a07c677..d5f78bb1e 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -71,6 +72,7 @@ namespace CSMWorld IdCollection mEnchantments; IdCollection mBodyParts; IdCollection mDebugProfiles; + IdCollection mSoundGens; InfoCollection mTopicInfos; InfoCollection mJournalInfos; IdCollection mCells; @@ -195,6 +197,10 @@ namespace CSMWorld IdCollection& getDebugProfiles(); + const IdCollection& getSoundGens() const; + + IdCollection& getSoundGens(); + /// Throws an exception, if \a id does not match a resources list. const Resources& getResources (const UniversalId& id) const; diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index 816dbc4fb..948c61894 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -52,6 +52,7 @@ namespace { CSMWorld::UniversalId::Class_ResourceList, CSMWorld::UniversalId::Type_Videos, "Videos", 0 }, { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_DebugProfiles, "Debug Profiles", 0 }, { CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_RunLog, "Run Log", 0 }, + { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_SoundGens, "Sound Gens", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; @@ -112,6 +113,7 @@ namespace { CSMWorld::UniversalId::Class_Resource, CSMWorld::UniversalId::Type_Texture, "Texture", 0 }, { CSMWorld::UniversalId::Class_Resource, CSMWorld::UniversalId::Type_Video, "Video", 0 }, { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_DebugProfile, "Debug Profile", 0 }, + { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_SoundGen, "Sound Gen", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; diff --git a/apps/opencs/model/world/universalid.hpp b/apps/opencs/model/world/universalid.hpp index 069beed4b..3d18d69ea 100644 --- a/apps/opencs/model/world/universalid.hpp +++ b/apps/opencs/model/world/universalid.hpp @@ -122,10 +122,12 @@ namespace CSMWorld Type_Video, Type_DebugProfiles, Type_DebugProfile, + Type_SoundGens, + Type_SoundGen, Type_RunLog }; - enum { NumberOfTypes = Type_DebugProfile+1 }; + enum { NumberOfTypes = Type_RunLog+1 }; private: diff --git a/components/esm/loadsndg.cpp b/components/esm/loadsndg.cpp index 1a8ca6335..9ab061ec2 100644 --- a/components/esm/loadsndg.cpp +++ b/components/esm/loadsndg.cpp @@ -22,4 +22,10 @@ void SoundGenerator::save(ESMWriter &esm) const esm.writeHNOCString("SNAM", mSound); } + void SoundGenerator::blank() + { + mType = LeftFoot; + mCreature.clear(); + mSound.clear(); + } } diff --git a/components/esm/loadsndg.hpp b/components/esm/loadsndg.hpp index 5509661c1..f89a11208 100644 --- a/components/esm/loadsndg.hpp +++ b/components/esm/loadsndg.hpp @@ -36,6 +36,8 @@ struct SoundGenerator void load(ESMReader &esm); void save(ESMWriter &esm) const; + + void blank(); }; } #endif From 7ab4881661748e2e463cbe6df92d48fca8b8028b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 23 Sep 2014 13:21:54 +0200 Subject: [PATCH 02/30] added sound gen table --- apps/opencs/model/world/data.cpp | 5 +++++ apps/opencs/model/world/universalid.cpp | 4 ++-- apps/opencs/view/doc/view.cpp | 9 +++++++++ apps/opencs/view/doc/view.hpp | 2 ++ apps/opencs/view/world/subviews.cpp | 2 ++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index f349e15dd..7bca63277 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -221,6 +221,10 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mBodyParts.addColumn (new ModelColumn); mBodyParts.addColumn (new RaceColumn); + mSoundGens.addColumn (new StringIdColumn); + mSoundGens.addColumn (new RecordStateColumn); + mSoundGens.addColumn (new FixedRecordTypeColumn (UniversalId::Type_SoundGen)); + mRefs.addColumn (new StringIdColumn (true)); mRefs.addColumn (new RecordStateColumn); mRefs.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Reference)); @@ -291,6 +295,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc addModel (new IdTable (&mCells, IdTable::Feature_ViewId), UniversalId::Type_Cell); addModel (new IdTable (&mEnchantments), UniversalId::Type_Enchantment); addModel (new IdTable (&mBodyParts), UniversalId::Type_BodyPart); + addModel (new IdTable (&mSoundGens), UniversalId::Type_SoundGen); addModel (new IdTable (&mReferenceables, IdTable::Feature_Preview), UniversalId::Type_Referenceable); addModel (new IdTable (&mRefs, IdTable::Feature_ViewCell | IdTable::Feature_Preview), UniversalId::Type_Reference); diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index 948c61894..fc7546086 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -52,7 +52,7 @@ namespace { CSMWorld::UniversalId::Class_ResourceList, CSMWorld::UniversalId::Type_Videos, "Videos", 0 }, { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_DebugProfiles, "Debug Profiles", 0 }, { CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_RunLog, "Run Log", 0 }, - { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_SoundGens, "Sound Gens", 0 }, + { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_SoundGens, "Sound Generators", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; @@ -113,7 +113,7 @@ namespace { CSMWorld::UniversalId::Class_Resource, CSMWorld::UniversalId::Type_Texture, "Texture", 0 }, { CSMWorld::UniversalId::Class_Resource, CSMWorld::UniversalId::Type_Video, "Video", 0 }, { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_DebugProfile, "Debug Profile", 0 }, - { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_SoundGen, "Sound Gen", 0 }, + { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_SoundGen, "Sound Generator", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 1ed75b0b4..7a4da6a04 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -215,6 +215,10 @@ void CSVDoc::View::setupAssetsMenu() connect (sounds, SIGNAL (triggered()), this, SLOT (addSoundsSubView())); assets->addAction (sounds); + QAction *soundGens = new QAction (tr ("Sound Generators"), this); + connect (soundGens, SIGNAL (triggered()), this, SLOT (addSoundGensSubView())); + assets->addAction (soundGens); + assets->addSeparator(); // resources follow here QAction *meshes = new QAction (tr ("Meshes"), this); @@ -561,6 +565,11 @@ void CSVDoc::View::addBodyPartsSubView() addSubView (CSMWorld::UniversalId::Type_BodyParts); } +void CSVDoc::View::addSoundGensSubView() +{ + addSubView (CSMWorld::UniversalId::Type_SoundGens); +} + void CSVDoc::View::addMeshesSubView() { addSubView (CSMWorld::UniversalId::Type_Meshes); diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 9b4f2099b..8e97d0beb 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -187,6 +187,8 @@ namespace CSVDoc void addBodyPartsSubView(); + void addSoundGensSubView(); + void addMeshesSubView(); void addIconsSubView(); diff --git a/apps/opencs/view/world/subviews.cpp b/apps/opencs/view/world/subviews.cpp index f86aa34ff..283d15bba 100644 --- a/apps/opencs/view/world/subviews.cpp +++ b/apps/opencs/view/world/subviews.cpp @@ -38,6 +38,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) CSMWorld::UniversalId::Type_Spells, CSMWorld::UniversalId::Type_Enchantments, CSMWorld::UniversalId::Type_BodyParts, + CSMWorld::UniversalId::Type_SoundGens, CSMWorld::UniversalId::Type_None // end marker }; @@ -116,6 +117,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) CSMWorld::UniversalId::Type_Faction, CSMWorld::UniversalId::Type_Enchantment, CSMWorld::UniversalId::Type_BodyPart, + CSMWorld::UniversalId::Type_SoundGen, CSMWorld::UniversalId::Type_None // end marker }; From 33cd04b37d6d1cc2d7c1d4a1d1fdbe8060ebe7c9 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 25 Sep 2014 11:40:45 +0200 Subject: [PATCH 03/30] added missing sound gen table columns --- apps/opencs/model/world/columnbase.hpp | 3 +- apps/opencs/model/world/columnimp.hpp | 82 ++++++++++++++++++++++++++ apps/opencs/model/world/columns.cpp | 9 +++ apps/opencs/model/world/columns.hpp | 2 + apps/opencs/model/world/data.cpp | 3 + apps/opencs/view/doc/viewmanager.cpp | 3 +- 6 files changed, 100 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index 45cb47ba0..85675c8a3 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -101,7 +101,8 @@ namespace CSMWorld Display_Texture, Display_Video, Display_Colour, - Display_ScriptLines // console context + Display_ScriptLines, // console context + Display_SoundGeneratorType }; int mColumnId; diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index b93deccb7..a43be43d4 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -1982,6 +1982,88 @@ namespace CSMWorld return false; } }; + + template + struct SoundColumn : public Column + { + SoundColumn() + : Column (Columns::ColumnId_Sound, ColumnBase::Display_Sound) + {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mSound.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mSound = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct CreatureColumn : public Column + { + CreatureColumn() + : Column (Columns::ColumnId_Creature, ColumnBase::Display_Creature) + {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mCreature.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mCreature = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct SoundGeneratorTypeColumn : public Column + { + SoundGeneratorTypeColumn() + : Column (Columns::ColumnId_SoundGeneratorType, ColumnBase::Display_SoundGeneratorType) + {} + + virtual QVariant get (const Record& record) const + { + return static_cast (record.get().mType); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mType = data.toInt(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + } #endif diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index 90af20059..44d8755c1 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -186,6 +186,8 @@ namespace CSMWorld { ColumnId_GlobalProfile, "Global Profile" }, { ColumnId_RefNumCounter, "RefNum Counter" }, { ColumnId_RefNum, "RefNum" }, + { ColumnId_Creature, "Creature" }, + { ColumnId_SoundGeneratorType, "Sound Generator Type" }, { ColumnId_UseValue1, "Use value 1" }, { ColumnId_UseValue2, "Use value 2" }, @@ -327,6 +329,12 @@ namespace "Skin", "Clothing", "Armour", 0 }; + static const char *sSoundGeneratorType[] = + { + "Left Foot", "Right Foot", "Swim Left", "Swim Right", "Moan", "Roar", "Scream", + "Land", 0 + }; + const char **getEnumNames (CSMWorld::Columns::ColumnId column) { switch (column) @@ -347,6 +355,7 @@ namespace case CSMWorld::Columns::ColumnId_EnchantmentType: return sEnchantmentTypes; case CSMWorld::Columns::ColumnId_BodyPartType: return sBodyPartTypes; case CSMWorld::Columns::ColumnId_MeshType: return sMeshTypes; + case CSMWorld::Columns::ColumnId_SoundGeneratorType: return sSoundGeneratorType; default: return 0; } diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index 5da1765a4..ea8a9200d 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -179,6 +179,8 @@ namespace CSMWorld ColumnId_GlobalProfile = 167, ColumnId_RefNumCounter = 168, ColumnId_RefNum = 169, + ColumnId_Creature = 170, + ColumnId_SoundGeneratorType = 171, // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 7bca63277..b74984c10 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -224,6 +224,9 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mSoundGens.addColumn (new StringIdColumn); mSoundGens.addColumn (new RecordStateColumn); mSoundGens.addColumn (new FixedRecordTypeColumn (UniversalId::Type_SoundGen)); + mSoundGens.addColumn (new CreatureColumn); + mSoundGens.addColumn (new SoundColumn); + mSoundGens.addColumn (new SoundGeneratorTypeColumn); mRefs.addColumn (new StringIdColumn (true)); mRefs.addColumn (new RecordStateColumn); diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 638b42d5f..608762c6c 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -81,7 +81,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) { CSMWorld::ColumnBase::Display_EnchantmentType, CSMWorld::Columns::ColumnId_EnchantmentType, false }, { CSMWorld::ColumnBase::Display_BodyPartType, CSMWorld::Columns::ColumnId_BodyPartType, false }, { CSMWorld::ColumnBase::Display_MeshType, CSMWorld::Columns::ColumnId_MeshType, false }, - { CSMWorld::ColumnBase::Display_Gender, CSMWorld::Columns::ColumnId_Gender, true } + { CSMWorld::ColumnBase::Display_Gender, CSMWorld::Columns::ColumnId_Gender, true }, + { CSMWorld::ColumnBase::Display_SoundGeneratorType, CSMWorld::Columns::ColumnId_SoundGeneratorType, false } }; for (std::size_t i=0; i Date: Thu, 25 Sep 2014 14:16:00 +0200 Subject: [PATCH 04/30] preparing magic effects record for use in OpenCS --- components/esm/loadmgef.cpp | 176 ++++++++++++++++++++++++++++++++++++ components/esm/loadmgef.hpp | 4 + 2 files changed, 180 insertions(+) diff --git a/components/esm/loadmgef.cpp b/components/esm/loadmgef.cpp index 04d55c828..e6951b5c9 100644 --- a/components/esm/loadmgef.cpp +++ b/components/esm/loadmgef.cpp @@ -10,6 +10,157 @@ namespace { + static const char *sIds[ESM::MagicEffect::Length] = + { + "WaterBreathing", + "SwiftSwim", + "WaterWalking", + "Shield", + "FireShield", + "LightningShield", + "FrostShield", + "Burden", + "Feather", + "Jump", + "Levitate", + "SlowFall", + "Lock", + "Open", + "FireDamage", + "ShockDamage", + "FrostDamage", + "DrainAttribute", + "DrainHealth", + "DrainMagicka", + "DrainFatigue", + "DrainSkill", + "DamageAttribute", + "DamageHealth", + "DamageMagicka", + "DamageFatigue", + "DamageSkill", + "Poison", + "WeaknessToFire", + "WeaknessToFrost", + "WeaknessToShock", + "WeaknessToMagicka", + "WeaknessToCommonDisease", + "WeaknessToBlightDisease", + "WeaknessToCorprusDisease", + "WeaknessToPoison", + "WeaknessToNormalWeapons", + "DisintegrateWeapon", + "DisintegrateArmor", + "Invisibility", + "Chameleon", + "Light", + "Sanctuary", + "NightEye", + "Charm", + "Paralyze", + "Silence", + "Blind", + "Sound", + "CalmHumanoid", + "CalmCreature", + "FrenzyHumanoid", + "FrenzyCreature", + "DemoralizeHumanoid", + "DemoralizeCreature", + "RallyHumanoid", + "RallyCreature", + "Dispel", + "Soultrap", + "Telekinesis", + "Mark", + "Recall", + "DivineIntervention", + "AlmsiviIntervention", + "DetectAnimal", + "DetectEnchantment", + "DetectKey", + "SpellAbsorption", + "Reflect", + "CureCommonDisease", + "CureBlightDisease", + "CureCorprusDisease", + "CurePoison", + "CureParalyzation", + "RestoreAttribute", + "RestoreHealth", + "RestoreMagicka", + "RestoreFatigue", + "RestoreSkill", + "FortifyAttribute", + "FortifyHealth", + "FortifyMagicka", + "FortifyFatigue", + "FortifySkill", + "FortifyMaximumMagicka", + "AbsorbAttribute", + "AbsorbHealth", + "AbsorbMagicka", + "AbsorbFatigue", + "AbsorbSkill", + "ResistFire", + "ResistFrost", + "ResistShock", + "ResistMagicka", + "ResistCommonDisease", + "ResistBlightDisease", + "ResistCorprusDisease", + "ResistPoison", + "ResistNormalWeapons", + "ResistParalysis", + "RemoveCurse", + "TurnUndead", + "SummonScamp", + "SummonClannfear", + "SummonDaedroth", + "SummonDremora", + "SummonAncestralGhost", + "SummonSkeletalMinion", + "SummonBonewalker", + "SummonGreaterBonewalker", + "SummonBonelord", + "SummonWingedTwilight", + "SummonHunger", + "SummonGoldenSaint", + "SummonFlameAtronach", + "SummonFrostAtronach", + "SummonStormAtronach", + "FortifyAttack", + "CommandCreature", + "CommandHumanoid", + "BoundDagger", + "BoundLongsword", + "BoundMace", + "BoundBattleAxe", + "BoundSpear", + "BoundLongbow", + "ExtraSpell", + "BoundCuirass", + "BoundHelm", + "BoundBoots", + "BoundShield", + "BoundGloves", + "Corprus", + "Vampirism", + "SummonCenturionSphere", + "SunDamage", + "StuntedMagicka", + + // Tribunal only + "SummonFabricant", + + // Bloodmoon only + "SummonWolf", + "SummonBear", + "SummonBonewolf", + "SummonCreature04", + "SummonCreature05" + }; + const int NumberOfHardcodedFlags = 143; const int HardcodedFlags[NumberOfHardcodedFlags] = { 0x11c8, 0x11c0, 0x11c8, 0x11e0, 0x11e0, 0x11e0, 0x11e0, 0x11d0, @@ -41,6 +192,9 @@ void MagicEffect::load(ESMReader &esm) { esm.getHNT(mIndex, "INDX"); + if (mIndex>=0 && mIndex Date: Fri, 26 Sep 2014 13:05:51 +0200 Subject: [PATCH 05/30] load and save magic effect records --- apps/opencs/model/doc/saving.cpp | 3 +++ apps/opencs/model/world/data.cpp | 20 +++++++++++++++++++- apps/opencs/model/world/data.hpp | 6 ++++++ apps/opencs/model/world/universalid.cpp | 2 ++ apps/opencs/model/world/universalid.hpp | 2 ++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/doc/saving.cpp b/apps/opencs/model/doc/saving.cpp index 9a67a2683..12c4b359b 100644 --- a/apps/opencs/model/doc/saving.cpp +++ b/apps/opencs/model/doc/saving.cpp @@ -75,6 +75,9 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje appendStage (new WriteCollectionStage > (mDocument.getData().getSoundGens(), mState)); + appendStage (new WriteCollectionStage > + (mDocument.getData().getMagicEffects(), mState)); + appendStage (new WriteDialogueCollectionStage (mDocument, mState, false)); appendStage (new WriteDialogueCollectionStage (mDocument, mState, true)); diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index b74984c10..d17f667ab 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -71,7 +71,6 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mGmsts.addColumn (new StringIdColumn); mGmsts.addColumn (new RecordStateColumn); mGmsts.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Gmst)); - mGmsts.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Gmst)); mGmsts.addColumn (new VarTypeColumn (ColumnBase::Display_GmstVarType)); mGmsts.addColumn (new VarValueColumn); @@ -228,6 +227,10 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mSoundGens.addColumn (new SoundColumn); mSoundGens.addColumn (new SoundGeneratorTypeColumn); + mMagicEffects.addColumn (new StringIdColumn); + mMagicEffects.addColumn (new RecordStateColumn); + mMagicEffects.addColumn (new FixedRecordTypeColumn (UniversalId::Type_MagicEffect)); + mRefs.addColumn (new StringIdColumn (true)); mRefs.addColumn (new RecordStateColumn); mRefs.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Reference)); @@ -299,6 +302,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc addModel (new IdTable (&mEnchantments), UniversalId::Type_Enchantment); addModel (new IdTable (&mBodyParts), UniversalId::Type_BodyPart); addModel (new IdTable (&mSoundGens), UniversalId::Type_SoundGen); + addModel (new IdTable (&mMagicEffects), UniversalId::Type_MagicEffect); addModel (new IdTable (&mReferenceables, IdTable::Feature_Preview), UniversalId::Type_Referenceable); addModel (new IdTable (&mRefs, IdTable::Feature_ViewCell | IdTable::Feature_Preview), UniversalId::Type_Reference); @@ -557,6 +561,16 @@ CSMWorld::IdCollection& CSMWorld::Data::getSoundGens() return mSoundGens; } +const CSMWorld::IdCollection& CSMWorld::Data::getMagicEffects() const +{ + return mMagicEffects; +} + +CSMWorld::IdCollection& CSMWorld::Data::getMagicEffects() +{ + return mMagicEffects; +} + const CSMWorld::Resources& CSMWorld::Data::getResources (const UniversalId& id) const { return mResourcesManager.get (id.getType()); @@ -644,6 +658,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages) case ESM::REC_ENCH: mEnchantments.load (*mReader, mBase); break; case ESM::REC_BODY: mBodyParts.load (*mReader, mBase); break; case ESM::REC_SNDG: mSoundGens.load (*mReader, mBase); break; + case ESM::REC_MGEF: mMagicEffects.load (*mReader, mBase); break; case ESM::REC_CELL: { @@ -795,6 +810,7 @@ bool CSMWorld::Data::hasId (const std::string& id) const getEnchantments().searchId (id)!=-1 || getBodyParts().searchId (id)!=-1 || getSoundGens().searchId (id)!=-1 || + getMagicEffects().searchId (id)!=-1 || getReferenceables().searchId (id)!=-1; } @@ -816,6 +832,7 @@ int CSMWorld::Data::count (RecordBase::State state) const count (state, mEnchantments) + count (state, mBodyParts) + count (state, mSoundGens) + + count (state, mMagicEffects) + count (state, mReferenceables); } @@ -859,6 +876,7 @@ std::vector CSMWorld::Data::getIds (bool listDeleted) const appendIds (ids, mEnchantments, listDeleted); appendIds (ids, mBodyParts, listDeleted); appendIds (ids, mSoundGens, listDeleted); + appendIds (ids, mMagicEffects, listDeleted); appendIds (ids, mReferenceables, listDeleted); std::sort (ids.begin(), ids.end()); diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index d5f78bb1e..6862ab51a 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -71,6 +72,7 @@ namespace CSMWorld IdCollection mJournals; IdCollection mEnchantments; IdCollection mBodyParts; + IdCollection mMagicEffects; IdCollection mDebugProfiles; IdCollection mSoundGens; InfoCollection mTopicInfos; @@ -201,6 +203,10 @@ namespace CSMWorld IdCollection& getSoundGens(); + const IdCollection& getMagicEffects() const; + + IdCollection& getMagicEffects(); + /// Throws an exception, if \a id does not match a resources list. const Resources& getResources (const UniversalId& id) const; diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index fc7546086..9f85cca14 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -53,6 +53,7 @@ namespace { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_DebugProfiles, "Debug Profiles", 0 }, { CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_RunLog, "Run Log", 0 }, { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_SoundGens, "Sound Generators", 0 }, + { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_MagicEffects, "Magic Effects", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; @@ -114,6 +115,7 @@ namespace { CSMWorld::UniversalId::Class_Resource, CSMWorld::UniversalId::Type_Video, "Video", 0 }, { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_DebugProfile, "Debug Profile", 0 }, { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_SoundGen, "Sound Generator", 0 }, + { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_MagicEffect, "Magic Effect", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; diff --git a/apps/opencs/model/world/universalid.hpp b/apps/opencs/model/world/universalid.hpp index 3d18d69ea..b244d9e16 100644 --- a/apps/opencs/model/world/universalid.hpp +++ b/apps/opencs/model/world/universalid.hpp @@ -124,6 +124,8 @@ namespace CSMWorld Type_DebugProfile, Type_SoundGens, Type_SoundGen, + Type_MagicEffects, + Type_MagicEffect, Type_RunLog }; From 23fd3142947a7a3d14622d1f4bfaa814f79af07e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 26 Sep 2014 13:12:17 +0200 Subject: [PATCH 06/30] added magic effects table --- apps/opencs/view/doc/view.cpp | 9 +++++++++ apps/opencs/view/doc/view.hpp | 2 ++ apps/opencs/view/world/subviews.cpp | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 7a4da6a04..7e8a6dee0 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -160,6 +160,10 @@ void CSVDoc::View::setupMechanicsMenu() QAction *enchantments = new QAction (tr ("Enchantments"), this); connect (enchantments, SIGNAL (triggered()), this, SLOT (addEnchantmentsSubView())); mechanics->addAction (enchantments); + + QAction *effects = new QAction (tr ("Magic Effects"), this); + connect (effects, SIGNAL (triggered()), this, SLOT (addMagicEffectsSubView())); + mechanics->addAction (effects); } void CSVDoc::View::setupCharacterMenu() @@ -590,6 +594,11 @@ void CSVDoc::View::addSoundsResSubView() addSubView (CSMWorld::UniversalId::Type_SoundsRes); } +void CSVDoc::View::addMagicEffectsSubView() +{ + addSubView (CSMWorld::UniversalId::Type_MagicEffects); +} + void CSVDoc::View::addTexturesSubView() { addSubView (CSMWorld::UniversalId::Type_Textures); diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 8e97d0beb..c81c101e0 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -189,6 +189,8 @@ namespace CSVDoc void addSoundGensSubView(); + void addMagicEffectsSubView(); + void addMeshesSubView(); void addIconsSubView(); diff --git a/apps/opencs/view/world/subviews.cpp b/apps/opencs/view/world/subviews.cpp index 283d15bba..2ce6ea490 100644 --- a/apps/opencs/view/world/subviews.cpp +++ b/apps/opencs/view/world/subviews.cpp @@ -26,6 +26,9 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) manager.add (CSMWorld::UniversalId::Type_Skills, new CSVDoc::SubViewFactoryWithCreator); + manager.add (CSMWorld::UniversalId::Type_MagicEffects, + new CSVDoc::SubViewFactoryWithCreator); + static const CSMWorld::UniversalId::Type sTableTypes[] = { CSMWorld::UniversalId::Type_Globals, @@ -130,6 +133,9 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) manager.add (CSMWorld::UniversalId::Type_Skill, new CSVDoc::SubViewFactoryWithCreator (false)); + manager.add (CSMWorld::UniversalId::Type_MagicEffect, + new CSVDoc::SubViewFactoryWithCreator (false)); + manager.add (CSMWorld::UniversalId::Type_Gmst, new CSVDoc::SubViewFactoryWithCreator (false)); From 850dbb55a537ffebc66db873dd39de946c43aebe Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 26 Sep 2014 13:36:54 +0200 Subject: [PATCH 07/30] improved magic effect IDs --- components/esm/loadmgef.cpp | 29 +++++++++++++++++++++++++++-- components/esm/loadmgef.hpp | 2 ++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/components/esm/loadmgef.cpp b/components/esm/loadmgef.cpp index e6951b5c9..cbdca3e31 100644 --- a/components/esm/loadmgef.cpp +++ b/components/esm/loadmgef.cpp @@ -1,6 +1,7 @@ #include "loadmgef.hpp" #include +#include #include @@ -192,8 +193,7 @@ void MagicEffect::load(ESMReader &esm) { esm.getHNT(mIndex, "INDX"); - if (mIndex>=0 && mIndex=0 && index Date: Sat, 27 Sep 2014 12:26:25 +0200 Subject: [PATCH 08/30] add magic effect records for newly created games --- apps/opencs/model/doc/document.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 9a174d9d5..850b7bc1b 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -2201,6 +2201,18 @@ void CSMDoc::Document::createBase() getData().getTopics().add (record); } + + for (int i=0; i Date: Sat, 27 Sep 2014 12:38:42 +0200 Subject: [PATCH 09/30] make sure magic effects added by expansions are available --- apps/opencs/model/doc/document.cpp | 29 +++++++++++++++++++++++++++++ apps/opencs/model/doc/document.hpp | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 850b7bc1b..4fdfd2e5e 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -2023,6 +2023,7 @@ void CSMDoc::Document::addOptionalGmsts() { ESM::GameSetting gmst; gmst.mId = sFloats[i]; + gmst.blank(); gmst.mValue.setType (ESM::VT_Float); addOptionalGmst (gmst); } @@ -2031,6 +2032,7 @@ void CSMDoc::Document::addOptionalGmsts() { ESM::GameSetting gmst; gmst.mId = sIntegers[i]; + gmst.blank(); gmst.mValue.setType (ESM::VT_Int); addOptionalGmst (gmst); } @@ -2039,6 +2041,7 @@ void CSMDoc::Document::addOptionalGmsts() { ESM::GameSetting gmst; gmst.mId = sStrings[i]; + gmst.blank(); gmst.mValue.setType (ESM::VT_String); gmst.mValue.setString (""); addOptionalGmst (gmst); @@ -2059,6 +2062,7 @@ void CSMDoc::Document::addOptionalGlobals() { ESM::Global global; global.mId = sGlobals[i]; + global.blank(); global.mValue.setType (ESM::VT_Long); if (i==0) @@ -2068,6 +2072,19 @@ void CSMDoc::Document::addOptionalGlobals() } } +void CSMDoc::Document::addOptionalMagicEffects() +{ + for (int i=ESM::MagicEffect::SummonFabricant; i<=ESM::MagicEffect::SummonCreature05; ++i) + { + ESM::MagicEffect effect; + effect.mIndex = i; + effect.mId = ESM::MagicEffect::indexToId (i); + effect.blank(); + + addOptionalMagicEffect (effect); + } +} + void CSMDoc::Document::addOptionalGmst (const ESM::GameSetting& gmst) { if (getData().getGmsts().searchId (gmst.mId)==-1) @@ -2090,6 +2107,17 @@ void CSMDoc::Document::addOptionalGlobal (const ESM::Global& global) } } +void CSMDoc::Document::addOptionalMagicEffect (const ESM::MagicEffect& magicEffect) +{ + if (getData().getMagicEffects().searchId (magicEffect.mId)==-1) + { + CSMWorld::Record record; + record.mBase = magicEffect; + record.mState = CSMWorld::RecordBase::State_BaseOnly; + getData().getMagicEffects().appendRecord (record); + } +} + void CSMDoc::Document::createBase() { static const char *sGlobals[] = @@ -2260,6 +2288,7 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, addOptionalGmsts(); addOptionalGlobals(); + addOptionalMagicEffects(); connect (&mUndoStack, SIGNAL (cleanChanged (bool)), this, SLOT (modificationStateChanged (bool))); diff --git a/apps/opencs/model/doc/document.hpp b/apps/opencs/model/doc/document.hpp index 29235e6e4..c5f6d1006 100644 --- a/apps/opencs/model/doc/document.hpp +++ b/apps/opencs/model/doc/document.hpp @@ -26,6 +26,7 @@ namespace ESM { struct GameSetting; struct Global; + struct MagicEffect; } namespace Files @@ -73,10 +74,14 @@ namespace CSMDoc void addOptionalGlobals(); + void addOptionalMagicEffects(); + void addOptionalGmst (const ESM::GameSetting& gmst); void addOptionalGlobal (const ESM::Global& global); + void addOptionalMagicEffect (const ESM::MagicEffect& effect); + public: Document (const Files::ConfigurationManager& configuration, From e47f9c7268c47d21deecde853739936c9287a934 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 27 Sep 2014 12:51:46 +0200 Subject: [PATCH 10/30] added first batch of magic effect columns (re-using existing columns) --- apps/opencs/model/world/columns.cpp | 2 ++ apps/opencs/model/world/columns.hpp | 2 ++ apps/opencs/model/world/data.cpp | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index 44d8755c1..f2ef0ffc2 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -188,6 +188,8 @@ namespace CSMWorld { ColumnId_RefNum, "RefNum" }, { ColumnId_Creature, "Creature" }, { ColumnId_SoundGeneratorType, "Sound Generator Type" }, + { ColumnId_AllowSpellmaking, "Allow Spellmaking" }, + { ColumnId_AllowEnchanting, "Allow Enchanting" }, { ColumnId_UseValue1, "Use value 1" }, { ColumnId_UseValue2, "Use value 2" }, diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index ea8a9200d..35d888b7e 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -181,6 +181,8 @@ namespace CSMWorld ColumnId_RefNum = 169, ColumnId_Creature = 170, ColumnId_SoundGeneratorType = 171, + ColumnId_AllowSpellmaking = 172, + ColumnId_AllowEnchanting = 173, // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index d17f667ab..da6cbca85 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -231,6 +231,14 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mMagicEffects.addColumn (new RecordStateColumn); mMagicEffects.addColumn (new FixedRecordTypeColumn (UniversalId::Type_MagicEffect)); + mMagicEffects.addColumn (new FlagColumn ( + Columns::ColumnId_AllowSpellmaking, ESM::MagicEffect::AllowSpellmaking)); + mMagicEffects.addColumn (new FlagColumn ( + Columns::ColumnId_AllowEnchanting, ESM::MagicEffect::AllowEnchanting)); + mMagicEffects.addColumn (new FlagColumn ( + Columns::ColumnId_NegativeLight, ESM::MagicEffect::NegativeLight)); + mMagicEffects.addColumn (new DescriptionColumn); + mRefs.addColumn (new StringIdColumn (true)); mRefs.addColumn (new RecordStateColumn); mRefs.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Reference)); From ff530a2e1914fed53463b0cf0bf513ce020d5475 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 30 Sep 2014 12:33:48 +0200 Subject: [PATCH 11/30] added missing magic effect table columns --- apps/opencs/model/world/columnbase.hpp | 3 +- apps/opencs/model/world/columnimp.hpp | 201 +++++++++++++++++++++++++ apps/opencs/model/world/columns.cpp | 17 +++ apps/opencs/model/world/columns.hpp | 12 +- apps/opencs/model/world/data.cpp | 13 +- apps/opencs/view/doc/viewmanager.cpp | 3 +- 6 files changed, 245 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index 85675c8a3..ae09dd88f 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -102,7 +102,8 @@ namespace CSMWorld Display_Video, Display_Colour, Display_ScriptLines, // console context - Display_SoundGeneratorType + Display_SoundGeneratorType, + Display_School }; int mColumnId; diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index a43be43d4..a25e36fc1 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -1,7 +1,9 @@ #ifndef CSM_WOLRD_COLUMNIMP_H #define CSM_WOLRD_COLUMNIMP_H +#include #include +#include #include @@ -2064,6 +2066,205 @@ namespace CSMWorld } }; + template + struct BaseCostColumn : public Column + { + BaseCostColumn() : Column (Columns::ColumnId_BaseCost, ColumnBase::Display_Float) {} + + virtual QVariant get (const Record& record) const + { + return record.get().mData.mBaseCost; + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + record2.mData.mBaseCost = data.toFloat(); + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct SchoolColumn : public Column + { + SchoolColumn() + : Column (Columns::ColumnId_School, ColumnBase::Display_School) + {} + + virtual QVariant get (const Record& record) const + { + return record.get().mData.mSchool; + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mData.mSchool = data.toInt(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct EffectTextureColumn : public Column + { + EffectTextureColumn (Columns::ColumnId columnId) + : Column (columnId, ColumnBase::Display_Texture) + { + assert (this->mColumnId==Columns::ColumnId_Icon || + this->mColumnId==Columns::ColumnId_Particle); + } + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 ( + (this->mColumnId==Columns::ColumnId_Icon ? + record.get().mIcon : record.get().mParticle).c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + (this->mColumnId==Columns::ColumnId_Icon ? + record2.mIcon : record2.mParticle) + = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct EffectObjectColumn : public Column + { + EffectObjectColumn (Columns::ColumnId columnId) + : Column (columnId, columnId==Columns::ColumnId_BoltObject ? ColumnBase::Display_Weapon : ColumnBase::Display_Static) + { + assert (this->mColumnId==Columns::ColumnId_CastingObject || + this->mColumnId==Columns::ColumnId_HitObject || + this->mColumnId==Columns::ColumnId_AreaObject || + this->mColumnId==Columns::ColumnId_BoltObject); + } + + virtual QVariant get (const Record& record) const + { + const std::string *string = 0; + + switch (this->mColumnId) + { + case Columns::ColumnId_CastingObject: string = &record.get().mCasting; break; + case Columns::ColumnId_HitObject: string = &record.get().mHit; break; + case Columns::ColumnId_AreaObject: string = &record.get().mArea; break; + case Columns::ColumnId_BoltObject: string = &record.get().mBolt; break; + } + + if (!string) + throw std::logic_error ("Unsupported column ID"); + + return QString::fromUtf8 (string->c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + std::string *string = 0; + + ESXRecordT record2 = record.get(); + + switch (this->mColumnId) + { + case Columns::ColumnId_CastingObject: string = &record2.mCasting; break; + case Columns::ColumnId_HitObject: string = &record2.mHit; break; + case Columns::ColumnId_AreaObject: string = &record2.mArea; break; + case Columns::ColumnId_BoltObject: string = &record2.mBolt; break; + } + + if (!string) + throw std::logic_error ("Unsupported column ID"); + + *string = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct EffectSoundColumn : public Column + { + EffectSoundColumn (Columns::ColumnId columnId) + : Column (columnId, ColumnBase::Display_Sound) + { + assert (this->mColumnId==Columns::ColumnId_CastingSound || + this->mColumnId==Columns::ColumnId_HitSound || + this->mColumnId==Columns::ColumnId_AreaSound || + this->mColumnId==Columns::ColumnId_BoltSound); + } + + virtual QVariant get (const Record& record) const + { + const std::string *string = 0; + + switch (this->mColumnId) + { + case Columns::ColumnId_CastingSound: string = &record.get().mCastSound; break; + case Columns::ColumnId_HitSound: string = &record.get().mHitSound; break; + case Columns::ColumnId_AreaSound: string = &record.get().mAreaSound; break; + case Columns::ColumnId_BoltSound: string = &record.get().mBoltSound; break; + } + + if (!string) + throw std::logic_error ("Unsupported column ID"); + + return QString::fromUtf8 (string->c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + std::string *string = 0; + + ESXRecordT record2 = record.get(); + + switch (this->mColumnId) + { + case Columns::ColumnId_CastingSound: string = &record2.mCastSound; break; + case Columns::ColumnId_HitSound: string = &record2.mHitSound; break; + case Columns::ColumnId_AreaSound: string = &record2.mAreaSound; break; + case Columns::ColumnId_BoltSound: string = &record2.mBoltSound; break; + } + + if (!string) + throw std::logic_error ("Unsupported column ID"); + + *string = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; } #endif diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index f2ef0ffc2..8349eb515 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -190,6 +190,17 @@ namespace CSMWorld { ColumnId_SoundGeneratorType, "Sound Generator Type" }, { ColumnId_AllowSpellmaking, "Allow Spellmaking" }, { ColumnId_AllowEnchanting, "Allow Enchanting" }, + { ColumnId_BaseCost, "Base Cost" }, + { ColumnId_School, "School" }, + { ColumnId_Particle, "Particle" }, + { ColumnId_CastingObject, "Casting Object" }, + { ColumnId_HitObject, "Hit Object" }, + { ColumnId_AreaObject, "Area Object" }, + { ColumnId_BoltObject, "Bolt Object" }, + { ColumnId_CastingSound, "Casting Sound" }, + { ColumnId_HitSound, "Hit Sound" }, + { ColumnId_AreaSound, "Area Sound" }, + { ColumnId_BoltSound, "Bolt Sound" }, { ColumnId_UseValue1, "Use value 1" }, { ColumnId_UseValue2, "Use value 2" }, @@ -337,6 +348,11 @@ namespace "Land", 0 }; + static const char *sSchools[] = + { + "Alteration", "Conjuration", "Destruction", "Illusion", "Mysticism", "Restoration", 0 + }; + const char **getEnumNames (CSMWorld::Columns::ColumnId column) { switch (column) @@ -358,6 +374,7 @@ namespace case CSMWorld::Columns::ColumnId_BodyPartType: return sBodyPartTypes; case CSMWorld::Columns::ColumnId_MeshType: return sMeshTypes; case CSMWorld::Columns::ColumnId_SoundGeneratorType: return sSoundGeneratorType; + case CSMWorld::Columns::ColumnId_School: return sSchools; default: return 0; } diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index 35d888b7e..ca0326655 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -183,7 +183,17 @@ namespace CSMWorld ColumnId_SoundGeneratorType = 171, ColumnId_AllowSpellmaking = 172, ColumnId_AllowEnchanting = 173, - + ColumnId_BaseCost = 174, + ColumnId_School = 175, + ColumnId_Particle = 176, + ColumnId_CastingObject = 177, + ColumnId_HitObject = 178, + ColumnId_AreaObject = 179, + ColumnId_BoltObject = 180, + ColumnId_CastingSound = 177, + ColumnId_HitSound = 178, + ColumnId_AreaSound = 179, + ColumnId_BoltSound = 180, // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. ColumnId_UseValue1 = 0x10000, diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index da6cbca85..41382fe48 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -230,7 +230,18 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mMagicEffects.addColumn (new StringIdColumn); mMagicEffects.addColumn (new RecordStateColumn); mMagicEffects.addColumn (new FixedRecordTypeColumn (UniversalId::Type_MagicEffect)); - + mMagicEffects.addColumn (new SchoolColumn); + mMagicEffects.addColumn (new BaseCostColumn); + mMagicEffects.addColumn (new EffectTextureColumn (Columns::ColumnId_Icon)); + mMagicEffects.addColumn (new EffectTextureColumn (Columns::ColumnId_Particle)); + mMagicEffects.addColumn (new EffectObjectColumn (Columns::ColumnId_CastingObject)); + mMagicEffects.addColumn (new EffectObjectColumn (Columns::ColumnId_HitObject)); + mMagicEffects.addColumn (new EffectObjectColumn (Columns::ColumnId_AreaObject)); + mMagicEffects.addColumn (new EffectObjectColumn (Columns::ColumnId_BoltObject)); + mMagicEffects.addColumn (new EffectSoundColumn (Columns::ColumnId_CastingSound)); + mMagicEffects.addColumn (new EffectSoundColumn (Columns::ColumnId_HitSound)); + mMagicEffects.addColumn (new EffectSoundColumn (Columns::ColumnId_AreaSound)); + mMagicEffects.addColumn (new EffectSoundColumn (Columns::ColumnId_BoltSound)); mMagicEffects.addColumn (new FlagColumn ( Columns::ColumnId_AllowSpellmaking, ESM::MagicEffect::AllowSpellmaking)); mMagicEffects.addColumn (new FlagColumn ( diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 608762c6c..7a63cb2a7 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -82,7 +82,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) { CSMWorld::ColumnBase::Display_BodyPartType, CSMWorld::Columns::ColumnId_BodyPartType, false }, { CSMWorld::ColumnBase::Display_MeshType, CSMWorld::Columns::ColumnId_MeshType, false }, { CSMWorld::ColumnBase::Display_Gender, CSMWorld::Columns::ColumnId_Gender, true }, - { CSMWorld::ColumnBase::Display_SoundGeneratorType, CSMWorld::Columns::ColumnId_SoundGeneratorType, false } + { CSMWorld::ColumnBase::Display_SoundGeneratorType, CSMWorld::Columns::ColumnId_SoundGeneratorType, false }, + { CSMWorld::ColumnBase::Display_School, CSMWorld::Columns::ColumnId_School, true } }; for (std::size_t i=0; i Date: Thu, 2 Oct 2014 12:30:15 +0200 Subject: [PATCH 12/30] load and save pathgrid records --- apps/opencs/CMakeLists.txt | 1 + apps/opencs/model/doc/saving.cpp | 3 +++ apps/opencs/model/world/data.cpp | 19 ++++++++++++++++++- apps/opencs/model/world/data.hpp | 6 ++++++ apps/opencs/model/world/pathgrid.cpp | 20 ++++++++++++++++++++ apps/opencs/model/world/pathgrid.hpp | 24 ++++++++++++++++++++++++ apps/opencs/model/world/universalid.cpp | 2 ++ apps/opencs/model/world/universalid.hpp | 2 ++ components/esm/loadpgrd.cpp | 10 ++++++++++ components/esm/loadpgrd.hpp | 2 ++ 10 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 apps/opencs/model/world/pathgrid.cpp create mode 100644 apps/opencs/model/world/pathgrid.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 7094f8799..86f44d2b2 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -27,6 +27,7 @@ opencs_units (model/world opencs_units_noqt (model/world universalid record commands columnbase scriptcontext cell refidcollection refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata cellcoordinates cellselection resources resourcesmanager scope + pathgrid ) opencs_hdrs_noqt (model/world diff --git a/apps/opencs/model/doc/saving.cpp b/apps/opencs/model/doc/saving.cpp index 12c4b359b..163d5991f 100644 --- a/apps/opencs/model/doc/saving.cpp +++ b/apps/opencs/model/doc/saving.cpp @@ -78,6 +78,9 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje appendStage (new WriteCollectionStage > (mDocument.getData().getMagicEffects(), mState)); + appendStage (new WriteCollectionStage > + (mDocument.getData().getPathgrids(), mState)); + appendStage (new WriteDialogueCollectionStage (mDocument, mState, false)); appendStage (new WriteDialogueCollectionStage (mDocument, mState, true)); diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 41382fe48..ccf86c5b8 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -250,6 +250,10 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc Columns::ColumnId_NegativeLight, ESM::MagicEffect::NegativeLight)); mMagicEffects.addColumn (new DescriptionColumn); + mPathgrids.addColumn (new StringIdColumn); + mPathgrids.addColumn (new RecordStateColumn); + mPathgrids.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Pathgrid)); + mRefs.addColumn (new StringIdColumn (true)); mRefs.addColumn (new RecordStateColumn); mRefs.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Reference)); @@ -322,6 +326,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc addModel (new IdTable (&mBodyParts), UniversalId::Type_BodyPart); addModel (new IdTable (&mSoundGens), UniversalId::Type_SoundGen); addModel (new IdTable (&mMagicEffects), UniversalId::Type_MagicEffect); + addModel (new IdTable (&mPathgrids), UniversalId::Type_Pathgrid); addModel (new IdTable (&mReferenceables, IdTable::Feature_Preview), UniversalId::Type_Referenceable); addModel (new IdTable (&mRefs, IdTable::Feature_ViewCell | IdTable::Feature_Preview), UniversalId::Type_Reference); @@ -590,6 +595,16 @@ CSMWorld::IdCollection& CSMWorld::Data::getMagicEffects() return mMagicEffects; } +const CSMWorld::IdCollection& CSMWorld::Data::getPathgrids() const +{ + return mPathgrids; +} + +CSMWorld::IdCollection& CSMWorld::Data::getPathgrids() +{ + return mPathgrids; +} + const CSMWorld::Resources& CSMWorld::Data::getResources (const UniversalId& id) const { return mResourcesManager.get (id.getType()); @@ -678,6 +693,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages) case ESM::REC_BODY: mBodyParts.load (*mReader, mBase); break; case ESM::REC_SNDG: mSoundGens.load (*mReader, mBase); break; case ESM::REC_MGEF: mMagicEffects.load (*mReader, mBase); break; + case ESM::REC_PGRD: mPathgrids.load (*mReader, mBase); break; case ESM::REC_CELL: { @@ -852,7 +868,8 @@ int CSMWorld::Data::count (RecordBase::State state) const count (state, mBodyParts) + count (state, mSoundGens) + count (state, mMagicEffects) + - count (state, mReferenceables); + count (state, mReferenceables) + + count (state, mPathgrids); } void CSMWorld::Data::setDescription (const std::string& description) diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index 6862ab51a..cae16128c 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -38,6 +38,7 @@ #include "refidcollection.hpp" #include "refcollection.hpp" #include "infocollection.hpp" +#include "pathgrid.hpp" class QAbstractItemModel; @@ -73,6 +74,7 @@ namespace CSMWorld IdCollection mEnchantments; IdCollection mBodyParts; IdCollection mMagicEffects; + IdCollection mPathgrids; IdCollection mDebugProfiles; IdCollection mSoundGens; InfoCollection mTopicInfos; @@ -207,6 +209,10 @@ namespace CSMWorld IdCollection& getMagicEffects(); + const IdCollection& getPathgrids() const; + + IdCollection& getPathgrids(); + /// Throws an exception, if \a id does not match a resources list. const Resources& getResources (const UniversalId& id) const; diff --git a/apps/opencs/model/world/pathgrid.cpp b/apps/opencs/model/world/pathgrid.cpp new file mode 100644 index 000000000..6226e361a --- /dev/null +++ b/apps/opencs/model/world/pathgrid.cpp @@ -0,0 +1,20 @@ + +#include "pathgrid.hpp" + +#include + +void CSMWorld::Pathgrid::load (ESM::ESMReader &esm) +{ + ESM::Pathgrid::load (esm); + + if (mCell.empty()) + { + std::ostringstream stream; + + stream << "#" << mData.mX << " " << mData.mY; + + mId = stream.str(); + } + else + mId = mCell; +} diff --git a/apps/opencs/model/world/pathgrid.hpp b/apps/opencs/model/world/pathgrid.hpp new file mode 100644 index 000000000..4e4525232 --- /dev/null +++ b/apps/opencs/model/world/pathgrid.hpp @@ -0,0 +1,24 @@ +#ifndef CSM_WOLRD_PATHGRID_H +#define CSM_WOLRD_PATHGRID_H + +#include +#include + +#include + +namespace CSMWorld +{ + /// \brief Wrapper for Pathgrid record + /// + /// \attention The mData.mX and mData.mY fields of the ESM::Pathgrid struct are not used. + /// Exterior cell coordinates are encoded in the pathgrid ID. + struct Pathgrid : public ESM::Pathgrid + { + std::string mId; + + void load (ESM::ESMReader &esm); + + }; +} + +#endif \ No newline at end of file diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index 9f85cca14..f2ed87d61 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -54,6 +54,7 @@ namespace { CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_RunLog, "Run Log", 0 }, { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_SoundGens, "Sound Generators", 0 }, { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_MagicEffects, "Magic Effects", 0 }, + { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Pathgrids, "Pathgrids", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; @@ -116,6 +117,7 @@ namespace { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_DebugProfile, "Debug Profile", 0 }, { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_SoundGen, "Sound Generator", 0 }, { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_MagicEffect, "Magic Effect", 0 }, + { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Pathgrid, "Pathgrid", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; diff --git a/apps/opencs/model/world/universalid.hpp b/apps/opencs/model/world/universalid.hpp index b244d9e16..ce2d021d0 100644 --- a/apps/opencs/model/world/universalid.hpp +++ b/apps/opencs/model/world/universalid.hpp @@ -126,6 +126,8 @@ namespace CSMWorld Type_SoundGen, Type_MagicEffects, Type_MagicEffect, + Type_Pathgrids, + Type_Pathgrid, Type_RunLog }; diff --git a/components/esm/loadpgrd.cpp b/components/esm/loadpgrd.cpp index 974e928d9..7fdc9a43c 100644 --- a/components/esm/loadpgrd.cpp +++ b/components/esm/loadpgrd.cpp @@ -115,4 +115,14 @@ void Pathgrid::save(ESMWriter &esm) const } } + void Pathgrid::blank() + { + mCell.clear(); + mData.mX = 0; + mData.mY = 0; + mData.mS1 = 0; + mData.mS2 = 0; + mPoints.clear(); + mEdges.clear(); + } } diff --git a/components/esm/loadpgrd.hpp b/components/esm/loadpgrd.hpp index 60a736991..256b86cda 100644 --- a/components/esm/loadpgrd.hpp +++ b/components/esm/loadpgrd.hpp @@ -53,6 +53,8 @@ struct Pathgrid void load(ESMReader &esm); void save(ESMWriter &esm) const; + + void blank(); }; } #endif From 00073694c6e195b5e397b9965a59ac96270cd1cc Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 2 Oct 2014 15:16:19 +0200 Subject: [PATCH 13/30] added pathgrid subview --- apps/opencs/view/doc/view.cpp | 9 +++++++++ apps/opencs/view/doc/view.hpp | 2 ++ apps/opencs/view/world/subviews.cpp | 2 ++ 3 files changed, 13 insertions(+) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 7e8a6dee0..03ef71f16 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -130,6 +130,10 @@ void CSVDoc::View::setupWorldMenu() connect (references, SIGNAL (triggered()), this, SLOT (addReferencesSubView())); world->addAction (references); + QAction *grid = new QAction (tr ("Pathgrid"), this); + connect (grid, SIGNAL (triggered()), this, SLOT (addPathgridSubView())); + world->addAction (grid); + world->addSeparator(); // items that don't represent single record lists follow here QAction *regionMap = new QAction (tr ("Region Map"), this); @@ -619,6 +623,11 @@ void CSVDoc::View::addRunLogSubView() addSubView (CSMWorld::UniversalId::Type_RunLog); } +void CSVDoc::View::addPathgridSubView() +{ + addSubView (CSMWorld::UniversalId::Type_Pathgrids); +} + void CSVDoc::View::abortOperation (int type) { mDocument->abortOperation (type); diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index c81c101e0..6c3468389 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -207,6 +207,8 @@ namespace CSVDoc void addRunLogSubView(); + void addPathgridSubView(); + void toggleShowStatusBar (bool show); void loadErrorLog(); diff --git a/apps/opencs/view/world/subviews.cpp b/apps/opencs/view/world/subviews.cpp index 2ce6ea490..c5d969d0d 100644 --- a/apps/opencs/view/world/subviews.cpp +++ b/apps/opencs/view/world/subviews.cpp @@ -42,6 +42,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) CSMWorld::UniversalId::Type_Enchantments, CSMWorld::UniversalId::Type_BodyParts, CSMWorld::UniversalId::Type_SoundGens, + CSMWorld::UniversalId::Type_Pathgrids, CSMWorld::UniversalId::Type_None // end marker }; @@ -121,6 +122,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) CSMWorld::UniversalId::Type_Enchantment, CSMWorld::UniversalId::Type_BodyPart, CSMWorld::UniversalId::Type_SoundGen, + CSMWorld::UniversalId::Type_Pathgrid, CSMWorld::UniversalId::Type_None // end marker }; From be3b229a5f12abc7b847944e92468e10cfbe74a6 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 4 Oct 2014 15:36:52 +0200 Subject: [PATCH 14/30] fixed pathgrid loading --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/world/data.cpp | 8 ++-- apps/opencs/model/world/data.hpp | 7 ++-- apps/opencs/model/world/idcollection.hpp | 11 +++++- apps/opencs/model/world/pathgrid.cpp | 15 ++++++++ apps/opencs/model/world/pathgrid.hpp | 6 ++- apps/opencs/model/world/subcellcollection.hpp | 38 +++++++++++++++++++ 7 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 apps/opencs/model/world/subcellcollection.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 86f44d2b2..c5f0a9028 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -31,7 +31,7 @@ opencs_units_noqt (model/world ) opencs_hdrs_noqt (model/world - columnimp idcollection collection info + columnimp idcollection collection info subcellcollection ) diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index ccf86c5b8..dc8b142a4 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -59,8 +59,8 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec } CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager) -: mEncoder (encoding), mRefs (mCells), mResourcesManager (resourcesManager), mReader (0), - mDialogue (0) +: mEncoder (encoding), mPathgrids (mCells), mRefs (mCells), + mResourcesManager (resourcesManager), mReader (0), mDialogue (0) { mGlobals.addColumn (new StringIdColumn); mGlobals.addColumn (new RecordStateColumn); @@ -595,12 +595,12 @@ CSMWorld::IdCollection& CSMWorld::Data::getMagicEffects() return mMagicEffects; } -const CSMWorld::IdCollection& CSMWorld::Data::getPathgrids() const +const CSMWorld::SubCellCollection& CSMWorld::Data::getPathgrids() const { return mPathgrids; } -CSMWorld::IdCollection& CSMWorld::Data::getPathgrids() +CSMWorld::SubCellCollection& CSMWorld::Data::getPathgrids() { return mPathgrids; } diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index cae16128c..572622ff9 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -39,6 +39,7 @@ #include "refcollection.hpp" #include "infocollection.hpp" #include "pathgrid.hpp" +#include "subcellcollection.hpp" class QAbstractItemModel; @@ -74,7 +75,7 @@ namespace CSMWorld IdCollection mEnchantments; IdCollection mBodyParts; IdCollection mMagicEffects; - IdCollection mPathgrids; + SubCellCollection mPathgrids; IdCollection mDebugProfiles; IdCollection mSoundGens; InfoCollection mTopicInfos; @@ -209,9 +210,9 @@ namespace CSMWorld IdCollection& getMagicEffects(); - const IdCollection& getPathgrids() const; + const SubCellCollection& getPathgrids() const; - IdCollection& getPathgrids(); + SubCellCollection& getPathgrids(); /// Throws an exception, if \a id does not match a resources list. const Resources& getResources (const UniversalId& id) const; diff --git a/apps/opencs/model/world/idcollection.hpp b/apps/opencs/model/world/idcollection.hpp index 940181c24..0129ba3d8 100644 --- a/apps/opencs/model/world/idcollection.hpp +++ b/apps/opencs/model/world/idcollection.hpp @@ -11,6 +11,8 @@ namespace CSMWorld template > class IdCollection : public Collection { + virtual void loadRecord (ESXRecordT& record, ESM::ESMReader& reader); + public: void load (ESM::ESMReader& reader, bool base); @@ -26,6 +28,13 @@ namespace CSMWorld /// \return Has the ID been deleted? }; + template + void IdCollection::loadRecord (ESXRecordT& record, + ESM::ESMReader& reader) + { + record.load (reader); + } + template void IdCollection::load (ESM::ESMReader& reader, bool base) { @@ -69,7 +78,7 @@ namespace CSMWorld record = this->getRecord (index).get(); } - record.load (reader); + loadRecord (record, reader); if (index==-1) { diff --git a/apps/opencs/model/world/pathgrid.cpp b/apps/opencs/model/world/pathgrid.cpp index 6226e361a..1c82585df 100644 --- a/apps/opencs/model/world/pathgrid.cpp +++ b/apps/opencs/model/world/pathgrid.cpp @@ -3,6 +3,21 @@ #include +void CSMWorld::Pathgrid::load (ESM::ESMReader &esm, const IdCollection& cells) +{ + load (esm); + + // correct ID + if (!mId.empty() && mId[0]!='#' && cells.searchId (mId)==-1) + { + std::ostringstream stream; + + stream << "#" << mData.mX << " " << mData.mY; + + mId = stream.str(); + } +} + void CSMWorld::Pathgrid::load (ESM::ESMReader &esm) { ESM::Pathgrid::load (esm); diff --git a/apps/opencs/model/world/pathgrid.hpp b/apps/opencs/model/world/pathgrid.hpp index 4e4525232..3c9fcff50 100644 --- a/apps/opencs/model/world/pathgrid.hpp +++ b/apps/opencs/model/world/pathgrid.hpp @@ -6,6 +6,9 @@ #include +#include "idcollection.hpp" +#include "cell.hpp" + namespace CSMWorld { /// \brief Wrapper for Pathgrid record @@ -16,8 +19,9 @@ namespace CSMWorld { std::string mId; - void load (ESM::ESMReader &esm); + void load (ESM::ESMReader &esm, const IdCollection& cells); + void load (ESM::ESMReader &esm); }; } diff --git a/apps/opencs/model/world/subcellcollection.hpp b/apps/opencs/model/world/subcellcollection.hpp new file mode 100644 index 000000000..28f0de695 --- /dev/null +++ b/apps/opencs/model/world/subcellcollection.hpp @@ -0,0 +1,38 @@ +#ifndef CSM_WOLRD_SUBCOLLECTION_H +#define CSM_WOLRD_SUBCOLLECTION_H + +#include "idcollection.hpp" + +namespace CSMWorld +{ + /// \brief Single type collection of top level records that are associated with cells + template > + class SubCellCollection : public IdCollection + { + const IdCollection& mCells; + + virtual void loadRecord (ESXRecordT& record, ESM::ESMReader& reader); + + public: + + SubCellCollection (const IdCollection& cells); + + + }; + + template + void SubCellCollection::loadRecord (ESXRecordT& record, + ESM::ESMReader& reader) + { + record.load (reader, mCells); + } + + template + SubCellCollection::SubCellCollection ( + const IdCollection& cells) + : mCells (cells) + {} + +} + +#endif From 2d3ffc4483fd2568e9d870ccc3fef5fe6af5fcd1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 5 Oct 2014 15:12:12 +0200 Subject: [PATCH 15/30] fixed pathgrid saving --- apps/opencs/model/doc/saving.cpp | 3 +- apps/opencs/model/doc/savingstages.cpp | 40 ++++++++++++++++++++++++++ apps/opencs/model/doc/savingstages.hpp | 17 +++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/doc/saving.cpp b/apps/opencs/model/doc/saving.cpp index 163d5991f..08a249cfa 100644 --- a/apps/opencs/model/doc/saving.cpp +++ b/apps/opencs/model/doc/saving.cpp @@ -78,8 +78,7 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje appendStage (new WriteCollectionStage > (mDocument.getData().getMagicEffects(), mState)); - appendStage (new WriteCollectionStage > - (mDocument.getData().getPathgrids(), mState)); + appendStage (new WritePathgridCollectionStage (mDocument, mState)); appendStage (new WriteDialogueCollectionStage (mDocument, mState, false)); diff --git a/apps/opencs/model/doc/savingstages.cpp b/apps/opencs/model/doc/savingstages.cpp index d62947df6..0d0805803 100644 --- a/apps/opencs/model/doc/savingstages.cpp +++ b/apps/opencs/model/doc/savingstages.cpp @@ -311,6 +311,46 @@ void CSMDoc::WriteCellCollectionStage::perform (int stage, Messages& messages) } +CSMDoc::WritePathgridCollectionStage::WritePathgridCollectionStage (Document& document, + SavingState& state) +: mDocument (document), mState (state) +{} + +int CSMDoc::WritePathgridCollectionStage::setup() +{ + return mDocument.getData().getPathgrids().getSize(); +} + +void CSMDoc::WritePathgridCollectionStage::perform (int stage, Messages& messages) +{ + const CSMWorld::Record& pathgrid = + mDocument.getData().getPathgrids().getRecord (stage); + + if (pathgrid.mState==CSMWorld::RecordBase::State_Modified || + pathgrid.mState==CSMWorld::RecordBase::State_ModifiedOnly) + { + CSMWorld::Pathgrid record = pathgrid.get(); + + if (record.mId.substr (0, 1)=="#") + { + std::istringstream stream (record.mId.c_str()); + char ignore; + stream >> ignore >> record.mData.mX >> record.mData.mY; + } + + mState.getWriter().startRecord (record.sRecordId); + + record.save (mState.getWriter()); + + mState.getWriter().endRecord (record.sRecordId); + } + else if (pathgrid.mState==CSMWorld::RecordBase::State_Deleted) + { + /// \todo write record with delete flag + } +} + + CSMDoc::CloseSaveStage::CloseSaveStage (SavingState& state) : mState (state) {} diff --git a/apps/opencs/model/doc/savingstages.hpp b/apps/opencs/model/doc/savingstages.hpp index 54e877ef3..87c9ba7eb 100644 --- a/apps/opencs/model/doc/savingstages.hpp +++ b/apps/opencs/model/doc/savingstages.hpp @@ -183,6 +183,23 @@ namespace CSMDoc ///< Messages resulting from this stage will be appended to \a messages. }; + + class WritePathgridCollectionStage : public Stage + { + Document& mDocument; + SavingState& mState; + + public: + + WritePathgridCollectionStage (Document& document, SavingState& state); + + virtual int setup(); + ///< \return number of steps + + virtual void perform (int stage, Messages& messages); + ///< Messages resulting from this stage will be appended to \a messages. + }; + class CloseSaveStage : public Stage { SavingState& mState; From 4adfbd5048ac3ad26afd179a10333fef96c56332 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Thu, 9 Oct 2014 11:59:55 +0200 Subject: [PATCH 16/30] Added obfuscation for email addresses in .mailmap file. Signed-off-by: Lukasz Gromanowski --- .mailmap | 274 +++++++++++++++++++++++++++---------------------------- 1 file changed, 137 insertions(+), 137 deletions(-) diff --git a/.mailmap b/.mailmap index 50ff0928d..b2fab713b 100644 --- a/.mailmap +++ b/.mailmap @@ -1,139 +1,139 @@ -Adam Hogan -Aleksandar Jovanov -Alexander Olofsson -Alex McKibben -Alex "rainChu" Haddad -Ardekantur -Armin Preiml -Artem Kotsynyak -Arthur Moore -Arthur Moore -athile -athile -Stefan Galowicz -Bret Curtis -Britt Mathis -Sandy Carter -Sandy Carter -Carl Maxwell -cc9cii -Cory F. Cohen -Chris Robinson -Cris Mihalache -darkf -Diggory Hardy -Thomas Luppi -Thomas Luppi -Dmitriy 'Endorph' Shkurskiy -Dmitry Marakasov -Douglas Diniz -Douglas Mencken -Edmondo Tommasina -Eduard Cot -Eli2 -Emanuel Guével -Leon Saunders -Fil Krynicki -John Blomberg -Gašper Sedej -Michał Bień -Joel Graff -Paul McElroy -Artem Kotsynyak -Artem Kotsynyak -gugus -guidoj -gus -Hallfaer Tuilinn -Julian Ospald -Jacob Essex -Jan Borsodi -Jan-Peter Nilsson -Jason Hooks -Jason Hooks -Jason Hooks -Jeffrey Haines -Jeffrey Haines -Jordan Ayers -Jordan Milne -Josua Grawitter -Julien Voisin -Karl-Felix Glatzer -Chris Robinson -Kevin Poitra -Roman Proskuryakov -Lars Söderberg -lazydev -lazydev -Lukasz Gromanowski -Marc Bouvier -Marcin Hulist -Marc Zinnschlag -Marek Kochanowicz -Marek Kochanowicz -Marek Kochanowicz -Mark Siewert -Mark Siewert -megaton <9megaton6@gmail.com> -Michael Mc Donnell -Michael Papageorgiou -Michal Sciubidlo -Michał Ściubidło -Nathan Jeffords -Nicolay Korslund -Nicolay Korslund -Nikolay Kasyanov -pchan3 -Pieter van der Kloet -Mateusz Kołaczek -Bret Curtis -Pieter van der Kloet -Rohit Nirmal -Roman Melnik -Radu-Marius Popovici -Sandy Carter -Scott Howard -Jannik Heller -Jannik Heller -Sebastian Wick -Sebastian Wick -Sergey Shambir -sergoz -Chris Boyce -Star-Demon -Sylvain Thesnieres -Thomas Luppi -Thomas Luppi -Thoronador -TomKoenderink -Tom Mason -Torben Carrington -Vincent Heuken -Manuel Edelmann -Manuel Edelmann -Alexander Nadeau -Michael Hogan -Jacob Essex -Yuri Krupenin -Bret Curtis +Adam Hogan +Aleksandar Jovanov +Alexander Olofsson +Alex McKibben +Alex "rainChu" Haddad +Ardekantur +Armin Preiml +Artem Kotsynyak +Arthur Moore +Arthur Moore +athile +athile +Stefan Galowicz +Bret Curtis +Britt Mathis +Sandy Carter +Sandy Carter +Carl Maxwell +cc9cii +Cory F. Cohen +Chris Robinson +Cris Mihalache +darkf +Diggory Hardy +Thomas Luppi +Thomas Luppi +Dmitriy 'Endorph' Shkurskiy +Dmitry Marakasov +Douglas Diniz +Douglas Mencken +Edmondo Tommasina +Eduard Cot +Eli2 +Emanuel Guével +Leon Saunders +Fil Krynicki +John Blomberg +Gašper Sedej +Michał Bień +Joel Graff +Paul McElroy +Artem Kotsynyak +Artem Kotsynyak +gugus +guidoj +gus +Hallfaer Tuilinn +Julian Ospald +Jacob Essex +Jan Borsodi +Jan-Peter Nilsson +Jason Hooks +Jason Hooks +Jason Hooks +Jeffrey Haines +Jeffrey Haines +Jordan Ayers +Jordan Milne +Josua Grawitter +Julien Voisin +Karl-Felix Glatzer +Chris Robinson +Kevin Poitra +Roman Proskuryakov +Lars Söderberg +lazydev +lazydev +Lukasz Gromanowski +Marc Bouvier +Marcin Hulist +Marc Zinnschlag +Marek Kochanowicz +Marek Kochanowicz +Marek Kochanowicz +Mark Siewert +Mark Siewert +megaton <9megaton6+openmw-mailmap!gmail.com> +Michael Mc Donnell +Michael Papageorgiou +Michal Sciubidlo +Michał Ściubidło +Nathan Jeffords +Nicolay Korslund +Nicolay Korslund +Nikolay Kasyanov +pchan3 +Pieter van der Kloet +Mateusz Kołaczek +Bret Curtis +Pieter van der Kloet +Rohit Nirmal +Roman Melnik +Radu-Marius Popovici +Sandy Carter +Scott Howard +Jannik Heller +Jannik Heller +Sebastian Wick +Sebastian Wick +Sergey Shambir +sergoz +Chris Boyce +Star-Demon +Sylvain Thesnieres +Thomas Luppi +Thomas Luppi +Thoronador +TomKoenderink +Tom Mason +Torben Carrington +Vincent Heuken +Manuel Edelmann +Manuel Edelmann +Alexander Nadeau +Michael Hogan +Jacob Essex +Yuri Krupenin +Bret Curtis -sirherrbatka -sirherrbatka -sergei -riothamus -nobrakal -nkorslund -mrcheko -Miroslav Puda -MiroslavR -mckibbenta -jeaye -eroen -eroen -dreamer-dead -crysthala -Berulacks -Axujen -root -unknown +sirherrbatka +sirherrbatka +sergei +riothamus +nobrakal +nkorslund +mrcheko +Miroslav Puda +MiroslavR +mckibbenta +jeaye +eroen +eroen +dreamer-dead +crysthala +Berulacks +Axujen +root +unknown From 136f1952c9f82cda7cbba48f7464269969bef414 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Thu, 9 Oct 2014 12:04:09 +0200 Subject: [PATCH 17/30] Completly removed .mailmap file. Signed-off-by: Lukasz Gromanowski --- .mailmap | 139 ------------------------------------------------------- 1 file changed, 139 deletions(-) delete mode 100644 .mailmap diff --git a/.mailmap b/.mailmap deleted file mode 100644 index b2fab713b..000000000 --- a/.mailmap +++ /dev/null @@ -1,139 +0,0 @@ -Adam Hogan -Aleksandar Jovanov -Alexander Olofsson -Alex McKibben -Alex "rainChu" Haddad -Ardekantur -Armin Preiml -Artem Kotsynyak -Arthur Moore -Arthur Moore -athile -athile -Stefan Galowicz -Bret Curtis -Britt Mathis -Sandy Carter -Sandy Carter -Carl Maxwell -cc9cii -Cory F. Cohen -Chris Robinson -Cris Mihalache -darkf -Diggory Hardy -Thomas Luppi -Thomas Luppi -Dmitriy 'Endorph' Shkurskiy -Dmitry Marakasov -Douglas Diniz -Douglas Mencken -Edmondo Tommasina -Eduard Cot -Eli2 -Emanuel Guével -Leon Saunders -Fil Krynicki -John Blomberg -Gašper Sedej -Michał Bień -Joel Graff -Paul McElroy -Artem Kotsynyak -Artem Kotsynyak -gugus -guidoj -gus -Hallfaer Tuilinn -Julian Ospald -Jacob Essex -Jan Borsodi -Jan-Peter Nilsson -Jason Hooks -Jason Hooks -Jason Hooks -Jeffrey Haines -Jeffrey Haines -Jordan Ayers -Jordan Milne -Josua Grawitter -Julien Voisin -Karl-Felix Glatzer -Chris Robinson -Kevin Poitra -Roman Proskuryakov -Lars Söderberg -lazydev -lazydev -Lukasz Gromanowski -Marc Bouvier -Marcin Hulist -Marc Zinnschlag -Marek Kochanowicz -Marek Kochanowicz -Marek Kochanowicz -Mark Siewert -Mark Siewert -megaton <9megaton6+openmw-mailmap!gmail.com> -Michael Mc Donnell -Michael Papageorgiou -Michal Sciubidlo -Michał Ściubidło -Nathan Jeffords -Nicolay Korslund -Nicolay Korslund -Nikolay Kasyanov -pchan3 -Pieter van der Kloet -Mateusz Kołaczek -Bret Curtis -Pieter van der Kloet -Rohit Nirmal -Roman Melnik -Radu-Marius Popovici -Sandy Carter -Scott Howard -Jannik Heller -Jannik Heller -Sebastian Wick -Sebastian Wick -Sergey Shambir -sergoz -Chris Boyce -Star-Demon -Sylvain Thesnieres -Thomas Luppi -Thomas Luppi -Thoronador -TomKoenderink -Tom Mason -Torben Carrington -Vincent Heuken -Manuel Edelmann -Manuel Edelmann -Alexander Nadeau -Michael Hogan -Jacob Essex -Yuri Krupenin -Bret Curtis - -sirherrbatka -sirherrbatka -sergei -riothamus -nobrakal -nkorslund -mrcheko -Miroslav Puda -MiroslavR -mckibbenta -jeaye -eroen -eroen -dreamer-dead -crysthala -Berulacks -Axujen -root -unknown - From 23e969eae708b67a7d94edb1e1d565d12c425cf5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 10 Oct 2014 15:29:21 +0200 Subject: [PATCH 18/30] fixed pathgrid saving again (previous fix was incomplete) --- apps/opencs/model/doc/saving.cpp | 4 ++-- apps/opencs/model/doc/savingstages.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/doc/saving.cpp b/apps/opencs/model/doc/saving.cpp index 08a249cfa..70e9e1d87 100644 --- a/apps/opencs/model/doc/saving.cpp +++ b/apps/opencs/model/doc/saving.cpp @@ -78,8 +78,6 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje appendStage (new WriteCollectionStage > (mDocument.getData().getMagicEffects(), mState)); - appendStage (new WritePathgridCollectionStage (mDocument, mState)); - appendStage (new WriteDialogueCollectionStage (mDocument, mState, false)); appendStage (new WriteDialogueCollectionStage (mDocument, mState, true)); @@ -90,6 +88,8 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje appendStage (new WriteCellCollectionStage (mDocument, mState)); + appendStage (new WritePathgridCollectionStage (mDocument, mState)); + // close file and clean up appendStage (new CloseSaveStage (mState)); diff --git a/apps/opencs/model/doc/savingstages.cpp b/apps/opencs/model/doc/savingstages.cpp index 0d0805803..08f8c9eaa 100644 --- a/apps/opencs/model/doc/savingstages.cpp +++ b/apps/opencs/model/doc/savingstages.cpp @@ -337,6 +337,8 @@ void CSMDoc::WritePathgridCollectionStage::perform (int stage, Messages& message char ignore; stream >> ignore >> record.mData.mX >> record.mData.mY; } + else + record.mCell = record.mId; mState.getWriter().startRecord (record.sRecordId); From f0d3fc73d5d052fe6345a948918cd343432d3db9 Mon Sep 17 00:00:00 2001 From: Thoronador Date: Fri, 10 Oct 2014 23:47:27 +0200 Subject: [PATCH 19/30] fix uninitialized pointer fields in GraphicsPage class --- apps/launcher/graphicspage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 638237f34..1c6e69023 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -33,7 +33,11 @@ QString getAspect(int x, int y) } Launcher::GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSetting, QWidget *parent) - : mCfgMgr(cfg) + : mOgre(NULL) + , mSelectedRenderSystem(NULL) + , mOpenGLRenderSystem(NULL) + , mDirect3DRenderSystem(NULL) + , mCfgMgr(cfg) , mGraphicsSettings(graphicsSetting) , QWidget(parent) { From deb6452e0d31eb5c9cd8117831473d1f83b1ec71 Mon Sep 17 00:00:00 2001 From: Thoronador Date: Fri, 10 Oct 2014 23:57:10 +0200 Subject: [PATCH 20/30] fix uninitialized pointer fields in CS::Editor class --- apps/opencs/editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index de3e23965..fb185e426 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -21,7 +21,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) : mUserSettings (mCfgMgr), mDocumentManager (mCfgMgr), mViewManager (mDocumentManager), - mIpcServerName ("org.openmw.OpenCS") + mIpcServerName ("org.openmw.OpenCS"), mServer(NULL), mClientSocket(NULL) { std::pair > config = readConfig(); From a799353f60ee5b51c6337fa55b79e1b55bb5af3b Mon Sep 17 00:00:00 2001 From: Thoronador Date: Sat, 11 Oct 2014 00:06:50 +0200 Subject: [PATCH 21/30] fix uninitialized fields in CSMDoc::Operation class --- apps/opencs/model/doc/operation.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/doc/operation.cpp b/apps/opencs/model/doc/operation.cpp index 533ee20a9..7f77e8ac9 100644 --- a/apps/opencs/model/doc/operation.cpp +++ b/apps/opencs/model/doc/operation.cpp @@ -27,7 +27,9 @@ void CSMDoc::Operation::prepareStages() } CSMDoc::Operation::Operation (int type, bool ordered, bool finalAlways) -: mType (type), mOrdered (ordered), mFinalAlways (finalAlways) +: mType (type), mStages(std::vector >()), mCurrentStage(mStages.begin()), + mCurrentStep(0), mCurrentStepTotal(0), mTotalSteps(0), mOrdered (ordered), + mFinalAlways (finalAlways), mError(false) { connect (this, SIGNAL (finished()), this, SLOT (operationDone())); } @@ -120,4 +122,4 @@ void CSMDoc::Operation::executeStage() void CSMDoc::Operation::operationDone() { emit done (mType, mError); -} \ No newline at end of file +} From 51cd2bb5d9f8e38c8b1c4ebabebbd243b837a111 Mon Sep 17 00:00:00 2001 From: Thoronador Date: Sat, 11 Oct 2014 00:15:36 +0200 Subject: [PATCH 22/30] remove unused/double variable from CSMWorld::Column class --- apps/opencs/model/world/columnbase.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index ae09dd88f..db9b8b3c6 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -127,8 +127,6 @@ namespace CSMWorld template struct Column : public ColumnBase { - int mFlags; - Column (int columnId, Display displayType, int flags = Flag_Table | Flag_Dialogue) : ColumnBase (columnId, displayType, flags) {} From ab364c944037975e4be9f400c9a8f4fe8f8f14f9 Mon Sep 17 00:00:00 2001 From: Thoronador Date: Sat, 11 Oct 2014 00:50:32 +0200 Subject: [PATCH 23/30] fix some more uninitialized class member fields --- apps/opencs/view/render/pagedworldspacewidget.cpp | 3 ++- apps/opencs/view/render/scenewidget.cpp | 8 +++++--- apps/opencs/view/render/worldspacewidget.cpp | 2 +- apps/opencs/view/settings/settingwindow.cpp | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index a66a1bb7e..aa74d4c91 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -148,7 +148,8 @@ std::string CSVRender::PagedWorldspaceWidget::getStartupInstruction() } CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document) -: WorldspaceWidget (document, parent), mDocument (document), mWorldspace ("std::default") +: WorldspaceWidget (document, parent), mDocument (document), mWorldspace ("std::default"), + mControlElements(NULL) { QAbstractItemModel *cells = document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 5ddb5e084..53599c3cb 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -22,10 +22,12 @@ namespace CSVRender { SceneWidget::SceneWidget(QWidget *parent) : QWidget(parent) - , mWindow(NULL) , mCamera(NULL) - , mSceneMgr(NULL), mNavigation (0), mLighting (0), mUpdate (false) - , mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false) + , mSceneMgr(NULL) + , mWindow(NULL) + , mViewport(NULL) + , mNavigation (0), mLighting (0), mUpdate (false), mKeyForward (false) + , mKeyBackward (false), mKeyLeft (false), mKeyRight (false) , mKeyRollLeft (false), mKeyRollRight (false) , mFast (false), mDragging (false), mMod1 (false) , mFastFactor (4) diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index fa304dd82..75ea4f46e 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -19,7 +19,7 @@ #include "elements.hpp" CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent) -: SceneWidget (parent), mDocument(document), mRun (0) +: SceneWidget (parent), mDocument(document), mSceneElements(0), mRun(0) { setAcceptDrops(true); diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index 590b6f7a5..4570a96db 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -9,7 +9,7 @@ #include "view.hpp" CSVSettings::SettingWindow::SettingWindow(QWidget *parent) - : QMainWindow(parent) + : QMainWindow(parent), mModel(NULL) {} void CSVSettings::SettingWindow::createPages() @@ -84,7 +84,7 @@ void CSVSettings::SettingWindow::createConnections void CSVSettings::SettingWindow::setViewValues() { - //iterate each page and view, setting their definintions + //iterate each page and view, setting their definitions //if they exist in the model foreach (const Page *page, mPages) { From a5245d5a139e0a7657c18296bdb9d10b2eca17a4 Mon Sep 17 00:00:00 2001 From: Thoronador Date: Sat, 11 Oct 2014 00:56:57 +0200 Subject: [PATCH 24/30] remove unused dummy variable --- apps/openmw/mwgui/hud.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/mwgui/hud.hpp b/apps/openmw/mwgui/hud.hpp index b41a374b6..ca68d907a 100644 --- a/apps/openmw/mwgui/hud.hpp +++ b/apps/openmw/mwgui/hud.hpp @@ -74,8 +74,6 @@ namespace MWGui MyGUI::TextBox* mWeaponSpellBox; MyGUI::Widget *mDrowningFrame, *mDrowningFlash; - MyGUI::Widget* mDummy; - MyGUI::Widget* mFpsBox; MyGUI::TextBox* mFpsCounter; MyGUI::TextBox* mTriangleCounter; From db381088019197729f2e35a26bbd541dd4a7f366 Mon Sep 17 00:00:00 2001 From: Thoronador Date: Sat, 11 Oct 2014 01:20:33 +0200 Subject: [PATCH 25/30] fix uninitialized pointer variables in some classes --- apps/openmw/mwgui/inventorywindow.cpp | 2 ++ apps/openmw/mwgui/mainmenu.cpp | 3 ++- apps/openmw/mwgui/spellcreationdialog.cpp | 4 ++++ apps/openmw/mwgui/windowmanagerimp.cpp | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 2786f6bd3..d1eeba157 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -39,6 +39,8 @@ namespace MWGui , mPreviewDirty(true) , mPreviewResize(true) , mDragAndDrop(dragAndDrop) + , mSortModel(NULL) + , mTradeModel(NULL) , mSelectedItem(-1) , mGuiMode(GM_Inventory) { diff --git a/apps/openmw/mwgui/mainmenu.cpp b/apps/openmw/mwgui/mainmenu.cpp index 81b082568..bb003c481 100644 --- a/apps/openmw/mwgui/mainmenu.cpp +++ b/apps/openmw/mwgui/mainmenu.cpp @@ -29,6 +29,7 @@ namespace MWGui , mButtonBox(0), mWidth (w), mHeight (h) , mSaveGameDialog(NULL) , mBackground(NULL) + , mVideoBackground(NULL) , mVideo(NULL) { getWidget(mVersionText, "VersionText"); @@ -43,7 +44,7 @@ namespace MWGui rev = rev.substr(0,10); sstream << "\nRevision: " << rev; } - + std::string output = sstream.str(); mVersionText->setCaption(output); diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index e2fac9d6d..00cab6c45 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -447,8 +447,12 @@ namespace MWGui EffectEditorBase::EffectEditorBase(Type type) : mAddEffectDialog() + , mAvailableEffectsList(NULL) + , mUsedEffectsView(NULL) , mSelectAttributeDialog(NULL) , mSelectSkillDialog(NULL) + , mSelectedEffect(0) + , mSelectedKnownEffectId(0) , mType(type) { mAddEffectDialog.eventEffectAdded += MyGUI::newDelegate(this, &EffectEditorBase::onEffectAdded); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 16295d3a5..f5d33e43c 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -123,6 +123,7 @@ namespace MWGui , mScreenFader(NULL) , mDebugWindow(NULL) , mTranslationDataStorage (translationDataStorage) + , mSoftwareCursor(NULL) , mCharGen(NULL) , mInputBlocker(NULL) , mCrosshairEnabled(Settings::Manager::getBool ("crosshair", "HUD")) From 13a0c5624c6dd5126b66b6f302ffe9080d132419 Mon Sep 17 00:00:00 2001 From: Thoronador Date: Sat, 11 Oct 2014 01:35:12 +0200 Subject: [PATCH 26/30] fix uninitialized member variables in OcclusionQuery class --- apps/openmw/mwrender/occlusionquery.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwrender/occlusionquery.cpp b/apps/openmw/mwrender/occlusionquery.cpp index 92a49acc0..2693d68b2 100644 --- a/apps/openmw/mwrender/occlusionquery.cpp +++ b/apps/openmw/mwrender/occlusionquery.cpp @@ -19,14 +19,14 @@ using namespace Ogre; OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNode* sunNode) : mSunTotalAreaQuery(0), mSunVisibleAreaQuery(0), mActiveQuery(0), - mDoQuery(0), mSunVisibility(0), + mBBQueryVisible(0), mBBQueryTotal(0), mSunNode(sunNode), mBBNodeReal(0), + mSunVisibility(0), mWasVisible(false), mActive(false), - mFirstFrame(true) + mFirstFrame(true), + mDoQuery(0), + mRendering(renderer) { - mRendering = renderer; - mSunNode = sunNode; - try { RenderSystem* renderSystem = Root::getSingleton().getRenderSystem(); From 8361019456e0d769a43090e275991784afb3c480 Mon Sep 17 00:00:00 2001 From: Thoronador Date: Sat, 11 Oct 2014 02:14:40 +0200 Subject: [PATCH 27/30] fix uninitialized (pointer) vars in more classes --- apps/openmw/mwrender/shadows.cpp | 3 +-- apps/openmw/mwrender/sky.cpp | 2 ++ apps/openmw/mwworld/store.hpp | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/shadows.cpp b/apps/openmw/mwrender/shadows.cpp index 596c6697a..5a6ccaca6 100644 --- a/apps/openmw/mwrender/shadows.cpp +++ b/apps/openmw/mwrender/shadows.cpp @@ -20,10 +20,9 @@ using namespace Ogre; using namespace MWRender; Shadows::Shadows(OEngine::Render::OgreRenderer* rend) : + mRendering(rend), mSceneMgr(rend->getScene()), mPSSMSetup(NULL), mShadowFar(1000), mFadeStart(0.9) { - mRendering = rend; - mSceneMgr = mRendering->getScene(); recreate(); } diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 8e7bd3d89..ccef74efb 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -69,6 +69,7 @@ BillboardObject::BillboardObject( const String& textureName, } BillboardObject::BillboardObject() +: mNode(NULL), mMaterial(NULL), mEntity(NULL) { } @@ -222,6 +223,7 @@ SkyManager::SkyManager(Ogre::SceneNode *root, Ogre::Camera *pCamera) , mCloudOpacity(0.0f) , mCloudSpeed(0.0f) , mStarsOpacity(0.0f) + , mLightning(NULL) , mRemainingTransitionTime(0.0f) , mGlareFade(0.0f) , mGlare(0.0f) diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 9a442387b..107db68b1 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -590,6 +590,7 @@ namespace MWWorld typedef SharedIterator iterator; Store() + : mEsmStore(NULL) {} const ESM::Cell *search(const std::string &id) const { From 138e3032cedf0f5d424475ea2f6606fbf332bc8d Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 11 Oct 2014 10:07:01 +0400 Subject: [PATCH 28/30] Fix: initialize boolean field with boolean value, not NULL --- apps/openmw/mwgui/container.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 7aac65bd3..58f23c175 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -34,7 +34,7 @@ namespace MWGui , mSourceModel(NULL) , mSourceView(NULL) , mSourceSortModel(NULL) - , mIsOnDragAndDrop(NULL) + , mIsOnDragAndDrop(false) { } From f29a71b498beb7efaab3b9db432d3edaf8093872 Mon Sep 17 00:00:00 2001 From: Thoronador Date: Sat, 11 Oct 2014 12:54:15 +0200 Subject: [PATCH 29/30] remove unused var. mSoftwareCursor in WindowManager --- apps/openmw/mwgui/windowmanagerimp.cpp | 1 - apps/openmw/mwgui/windowmanagerimp.hpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index f5d33e43c..16295d3a5 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -123,7 +123,6 @@ namespace MWGui , mScreenFader(NULL) , mDebugWindow(NULL) , mTranslationDataStorage (translationDataStorage) - , mSoftwareCursor(NULL) , mCharGen(NULL) , mInputBlocker(NULL) , mCrosshairEnabled(Settings::Manager::getBool ("crosshair", "HUD")) diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 1dae77641..d473988f9 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -79,7 +79,6 @@ namespace MWGui class SpellCreationDialog; class EnchantingDialog; class TrainingWindow; - class Cursor; class SpellIcons; class MerchantRepair; class Repair; @@ -392,7 +391,6 @@ namespace MWGui DebugWindow* mDebugWindow; Translation::Storage& mTranslationDataStorage; - Cursor* mSoftwareCursor; CharacterCreation* mCharGen; From a0dbb40c8e0e7f045d2aff10ce919d171a7984eb Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 11 Oct 2014 14:48:52 +0200 Subject: [PATCH 30/30] Allow script names starting with digits (Fixes #1730) --- components/compiler/fileparser.cpp | 1 + components/compiler/scanner.cpp | 20 +++++++++++++++----- components/compiler/scanner.hpp | 4 ++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/components/compiler/fileparser.cpp b/components/compiler/fileparser.cpp index e90e9a8f6..37ad1f258 100644 --- a/components/compiler/fileparser.cpp +++ b/components/compiler/fileparser.cpp @@ -65,6 +65,7 @@ namespace Compiler if (mState==BeginState && keyword==Scanner::K_begin) { mState = NameState; + scanner.allowNameStartingwithDigit(); return true; } diff --git a/components/compiler/scanner.cpp b/components/compiler/scanner.cpp index dd8fb431b..e73477ee7 100644 --- a/components/compiler/scanner.cpp +++ b/components/compiler/scanner.cpp @@ -48,6 +48,9 @@ namespace Compiler bool Scanner::scanToken (Parser& parser) { + bool allowDigit = mNameStartingWithDigit; + mNameStartingWithDigit = false; + switch (mPutback) { case Putback_Special: @@ -112,6 +115,7 @@ namespace Compiler else if (isWhitespace (c)) { mLoc.mLiteral.clear(); + mNameStartingWithDigit = allowDigit; return true; } else if (c==':') @@ -120,21 +124,21 @@ namespace Compiler mLoc.mLiteral.clear(); return true; } - else if (std::isdigit (c)) + else if (std::isalpha (c) || c=='_' || c=='"' || (allowDigit && std::isdigit (c))) { bool cont = false; - if (scanInt (c, parser, cont)) + if (scanName (c, parser, cont)) { mLoc.mLiteral.clear(); return cont; } } - else if (std::isalpha (c) || c=='_' || c=='"') + else if (std::isdigit (c)) { bool cont = false; - if (scanName (c, parser, cont)) + if (scanInt (c, parser, cont)) { mLoc.mLiteral.clear(); return cont; @@ -516,7 +520,8 @@ namespace Compiler Scanner::Scanner (ErrorHandler& errorHandler, std::istream& inputStream, const Extensions *extensions) : mErrorHandler (errorHandler), mStream (inputStream), mExtensions (extensions), - mPutback (Putback_None), mPutbackCode(0), mPutbackInteger(0), mPutbackFloat(0) + mPutback (Putback_None), mPutbackCode(0), mPutbackInteger(0), mPutbackFloat(0), + mNameStartingWithDigit (false) { } @@ -568,4 +573,9 @@ namespace Compiler if (mExtensions) mExtensions->listKeywords (keywords); } + + void Scanner::allowNameStartingwithDigit() + { + mNameStartingWithDigit = true; + } } diff --git a/components/compiler/scanner.hpp b/components/compiler/scanner.hpp index 7f6609f76..349a8afb6 100644 --- a/components/compiler/scanner.hpp +++ b/components/compiler/scanner.hpp @@ -37,6 +37,7 @@ namespace Compiler float mPutbackFloat; std::string mPutbackName; TokenLoc mPutbackLoc; + bool mNameStartingWithDigit; public: @@ -122,6 +123,9 @@ namespace Compiler void listKeywords (std::vector& keywords); ///< Append all known keywords to \a kaywords. + + /// For the next token allow names to start with a digit. + void allowNameStartingwithDigit(); }; }