From 30f114873d419cefef6aec22d9ef2999e376decc Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 3 Aug 2014 10:12:03 +0200 Subject: [PATCH] added debug profile record --- components/CMakeLists.txt | 2 +- components/esm/debugprofile.cpp | 50 +++++++++++++++++++++++++++++++++ components/esm/debugprofile.hpp | 33 ++++++++++++++++++++++ components/esm/defs.hpp | 3 +- 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 components/esm/debugprofile.cpp create mode 100644 components/esm/debugprofile.hpp diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index efe4322272..c8758ca9ec 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -41,7 +41,7 @@ add_component_dir (esm loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat loadweap records aipackage effectlist spelllist variant variantimp loadtes3 cellref filter savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate npcstate creaturestate dialoguestate statstate - npcstats creaturestats weatherstate quickkeys fogstate spellstate activespells creaturelevliststate doorstate projectilestate + npcstats creaturestats weatherstate quickkeys fogstate spellstate activespells creaturelevliststate doorstate projectilestate debugprofile aisequence ) diff --git a/components/esm/debugprofile.cpp b/components/esm/debugprofile.cpp new file mode 100644 index 0000000000..eb6dc2fdc7 --- /dev/null +++ b/components/esm/debugprofile.cpp @@ -0,0 +1,50 @@ + +#include "debugprofile.hpp" + +#include "esmreader.hpp" +#include "esmwriter.hpp" +#include "defs.hpp" + +unsigned int ESM::DebugProfile::sRecordId = REC_DBGP; + +void ESM::DebugProfile::load (ESMReader& esm) +{ + mDescription = esm.getHNString ("DESC"); + mScript = esm.getHNString ("SCRP"); + + int default_ = 0; + esm.getHNOT (default_, "DEFA"); + + mDefault = default_!=0; + + int bypass = 0; + esm.getHNOT (bypass, "BYNG"); + + mBypassNewGame = bypass!=0; +} + +void ESM::DebugProfile::save (ESMWriter& esm) const +{ + esm.writeHNCString ("DESC", mDescription); + esm.writeHNCString ("SCRP", mScript); + + if (mDefault) + { + int default_ = 1; + esm.writeHNT ("DEFA", default_); + } + + if (mBypassNewGame) + { + int bypass = 1; + esm.writeHNT ("BYNG", bypass); + } +} + +void ESM::DebugProfile::blank() +{ + mDescription.clear(); + mScript.clear(); + mDefault = false; + mBypassNewGame = false; +} diff --git a/components/esm/debugprofile.hpp b/components/esm/debugprofile.hpp new file mode 100644 index 0000000000..1e85742993 --- /dev/null +++ b/components/esm/debugprofile.hpp @@ -0,0 +1,33 @@ +#ifndef COMPONENTS_ESM_DEBUGPROFILE_H +#define COMPONENTS_ESM_DEBUGPROFILE_H + +#include + +namespace ESM +{ + class ESMReader; + class ESMWriter; + + struct DebugProfile + { + static unsigned int sRecordId; + + std::string mId; + + std::string mDescription; + + std::string mScript; + + bool mDefault; + + bool mBypassNewGame; + + void load (ESMReader& esm); + void save (ESMWriter& esm) const; + + /// Set record to default state (does not touch the ID). + void blank(); + }; +} + +#endif diff --git a/components/esm/defs.hpp b/components/esm/defs.hpp index f967af274a..14f2d3ebdd 100644 --- a/components/esm/defs.hpp +++ b/components/esm/defs.hpp @@ -114,7 +114,8 @@ enum RecNameInts REC_DCOU = FourCC<'D','C','O','U'>::value, // format 1 - REC_FILT = 0x544C4946 + REC_FILT = 0x544C4946, + REC_DBGP = FourCC<'D','B','G','P'>::value ///< only used in project files }; }