From 721324c1db1478abe13bcfdb59e10d9a910395f8 Mon Sep 17 00:00:00 2001 From: greye Date: Sun, 30 Sep 2012 23:34:53 +0400 Subject: [PATCH] rm record inheritance, rework esmtool accordingly --- apps/esmtool/CMakeLists.txt | 2 + apps/esmtool/esmtool.cpp | 742 ++++++------------------ apps/esmtool/record.cpp | 568 ++++++++++++++++++ apps/esmtool/record.hpp | 127 ++++ apps/openmw/mwclass/creature.cpp | 2 +- apps/openmw/mwclass/ingredient.cpp | 2 +- apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwclass/potion.cpp | 2 +- apps/openmw/mwdialogue/journalentry.cpp | 4 +- apps/openmw/mwdialogue/quest.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 2 +- components/esm/loadacti.hpp | 4 +- components/esm/loadalch.hpp | 8 +- components/esm/loadappa.hpp | 4 +- components/esm/loadarmo.hpp | 4 +- components/esm/loadbody.hpp | 4 +- components/esm/loadbook.hpp | 6 +- components/esm/loadbsgn.hpp | 4 +- components/esm/loadcell.cpp | 2 + components/esm/loadcell.hpp | 4 +- components/esm/loadclas.hpp | 4 +- components/esm/loadclot.hpp | 4 +- components/esm/loadcont.hpp | 4 +- components/esm/loadcrea.hpp | 6 +- components/esm/loadcrec.hpp | 8 +- components/esm/loaddial.hpp | 5 +- components/esm/loaddoor.hpp | 4 +- components/esm/loadench.hpp | 4 +- components/esm/loadfact.hpp | 6 +- components/esm/loadglob.hpp | 4 +- components/esm/loadgmst.hpp | 5 +- components/esm/loadinfo.cpp | 6 +- components/esm/loadinfo.hpp | 6 +- components/esm/loadingr.hpp | 6 +- components/esm/loadland.hpp | 4 +- components/esm/loadlevlist.hpp | 10 +- components/esm/loadligh.hpp | 4 +- components/esm/loadlocks.hpp | 12 +- components/esm/loadltex.hpp | 6 +- components/esm/loadmgef.hpp | 4 +- components/esm/loadmisc.hpp | 4 +- components/esm/loadnpc.hpp | 6 +- components/esm/loadnpcc.hpp | 4 +- components/esm/loadpgrd.hpp | 4 +- components/esm/loadrace.hpp | 4 +- components/esm/loadregn.hpp | 4 +- components/esm/loadscpt.hpp | 4 +- components/esm/loadskil.hpp | 4 +- components/esm/loadsndg.hpp | 4 +- components/esm/loadsoun.hpp | 4 +- components/esm/loadspel.hpp | 4 +- components/esm/loadsscr.hpp | 4 +- components/esm/loadstat.hpp | 4 +- components/esm/loadweap.hpp | 4 +- components/esm_store/reclists.hpp | 6 +- 55 files changed, 934 insertions(+), 737 deletions(-) create mode 100644 apps/esmtool/record.cpp create mode 100644 apps/esmtool/record.hpp diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index bd397d554..f48aa41bf 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -1,5 +1,7 @@ set(ESMTOOL esmtool.cpp + record.hpp + record.cpp ) source_group(apps\\esmtool FILES ${ESMTOOL}) diff --git a/apps/esmtool/esmtool.cpp b/apps/esmtool/esmtool.cpp index 8d224e8b3..71d42df55 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -1,6 +1,9 @@ #include +#include +#include #include #include +#include #include @@ -8,10 +11,9 @@ #include #include -#define ESMTOOL_VERSION 1.1 +#include "record.hpp" -using namespace std; -using namespace ESM; +#define ESMTOOL_VERSION 1.1 // Create a local alias for brevity namespace bpo = boost::program_options; @@ -19,15 +21,31 @@ namespace bpo = boost::program_options; struct ESMData { std::string author; - string description; + std::string description; int version; int type; - ESMReader::MasterList masters; + ESM::ESMReader::MasterList masters; + + std::deque mRecords; + std::map > mCellRefs; + std::map mRecordStats; + + static const std::set sLabeledRec; +}; - list records; - map > cellRefs; +static const int sLabeledRecIds[] = { + ESM::REC_GLOB, ESM::REC_CLAS, ESM::REC_FACT, ESM::REC_RACE, ESM::REC_SOUN, + ESM::REC_REGN, ESM::REC_BSGN, ESM::REC_LTEX, ESM::REC_STAT, ESM::REC_DOOR, + ESM::REC_MISC, ESM::REC_WEAP, ESM::REC_CONT, ESM::REC_SPEL, ESM::REC_CREA, + ESM::REC_BODY, ESM::REC_LIGH, ESM::REC_ENCH, ESM::REC_NPC_, ESM::REC_ARMO, + ESM::REC_CLOT, ESM::REC_REPA, ESM::REC_ACTI, ESM::REC_APPA, ESM::REC_LOCK, + ESM::REC_PROB, ESM::REC_INGR, ESM::REC_BOOK, ESM::REC_ALCH, ESM::REC_LEVI, + ESM::REC_LEVC, ESM::REC_SNDG, ESM::REC_CELL, ESM::REC_DIAL }; +const std::set ESMData::sLabeledRec = + std::set(sLabeledRecIds, sLabeledRecIds + 34); + // Based on the legacy struct struct Arguments { @@ -35,14 +53,14 @@ struct Arguments unsigned int quiet_given; unsigned int loadcells_given; - string mode; - string encoding; - string filename; - string outname; + std::string mode; + std::string encoding; + std::string filename; + std::string outname; ESMData data; - ESMReader reader; - ESMWriter writer; + ESM::ESMReader reader; + ESM::ESMWriter writer; }; bool parseOptions (int argc, char** argv, Arguments &info) @@ -56,7 +74,7 @@ bool parseOptions (int argc, char** argv, Arguments &info) ("quiet,q", "Supress all record information. Useful for speed tests.") ("loadcells,C", "Browse through contents of all cells.") - ( "encoding,e", bpo::value(&(info.encoding))-> + ( "encoding,e", bpo::value(&(info.encoding))-> default_value("win1252"), "Character encoding used in ESMTool:\n" "\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n" @@ -64,14 +82,14 @@ bool parseOptions (int argc, char** argv, Arguments &info) "\n\twin1252 - Western European (Latin) alphabet, used by default") ; - string finalText = "\nIf no option is given, the default action is to parse all records in the archive\nand display diagnostic information."; + std::string finalText = "\nIf no option is given, the default action is to parse all records in the archive\nand display diagnostic information."; // input-file is hidden and used as a positional argument bpo::options_description hidden("Hidden Options"); hidden.add_options() - ( "mode,m", bpo::value(), "esmtool mode") - ( "input-file,i", bpo::value< vector >(), "input file") + ( "mode,m", bpo::value(), "esmtool mode") + ( "input-file,i", bpo::value< std::vector >(), "input file") ; bpo::positional_options_description p; @@ -89,77 +107,77 @@ bool parseOptions (int argc, char** argv, Arguments &info) if (variables.count ("help")) { - cout << desc << finalText << endl; + std::cout << desc << finalText << std::endl; return false; } if (variables.count ("version")) { - cout << "ESMTool version " << ESMTOOL_VERSION << endl; + std::cout << "ESMTool version " << ESMTOOL_VERSION << std::endl; return false; } if (!variables.count("mode")) { - cout << "No mode specified!" << endl << endl - << desc << finalText << endl; + std::cout << "No mode specified!" << std::endl << std::endl + << desc << finalText << std::endl; return false; } - info.mode = variables["mode"].as(); + info.mode = variables["mode"].as(); if (!(info.mode == "dump" || info.mode == "clone" || info.mode == "comp")) { - cout << endl << "ERROR: invalid mode \"" << info.mode << "\"" << endl << endl - << desc << finalText << endl; + std::cout << std::endl << "ERROR: invalid mode \"" << info.mode << "\"" << std::endl << std::endl + << desc << finalText << std::endl; return false; } if ( !variables.count("input-file") ) { - cout << "\nERROR: missing ES file\n\n"; - cout << desc << finalText << endl; + std::cout << "\nERROR: missing ES file\n\n"; + std::cout << desc << finalText << std::endl; return false; } // handling gracefully the user adding multiple files -/* if (variables["input-file"].as< vector >().size() > 1) +/* if (variables["input-file"].as< std::vector >().size() > 1) { - cout << "\nERROR: more than one ES file specified\n\n"; - cout << desc << finalText << endl; + std::cout << "\nERROR: more than one ES file specified\n\n"; + std::cout << desc << finalText << std::endl; return false; }*/ - info.filename = variables["input-file"].as< vector >()[0]; - if (variables["input-file"].as< vector >().size() > 1) - info.outname = variables["input-file"].as< vector >()[1]; + info.filename = variables["input-file"].as< std::vector >()[0]; + if (variables["input-file"].as< std::vector >().size() > 1) + info.outname = variables["input-file"].as< std::vector >()[1]; info.raw_given = variables.count ("raw"); info.quiet_given = variables.count ("quiet"); info.loadcells_given = variables.count ("loadcells"); // Font encoding settings - info.encoding = variables["encoding"].as(); + info.encoding = variables["encoding"].as(); if (info.encoding == "win1250") { - cout << "Using Central and Eastern European font encoding." << endl; + std::cout << "Using Central and Eastern European font encoding." << std::endl; } else if (info.encoding == "win1251") { - cout << "Using Cyrillic font encoding." << endl; + std::cout << "Using Cyrillic font encoding." << std::endl; } else { if(info.encoding != "win1252") { - cout << info.encoding << " is not a valid encoding option." << endl; + std::cout << info.encoding << " is not a valid encoding option." << std::endl; info.encoding = "win1252"; } - cout << "Using default (English) font encoding." << endl; + std::cout << "Using default (English) font encoding." << std::endl; } return true; } -void printRaw(ESMReader &esm); -void loadCell(Cell &cell, ESMReader &esm, Arguments& info); +void printRaw(ESM::ESMReader &esm); +void loadCell(ESM::Cell &cell, ESM::ESMReader &esm, Arguments& info); int load(Arguments& info); int clone(Arguments& info); @@ -179,14 +197,14 @@ int main(int argc, char**argv) return comp(info); else { - cout << "Invalid or no mode specified, dying horribly. Have a nice day." << endl; + std::cout << "Invalid or no mode specified, dying horribly. Have a nice day." << std::endl; return 1; } return 0; } -void loadCell(Cell &cell, ESMReader &esm, Arguments& info) +void loadCell(ESM::Cell &cell, ESM::ESMReader &esm, Arguments& info) { bool quiet = (info.quiet_given || info.mode == "clone"); bool save = (info.mode == "clone"); @@ -195,28 +213,29 @@ void loadCell(Cell &cell, ESMReader &esm, Arguments& info) cell.restore(esm); // Loop through all the references - CellRef ref; - if(!quiet) cout << " References:\n"; + ESM::CellRef ref; + if(!quiet) std::cout << " References:\n"; while(cell.getNextRef(esm, ref)) { - if (save) - info.data.cellRefs[&cell].push_back(ref); + if (save) { + info.data.mCellRefs[&cell].push_back(ref); + } if(quiet) continue; - cout << " Refnum: " << ref.mRefnum << endl; - cout << " ID: '" << ref.mRefID << "'\n"; - cout << " Owner: '" << ref.mOwner << "'\n"; - cout << " INTV: " << ref.mIntv << " NAM9: " << ref.mIntv << endl; + std::cout << " Refnum: " << ref.mRefnum << std::endl; + std::cout << " ID: '" << ref.mRefID << "'\n"; + std::cout << " Owner: '" << ref.mOwner << "'\n"; + std::cout << " INTV: " << ref.mIntv << " NAM9: " << ref.mIntv << std::endl; } } -void printRaw(ESMReader &esm) +void printRaw(ESM::ESMReader &esm) { while(esm.hasMoreRecs()) { - NAME n = esm.getRecName(); - cout << "Record: " << n.toString() << endl; + ESM::NAME n = esm.getRecName(); + std::cout << "Record: " << n.toString() << std::endl; esm.getRecHeader(); while(esm.hasMoreSubs()) { @@ -224,27 +243,27 @@ void printRaw(ESMReader &esm) esm.getSubName(); esm.skipHSub(); n = esm.retSubName(); - cout << " " << n.toString() << " - " << esm.getSubSize() - << " bytes @ 0x" << hex << offs << "\n"; + std::cout << " " << n.toString() << " - " << esm.getSubSize() + << " bytes @ 0x" << std::hex << offs << "\n"; } } } int load(Arguments& info) { - ESMReader& esm = info.reader; + ESM::ESMReader& esm = info.reader; esm.setEncoding(info.encoding); - string filename = info.filename; - cout << "Loading file: " << filename << endl; + std::string filename = info.filename; + std::cout << "Loading file: " << filename << std::endl; - list skipped; + std::list skipped; try { if(info.raw_given && info.mode == "dump") { - cout << "RAW file listing:\n"; + std::cout << "RAW file listing:\n"; esm.openRaw(filename); @@ -267,496 +286,79 @@ int load(Arguments& info) if (!quiet) { - cout << "Author: " << esm.getAuthor() << endl - << "Description: " << esm.getDesc() << endl - << "File format version: " << esm.getFVer() << endl - << "Special flag: " << esm.getSpecial() << endl; - ESMReader::MasterList m = esm.getMasters(); + std::cout << "Author: " << esm.getAuthor() << std::endl + << "Description: " << esm.getDesc() << std::endl + << "File format version: " << esm.getFVer() << std::endl + << "Special flag: " << esm.getSpecial() << std::endl; + ESM::ESMReader::MasterList m = esm.getMasters(); if (!m.empty()) { - cout << "Masters:" << endl; + std::cout << "Masters:" << std::endl; for(unsigned int i=0;isetId(id); + if (quiet) break; + std::cout << " Skipping\n"; + } else { + if (record->getType() == ESM::REC_GMST) { + // preset id for GameSetting record + record->cast()->get().mId = id; + } + record->setId(id); + record->setFlags((int) flags); + record->load(esm); + if (!quiet) { + record->print(); + } - rec->setFlags((int)flags); + if (record->getType() == ESM::REC_CELL && loadCells) { + loadCell(record->cast()->get(), esm, info); + } - if (save) - info.data.records.push_back(rec); - else - delete rec; + if (save) { + info.data.mRecords.push_back(record); + } else { + delete record; + } + ++info.data.mRecordStats[n.val]; } } - } catch(exception &e) - { - cout << "\nERROR:\n\n " << e.what() << endl; + } catch(std::exception &e) { + std::cout << "\nERROR:\n\n " << e.what() << std::endl; - for (list::iterator it = info.data.records.begin(); it != info.data.records.end();) + typedef std::deque RecStore; + RecStore &store = info.data.mRecords; + for (RecStore::iterator it = store.begin(); it != store.end(); ++it) { delete *it; - info.data.records.erase(it++); } + store.clear(); return 1; } @@ -769,17 +371,17 @@ int clone(Arguments& info) { if (info.outname.empty()) { - cout << "You need to specify an output name" << endl; + std::cout << "You need to specify an output name" << std::endl; return 1; } if (load(info) != 0) { - cout << "Failed to load, aborting." << endl; + std::cout << "Failed to load, aborting." << std::endl; return 1; } - int recordCount = info.data.records.size(); + int recordCount = info.data.mRecords.size(); int digitCount = 1; // For a nicer output if (recordCount > 9) ++digitCount; @@ -789,92 +391,84 @@ int clone(Arguments& info) if (recordCount > 99999) ++digitCount; if (recordCount > 999999) ++digitCount; - cout << "Loaded " << recordCount << " records:" << endl << endl; + std::cout << "Loaded " << recordCount << " records:" << std::endl << std::endl; - map records; - - for (list::iterator it = info.data.records.begin(); it != info.data.records.end(); ++it) - { - Record* rec = *it; - NAME n; - n.val = rec->getName(); - records[n.toString()]++; - } + ESM::NAME name; int i = 0; - for (map::iterator it = records.begin(); it != records.end(); ++it) + typedef std::map Stats; + Stats &stats = info.data.mRecordStats; + for (Stats::iterator it = stats.begin(); it != stats.end(); ++it) { - string n = it->first; + name.val = it->first; float amount = it->second; - cout << setw(digitCount) << amount << " " << n << " "; + std::cout << std::setw(digitCount) << amount << " " << name.toString() << " "; if (++i % 3 == 0) - cout << endl; + std::cout << std::endl; } if (i % 3 != 0) - cout << endl; + std::cout << std::endl; - cout << endl << "Saving records to: " << info.outname << "..." << endl; + std::cout << std::endl << "Saving records to: " << info.outname << "..." << std::endl; - ESMWriter& esm = info.writer; + ESM::ESMWriter& esm = info.writer; esm.setEncoding(info.encoding); esm.setAuthor(info.data.author); esm.setDescription(info.data.description); esm.setVersion(info.data.version); esm.setType(info.data.type); - for (ESMReader::MasterList::iterator it = info.data.masters.begin(); it != info.data.masters.end(); ++it) + for (ESM::ESMReader::MasterList::iterator it = info.data.masters.begin(); it != info.data.masters.end(); ++it) esm.addMaster(it->name, it->size); - fstream save(info.outname.c_str(), fstream::out | fstream::binary); + std::fstream save(info.outname.c_str(), std::fstream::out | std::fstream::binary); esm.save(save); int saved = 0; - for (list::iterator it = info.data.records.begin(); it != info.data.records.end() && i > 0; ++it) + typedef std::deque Records; + Records &records = info.data.mRecords; + for (Records::iterator it = records.begin(); it != records.end() && i > 0; ++it) { - Record* rec = *it; + EsmTool::RecordBase *record = *it; - NAME n; - n.val = rec->getName(); + name.val = record->getType(); - esm.startRecord(n.toString(), rec->getFlags()); - string id = rec->getId(); + esm.startRecord(name.toString(), record->getFlags()); // TODO wrap this with std::set - if (n.val == REC_GLOB || n.val == REC_CLAS || n.val == REC_FACT || n.val == REC_RACE || n.val == REC_SOUN - || n.val == REC_REGN || n.val == REC_BSGN || n.val == REC_LTEX || n.val == REC_STAT || n.val == REC_DOOR - || n.val == REC_MISC || n.val == REC_WEAP || n.val == REC_CONT || n.val == REC_SPEL || n.val == REC_CREA - || n.val == REC_BODY || n.val == REC_LIGH || n.val == REC_ENCH || n.val == REC_NPC_ || n.val == REC_ARMO - || n.val == REC_CLOT || n.val == REC_REPA || n.val == REC_ACTI || n.val == REC_APPA || n.val == REC_LOCK - || n.val == REC_PROB || n.val == REC_INGR || n.val == REC_BOOK || n.val == REC_ALCH || n.val == REC_LEVI - || n.val == REC_LEVC || n.val == REC_SNDG || n.val == REC_CELL || n.val == REC_DIAL) - esm.writeHNCString("NAME", id); - else - esm.writeHNOString("NAME", id); - - rec->save(esm); - - if (n.val == REC_CELL && !info.data.cellRefs[rec].empty()) - { - list& refs = info.data.cellRefs[rec]; - for (list::iterator it = refs.begin(); it != refs.end(); ++it) - { - it->save(esm); + if (ESMData::sLabeledRec.count(name.val) > 0) { + esm.writeHNCString("NAME", record->getId()); + } else { + esm.writeHNOString("NAME", record->getId()); + } + + record->save(esm); + + if (name.val == ESM::REC_CELL) { + ESM::Cell *ptr = &record->cast()->get(); + if (!info.data.mCellRefs[ptr].empty()) { + typedef std::deque RefList; + RefList &refs = info.data.mCellRefs[ptr]; + for (RefList::iterator it = refs.begin(); it != refs.end(); ++it) + { + it->save(esm); + } } } - esm.endRecord(n.toString()); + esm.endRecord(name.toString()); saved++; int perc = (saved / (float)recordCount)*100; if (perc % 10 == 0) { - cerr << "\r" << perc << "%"; + std::cerr << "\r" << perc << "%"; } } - cout << "\rDone!" << endl; + std::cout << "\rDone!" << std::endl; esm.close(); save.close(); @@ -886,7 +480,7 @@ int comp(Arguments& info) { if (info.filename.empty() || info.outname.empty()) { - cout << "You need to specify two input files" << endl; + std::cout << "You need to specify two input files" << std::endl; return 1; } @@ -907,19 +501,19 @@ int comp(Arguments& info) if (load(fileOne) != 0) { - cout << "Failed to load " << info.filename << ", aborting comparison." << endl; + std::cout << "Failed to load " << info.filename << ", aborting comparison." << std::endl; return 1; } if (load(fileTwo) != 0) { - cout << "Failed to load " << info.outname << ", aborting comparison." << endl; + std::cout << "Failed to load " << info.outname << ", aborting comparison." << std::endl; return 1; } - if (fileOne.data.records.size() != fileTwo.data.records.size()) + if (fileOne.data.mRecords.size() != fileTwo.data.mRecords.size()) { - cout << "Not equal, different amount of records." << endl; + std::cout << "Not equal, different amount of records." << std::endl; return 1; } diff --git a/apps/esmtool/record.cpp b/apps/esmtool/record.cpp new file mode 100644 index 000000000..9609e5242 --- /dev/null +++ b/apps/esmtool/record.cpp @@ -0,0 +1,568 @@ +#include "record.hpp" + +#include + +namespace EsmTool { + +RecordBase * +RecordBase::create(int type) +{ + RecordBase *record = 0; + + switch (type) { + case ESM::REC_ACTI: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_ALCH: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_APPA: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_ARMO: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_BODY: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_BOOK: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_BSGN: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_CELL: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_CLAS: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_CLOT: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_CONT: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_CREA: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_DIAL: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_DOOR: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_ENCH: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_FACT: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_GLOB: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_GMST: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_INFO: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_INGR: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_LAND: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_LEVI: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_LEVC: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_LIGH: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_LOCK: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_LTEX: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_MISC: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_MGEF: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_NPC_: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_PGRD: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_PROB: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_RACE: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_REGN: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_REPA: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_SCPT: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_SKIL: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_SNDG: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_SOUN: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_SPEL: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_STAT: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_WEAP: + { + record = new EsmTool::Record; + break; + } + case ESM::REC_SSCR: + { + record = new EsmTool::Record; + break; + } + default: + record = 0; + } + if (record) { + record->mType = type; + } + return record; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Mesh: " << mData.mModel << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Mesh: " << mData.mModel << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Enchantment: " << mData.mEnchant << std::endl; + std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Mesh: " << mData.mModel << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Mesh: " << mData.mModel << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Texture: " << mData.mTexture << std::endl; + std::cout << " Description: " << mData.mDescription << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Region: " << mData.mRegion << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Description: " << mData.mDescription << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; +} + +template<> +void Record::print() +{ + // nothing to print +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Mesh: " << mData.mModel << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " OpenSound: " << mData.mOpenSound << std::endl; + std::cout << " CloseSound: " << mData.mCloseSound << std::endl; +} + +template<> +void Record::print() +{ + // nothing to print +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Attr1: " << mData.mData.mAttribute1 << std::endl; + std::cout << " Attr2: " << mData.mData.mAttribute2 << std::endl; + std::cout << " Hidden: " << mData.mData.mIsHidden << std::endl; +} + +template<> +void Record::print() +{ + // nothing to print +} + +template<> +void Record::print() +{ + std::cout << " Value: "; + switch (mData.mType) { + case ESM::VT_String: + std::cout << "'" << mData.mStr << "' (std::string)"; + break; + + case ESM::VT_Float: + std::cout << mData.mF << " (float)"; + break; + + case ESM::VT_Int: + std::cout << mData.mI << " (int)"; + break; + + default: + std::cout << "unknown type"; + } + std::cout << "\n Dirty: " << mData.mDirty << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Id: " << mData.mId << std::endl; + std::cout << " Text: " << mData.mResponse << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Coords: [" << mData.mX << "," << mData.mY << "]" << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Number of items: " << mData.mList.size() << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Number of items: " << mData.mList.size() << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Quality: " << mData.mData.mQuality << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Quality: " << mData.mData.mQuality << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Quality: " << mData.mData.mQuality << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Id: " << mData.mId << std::endl; + std::cout << " Texture: " << mData.mTexture << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Index: " << mData.mIndex << std::endl; + + const char *text = "Positive"; + if (mData.mData.mFlags & ESM::MagicEffect::Negative) { + text = "Negative"; + } + std::cout << " " << text << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Race: " << mData.mRace << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Cell: " << mData.mCell << std::endl; + std::cout << " Point count: " << mData.mPoints.size() << std::endl; + std::cout << " Edge count: " << mData.mEdges.size() << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Length: " << mData.mData.mHeight.mMale << "m " << mData.mData.mHeight.mFemale << "f" << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mData.mName.toString() << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " ID: " << mData.mIndex << std::endl; + + const char *spec = 0; + int specId = mData.mData.mSpecialization; + if (specId == 0) { + spec = "Combat"; + } else if (specId == 1) { + spec = "Magic"; + } else { + spec = "Stealth"; + } + std::cout << " Type: " << spec << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Creature: " << mData.mCreature << std::endl; + std::cout << " Sound: " << mData.mSound << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Sound: " << mData.mSound << std::endl; + std::cout << " Volume: " << mData.mData.mVolume << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; +} + +template<> +void Record::print() +{ + std::cout << "Start script: " << mData.mScript << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Model: " << mData.mModel << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Chop: " << mData.mData.mChop[0] << "-" << mData.mData.mChop[1] << std::endl; + std::cout << " Slash: " << mData.mData.mSlash[0] << "-" << mData.mData.mSlash[1] << std::endl; + std::cout << " Thrust: " << mData.mData.mThrust[0] << "-" << mData.mData.mThrust[1] << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; +} + +template<> +void Record::print() +{ + std::cout << " Refnum: " << mData.mRefnum << std::endl; + std::cout << " ID: '" << mData.mRefID << "'\n"; + std::cout << " Owner: '" << mData.mOwner << "'\n"; + std::cout << " INTV: " << mData.mIntv << " NAM9: " << mData.mIntv << std::endl; +} + +} // end namespace diff --git a/apps/esmtool/record.hpp b/apps/esmtool/record.hpp new file mode 100644 index 000000000..3cd7f5b54 --- /dev/null +++ b/apps/esmtool/record.hpp @@ -0,0 +1,127 @@ +#ifndef OPENMW_ESMTOOL_RECORD_H +#define OPENMW_ESMTOOL_RECORD_H + +#include + +#include + +namespace ESM +{ + class ESMReader; + class ESMWriter; +} + +namespace EsmTool +{ + template class Record; + + class RecordBase + { + protected: + std::string mId; + int mFlags; + int mType; + + public: + RecordBase () {} + virtual ~RecordBase() {} + + const std::string &getId() const { + return mId; + } + + void setId(const std::string &id) { + mId = id; + } + + int getFlags() const { + return mFlags; + } + + void setFlags(int flags) { + mFlags = flags; + } + + int getType() const { + return mType; + } + + virtual void load(ESM::ESMReader &esm) = 0; + virtual void save(ESM::ESMWriter &esm) = 0; + virtual void print() = 0; + + static RecordBase *create(int type); + + // just make it a bit shorter + template + Record *cast() { + return static_cast *>(this); + } + }; + + template + class Record : public RecordBase + { + T mData; + + public: + T &get() { + return mData; + } + + void save(ESM::ESMWriter &esm) { + mData.save(esm); + } + + void load(ESM::ESMReader &esm) { + mData.load(esm); + } + + void print(); + }; + + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); + template<> void Record::print(); +} + +#endif diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index d89c9abfe..0cf348b14 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -81,7 +81,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->getId(); + return ref->base->mId; } void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 75cd84a2e..8dec3f537 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -25,7 +25,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->getId(); + return ref->base->mId; } void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index e7ec1d794..03b5e56aa 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -120,7 +120,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->getId(); + return ref->base->mId; } void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 2b76ebd54..be0d1dd0f 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -159,7 +159,7 @@ namespace MWClass MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); boost::shared_ptr action ( - new MWWorld::ActionApply (actor, ref->base->getId())); + new MWWorld::ActionApply (actor, ref->base->mId)); action->setSound ("Drink"); diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index d25efc269..1c6addb6e 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -22,7 +22,7 @@ namespace MWDialogue for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) - if (iter->getId() == mInfoId) + if (iter->mId == mInfoId) return iter->mResponse; throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic); @@ -41,7 +41,7 @@ namespace MWDialogue iter!=dialogue->mInfo.end(); ++iter) if (iter->mData.mDisposition==index) /// \todo cleanup info structure { - return iter->getId(); + return iter->mId; } throw std::runtime_error ("unknown journal index for topic " + topic); diff --git a/apps/openmw/mwdialogue/quest.cpp b/apps/openmw/mwdialogue/quest.cpp index c6a1d7ea5..b4f02e128 100644 --- a/apps/openmw/mwdialogue/quest.cpp +++ b/apps/openmw/mwdialogue/quest.cpp @@ -67,7 +67,7 @@ namespace MWDialogue for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) - if (iter->getId() == entry.mInfoId) + if (iter->mId == entry.mInfoId) { index = iter->mData.mDisposition; /// \todo cleanup info structure break; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 0cdb2b528..1bb29e9a6 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -776,7 +776,7 @@ namespace MWWorld stream << "$dynamic" << mNextDynamicRecord++; ESM::Potion record2 (record); - record2.setId(stream.str()); + record2.mId = stream.str(); const ESM::Potion *created = &mStore.potions.list.insert (std::make_pair (stream.str(), record2)).first->second; diff --git a/components/esm/loadacti.hpp b/components/esm/loadacti.hpp index c1a630ab8..64cf1db6f 100644 --- a/components/esm/loadacti.hpp +++ b/components/esm/loadacti.hpp @@ -6,14 +6,12 @@ namespace ESM { -struct Activator : public Record +struct Activator { std::string mName, mScript, mModel; void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_ACTI; } }; } diff --git a/components/esm/loadalch.hpp b/components/esm/loadalch.hpp index 4d21b3b58..1367b9927 100644 --- a/components/esm/loadalch.hpp +++ b/components/esm/loadalch.hpp @@ -12,7 +12,7 @@ namespace ESM * Alchemy item (potions) */ -struct Potion : public Record +struct Potion { struct ALDTstruct { @@ -22,13 +22,11 @@ struct Potion : public Record }; ALDTstruct mData; - std::string mName, mModel, mIcon, mScript; + std::string mId, mName, mModel, mIcon, mScript; EffectList mEffects; void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_ALCH; } -}; + }; } #endif diff --git a/components/esm/loadappa.hpp b/components/esm/loadappa.hpp index e0850231f..b3d37cf75 100644 --- a/components/esm/loadappa.hpp +++ b/components/esm/loadappa.hpp @@ -9,7 +9,7 @@ namespace ESM * Alchemist apparatus */ -struct Apparatus : public Record +struct Apparatus { enum AppaType { @@ -32,8 +32,6 @@ struct Apparatus : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_APPA; } }; } #endif diff --git a/components/esm/loadarmo.hpp b/components/esm/loadarmo.hpp index 1adfd4fbc..04616c9ea 100644 --- a/components/esm/loadarmo.hpp +++ b/components/esm/loadarmo.hpp @@ -56,7 +56,7 @@ struct PartReferenceList void save(ESMWriter &esm); }; -struct Armor : public Record +struct Armor { enum Type { @@ -87,8 +87,6 @@ struct Armor : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_ARMO; } }; } #endif diff --git a/components/esm/loadbody.hpp b/components/esm/loadbody.hpp index d07a78fc8..66d555029 100644 --- a/components/esm/loadbody.hpp +++ b/components/esm/loadbody.hpp @@ -6,7 +6,7 @@ namespace ESM { -struct BodyPart : public Record +struct BodyPart { enum MeshPart { @@ -53,8 +53,6 @@ struct BodyPart : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_BODY; } }; } #endif diff --git a/components/esm/loadbook.hpp b/components/esm/loadbook.hpp index 8102b2dc1..dc7067e1f 100644 --- a/components/esm/loadbook.hpp +++ b/components/esm/loadbook.hpp @@ -9,7 +9,7 @@ namespace ESM * Books, magic scrolls, notes and so on */ -struct Book : public Record +struct Book { struct BKDTstruct { @@ -22,8 +22,6 @@ struct Book : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_BOOK; } -}; + }; } #endif diff --git a/components/esm/loadbsgn.hpp b/components/esm/loadbsgn.hpp index cd8a1c753..7733cb42f 100644 --- a/components/esm/loadbsgn.hpp +++ b/components/esm/loadbsgn.hpp @@ -9,7 +9,7 @@ namespace ESM { -struct BirthSign : public Record +struct BirthSign { std::string mName, mDescription, mTexture; @@ -18,8 +18,6 @@ struct BirthSign : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_BSGN; } }; } #endif diff --git a/components/esm/loadcell.cpp b/components/esm/loadcell.cpp index b7e2063ef..97ce17775 100644 --- a/components/esm/loadcell.cpp +++ b/components/esm/loadcell.cpp @@ -102,6 +102,8 @@ void Cell::load(ESMReader &esm) { // Exterior cells mRegion = esm.getHNOString("RGNN"); + + mMapColor = 0; esm.getHNOT(mMapColor, "NAM5"); } if (esm.isNextSub("NAM0")) { diff --git a/components/esm/loadcell.hpp b/components/esm/loadcell.hpp index 6936dc255..6773235a7 100644 --- a/components/esm/loadcell.hpp +++ b/components/esm/loadcell.hpp @@ -87,7 +87,7 @@ public: (using ESMReader::getContext()) and jumping back into place whenever we need to load a given cell. */ -struct Cell : public Record +struct Cell { enum Flags { @@ -128,8 +128,6 @@ struct Cell : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - int getName() { return REC_CELL; } - bool isExterior() const { return !(mData.mFlags & Interior); diff --git a/components/esm/loadclas.hpp b/components/esm/loadclas.hpp index 556892585..3897aabed 100644 --- a/components/esm/loadclas.hpp +++ b/components/esm/loadclas.hpp @@ -13,7 +13,7 @@ namespace ESM // These flags tells us which items should be auto-calculated for this // class -struct Class : public Record +struct Class { enum AutoCalc { @@ -63,8 +63,6 @@ struct Class : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_CLAS; } }; } #endif diff --git a/components/esm/loadclot.hpp b/components/esm/loadclot.hpp index a27953c6e..7fc59fdbd 100644 --- a/components/esm/loadclot.hpp +++ b/components/esm/loadclot.hpp @@ -13,7 +13,7 @@ namespace ESM * Clothing */ -struct Clothing : public Record +struct Clothing { enum Type { @@ -44,8 +44,6 @@ struct Clothing : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_CLOT; } }; } #endif diff --git a/components/esm/loadcont.hpp b/components/esm/loadcont.hpp index 66e906050..d3a89a503 100644 --- a/components/esm/loadcont.hpp +++ b/components/esm/loadcont.hpp @@ -28,7 +28,7 @@ struct InventoryList void save(ESMWriter &esm); }; -struct Container : public Record +struct Container { enum Flags { @@ -45,8 +45,6 @@ struct Container : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_CONT; } }; } #endif diff --git a/components/esm/loadcrea.hpp b/components/esm/loadcrea.hpp index 262bc92dd..e1b1e9310 100644 --- a/components/esm/loadcrea.hpp +++ b/components/esm/loadcrea.hpp @@ -16,7 +16,7 @@ namespace ESM * */ -struct Creature : public Record +struct Creature { // Default is 0x48? enum Flags @@ -69,7 +69,7 @@ struct Creature : public Record int mFlags; float mScale; - std::string mModel, mName, mScript; + std::string mId, mModel, mName, mScript; std::string mOriginal; // Base creature that this is a modification of InventoryList mInventory; @@ -80,8 +80,6 @@ struct Creature : public Record AIData mAiData; AIPackageList mAiPackage; - int getName() { return REC_CREA; } - void load(ESMReader &esm); void save(ESMWriter &esm); }; diff --git a/components/esm/loadcrec.hpp b/components/esm/loadcrec.hpp index b40a9605f..0609ea37f 100644 --- a/components/esm/loadcrec.hpp +++ b/components/esm/loadcrec.hpp @@ -12,7 +12,7 @@ namespace ESM { */ /// Changes a creature -struct LoadCREC : public Record +struct LoadCREC { void load(ESMReader &esm) { @@ -22,12 +22,10 @@ struct LoadCREC : public Record void save(ESMWriter &esm) { } - - int getName() { return REC_CREC; } }; /// Changes an item list / container -struct LoadCNTC : public Record +struct LoadCNTC { void load(ESMReader &esm) { @@ -37,8 +35,6 @@ struct LoadCNTC : public Record void save(ESMWriter &esm) { } - - int getName() { return REC_CNTC; } }; } #endif diff --git a/components/esm/loaddial.hpp b/components/esm/loaddial.hpp index ccf2ebb44..d561b9d76 100644 --- a/components/esm/loaddial.hpp +++ b/components/esm/loaddial.hpp @@ -14,7 +14,7 @@ namespace ESM * the INFO records following the DIAL. */ -struct Dialogue : public Record +struct Dialogue { enum Type { @@ -26,13 +26,12 @@ struct Dialogue : public Record Deleted = -1 }; + std::string mId; char mType; std::vector mInfo; void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_DIAL; } }; } #endif diff --git a/components/esm/loaddoor.hpp b/components/esm/loaddoor.hpp index 37ec5fdd3..337c81328 100644 --- a/components/esm/loaddoor.hpp +++ b/components/esm/loaddoor.hpp @@ -8,14 +8,12 @@ namespace ESM { -struct Door : public Record +struct Door { std::string mName, mModel, mScript, mOpenSound, mCloseSound; void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_DOOR; } }; } #endif diff --git a/components/esm/loadench.hpp b/components/esm/loadench.hpp index 81486c390..2894df393 100644 --- a/components/esm/loadench.hpp +++ b/components/esm/loadench.hpp @@ -10,7 +10,7 @@ namespace ESM * Enchantments */ -struct Enchantment : public Record +struct Enchantment { enum Type { @@ -34,8 +34,6 @@ struct Enchantment : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_ENCH; } }; } #endif diff --git a/components/esm/loadfact.hpp b/components/esm/loadfact.hpp index f5a6f05d7..50c2b42ba 100644 --- a/components/esm/loadfact.hpp +++ b/components/esm/loadfact.hpp @@ -26,9 +26,9 @@ struct RankData int mFactReaction; // Reaction from faction members }; -struct Faction : public Record +struct Faction { - std::string mName; + std::string mId, mName; struct FADTstruct { @@ -57,8 +57,6 @@ struct Faction : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_FACT; } }; } #endif diff --git a/components/esm/loadglob.hpp b/components/esm/loadglob.hpp index 2aceaae59..0147afded 100644 --- a/components/esm/loadglob.hpp +++ b/components/esm/loadglob.hpp @@ -11,15 +11,13 @@ namespace ESM * Global script variables */ -struct Global : public Record +struct Global { unsigned mValue; VarType mType; void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_GLOB; } }; } #endif diff --git a/components/esm/loadgmst.hpp b/components/esm/loadgmst.hpp index c99ec5fd1..acfc49814 100644 --- a/components/esm/loadgmst.hpp +++ b/components/esm/loadgmst.hpp @@ -13,8 +13,9 @@ namespace ESM * */ -struct GameSetting : public Record +struct GameSetting { + std::string mId; // One of these is used depending on the variable type std::string mStr; int mI; @@ -93,8 +94,6 @@ struct GameSetting : public Record ///< Throwns an exception if GMST is not of type string. void save(ESMWriter &esm); - - int getName() { return REC_GMST; } }; } #endif diff --git a/components/esm/loadinfo.cpp b/components/esm/loadinfo.cpp index 5535d6abb..f237cf780 100644 --- a/components/esm/loadinfo.cpp +++ b/components/esm/loadinfo.cpp @@ -8,7 +8,7 @@ namespace ESM void DialInfo::load(ESMReader &esm) { - mSelfId = esm.getHNString("INAM"); + mId = esm.getHNString("INAM"); mPrev = esm.getHNString("PNAM"); mNext = esm.getHNString("NNAM"); @@ -127,7 +127,7 @@ void DialInfo::load(ESMReader &esm) else esm.fail( "Don't know what to do with " + subName.toString() - + " in INFO " + mSelfId); + + " in INFO " + mId); if (mQuestStatus != QS_None) // Skip rest of record @@ -136,7 +136,7 @@ void DialInfo::load(ESMReader &esm) void DialInfo::save(ESMWriter &esm) { - esm.writeHNCString("INAM", mSelfId); + esm.writeHNCString("INAM", mId); esm.writeHNCString("PNAM", mPrev); esm.writeHNCString("NNAM", mNext); esm.writeHNT("DATA", mData, 12); diff --git a/components/esm/loadinfo.hpp b/components/esm/loadinfo.hpp index 085aabb24..83d5fe6b4 100644 --- a/components/esm/loadinfo.hpp +++ b/components/esm/loadinfo.hpp @@ -17,7 +17,7 @@ namespace ESM * and form a linked list of dialogue items. */ -struct DialInfo : public Record +struct DialInfo { enum Gender { @@ -61,7 +61,7 @@ struct DialInfo : public Record std::vector mSelects; // Id of this, previous and next INFO items - std::string mSelfId, mPrev, mNext; + std::string mId, mPrev, mNext; // Various references used in determining when to select this item. std::string mActor, mRace, mClass, mNpcFaction, mPcFaction, mCell; @@ -102,8 +102,6 @@ struct DialInfo : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_INFO; } }; /* diff --git a/components/esm/loadingr.hpp b/components/esm/loadingr.hpp index 4c4b40443..3f0423e1c 100644 --- a/components/esm/loadingr.hpp +++ b/components/esm/loadingr.hpp @@ -11,7 +11,7 @@ namespace ESM * Alchemy ingredient */ -struct Ingredient : public Record +struct Ingredient { struct IRDTstruct { @@ -23,12 +23,10 @@ struct Ingredient : public Record }; IRDTstruct mData; - std::string mName, mModel, mIcon, mScript; + std::string mId, mName, mModel, mIcon, mScript; void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_INGR; } }; } #endif diff --git a/components/esm/loadland.hpp b/components/esm/loadland.hpp index f82cd1da8..9f85bfb00 100644 --- a/components/esm/loadland.hpp +++ b/components/esm/loadland.hpp @@ -12,7 +12,7 @@ namespace ESM * Landscape data. */ -struct Land : public Record +struct Land { Land(); ~Land(); @@ -92,8 +92,6 @@ struct Land : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - int getName() { return REC_LAND; } - /** * Actually loads data */ diff --git a/components/esm/loadlevlist.hpp b/components/esm/loadlevlist.hpp index 6d420d68b..f39ddd4c2 100644 --- a/components/esm/loadlevlist.hpp +++ b/components/esm/loadlevlist.hpp @@ -17,7 +17,7 @@ namespace ESM * several files. */ -struct LeveledListBase : public Record +struct LeveledListBase { enum Flags { @@ -47,14 +47,6 @@ struct LeveledListBase : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() - { - if (mRecName[0] == 'C') - return REC_LEVC; - - return REC_LEVI; - } }; struct CreatureLevList: LeveledListBase diff --git a/components/esm/loadligh.hpp b/components/esm/loadligh.hpp index 626dd06e4..febbe4a5c 100644 --- a/components/esm/loadligh.hpp +++ b/components/esm/loadligh.hpp @@ -13,7 +13,7 @@ namespace ESM * and torches. */ -struct Light : public Record +struct Light { enum Flags { @@ -44,8 +44,6 @@ struct Light : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_LIGH; } }; } #endif diff --git a/components/esm/loadlocks.hpp b/components/esm/loadlocks.hpp index f30b0c4f1..e3a486086 100644 --- a/components/esm/loadlocks.hpp +++ b/components/esm/loadlocks.hpp @@ -11,7 +11,7 @@ namespace ESM * items (REPA). These have nearly identical data structures. */ -struct Tool : public Record +struct Tool { enum Type { @@ -37,16 +37,6 @@ struct Tool : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() - { - if (mType == Type_Probe) - return REC_PROB; - else if (mType == Type_Repair) - return REC_REPA; - else - return REC_LOCK; - } }; struct Probe: Tool diff --git a/components/esm/loadltex.hpp b/components/esm/loadltex.hpp index 8ac0da155..34aea8314 100644 --- a/components/esm/loadltex.hpp +++ b/components/esm/loadltex.hpp @@ -24,15 +24,13 @@ namespace ESM * texture, and see if it affects the game. */ -struct LandTexture : public Record +struct LandTexture { - std::string mTexture; + std::string mId, mTexture; int mIndex; void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_LTEX; } }; } #endif diff --git a/components/esm/loadmgef.hpp b/components/esm/loadmgef.hpp index caa983d6b..1ca7382b0 100644 --- a/components/esm/loadmgef.hpp +++ b/components/esm/loadmgef.hpp @@ -8,7 +8,7 @@ namespace ESM { -struct MagicEffect : public Record +struct MagicEffect { enum Flags { @@ -50,8 +50,6 @@ struct MagicEffect : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_MGEF; } }; } #endif diff --git a/components/esm/loadmisc.hpp b/components/esm/loadmisc.hpp index 3e0d5db64..f40ac9b79 100644 --- a/components/esm/loadmisc.hpp +++ b/components/esm/loadmisc.hpp @@ -13,7 +13,7 @@ namespace ESM * carried, bought and sold. It also includes keys. */ -struct Miscellaneous : public Record +struct Miscellaneous { struct MCDTstruct { @@ -29,8 +29,6 @@ struct Miscellaneous : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_MISC; } }; } #endif diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index f9b579f4f..42a8a70bd 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -15,7 +15,7 @@ namespace ESM { * NPC definition */ -struct NPC : public Record +struct NPC { // Services enum Services @@ -106,7 +106,7 @@ struct NPC : public Record std::vector mTransport; AIPackageList mAiPackage; - std::string mName, mModel, mRace, mClass, mFaction, mScript; + std::string mId, mName, mModel, mRace, mClass, mFaction, mScript; // body parts std::string mHair, mHead; @@ -114,8 +114,6 @@ struct NPC : public Record // Implementation moved to load_impl.cpp void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_NPC_; } }; } #endif diff --git a/components/esm/loadnpcc.hpp b/components/esm/loadnpcc.hpp index 17ef8763b..a056dc701 100644 --- a/components/esm/loadnpcc.hpp +++ b/components/esm/loadnpcc.hpp @@ -73,7 +73,7 @@ namespace ESM { * will be harder than reading it. */ -struct LoadNPCC : public Record +struct LoadNPCC { void load(ESMReader &esm) { @@ -82,8 +82,6 @@ struct LoadNPCC : public Record void save(ESMWriter &esm) { } - - int getName() { return REC_NPCC; } }; } #endif diff --git a/components/esm/loadpgrd.hpp b/components/esm/loadpgrd.hpp index 3d8fb5ccd..039812040 100644 --- a/components/esm/loadpgrd.hpp +++ b/components/esm/loadpgrd.hpp @@ -12,7 +12,7 @@ namespace ESM /* * Path grid. */ -struct Pathgrid : public Record +struct Pathgrid { struct DATAstruct { @@ -46,8 +46,6 @@ struct Pathgrid : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_PGRD; } }; } #endif diff --git a/components/esm/loadrace.hpp b/components/esm/loadrace.hpp index bd7096a4c..ae12eec14 100644 --- a/components/esm/loadrace.hpp +++ b/components/esm/loadrace.hpp @@ -12,7 +12,7 @@ namespace ESM * Race definition */ -struct Race : public Record +struct Race { struct SkillBonus { @@ -66,8 +66,6 @@ struct Race : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_RACE; } }; } diff --git a/components/esm/loadregn.hpp b/components/esm/loadregn.hpp index 5c9086d14..568d096fe 100644 --- a/components/esm/loadregn.hpp +++ b/components/esm/loadregn.hpp @@ -14,7 +14,7 @@ namespace ESM * Region data */ -struct Region : public Record +struct Region { #pragma pack(push) #pragma pack(1) @@ -46,8 +46,6 @@ struct Region : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_REGN; } }; } #endif diff --git a/components/esm/loadscpt.hpp b/components/esm/loadscpt.hpp index 2cc786cb9..9c8acd81f 100644 --- a/components/esm/loadscpt.hpp +++ b/components/esm/loadscpt.hpp @@ -14,7 +14,7 @@ namespace ESM * Script definitions */ -class Script : public Record +class Script { public: struct SCHDstruct @@ -55,8 +55,6 @@ public: void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_SCPT; } }; } #endif diff --git a/components/esm/loadskil.hpp b/components/esm/loadskil.hpp index a6716dc27..56ea07929 100644 --- a/components/esm/loadskil.hpp +++ b/components/esm/loadskil.hpp @@ -15,7 +15,7 @@ namespace ESM { * */ -struct Skill : public Record +struct Skill { struct SKDTstruct { @@ -71,8 +71,6 @@ struct Skill : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_SKIL; } }; } #endif diff --git a/components/esm/loadsndg.hpp b/components/esm/loadsndg.hpp index e58f2eb0c..22d42dc2f 100644 --- a/components/esm/loadsndg.hpp +++ b/components/esm/loadsndg.hpp @@ -12,7 +12,7 @@ namespace ESM * Sound generator. This describes the sounds a creature make. */ -struct SoundGenerator : public Record +struct SoundGenerator { enum Type { @@ -33,8 +33,6 @@ struct SoundGenerator : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_SNDG; } }; } #endif diff --git a/components/esm/loadsoun.hpp b/components/esm/loadsoun.hpp index d4647bd08..73ee5b22f 100644 --- a/components/esm/loadsoun.hpp +++ b/components/esm/loadsoun.hpp @@ -13,15 +13,13 @@ struct SOUNstruct unsigned char mVolume, mMinRange, mMaxRange; }; -struct Sound : public Record +struct Sound { SOUNstruct mData; std::string mSound; void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_SOUN; } }; } #endif diff --git a/components/esm/loadspel.hpp b/components/esm/loadspel.hpp index 9f557a9b2..d96a12a4e 100644 --- a/components/esm/loadspel.hpp +++ b/components/esm/loadspel.hpp @@ -9,7 +9,7 @@ namespace ESM { -struct Spell : public Record +struct Spell { enum SpellType { @@ -41,8 +41,6 @@ struct Spell : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_SPEL; } }; } #endif diff --git a/components/esm/loadsscr.hpp b/components/esm/loadsscr.hpp index 2b87f7621..758847f21 100644 --- a/components/esm/loadsscr.hpp +++ b/components/esm/loadsscr.hpp @@ -16,7 +16,7 @@ namespace ESM reference. */ -struct StartScript : public Record +struct StartScript { std::string mData; std::string mScript; @@ -24,8 +24,6 @@ struct StartScript : public Record // Load a record and add it to the list void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_SSCR; } }; } diff --git a/components/esm/loadstat.hpp b/components/esm/loadstat.hpp index 2a51fa7a7..45a43082d 100644 --- a/components/esm/loadstat.hpp +++ b/components/esm/loadstat.hpp @@ -19,14 +19,12 @@ namespace ESM { * you decode the CELL blocks, if you want to test this hypothesis. */ -struct Static : public Record +struct Static { std::string mModel; void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_STAT; } }; } #endif diff --git a/components/esm/loadweap.hpp b/components/esm/loadweap.hpp index 2a6439f8f..724c96c88 100644 --- a/components/esm/loadweap.hpp +++ b/components/esm/loadweap.hpp @@ -12,7 +12,7 @@ namespace ESM * Weapon definition */ -struct Weapon : public Record +struct Weapon { enum Type { @@ -59,8 +59,6 @@ struct Weapon : public Record void load(ESMReader &esm); void save(ESMWriter &esm); - - int getName() { return REC_WEAP; } }; } #endif diff --git a/components/esm_store/reclists.hpp b/components/esm_store/reclists.hpp index bf98bf1d7..24580a79c 100644 --- a/components/esm_store/reclists.hpp +++ b/components/esm_store/reclists.hpp @@ -173,7 +173,7 @@ namespace ESMS void load(ESMReader &esm, const std::string &id) { std::string id2 = toLower (id); - list[id2].setId(id2); + list[id2].mId = id2; list[id2].load(esm); } @@ -226,7 +226,7 @@ namespace ESMS std::string id2 = toLower (id); X& ref = list[id2]; - ref.setId(id); + ref.mId = id; ref.load(esm); } @@ -293,7 +293,7 @@ namespace ESMS { LandTexture lt; lt.load(esm); - lt.setId(id); + lt.mId = id; // Make sure we have room for the structure if(lt.mIndex + 1 > (int)ltex.size())