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 4888d3ceb..88709f58b 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -1,20 +1,50 @@ #include +#include +#include +#include +#include +#include #include -#include +#include +#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; -void printRaw(ESMReader &esm); -void loadCell(Cell &cell, ESMReader &esm, bool quiet); +struct ESMData +{ + std::string author; + std::string description; + int version; + int type; + ESM::ESMReader::MasterList masters; + + std::deque mRecords; + std::map > mCellRefs; + std::map mRecordStats; + + static const std::set sLabeledRec; +}; + +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 @@ -22,13 +52,20 @@ struct Arguments unsigned int raw_given; unsigned int quiet_given; unsigned int loadcells_given; + + std::string mode; std::string encoding; std::string filename; + std::string outname; + + ESMData data; + ESM::ESMReader reader; + ESM::ESMWriter writer; }; bool parseOptions (int argc, char** argv, Arguments &info) { - bpo::options_description desc("Inspect and extract from Morrowind ES files (ESM, ESP, ESS)\nSyntax: esmtool [options] file \nAllowed options"); + bpo::options_description desc("Inspect and extract from Morrowind ES files (ESM, ESP, ESS)\nSyntax: esmtool [options] mode infile [outfile]\nAllowed modes:\n dump\t Dumps all readable data from the input file.\n clone\t Clones the input file to the output file.\n comp\t Compares the given files.\n\nAllowed options"); desc.add_options() ("help,h", "print help message.") @@ -38,11 +75,11 @@ bool parseOptions (int argc, char** argv, Arguments &info) ("loadcells,C", "Browse through contents of all cells.") ( "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" - "\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n" - "\n\twin1252 - Western European (Latin) alphabet, used by default") + 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" + "\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n" + "\n\twin1252 - Western European (Latin) alphabet, used by default") ; std::string finalText = "\nIf no option is given, the default action is to parse all records in the archive\nand display diagnostic information."; @@ -51,11 +88,12 @@ bool parseOptions (int argc, char** argv, Arguments &info) bpo::options_description hidden("Hidden Options"); hidden.add_options() - ( "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; - p.add("input-file", -1); + p.add("mode", 1).add("input-file", 2); // there might be a better way to do this bpo::options_description all; @@ -77,6 +115,20 @@ bool parseOptions (int argc, char** argv, Arguments &info) std::cout << "ESMTool version " << ESMTOOL_VERSION << std::endl; return false; } + if (!variables.count("mode")) + { + std::cout << "No mode specified!" << std::endl << std::endl + << desc << finalText << std::endl; + return false; + } + + info.mode = variables["mode"].as(); + if (!(info.mode == "dump" || info.mode == "clone" || info.mode == "comp")) + { + std::cout << std::endl << "ERROR: invalid mode \"" << info.mode << "\"" << std::endl << std::endl + << desc << finalText << std::endl; + return false; + } if ( !variables.count("input-file") ) { @@ -86,14 +138,16 @@ bool parseOptions (int argc, char** argv, Arguments &info) } // handling gracefully the user adding multiple files - if (variables["input-file"].as< vector >().size() > 1) - { - std::cout << "\nERROR: more than one ES file specified\n\n"; - std::cout << desc << finalText << std::endl; - return false; - } +/* if (variables["input-file"].as< std::vector >().size() > 1) + { + 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]; + 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"); @@ -122,288 +176,350 @@ bool parseOptions (int argc, char** argv, Arguments &info) return true; } +void printRaw(ESM::ESMReader &esm); +void loadCell(ESM::Cell &cell, ESM::ESMReader &esm, Arguments& info); + +int load(Arguments& info); +int clone(Arguments& info); +int comp(Arguments& info); int main(int argc, char**argv) { - Arguments info; - if(!parseOptions (argc, argv, info)) - return 1; + Arguments info; + if(!parseOptions (argc, argv, info)) + return 1; - ESMReader esm; - esm.setEncoding(info.encoding); - - string filename = info.filename; - cout << "\nFile: " << filename << endl; - - try { - - if(info.raw_given) + if (info.mode == "dump") + return load(info); + else if (info.mode == "clone") + return clone(info); + else if (info.mode == "comp") + return comp(info); + else { - cout << "RAW file listing:\n"; - - esm.openRaw(filename); - - printRaw(esm); - - return 0; + std::cout << "Invalid or no mode specified, dying horribly. Have a nice day." << std::endl; + return 1; } - bool quiet = info.quiet_given; - bool loadCells = info.loadcells_given; + return 0; +} - esm.open(filename); +void loadCell(ESM::Cell &cell, ESM::ESMReader &esm, Arguments& info) +{ + bool quiet = (info.quiet_given || info.mode == "clone"); + bool save = (info.mode == "clone"); - cout << "Author: " << esm.getAuthor() << endl; - cout << "Description: " << esm.getDesc() << endl; - cout << "File format version: " << esm.getFVer() << endl; - cout << "Special flag: " << esm.getSpecial() << endl; - cout << "Masters:\n"; - ESMReader::MasterList m = esm.getMasters(); - for(unsigned int i=0;i skipped; + + try { + + if(info.raw_given && info.mode == "dump") + { + std::cout << "RAW file listing:\n"; + + esm.openRaw(filename); + + printRaw(esm); + + return 0; + } + + bool quiet = (info.quiet_given || info.mode == "clone"); + bool loadCells = (info.loadcells_given || info.mode == "clone"); + bool save = (info.mode == "clone"); + + esm.open(filename); + + info.data.author = esm.getAuthor(); + info.data.description = esm.getDesc(); + info.data.masters = esm.getMasters(); + info.data.version = esm.getVer(); + info.data.type = esm.getType(); + + if (!quiet) + { + 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()) + { + std::cout << "Masters:" << std::endl; + for(unsigned int i=0;igetType() == 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(); + } + + if (record->getType() == ESM::REC_CELL && loadCells) { + loadCell(record->cast()->get(), esm, info); + } + + 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; - return 1; - } + } catch(std::exception &e) { + std::cout << "\nERROR:\n\n " << e.what() << std::endl; - return 0; -} - -void loadCell(Cell &cell, ESMReader &esm, bool quiet) -{ - // Skip back to the beginning of the reference list - cell.restore(esm); - - // Loop through all the references - CellRef ref; - if(!quiet) cout << " References:\n"; - while(cell.getNextRef(esm, ref)) - { - if(quiet) continue; - - cout << " Refnum: " << ref.refnum << endl; - cout << " ID: '" << ref.refID << "'\n"; - cout << " Owner: '" << ref.owner << "'\n"; - cout << " INTV: " << ref.intv << " NAM9: " << ref.intv << endl; - } -} - -void printRaw(ESMReader &esm) -{ - while(esm.hasMoreRecs()) - { - NAME n = esm.getRecName(); - cout << "Record: " << n.toString() << endl; - esm.getRecHeader(); - while(esm.hasMoreSubs()) + typedef std::deque RecStore; + RecStore &store = info.data.mRecords; + for (RecStore::iterator it = store.begin(); it != store.end(); ++it) { - uint64_t offs = esm.getOffset(); - esm.getSubName(); - esm.skipHSub(); - n = esm.retSubName(); - cout << " " << n.toString() << " - " << esm.getSubSize() - << " bytes @ 0x" << hex << offs << "\n"; + delete *it; + } + store.clear(); + return 1; + } + + return 0; +} + +#include + +int clone(Arguments& info) +{ + if (info.outname.empty()) + { + std::cout << "You need to specify an output name" << std::endl; + return 1; + } + + if (load(info) != 0) + { + std::cout << "Failed to load, aborting." << std::endl; + return 1; + } + + int recordCount = info.data.mRecords.size(); + + int digitCount = 1; // For a nicer output + if (recordCount > 9) ++digitCount; + if (recordCount > 99) ++digitCount; + if (recordCount > 999) ++digitCount; + if (recordCount > 9999) ++digitCount; + if (recordCount > 99999) ++digitCount; + if (recordCount > 999999) ++digitCount; + + std::cout << "Loaded " << recordCount << " records:" << std::endl << std::endl; + + ESM::NAME name; + + int i = 0; + typedef std::map Stats; + Stats &stats = info.data.mRecordStats; + for (Stats::iterator it = stats.begin(); it != stats.end(); ++it) + { + name.val = it->first; + float amount = it->second; + std::cout << std::setw(digitCount) << amount << " " << name.toString() << " "; + + if (++i % 3 == 0) + std::cout << std::endl; + } + + if (i % 3 != 0) + std::cout << std::endl; + + std::cout << std::endl << "Saving records to: " << info.outname << "..." << std::endl; + + 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 (ESM::ESMReader::MasterList::iterator it = info.data.masters.begin(); it != info.data.masters.end(); ++it) + esm.addMaster(it->name, it->size); + + std::fstream save(info.outname.c_str(), std::fstream::out | std::fstream::binary); + esm.save(save); + + int saved = 0; + typedef std::deque Records; + Records &records = info.data.mRecords; + for (Records::iterator it = records.begin(); it != records.end() && i > 0; ++it) + { + EsmTool::RecordBase *record = *it; + + name.val = record->getType(); + + esm.startRecord(name.toString(), record->getFlags()); + + // TODO wrap this with std::set + 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(name.toString()); + + saved++; + int perc = (saved / (float)recordCount)*100; + if (perc % 10 == 0) + { + std::cerr << "\r" << perc << "%"; } } + + std::cout << "\rDone!" << std::endl; + + esm.close(); + save.close(); + + return 0; +} + +int comp(Arguments& info) +{ + if (info.filename.empty() || info.outname.empty()) + { + std::cout << "You need to specify two input files" << std::endl; + return 1; + } + + Arguments fileOne; + Arguments fileTwo; + + fileOne.raw_given = 0; + fileTwo.raw_given = 0; + + fileOne.mode = "clone"; + fileTwo.mode = "clone"; + + fileOne.encoding = info.encoding; + fileTwo.encoding = info.encoding; + + fileOne.filename = info.filename; + fileTwo.filename = info.outname; + + if (load(fileOne) != 0) + { + std::cout << "Failed to load " << info.filename << ", aborting comparison." << std::endl; + return 1; + } + + if (load(fileTwo) != 0) + { + std::cout << "Failed to load " << info.outname << ", aborting comparison." << std::endl; + return 1; + } + + if (fileOne.data.mRecords.size() != fileTwo.data.mRecords.size()) + { + std::cout << "Not equal, different amount of records." << std::endl; + return 1; + } + + + + + return 0; } 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/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index d32a3b045..8ca3c9aed 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include "datafilespage.hpp" diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index b86923a1d..adbfca129 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -372,7 +372,7 @@ void OMW::Engine::go() if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName)) { - MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY, + MWBase::Environment::get().getWorld()->indexToPosition (exterior->mData.mX, exterior->mData.mY, pos.pos[0], pos.pos[1], true); MWBase::Environment::get().getWorld()->changeToExteriorCell (pos); } diff --git a/apps/openmw/mwbase/soundmanager.hpp b/apps/openmw/mwbase/soundmanager.hpp index dfc619bf9..745832583 100644 --- a/apps/openmw/mwbase/soundmanager.hpp +++ b/apps/openmw/mwbase/soundmanager.hpp @@ -112,12 +112,9 @@ namespace MWBase virtual bool getSoundPlaying(MWWorld::Ptr reference, const std::string& soundId) const = 0; ///< Is the given sound currently playing on the given object? - virtual void updateObject(MWWorld::Ptr reference) = 0; - ///< Update the position of all sounds connected to the given object. - virtual void update(float duration) = 0; - virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir) = 0; + virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up) = 0; }; inline int operator|(SoundManager::PlayMode a, SoundManager::PlayMode b) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 429163136..d1daa101d 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -213,7 +213,7 @@ namespace MWBase * @param id Identifier for the GMST setting, e.g. "aName" * @param default Default value if the GMST setting cannot be used. */ - virtual const std::string &getGameSettingString(const std::string &id, const std::string &default_) = 0; + virtual std::string getGameSettingString(const std::string &id, const std::string &default_) = 0; virtual void processChangedSettings(const Settings::CategorySettingVector& changed) = 0; @@ -226,6 +226,7 @@ namespace MWBase virtual bool getRestEnabled() = 0; virtual bool getPlayerSleeping() = 0; + virtual void wakeUpPlayer() = 0; }; } diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 7b8cbd3da..e815549d8 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -41,7 +41,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -53,7 +53,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } std::string Activator::getScript (const MWWorld::Ptr& ptr) const @@ -61,7 +61,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } void Activator::registerSelf() @@ -76,7 +76,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -85,11 +85,11 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); std::string text; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); info.text = text; return info; diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 7c20eadec..a05c24e86 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -44,7 +44,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -56,7 +56,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Apparatus::activate (const MWWorld::Ptr& ptr, @@ -75,7 +75,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } int Apparatus::getValue (const MWWorld::Ptr& ptr) const @@ -83,7 +83,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Apparatus::registerSelf() @@ -108,7 +108,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const @@ -116,7 +116,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -125,17 +125,17 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; std::string text; - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->data.quality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } info.text = text; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 93d481e93..7254c37f8 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -47,7 +47,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -59,7 +59,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Armor::activate (const MWWorld::Ptr& ptr, @@ -82,7 +82,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.health; + return ref->base->mData.mHealth; } std::string Armor::getScript (const MWWorld::Ptr& ptr) const @@ -90,7 +90,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } std::pair, bool> Armor::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -118,7 +118,7 @@ namespace MWClass }; for (int i=0; ibase->data.type) + if (sMapping[i][0]==ref->base->mData.mType) { slots.push_back (int (sMapping[i][1])); break; @@ -134,7 +134,7 @@ namespace MWClass std::string typeGmst; - switch (ref->base->data.type) + switch (ref->base->mData.mType) { case ESM::Armor::Helmet: typeGmst = "iHelmWeight"; break; case ESM::Armor::Cuirass: typeGmst = "iCuirassWeight"; break; @@ -155,11 +155,11 @@ namespace MWClass float iWeight = MWBase::Environment::get().getWorld()->getStore().gameSettings.find (typeGmst)->getInt(); if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fLightMaxMod")->getFloat()>= - ref->base->data.weight) + ref->base->mData.mWeight) return ESM::Skill::LightArmor; if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMedMaxMod")->getFloat()>= - ref->base->data.weight) + ref->base->mData.mWeight) return ESM::Skill::MediumArmor; return ESM::Skill::HeavyArmor; @@ -170,7 +170,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Armor::registerSelf() @@ -207,7 +207,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const @@ -215,7 +215,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -224,8 +224,8 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; std::string text; @@ -239,20 +239,20 @@ namespace MWClass else typeText = "#{sHeavy}"; - text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->base->data.armor); + text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->base->mData.mArmor); /// \todo store the current armor health somewhere - text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->data.health); + text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->mData.mHealth); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight) + " (" + typeText + ")"; - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight) + " (" + typeText + ")"; + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } - info.enchant = ref->base->enchant; + info.enchant = ref->base->mEnchant; info.text = text; @@ -264,7 +264,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->enchant; + return ref->base->mEnchant; } boost::shared_ptr Armor::use (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 3653ad901..4a2ad1dcb 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -1,4 +1,3 @@ - #include "book.hpp" #include @@ -44,7 +43,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -56,7 +55,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Book::activate (const MWWorld::Ptr& ptr, @@ -71,7 +70,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } int Book::getValue (const MWWorld::Ptr& ptr) const @@ -79,7 +78,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Book::registerSelf() @@ -104,7 +103,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Book::hasToolTip (const MWWorld::Ptr& ptr) const @@ -112,7 +111,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -121,20 +120,20 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } - info.enchant = ref->base->enchant; + info.enchant = ref->base->mEnchant; info.text = text; @@ -146,7 +145,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->enchant; + return ref->base->mEnchant; } boost::shared_ptr Book::use (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 3dee0df89..d746350df 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -45,7 +45,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Clothing::activate (const MWWorld::Ptr& ptr, @@ -75,7 +75,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } std::pair, bool> Clothing::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -85,7 +85,7 @@ namespace MWClass std::vector slots; - if (ref->base->data.type==ESM::Clothing::Ring) + if (ref->base->mData.mType==ESM::Clothing::Ring) { slots.push_back (int (MWWorld::InventoryStore::Slot_LeftRing)); slots.push_back (int (MWWorld::InventoryStore::Slot_RightRing)); @@ -108,7 +108,7 @@ namespace MWClass }; for (int i=0; ibase->data.type) + if (sMapping[i][0]==ref->base->mData.mType) { slots.push_back (int (sMapping[i][1])); break; @@ -123,7 +123,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->data.type==ESM::Clothing::Shoes) + if (ref->base->mData.mType==ESM::Clothing::Shoes) return ESM::Skill::Unarmored; return -1; @@ -134,7 +134,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Clothing::registerSelf() @@ -149,7 +149,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->data.type == 8) + if (ref->base->mData.mType == 8) { return std::string("Item Ring Up"); } @@ -161,7 +161,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->data.type == 8) + if (ref->base->mData.mType == 8) { return std::string("Item Ring Down"); } @@ -173,7 +173,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const @@ -181,7 +181,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -190,20 +190,20 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } - info.enchant = ref->base->enchant; + info.enchant = ref->base->mEnchant; info.text = text; @@ -215,7 +215,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->enchant; + return ref->base->mEnchant; } boost::shared_ptr Clothing::use (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index be88dd631..28fa72378 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -76,7 +76,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -92,12 +92,12 @@ namespace MWClass MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer(); MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player); - bool needKey = ptr.getCellRef().lockLevel>0; + bool needKey = ptr.getCellRef().mLockLevel>0; bool hasKey = false; std::string keyName; for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - if (it->getCellRef ().refID == ptr.getCellRef().key) + if (it->getCellRef ().mRefID == ptr.getCellRef().mKey) { hasKey = true; keyName = MWWorld::Class::get(*it).getName(*it); @@ -107,15 +107,15 @@ namespace MWClass if (needKey && hasKey) { MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}", std::vector()); - ptr.getCellRef().lockLevel = 0; + ptr.getCellRef().mLockLevel = 0; // using a key disarms the trap - ptr.getCellRef().trap = ""; + ptr.getCellRef().mTrap = ""; } if (!needKey || hasKey) { - if(ptr.getCellRef().trap.empty()) + if(ptr.getCellRef().mTrap.empty()) { boost::shared_ptr action (new MWWorld::ActionOpen(ptr)); return action; @@ -123,10 +123,10 @@ namespace MWClass else { // Trap activation goes here - std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; + std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl; boost::shared_ptr action(new MWWorld::NullAction); action->setSound(trapActivationSound); - ptr.getCellRef().trap = ""; + ptr.getCellRef().mTrap = ""; return action; } } @@ -143,7 +143,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } MWWorld::ContainerStore& Container::getContainerStore (const MWWorld::Ptr& ptr) @@ -159,7 +159,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } void Container::registerSelf() @@ -174,7 +174,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -183,17 +183,17 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name; + info.caption = ref->base->mName; std::string text; - if (ref->ref.lockLevel > 0) - text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.lockLevel); - if (ref->ref.trap != "") + if (ref->ref.mLockLevel > 0) + text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.mLockLevel); + if (ref->ref.mTrap != "") text += "\n#{sTrapped}"; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } info.text = text; @@ -206,7 +206,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->weight; + return ref->base->mWeight; } float Container::getEncumbrance (const MWWorld::Ptr& ptr) const @@ -219,12 +219,12 @@ namespace MWClass if (lockLevel<0) lockLevel = 0; - ptr.getCellRef().lockLevel = lockLevel; + ptr.getCellRef().mLockLevel = lockLevel; } void Container::unlock (const MWWorld::Ptr& ptr) const { - ptr.getCellRef().lockLevel = 0; + ptr.getCellRef().mLockLevel = 0; } MWWorld::Ptr diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index d80a5c788..0cf348b14 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -47,19 +47,19 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); // creature stats - data->mCreatureStats.getAttribute(0).set (ref->base->data.strength); - data->mCreatureStats.getAttribute(1).set (ref->base->data.intelligence); - data->mCreatureStats.getAttribute(2).set (ref->base->data.willpower); - data->mCreatureStats.getAttribute(3).set (ref->base->data.agility); - data->mCreatureStats.getAttribute(4).set (ref->base->data.speed); - data->mCreatureStats.getAttribute(5).set (ref->base->data.endurance); - data->mCreatureStats.getAttribute(6).set (ref->base->data.personality); - data->mCreatureStats.getAttribute(7).set (ref->base->data.luck); - data->mCreatureStats.getHealth().set (ref->base->data.health); - data->mCreatureStats.getMagicka().set (ref->base->data.mana); - data->mCreatureStats.getFatigue().set (ref->base->data.fatigue); + data->mCreatureStats.getAttribute(0).set (ref->base->mData.mStrength); + data->mCreatureStats.getAttribute(1).set (ref->base->mData.mIntelligence); + data->mCreatureStats.getAttribute(2).set (ref->base->mData.mWillpower); + data->mCreatureStats.getAttribute(3).set (ref->base->mData.mAgility); + data->mCreatureStats.getAttribute(4).set (ref->base->mData.mSpeed); + data->mCreatureStats.getAttribute(5).set (ref->base->mData.mEndurance); + data->mCreatureStats.getAttribute(6).set (ref->base->mData.mPersonality); + data->mCreatureStats.getAttribute(7).set (ref->base->mData.mLuck); + data->mCreatureStats.getHealth().set (ref->base->mData.mHealth); + data->mCreatureStats.getMagicka().set (ref->base->mData.mMana); + data->mCreatureStats.getFatigue().set (ref->base->mData.mFatigue); - data->mCreatureStats.setLevel(ref->base->data.level); + data->mCreatureStats.setLevel(ref->base->mData.mLevel); data->mCreatureStats.setHello(ref->base->mAiData.mHello); data->mCreatureStats.setFight(ref->base->mAiData.mFight); @@ -67,8 +67,8 @@ namespace MWClass data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm); // spells - for (std::vector::const_iterator iter (ref->base->mSpells.list.begin()); - iter!=ref->base->mSpells.list.end(); ++iter) + for (std::vector::const_iterator iter (ref->base->mSpells.mList.begin()); + iter!=ref->base->mSpells.mList.end(); ++iter) data->mCreatureStats.getSpells().add (*iter); // store @@ -105,7 +105,7 @@ namespace MWClass ptr.get(); assert (ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -117,7 +117,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } MWMechanics::CreatureStats& Creature::getCreatureStats (const MWWorld::Ptr& ptr) const @@ -146,7 +146,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } void Creature::registerSelf() @@ -169,11 +169,11 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name; + info.caption = ref->base->mName; std::string text; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); info.text = text; return info; diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index ffa901fe4..b94a24ed5 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -46,7 +46,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -58,10 +58,10 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->ref.teleport && !ref->ref.destCell.empty()) // TODO doors that lead to exteriors - return ref->ref.destCell; + if (ref->ref.mTeleport && !ref->ref.mDestCell.empty()) // TODO doors that lead to exteriors + return ref->ref.mDestCell; - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Door::activate (const MWWorld::Ptr& ptr, @@ -70,7 +70,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - const std::string &openSound = ref->base->openSound; + const std::string &openSound = ref->base->mOpenSound; //const std::string &closeSound = ref->base->closeSound; const std::string lockedSound = "LockedDoor"; const std::string trapActivationSound = "Disarm Trap Fail"; @@ -78,12 +78,12 @@ namespace MWClass MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer(); MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player); - bool needKey = ptr.getCellRef().lockLevel>0; + bool needKey = ptr.getCellRef().mLockLevel>0; bool hasKey = false; std::string keyName; for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - if (it->getCellRef ().refID == ptr.getCellRef().key) + if (it->getCellRef ().mRefID == ptr.getCellRef().mKey) { hasKey = true; keyName = MWWorld::Class::get(*it).getName(*it); @@ -93,33 +93,33 @@ namespace MWClass if (needKey && hasKey) { MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}", std::vector()); - ptr.getCellRef().lockLevel = 0; + ptr.getCellRef().mLockLevel = 0; // using a key disarms the trap - ptr.getCellRef().trap = ""; + ptr.getCellRef().mTrap = ""; } if (!needKey || hasKey) { - if(!ptr.getCellRef().trap.empty()) + if(!ptr.getCellRef().mTrap.empty()) { // Trap activation - std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; + std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl; boost::shared_ptr action(new MWWorld::NullAction); action->setSound(trapActivationSound); - ptr.getCellRef().trap = ""; + ptr.getCellRef().mTrap = ""; return action; } - if (ref->ref.teleport) + if (ref->ref.mTeleport) { // teleport door /// \todo remove this if clause once ActionTeleport can also support other actors if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor) { - boost::shared_ptr action(new MWWorld::ActionTeleport (ref->ref.destCell, ref->ref.doorDest)); + boost::shared_ptr action(new MWWorld::ActionTeleport (ref->ref.mDestCell, ref->ref.mDoorDest)); action->setSound(openSound); @@ -158,12 +158,12 @@ namespace MWClass if (lockLevel<0) lockLevel = 0; - ptr.getCellRef().lockLevel = lockLevel; + ptr.getCellRef().mLockLevel = lockLevel; } void Door::unlock (const MWWorld::Ptr& ptr) const { - ptr.getCellRef().lockLevel = 0; + ptr.getCellRef().mLockLevel = 0; } std::string Door::getScript (const MWWorld::Ptr& ptr) const @@ -171,7 +171,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } void Door::registerSelf() @@ -186,7 +186,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -195,45 +195,45 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name; + info.caption = ref->base->mName; std::string text; const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); - if (ref->ref.teleport) + if (ref->ref.mTeleport) { std::string dest; - if (ref->ref.destCell != "") + if (ref->ref.mDestCell != "") { // door leads to an interior, use interior name as tooltip - dest = ref->ref.destCell; + dest = ref->ref.mDestCell; } else { // door leads to exterior, use cell name (if any), otherwise translated region name int x,y; - MWBase::Environment::get().getWorld()->positionToIndex (ref->ref.doorDest.pos[0], ref->ref.doorDest.pos[1], x, y); + MWBase::Environment::get().getWorld()->positionToIndex (ref->ref.mDoorDest.pos[0], ref->ref.mDoorDest.pos[1], x, y); const ESM::Cell* cell = store.cells.findExt(x,y); - if (cell->name != "") - dest = cell->name; + if (cell->mName != "") + dest = cell->mName; else { - const ESM::Region* region = store.regions.search(cell->region); - dest = region->name; + const ESM::Region* region = store.regions.search(cell->mRegion); + dest = region->mName; } } text += "\n#{sTo}"; text += "\n"+dest; } - if (ref->ref.lockLevel > 0) - text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.lockLevel); - if (ref->ref.trap != "") + if (ref->ref.mLockLevel > 0) + text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.mLockLevel); + if (ref->ref.mTrap != "") text += "\n#{sTrapped}"; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); info.text = text; diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 5d621caf7..45779287f 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -52,7 +52,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -64,7 +64,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Ingredient::activate (const MWWorld::Ptr& ptr, @@ -82,7 +82,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } int Ingredient::getValue (const MWWorld::Ptr& ptr) const @@ -90,7 +90,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } @@ -125,7 +125,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const @@ -133,7 +133,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -142,28 +142,28 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } MWGui::Widgets::SpellEffectList list; for (int i=0; i<4; ++i) { - if (ref->base->data.effectID[i] < 0) + if (ref->base->mData.mEffectID[i] < 0) continue; MWGui::Widgets::SpellEffectParams params; - params.mEffectID = ref->base->data.effectID[i]; - params.mAttribute = ref->base->data.attributes[i]; - params.mSkill = ref->base->data.skills[i]; + params.mEffectID = ref->base->mData.mEffectID[i]; + params.mAttribute = ref->base->mData.mAttributes[i]; + params.mSkill = ref->base->mData.mSkills[i]; list.push_back(params); } info.effects = list; diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 560bdd71d..6ae9ed661 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -29,7 +29,7 @@ namespace MWClass ptr.get(); assert (ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; MWRender::Objects& objects = renderingInterface.getObjects(); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); @@ -37,11 +37,11 @@ namespace MWClass if (!model.empty()) objects.insertMesh(ptr, "meshes\\" + model); - const int color = ref->base->data.color; + const int color = ref->base->mData.mColor; const float r = ((color >> 0) & 0xFF) / 255.0f; const float g = ((color >> 8) & 0xFF) / 255.0f; const float b = ((color >> 16) & 0xFF) / 255.0f; - const float radius = float (ref->base->data.radius); + const float radius = float (ref->base->mData.mRadius); objects.insertLight (ptr, r, g, b, radius); } @@ -51,13 +51,13 @@ namespace MWClass ptr.get(); assert (ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if(!model.empty()) { physics.insertObjectPhysics(ptr, "meshes\\" + model); } - if (!ref->base->sound.empty()) { - MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->sound, 1.0, 1.0, MWBase::SoundManager::Play_Loop); + if (!ref->base->mSound.empty()) { + MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop); } } @@ -67,7 +67,7 @@ namespace MWClass ptr.get(); assert (ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -79,10 +79,10 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->model.empty()) + if (ref->base->mModel.empty()) return ""; - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Light::activate (const MWWorld::Ptr& ptr, @@ -91,7 +91,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (!(ref->base->data.flags & ESM::Light::Carry)) + if (!(ref->base->mData.mFlags & ESM::Light::Carry)) return boost::shared_ptr (new MWWorld::NullAction); boost::shared_ptr action(new MWWorld::ActionTake (ptr)); @@ -106,7 +106,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } std::pair, bool> Light::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -116,7 +116,7 @@ namespace MWClass std::vector slots; - if (ref->base->data.flags & ESM::Light::Carry) + if (ref->base->mData.mFlags & ESM::Light::Carry) slots.push_back (int (MWWorld::InventoryStore::Slot_CarriedLeft)); return std::make_pair (slots, false); @@ -127,7 +127,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Light::registerSelf() @@ -153,7 +153,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Light::hasToolTip (const MWWorld::Ptr& ptr) const @@ -161,7 +161,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -170,17 +170,17 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } info.text = text; diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index d4c9a01d0..a0ec65c98 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -45,7 +45,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Lockpick::activate (const MWWorld::Ptr& ptr, @@ -75,7 +75,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } std::pair, bool> Lockpick::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -92,7 +92,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Lockpick::registerSelf() @@ -117,7 +117,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const @@ -125,7 +125,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -134,21 +134,21 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; std::string text; /// \todo store remaining uses somewhere - text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->data.uses); - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->data.quality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } info.text = text; diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index a2d868a6e..edcfc7daa 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -48,7 +48,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -60,7 +60,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, @@ -78,7 +78,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } int Miscellaneous::getValue (const MWWorld::Ptr& ptr) const @@ -86,7 +86,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Miscellaneous::registerSelf() @@ -101,7 +101,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->name == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (ref->base->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) { return std::string("Item Gold Up"); } @@ -113,7 +113,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - if (ref->base->name == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (ref->base->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) { return std::string("Item Gold Down"); } @@ -125,7 +125,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const @@ -133,7 +133,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -147,9 +147,9 @@ namespace MWClass int count = ptr.getRefData().getCount(); - bool isGold = (ref->base->name == store.gameSettings.find("sGold")->getString()); + bool isGold = (ref->base->mName == store.gameSettings.find("sGold")->getString()); if (isGold && count == 1) - count = ref->base->data.value; + count = ref->base->mData.mValue; std::string countString; if (!isGold) @@ -157,26 +157,26 @@ namespace MWClass else // gold displays its count also if it's 1. countString = " (" + boost::lexical_cast(count) + ")"; - info.caption = ref->base->name + countString; - info.icon = ref->base->icon; + info.caption = ref->base->mName + countString; + info.icon = ref->base->mIcon; - if (ref->ref.soul != "") + if (ref->ref.mSoul != "") { - const ESM::Creature *creature = store.creatures.search(ref->ref.soul); - info.caption += " (" + creature->name + ")"; + const ESM::Creature *creature = store.creatures.search(ref->ref.mSoul); + info.caption += " (" + creature->mName + ")"; } std::string text; if (!isGold) { - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); } if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } info.text = text; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index daf39a1ee..03b5e56aa 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -61,43 +61,43 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); // NPC stats - if (!ref->base->faction.empty()) + if (!ref->base->mFaction.empty()) { - std::string faction = ref->base->faction; + std::string faction = ref->base->mFaction; boost::algorithm::to_lower(faction); - if(ref->base->npdt52.gold != -10) + if(ref->base->mNpdt52.mGold != -10) { - data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->npdt52.rank; + data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->mNpdt52.mRank; } else { - data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->npdt12.rank; + data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->mNpdt12.mRank; } } // creature stats - if(ref->base->npdt52.gold != -10) + if(ref->base->mNpdt52.mGold != -10) { for (int i=0; i<27; ++i) - data->mNpcStats.getSkill (i).setBase (ref->base->npdt52.skills[i]); + data->mNpcStats.getSkill (i).setBase (ref->base->mNpdt52.mSkills[i]); - data->mCreatureStats.getAttribute(0).set (ref->base->npdt52.strength); - data->mCreatureStats.getAttribute(1).set (ref->base->npdt52.intelligence); - data->mCreatureStats.getAttribute(2).set (ref->base->npdt52.willpower); - data->mCreatureStats.getAttribute(3).set (ref->base->npdt52.agility); - data->mCreatureStats.getAttribute(4).set (ref->base->npdt52.speed); - data->mCreatureStats.getAttribute(5).set (ref->base->npdt52.endurance); - data->mCreatureStats.getAttribute(6).set (ref->base->npdt52.personality); - data->mCreatureStats.getAttribute(7).set (ref->base->npdt52.luck); - data->mCreatureStats.getHealth().set (ref->base->npdt52.health); - data->mCreatureStats.getMagicka().set (ref->base->npdt52.mana); - data->mCreatureStats.getFatigue().set (ref->base->npdt52.fatigue); + data->mCreatureStats.getAttribute(0).set (ref->base->mNpdt52.mStrength); + data->mCreatureStats.getAttribute(1).set (ref->base->mNpdt52.mIntelligence); + data->mCreatureStats.getAttribute(2).set (ref->base->mNpdt52.mWillpower); + data->mCreatureStats.getAttribute(3).set (ref->base->mNpdt52.mAgility); + data->mCreatureStats.getAttribute(4).set (ref->base->mNpdt52.mSpeed); + data->mCreatureStats.getAttribute(5).set (ref->base->mNpdt52.mEndurance); + data->mCreatureStats.getAttribute(6).set (ref->base->mNpdt52.mPersonality); + data->mCreatureStats.getAttribute(7).set (ref->base->mNpdt52.mLuck); + data->mCreatureStats.getHealth().set (ref->base->mNpdt52.mHealth); + data->mCreatureStats.getMagicka().set (ref->base->mNpdt52.mMana); + data->mCreatureStats.getFatigue().set (ref->base->mNpdt52.mFatigue); - data->mCreatureStats.setLevel(ref->base->npdt52.level); + data->mCreatureStats.setLevel(ref->base->mNpdt52.mLevel); } else { - /// \todo do something with npdt12 maybe:p + /// \todo do something with mNpdt12 maybe:p } data->mCreatureStats.setHello(ref->base->mAiData.mHello); @@ -106,8 +106,8 @@ namespace MWClass data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm); // spells - for (std::vector::const_iterator iter (ref->base->spells.list.begin()); - iter!=ref->base->spells.list.end(); ++iter) + for (std::vector::const_iterator iter (ref->base->mSpells.mList.begin()); + iter!=ref->base->mSpells.mList.end(); ++iter) data->mCreatureStats.getSpells().add (*iter); // store @@ -140,7 +140,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - std::string headID = ref->base->head; + std::string headID = ref->base->mHead; int end = headID.find_last_of("head_") - 4; std::string bodyRaceID = headID.substr(0, end); @@ -162,7 +162,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } MWMechanics::CreatureStats& Npc::getCreatureStats (const MWWorld::Ptr& ptr) const @@ -206,7 +206,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } void Npc::setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const @@ -301,7 +301,7 @@ namespace MWClass vector.x = getMovementSettings (ptr).mLeftRight * 127; vector.y = getMovementSettings (ptr).mForwardBackward * 127; - vector.z = getMovementSettings(ptr).mUpDown * 127; + vector.z = getMovementSettings(ptr).mUpDown * 127; //if (getStance (ptr, Run, false)) // vector *= 2; @@ -328,11 +328,11 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name; + info.caption = ref->base->mName; std::string text; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); info.text = text; return info; @@ -377,7 +377,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - ref->base->cls); + ref->base->mClass); stats.useSkill (skill, *class_, usageType); } diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 259406b37..f641cc719 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -45,7 +45,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Potion::activate (const MWWorld::Ptr& ptr, @@ -76,7 +76,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } int Potion::getValue (const MWWorld::Ptr& ptr) const @@ -84,7 +84,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Potion::registerSelf() @@ -109,7 +109,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const @@ -117,7 +117,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -126,20 +126,20 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); - info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->base->effects); + info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->base->mEffects); info.isPotion = true; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } info.text = text; diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 15ef2c1ad..39472f2ec 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -45,7 +45,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Probe::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const @@ -74,7 +74,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } std::pair, bool> Probe::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -91,7 +91,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Probe::registerSelf() @@ -116,7 +116,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const @@ -124,7 +124,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -133,21 +133,21 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; std::string text; /// \todo store remaining uses somewhere - text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->data.uses); - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->data.quality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } info.text = text; diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 7de3b3476..7ccb34913 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -43,7 +43,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -55,7 +55,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Repair::activate (const MWWorld::Ptr& ptr, @@ -73,7 +73,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } int Repair::getValue (const MWWorld::Ptr& ptr) const @@ -81,7 +81,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Repair::registerSelf() @@ -106,7 +106,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const @@ -114,7 +114,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -123,21 +123,21 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; std::string text; /// \todo store remaining uses somewhere - text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->data.uses); - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->data.quality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } info.text = text; diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index e317b740c..07ab54256 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -35,7 +35,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index a0ec16369..fee0dfdf1 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -45,7 +45,7 @@ namespace MWClass ptr.get(); assert(ref->base != NULL); - const std::string &model = ref->base->model; + const std::string &model = ref->base->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->name; + return ref->base->mName; } boost::shared_ptr Weapon::activate (const MWWorld::Ptr& ptr, @@ -80,7 +80,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.health; + return ref->base->mData.mHealth; } std::string Weapon::getScript (const MWWorld::Ptr& ptr) const @@ -88,7 +88,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->script; + return ref->base->mScript; } std::pair, bool> Weapon::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -99,12 +99,12 @@ namespace MWClass std::vector slots; bool stack = false; - if (ref->base->data.type==ESM::Weapon::Arrow || ref->base->data.type==ESM::Weapon::Bolt) + if (ref->base->mData.mType==ESM::Weapon::Arrow || ref->base->mData.mType==ESM::Weapon::Bolt) { slots.push_back (int (MWWorld::InventoryStore::Slot_Ammunition)); stack = true; } - else if (ref->base->data.type==ESM::Weapon::MarksmanThrown) + else if (ref->base->mData.mType==ESM::Weapon::MarksmanThrown) { slots.push_back (int (MWWorld::InventoryStore::Slot_CarriedRight)); stack = true; @@ -139,7 +139,7 @@ namespace MWClass }; for (int i=0; ibase->data.type) + if (sMapping[i][0]==ref->base->mData.mType) return sMapping[i][1]; return -1; @@ -150,7 +150,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->data.value; + return ref->base->mData.mValue; } void Weapon::registerSelf() @@ -165,7 +165,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - int type = ref->base->data.type; + int type = ref->base->mData.mType; // Ammo if (type == 12 || type == 13) { @@ -211,7 +211,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - int type = ref->base->data.type; + int type = ref->base->mData.mType; // Ammo if (type == 12 || type == 13) { @@ -257,7 +257,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->icon; + return ref->base->mIcon; } bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const @@ -265,7 +265,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return (ref->base->name != ""); + return (ref->base->mName != ""); } MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -274,15 +274,15 @@ namespace MWClass ptr.get(); MWGui::ToolTipInfo info; - info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->icon; + info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->base->mIcon; const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); std::string text; // weapon type & damage. arrows / bolts don't have his info. - if (ref->base->data.type < 12) + if (ref->base->mData.mType < 12) { text += "\n#{sType} "; @@ -300,49 +300,49 @@ namespace MWClass mapping[ESM::Weapon::MarksmanCrossbow] = std::make_pair("sSkillMarksman", ""); mapping[ESM::Weapon::MarksmanThrown] = std::make_pair("sSkillMarksman", ""); - std::string type = mapping[ref->base->data.type].first; - std::string oneOrTwoHanded = mapping[ref->base->data.type].second; + std::string type = mapping[ref->base->mData.mType].first; + std::string oneOrTwoHanded = mapping[ref->base->mData.mType].second; text += store.gameSettings.find(type)->getString() + ((oneOrTwoHanded != "") ? ", " + store.gameSettings.find(oneOrTwoHanded)->getString() : ""); // weapon damage - if (ref->base->data.type >= 9) + if (ref->base->mData.mType >= 9) { // marksman text += "\n#{sAttack}: " - + MWGui::ToolTips::toString(static_cast(ref->base->data.chop[0])) - + " - " + MWGui::ToolTips::toString(static_cast(ref->base->data.chop[1])); + + MWGui::ToolTips::toString(static_cast(ref->base->mData.mChop[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->base->mData.mChop[1])); } else { // Chop text += "\n#{sChop}: " - + MWGui::ToolTips::toString(static_cast(ref->base->data.chop[0])) - + " - " + MWGui::ToolTips::toString(static_cast(ref->base->data.chop[1])); + + MWGui::ToolTips::toString(static_cast(ref->base->mData.mChop[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->base->mData.mChop[1])); // Slash text += "\n#{sSlash}: " - + MWGui::ToolTips::toString(static_cast(ref->base->data.slash[0])) - + " - " + MWGui::ToolTips::toString(static_cast(ref->base->data.slash[1])); + + MWGui::ToolTips::toString(static_cast(ref->base->mData.mSlash[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->base->mData.mSlash[1])); // Thrust text += "\n#{sThrust}: " - + MWGui::ToolTips::toString(static_cast(ref->base->data.thrust[0])) - + " - " + MWGui::ToolTips::toString(static_cast(ref->base->data.thrust[1])); + + MWGui::ToolTips::toString(static_cast(ref->base->mData.mThrust[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->base->mData.mThrust[1])); } } /// \todo store the current weapon health somewhere - if (ref->base->data.type < 11) // thrown weapons and arrows/bolts don't have health, only quantity - text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->data.health); + if (ref->base->mData.mType < 11) // thrown weapons and arrows/bolts don't have health, only quantity + text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->mData.mHealth); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight); - text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); - info.enchant = ref->base->enchant; + info.enchant = ref->base->mEnchant; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); } info.text = text; @@ -355,7 +355,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return ref->base->enchant; + return ref->base->mEnchant; } boost::shared_ptr Weapon::use (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 1b7532d0a..f37955c7e 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -95,24 +95,24 @@ namespace int i = 0; - for (; i (script->varNames.size()); ++i) - if (script->varNames[i]==name) + for (; i (script->mVarNames.size()); ++i) + if (script->mVarNames[i]==name) break; - if (i>=static_cast (script->varNames.size())) + if (i>=static_cast (script->mVarNames.size())) return false; // script does not have a variable of this name const MWScript::Locals& locals = actor.getRefData().getLocals(); - if (idata.numShorts) + if (imData.mNumShorts) return selectCompare (comp, locals.mShorts[i], value); else - i -= script->data.numShorts; + i -= script->mData.mNumShorts; - if (idata.numLongs) + if (imData.mNumLongs) return selectCompare (comp, locals.mLongs[i], value); else - i -= script->data.numShorts; + i -= script->mData.mNumShorts; return selectCompare (comp, locals.mFloats.at (i), value); } @@ -160,16 +160,16 @@ namespace MWDialogue { bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name()); - for (std::vector::const_iterator iter (info.selects.begin()); - iter != info.selects.end(); ++iter) + for (std::vector::const_iterator iter (info.mSelects.begin()); + iter != info.mSelects.end(); ++iter) { ESM::DialInfo::SelectStruct select = *iter; - char type = select.selectRule[1]; + char type = select.mSelectRule[1]; if(type == '1') { - char comp = select.selectRule[4]; - std::string name = select.selectRule.substr (5); - std::string function = select.selectRule.substr(2,2); + char comp = select.mSelectRule[4]; + std::string name = select.mSelectRule.substr (5); + std::string function = select.mSelectRule.substr(2,2); int ifunction; std::istringstream iss(function); @@ -177,19 +177,19 @@ namespace MWDialogue switch(ifunction) { case 39://PC Expelled - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 40://PC Common Disease - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 41://PC Blight Disease - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 43://PC Crime level - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 46://Same faction @@ -205,71 +205,71 @@ namespace MWDialogue std::string NPCFaction = NPCstats.getFactionRanks().begin()->first; if(PCstats.getFactionRanks().find(toLower(NPCFaction)) != PCstats.getFactionRanks().end()) sameFaction = 1; } - if(!selectCompare(comp,sameFaction,select.i)) return false; + if(!selectCompare(comp,sameFaction,select.mI)) return false; } break; case 48://Detected - if(!selectCompare(comp,1,select.i)) return false; + if(!selectCompare(comp,1,select.mI)) return false; break; case 49://Alarmed - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 50://choice if(choice) { - if(!selectCompare(comp,mChoice,select.i)) return false; + if(!selectCompare(comp,mChoice,select.mI)) return false; } break; case 60://PC Vampire - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 61://Level - if(!selectCompare(comp,1,select.i)) return false; + if(!selectCompare(comp,1,select.mI)) return false; break; case 62://Attacked - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 63://Talked to PC - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 64://PC Health - if(!selectCompare(comp,50,select.i)) return false; + if(!selectCompare(comp,50,select.mI)) return false; break; case 65://Creature target - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 66://Friend hit - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 67://Fight - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 68://Hello???? - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 69://Alarm - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 70://Flee - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; case 71://Should Attack - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; break; default: @@ -287,13 +287,13 @@ namespace MWDialogue { bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name()); - char type = select.selectRule[1]; + char type = select.mSelectRule[1]; if (type!='0') { - char comp = select.selectRule[4]; - std::string name = select.selectRule.substr (5); - std::string function = select.selectRule.substr(1,2); + char comp = select.mSelectRule[4]; + std::string name = select.mSelectRule.substr (5); + std::string function = select.mSelectRule.substr(1,2); switch (type) { @@ -303,15 +303,15 @@ namespace MWDialogue case '2': // global - if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || - select.type==ESM::VT_Long) + if (select.mType==ESM::VT_Short || select.mType==ESM::VT_Int || + select.mType==ESM::VT_Long) { - if (!checkGlobal (comp, toLower (name), select.i)) + if (!checkGlobal (comp, toLower (name), select.mI)) return false; } - else if (select.type==ESM::VT_Float) + else if (select.mType==ESM::VT_Float) { - if (!checkGlobal (comp, toLower (name), select.f)) + if (!checkGlobal (comp, toLower (name), select.mF)) return false; } else @@ -322,16 +322,16 @@ namespace MWDialogue case '3': // local - if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || - select.type==ESM::VT_Long) + if (select.mType==ESM::VT_Short || select.mType==ESM::VT_Int || + select.mType==ESM::VT_Long) { - if (!checkLocal (comp, toLower (name), select.i, actor, + if (!checkLocal (comp, toLower (name), select.mI, actor, MWBase::Environment::get().getWorld()->getStore())) return false; } - else if (select.type==ESM::VT_Float) + else if (select.mType==ESM::VT_Float) { - if (!checkLocal (comp, toLower (name), select.f, actor, + if (!checkLocal (comp, toLower (name), select.mF, actor, MWBase::Environment::get().getWorld()->getStore())) return false; } @@ -342,9 +342,9 @@ namespace MWDialogue return true; case '4'://journal - if(select.type==ESM::VT_Int) + if(select.mType==ESM::VT_Int) { - if(!selectCompare(comp,MWBase::Environment::get().getJournal()->getJournalIndex(toLower(name)),select.i)) return false; + if(!selectCompare(comp,MWBase::Environment::get().getJournal()->getJournalIndex(toLower(name)),select.mI)) return false; } else throw std::runtime_error ( @@ -360,22 +360,22 @@ namespace MWDialogue int sum = 0; for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) - if (toLower(iter->getCellRef().refID) == toLower(name)) + if (toLower(iter->getCellRef().mRefID) == toLower(name)) sum += iter->getRefData().getCount(); - if(!selectCompare(comp,sum,select.i)) return false; + if(!selectCompare(comp,sum,select.mI)) return false; } return true; case '6'://dead - if(!selectCompare(comp,0,select.i)) return false; + if(!selectCompare(comp,0,select.mI)) return false; case '7':// not ID - if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string + if(select.mType==ESM::VT_String ||select.mType==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string { int isID = int(toLower(name)==toLower(MWWorld::Class::get (actor).getId (actor))); - if (selectCompare(comp,!isID,select.i)) return false; + if (selectCompare(comp,!isID,select.mI)) return false; } else throw std::runtime_error ( @@ -387,11 +387,11 @@ namespace MWDialogue if (isCreature) return false; - if(select.type==ESM::VT_Int) + if(select.mType==ESM::VT_Int) { MWWorld::LiveCellRef* npc = actor.get(); - int isFaction = int(toLower(npc->base->faction) == toLower(name)); - if(selectCompare(comp,!isFaction,select.i)) + int isFaction = int(toLower(npc->base->mFaction) == toLower(name)); + if(selectCompare(comp,!isFaction,select.mI)) return false; } else @@ -404,11 +404,11 @@ namespace MWDialogue if (isCreature) return false; - if(select.type==ESM::VT_Int) + if(select.mType==ESM::VT_Int) { MWWorld::LiveCellRef* npc = actor.get(); - int isClass = int(toLower(npc->base->cls) == toLower(name)); - if(selectCompare(comp,!isClass,select.i)) + int isClass = int(toLower(npc->base->mClass) == toLower(name)); + if(selectCompare(comp,!isClass,select.mI)) return false; } else @@ -421,11 +421,11 @@ namespace MWDialogue if (isCreature) return false; - if(select.type==ESM::VT_Int) + if(select.mType==ESM::VT_Int) { MWWorld::LiveCellRef* npc = actor.get(); - int isRace = int(toLower(npc->base->race) == toLower(name)); - if(selectCompare(comp,!isRace,select.i)) + int isRace = int(toLower(npc->base->mRace) == toLower(name)); + if(selectCompare(comp,!isRace,select.mI)) return false; } else @@ -435,10 +435,10 @@ namespace MWDialogue return true; case 'B'://not Cell - if(select.type==ESM::VT_Int) + if(select.mType==ESM::VT_Int) { - int isCell = int(toLower(actor.getCell()->cell->name) == toLower(name)); - if(selectCompare(comp,!isCell,select.i)) + int isCell = int(toLower(actor.getCell()->cell->mName) == toLower(name)); + if(selectCompare(comp,!isCell,select.mI)) return false; } else @@ -447,16 +447,16 @@ namespace MWDialogue return true; case 'C'://not local - if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || - select.type==ESM::VT_Long) + if (select.mType==ESM::VT_Short || select.mType==ESM::VT_Int || + select.mType==ESM::VT_Long) { - if (checkLocal (comp, toLower (name), select.i, actor, + if (checkLocal (comp, toLower (name), select.mI, actor, MWBase::Environment::get().getWorld()->getStore())) return false; } - else if (select.type==ESM::VT_Float) + else if (select.mType==ESM::VT_Float) { - if (checkLocal (comp, toLower (name), select.f, actor, + if (checkLocal (comp, toLower (name), select.mF, actor, MWBase::Environment::get().getWorld()->getStore())) return false; } @@ -480,12 +480,12 @@ namespace MWDialogue bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name()); // actor id - if (!info.actor.empty()) - if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor)) + if (!info.mActor.empty()) + if (toLower (info.mActor)!=MWWorld::Class::get (actor).getId (actor)) return false; //NPC race - if (!info.race.empty()) + if (!info.mRace.empty()) { if (isCreature) return false; @@ -495,12 +495,12 @@ namespace MWDialogue if (!cellRef) return false; - if (toLower (info.race)!=toLower (cellRef->base->race)) + if (toLower (info.mRace)!=toLower (cellRef->base->mRace)) return false; } //NPC class - if (!info.clas.empty()) + if (!info.mClass.empty()) { if (isCreature) return false; @@ -510,23 +510,23 @@ namespace MWDialogue if (!cellRef) return false; - if (toLower (info.clas)!=toLower (cellRef->base->cls)) + if (toLower (info.mClass)!=toLower (cellRef->base->mClass)) return false; } //NPC faction - if (!info.npcFaction.empty()) + if (!info.mNpcFaction.empty()) { if (isCreature) return false; //MWWorld::Class npcClass = MWWorld::Class::get(actor); MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor); - std::map::iterator it = stats.getFactionRanks().find(toLower(info.npcFaction)); + std::map::iterator it = stats.getFactionRanks().find(toLower(info.mNpcFaction)); if(it!=stats.getFactionRanks().end()) { //check rank - if(it->second < (int)info.data.rank) return false; + if(it->second < (int)info.mData.mRank) return false; } else { @@ -536,14 +536,14 @@ namespace MWDialogue } // TODO check player faction - if(!info.pcFaction.empty()) + if(!info.mPcFaction.empty()) { MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); - std::map::iterator it = stats.getFactionRanks().find(toLower(info.pcFaction)); + std::map::iterator it = stats.getFactionRanks().find(toLower(info.mPcFaction)); if(it!=stats.getFactionRanks().end()) { //check rank - if(it->second < (int)info.data.PCrank) return false; + if(it->second < (int)info.mData.mPCrank) return false; } else { @@ -556,24 +556,24 @@ namespace MWDialogue if (!isCreature) { MWWorld::LiveCellRef* npc = actor.get(); - if(npc->base->flags&npc->base->Female) + if(npc->base->mFlags & npc->base->Female) { - if(static_cast (info.data.gender)==0) return false; + if(static_cast (info.mData.mGender)==0) return false; } else { - if(static_cast (info.data.gender)==1) return false; + if(static_cast (info.mData.mGender)==1) return false; } } // check cell - if (!info.cell.empty()) - if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->name != info.cell) + if (!info.mCell.empty()) + if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mName != info.mCell) return false; // TODO check DATAstruct - for (std::vector::const_iterator iter (info.selects.begin()); - iter != info.selects.end(); ++iter) + for (std::vector::const_iterator iter (info.mSelects.begin()); + iter != info.mSelects.end(); ++iter) if (!isMatching (actor, *iter)) return false; @@ -646,7 +646,7 @@ namespace MWDialogue for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; - if(ndialogue.type == ESM::Dialogue::Greeting) + if(ndialogue.mType == ESM::Dialogue::Greeting) { if (greetingFound) break; for (std::vector::const_iterator iter (it->second.mInfo.begin()); @@ -654,15 +654,15 @@ namespace MWDialogue { if (isMatching (actor, *iter) && functionFilter(mActor,*iter,true)) { - if (!iter->sound.empty()) + if (!iter->mSound.empty()) { // TODO play sound } - std::string text = iter->response; + std::string text = iter->mResponse; parseText(text); - win->addText(iter->response); - executeScript(iter->resultScript); + win->addText(iter->mResponse); + executeScript(iter->mResultScript); greetingFound = true; mLastTopic = it->first; mLastDialogue = *iter; @@ -745,7 +745,7 @@ namespace MWDialogue for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; - if(ndialogue.type == ESM::Dialogue::Topic) + if(ndialogue.mType == ESM::Dialogue::Topic) { for (std::vector::const_iterator iter (it->second.mInfo.begin()); iter!=it->second.mInfo.end(); ++iter) @@ -813,21 +813,21 @@ namespace MWDialogue if(mDialogueMap.find(keyword) != mDialogueMap.end()) { ESM::Dialogue ndialogue = mDialogueMap[keyword]; - if(ndialogue.type == ESM::Dialogue::Topic) + if(ndialogue.mType == ESM::Dialogue::Topic) { for (std::vector::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) { if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { - std::string text = iter->response; - std::string script = iter->resultScript; + std::string text = iter->mResponse; + std::string script = iter->mResultScript; parseText(text); MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->addTitle(keyword); - win->addText(iter->response); + win->addText(iter->mResponse); executeScript(script); @@ -858,7 +858,7 @@ namespace MWDialogue if(mDialogueMap.find(mLastTopic) != mDialogueMap.end()) { ESM::Dialogue ndialogue = mDialogueMap[mLastTopic]; - if(ndialogue.type == ESM::Dialogue::Topic) + if(ndialogue.mType == ESM::Dialogue::Topic) { for (std::vector::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) @@ -869,10 +869,10 @@ namespace MWDialogue mChoice = -1; mIsInChoice = false; MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); - std::string text = iter->response; + std::string text = iter->mResponse; parseText(text); win->addText(text); - executeScript(iter->resultScript); + executeScript(iter->mResultScript); mLastTopic = mLastTopic; mLastDialogue = *iter; break; diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index 9d58687e1..1c6addb6e 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -22,8 +22,8 @@ namespace MWDialogue for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) - if (iter->id==mInfoId) - return iter->response; + if (iter->mId == mInfoId) + return iter->mResponse; throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic); } @@ -39,9 +39,9 @@ namespace MWDialogue for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) - if (iter->data.disposition==index) /// \todo cleanup info structure + if (iter->mData.mDisposition==index) /// \todo cleanup info structure { - return iter->id; + 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 484c2c19c..b4f02e128 100644 --- a/apps/openmw/mwdialogue/quest.cpp +++ b/apps/openmw/mwdialogue/quest.cpp @@ -22,8 +22,8 @@ namespace MWDialogue for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) - if (iter->questStatus==ESM::DialInfo::QS_Name) - return iter->response; + if (iter->mQuestStatus==ESM::DialInfo::QS_Name) + return iter->mResponse; return ""; } @@ -39,13 +39,13 @@ namespace MWDialogue for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) - if (iter->data.disposition==index && iter->questStatus!=ESM::DialInfo::QS_Name) + if (iter->mData.mDisposition==index && iter->mQuestStatus!=ESM::DialInfo::QS_Name) { mIndex = index; - if (iter->questStatus==ESM::DialInfo::QS_Finished) + if (iter->mQuestStatus==ESM::DialInfo::QS_Finished) mFinished = true; - else if (iter->questStatus==ESM::DialInfo::QS_Restart) + else if (iter->mQuestStatus==ESM::DialInfo::QS_Restart) mFinished = false; return; @@ -67,9 +67,9 @@ namespace MWDialogue for (std::vector::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) - if (iter->id==entry.mInfoId) + if (iter->mId == entry.mInfoId) { - index = iter->data.disposition; /// \todo cleanup info structure + index = iter->mData.mDisposition; /// \todo cleanup info structure break; } diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 308029810..4a419c0c0 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -112,22 +112,22 @@ namespace MWGui if (rand() % 2 == 0) /// \todo { ESM::Potion newPotion; - newPotion.name = mNameEdit->getCaption(); + newPotion.mName = mNameEdit->getCaption(); ESM::EffectList effects; for (unsigned int i=0; i<4; ++i) { if (mEffects.size() >= i+1) { ESM::ENAMstruct effect; - effect.effectID = mEffects[i].mEffectID; - effect.area = 0; - effect.range = ESM::RT_Self; - effect.skill = mEffects[i].mSkill; - effect.attribute = mEffects[i].mAttribute; - effect.magnMin = 1; /// \todo - effect.magnMax = 10; /// \todo - effect.duration = 60; /// \todo - effects.list.push_back(effect); + effect.mEffectID = mEffects[i].mEffectID; + effect.mArea = 0; + effect.mRange = ESM::RT_Self; + effect.mSkill = mEffects[i].mSkill; + effect.mAttribute = mEffects[i].mAttribute; + effect.mMagnMin = 1; /// \todo + effect.mMagnMax = 10; /// \todo + effect.mDuration = 60; /// \todo + effects.mList.push_back(effect); } } @@ -137,17 +137,17 @@ namespace MWGui // have 0 weight when using ingredients with 0.1 weight respectively float weight = 0; if (mIngredient1->isUserString("ToolTipType")) - weight += mIngredient1->getUserData()->get()->base->data.weight; + weight += mIngredient1->getUserData()->get()->base->mData.mWeight; if (mIngredient2->isUserString("ToolTipType")) - weight += mIngredient2->getUserData()->get()->base->data.weight; + weight += mIngredient2->getUserData()->get()->base->mData.mWeight; if (mIngredient3->isUserString("ToolTipType")) - weight += mIngredient3->getUserData()->get()->base->data.weight; + weight += mIngredient3->getUserData()->get()->base->mData.mWeight; if (mIngredient4->isUserString("ToolTipType")) - weight += mIngredient4->getUserData()->get()->base->data.weight; - newPotion.data.weight = weight / float(numIngreds); + weight += mIngredient4->getUserData()->get()->base->mData.mWeight; + newPotion.mData.mWeight = weight / float(numIngreds); - newPotion.data.value = 100; /// \todo - newPotion.effects = effects; + newPotion.mData.mValue = 100; /// \todo + newPotion.mEffects = effects; // pick a random mesh and icon std::vector names; /// \todo is the mesh/icon dependent on alchemy skill? @@ -158,8 +158,8 @@ namespace MWGui names.push_back("exclusive"); names.push_back("quality"); int random = rand() % names.size(); - newPotion.model = "m\\misc_potion_" + names[random ] + "_01.nif"; - newPotion.icon = "m\\tx_potion_" + names[random ] + "_01.dds"; + newPotion.mModel = "m\\misc_potion_" + names[random ] + "_01.nif"; + newPotion.mIcon = "m\\tx_potion_" + names[random ] + "_01.dds"; // check if a similiar potion record exists already bool found = false; @@ -170,24 +170,24 @@ namespace MWGui { if (found) break; - if (it->second.data.value == newPotion.data.value - && it->second.data.weight == newPotion.data.weight - && it->second.name == newPotion.name - && it->second.effects.list.size() == newPotion.effects.list.size()) + if (it->second.mData.mValue == newPotion.mData.mValue + && it->second.mData.mWeight == newPotion.mData.mWeight + && it->second.mName == newPotion.mName + && it->second.mEffects.mList.size() == newPotion.mEffects.mList.size()) { // check effects - for (unsigned int i=0; i < it->second.effects.list.size(); ++i) + for (unsigned int i=0; i < it->second.mEffects.mList.size(); ++i) { - const ESM::ENAMstruct& a = it->second.effects.list[i]; - const ESM::ENAMstruct& b = newPotion.effects.list[i]; - if (a.effectID == b.effectID - && a.area == b.area - && a.range == b.range - && a.skill == b.skill - && a.attribute == b.attribute - && a.magnMin == b.magnMin - && a.magnMax == b.magnMax - && a.duration == b.duration) + const ESM::ENAMstruct& a = it->second.mEffects.mList[i]; + const ESM::ENAMstruct& b = newPotion.mEffects.mList[i]; + if (a.mEffectID == b.mEffectID + && a.mArea == b.mArea + && a.mRange == b.mRange + && a.mSkill == b.mSkill + && a.mAttribute == b.mAttribute + && a.mMagnMin == b.mMagnMin + && a.mMagnMax == b.mMagnMax + && a.mDuration == b.mDuration) { found = true; objectId = it->first; @@ -268,17 +268,17 @@ namespace MWGui it != store.end(); ++it) { MWWorld::LiveCellRef* ref = it->get(); - if (ref->base->data.type == ESM::Apparatus::Albemic - && (bestAlbemic.isEmpty() || ref->base->data.quality > bestAlbemic.get()->base->data.quality)) + if (ref->base->mData.mType == ESM::Apparatus::Albemic + && (bestAlbemic.isEmpty() || ref->base->mData.mQuality > bestAlbemic.get()->base->mData.mQuality)) bestAlbemic = *it; - else if (ref->base->data.type == ESM::Apparatus::MortarPestle - && (bestMortarPestle.isEmpty() || ref->base->data.quality > bestMortarPestle.get()->base->data.quality)) + else if (ref->base->mData.mType == ESM::Apparatus::MortarPestle + && (bestMortarPestle.isEmpty() || ref->base->mData.mQuality > bestMortarPestle.get()->base->mData.mQuality)) bestMortarPestle = *it; - else if (ref->base->data.type == ESM::Apparatus::Calcinator - && (bestCalcinator.isEmpty() || ref->base->data.quality > bestCalcinator.get()->base->data.quality)) + else if (ref->base->mData.mType == ESM::Apparatus::Calcinator + && (bestCalcinator.isEmpty() || ref->base->mData.mQuality > bestCalcinator.get()->base->mData.mQuality)) bestCalcinator = *it; - else if (ref->base->data.type == ESM::Apparatus::Retort - && (bestRetort.isEmpty() || ref->base->data.quality > bestRetort.get()->base->data.quality)) + else if (ref->base->mData.mType == ESM::Apparatus::Retort + && (bestRetort.isEmpty() || ref->base->mData.mQuality > bestRetort.get()->base->mData.mQuality)) bestRetort = *it; } @@ -415,12 +415,12 @@ namespace MWGui MWWorld::LiveCellRef* ref = ingredient->getUserData()->get(); for (int i=0; i<4; ++i) { - if (ref->base->data.effectID[i] < 0) + if (ref->base->mData.mEffectID[i] < 0) continue; MWGui::Widgets::SpellEffectParams params; - params.mEffectID = ref->base->data.effectID[i]; - params.mAttribute = ref->base->data.attributes[i]; - params.mSkill = ref->base->data.skills[i]; + params.mEffectID = ref->base->mData.mEffectID[i]; + params.mAttribute = ref->base->mData.mAttributes[i]; + params.mSkill = ref->base->mData.mSkills[i]; effects.push_back(params); } diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 043fcd62c..c8ef35be3 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -118,7 +118,7 @@ void BirthDialog::updateBirths() for (; it != end; ++it) { const ESM::BirthSign &birth = it->second; - mBirthList->addItem(birth.name, it->first); + mBirthList->addItem(birth.mName, it->first); if (boost::iequals(it->first, mCurrentBirthId)) mBirthList->setIndexSelected(index); ++index; @@ -143,21 +143,21 @@ void BirthDialog::updateSpells() const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId); - std::string texturePath = std::string("textures\\") + birth->texture; + std::string texturePath = std::string("textures\\") + birth->mTexture; fixTexturePath(texturePath); mBirthImage->setImageTexture(texturePath); std::vector abilities, powers, spells; - std::vector::const_iterator it = birth->powers.list.begin(); - std::vector::const_iterator end = birth->powers.list.end(); + std::vector::const_iterator it = birth->mPowers.mList.begin(); + std::vector::const_iterator end = birth->mPowers.mList.end(); for (; it != end; ++it) { const std::string &spellId = *it; const ESM::Spell *spell = store.spells.search(spellId); if (!spell) continue; // Skip spells which cannot be found - ESM::Spell::SpellType type = static_cast(spell->data.type); + ESM::Spell::SpellType type = static_cast(spell->mData.mType); if (type != ESM::Spell::ST_Spell && type != ESM::Spell::ST_Ability && type != ESM::Spell::ST_Power) continue; // We only want spell, ability and powers. diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index 57e59657a..cb142db60 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -60,7 +60,7 @@ void BookWindow::open (MWWorld::Ptr book) MWWorld::LiveCellRef *ref = mBook.get(); BookTextParser parser; - std::vector results = parser.split(ref->base->text, mLeftPage->getSize().width, mLeftPage->getSize().height); + std::vector results = parser.split(ref->base->mText, mLeftPage->getSize().width, mLeftPage->getSize().height); int i=0; for (std::vector::iterator it=results.begin(); diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 0005b78ad..e5bcdbaf8 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -221,7 +221,7 @@ void CharacterCreation::spawnDialog(const char id) mPickClassDialog = 0; mPickClassDialog = new PickClassDialog(*mWM); mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen); - mPickClassDialog->setClassId(mPlayerClass.name); + mPickClassDialog->setClassId(mPlayerClass.mName); mPickClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone); mPickClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack); mPickClassDialog->setVisible(true); @@ -537,24 +537,24 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow) if (mCreateClassDialog) { ESM::Class klass; - klass.name = mCreateClassDialog->getName(); - klass.description = mCreateClassDialog->getDescription(); - klass.data.specialization = mCreateClassDialog->getSpecializationId(); - klass.data.isPlayable = 0x1; + klass.mName = mCreateClassDialog->getName(); + klass.mDescription = mCreateClassDialog->getDescription(); + klass.mData.mSpecialization = mCreateClassDialog->getSpecializationId(); + klass.mData.mIsPlayable = 0x1; std::vector attributes = mCreateClassDialog->getFavoriteAttributes(); assert(attributes.size() == 2); - klass.data.attribute[0] = attributes[0]; - klass.data.attribute[1] = attributes[1]; + klass.mData.mAttribute[0] = attributes[0]; + klass.mData.mAttribute[1] = attributes[1]; std::vector majorSkills = mCreateClassDialog->getMajorSkills(); std::vector minorSkills = mCreateClassDialog->getMinorSkills(); - assert(majorSkills.size() >= sizeof(klass.data.skills)/sizeof(klass.data.skills[0])); - assert(minorSkills.size() >= sizeof(klass.data.skills)/sizeof(klass.data.skills[0])); - for (size_t i = 0; i < sizeof(klass.data.skills)/sizeof(klass.data.skills[0]); ++i) + assert(majorSkills.size() >= sizeof(klass.mData.mSkills)/sizeof(klass.mData.mSkills[0])); + assert(minorSkills.size() >= sizeof(klass.mData.mSkills)/sizeof(klass.mData.mSkills[0])); + for (size_t i = 0; i < sizeof(klass.mData.mSkills)/sizeof(klass.mData.mSkills[0]); ++i) { - klass.data.skills[i][1] = majorSkills[i]; - klass.data.skills[i][0] = minorSkills[i]; + klass.mData.mSkills[i][1] = majorSkills[i]; + klass.mData.mSkills[i][0] = minorSkills[i]; } MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass); mPlayerClass = klass; diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 309aa5a5d..dfd9bde53 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -50,7 +50,7 @@ void GenerateClassResultDialog::setClassId(const std::string &classId) { mCurrentClassId = classId; mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds"); - mClassName->setCaption(MWBase::Environment::get().getWorld()->getStore().classes.find(mCurrentClassId)->name); + mClassName->setCaption(MWBase::Environment::get().getWorld()->getStore().classes.find(mCurrentClassId)->mName); } // widget controls @@ -183,12 +183,12 @@ void PickClassDialog::updateClasses() for (; it != end; ++it) { const ESM::Class &klass = it->second; - bool playable = (klass.data.isPlayable != 0); + bool playable = (klass.mData.mIsPlayable != 0); if (!playable) // Only display playable classes continue; const std::string &id = it->first; - mClassList->addItem(klass.name, id); + mClassList->addItem(klass.mName, id); if (boost::iequals(id, mCurrentClassId)) mClassList->setIndexSelected(index); ++index; @@ -204,7 +204,7 @@ void PickClassDialog::updateStats() if (!klass) return; - ESM::Class::Specialization specialization = static_cast(klass->data.specialization); + ESM::Class::Specialization specialization = static_cast(klass->mData.mSpecialization); static const char *specIds[3] = { "sSpecializationCombat", @@ -215,17 +215,17 @@ void PickClassDialog::updateStats() mSpecializationName->setCaption(specName); ToolTips::createSpecializationToolTip(mSpecializationName, specName, specialization); - mFavoriteAttribute[0]->setAttributeId(klass->data.attribute[0]); - mFavoriteAttribute[1]->setAttributeId(klass->data.attribute[1]); + mFavoriteAttribute[0]->setAttributeId(klass->mData.mAttribute[0]); + mFavoriteAttribute[1]->setAttributeId(klass->mData.mAttribute[1]); ToolTips::createAttributeToolTip(mFavoriteAttribute[0], mFavoriteAttribute[0]->getAttributeId()); ToolTips::createAttributeToolTip(mFavoriteAttribute[1], mFavoriteAttribute[1]->getAttributeId()); for (int i = 0; i < 5; ++i) { - mMinorSkill[i]->setSkillNumber(klass->data.skills[i][0]); - mMajorSkill[i]->setSkillNumber(klass->data.skills[i][1]); - ToolTips::createSkillToolTip(mMinorSkill[i], klass->data.skills[i][0]); - ToolTips::createSkillToolTip(mMajorSkill[i], klass->data.skills[i][1]); + mMinorSkill[i]->setSkillNumber(klass->mData.mSkills[i][0]); + mMajorSkill[i]->setSkillNumber(klass->mData.mSkills[i][1]); + ToolTips::createSkillToolTip(mMinorSkill[i], klass->mData.mSkills[i][0]); + ToolTips::createSkillToolTip(mMajorSkill[i], klass->mData.mSkills[i][1]); } mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds"); @@ -664,9 +664,9 @@ SelectSpecializationDialog::SelectSpecializationDialog(MWBase::WindowManager& pa getWidget(mSpecialization0, "Specialization0"); getWidget(mSpecialization1, "Specialization1"); getWidget(mSpecialization2, "Specialization2"); - std::string combat = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""); - std::string magic = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], ""); - std::string stealth = mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], ""); + std::string combat = mWindowManager.getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Combat], ""); + std::string magic = mWindowManager.getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Magic], ""); + std::string stealth = mWindowManager.getGameSettingString(ESM::Class::sGmstSpecializationIds[ESM::Class::Stealth], ""); mSpecialization0->setCaption(combat); mSpecialization0->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); @@ -728,7 +728,7 @@ SelectAttributeDialog::SelectAttributeDialog(MWBase::WindowManager& parWindowMan getWidget(attribute, std::string("Attribute").append(1, theIndex)); attribute->setWindowManager(&parWindowManager); - attribute->setAttributeId(ESM::Attribute::attributeIds[i]); + attribute->setAttributeId(ESM::Attribute::sAttributeIds[i]); attribute->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); ToolTips::createAttributeToolTip(attribute, attribute->getAttributeId()); } diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 86c8940a1..b939284dd 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -407,7 +407,7 @@ namespace MWGui { mPtr = object; if (!mPtr.isEmpty()) - setTitle("#{sConsoleTitle} (" + mPtr.getCellRef().refID + ")"); + setTitle("#{sConsoleTitle} (" + mPtr.getCellRef().mRefID + ")"); else setTitle("#{sConsoleTitle}"); MyGUI::InputManager::getInstance().setKeyFocusWidget(command); diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index e20cf5914..5c202941f 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -129,8 +129,8 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender) { // the player is trying to sell an item, check if the merchant accepts it // also, don't allow selling gold (let's be better than Morrowind at this, can we?) - if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object) - || MWWorld::Class::get(object).getName(object) == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object) || + MWWorld::Class::get(object).getName(object) == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) { // user notification "i don't buy this item" MWBase::Environment::get().getWindowManager()-> @@ -274,11 +274,12 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender) if (mPtr.getTypeName() == typeid(ESM::Container).name()) { MWWorld::LiveCellRef* ref = mPtr.get(); - if (ref->base->flags & ESM::Container::Organic) + if (ref->base->mFlags & ESM::Container::Organic) { // user notification MWBase::Environment::get().getWindowManager()-> messageBox("#{sContentsMessage2}", std::vector()); + return; } } @@ -302,6 +303,7 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender) // user notification MWBase::Environment::get().getWindowManager()-> messageBox("#{sContentsMessage3}", std::vector()); + return; } else diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 72dc0c7fb..ed0e59226 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -350,7 +350,7 @@ void HUD::onResChange(int width, int height) void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent) { const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - std::string spellName = spell->name; + std::string spellName = spell->mName; if (spellName != mSpellName && mSpellVisible) { mWeaponSpellTimer = 5.0f; @@ -369,8 +369,8 @@ void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent) mSpellBox->setUserString("Spell", spellId); // use the icon of the first effect - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->effects.list.front().effectID); - std::string icon = effect->icon; + const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->mEffects.mList.front().mEffectID); + std::string icon = effect->mIcon; int slashPos = icon.find("\\"); icon.insert(slashPos+1, "b_"); icon = std::string("icons\\") + icon; diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index a8c0e2ac9..bb3dc67e6 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -284,7 +284,7 @@ namespace MWGui for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - if (toLower(it->getCellRef().refID) == "gold_001") + if (toLower(it->getCellRef().mRefID) == "gold_001") return it->getRefData().getCount(); } return 0; diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 980a9e13b..7dced94f5 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -128,7 +128,7 @@ namespace MWGui std::map list = MWBase::Environment::get().getWorld()->getStore ().classes.list; for (std::map::iterator it = list.begin(); it != list.end(); ++it) { - if (playerClass.name == it->second.name) + if (playerClass.mName == it->second.mName) classId = it->first; } mClassImage->setImageTexture ("textures\\levelup\\" + classId + ".dds"); diff --git a/apps/openmw/mwgui/map_window.cpp b/apps/openmw/mwgui/map_window.cpp index 0fc4233b6..1913ed8dd 100644 --- a/apps/openmw/mwgui/map_window.cpp +++ b/apps/openmw/mwgui/map_window.cpp @@ -224,6 +224,9 @@ void LocalMapBase::setPlayerPos(const float x, const float y) { if (x == mLastPositionX && y == mLastPositionY) return; + + notifyPlayerUpdate (); + MyGUI::IntSize size = mLocalMap->getCanvasSize(); MyGUI::IntPoint middle = MyGUI::IntPoint((1/3.f + x/3.f)*size.width,(1/3.f + y/3.f)*size.height); MyGUI::IntCoord viewsize = mLocalMap->getCoord(); @@ -239,6 +242,9 @@ void LocalMapBase::setPlayerDir(const float x, const float y) { if (x == mLastDirectionX && y == mLastDirectionY) return; + + notifyPlayerUpdate (); + MyGUI::ISubWidget* main = mCompass->getSubWidgetMain(); MyGUI::RotatingSkin* rotatingSubskin = main->castType(); rotatingSubskin->setCenter(MyGUI::IntPoint(16,16)); @@ -400,10 +406,15 @@ void MapWindow::globalMapUpdatePlayer () rotatingSubskin->setCenter(MyGUI::IntPoint(16,16)); float angle = std::atan2(dir.x, dir.y); rotatingSubskin->setAngle(angle); - } - // set the view offset so that player is in the center - MyGUI::IntSize viewsize = mGlobalMap->getSize(); - MyGUI::IntPoint viewoffs(0.5*viewsize.width - worldX, 0.5*viewsize.height - worldY); - mGlobalMap->setViewOffset(viewoffs); + // set the view offset so that player is in the center + MyGUI::IntSize viewsize = mGlobalMap->getSize(); + MyGUI::IntPoint viewoffs(0.5*viewsize.width - worldX, 0.5*viewsize.height - worldY); + mGlobalMap->setViewOffset(viewoffs); + } +} + +void MapWindow::notifyPlayerUpdate () +{ + globalMapUpdatePlayer (); } diff --git a/apps/openmw/mwgui/map_window.hpp b/apps/openmw/mwgui/map_window.hpp index 042e6c8ec..73eaad1cd 100644 --- a/apps/openmw/mwgui/map_window.hpp +++ b/apps/openmw/mwgui/map_window.hpp @@ -49,6 +49,8 @@ namespace MWGui void onMarkerFocused(MyGUI::Widget* w1, MyGUI::Widget* w2); void onMarkerUnfocused(MyGUI::Widget* w1, MyGUI::Widget* w2); + virtual void notifyPlayerUpdate() {} + OEngine::GUI::Layout* mLayout; bool mMapDragAndDrop; @@ -93,6 +95,8 @@ namespace MWGui protected: virtual void onPinToggled(); + + virtual void notifyPlayerUpdate(); }; } #endif diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 89b43e0ec..e927af95d 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -32,7 +32,7 @@ namespace const ESM::Spell* a = MWBase::Environment::get().getWorld()->getStore().spells.find(left); const ESM::Spell* b = MWBase::Environment::get().getWorld()->getStore().spells.find(right); - int cmp = a->name.compare(b->name); + int cmp = a->mName.compare(b->mName); return cmp < 0; } } @@ -236,8 +236,8 @@ namespace MWGui // use the icon of the first effect const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->effects.list.front().effectID); - std::string path = effect->icon; + const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->mEffects.mList.front().mEffectID); + std::string path = effect->mIcon; int slashPos = path.find("\\"); path.insert(slashPos+1, "b_"); path = std::string("icons\\") + path; @@ -439,15 +439,15 @@ namespace MWGui while (it != spellList.end()) { const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); - if (spell->data.type == ESM::Spell::ST_Power) + if (spell->mData.mType == ESM::Spell::ST_Power) { powers.push_back(*it); it = spellList.erase(it); } - else if (spell->data.type == ESM::Spell::ST_Ability - || spell->data.type == ESM::Spell::ST_Blight - || spell->data.type == ESM::Spell::ST_Curse - || spell->data.type == ESM::Spell::ST_Disease) + else if (spell->mData.mType == ESM::Spell::ST_Ability + || spell->mData.mType == ESM::Spell::ST_Blight + || spell->mData.mType == ESM::Spell::ST_Curse + || spell->mData.mType == ESM::Spell::ST_Disease) { it = spellList.erase(it); } @@ -466,7 +466,7 @@ namespace MWGui { // only add items with "Cast once" or "Cast on use" const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(enchantId); - int type = enchant->data.type; + int type = enchant->mData.mType; if (type != ESM::Enchantment::CastOnce && type != ESM::Enchantment::WhenUsed) continue; @@ -490,7 +490,7 @@ namespace MWGui const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); MyGUI::Button* t = mMagicList->createWidget("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); - t->setCaption(spell->name); + t->setCaption(spell->mName); t->setTextAlign(MyGUI::Align::Left); t->setUserString("ToolTipType", "Spell"); t->setUserString("Spell", *it); @@ -507,7 +507,7 @@ namespace MWGui const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); MyGUI::Button* t = mMagicList->createWidget("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); - t->setCaption(spell->name); + t->setCaption(spell->mName); t->setTextAlign(MyGUI::Align::Left); t->setUserString("ToolTipType", "Spell"); t->setUserString("Spell", *it); diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 4b74ee2c8..019a59cf4 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -223,11 +223,11 @@ void RaceDialog::updateRaces() for (; it != end; ++it) { const ESM::Race &race = it->second; - bool playable = race.data.flags & ESM::Race::Playable; + bool playable = race.mData.mFlags & ESM::Race::Playable; if (!playable) // Only display playable races continue; - mRaceList->addItem(race.name, it->first); + mRaceList->addItem(race.mName, it->first); if (boost::iequals(it->first, mCurrentRaceId)) mRaceList->setIndexSelected(index); ++index; @@ -251,10 +251,10 @@ void RaceDialog::updateSkills() const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Race *race = store.races.find(mCurrentRaceId); - int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? + int count = sizeof(race->mData.mBonus)/sizeof(race->mData.mBonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? for (int i = 0; i < count; ++i) { - int skillId = race->data.bonus[i].skill; + int skillId = race->mData.mBonus[i].mSkill; if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes continue; @@ -262,7 +262,7 @@ void RaceDialog::updateSkills() std::string("Skill") + boost::lexical_cast(i)); skillWidget->setWindowManager(&mWindowManager); skillWidget->setSkillNumber(skillId); - skillWidget->setSkillValue(MWSkill::SkillValue(race->data.bonus[i].bonus)); + skillWidget->setSkillValue(MWSkill::SkillValue(race->mData.mBonus[i].mBonus)); ToolTips::createSkillToolTip(skillWidget, skillId); @@ -290,8 +290,8 @@ void RaceDialog::updateSpellPowers() const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Race *race = store.races.find(mCurrentRaceId); - std::vector::const_iterator it = race->powers.list.begin(); - std::vector::const_iterator end = race->powers.list.end(); + std::vector::const_iterator it = race->mPowers.mList.begin(); + std::vector::const_iterator end = race->mPowers.mList.end(); for (int i = 0; it != end; ++it) { const std::string &spellpower = *it; diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 411fead08..984c7d1ae 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -70,9 +70,9 @@ ReviewDialog::ReviewDialog(MWBase::WindowManager& parWindowManager) for (int idx = 0; idx < ESM::Attribute::Length; ++idx) { getWidget(attribute, std::string("Attribute") + boost::lexical_cast(idx)); - mAttributeWidgets.insert(std::make_pair(static_cast(ESM::Attribute::attributeIds[idx]), attribute)); + mAttributeWidgets.insert(std::make_pair(static_cast(ESM::Attribute::sAttributeIds[idx]), attribute)); attribute->setWindowManager(&mWindowManager); - attribute->setAttributeId(ESM::Attribute::attributeIds[idx]); + attribute->setAttributeId(ESM::Attribute::sAttributeIds[idx]); attribute->setAttributeValue(MWAttribute::AttributeValue(0, 0)); } @@ -112,14 +112,14 @@ void ReviewDialog::setRace(const std::string &raceId) if (race) { ToolTips::createRaceToolTip(mRaceWidget, race); - mRaceWidget->setCaption(race->name); + mRaceWidget->setCaption(race->mName); } } void ReviewDialog::setClass(const ESM::Class& class_) { mKlass = class_; - mClassWidget->setCaption(mKlass.name); + mClassWidget->setCaption(mKlass.mName); ToolTips::createClassToolTip(mClassWidget, mKlass); } @@ -129,7 +129,7 @@ void ReviewDialog::setBirthSign(const std::string& signId) const ESM::BirthSign *sign = MWBase::Environment::get().getWorld()->getStore().birthSigns.search(mBirthSignId); if (sign) { - mBirthSignWidget->setCaption(sign->name); + mBirthSignWidget->setCaption(sign->mName); ToolTips::createBirthsignToolTip(mBirthSignWidget, mBirthSignId); } } @@ -193,9 +193,9 @@ void ReviewDialog::configureSkills(const std::vector& major, const std::vec std::set skillSet; std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin())); std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin())); - boost::array::const_iterator end = ESM::Skill::skillIds.end(); + boost::array::const_iterator end = ESM::Skill::sSkillIds.end(); mMiscSkills.clear(); - for (boost::array::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it) + for (boost::array::const_iterator it = ESM::Skill::sSkillIds.begin(); it != end; ++it) { int skill = *it; if (skillSet.find(skill) == skillSet.end()) diff --git a/apps/openmw/mwgui/scrollwindow.cpp b/apps/openmw/mwgui/scrollwindow.cpp index ff83b0e3e..c839e9b73 100644 --- a/apps/openmw/mwgui/scrollwindow.cpp +++ b/apps/openmw/mwgui/scrollwindow.cpp @@ -36,7 +36,7 @@ void ScrollWindow::open (MWWorld::Ptr scroll) MWWorld::LiveCellRef *ref = mScroll.get(); BookTextParser parser; - MyGUI::IntSize size = parser.parse(ref->base->text, mTextView, 390); + MyGUI::IntSize size = parser.parse(ref->base->mText, mTextView, 390); if (size.height > mTextView->getSize().height) mTextView->setCanvasSize(MyGUI::IntSize(410, size.height)); diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 5306d94fe..f8d5649b9 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -51,12 +51,23 @@ namespace MWGui void SpellBuyingWindow::addSpell(const std::string& spellId) { const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - int price = spell->data.cost*MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellValueMult")->getFloat(); - MyGUI::Button* toAdd = mSpellsView->createWidget((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); + int price = spell->mData.mCost*MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellValueMult")->getFloat(); + + MyGUI::Button* toAdd = + mSpellsView->createWidget( + (price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", + 0, + mCurrentY, + 200, + sLineHeight, + MyGUI::Align::Default + ); + mCurrentY += sLineHeight; /// \todo price adjustment depending on merchantile skill + toAdd->setUserData(price); - toAdd->setCaptionWithReplacing(spell->name+" - "+boost::lexical_cast(price)+"#{sgp}"); + toAdd->setCaptionWithReplacing(spell->mName+" - "+boost::lexical_cast(price)+"#{sgp}"); toAdd->setSize(toAdd->getTextSize().width,sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel); toAdd->setUserString("ToolTipType", "Spell"); @@ -89,7 +100,7 @@ namespace MWGui { const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); - if (spell->data.type!=ESM::Spell::ST_Spell) + if (spell->mData.mType!=ESM::Spell::ST_Spell) continue; // don't try to sell diseases, curses or powers if (std::find (playerSpells.begin(), playerSpells.end(), *iter)!=playerSpells.end()) diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index bd671cab6..a203ac92b 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -29,7 +29,7 @@ namespace const ESM::Spell* a = MWBase::Environment::get().getWorld()->getStore().spells.find(left); const ESM::Spell* b = MWBase::Environment::get().getWorld()->getStore().spells.find(right); - int cmp = a->name.compare(b->name); + int cmp = a->mName.compare(b->mName); return cmp < 0; } @@ -144,15 +144,15 @@ namespace MWGui while (it != spellList.end()) { const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); - if (spell->data.type == ESM::Spell::ST_Power) + if (spell->mData.mType == ESM::Spell::ST_Power) { powers.push_back(*it); it = spellList.erase(it); } - else if (spell->data.type == ESM::Spell::ST_Ability - || spell->data.type == ESM::Spell::ST_Blight - || spell->data.type == ESM::Spell::ST_Curse - || spell->data.type == ESM::Spell::ST_Disease) + else if (spell->mData.mType == ESM::Spell::ST_Ability + || spell->mData.mType == ESM::Spell::ST_Blight + || spell->mData.mType == ESM::Spell::ST_Curse + || spell->mData.mType == ESM::Spell::ST_Disease) { it = spellList.erase(it); } @@ -171,7 +171,7 @@ namespace MWGui { // only add items with "Cast once" or "Cast on use" const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(enchantId); - int type = enchant->data.type; + int type = enchant->mData.mType; if (type != ESM::Enchantment::CastOnce && type != ESM::Enchantment::WhenUsed) continue; @@ -194,7 +194,7 @@ namespace MWGui const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); MyGUI::Button* t = mSpellView->createWidget("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); - t->setCaption(spell->name); + t->setCaption(spell->mName); t->setTextAlign(MyGUI::Align::Left); t->setUserString("ToolTipType", "Spell"); t->setUserString("Spell", *it); @@ -214,7 +214,7 @@ namespace MWGui const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); MyGUI::Button* t = mSpellView->createWidget("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); - t->setCaption(spell->name); + t->setCaption(spell->mName); t->setTextAlign(MyGUI::Align::Left); t->setUserString("ToolTipType", "Spell"); t->setUserString("Spell", *it); @@ -225,7 +225,7 @@ namespace MWGui // cost / success chance MyGUI::Button* costChance = mSpellView->createWidget("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); - std::string cost = boost::lexical_cast(spell->data.cost); + std::string cost = boost::lexical_cast(spell->mData.mCost); std::string chance = boost::lexical_cast(int(MWMechanics::getSpellSuccessChance(*it, player))); costChance->setCaption(cost + "/" + chance); costChance->setTextAlign(MyGUI::Align::Right); @@ -272,9 +272,9 @@ namespace MWGui MyGUI::Button* costCharge = mSpellView->createWidget(equipped ? "SpellText" : "SpellTextUnequipped", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); - std::string cost = boost::lexical_cast(enchant->data.cost); - std::string charge = boost::lexical_cast(enchant->data.charge); /// \todo track current charge - if (enchant->data.type == ESM::Enchantment::CastOnce) + std::string cost = boost::lexical_cast(enchant->mData.mCost); + std::string charge = boost::lexical_cast(enchant->mData.mCharge); /// \todo track current charge + if (enchant->mData.mType == ESM::Enchantment::CastOnce) { // this is Morrowind behaviour cost = "100"; @@ -379,8 +379,8 @@ namespace MWGui { // delete spell, if allowed const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - if (spell->data.flags & ESM::Spell::F_Always - || spell->data.type == ESM::Spell::ST_Power) + if (spell->mData.mFlags & ESM::Spell::F_Always + || spell->mData.mType == ESM::Spell::ST_Power) { mWindowManager.messageBox("#{sDeleteSpellError}", std::vector()); } @@ -390,7 +390,7 @@ namespace MWGui mSpellToDelete = spellId; ConfirmationDialog* dialog = mWindowManager.getConfirmationDialog(); std::string question = mWindowManager.getGameSettingString("sQuestionDeleteSpell", "Delete %s?"); - question = boost::str(boost::format(question) % spell->name); + question = boost::str(boost::format(question) % spell->mName); dialog->open(question); dialog->eventOkClicked.clear(); dialog->eventOkClicked += MyGUI::newDelegate(this, &SpellWindow::onDeleteSpellAccept); diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 9a23082e6..5a670968e 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -222,9 +222,9 @@ void StatsWindow::configureSkills (const std::vector& major, const std::vec std::set skillSet; std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin())); std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin())); - boost::array::const_iterator end = ESM::Skill::skillIds.end(); + boost::array::const_iterator end = ESM::Skill::sSkillIds.end(); mMiscSkills.clear(); - for (boost::array::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it) + for (boost::array::const_iterator it = ESM::Skill::sSkillIds.begin(); it != end; ++it) { int skill = *it; if (skillSet.find(skill) == skillSet.end()) @@ -368,7 +368,7 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; - const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->data.attribute); + const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->mData.mAttribute); assert(attr); std::string state = "normal"; @@ -384,8 +384,8 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipLayout", "SkillToolTip"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillName", "#{"+skillNameId+"}"); - mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillDescription", skill->description); - mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->name + "}"); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillDescription", skill->mDescription); + mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->mName + "}"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ImageTexture_SkillImage", icon); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillProgressText", boost::lexical_cast(progressPercent)+"/100"); mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Range_SkillProgress", "100"); @@ -451,41 +451,41 @@ void StatsWindow::updateSkillArea() for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it) { const ESM::Faction *faction = store.factions.find(it->first); - MyGUI::Widget* w = addItem(faction->name, coord1, coord2); + MyGUI::Widget* w = addItem(faction->mName, coord1, coord2); std::string text; - text += std::string("#DDC79E") + faction->name; - text += std::string("\n#BF9959") + faction->ranks[it->second]; + text += std::string("#DDC79E") + faction->mName; + text += std::string("\n#BF9959") + faction->mRanks[it->second]; if (it->second < 9) { // player doesn't have max rank yet - text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->ranks[it->second+1]; + text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[it->second+1]; - ESM::RankData rankData = faction->data.rankData[it->second+1]; - const ESM::Attribute* attr1 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->data.attribute1); - const ESM::Attribute* attr2 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->data.attribute2); + ESM::RankData rankData = faction->mData.mRankData[it->second+1]; + const ESM::Attribute* attr1 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->mData.mAttribute1); + const ESM::Attribute* attr2 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->mData.mAttribute2); assert(attr1 && attr2); - text += "\n#BF9959#{" + attr1->name + "}: " + boost::lexical_cast(rankData.attribute1) - + ", #{" + attr2->name + "}: " + boost::lexical_cast(rankData.attribute2); + text += "\n#BF9959#{" + attr1->mName + "}: " + boost::lexical_cast(rankData.mAttribute1) + + ", #{" + attr2->mName + "}: " + boost::lexical_cast(rankData.mAttribute2); text += "\n\n#DDC79E#{sFavoriteSkills}"; text += "\n#BF9959"; for (int i=0; i<6; ++i) { - text += "#{"+ESM::Skill::sSkillNameIds[faction->data.skillID[i]]+"}"; + text += "#{"+ESM::Skill::sSkillNameIds[faction->mData.mSkillID[i]]+"}"; if (i<5) text += ", "; } text += "\n"; - if (rankData.skill1 > 0) - text += "\n#{sNeedOneSkill} " + boost::lexical_cast(rankData.skill1); - if (rankData.skill2 > 0) - text += "\n#{sNeedTwoSkills} " + boost::lexical_cast(rankData.skill2); + if (rankData.mSkill1 > 0) + text += "\n#{sNeedOneSkill} " + boost::lexical_cast(rankData.mSkill1); + if (rankData.mSkill2 > 0) + text += "\n#{sNeedTwoSkills} " + boost::lexical_cast(rankData.mSkill2); } w->setUserString("ToolTipType", "Layout"); @@ -502,7 +502,7 @@ void StatsWindow::updateSkillArea() addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2); const ESM::BirthSign *sign = store.birthSigns.find(mBirthSignId); - MyGUI::Widget* w = addItem(sign->name, coord1, coord2); + MyGUI::Widget* w = addItem(sign->mName, coord1, coord2); ToolTips::createBirthsignToolTip(w, mBirthSignId); } diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index b6aea583b..cc4843841 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -184,20 +184,20 @@ void ToolTips::onFrame(float frameDuration) { ToolTipInfo info; const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find(focus->getUserString("Spell")); - info.caption = spell->name; + info.caption = spell->mName; Widgets::SpellEffectList effects; - std::vector::const_iterator end = spell->effects.list.end(); - for (std::vector::const_iterator it = spell->effects.list.begin(); it != end; ++it) + std::vector::const_iterator end = spell->mEffects.mList.end(); + for (std::vector::const_iterator it = spell->mEffects.mList.begin(); it != end; ++it) { Widgets::SpellEffectParams params; - params.mEffectID = it->effectID; - params.mSkill = it->skill; - params.mAttribute = it->attribute; - params.mDuration = it->duration; - params.mMagnMin = it->magnMin; - params.mMagnMax = it->magnMax; - params.mRange = it->range; - params.mIsConstant = (spell->data.type == ESM::Spell::ST_Ability); + params.mEffectID = it->mEffectID; + params.mSkill = it->mSkill; + params.mAttribute = it->mAttribute; + params.mDuration = it->mDuration; + params.mMagnMin = it->mMagnMin; + params.mMagnMax = it->mMagnMax; + params.mRange = it->mRange; + params.mIsConstant = (spell->mData.mType == ESM::Spell::ST_Ability); params.mNoTarget = false; effects.push_back(params); } @@ -373,13 +373,13 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info) if (info.enchant != "") { enchant = store.enchants.search(info.enchant); - if (enchant->data.type == ESM::Enchantment::CastOnce) + if (enchant->mData.mType == ESM::Enchantment::CastOnce) text += "\n#{sItemCastOnce}"; - else if (enchant->data.type == ESM::Enchantment::WhenStrikes) + else if (enchant->mData.mType == ESM::Enchantment::WhenStrikes) text += "\n#{sItemCastWhenStrikes}"; - else if (enchant->data.type == ESM::Enchantment::WhenUsed) + else if (enchant->mData.mType == ESM::Enchantment::WhenUsed) text += "\n#{sItemCastWhenUsed}"; - else if (enchant->data.type == ESM::Enchantment::ConstantEffect) + else if (enchant->mData.mType == ESM::Enchantment::ConstantEffect) text += "\n#{sItemCastConstant}"; } @@ -450,24 +450,25 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info) Widgets::MWEffectListPtr enchantWidget = enchantArea->createWidget ("MW_StatName", coord, Align::Default, "ToolTipEnchantWidget"); enchantWidget->setWindowManager(mWindowManager); - enchantWidget->setEffectList(Widgets::MWEffectList::effectListFromESM(&enchant->effects)); + enchantWidget->setEffectList(Widgets::MWEffectList::effectListFromESM(&enchant->mEffects)); std::vector enchantEffectItems; - int flag = (enchant->data.type == ESM::Enchantment::ConstantEffect) ? Widgets::MWEffectList::EF_Constant : 0; + int flag = (enchant->mData.mType == ESM::Enchantment::ConstantEffect) ? Widgets::MWEffectList::EF_Constant : 0; enchantWidget->createEffectWidgets(enchantEffectItems, enchantArea, coord, true, flag); totalSize.height += coord.top-6; totalSize.width = std::max(totalSize.width, coord.width); - if (enchant->data.type == ESM::Enchantment::WhenStrikes - || enchant->data.type == ESM::Enchantment::WhenUsed) + if (enchant->mData.mType == ESM::Enchantment::WhenStrikes + || enchant->mData.mType == ESM::Enchantment::WhenUsed) { /// \todo store the current enchantment charge somewhere - int charge = enchant->data.charge; + int charge = enchant->mData.mCharge; const int chargeWidth = 204; TextBox* chargeText = enchantArea->createWidget("SandText", IntCoord(0, 0, 10, 18), Align::Default, "ToolTipEnchantChargeText"); chargeText->setCaptionWithReplacing("#{sCharges}"); + const int chargeTextWidth = chargeText->getTextSize().width + 5; const int chargeAndTextWidth = chargeWidth + chargeTextWidth; @@ -577,15 +578,15 @@ void ToolTips::createSkillToolTip(MyGUI::Widget* widget, int skillId) const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(skillId); assert(skill); - const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->data.attribute); + const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->mData.mAttribute); assert(attr); std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "SkillNoProgressToolTip"); widget->setUserString("Caption_SkillNoProgressName", "#{"+skillNameId+"}"); - widget->setUserString("Caption_SkillNoProgressDescription", skill->description); - widget->setUserString("Caption_SkillNoProgressAttribute", "#{sGoverningAttribute}: #{" + attr->name + "}"); + widget->setUserString("Caption_SkillNoProgressDescription", skill->mDescription); + widget->setUserString("Caption_SkillNoProgressAttribute", "#{sGoverningAttribute}: #{" + attr->mName + "}"); widget->setUserString("ImageTexture_SkillNoProgressImage", icon); widget->setUserString("ToolTipLayout", "SkillNoProgressToolTip"); widget->setUserString("ToolTipLayout", "SkillNoProgressToolTip"); @@ -596,9 +597,9 @@ void ToolTips::createAttributeToolTip(MyGUI::Widget* widget, int attributeId) if (attributeId == -1) return; - std::string icon = ESM::Attribute::attributeIcons[attributeId]; - std::string name = ESM::Attribute::gmstAttributeIds[attributeId]; - std::string desc = ESM::Attribute::gmstAttributeDescIds[attributeId]; + std::string icon = ESM::Attribute::sAttributeIcons[attributeId]; + std::string name = ESM::Attribute::sGmstAttributeIds[attributeId]; + std::string desc = ESM::Attribute::sGmstAttributeDescIds[attributeId]; widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "AttributeToolTip"); @@ -616,8 +617,8 @@ void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, const std::str for (std::map::const_iterator it = skills.begin(); it != skills.end(); ++it) { - if (it->second.data.specialization == specId) - specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->second.index] + "}"; + if (it->second.mData.mSpecialization == specId) + specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->second.mIndex] + "}"; } widget->setUserString("Caption_CenteredCaptionText", specText); widget->setUserString("ToolTipLayout", "TextWithCenteredCaptionToolTip"); @@ -630,25 +631,25 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "BirthSignToolTip"); - std::string image = sign->texture; + std::string image = sign->mTexture; image.replace(image.size()-3, 3, "dds"); widget->setUserString("ImageTexture_BirthSignImage", "textures\\" + image); std::string text; - text += sign->name; - text += "\n#BF9959" + sign->description; + text += sign->mName; + text += "\n#BF9959" + sign->mDescription; std::vector abilities, powers, spells; - std::vector::const_iterator it = sign->powers.list.begin(); - std::vector::const_iterator end = sign->powers.list.end(); + std::vector::const_iterator it = sign->mPowers.mList.begin(); + std::vector::const_iterator end = sign->mPowers.mList.end(); for (; it != end; ++it) { const std::string &spellId = *it; const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.search(spellId); if (!spell) continue; // Skip spells which cannot be found - ESM::Spell::SpellType type = static_cast(spell->data.type); + ESM::Spell::SpellType type = static_cast(spell->mData.mType); if (type != ESM::Spell::ST_Spell && type != ESM::Spell::ST_Ability && type != ESM::Spell::ST_Power) continue; // We only want spell, ability and powers. @@ -678,7 +679,7 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& const std::string &spellId = *it; const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.search(spellId); - text += "\n#BF9959" + spell->name; + text += "\n#BF9959" + spell->mName; } } @@ -687,18 +688,18 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& void ToolTips::createRaceToolTip(MyGUI::Widget* widget, const ESM::Race* playerRace) { - widget->setUserString("Caption_CenteredCaption", playerRace->name); - widget->setUserString("Caption_CenteredCaptionText", playerRace->description); + widget->setUserString("Caption_CenteredCaption", playerRace->mName); + widget->setUserString("Caption_CenteredCaptionText", playerRace->mDescription); widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "TextWithCenteredCaptionToolTip"); } void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass) { - if (playerClass.name == "") + if (playerClass.mName == "") return; - int spec = playerClass.data.specialization; + int spec = playerClass.mData.mSpecialization; std::string specStr; if (spec == 0) specStr = "#{sSpecializationCombat}"; @@ -707,8 +708,8 @@ void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playe else if (spec == 2) specStr = "#{sSpecializationStealth}"; - widget->setUserString("Caption_ClassName", playerClass.name); - widget->setUserString("Caption_ClassDescription", playerClass.description); + widget->setUserString("Caption_ClassName", playerClass.mName); + widget->setUserString("Caption_ClassDescription", playerClass.mDescription); widget->setUserString("Caption_ClassSpecialisation", "#{sSpecialization}: " + specStr); widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "ClassToolTip"); diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index fc4220fc3..64710c279 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -156,15 +156,15 @@ namespace MWGui if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { MWWorld::LiveCellRef* ref = mPtr.get(); - if (ref->base->npdt52.gold == -10) - merchantgold = ref->base->npdt12.gold; + if (ref->base->mNpdt52.mGold == -10) + merchantgold = ref->base->mNpdt12.mGold; else - merchantgold = ref->base->npdt52.gold; + merchantgold = ref->base->mNpdt52.mGold; } else // ESM::Creature { MWWorld::LiveCellRef* ref = mPtr.get(); - merchantgold = ref->base->data.gold; + merchantgold = ref->base->mData.mGold; } if (mCurrentBalance > 0 && merchantgold < mCurrentBalance) { @@ -217,15 +217,15 @@ namespace MWGui if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { MWWorld::LiveCellRef* ref = mPtr.get(); - if (ref->base->npdt52.gold == -10) - merchantgold = ref->base->npdt12.gold; + if (ref->base->mNpdt52.mGold == -10) + merchantgold = ref->base->mNpdt12.mGold; else - merchantgold = ref->base->npdt52.gold; + merchantgold = ref->base->mNpdt52.mGold; } else // ESM::Creature { MWWorld::LiveCellRef* ref = mPtr.get(); - merchantgold = ref->base->data.gold; + merchantgold = ref->base->mData.mGold; } mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast(merchantgold)); diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 3210f1db9..380fb8dd5 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -202,7 +202,7 @@ namespace MWGui { MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(0.2); mProgressBar.setVisible (false); - mWindowManager.popGuiMode (); + mWindowManager.removeGuiMode (GM_Rest); mWaiting = false; MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); @@ -215,4 +215,11 @@ namespace MWGui } } + void WaitDialog::wakeUp () + { + mSleeping = false; + mWaiting = false; + stopWaiting(); + } + } diff --git a/apps/openmw/mwgui/waitdialog.hpp b/apps/openmw/mwgui/waitdialog.hpp index 4a401c0c6..6af565c6e 100644 --- a/apps/openmw/mwgui/waitdialog.hpp +++ b/apps/openmw/mwgui/waitdialog.hpp @@ -32,6 +32,7 @@ namespace MWGui void bedActivated() { setCanRest(true); } bool getSleeping() { return mWaiting && mSleeping; } + void wakeUp(); protected: MyGUI::TextBox* mDateTimeText; diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 313820534..33aa1886c 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -233,19 +233,19 @@ void MWSpell::createEffectWidgets(std::vector &effects, MyGUI: MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); MWSpellEffectPtr effect = nullptr; - std::vector::const_iterator end = spell->effects.list.end(); - for (std::vector::const_iterator it = spell->effects.list.begin(); it != end; ++it) + std::vector::const_iterator end = spell->mEffects.mList.end(); + for (std::vector::const_iterator it = spell->mEffects.mList.begin(); it != end; ++it) { effect = creator->createWidget("MW_EffectImage", coord, MyGUI::Align::Default); effect->setWindowManager(mWindowManager); SpellEffectParams params; - params.mEffectID = it->effectID; - params.mSkill = it->skill; - params.mAttribute = it->attribute; - params.mDuration = it->duration; - params.mMagnMin = it->magnMin; - params.mMagnMax = it->magnMax; - params.mRange = it->range; + params.mEffectID = it->mEffectID; + params.mSkill = it->mSkill; + params.mAttribute = it->mAttribute; + params.mDuration = it->mDuration; + params.mMagnMin = it->mMagnMin; + params.mMagnMax = it->mMagnMax; + params.mRange = it->mRange; params.mIsConstant = (flags & MWEffectList::EF_Constant); params.mNoTarget = (flags & MWEffectList::EF_NoTarget); effect->setSpellEffect(params); @@ -262,7 +262,7 @@ void MWSpell::updateWidgets() const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Spell *spell = store.spells.search(mId); if (spell) - static_cast(mSpellNameWidget)->setCaption(spell->name); + static_cast(mSpellNameWidget)->setCaption(spell->mName); else static_cast(mSpellNameWidget)->setCaption(""); } @@ -351,17 +351,17 @@ MWEffectList::~MWEffectList() SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects) { SpellEffectList result; - std::vector::const_iterator end = effects->list.end(); - for (std::vector::const_iterator it = effects->list.begin(); it != end; ++it) + std::vector::const_iterator end = effects->mList.end(); + for (std::vector::const_iterator it = effects->mList.begin(); it != end; ++it) { SpellEffectParams params; - params.mEffectID = it->effectID; - params.mSkill = it->skill; - params.mAttribute = it->attribute; - params.mDuration = it->duration; - params.mMagnMin = it->magnMin; - params.mMagnMax = it->magnMax; - params.mRange = it->range; + params.mEffectID = it->mEffectID; + params.mSkill = it->mSkill; + params.mAttribute = it->mAttribute; + params.mDuration = it->mDuration; + params.mMagnMin = it->mMagnMin; + params.mMagnMax = it->mMagnMax; + params.mRange = it->mRange; result.push_back(params); } return result; @@ -457,7 +457,7 @@ void MWSpellEffect::updateWidgets() } if (mImageWidget) { - std::string path = std::string("icons\\") + magicEffect->icon; + std::string path = std::string("icons\\") + magicEffect->mIcon; fixTexturePath(path); mImageWidget->setImageTexture(path); } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 378003e39..555767c8e 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -169,12 +169,12 @@ WindowManager::WindowManager( // Setup player stats for (int i = 0; i < ESM::Attribute::Length; ++i) { - mPlayerAttributes.insert(std::make_pair(ESM::Attribute::attributeIds[i], MWMechanics::Stat())); + mPlayerAttributes.insert(std::make_pair(ESM::Attribute::sAttributeIds[i], MWMechanics::Stat())); } for (int i = 0; i < ESM::Skill::Length; ++i) { - mPlayerSkillValues.insert(std::make_pair(ESM::Skill::skillIds[i], MWMechanics::Stat())); + mPlayerSkillValues.insert(std::make_pair(ESM::Skill::sSkillIds[i], MWMechanics::Stat())); } unsetSelectedSpell(); @@ -472,7 +472,7 @@ void WindowManager::setValue (const std::string& id, int value) void WindowManager::setPlayerClass (const ESM::Class &class_) { mPlayerClass = class_; - mStatsWindow->setValue("class", mPlayerClass.name); + mStatsWindow->setValue("class", mPlayerClass.mName); } void WindowManager::configureSkills (const SkillList& major, const SkillList& minor) @@ -524,11 +524,11 @@ int WindowManager::readPressedButton () return mMessageBoxManager->readPressedButton(); } -const std::string &WindowManager::getGameSettingString(const std::string &id, const std::string &default_) +std::string WindowManager::getGameSettingString(const std::string &id, const std::string &default_) { - const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.find(id); - if (setting && setting->type == ESM::VT_String) - return setting->str; + const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.search(id); + if (setting && setting->mType == ESM::VT_String) + return setting->getString(); return default_; } @@ -571,19 +571,19 @@ void WindowManager::onFrame (float frameDuration) void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) { - if (!(cell->cell->data.flags & ESM::Cell::Interior)) + if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) { std::string name; - if (cell->cell->name != "") + if (cell->cell->mName != "") { - name = cell->cell->name; + name = cell->cell->mName; mMap->addVisitedLocation (name, cell->cell->getGridX (), cell->cell->getGridY ()); } else { - const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->region); + const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->mRegion); if (region) - name = region->name; + name = region->mName; else name = getGameSettingString("sDefaultCellname", "Wilderness"); } @@ -593,15 +593,15 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) mMap->setCellPrefix("Cell"); mHud->setCellPrefix("Cell"); - mMap->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY ); - mHud->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY ); + mMap->setActiveCell( cell->cell->mData.mX, cell->cell->mData.mY ); + mHud->setActiveCell( cell->cell->mData.mX, cell->cell->mData.mY ); } else { - mMap->setCellName( cell->cell->name ); - mHud->setCellName( cell->cell->name ); - mMap->setCellPrefix( cell->cell->name ); - mHud->setCellPrefix( cell->cell->name ); + mMap->setCellName( cell->cell->mName ); + mHud->setCellName( cell->cell->mName ); + mMap->setCellPrefix( cell->cell->mName ); + mHud->setCellPrefix( cell->cell->mName ); } } @@ -685,8 +685,8 @@ void WindowManager::setDragDrop(bool dragDrop) void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result) { const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.find(_tag); - if (setting && setting->type == ESM::VT_String) - _result = setting->str; + if (setting && setting->mType == ESM::VT_String) + _result = setting->getString(); else _result = _tag; } @@ -776,7 +776,7 @@ void WindowManager::setSelectedSpell(const std::string& spellId, int successChan { mHud->setSelectedSpell(spellId, successChancePercent); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - mSpellWindow->setTitle(spell->name); + mSpellWindow->setTitle(spell->mName); } void WindowManager::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) @@ -960,6 +960,11 @@ bool WindowManager::getPlayerSleeping () return mWaitDialog->getSleeping(); } +void WindowManager::wakeUpPlayer() +{ + mWaitDialog->wakeUp(); +} + void WindowManager::addVisitedLocation(const std::string& name, int x, int y) { mMap->addVisitedLocation (name, x, y); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index d7773e261..f67559ccd 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -196,7 +196,7 @@ namespace MWGui * @param id Identifier for the GMST setting, e.g. "aName" * @param default Default value if the GMST setting cannot be used. */ - virtual const std::string &getGameSettingString(const std::string &id, const std::string &default_); + virtual std::string getGameSettingString(const std::string &id, const std::string &default_); virtual void processChangedSettings(const Settings::CategorySettingVector& changed); @@ -209,6 +209,7 @@ namespace MWGui virtual bool getRestEnabled() { return mRestAllowed; } virtual bool getPlayerSleeping(); + virtual void wakeUpPlayer(); private: OEngine::GUI::MyGUIManager *mGuiManager; diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 67e5bad3d..df5ea7c3f 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -65,12 +65,12 @@ namespace MWMechanics const MWWorld::TimeStamp& start = iter->second.first; float magnitude = iter->second.second; - for (std::vector::const_iterator iter (effects.first.list.begin()); - iter!=effects.first.list.end(); ++iter) + for (std::vector::const_iterator iter (effects.first.mList.begin()); + iter!=effects.first.mList.end(); ++iter) { - if (iter->duration) + if (iter->mDuration) { - int duration = iter->duration; + int duration = iter->mDuration; if (effects.second) duration *= magnitude; @@ -87,22 +87,22 @@ namespace MWMechanics { const ESM::MagicEffect *magicEffect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find ( - iter->effectID); + iter->mEffectID); - if (iter->duration==0) + if (iter->mDuration==0) { param.mMagnitude = - static_cast (magnitude / (0.1 * magicEffect->data.baseCost)); + static_cast (magnitude / (0.1 * magicEffect->mData.mBaseCost)); } else { param.mMagnitude = - static_cast (0.05*magnitude / (0.1 * magicEffect->data.baseCost)); + static_cast (0.05*magnitude / (0.1 * magicEffect->mData.mBaseCost)); } } else param.mMagnitude = static_cast ( - (iter->magnMax-iter->magnMin)*magnitude + iter->magnMin); + (iter->mMagnMax-iter->mMagnMin)*magnitude + iter->mMagnMin); mEffects.add (*iter, param); } @@ -115,32 +115,32 @@ namespace MWMechanics { if (const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.search (id)) - return std::make_pair (spell->effects, false); + return std::make_pair (spell->mEffects, false); if (const ESM::Potion *potion = MWBase::Environment::get().getWorld()->getStore().potions.search (id)) - return std::make_pair (potion->effects, false); + return std::make_pair (potion->mEffects, false); if (const ESM::Ingredient *ingredient = MWBase::Environment::get().getWorld()->getStore().ingreds.search (id)) { const ESM::MagicEffect *magicEffect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find ( - ingredient->data.effectID[0]); + ingredient->mData.mEffectID[0]); ESM::ENAMstruct effect; - effect.effectID = ingredient->data.effectID[0]; - effect.skill = ingredient->data.skills[0]; - effect.attribute = ingredient->data.attributes[0]; - effect.range = 0; - effect.area = 0; - effect.duration = magicEffect->data.flags & ESM::MagicEffect::NoDuration ? 0 : 1; - effect.magnMin = 1; - effect.magnMax = 1; + effect.mEffectID = ingredient->mData.mEffectID[0]; + effect.mSkill = ingredient->mData.mSkills[0]; + effect.mAttribute = ingredient->mData.mAttributes[0]; + effect.mRange = 0; + effect.mArea = 0; + effect.mDuration = magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration ? 0 : 1; + effect.mMagnMin = 1; + effect.mMagnMax = 1; std::pair result; - result.first.list.push_back (effect); + result.first.mList.push_back (effect); result.second = true; return result; @@ -159,10 +159,10 @@ namespace MWMechanics bool found = false; - for (std::vector::const_iterator iter (effects.first.list.begin()); - iter!=effects.first.list.end(); ++iter) + for (std::vector::const_iterator iter (effects.first.mList.begin()); + iter!=effects.first.mList.end(); ++iter) { - if (iter->duration) + if (iter->mDuration) { found = true; break; @@ -238,11 +238,11 @@ namespace MWMechanics int duration = 0; - for (std::vector::const_iterator iter (effects.first.list.begin()); - iter!=effects.first.list.end(); ++iter) + for (std::vector::const_iterator iter (effects.first.mList.begin()); + iter!=effects.first.mList.end(); ++iter) { - if (iter->duration>duration) - duration = iter->duration; + if (iter->mDuration > duration) + duration = iter->mDuration; } if (effects.second) diff --git a/apps/openmw/mwmechanics/magiceffects.cpp b/apps/openmw/mwmechanics/magiceffects.cpp index a77e19966..94363cb79 100644 --- a/apps/openmw/mwmechanics/magiceffects.cpp +++ b/apps/openmw/mwmechanics/magiceffects.cpp @@ -5,7 +5,7 @@ #include -#include +#include namespace MWMechanics { @@ -13,19 +13,19 @@ namespace MWMechanics EffectKey::EffectKey (const ESM::ENAMstruct& effect) { - mId = effect.effectID; + mId = effect.mEffectID; mArg = -1; - if (effect.skill!=-1) - mArg = effect.skill; + if (effect.mSkill!=-1) + mArg = effect.mSkill; - if (effect.attribute!=-1) + if (effect.mAttribute!=-1) { if (mArg!=-1) throw std::runtime_error ( "magic effect can't have both a skill and an attribute argument"); - mArg = effect.attribute; + mArg = effect.mAttribute; } } @@ -70,17 +70,17 @@ namespace MWMechanics void MagicEffects::add (const ESM::EffectList& list) { - for (std::vector::const_iterator iter (list.list.begin()); iter!=list.list.end(); + for (std::vector::const_iterator iter (list.mList.begin()); iter!=list.mList.end(); ++iter) { EffectParam param; - if (iter->magnMin>=iter->magnMax) - param.mMagnitude = iter->magnMin; + if (iter->mMagnMin>=iter->mMagnMax) + param.mMagnitude = iter->mMagnMin; else param.mMagnitude = static_cast ( - (iter->magnMax-iter->magnMin+1)* - (static_cast (std::rand()) / RAND_MAX) + iter->magnMin); + (iter->mMagnMax-iter->mMagnMin+1)* + (static_cast (std::rand()) / RAND_MAX) + iter->mMagnMin); add (*iter, param); } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index de016811b..364e65321 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -22,21 +22,21 @@ namespace MWMechanics const ESM::NPC *player = ptr.get()->base; // reset - creatureStats.setLevel(player->npdt52.level); + creatureStats.setLevel(player->mNpdt52.mLevel); creatureStats.getSpells().clear(); creatureStats.setMagicEffects(MagicEffects()); for (int i=0; i<27; ++i) - npcStats.getSkill (i).setBase (player->npdt52.skills[i]); + npcStats.getSkill (i).setBase (player->mNpdt52.mSkills[i]); - creatureStats.getAttribute(0).setBase (player->npdt52.strength); - creatureStats.getAttribute(1).setBase (player->npdt52.intelligence); - creatureStats.getAttribute(2).setBase (player->npdt52.willpower); - creatureStats.getAttribute(3).setBase (player->npdt52.agility); - creatureStats.getAttribute(4).setBase (player->npdt52.speed); - creatureStats.getAttribute(5).setBase (player->npdt52.endurance); - creatureStats.getAttribute(6).setBase (player->npdt52.personality); - creatureStats.getAttribute(7).setBase (player->npdt52.luck); + creatureStats.getAttribute(0).setBase (player->mNpdt52.mStrength); + creatureStats.getAttribute(1).setBase (player->mNpdt52.mIntelligence); + creatureStats.getAttribute(2).setBase (player->mNpdt52.mWillpower); + creatureStats.getAttribute(3).setBase (player->mNpdt52.mAgility); + creatureStats.getAttribute(4).setBase (player->mNpdt52.mSpeed); + creatureStats.getAttribute(5).setBase (player->mNpdt52.mEndurance); + creatureStats.getAttribute(6).setBase (player->mNpdt52.mPersonality); + creatureStats.getAttribute(7).setBase (player->mNpdt52.mLuck); // race if (mRaceSelected) @@ -52,18 +52,18 @@ namespace MWMechanics const ESM::Race::MaleFemale *attribute = 0; switch (i) { - case 0: attribute = &race->data.strength; break; - case 1: attribute = &race->data.intelligence; break; - case 2: attribute = &race->data.willpower; break; - case 3: attribute = &race->data.agility; break; - case 4: attribute = &race->data.speed; break; - case 5: attribute = &race->data.endurance; break; - case 6: attribute = &race->data.personality; break; - case 7: attribute = &race->data.luck; break; + case 0: attribute = &race->mData.mStrength; break; + case 1: attribute = &race->mData.mIntelligence; break; + case 2: attribute = &race->mData.mWillpower; break; + case 3: attribute = &race->mData.mAgility; break; + case 4: attribute = &race->mData.mSpeed; break; + case 5: attribute = &race->mData.mEndurance; break; + case 6: attribute = &race->mData.mPersonality; break; + case 7: attribute = &race->mData.mLuck; break; } creatureStats.getAttribute(i).setBase ( - static_cast (male ? attribute->male : attribute->female)); + static_cast (male ? attribute->mMale : attribute->mFemale)); } for (int i=0; i<27; ++i) @@ -71,17 +71,17 @@ namespace MWMechanics int bonus = 0; for (int i2=0; i2<7; ++i2) - if (race->data.bonus[i2].skill==i) + if (race->mData.mBonus[i2].mSkill==i) { - bonus = race->data.bonus[i2].bonus; + bonus = race->mData.mBonus[i2].mBonus; break; } npcStats.getSkill (i).setBase (5 + bonus); } - for (std::vector::const_iterator iter (race->powers.list.begin()); - iter!=race->powers.list.end(); ++iter) + for (std::vector::const_iterator iter (race->mPowers.mList.begin()); + iter!=race->mPowers.mList.end(); ++iter) { creatureStats.getSpells().add (*iter); } @@ -94,8 +94,8 @@ namespace MWMechanics MWBase::Environment::get().getWorld()->getStore().birthSigns.find ( MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); - for (std::vector::const_iterator iter (sign->powers.list.begin()); - iter!=sign->powers.list.end(); ++iter) + for (std::vector::const_iterator iter (sign->mPowers.mList.begin()); + iter!=sign->mPowers.mList.end(); ++iter) { creatureStats.getSpells().add (*iter); } @@ -108,7 +108,7 @@ namespace MWMechanics for (int i=0; i<2; ++i) { - int attribute = class_.data.attribute[i]; + int attribute = class_.mData.mAttribute[i]; if (attribute>=0 && attribute<8) { creatureStats.getAttribute(attribute).setBase ( @@ -122,7 +122,7 @@ namespace MWMechanics for (int i2=0; i2<5; ++i2) { - int index = class_.data.skills[i2][i]; + int index = class_.mData.mSkills[i2][i]; if (index>=0 && index<27) { @@ -137,7 +137,7 @@ namespace MWMechanics for (ContainerType::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter) { - if (iter->second.data.specialization==class_.data.specialization) + if (iter->second.mData.mSpecialization==class_.mData.mSpecialization) { int index = iter->first; @@ -262,9 +262,9 @@ namespace MWMechanics MWBase::Environment::get().getWindowManager()->setValue ("name", MWBase::Environment::get().getWorld()->getPlayer().getName()); MWBase::Environment::get().getWindowManager()->setValue ("race", MWBase::Environment::get().getWorld()->getStore().races.find (MWBase::Environment::get().getWorld()->getPlayer(). - getRace())->name); + getRace())->mName); MWBase::Environment::get().getWindowManager()->setValue ("class", - MWBase::Environment::get().getWorld()->getPlayer().getClass().name); + MWBase::Environment::get().getWorld()->getPlayer().getClass().mName); mUpdatePlayer = false; MWBase::WindowManager::SkillList majorSkills (5); @@ -272,8 +272,8 @@ namespace MWMechanics for (int i=0; i<5; ++i) { - minorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().data.skills[i][0]; - majorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().data.skills[i][1]; + minorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().mData.mSkills[i][0]; + majorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().mData.mSkills[i][1]; } MWBase::Environment::get().getWindowManager()->configureSkills (majorSkills, minorSkills); diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 39a5d6803..bbd42c147 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -90,7 +90,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla if (usageType>0) { - skillFactor = skill->data.useValue[usageType]; + skillFactor = skill->mData.mUseValue[usageType]; if (skillFactor<=0) throw std::runtime_error ("invalid skill gain factor"); @@ -100,7 +100,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMiscSkillBonus")->getFloat(); for (int i=0; i<5; ++i) - if (class_.data.skills[i][0]==skillIndex) + if (class_.mData.mSkills[i][0]==skillIndex) { typeFactor = MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMinorSkillBonus")->getFloat(); @@ -109,7 +109,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla } for (int i=0; i<5; ++i) - if (class_.data.skills[i][1]==skillIndex) + if (class_.mData.mSkills[i][1]==skillIndex) { typeFactor = MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMajorSkillBonus")->getFloat(); @@ -122,7 +122,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla float specialisationFactor = 1; - if (skill->data.specialization==class_.data.specialization) + if (skill->mData.mSpecialization==class_.mData.mSpecialization) { specialisationFactor = MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fSpecialSkillBonus")->getFloat(); @@ -170,7 +170,7 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas for (int i=0; i<2; ++i) for (int j=0; j<5; ++j) { - int skill = class_.data.skills[j][i]; + int skill = class_.mData.mSkills[j][i]; if (skill == skillIndex) levelProgress = true; } @@ -179,7 +179,7 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas // check the attribute this skill belongs to const ESM::Skill* skill = MWBase::Environment::get().getWorld ()->getStore ().skills.find(skillIndex); - ++mSkillIncreases[skill->data.attribute]; + ++mSkillIncreases[skill->mData.mAttribute]; // Play sound & skill progress notification /// \todo check if character is the player, if levelling is ever implemented for NPCs @@ -227,3 +227,13 @@ int MWMechanics::NpcStats::getLevelupAttributeMultiplier(int attribute) const else return 5; } + +void MWMechanics::NpcStats::flagAsUsed (const std::string& id) +{ + mUsedIds.insert (id); +} + +bool MWMechanics::NpcStats::hasBeenUsed (const std::string& id) const +{ + return mUsedIds.find (id)!=mUsedIds.end(); +} diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 7c3055783..48e63d7b6 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -50,6 +50,8 @@ namespace MWMechanics std::vector mSkillIncreases; // number of skill increases for each attribute + std::set mUsedIds; + public: NpcStats(); @@ -86,6 +88,10 @@ namespace MWMechanics int getLevelupAttributeMultiplier(int attribute) const; void levelUp(); + + void flagAsUsed (const std::string& id); + + bool hasBeenUsed (const std::string& id) const; }; } diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index 5d21d96d0..adfb35cd9 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -14,7 +14,7 @@ namespace MWMechanics { void Spells::addSpell (const ESM::Spell *spell, MagicEffects& effects) const { - effects.add (spell->effects); + effects.add (spell->mEffects); } Spells::TIterator Spells::begin() const @@ -52,8 +52,8 @@ namespace MWMechanics { const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); - if (spell->data.type==ESM::Spell::ST_Ability || spell->data.type==ESM::Spell::ST_Blight || - spell->data.type==ESM::Spell::ST_Disease || spell->data.type==ESM::Spell::ST_Curse) + if (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight || + spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse) addSpell (spell, effects); } diff --git a/apps/openmw/mwmechanics/spellsuccess.hpp b/apps/openmw/mwmechanics/spellsuccess.hpp index e4778be69..43db42aab 100644 --- a/apps/openmw/mwmechanics/spellsuccess.hpp +++ b/apps/openmw/mwmechanics/spellsuccess.hpp @@ -35,14 +35,14 @@ namespace MWMechanics // determine the spell's school // this is always the school where the player's respective skill is the least advanced // out of all the magic effects' schools - const std::vector& effects = spell->effects.list; + const std::vector& effects = spell->mEffects.mList; int school = -1; int skillLevel = -1; for (std::vector::const_iterator it = effects.begin(); it != effects.end(); ++it) { - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->effectID); - int _school = effect->data.school; + const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->mEffectID); + int _school = effect->mData.mSchool; int _skillLevel = stats.getSkill (spellSchoolToSkill(_school)).getModified(); if (school == -1) @@ -73,8 +73,8 @@ namespace MWMechanics { const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - if (spell->data.flags & ESM::Spell::F_Always // spells with this flag always succeed (usually birthsign spells) - || spell->data.type == ESM::Spell::ST_Power) // powers always succeed, but can be cast only once per day + if (spell->mData.mFlags & ESM::Spell::F_Always // spells with this flag always succeed (usually birthsign spells) + || spell->mData.mType == ESM::Spell::ST_Power) // powers always succeed, but can be cast only once per day return 100.0; NpcStats& stats = MWWorld::Class::get(actor).getNpcStats(actor); @@ -89,7 +89,7 @@ namespace MWMechanics int luck = creatureStats.getAttribute(ESM::Attribute::Luck).getModified(); int currentFatigue = creatureStats.getFatigue().getCurrent(); int maxFatigue = creatureStats.getFatigue().getModified(); - int spellCost = spell->data.cost; + int spellCost = spell->mData.mCost; // There we go, all needed variables are there, lets go float chance = (float(skillLevel * 2) + float(willpower)/5.0 + float(luck)/ 10.0 - spellCost - soundMagnitude) * (float(currentFatigue + maxFatigue * 1.5)) / float(maxFatigue * 2.0); diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index 41d02332e..05bb030d7 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -45,10 +45,10 @@ void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ Ogre::SceneNode* insert = cellnode->createChildSceneNode(); const float *f = ptr.getRefData().getPosition().pos; insert->setPosition(f[0], f[1], f[2]); - insert->setScale(ptr.getCellRef().scale, ptr.getCellRef().scale, ptr.getCellRef().scale); + insert->setScale(ptr.getCellRef().mScale, ptr.getCellRef().mScale, ptr.getCellRef().mScale); // Convert MW rotation to a quaternion: - f = ptr.getCellRef().pos.rot; + f = ptr.getCellRef().mPos.rot; // Rotate around X axis Quaternion xr(Radian(-f[0]), Vector3::UNIT_X); diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 3d7629e5b..ef92497e5 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -49,44 +49,27 @@ bool Animation::findGroupTimes(const std::string &groupname, Animation::GroupTim std::string::const_iterator strpos = iter->second.begin(); std::string::const_iterator strend = iter->second.end(); + size_t strlen = strend-strpos; - while(strpos != strend) + if(start.size() <= strlen && std::mismatch(strpos, strend, start.begin(), checklow()).first == strend) { - size_t strlen = strend-strpos; - std::string::const_iterator striter; - - if(start.size() <= strlen && - ((striter=std::mismatch(strpos, strend, start.begin(), checklow()).first) == strend || - *striter == '\r' || *striter == '\n')) - { - times->mStart = iter->first; - times->mLoopStart = iter->first; - } - else if(startloop.size() <= strlen && - ((striter=std::mismatch(strpos, strend, startloop.begin(), checklow()).first) == strend || - *striter == '\r' || *striter == '\n')) - { - times->mLoopStart = iter->first; - } - else if(stoploop.size() <= strlen && - ((striter=std::mismatch(strpos, strend, stoploop.begin(), checklow()).first) == strend || - *striter == '\r' || *striter == '\n')) - { + times->mStart = iter->first; + times->mLoopStart = iter->first; + } + else if(startloop.size() <= strlen && std::mismatch(strpos, strend, startloop.begin(), checklow()).first == strend) + { + times->mLoopStart = iter->first; + } + else if(stoploop.size() <= strlen && std::mismatch(strpos, strend, stoploop.begin(), checklow()).first == strend) + { + times->mLoopStop = iter->first; + } + else if(stop.size() <= strlen && std::mismatch(strpos, strend, stop.begin(), checklow()).first == strend) + { + times->mStop = iter->first; + if(times->mLoopStop < 0.0f) times->mLoopStop = iter->first; - } - else if(stop.size() <= strlen && - ((striter=std::mismatch(strpos, strend, stop.begin(), checklow()).first) == strend || - *striter == '\r' || *striter == '\n')) - { - times->mStop = iter->first; - if(times->mLoopStop < 0.0f) - times->mLoopStop = iter->first; - break; - } - - strpos = std::find(strpos+1, strend, '\n'); - while(strpos != strend && *strpos == '\n') - strpos++; + break; } } @@ -104,17 +87,9 @@ void Animation::playGroup(std::string groupname, int mode, int loops) times.mStart = times.mLoopStart = 0.0f; times.mLoopStop = times.mStop = 0.0f; - if(mEntityList.mSkelBase) - { - Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates(); - Ogre::AnimationStateIterator as = aset->getAnimationStateIterator(); - while(as.hasMoreElements()) - { - Ogre::AnimationState *state = as.getNext(); - times.mLoopStop = times.mStop = state->getLength(); - break; - } - } + NifOgre::TextKeyMap::const_reverse_iterator iter = mTextKeys.rbegin(); + if(iter != mTextKeys.rend()) + times.mLoopStop = times.mStop = iter->first; } else if(!findGroupTimes(groupname, ×)) throw std::runtime_error("Failed to find animation group "+groupname); diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index f755f34ef..017062baa 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -118,6 +118,9 @@ namespace MWRender void InventoryPreview::onSetup () { mSelectionBuffer = new OEngine::Render::SelectionBuffer(mCamera, 512, 1024, RV_PlayerPreview); + + mAnimation->playGroup ("inventoryhandtohand", 0, 1); + mAnimation->runAnimation (0); } // -------------------------------------------------------------------------------------------------- diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index 5e3ec9a77..afd114972 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -22,9 +22,9 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation() MWWorld::LiveCellRef *ref = ptr.get(); assert (ref->base != NULL); - if(!ref->base->model.empty()) + if(!ref->base->mModel.empty()) { - std::string mesh = "meshes\\" + ref->base->model; + std::string mesh = "meshes\\" + ref->base->mModel; mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh); for(size_t i = 0;i < mEntityList.mEntities.size();i++) diff --git a/apps/openmw/mwrender/debugging.cpp b/apps/openmw/mwrender/debugging.cpp index 91b217a36..4f7150754 100644 --- a/apps/openmw/mwrender/debugging.cpp +++ b/apps/openmw/mwrender/debugging.cpp @@ -19,6 +19,7 @@ #include "../mwworld/ptr.hpp" #include "player.hpp" +#include "renderconst.hpp" using namespace Ogre; @@ -71,21 +72,23 @@ ManualObject *Debugging::createPathgridLines(const ESM::Pathgrid *pathgrid) ManualObject *result = mSceneMgr->createManualObject(); result->begin(PATHGRID_LINE_MATERIAL, RenderOperation::OT_LINE_LIST); - for(ESM::Pathgrid::EdgeList::const_iterator it = pathgrid->edges.begin(); - it != pathgrid->edges.end(); + for(ESM::Pathgrid::EdgeList::const_iterator it = pathgrid->mEdges.begin(); + it != pathgrid->mEdges.end(); ++it) { const ESM::Pathgrid::Edge &edge = *it; - const ESM::Pathgrid::Point &p1 = pathgrid->points[edge.v0], &p2 = pathgrid->points[edge.v1]; - Vector3 direction = (Vector3(p2.x, p2.y, p2.z) - Vector3(p1.x, p1.y, p1.z)); + const ESM::Pathgrid::Point &p1 = pathgrid->mPoints[edge.mV0], &p2 = pathgrid->mPoints[edge.mV1]; + Vector3 direction = (Vector3(p2.mX, p2.mY, p2.mZ) - Vector3(p1.mX, p1.mY, p1.mZ)); Vector3 lineDisplacement = direction.crossProduct(Vector3::UNIT_Z).normalisedCopy(); lineDisplacement = lineDisplacement * POINT_MESH_BASE + Vector3(0, 0, 10); // move lines up a little, so they will be less covered by meshes/landscape - result->position(Vector3(p1.x, p1.y, p1.z) + lineDisplacement); - result->position(Vector3(p2.x, p2.y, p2.z) + lineDisplacement); + result->position(Vector3(p1.mX, p1.mY, p1.mZ) + lineDisplacement); + result->position(Vector3(p2.mX, p2.mY, p2.mZ) + lineDisplacement); } result->end(); + result->setVisibilityFlags (RV_Debug); + return result; } @@ -98,11 +101,11 @@ ManualObject *Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid) bool first = true; uint32 startIndex = 0; - for(ESM::Pathgrid::PointList::const_iterator it = pathgrid->points.begin(); - it != pathgrid->points.end(); + for(ESM::Pathgrid::PointList::const_iterator it = pathgrid->mPoints.begin(); + it != pathgrid->mPoints.end(); it++, startIndex += 6) { - Vector3 pointPos(it->x, it->y, it->z); + Vector3 pointPos(it->mX, it->mY, it->mZ); if (!first) { @@ -140,6 +143,8 @@ ManualObject *Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid) result->end(); + result->setVisibilityFlags (RV_Debug); + return result; } @@ -229,8 +234,8 @@ void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store) Vector3 cellPathGridPos(0, 0, 0); if (store->cell->isExterior()) { - cellPathGridPos.x = store->cell->data.gridX * ESM::Land::REAL_SIZE; - cellPathGridPos.y = store->cell->data.gridY * ESM::Land::REAL_SIZE; + cellPathGridPos.x = store->cell->mData.mX * ESM::Land::REAL_SIZE; + cellPathGridPos.y = store->cell->mData.mY * ESM::Land::REAL_SIZE; } SceneNode *cellPathGrid = mPathGridRoot->createChildSceneNode(cellPathGridPos); cellPathGrid->attachObject(createPathgridLines(pathgrid)); @@ -238,7 +243,7 @@ void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store) if (store->cell->isExterior()) { - mExteriorPathgridNodes[std::make_pair(store->cell->data.gridX, store->cell->data.gridY)] = cellPathGrid; + mExteriorPathgridNodes[std::make_pair(store->cell->mData.mX, store->cell->mData.mY)] = cellPathGrid; } else { @@ -252,7 +257,7 @@ void Debugging::disableCellPathgrid(MWWorld::Ptr::CellStore *store) if (store->cell->isExterior()) { ExteriorPathgridNodes::iterator it = - mExteriorPathgridNodes.find(std::make_pair(store->cell->data.gridX, store->cell->data.gridY)); + mExteriorPathgridNodes.find(std::make_pair(store->cell->mData.mX, store->cell->mData.mY)); if (it != mExteriorPathgridNodes.end()) { destroyCellPathgridNode(it->second); diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 5e0a63c77..c23fdc1a3 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -63,9 +63,9 @@ namespace MWRender if (land) { - if (!land->dataLoaded) + if (!land->isDataLoaded(ESM::Land::DATA_VHGT)) { - land->loadData(); + land->loadData(ESM::Land::DATA_VHGT); } } @@ -93,7 +93,7 @@ namespace MWRender if (land) { - float landHeight = land->landData->heights[vertexY * ESM::Land::LAND_SIZE + vertexX]; + float landHeight = land->mLandData->mHeights[vertexY * ESM::Land::LAND_SIZE + vertexX]; if (landHeight >= 0) diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index e254a2f0a..1bdbce6d9 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -108,10 +108,10 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell) mCameraRotNode->setOrientation(Quaternion::IDENTITY); - std::string name = "Cell_"+coordStr(cell->cell->data.gridX, cell->cell->data.gridY); + std::string name = "Cell_"+coordStr(cell->cell->mData.mX, cell->cell->mData.mY); - int x = cell->cell->data.gridX; - int y = cell->cell->data.gridY; + int x = cell->cell->mData.mX; + int y = cell->cell->mData.mY; mCameraPosNode->setPosition(Vector3(0,0,0)); @@ -163,7 +163,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell, const int segsX = std::ceil( length.x / sSize ); const int segsY = std::ceil( length.y / sSize ); - mInteriorName = cell->cell->name; + mInteriorName = cell->cell->mName; for (int x=0; xcell->name + "_" + coordStr(x,y)); + cell->cell->mName + "_" + coordStr(x,y)); } } } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 5d1d3d690..5c2b05aca 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -63,18 +63,18 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor } const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Race *race = store.races.find(ref->base->race); + const ESM::Race *race = store.races.find(ref->base->mRace); - std::string hairID = ref->base->hair; - std::string headID = ref->base->head; - headModel = "meshes\\" + store.bodyParts.find(headID)->model; - hairModel = "meshes\\" + store.bodyParts.find(hairID)->model; - npcName = ref->base->name; + std::string hairID = ref->base->mHair; + std::string headID = ref->base->mHead; + headModel = "meshes\\" + store.bodyParts.find(headID)->mModel; + hairModel = "meshes\\" + store.bodyParts.find(hairID)->mModel; + npcName = ref->base->mName; - isFemale = !!(ref->base->flags&ESM::NPC::Female); - isBeast = !!(race->data.flags&ESM::Race::Beast); + isFemale = !!(ref->base->mFlags&ESM::NPC::Female); + isBeast = !!(race->mData.mFlags&ESM::Race::Beast); - bodyRaceID = "b_n_"+ref->base->race; + bodyRaceID = "b_n_"+ref->base->mRace; std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower); @@ -123,12 +123,12 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor } } + float scale = race->mData.mHeight.mMale; + if (isFemale) { + scale = race->mData.mHeight.mFemale; + } + mInsert->scale(scale, scale, scale); - - if(isFemale) - mInsert->scale(race->data.height.female, race->data.height.female, race->data.height.female); - else - mInsert->scale(race->data.height.male, race->data.height.male, race->data.height.male); updateParts(); } @@ -171,7 +171,7 @@ void NpcAnimation::updateParts() MWWorld::Ptr ptr = *robe; const ESM::Clothing *clothes = (ptr.get())->base; - std::vector parts = clothes->parts.parts; + std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts); reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Robe, 5); reserveIndividualPart(ESM::PRT_Skirt, MWWorld::InventoryStore::Slot_Robe, 5); @@ -191,7 +191,7 @@ void NpcAnimation::updateParts() MWWorld::Ptr ptr = *skirtiter; const ESM::Clothing *clothes = (ptr.get())->base; - std::vector parts = clothes->parts.parts; + std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Skirt, 4, parts); reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Skirt, 4); reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Skirt, 4); @@ -202,32 +202,32 @@ void NpcAnimation::updateParts() { removeIndividualPart(ESM::PRT_Hair); const ESM::Armor *armor = (helmet->get())->base; - std::vector parts = armor->parts.parts; + std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); } if(cuirass != mInv.end()) { const ESM::Armor *armor = (cuirass->get())->base; - std::vector parts = armor->parts.parts; + std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); } if(greaves != mInv.end()) { const ESM::Armor *armor = (greaves->get())->base; - std::vector parts = armor->parts.parts; + std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); } if(leftpauldron != mInv.end()) { const ESM::Armor *armor = (leftpauldron->get())->base; - std::vector parts = armor->parts.parts; + std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts); } if(rightpauldron != mInv.end()) { const ESM::Armor *armor = (rightpauldron->get())->base; - std::vector parts = armor->parts.parts; + std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); } if(boots != mInv.end()) @@ -235,13 +235,13 @@ void NpcAnimation::updateParts() if(boots->getTypeName() == typeid(ESM::Clothing).name()) { const ESM::Clothing *clothes = (boots->get())->base; - std::vector parts = clothes->parts.parts; + std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); } else if(boots->getTypeName() == typeid(ESM::Armor).name()) { const ESM::Armor *armor = (boots->get())->base; - std::vector parts = armor->parts.parts; + std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts); } } @@ -250,13 +250,13 @@ void NpcAnimation::updateParts() if(leftglove->getTypeName() == typeid(ESM::Clothing).name()) { const ESM::Clothing *clothes = (leftglove->get())->base; - std::vector parts = clothes->parts.parts; + std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); } else { const ESM::Armor *armor = (leftglove->get())->base; - std::vector parts = armor->parts.parts; + std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts); } } @@ -265,13 +265,13 @@ void NpcAnimation::updateParts() if(rightglove->getTypeName() == typeid(ESM::Clothing).name()) { const ESM::Clothing *clothes = (rightglove->get())->base; - std::vector parts = clothes->parts.parts; + std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); } else { const ESM::Armor *armor = (rightglove->get())->base; - std::vector parts = armor->parts.parts; + std::vector parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts); } @@ -280,13 +280,13 @@ void NpcAnimation::updateParts() if(shirt != mInv.end()) { const ESM::Clothing *clothes = (shirt->get())->base; - std::vector parts = clothes->parts.parts; + std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); } if(pants != mInv.end()) { const ESM::Clothing *clothes = (pants->get())->base; - std::vector parts = clothes->parts.parts; + std::vector parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts); } } @@ -344,7 +344,7 @@ void NpcAnimation::updateParts() } while(1); if(part) - addOrReplaceIndividualPart(PartTypeList[i].type, -1,1, "meshes\\"+part->model); + addOrReplaceIndividualPart(PartTypeList[i].type, -1,1, "meshes\\"+part->mModel); } } } @@ -571,14 +571,14 @@ void NpcAnimation::addPartGroup(int group, int priority, std::vectorgetStore().bodyParts.search(part.female); + bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search(part.mFemale); if(!bodypart) - bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search(part.male); + bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search(part.mMale); if(bodypart) - addOrReplaceIndividualPart(part.part, group, priority,"meshes\\" + bodypart->model); + addOrReplaceIndividualPart(part.mPart, group, priority,"meshes\\" + bodypart->mModel); else - reserveIndividualPart(part.part, group, priority); + reserveIndividualPart(part.mPart, group, priority); } } diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 2a90dea5d..69c853d86 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -64,11 +64,11 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_) const float *f = ptr.getRefData().getPosition().pos; insert->setPosition(f[0], f[1], f[2]); - insert->setScale(ptr.getCellRef().scale, ptr.getCellRef().scale, ptr.getCellRef().scale); + insert->setScale(ptr.getCellRef().mScale, ptr.getCellRef().mScale, ptr.getCellRef().mScale); // Convert MW rotation to a quaternion: - f = ptr.getCellRef().pos.rot; + f = ptr.getCellRef().mPos.rot; // Rotate around X axis Ogre::Quaternion xr(Ogre::Radian(-f[0]), Ogre::Vector3::UNIT_X); @@ -219,18 +219,18 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f info.radius = radius; info.colour = Ogre::ColourValue(r, g, b); - if (ref->base->data.flags & ESM::Light::Negative) + if (ref->base->mData.mFlags & ESM::Light::Negative) info.colour *= -1; - info.interior = (ptr.getCell()->cell->data.flags & ESM::Cell::Interior); + info.interior = (ptr.getCell()->cell->mData.mFlags & ESM::Cell::Interior); - if (ref->base->data.flags & ESM::Light::Flicker) + if (ref->base->mData.mFlags & ESM::Light::Flicker) info.type = LT_Flicker; - else if (ref->base->data.flags & ESM::Light::FlickerSlow) + else if (ref->base->mData.mFlags & ESM::Light::FlickerSlow) info.type = LT_FlickerSlow; - else if (ref->base->data.flags & ESM::Light::Pulse) + else if (ref->base->mData.mFlags & ESM::Light::Pulse) info.type = LT_Pulse; - else if (ref->base->data.flags & ESM::Light::PulseSlow) + else if (ref->base->mData.mFlags & ESM::Light::PulseSlow) info.type = LT_PulseSlow; else info.type = LT_Normal; diff --git a/apps/openmw/mwrender/player.cpp b/apps/openmw/mwrender/player.cpp index 8c8bbb86f..bbc75cade 100644 --- a/apps/openmw/mwrender/player.cpp +++ b/apps/openmw/mwrender/player.cpp @@ -94,7 +94,6 @@ namespace MWRender } else { mCameraNode->setOrientation(zr * xr); } - updateListener(); } std::string Player::getHandle() const @@ -111,16 +110,20 @@ namespace MWRender { Ogre::Vector3 pos = mCamera->getRealPosition(); Ogre::Vector3 dir = mCamera->getRealDirection(); + Ogre::Vector3 up = mCamera->getRealUp(); Ogre::Real xch; xch = pos.y, pos.y = -pos.z, pos.z = xch; xch = dir.y, dir.y = -dir.z, dir.z = xch; + xch = up.y, up.y = -up.z, up.z = xch; - MWBase::Environment::get().getSoundManager()->setListenerPosDir(pos, dir); + MWBase::Environment::get().getSoundManager()->setListenerPosDir(pos, dir, up); } void Player::update(float duration) { + updateListener(); + // only show the crosshair in game mode and in first person mode. MWBase::Environment::get().getWindowManager ()->showCrosshair (!MWBase::Environment::get().getWindowManager ()->isGuiMode () && (mFirstPersonView && !mVanity.enabled && !mPreviewMode)); diff --git a/apps/openmw/mwrender/renderconst.hpp b/apps/openmw/mwrender/renderconst.hpp index e6ecb5150..75e243ec7 100644 --- a/apps/openmw/mwrender/renderconst.hpp +++ b/apps/openmw/mwrender/renderconst.hpp @@ -56,9 +56,9 @@ enum VisibilityFlags RV_PlayerPreview = 512, - RV_Map = RV_Terrain + RV_Statics + RV_StaticsSmall + RV_Misc + RV_Water + RV_Debug = 1024, - /// \todo markers (normally hidden) + RV_Map = RV_Terrain + RV_Statics + RV_StaticsSmall + RV_Misc + RV_Water }; } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 98fc4175e..fe74fe545 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -378,9 +378,9 @@ void RenderingManager::update (float duration) } void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){ - if(store->cell->data.flags & store->cell->HasWater - || ((!(store->cell->data.flags & ESM::Cell::Interior)) - && !MWBase::Environment::get().getWorld()->getStore().lands.search(store->cell->data.gridX,store->cell->data.gridY) )) // always use water, if the cell does not have land. + if(store->cell->mData.mFlags & store->cell->HasWater + || ((!(store->cell->mData.mFlags & ESM::Cell::Interior)) + && !MWBase::Environment::get().getWorld()->getStore().lands.search(store->cell->mData.mX,store->cell->mData.mY) )) // always use water, if the cell does not have land. { if(mWater == 0) mWater = new MWRender::Water(mRendering.getCamera(), this, store->cell); @@ -471,9 +471,9 @@ bool RenderingManager::toggleRenderMode(int mode) void RenderingManager::configureFog(MWWorld::Ptr::CellStore &mCell) { Ogre::ColourValue color; - color.setAsABGR (mCell.cell->ambi.fog); + color.setAsABGR (mCell.cell->mAmbi.mFog); - configureFog(mCell.cell->ambi.fogDensity, color); + configureFog(mCell.cell->mAmbi.mFogDensity, color); if (mWater) mWater->setViewportBackground (Ogre::ColourValue(0.8f, 0.9f, 1.0f)); @@ -523,7 +523,7 @@ void RenderingManager::setAmbientMode() void RenderingManager::configureAmbient(MWWorld::Ptr::CellStore &mCell) { - mAmbientColor.setAsABGR (mCell.cell->ambi.ambient); + mAmbientColor.setAsABGR (mCell.cell->mAmbi.mAmbient); setAmbientMode(); // Create a "sun" that shines light downwards. It doesn't look @@ -533,7 +533,7 @@ void RenderingManager::configureAmbient(MWWorld::Ptr::CellStore &mCell) mSun = mRendering.getScene()->createLight(); } Ogre::ColourValue colour; - colour.setAsABGR (mCell.cell->ambi.sunlight); + colour.setAsABGR (mCell.cell->mAmbi.mSunlight); mSun->setDiffuseColour (colour); mSun->setType(Ogre::Light::LT_DIRECTIONAL); mSun->setDirection(0,-1,0); @@ -617,7 +617,7 @@ void RenderingManager::setGlare(bool glare) void RenderingManager::requestMap(MWWorld::Ptr::CellStore* cell) { - if (!(cell->cell->data.flags & ESM::Cell::Interior)) + if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) mLocalMap->requestMap(cell); else mLocalMap->requestMap(cell, mObjects.getDimensions(cell)); diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index 691e7c4af..114a9bc37 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -99,9 +99,10 @@ namespace MWRender if (land == NULL) // no land data means we're not going to create any terrain. return; - if (!land->dataLoaded) + int dataRequired = ESM::Land::DATA_VHGT | ESM::Land::DATA_VCLR; + if (!land->isDataLoaded(dataRequired)) { - land->loadData(); + land->loadData(dataRequired); } //split the cell terrain into four segments @@ -134,7 +135,7 @@ namespace MWRender const size_t xOffset = x * (mLandSize-1); memcpy(&terrainData.inputFloat[terrainCopyY*mLandSize], - &land->landData->heights[yOffset + xOffset], + &land->mLandData->mHeights[yOffset + xOffset], mLandSize*sizeof(float)); } @@ -159,7 +160,7 @@ namespace MWRender terrain->setRenderQueueGroup(RQG_Main); // disable or enable global colour map (depends on available vertex colours) - if ( land->landData->usingColours ) + if ( land->mLandData->mUsingColours ) { TexturePtr vertex = getVertexColours(land, cellX, cellY, @@ -254,7 +255,7 @@ namespace MWRender } else { - texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1)->texture; + texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1)->mTexture; //TODO this is needed due to MWs messed up texture handling texture = texture.substr(0, texture.rfind(".")) + ".dds"; } @@ -413,13 +414,13 @@ namespace MWRender ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); if ( land != NULL ) { - if (!land->dataLoaded) + if (!land->isDataLoaded(ESM::Land::DATA_VTEX)) { - land->loadData(); + land->loadData(ESM::Land::DATA_VTEX); } - return land->landData - ->textures[y * ESM::Land::LAND_TEXTURE_SIZE + x]; + return land->mLandData + ->mTextures[y * ESM::Land::LAND_TEXTURE_SIZE + x]; } else { @@ -463,7 +464,7 @@ namespace MWRender if ( land != NULL ) { - const char* const colours = land->landData->colours; + const char* const colours = land->mLandData->mColours; for ( int y = 0; y < size; y++ ) { for ( int x = 0; x < size; x++ ) diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 7100540fc..e8f099640 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -38,7 +38,7 @@ Water::Water (Ogre::Camera *camera, RenderingManager* rend, const ESM::Cell* cel mMaterial = MaterialManager::getSingleton().getByName("Water"); - mTop = cell->water; + mTop = cell->mWater; mIsUnderwater = false; @@ -55,9 +55,9 @@ Water::Water (Ogre::Camera *camera, RenderingManager* rend, const ESM::Cell* cel mReflectionCamera = mSceneManager->createCamera("ReflectionCamera"); - if(!(cell->data.flags & cell->Interior)) + if(!(cell->mData.mFlags & cell->Interior)) { - mWaterNode->setPosition(getSceneNodeCoordinates(cell->data.gridX, cell->data.gridY)); + mWaterNode->setPosition(getSceneNodeCoordinates(cell->mData.mX, cell->mData.mY)); } mWaterNode->attachObject(mWater); @@ -156,12 +156,12 @@ Water::~Water() void Water::changeCell(const ESM::Cell* cell) { - mTop = cell->water; + mTop = cell->mWater; setHeight(mTop); - if(!(cell->data.flags & cell->Interior)) - mWaterNode->setPosition(getSceneNodeCoordinates(cell->data.gridX, cell->data.gridY)); + if(!(cell->mData.mFlags & cell->Interior)) + mWaterNode->setPosition(getSceneNodeCoordinates(cell->mData.mX, cell->mData.mY)); } void Water::setHeight(const float height) diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index c1d09fac4..57dd7962b 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -45,7 +45,7 @@ namespace MWScript if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (cell)) { - MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY, + MWBase::Environment::get().getWorld()->indexToPosition (exterior->mData.mX, exterior->mData.mY, pos.pos[0], pos.pos[1], true); MWBase::Environment::get().getWorld()->changeToExteriorCell (pos); } @@ -87,7 +87,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { bool interior = - MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->data.flags & + MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mData.mFlags & ESM::Cell::Interior; runtime.push (interior ? 1 : 0); @@ -105,14 +105,14 @@ namespace MWScript const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell; - std::string current = cell->name; + std::string current = cell->mName; - if (!(cell->data.flags & ESM::Cell::Interior) && current.empty()) + if (!(cell->mData.mFlags & ESM::Cell::Interior) && current.empty()) { const ESM::Region *region = - MWBase::Environment::get().getWorld()->getStore().regions.find (cell->region); + MWBase::Environment::get().getWorld()->getStore().regions.find (cell->mRegion); - current = region->name; + current = region->mName; } bool match = current.length()>=name.length() && @@ -143,7 +143,7 @@ namespace MWScript MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); - if (!(cell->cell->data.flags & ESM::Cell::Interior)) + if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) throw std::runtime_error("Can't set water level in exterior cell"); cell->mWaterLevel = level; @@ -161,7 +161,7 @@ namespace MWScript MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); - if (!(cell->cell->data.flags & ESM::Cell::Interior)) + if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) throw std::runtime_error("Can't set water level in exterior cell"); cell->mWaterLevel +=level; diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index b916ba72c..5e9746b2f 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -78,7 +78,7 @@ namespace MWScript Interpreter::Type_Integer sum = 0; for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) - if (toLower(iter->getCellRef().refID) == toLower(item)) + if (toLower(iter->getCellRef().mRefID) == toLower(item)) sum += iter->getRefData().getCount(); runtime.push (sum); @@ -108,7 +108,7 @@ namespace MWScript for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end() && count; ++iter) { - if (toLower(iter->getCellRef().refID) == toLower(item)) + if (toLower(iter->getCellRef().mRefID) == toLower(item)) { if (iter->getRefData().getCount()<=count) { diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 1c74a713f..584a29926 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -205,6 +205,6 @@ op 0x200019e: PlaceAtMe Explicit op 0x200019f: GetPcSleep op 0x20001a0: ShowMap op 0x20001a1: FillMap -op 0x20001a2: PlayBink +op 0x20001a2: WakeUpPc opcodes 0x20001a3-0x3ffffff unused diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index 6407bf0cb..37cf34127 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -21,7 +21,7 @@ namespace MWScript for (ESMS::RecListT::MapType::const_iterator iter (store.startScripts.list.begin()); iter != store.startScripts.list.end(); ++iter) - addScript (iter->second.script); + addScript (iter->second.mScript); } void GlobalScripts::addScript (const std::string& name) diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index a93de0ede..66bb4e043 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -112,10 +112,10 @@ namespace MWScript const ESMS::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; for (ESMS::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) { - std::string name = it->second->name; + std::string name = it->second->mName; boost::algorithm::to_lower(name); if (name.find(cell) != std::string::npos) - MWBase::Environment::get().getWindowManager()->addVisitedLocation (it->second->name, it->first.first, it->first.second); + MWBase::Environment::get().getWindowManager()->addVisitedLocation (it->second->mName, it->first.first, it->first.second); } } }; @@ -129,7 +129,7 @@ namespace MWScript const ESMS::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; for (ESMS::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) { - std::string name = it->second->name; + std::string name = it->second->mName; if (name != "") MWBase::Environment::get().getWindowManager()->addVisitedLocation (name, it->first.first, it->first.second); } diff --git a/apps/openmw/mwscript/locals.hpp b/apps/openmw/mwscript/locals.hpp index e5500158f..ec02e2f12 100644 --- a/apps/openmw/mwscript/locals.hpp +++ b/apps/openmw/mwscript/locals.hpp @@ -17,11 +17,11 @@ namespace MWScript void configure (const ESM::Script& script) { mShorts.clear(); - mShorts.resize (script.data.numShorts, 0); + mShorts.resize (script.mData.mNumShorts, 0); mLongs.clear(); - mLongs.resize (script.data.numLongs, 0); + mLongs.resize (script.mData.mNumLongs, 0); mFloats.clear(); - mFloats.resize (script.data.numFloats, 0); + mFloats.resize (script.mData.mNumFloats, 0); } }; } diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 330c1c79f..885db6458 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -44,6 +44,16 @@ namespace MWScript } }; + class OpWakeUpPc : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWBase::Environment::get().getWindowManager ()->wakeUpPlayer(); + } + }; + class OpXBox : public Interpreter::Opcode0 { public: @@ -274,7 +284,9 @@ namespace MWScript const int opcodeDontSaveObject = 0x2000153; const int opcodeToggleVanityMode = 0x2000174; const int opcodeGetPcSleep = 0x200019f; - const int opcodePlayBink = 0x20001a2; + const int opcodeWakeUpPc = 0x20001a2; + + const int opcodePlayBink = 0x20001a3; void registerExtensions (Compiler::Extensions& extensions) { @@ -300,6 +312,8 @@ namespace MWScript extensions.registerInstruction ("togglevanitymode", "", opcodeToggleVanityMode); extensions.registerInstruction ("tvm", "", opcodeToggleVanityMode); extensions.registerFunction ("getpcsleep", 'l', "", opcodeGetPcSleep); + extensions.registerInstruction ("wakeuppc", "", opcodeWakeUpPc); + extensions.registerInstruction ("playbink", "S", opcodePlayBink); } @@ -322,6 +336,8 @@ namespace MWScript interpreter.installSegment5 (opcodeDontSaveObject, new OpDontSaveObject); interpreter.installSegment5 (opcodeToggleVanityMode, new OpToggleVanityMode); interpreter.installSegment5 (opcodeGetPcSleep, new OpGetPcSleep); + interpreter.installSegment5 (opcodeWakeUpPc, new OpWakeUpPc); + interpreter.installSegment5 (opcodePlayBink, new OpPlayBink); } } diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 0b33d43fa..883d3dfd3 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -38,7 +38,7 @@ namespace MWScript try { - std::istringstream input (script->scriptText); + std::istringstream input (script->mScriptText); Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions()); @@ -62,7 +62,7 @@ namespace MWScript { std::cerr << "compiling failed: " << name << std::endl - << script->scriptText + << script->mScriptText << std::endl << std::endl; } @@ -180,19 +180,19 @@ namespace MWScript case 's': offset = 0; - size = script->data.numShorts; + size = script->mData.mNumShorts; break; case 'l': - offset = script->data.numShorts; - size = script->data.numLongs; + offset = script->mData.mNumShorts; + size = script->mData.mNumLongs; break; case 'f': - offset = script->data.numShorts+script->data.numLongs; - size = script->data.numFloats; + offset = script->mData.mNumShorts+script->mData.mNumLongs; + size = script->mData.mNumFloats; default: @@ -200,7 +200,7 @@ namespace MWScript } for (int i=0; ivarNames.at (i+offset)==variable) + if (script->mVarNames.at (i+offset)==variable) return i; throw std::runtime_error ("unable to access local variable " + variable + " of " + scriptId); diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index f49d684a5..66a5acae0 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -316,7 +316,7 @@ namespace MWScript assert (ref); const ESM::Class& class_ = - *MWBase::Environment::get().getWorld()->getStore().classes.find (ref->base->cls); + *MWBase::Environment::get().getWorld()->getStore().classes.find (ref->base->mClass); float level = 0; float progress = std::modf (stats.getSkill (mIndex).getBase(), &level); diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 706d8d720..6e70f588e 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -49,7 +49,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - runtime.push(ptr.getCellRef().scale); + runtime.push(ptr.getCellRef().mScale); } }; @@ -131,15 +131,15 @@ namespace MWScript if (axis=="x") { - runtime.push(Ogre::Radian(ptr.getCellRef().pos.rot[0]).valueDegrees()); + runtime.push(Ogre::Radian(ptr.getCellRef().mPos.rot[0]).valueDegrees()); } else if (axis=="y") { - runtime.push(Ogre::Radian(ptr.getCellRef().pos.rot[1]).valueDegrees()); + runtime.push(Ogre::Radian(ptr.getCellRef().mPos.rot[1]).valueDegrees()); } else if (axis=="z") { - runtime.push(Ogre::Radian(ptr.getCellRef().pos.rot[2]).valueDegrees()); + runtime.push(Ogre::Radian(ptr.getCellRef().mPos.rot[2]).valueDegrees()); } else throw std::runtime_error ("invalid ration axis: " + axis); @@ -224,15 +224,15 @@ namespace MWScript if(axis == "x") { - runtime.push(ptr.getCellRef().pos.pos[0]); + runtime.push(ptr.getCellRef().mPos.pos[0]); } else if(axis == "y") { - runtime.push(ptr.getCellRef().pos.pos[1]); + runtime.push(ptr.getCellRef().mPos.pos[1]); } else if(axis == "z") { - runtime.push(ptr.getCellRef().pos.pos[2]); + runtime.push(ptr.getCellRef().mPos.pos[2]); } else throw std::runtime_error ("invalid axis: " + axis); @@ -372,7 +372,7 @@ namespace MWScript pos.rot[0] = pos.rot[1] = 0; pos.rot[2] = zRot; MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(),itemID); - ref.getPtr().getCellRef().pos = pos; + ref.getPtr().getCellRef().mPos = pos; MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(),*store,pos); } else @@ -413,7 +413,7 @@ namespace MWScript pos.rot[0] = pos.rot[1] = 0; pos.rot[2] = zRot; MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(),itemID); - ref.getPtr().getCellRef().pos = pos; + ref.getPtr().getCellRef().mPos = pos; MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(),*store,pos); } else @@ -458,7 +458,7 @@ namespace MWScript MWWorld::CellStore* store = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(),itemID); - ref.getPtr().getCellRef().pos = ipos; + ref.getPtr().getCellRef().mPos = ipos; ref.getPtr().getRefData().setCount(count); MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(),*store,ipos); } @@ -501,7 +501,7 @@ namespace MWScript MWWorld::CellStore* store = me.getCell(); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(),itemID); - ref.getPtr().getCellRef().pos = ipos; + ref.getPtr().getCellRef().mPos = ipos; ref.getPtr().getRefData().setCount(count); MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(),*store,ipos); diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 4b10624a5..5d5ef3d1d 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -120,22 +120,22 @@ namespace MWSound if(snd == NULL) throw std::runtime_error(std::string("Failed to lookup sound ")+soundId); - volume *= pow(10.0, (snd->data.volume/255.0*3348.0 - 3348.0) / 2000.0); + volume *= pow(10.0, (snd->mData.mVolume/255.0*3348.0 - 3348.0) / 2000.0); - if(snd->data.minRange == 0 && snd->data.maxRange == 0) + if(snd->mData.mMinRange == 0 && snd->mData.mMaxRange == 0) { min = 100.0f; max = 2000.0f; } else { - min = snd->data.minRange * 20.0f; - max = snd->data.maxRange * 50.0f; + min = snd->mData.mMinRange * 20.0f; + max = snd->mData.mMaxRange * 50.0f; min = std::max(min, 1.0f); max = std::max(min, max); } - return "Sound/"+snd->sound; + return "Sound/"+snd->mSound; } @@ -296,7 +296,7 @@ namespace MWSound } catch(std::exception &e) { - std::cout <<"Sound Error: "<second.first == ptr) - snditer->first->setPosition(objpos); - snditer++; - } - } void SoundManager::updateRegionSound(float duration) { @@ -426,13 +414,13 @@ namespace MWSound //If the region has changed timePassed += duration; - if((current->cell->data.flags & current->cell->Interior) || timePassed < 10) + if((current->cell->mData.mFlags & current->cell->Interior) || timePassed < 10) return; timePassed = 0; - if(regionName != current->cell->region) + if(regionName != current->cell->mRegion) { - regionName = current->cell->region; + regionName = current->cell->mRegion; total = 0; } @@ -443,10 +431,10 @@ namespace MWSound std::vector::const_iterator soundIter; if(total == 0) { - soundIter = regn->soundList.begin(); - while(soundIter != regn->soundList.end()) + soundIter = regn->mSoundList.begin(); + while(soundIter != regn->mSoundList.end()) { - total += (int)soundIter->chance; + total += (int)soundIter->mChance; soundIter++; } if(total == 0) @@ -456,11 +444,11 @@ namespace MWSound int r = (int)(rand()/((double)RAND_MAX+1) * total); int pos = 0; - soundIter = regn->soundList.begin(); - while(soundIter != regn->soundList.end()) + soundIter = regn->mSoundList.begin(); + while(soundIter != regn->mSoundList.end()) { - const std::string go = soundIter->sound.toString(); - int chance = (int) soundIter->chance; + const std::string go = soundIter->mSound.toString(); + int chance = (int) soundIter->mChance; //std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; soundIter++; if(r - pos < chance) @@ -492,13 +480,13 @@ namespace MWSound const ESM::Cell *cell = player.getCell()->cell; Environment env = Env_Normal; - if((cell->data.flags&cell->HasWater) && mListenerPos.z < cell->water) + if((cell->mData.mFlags&cell->HasWater) && mListenerPos.z < cell->mWater) env = Env_Underwater; mOutput->updateListener( mListenerPos, mListenerDir, - Ogre::Vector3::UNIT_Z, + mListenerUp, env ); @@ -558,10 +546,11 @@ namespace MWSound } } - void SoundManager::setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir) + void SoundManager::setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up) { mListenerPos = pos; mListenerDir = dir; + mListenerUp = up; } // Default readAll implementation, for decoders that can't do anything diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index 956ad5712..f91e291ef 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -52,6 +52,7 @@ namespace MWSound Ogre::Vector3 mListenerPos; Ogre::Vector3 mListenerDir; + Ogre::Vector3 mListenerUp; std::string lookup(const std::string &soundId, float &volume, float &min, float &max); @@ -126,12 +127,9 @@ namespace MWSound virtual bool getSoundPlaying(MWWorld::Ptr reference, const std::string& soundId) const; ///< Is the given sound currently playing on the given object? - virtual void updateObject(MWWorld::Ptr reference); - ///< Update the position of all sounds connected to the given object. - virtual void update(float duration); - virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir); + virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up); }; } diff --git a/apps/openmw/mwworld/actionread.cpp b/apps/openmw/mwworld/actionread.cpp index fe5e2d58f..4ac613df7 100644 --- a/apps/openmw/mwworld/actionread.cpp +++ b/apps/openmw/mwworld/actionread.cpp @@ -24,7 +24,7 @@ namespace MWWorld { LiveCellRef *ref = getTarget().get(); - if (ref->base->data.isScroll) + if (ref->base->mData.mIsScroll) { MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Scroll); MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(getTarget()); @@ -35,22 +35,21 @@ namespace MWWorld MWBase::Environment::get().getWindowManager()->getBookWindow()->open(getTarget()); } - /* + MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer(); + MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player); + // Skill gain from books - if (ref->base->data.skillID >= 0 && ref->base->data.skillID < ESM::Skill::Length) + if (ref->base->mData.mSkillID >= 0 && ref->base->mData.mSkillID < ESM::Skill::Length + && !npcStats.hasBeenUsed (ref->base->mId)) { - MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer(); - MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player); MWWorld::LiveCellRef *playerRef = player.get(); const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - playerRef->base->cls); + playerRef->base->mClass); - npcStats.increaseSkill (ref->base->data.skillID, *class_, true); + npcStats.increaseSkill (ref->base->mData.mSkillID, *class_, true); - /// \todo Remove skill from the book. Right now you can read as many times as you want - /// and the skill will still increase. + npcStats.flagAsUsed (ref->base->mId); } - */ } } diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index 822aa78d6..e5a38d4be 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -10,13 +10,13 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell) { - if (cell->data.flags & ESM::Cell::Interior) + if (cell->mData.mFlags & ESM::Cell::Interior) { - std::map::iterator result = mInteriors.find (cell->name); + std::map::iterator result = mInteriors.find (cell->mName); if (result==mInteriors.end()) { - result = mInteriors.insert (std::make_pair (cell->name, Ptr::CellStore (cell))).first; + result = mInteriors.insert (std::make_pair (cell->mName, Ptr::CellStore (cell))).first; } return &result->second; @@ -24,12 +24,12 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell) else { std::map, Ptr::CellStore>::iterator result = - mExteriors.find (std::make_pair (cell->data.gridX, cell->data.gridY)); + mExteriors.find (std::make_pair (cell->mData.mX, cell->mData.mY)); if (result==mExteriors.end()) { result = mExteriors.insert (std::make_pair ( - std::make_pair (cell->data.gridX, cell->data.gridY), Ptr::CellStore (cell))).first; + std::make_pair (cell->mData.mX, cell->mData.mY), Ptr::CellStore (cell))).first; } @@ -46,7 +46,7 @@ void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) Ptr container (&*iter, &cellStore); Class::get (container).getContainerStore (container).fill ( - iter->base->inventory, mStore); + iter->base->mInventory, mStore); } for (CellRefList::List::iterator iter ( @@ -56,7 +56,7 @@ void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) Ptr container (&*iter, &cellStore); Class::get (container).getContainerStore (container).fill ( - iter->base->inventory, mStore); + iter->base->mInventory, mStore); } for (CellRefList::List::iterator iter ( @@ -66,7 +66,7 @@ void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) Ptr container (&*iter, &cellStore); Class::get (container).getContainerStore (container).fill ( - iter->base->inventory, mStore); + iter->base->mInventory, mStore); } } @@ -105,11 +105,11 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y) // Cell isn't predefined. Make one on the fly. ESM::Cell record; - record.data.flags = 0; - record.data.gridX = x; - record.data.gridY = y; - record.water = 0; - record.mapColor = 0; + record.mData.mFlags = 0; + record.mData.mX = x; + record.mData.mY = y; + record.mWater = 0; + record.mMapColor = 0; cell = MWBase::Environment::get().getWorld()->createRecord (record); } diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index eceb5ddc1..fcdec1e7f 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -13,7 +13,7 @@ namespace MWWorld { CellStore::CellStore (const ESM::Cell *cell_) : cell (cell_), mState (State_Unloaded) { - mWaterLevel = cell->water; + mWaterLevel = cell->mWater; } void CellStore::load (const ESMS::ESMStore &store, ESM::ESMReader &esm) @@ -45,7 +45,7 @@ namespace MWWorld { assert (cell); - if (cell->context.filename.empty()) + if (cell->mContext.filename.empty()) return; // this is a dynamically generated cell -> skipping. // Reopen the ESM reader and seek to the right position. @@ -58,7 +58,7 @@ namespace MWWorld { std::string lowerCase; - std::transform (ref.refID.begin(), ref.refID.end(), std::back_inserter (lowerCase), + std::transform (ref.mRefID.begin(), ref.mRefID.end(), std::back_inserter (lowerCase), (int(*)(int)) std::tolower); mIds.push_back (lowerCase); @@ -71,7 +71,7 @@ namespace MWWorld { assert (cell); - if (cell->context.filename.empty()) + if (cell->mContext.filename.empty()) return; // this is a dynamically generated cell -> skipping. // Reopen the ESM reader and seek to the right position. @@ -84,12 +84,12 @@ namespace MWWorld { std::string lowerCase; - std::transform (ref.refID.begin(), ref.refID.end(), std::back_inserter (lowerCase), + std::transform (ref.mRefID.begin(), ref.mRefID.end(), std::back_inserter (lowerCase), (int(*)(int)) std::tolower); - int rec = store.find(ref.refID); + int rec = store.find(ref.mRefID); - ref.refID = lowerCase; + ref.mRefID = lowerCase; /* We can optimize this further by storing the pointer to the record itself in store.all, so that we don't need to look it @@ -119,9 +119,9 @@ namespace MWWorld case ESM::REC_STAT: statics.find(ref, store.statics); break; case ESM::REC_WEAP: weapons.find(ref, store.weapons); break; - case 0: std::cout << "Cell reference " + ref.refID + " not found!\n"; break; + case 0: std::cout << "Cell reference " + ref.mRefID + " not found!\n"; break; default: - std::cout << "WARNING: Ignoring reference '" << ref.refID << "' of unhandled type\n"; + std::cout << "WARNING: Ignoring reference '" << ref.mRefID << "' of unhandled type\n"; } } } diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index 3ec4a2e78..32ab6e07b 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -58,9 +58,9 @@ namespace MWWorld template void find(ESM::CellRef &ref, const Y& recList) { - const X* obj = recList.find(ref.refID); + const X* obj = recList.find(ref.mRefID); if(obj == NULL) - throw std::runtime_error("Error resolving cell reference " + ref.refID); + throw std::runtime_error("Error resolving cell reference " + ref.mRefID); list.push_back(LiveRef(ref, obj)); } @@ -69,7 +69,7 @@ namespace MWWorld { for (typename std::list::iterator iter (list.begin()); iter!=list.end(); ++iter) { - if (iter->mData.getCount() > 0 && iter->ref.refID == name) + if (iter->mData.getCount() > 0 && iter->ref.mRefID == name) return &*iter; } @@ -156,9 +156,9 @@ namespace MWWorld } bool operator==(const CellStore &cell) { - return this->cell->name == cell.cell->name && - this->cell->data.gridX == cell.cell->data.gridX && - this->cell->data.gridY == cell.cell->data.gridY; + return this->cell->mName == cell.cell->mName && + this->cell->mData.mX == cell.cell->mData.mX && + this->cell->mData.mY == cell.cell->mData.mY; } bool operator!=(const CellStore &cell) { diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index ed7336e97..3bc06b581 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -29,7 +29,7 @@ namespace ++iter) { if (iter->mData.getCount()>0) - sum += iter->mData.getCount()*iter->base->data.weight; + sum += iter->mData.getCount()*iter->base->mData.mWeight; } return sum; @@ -59,12 +59,12 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end() bool MWWorld::ContainerStore::stacks(const Ptr& ptr1, const Ptr& ptr2) { /// \todo add current weapon/armor health, remaining lockpick/repair uses, current enchantment charge here as soon as they are implemented - if ( ptr1.mCellRef->refID == ptr2.mCellRef->refID + if ( ptr1.mCellRef->mRefID == ptr2.mCellRef->mRefID && MWWorld::Class::get(ptr1).getScript(ptr1) == "" // item with a script never stacks && MWWorld::Class::get(ptr1).getEnchantment(ptr1) == "" // item with enchantment never stacks (we could revisit this later, but for now it makes selecting items in the spell window much easier) - && ptr1.mCellRef->owner == ptr2.mCellRef->owner - && ptr1.mCellRef->soul == ptr2.mCellRef->soul - && ptr1.mCellRef->charge == ptr2.mCellRef->charge) + && ptr1.mCellRef->mOwner == ptr2.mCellRef->mOwner + && ptr1.mCellRef->mSoul == ptr2.mCellRef->mSoul + && ptr1.mCellRef->mCharge == ptr2.mCellRef->mCharge) return true; return false; @@ -81,19 +81,19 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr) MWWorld::LiveCellRef *gold = ptr.get(); - if (compare_string_ci(gold->ref.refID, "gold_001") - || compare_string_ci(gold->ref.refID, "gold_005") - || compare_string_ci(gold->ref.refID, "gold_010") - || compare_string_ci(gold->ref.refID, "gold_025") - || compare_string_ci(gold->ref.refID, "gold_100")) + if (compare_string_ci(gold->ref.mRefID, "gold_001") + || compare_string_ci(gold->ref.mRefID, "gold_005") + || compare_string_ci(gold->ref.mRefID, "gold_010") + || compare_string_ci(gold->ref.mRefID, "gold_025") + || compare_string_ci(gold->ref.mRefID, "gold_100")) { MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001"); - int count = (ptr.getRefData().getCount() == 1) ? gold->base->data.value : ptr.getRefData().getCount(); + int count = (ptr.getRefData().getCount() == 1) ? gold->base->mData.mValue : ptr.getRefData().getCount(); ref.getPtr().getRefData().setCount(count); for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter) { - if (compare_string_ci((*iter).get()->ref.refID, "gold_001")) + if (compare_string_ci((*iter).get()->ref.mRefID, "gold_001")) { (*iter).getRefData().setCount( (*iter).getRefData().getCount() + count); flagAsModified(); @@ -117,7 +117,6 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr) return iter; } } - // if we got here, this means no stacking return addImpl(ptr); } @@ -148,10 +147,10 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImpl (const Ptr& ptr void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const ESMS::ESMStore& store) { - for (std::vector::const_iterator iter (items.list.begin()); iter!=items.list.end(); + for (std::vector::const_iterator iter (items.mList.begin()); iter!=items.mList.end(); ++iter) { - ManualRef ref (store, iter->item.toString()); + ManualRef ref (store, iter->mItem.toString()); if (ref.getPtr().getTypeName()==typeid (ESM::ItemLevList).name()) { @@ -159,7 +158,7 @@ void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const ESMS: continue; } - ref.getPtr().getRefData().setCount (std::abs(iter->count)); /// \todo implement item restocking (indicated by negative count) + ref.getPtr().getRefData().setCount (std::abs(iter->mCount)); /// \todo implement item restocking (indicated by negative count) add (ref.getPtr()); } diff --git a/apps/openmw/mwworld/globals.cpp b/apps/openmw/mwworld/globals.cpp index b20a678bc..1430219d9 100644 --- a/apps/openmw/mwworld/globals.cpp +++ b/apps/openmw/mwworld/globals.cpp @@ -35,27 +35,27 @@ namespace MWWorld char type = ' '; Data value; - switch (iter->second.type) + switch (iter->second.mType) { case ESM::VT_Short: type = 's'; value.mShort = *reinterpret_cast ( - &iter->second.value); + &iter->second.mValue); break; case ESM::VT_Int: type = 'l'; value.mLong = *reinterpret_cast ( - &iter->second.value); + &iter->second.mValue); break; case ESM::VT_Float: type = 'f'; value.mFloat = *reinterpret_cast ( - &iter->second.value); + &iter->second.mValue); break; default: diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 9e4381f07..179a484e9 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -233,8 +233,8 @@ const MWMechanics::MagicEffects& MWWorld::InventoryStore::getMagicEffects() const ESM::Enchantment& enchantment = *MWBase::Environment::get().getWorld()->getStore().enchants.find (enchantmentId); - if (enchantment.data.type==ESM::Enchantment::ConstantEffect) - mMagicEffects.add (enchantment.effects); + if (enchantment.mData.mType==ESM::Enchantment::ConstantEffect) + mMagicEffects.add (enchantment.mEffects); } } diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index d15f00c92..d0d698feb 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -15,9 +15,9 @@ namespace cellRefList.list.begin()); iter!=cellRefList.list.end(); ++iter) { - if (!iter->base->script.empty() && iter->mData.getCount()) + if (!iter->base->mScript.empty() && iter->mData.getCount()) { - localScripts.add (iter->base->script, MWWorld::Ptr (&*iter, cell)); + localScripts.add (iter->base->mScript, MWWorld::Ptr (&*iter, cell)); } } } diff --git a/apps/openmw/mwworld/manualref.hpp b/apps/openmw/mwworld/manualref.hpp index 6044ac8d5..6570761ab 100644 --- a/apps/openmw/mwworld/manualref.hpp +++ b/apps/openmw/mwworld/manualref.hpp @@ -82,16 +82,16 @@ namespace MWWorld // initialise ESM::CellRef& cellRef = mPtr.getCellRef(); - cellRef.refID = name; - cellRef.refnum = -1; - cellRef.scale = 1; - cellRef.factIndex = 0; - cellRef.charge = 0; - cellRef.intv = 0; - cellRef.nam9 = 0; - cellRef.teleport = false; - cellRef.lockLevel = 0; - cellRef.unam = 0; + cellRef.mRefID = name; + cellRef.mRefnum = -1; + cellRef.mScale = 1; + cellRef.mFactIndex = 0; + cellRef.mCharge = 0; + cellRef.mIntv = 0; + cellRef.mNam9 = 0; + cellRef.mTeleport = false; + cellRef.mLockLevel = 0; + cellRef.mUnam = 0; } const Ptr& getPtr() const diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 8de415980..8fa1976ac 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -399,7 +399,7 @@ namespace MWWorld return false; } btVector3 btMin, btMax; - float scale = ptr.getCellRef().scale; + float scale = ptr.getCellRef().mScale; mEngine->getObjectAABB(model, scale, btMin, btMax); min.x = btMin.x(); diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 0f05ae24d..e1eb02c32 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -18,16 +18,16 @@ namespace MWWorld mAutoMove (false), mForwardBackward (0) { mPlayer.base = player; - mPlayer.ref.refID = "player"; - mName = player->name; - mMale = !(player->flags & ESM::NPC::Female); - mRace = player->race; + mPlayer.ref.mRefID = "player"; + mName = player->mName; + mMale = !(player->mFlags & ESM::NPC::Female); + mRace = player->mRace; float* playerPos = mPlayer.mData.getPosition().pos; playerPos[0] = playerPos[1] = playerPos[2] = 0; /// \todo Do not make a copy of classes defined in esm/p records. - mClass = new ESM::Class (*world.getStore().classes.find (player->cls)); + mClass = new ESM::Class (*world.getStore().classes.find (player->mClass)); } Player::~Player() diff --git a/apps/openmw/mwworld/refdata.cpp b/apps/openmw/mwworld/refdata.cpp index 41794c2ad..5630bfd5c 100644 --- a/apps/openmw/mwworld/refdata.cpp +++ b/apps/openmw/mwworld/refdata.cpp @@ -29,7 +29,7 @@ namespace MWWorld } RefData::RefData (const ESM::CellRef& cellRef) - : mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mPosition (cellRef.pos), + : mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mPosition (cellRef.mPos), mCustomData (0) {} diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 8a4a09358..f16077202 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -88,11 +88,11 @@ namespace MWWorld mPhysics->removeObject (node->getName()); } - if (!((*iter)->cell->data.flags & ESM::Cell::Interior)) + if (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)) { - ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search((*iter)->cell->data.gridX,(*iter)->cell->data.gridY); + ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search((*iter)->cell->mData.mX,(*iter)->cell->mData.mY); if (land) - mPhysics->removeHeightField( (*iter)->cell->data.gridX, (*iter)->cell->data.gridY ); + mPhysics->removeHeightField( (*iter)->cell->mData.mX, (*iter)->cell->mData.mY ); } } @@ -126,12 +126,12 @@ namespace MWWorld float verts = ESM::Land::LAND_SIZE; float worldsize = ESM::Land::REAL_SIZE; - if (!(cell->cell->data.flags & ESM::Cell::Interior)) + if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) { - ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cell->cell->data.gridX,cell->cell->data.gridY); + ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cell->cell->mData.mX,cell->cell->mData.mY); if (land) - mPhysics->addHeightField (land->landData->heights, - cell->cell->data.gridX, cell->cell->data.gridY, + mPhysics->addHeightField (land->mLandData->mHeights, + cell->cell->mData.mX, cell->cell->mData.mY, 0, ( worldsize/(verts-1) ), verts); } @@ -149,8 +149,8 @@ namespace MWWorld const ESM::Position& pos, bool adjustPlayerPos) { - bool hasWater = cell->cell->data.flags & cell->cell->HasWater; - mPhysics->setCurrentWater(hasWater, cell->cell->water); + bool hasWater = cell->cell->mData.mFlags & cell->cell->HasWater; + mPhysics->setCurrentWater(hasWater, cell->cell->mWater); MWBase::World *world = MWBase::Environment::get().getWorld(); world->getPlayer().setCell(cell); @@ -188,10 +188,10 @@ namespace MWWorld int numUnload = 0; while (active!=mActiveCells.end()) { - if (!((*active)->cell->data.flags & ESM::Cell::Interior)) + if (!((*active)->cell->mData.mFlags & ESM::Cell::Interior)) { - if (std::abs (X-(*active)->cell->data.gridX)<=1 && - std::abs (Y-(*active)->cell->data.gridY)<=1) + if (std::abs (X-(*active)->cell->mData.mX)<=1 && + std::abs (Y-(*active)->cell->mData.mY)<=1) { // keep cells within the new 3x3 grid ++active; @@ -206,10 +206,10 @@ namespace MWWorld active = mActiveCells.begin(); while (active!=mActiveCells.end()) { - if (!((*active)->cell->data.flags & ESM::Cell::Interior)) + if (!((*active)->cell->mData.mFlags & ESM::Cell::Interior)) { - if (std::abs (X-(*active)->cell->data.gridX)<=1 && - std::abs (Y-(*active)->cell->data.gridY)<=1) + if (std::abs (X-(*active)->cell->mData.mX)<=1 && + std::abs (Y-(*active)->cell->mData.mY)<=1) { // keep cells within the new 3x3 grid ++active; @@ -231,10 +231,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert (!((*iter)->cell->data.flags & ESM::Cell::Interior)); + assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)); - if (x==(*iter)->cell->data.gridX && - y==(*iter)->cell->data.gridY) + if (x==(*iter)->cell->mData.mX && + y==(*iter)->cell->mData.mY) break; ++iter; @@ -253,10 +253,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert (!((*iter)->cell->data.flags & ESM::Cell::Interior)); + assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)); - if (x==(*iter)->cell->data.gridX && - y==(*iter)->cell->data.gridY) + if (x==(*iter)->cell->mData.mX && + y==(*iter)->cell->mData.mY) break; ++iter; @@ -277,10 +277,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert (!((*iter)->cell->data.flags & ESM::Cell::Interior)); + assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)); - if (X==(*iter)->cell->data.gridX && - Y==(*iter)->cell->data.gridY) + if (X==(*iter)->cell->mData.mX && + Y==(*iter)->cell->mData.mY) break; ++iter; diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 0adf87dae..391b34a84 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -41,7 +41,8 @@ const float WeatherGlobals::mThunderSoundDelay = 0.25; WeatherManager::WeatherManager(MWRender::RenderingManager* rendering) : mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0), - mRemainingTransitionTime(0), mMonth(0), mDay(0) + mRemainingTransitionTime(0), mMonth(0), mDay(0), + mTimePassed(0) { mRendering = rendering; @@ -487,13 +488,16 @@ WeatherResult WeatherManager::transition(float factor) void WeatherManager::update(float duration) { - mWeatherUpdateTime -= duration * MWBase::Environment::get().getWorld()->getTimeScaleFactor(); + float timePassed = mTimePassed; + mTimePassed = 0; + + mWeatherUpdateTime -= timePassed; bool exterior = (MWBase::Environment::get().getWorld()->isCellExterior() || MWBase::Environment::get().getWorld()->isCellQuasiExterior()); if (exterior) { - std::string regionstr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->region; + std::string regionstr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mRegion; boost::algorithm::to_lower(regionstr); if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) @@ -512,16 +516,16 @@ void WeatherManager::update(float duration) if (region != 0) { - float clear = region->data.clear/255.f; - float cloudy = region->data.cloudy/255.f; - float foggy = region->data.foggy/255.f; - float overcast = region->data.overcast/255.f; - float rain = region->data.rain/255.f; - float thunder = region->data.thunder/255.f; - float ash = region->data.ash/255.f; - float blight = region->data.blight/255.f; - //float snow = region->data.a/255.f; - //float blizzard = region->data.b/255.f; + float clear = region->mData.mClear/255.f; + float cloudy = region->mData.mCloudy/255.f; + float foggy = region->mData.mFoggy/255.f; + float overcast = region->mData.mOvercast/255.f; + float rain = region->mData.mRain/255.f; + float thunder = region->mData.mThunder/255.f; + float ash = region->mData.mAsh/255.f; + float blight = region->mData.mBlight/255.f; + //float snow = region->mData.a/255.f; + //float blizzard = region->mData.b/255.f; // re-scale to 100 percent const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight;//+snow+blizzard; @@ -558,7 +562,7 @@ void WeatherManager::update(float duration) if (mNextWeather != "") { - mRemainingTransitionTime -= duration * MWBase::Environment::get().getWorld()->getTimeScaleFactor(); + mRemainingTransitionTime -= timePassed; if (mRemainingTransitionTime < 0) { mCurrentWeather = mNextWeather; diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index 5e0388751..589dff3eb 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -231,6 +231,11 @@ namespace MWWorld void setDate(const int day, const int month); + void advanceTime(double hours) + { + mTimePassed += hours*3600; + } + unsigned int getWeatherID() const; private: @@ -261,6 +266,8 @@ namespace MWWorld float mThunderChanceNeeded; float mThunderSoundDelay; + double mTimePassed; // time passed since last update + WeatherResult transition(const float factor); WeatherResult getResult(const Ogre::String& weather); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 06b58c183..595ccd0c8 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -233,7 +233,7 @@ namespace MWWorld for (ESMS::RecListT::MapType::const_iterator iter (mStore.regions.list.begin()); iter!=mStore.regions.list.end(); ++iter) { - if (ESMS::RecListT::toLower (iter->second.name)==cellName2) + if (ESMS::RecListT::toLower (iter->second.mName)==cellName2) { if (const ESM::Cell *cell = mStore.cells.searchExtByRegion (iter->first)) return cell; @@ -366,6 +366,8 @@ namespace MWWorld void World::advanceTime (double hours) { + mWeatherManager->advanceTime (hours); + hours += mGlobalVariables->getFloat ("gamehour"); setHour (hours); @@ -575,10 +577,10 @@ namespace MWWorld if (*currCell != newCell) { if (isPlayer) { if (!newCell.isExterior()) { - changeToInteriorCell(toLower(newCell.cell->name), pos); + changeToInteriorCell(toLower(newCell.cell->mName), pos); } else { - int cellX = newCell.cell->data.gridX; - int cellY = newCell.cell->data.gridY; + int cellX = newCell.cell->mData.mX; + int cellY = newCell.cell->mData.mY; mWorldScene->changeCell(cellX, cellY, pos, false); } } else { @@ -644,7 +646,7 @@ namespace MWWorld { MWWorld::Class::get(ptr).adjustScale(ptr,scale); - ptr.getCellRef().scale = scale; + ptr.getCellRef().mScale = scale; //scale = scale/ptr.getRefData().getBaseNode()->getScale().x; ptr.getRefData().getBaseNode()->setScale(scale,scale,scale); mPhysics->scaleObject( ptr.getRefData().getHandle(), ptr.getRefData().getBaseNode()); @@ -802,23 +804,23 @@ namespace MWWorld const ESM::Cell *World::createRecord (const ESM::Cell& record) { - if (record.data.flags & ESM::Cell::Interior) + if (record.mData.mFlags & ESM::Cell::Interior) { - if (mStore.cells.searchInt (record.name)) + if (mStore.cells.searchInt (record.mName)) throw std::runtime_error ("failed creating interior cell"); ESM::Cell *cell = new ESM::Cell (record); - mStore.cells.intCells.insert (std::make_pair (record.name, cell)); + mStore.cells.intCells.insert (std::make_pair (record.mName, cell)); return cell; } else { - if (mStore.cells.searchExt (record.data.gridX, record.data.gridY)) + if (mStore.cells.searchExt (record.mData.mX, record.mData.mY)) throw std::runtime_error ("failed creating exterior cell"); ESM::Cell *cell = new ESM::Cell (record); mStore.cells.extCells.insert ( - std::make_pair (std::make_pair (record.data.gridX, record.data.gridY), cell)); + std::make_pair (std::make_pair (record.mData.mX, record.mData.mY), cell)); return cell; } } @@ -1013,7 +1015,7 @@ namespace MWWorld Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { - if (!(currentCell->cell->data.flags & ESM::Cell::Interior)) + if (!(currentCell->cell->mData.mFlags & ESM::Cell::Interior)) return true; else return false; @@ -1026,7 +1028,7 @@ namespace MWWorld Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { - if (!(currentCell->cell->data.flags & ESM::Cell::QuasiEx)) + if (!(currentCell->cell->mData.mFlags & ESM::Cell::QuasiEx)) return false; else return true; @@ -1071,28 +1073,28 @@ namespace MWWorld { MWWorld::LiveCellRef& ref = *it; - if (ref.ref.teleport) + if (ref.ref.mTeleport) { World::DoorMarker newMarker; std::string dest; - if (ref.ref.destCell != "") + if (ref.ref.mDestCell != "") { // door leads to an interior, use interior name - dest = ref.ref.destCell; + dest = ref.ref.mDestCell; } else { // door leads to exterior, use cell name (if any), otherwise translated region name int x,y; - positionToIndex (ref.ref.doorDest.pos[0], ref.ref.doorDest.pos[1], x, y); + positionToIndex (ref.ref.mDoorDest.pos[0], ref.ref.mDoorDest.pos[1], x, y); const ESM::Cell* cell = mStore.cells.findExt(x,y); - if (cell->name != "") - dest = cell->name; + if (cell->mName != "") + dest = cell->mName; else { - const ESM::Region* region = mStore.regions.search(cell->region); - dest = region->name; + const ESM::Region* region = mStore.regions.search(cell->mRegion); + dest = region->mName; } } @@ -1242,10 +1244,10 @@ namespace MWWorld bool World::isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos) { - if (!(cell.data.flags & ESM::Cell::HasWater)) { + if (!(cell.mData.mFlags & ESM::Cell::HasWater)) { return false; } - return pos.z < cell.water; + return pos.z < cell.mWater; } void World::renderPlayer() @@ -1275,7 +1277,7 @@ namespace MWWorld if (!isOnGround || isUnderwater (*currentCell->cell, playerPos)) return 2; - if (currentCell->cell->data.flags & ESM::Cell::NoSleep) + if (currentCell->cell->mData.mFlags & ESM::Cell::NoSleep) return 1; return 0; diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 1bc5e65f8..c714693c3 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -39,11 +39,11 @@ add_component_dir (esm_store ) add_component_dir (esm - attr defs esm_reader loadacti loadalch loadappa loadarmo loadbody loadbook loadbsgn loadcell + attr defs esmcommon esmreader esmwriter loadacti loadalch loadappa loadarmo loadbody loadbook loadbsgn loadcell loadclas loadclot loadcont loadcrea loadcrec loaddial loaddoor loadench loadfact loadglob loadgmst loadinfo loadingr loadland loadlevlist loadligh loadlocks loadltex loadmgef loadmisc loadnpcc loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat - loadweap records aipackage + loadweap records aipackage effectlist spelllist ) add_component_dir (misc diff --git a/components/esm/aipackage.cpp b/components/esm/aipackage.cpp index a2fd8beb1..1e6220c3a 100644 --- a/components/esm/aipackage.cpp +++ b/components/esm/aipackage.cpp @@ -1,5 +1,8 @@ #include "aipackage.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void AIPackageList::load(ESMReader &esm) @@ -34,4 +37,35 @@ namespace ESM } } } + + void AIPackageList::save(ESMWriter &esm) + { + typedef std::vector::iterator PackageIter; + for (PackageIter it = mList.begin(); it != mList.end(); ++it) { + switch (it->mType) { + case AI_Wander: + esm.writeHNT("AI_W", it->mWander, sizeof(it->mWander)); + break; + + case AI_Travel: + esm.writeHNT("AI_T", it->mTravel, sizeof(it->mTravel)); + break; + + case AI_Activate: + esm.writeHNT("AI_A", it->mActivate, sizeof(it->mActivate)); + break; + + case AI_Escort: + case AI_Follow: { + const char *name = (it->mType == AI_Escort) ? "AI_E" : "AI_F"; + esm.writeHNT(name, it->mTarget, sizeof(it->mTarget)); + esm.writeHNOCString("CNDT", it->mCellName); + break; + } + + default: + break; + } + } + } } diff --git a/components/esm/aipackage.hpp b/components/esm/aipackage.hpp index 3a8547402..3046a6a98 100644 --- a/components/esm/aipackage.hpp +++ b/components/esm/aipackage.hpp @@ -1,12 +1,16 @@ #ifndef OPENMW_ESM_AIPACKAGE_H #define OPENMW_ESM_AIPACKAGE_H -#include "esm_reader.hpp" - #include +#include + +#include "esmcommon.hpp" namespace ESM { + class ESMReader; + class ESMWriter; + #pragma pack(push) #pragma pack(1) @@ -31,7 +35,7 @@ namespace ESM struct AITravel { float mX, mY, mZ; - long mUnk; + int mUnk; }; struct AITarget @@ -88,6 +92,7 @@ namespace ESM /// it needs to use retSubName() if needed. But, hey, there /// is only one field left (XSCL) and only two records uses AI void load(ESMReader &esm); + void save(ESMWriter &esm); }; } diff --git a/components/esm/attr.cpp b/components/esm/attr.cpp index b077ef499..e20050bb3 100644 --- a/components/esm/attr.cpp +++ b/components/esm/attr.cpp @@ -2,7 +2,7 @@ using namespace ESM; -const Attribute::AttributeID Attribute::attributeIds[Attribute::Length] = { +const Attribute::AttributeID Attribute::sAttributeIds[Attribute::Length] = { Attribute::Strength, Attribute::Intelligence, Attribute::Willpower, @@ -13,7 +13,7 @@ const Attribute::AttributeID Attribute::attributeIds[Attribute::Length] = { Attribute::Luck }; -const std::string Attribute::gmstAttributeIds[Attribute::Length] = { +const std::string Attribute::sGmstAttributeIds[Attribute::Length] = { "sAttributeStrength", "sAttributeIntelligence", "sAttributeWillpower", @@ -24,7 +24,7 @@ const std::string Attribute::gmstAttributeIds[Attribute::Length] = { "sAttributeLuck" }; -const std::string Attribute::gmstAttributeDescIds[Attribute::Length] = { +const std::string Attribute::sGmstAttributeDescIds[Attribute::Length] = { "sStrDesc", "sIntDesc", "sWilDesc", @@ -35,7 +35,7 @@ const std::string Attribute::gmstAttributeDescIds[Attribute::Length] = { "sLucDesc" }; -const std::string Attribute::attributeIcons[Attribute::Length] = { +const std::string Attribute::sAttributeIcons[Attribute::Length] = { "icons\\k\\attribute_strength.dds", "icons\\k\\attribute_int.dds", "icons\\k\\attribute_wilpower.dds", diff --git a/components/esm/attr.hpp b/components/esm/attr.hpp index 620683dbb..2ed9b4f41 100644 --- a/components/esm/attr.hpp +++ b/components/esm/attr.hpp @@ -1,5 +1,5 @@ -#ifndef _ESM_ATTR_H -#define _ESM_ATTR_H +#ifndef OPENMW_ESM_ATTR_H +#define OPENMW_ESM_ATTR_H #include @@ -24,18 +24,18 @@ struct Attribute Length }; - AttributeID id; - std::string name, description; + AttributeID mId; + std::string mName, mDescription; - static const AttributeID attributeIds[Length]; - static const std::string gmstAttributeIds[Length]; - static const std::string gmstAttributeDescIds[Length]; - static const std::string attributeIcons[Length]; + static const AttributeID sAttributeIds[Length]; + static const std::string sGmstAttributeIds[Length]; + static const std::string sGmstAttributeDescIds[Length]; + static const std::string sAttributeIcons[Length]; Attribute(AttributeID id, const std::string &name, const std::string &description) - : id(id) - , name(name) - , description(description) + : mId(id) + , mName(name) + , mDescription(description) { } }; diff --git a/components/esm/defs.hpp b/components/esm/defs.hpp index 917c1031f..aa870f925 100644 --- a/components/esm/defs.hpp +++ b/components/esm/defs.hpp @@ -1,7 +1,7 @@ -#ifndef _ESM_DEFS_H -#define _ESM_DEFS_H +#ifndef OPENMW_ESM_DEFS_H +#define OPENMW_ESM_DEFS_H -#include "esm_reader.hpp" +#include namespace ESM { @@ -35,23 +35,6 @@ enum RangeType RT_Target = 2 }; -/** A list of references to spells and spell effects. This is shared - between the records BSGN, NPC and RACE. - */ -struct SpellList -{ - std::vector list; - - void load(ESMReader &esm) - { - while (esm.isNextSub("NPCS")) - list.push_back(esm.getHString()); - } -}; - -/** Defines a spell effect. Shared between SPEL (Spells), ALCH - (Potions) and ENCH (Item enchantments) records - */ #pragma pack(push) #pragma pack(1) @@ -61,37 +44,55 @@ struct Position float pos[3]; float rot[3]; }; - -struct ENAMstruct -{ - // Magical effect, hard-coded ID - short effectID; - - // Which skills/attributes are affected (for restore/drain spells - // etc.) - signed char skill, attribute; // -1 if N/A - - // Other spell parameters - int range; // 0 - self, 1 - touch, 2 - target (RangeType enum) - int area, duration, magnMin, magnMax; - - // Struct size should be 24 bytes -}; #pragma pack(pop) -struct EffectList +enum RecNameInts { - std::vector list; - - void load(ESMReader &esm) - { - ENAMstruct s; - while (esm.isNextSub("ENAM")) - { - esm.getHT(s, 24); - list.push_back(s); - } - } + REC_ACTI = 0x49544341, + REC_ALCH = 0x48434c41, + REC_APPA = 0x41505041, + REC_ARMO = 0x4f4d5241, + REC_BODY = 0x59444f42, + REC_BOOK = 0x4b4f4f42, + REC_BSGN = 0x4e475342, + REC_CELL = 0x4c4c4543, + REC_CLAS = 0x53414c43, + REC_CLOT = 0x544f4c43, + REC_CNTC = 0x43544e43, + REC_CONT = 0x544e4f43, + REC_CREA = 0x41455243, + REC_CREC = 0x43455243, + REC_DIAL = 0x4c414944, + REC_DOOR = 0x524f4f44, + REC_ENCH = 0x48434e45, + REC_FACT = 0x54434146, + REC_GLOB = 0x424f4c47, + REC_GMST = 0x54534d47, + REC_INFO = 0x4f464e49, + REC_INGR = 0x52474e49, + REC_LAND = 0x444e414c, + REC_LEVC = 0x4356454c, + REC_LEVI = 0x4956454c, + REC_LIGH = 0x4847494c, + REC_LOCK = 0x4b434f4c, + REC_LTEX = 0x5845544c, + REC_MGEF = 0x4645474d, + REC_MISC = 0x4353494d, + REC_NPC_ = 0x5f43504e, + REC_NPCC = 0x4343504e, + REC_PGRD = 0x44524750, + REC_PROB = 0x424f5250, + REC_RACE = 0x45434152, + REC_REGN = 0x4e474552, + REC_REPA = 0x41504552, + REC_SCPT = 0x54504353, + REC_SKIL = 0x4c494b53, + REC_SNDG = 0x47444e53, + REC_SOUN = 0x4e554f53, + REC_SPEL = 0x4c455053, + REC_SSCR = 0x52435353, + REC_STAT = 0x54415453, + REC_WEAP = 0x50414557 }; } diff --git a/components/esm/effectlist.cpp b/components/esm/effectlist.cpp new file mode 100644 index 000000000..88f87d6e2 --- /dev/null +++ b/components/esm/effectlist.cpp @@ -0,0 +1,24 @@ +#include "effectlist.hpp" + +#include "esmreader.hpp" +#include "esmwriter.hpp" + +namespace ESM { + +void EffectList::load(ESMReader &esm) +{ + ENAMstruct s; + while (esm.isNextSub("ENAM")) { + esm.getHT(s, 24); + mList.push_back(s); + } +} + +void EffectList::save(ESMWriter &esm) +{ + for (std::vector::iterator it = mList.begin(); it != mList.end(); ++it) { + esm.writeHNT("ENAM", *it, 24); + } +} + +} // end namespace diff --git a/components/esm/effectlist.hpp b/components/esm/effectlist.hpp new file mode 100644 index 000000000..9f5b87aed --- /dev/null +++ b/components/esm/effectlist.hpp @@ -0,0 +1,43 @@ +#ifndef OPENMW_ESM_EFFECTLIST_H +#define OPENMW_ESM_EFFECTLIST_H + +#include + +namespace ESM +{ + class ESMReader; + class ESMWriter; + + #pragma pack(push) + #pragma pack(1) + + /** Defines a spell effect. Shared between SPEL (Spells), ALCH + (Potions) and ENCH (Item enchantments) records + */ + struct ENAMstruct + { + // Magical effect, hard-coded ID + short mEffectID; + + // Which skills/attributes are affected (for restore/drain spells + // etc.) + signed char mSkill, mAttribute; // -1 if N/A + + // Other spell parameters + int mRange; // 0 - self, 1 - touch, 2 - target (RangeType enum) + int mArea, mDuration, mMagnMin, mMagnMax; + }; + #pragma pack(pop) + + struct EffectList + { + + std::vector mList; + + void load(ESMReader &esm); + void save(ESMWriter &esm); + }; + +} + +#endif diff --git a/components/esm/esmcommon.hpp b/components/esm/esmcommon.hpp new file mode 100644 index 000000000..e0c5c08af --- /dev/null +++ b/components/esm/esmcommon.hpp @@ -0,0 +1,127 @@ +#ifndef OPENMW_ESM_COMMON_H +#define OPENMW_ESM_COMMON_H + +#include + +#include +#include + +namespace ESM +{ +enum Version + { + VER_12 = 0x3f99999a, + VER_13 = 0x3fa66666 + }; + +enum FileType + { + FT_ESP = 0, // Plugin + FT_ESM = 1, // Master + FT_ESS = 32 // Savegame + }; + +// Used to mark special files. The original ESM files are given +// special treatment in a few places, most noticably in loading and +// filtering out "dirtly" GMST entries correctly. +enum SpecialFile + { + SF_Other, + SF_Morrowind, + SF_Tribunal, + SF_Bloodmoon + }; + +/* A structure used for holding fixed-length strings. In the case of + LEN=4, it can be more efficient to match the string as a 32 bit + number, therefore the struct is implemented as a union with an int. + */ +template +union NAME_T +{ + char name[LEN]; + int32_t val; + + bool operator==(const char *str) const + { + for(int i=0; i NAME; +typedef NAME_T<32> NAME32; +typedef NAME_T<64> NAME64; +typedef NAME_T<256> NAME256; + +#pragma pack(push) +#pragma pack(1) +/// File header data for all ES files +struct HEDRstruct +{ + /* File format version. This is actually a float, the supported + versions are 1.2 and 1.3. These correspond to: + 1.2 = 0x3f99999a and 1.3 = 0x3fa66666 + */ + int version; + int type; // 0=esp, 1=esm, 32=ess + NAME32 author; // Author's name + NAME256 desc; // File description + int records; // Number of records? Not used. +}; + +// Defines another files (esm or esp) that this file depends upon. +struct MasterData +{ + std::string name; + uint64_t size; +}; + +// Data that is only present in save game files +struct SaveData +{ + float pos[6]; // Player position and rotation + NAME64 cell; // Cell name + float unk2; // Unknown value - possibly game time? + NAME32 player; // Player name +}; +#pragma pack(pop) + +/* This struct defines a file 'context' which can be saved and later + restored by an ESMReader instance. It will save the position within + a file, and when restored will let you read from that position as + if you never left it. + */ +struct ESM_Context +{ + std::string filename; + uint32_t leftRec, leftSub; + size_t leftFile; + NAME recName, subName; + HEDRstruct header; + + // True if subName has been read but not used. + bool subCached; + + // File position. Only used for stored contexts, not regularly + // updated within the reader itself. + size_t filePos; +}; + +} + +#endif diff --git a/components/esm/esm_reader.cpp b/components/esm/esmreader.cpp similarity index 99% rename from components/esm/esm_reader.cpp rename to components/esm/esmreader.cpp index 95ef46e81..2915a1ce7 100644 --- a/components/esm/esm_reader.cpp +++ b/components/esm/esmreader.cpp @@ -1,4 +1,4 @@ -#include "esm_reader.hpp" +#include "esmreader.hpp" #include namespace ESM diff --git a/components/esm/esm_reader.hpp b/components/esm/esmreader.hpp similarity index 70% rename from components/esm/esm_reader.hpp rename to components/esm/esmreader.hpp index 66c0710a6..6a74c53e8 100644 --- a/components/esm/esm_reader.hpp +++ b/components/esm/esmreader.hpp @@ -1,5 +1,5 @@ -#ifndef _ESM_READER_H -#define _ESM_READER_H +#ifndef OPENMW_ESM_READER_H +#define OPENMW_ESM_READER_H #include #include @@ -12,124 +12,10 @@ #include #include +#include "esmcommon.hpp" namespace ESM { -enum Version - { - VER_12 = 0x3f99999a, - VER_13 = 0x3fa66666 - }; - -enum FileType - { - FT_ESP = 0, // Plugin - FT_ESM = 1, // Master - FT_ESS = 32 // Savegame - }; - -// Used to mark special files. The original ESM files are given -// special treatment in a few places, most noticably in loading and -// filtering out "dirtly" GMST entries correctly. -enum SpecialFile - { - SF_Other, - SF_Morrowind, - SF_Tribunal, - SF_Bloodmoon - }; - -/* A structure used for holding fixed-length strings. In the case of - LEN=4, it can be more efficient to match the string as a 32 bit - number, therefore the struct is implemented as a union with an int. - */ -template -union NAME_T -{ - char name[LEN]; - int32_t val; - - bool operator==(const char *str) const - { - for(int i=0; i NAME; -typedef NAME_T<32> NAME32; -typedef NAME_T<64> NAME64; -typedef NAME_T<256> NAME256; - -#pragma pack(push) -#pragma pack(1) -/// File header data for all ES files -struct HEDRstruct -{ - /* File format version. This is actually a float, the supported - versions are 1.2 and 1.3. These correspond to: - 1.2 = 0x3f99999a and 1.3 = 0x3fa66666 - */ - int version; - int type; // 0=esp, 1=esm, 32=ess - NAME32 author; // Author's name - NAME256 desc; // File description - int records; // Number of records? Not used. -}; - -// Defines another files (esm or esp) that this file depends upon. -struct MasterData -{ - std::string name; - uint64_t size; -}; - -// Data that is only present in save game files -struct SaveData -{ - float pos[6]; // Player position and rotation - NAME64 cell; // Cell name - float unk2; // Unknown value - possibly game time? - NAME32 player; // Player name -}; -#pragma pack(pop) - - -/* This struct defines a file 'context' which can be saved and later - restored by an ESMReader instance. It will save the position within - a file, and when restored will let you read from that position as - if you never left it. - */ -struct ESM_Context -{ - std::string filename; - uint32_t leftRec, leftSub; - size_t leftFile; - NAME recName, subName; - HEDRstruct header; - - // True if subName has been read but not used. - bool subCached; - - // File position. Only used for stored contexts, not regularly - // updated within the reader itself. - size_t filePos; -}; - class ESMReader { public: @@ -150,7 +36,8 @@ public: int getVer() const { return mCtx.header.version; } float getFVer() { if(mCtx.header.version == VER_12) return 1.2; else return 1.3; } - int getSpecial() const { return mSpf; } + int getSpecial() { return mSpf; } + int getType() { return mCtx.header.type; } const std::string getAuthor() { return mCtx.header.author.toString(); } const std::string getDesc() { return mCtx.header.desc.toString(); } const SaveData &getSaveData() const { return mSaveData; } diff --git a/components/esm/esmwriter.cpp b/components/esm/esmwriter.cpp new file mode 100644 index 000000000..24658a40b --- /dev/null +++ b/components/esm/esmwriter.cpp @@ -0,0 +1,212 @@ +#include "esmwriter.hpp" +#include +#include + +bool count = true; + +namespace ESM +{ + +int ESMWriter::getVersion() +{ + return m_header.version; +} + +void ESMWriter::setVersion(int ver) +{ + m_header.version = ver; +} + +int ESMWriter::getType() +{ + return m_header.type; +} + +void ESMWriter::setType(int type) +{ + m_header.type = type; +} + +void ESMWriter::setAuthor(const std::string& auth) +{ + strncpy((char*)&m_header.author, auth.c_str(), 32); +} + +void ESMWriter::setDescription(const std::string& desc) +{ + strncpy((char*)&m_header.desc, desc.c_str(), 256); +} + +void ESMWriter::addMaster(const std::string& name, uint64_t size) +{ + MasterData d; + d.name = name; + d.size = size; + m_masters.push_back(d); +} + +void ESMWriter::save(const std::string& file) +{ + std::ofstream fs(file.c_str(), std::ios_base::out | std::ios_base::trunc); + save(fs); +} + +void ESMWriter::save(std::ostream& file) +{ + m_recordCount = 0; + m_stream = &file; + + startRecord("TES3", 0); + + m_header.records = 0; + writeHNT("HEDR", m_header, 300); + m_headerPos = m_stream->tellp() - (std::streampos)4; + + for (std::list::iterator it = m_masters.begin(); it != m_masters.end(); ++it) + { + writeHNCString("MAST", it->name); + writeHNT("DATA", it->size); + } + + endRecord("TES3"); +} + +void ESMWriter::close() +{ + std::cout << "Writing amount of saved records (" << m_recordCount - 1 << ")" << std::endl; + m_stream->seekp(m_headerPos); + writeT(m_recordCount-1); + m_stream->seekp(0, std::ios::end); + m_stream->flush(); + + if (!m_records.empty()) + throw "Unclosed record remaining"; +} + +void ESMWriter::startRecord(const std::string& name, uint32_t flags) +{ + m_recordCount++; + + writeName(name); + RecordData rec; + rec.name = name; + rec.position = m_stream->tellp(); + rec.size = 0; + writeT(0); // Size goes here + writeT(0); // Unused header? + writeT(flags); + m_records.push_back(rec); + + assert(m_records.back().size == 0); +} + +void ESMWriter::startSubRecord(const std::string& name) +{ + writeName(name); + RecordData rec; + rec.name = name; + rec.position = m_stream->tellp(); + rec.size = 0; + writeT(0); // Size goes here + m_records.push_back(rec); + + assert(m_records.back().size == 0); +} + +void ESMWriter::endRecord(const std::string& name) +{ + RecordData rec = m_records.back(); + assert(rec.name == name); + m_records.pop_back(); + + m_stream->seekp(rec.position); + + count = false; + write((char*)&rec.size, sizeof(int)); + count = true; + + m_stream->seekp(0, std::ios::end); + +} + +void ESMWriter::writeHNString(const std::string& name, const std::string& data) +{ + startSubRecord(name); + writeHString(data); + endRecord(name); +} + +void ESMWriter::writeHNString(const std::string& name, const std::string& data, int size) +{ + assert(data.size() <= size); + startSubRecord(name); + writeHString(data); + + if (data.size() < size) + { + for (int i = data.size(); i < size; ++i) + write("\0",1); + } + + endRecord(name); +} + +void ESMWriter::writeHString(const std::string& data) +{ + if (data.size() == 0) + write("\0", 1); + else + { + char *ptr = ToUTF8::getBuffer(data.size()+1); + strncpy(ptr, &data[0], data.size()); + ptr[data.size()] = '\0'; + + // Convert to UTF8 and return + std::string ascii = ToUTF8::getLegacyEnc(m_encoding); + + write(ascii.c_str(), ascii.size()); + } +} + +void ESMWriter::writeHCString(const std::string& data) +{ + writeHString(data); + if (data.size() > 0 && data[data.size()-1] != '\0') + write("\0", 1); +} + +void ESMWriter::writeName(const std::string& name) +{ + assert((name.size() == 4 && name[3] != '\0')); + write(name.c_str(), name.size()); +} + +void ESMWriter::write(const char* data, int size) +{ + if (count && !m_records.empty()) + { + for (std::list::iterator it = m_records.begin(); it != m_records.end(); ++it) + it->size += size; + } + + m_stream->write(data, size); +} + +void ESMWriter::setEncoding(const std::string& encoding) +{ + if (encoding == "win1250") + { + m_encoding = ToUTF8::WINDOWS_1250; + } + else if (encoding == "win1251") + { + m_encoding = ToUTF8::WINDOWS_1251; + } + else + { + // Default Latin encoding + m_encoding = ToUTF8::WINDOWS_1252; + } +} + +} diff --git a/components/esm/esmwriter.hpp b/components/esm/esmwriter.hpp new file mode 100644 index 000000000..d3777be81 --- /dev/null +++ b/components/esm/esmwriter.hpp @@ -0,0 +1,105 @@ +#ifndef OPENMW_ESM_WRITER_H +#define OPENMW_ESM_WRITER_H + +#include +#include +#include + +#include "esmcommon.hpp" +#include "../to_utf8/to_utf8.hpp" + +namespace ESM { + +class ESMWriter +{ + struct RecordData + { + std::string name; + std::streampos position; + int size; + }; + +public: + int getVersion(); + void setVersion(int ver); + int getType(); + void setType(int type); + void setEncoding(const std::string& encoding); // Write strings as UTF-8? + void setAuthor(const std::string& author); + void setDescription(const std::string& desc); + + void addMaster(const std::string& name, uint64_t size); + + void save(const std::string& file); + void save(std::ostream& file); + void close(); + + void writeHNString(const std::string& name, const std::string& data); + void writeHNString(const std::string& name, const std::string& data, int size); + void writeHNCString(const std::string& name, const std::string& data) + { + startSubRecord(name); + writeHCString(data); + endRecord(name); + } + void writeHNOString(const std::string& name, const std::string& data) + { + if (!data.empty()) + writeHNString(name, data); + } + void writeHNOCString(const std::string& name, const std::string& data) + { + if (!data.empty()) + writeHNCString(name, data); + } + + template + void writeHNT(const std::string& name, const T& data) + { + startSubRecord(name); + writeT(data); + endRecord(name); + } + + template + void writeHNT(const std::string& name, const T& data, int size) + { + startSubRecord(name); + writeT(data, size); + endRecord(name); + } + + template + void writeT(const T& data) + { + write((char*)&data, sizeof(T)); + } + + template + void writeT(const T& data, int size) + { + write((char*)&data, size); + } + + void startRecord(const std::string& name, uint32_t flags); + void startSubRecord(const std::string& name); + void endRecord(const std::string& name); + void writeHString(const std::string& data); + void writeHCString(const std::string& data); + void writeName(const std::string& data); + void write(const char* data, int size); + +private: + std::list m_masters; + std::list m_records; + std::ostream* m_stream; + std::streampos m_headerPos; + ToUTF8::FromType m_encoding; + int m_recordCount; + + HEDRstruct m_header; + SaveData m_saveData; +}; + +} +#endif diff --git a/components/esm/loadacti.cpp b/components/esm/loadacti.cpp index 40c9b635c..0e214e2b6 100644 --- a/components/esm/loadacti.cpp +++ b/components/esm/loadacti.cpp @@ -1,11 +1,20 @@ #include "loadacti.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Activator::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNString("FNAM"); - script = esm.getHNOString("SCRI"); + mModel = esm.getHNString("MODL"); + mName = esm.getHNString("FNAM"); + mScript = esm.getHNOString("SCRI"); +} +void Activator::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNCString("FNAM", mName); + esm.writeHNOCString("SCRI", mScript); } } diff --git a/components/esm/loadacti.hpp b/components/esm/loadacti.hpp index 783559e11..86c2f44c4 100644 --- a/components/esm/loadacti.hpp +++ b/components/esm/loadacti.hpp @@ -1,16 +1,21 @@ -#ifndef _ESM_ACTI_H -#define _ESM_ACTI_H +#ifndef OPENMW_ESM_ACTI_H +#define OPENMW_ESM_ACTI_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + struct Activator { - std::string name, script, model; + std::string mName, mScript, mModel; void load(ESMReader &esm); + void save(ESMWriter &esm); }; + } #endif diff --git a/components/esm/loadalch.cpp b/components/esm/loadalch.cpp index cd36887b0..a4b1bb718 100644 --- a/components/esm/loadalch.cpp +++ b/components/esm/loadalch.cpp @@ -1,16 +1,26 @@ #include "loadalch.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { -void Potion::load(ESMReader &esm, const std::string& id) +void Potion::load(ESMReader &esm) { - mId = id; - - model = esm.getHNString("MODL"); - icon = esm.getHNOString("TEXT"); // not ITEX here for some reason - script = esm.getHNOString("SCRI"); - name = esm.getHNOString("FNAM"); - esm.getHNT(data, "ALDT", 12); - effects.load(esm); + mModel = esm.getHNString("MODL"); + mIcon = esm.getHNOString("TEXT"); // not ITEX here for some reason + mScript = esm.getHNOString("SCRI"); + mName = esm.getHNOString("FNAM"); + esm.getHNT(mData, "ALDT", 12); + mEffects.load(esm); +} +void Potion::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNOCString("TEXT", mIcon); + esm.writeHNOCString("SCRI", mScript); + esm.writeHNOCString("FNAM", mName); + esm.writeHNT("ALDT", mData, 12); + mEffects.save(esm); } } diff --git a/components/esm/loadalch.hpp b/components/esm/loadalch.hpp index 6917fb448..1e571ac40 100644 --- a/components/esm/loadalch.hpp +++ b/components/esm/loadalch.hpp @@ -1,12 +1,16 @@ -#ifndef _ESM_ALCH_H -#define _ESM_ALCH_H +#ifndef OPENMW_ESM_ALCH_H +#define OPENMW_ESM_ALCH_H -#include "esm_reader.hpp" -#include "defs.hpp" +#include + +#include "effectlist.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Alchemy item (potions) */ @@ -15,18 +19,17 @@ struct Potion { struct ALDTstruct { - float weight; - int value; - int autoCalc; + float mWeight; + int mValue; + int mAutoCalc; }; - ALDTstruct data; + ALDTstruct mData; - std::string name, model, icon, script; - EffectList effects; + std::string mId, mName, mModel, mIcon, mScript; + EffectList mEffects; - std::string mId; - - void load(ESMReader &esm, const std::string& id); -}; + void load(ESMReader &esm); + void save(ESMWriter &esm); + }; } #endif diff --git a/components/esm/loadappa.cpp b/components/esm/loadappa.cpp index c76ad5350..f5e7e10e1 100644 --- a/components/esm/loadappa.cpp +++ b/components/esm/loadappa.cpp @@ -1,13 +1,24 @@ #include "loadappa.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Apparatus::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNString("FNAM"); - esm.getHNT(data, "AADT", 16); - script = esm.getHNOString("SCRI"); - icon = esm.getHNString("ITEX"); + mModel = esm.getHNString("MODL"); + mName = esm.getHNString("FNAM"); + esm.getHNT(mData, "AADT", 16); + mScript = esm.getHNOString("SCRI"); + mIcon = esm.getHNString("ITEX"); +} +void Apparatus::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNCString("FNAM", mName); + esm.writeHNT("AADT", mData, 16); + esm.writeHNOCString("SCRI", mScript); + esm.writeHNCString("ITEX", mIcon); } } diff --git a/components/esm/loadappa.hpp b/components/esm/loadappa.hpp index 2caca32b3..101c39f41 100644 --- a/components/esm/loadappa.hpp +++ b/components/esm/loadappa.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_APPA_H -#define _ESM_APPA_H +#ifndef OPENMW_ESM_APPA_H +#define OPENMW_ESM_APPA_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Alchemist apparatus */ @@ -22,16 +25,17 @@ struct Apparatus struct AADTstruct { - int type; - float quality; - float weight; - int value; + int mType; + float mQuality; + float mWeight; + int mValue; }; - AADTstruct data; - std::string model, icon, script, name; + AADTstruct mData; + std::string mModel, mIcon, mScript, mName; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadarmo.cpp b/components/esm/loadarmo.cpp index 8b559b10f..613346533 100644 --- a/components/esm/loadarmo.cpp +++ b/components/esm/loadarmo.cpp @@ -1,5 +1,8 @@ #include "loadarmo.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { @@ -8,22 +11,43 @@ void PartReferenceList::load(ESMReader &esm) while (esm.isNextSub("INDX")) { PartReference pr; - esm.getHT(pr.part); // The INDX byte - pr.male = esm.getHNOString("BNAM"); - pr.female = esm.getHNOString("CNAM"); - parts.push_back(pr); + esm.getHT(pr.mPart); // The INDX byte + pr.mMale = esm.getHNOString("BNAM"); + pr.mFemale = esm.getHNOString("CNAM"); + mParts.push_back(pr); + } +} + +void PartReferenceList::save(ESMWriter &esm) +{ + for (std::vector::iterator it = mParts.begin(); it != mParts.end(); ++it) + { + esm.writeHNT("INDX", it->mPart); + esm.writeHNOString("BNAM", it->mMale); + esm.writeHNOString("CNAM", it->mFemale); } } void Armor::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNString("FNAM"); - script = esm.getHNOString("SCRI"); - esm.getHNT(data, "AODT", 24); - icon = esm.getHNOString("ITEX"); - parts.load(esm); - enchant = esm.getHNOString("ENAM"); + mModel = esm.getHNString("MODL"); + mName = esm.getHNString("FNAM"); + mScript = esm.getHNOString("SCRI"); + esm.getHNT(mData, "AODT", 24); + mIcon = esm.getHNOString("ITEX"); + mParts.load(esm); + mEnchant = esm.getHNOString("ENAM"); +} + +void Armor::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNCString("FNAM", mName); + esm.writeHNOCString("SCRI", mScript); + esm.writeHNT("AODT", mData, 24); + esm.writeHNOCString("ITEX", mIcon); + mParts.save(esm); + esm.writeHNOCString("ENAM", mEnchant); } } diff --git a/components/esm/loadarmo.hpp b/components/esm/loadarmo.hpp index 16b6b1d3a..57c9ccf12 100644 --- a/components/esm/loadarmo.hpp +++ b/components/esm/loadarmo.hpp @@ -1,11 +1,15 @@ -#ifndef _ESM_ARMO_H -#define _ESM_ARMO_H +#ifndef OPENMW_ESM_ARMO_H +#define OPENMW_ESM_ARMO_H -#include "esm_reader.hpp" +#include +#include namespace ESM { +class ESMReader; +class ESMWriter; + enum PartReferenceType { PRT_Head = 0, @@ -40,16 +44,17 @@ enum PartReferenceType // Reference to body parts struct PartReference { - char part; - std::string male, female; + char mPart; + std::string mMale, mFemale; }; // A list of references to body parts struct PartReferenceList { - std::vector parts; + std::vector mParts; void load(ESMReader &esm); + void save(ESMWriter &esm); }; struct Armor @@ -71,17 +76,18 @@ struct Armor struct AODTstruct { - int type; - float weight; - int value, health, enchant, armor; + int mType; + float mWeight; + int mValue, mHealth, mEnchant, mArmor; }; - AODTstruct data; - PartReferenceList parts; + AODTstruct mData; + PartReferenceList mParts; - std::string name, model, icon, script, enchant; + std::string mName, mModel, mIcon, mScript, mEnchant; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadbody.cpp b/components/esm/loadbody.cpp index 1c72b0fe0..831ad8b64 100644 --- a/components/esm/loadbody.cpp +++ b/components/esm/loadbody.cpp @@ -1,13 +1,22 @@ #include "loadbody.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void BodyPart::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNString("FNAM"); - esm.getHNT(data, "BYDT", 4); + mModel = esm.getHNString("MODL"); + mName = esm.getHNString("FNAM"); + esm.getHNT(mData, "BYDT", 4); +} +void BodyPart::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNCString("FNAM", mName); + esm.writeHNT("BYDT", mData, 4); } } diff --git a/components/esm/loadbody.hpp b/components/esm/loadbody.hpp index de3db40fc..8a05d9924 100644 --- a/components/esm/loadbody.hpp +++ b/components/esm/loadbody.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_BODY_H -#define _ESM_BODY_H +#ifndef OPENMW_ESM_BODY_H +#define OPENMW_ESM_BODY_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + struct BodyPart { enum MeshPart @@ -42,16 +45,17 @@ struct BodyPart struct BYDTstruct { - char part; - char vampire; - char flags; - char type; + char mPart; + char mVampire; + char mFlags; + char mType; }; - BYDTstruct data; - std::string model, name; + BYDTstruct mData; + std::string mModel, mName; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadbook.cpp b/components/esm/loadbook.cpp index ffa958e14..8ed2f122a 100644 --- a/components/esm/loadbook.cpp +++ b/components/esm/loadbook.cpp @@ -1,17 +1,30 @@ #include "loadbook.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Book::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNOString("FNAM"); - esm.getHNT(data, "BKDT", 20); - script = esm.getHNOString("SCRI"); - icon = esm.getHNOString("ITEX"); - text = esm.getHNOString("TEXT"); - enchant = esm.getHNOString("ENAM"); + mModel = esm.getHNString("MODL"); + mName = esm.getHNOString("FNAM"); + esm.getHNT(mData, "BKDT", 20); + mScript = esm.getHNOString("SCRI"); + mIcon = esm.getHNOString("ITEX"); + mText = esm.getHNOString("TEXT"); + mEnchant = esm.getHNOString("ENAM"); +} +void Book::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNOCString("FNAM", mName); + esm.writeHNT("BKDT", mData, 20); + esm.writeHNOCString("SCRI", mScript); + esm.writeHNOCString("ITEX", mIcon); + esm.writeHNOString("TEXT", mText); + esm.writeHNOCString("ENAM", mEnchant); } } diff --git a/components/esm/loadbook.hpp b/components/esm/loadbook.hpp index 3a4ab441e..22201abed 100644 --- a/components/esm/loadbook.hpp +++ b/components/esm/loadbook.hpp @@ -1,27 +1,31 @@ -#ifndef _ESM_BOOK_H -#define _ESM_BOOK_H +#ifndef OPENMW_ESM_BOOK_H +#define OPENMW_ESM_BOOK_H -#include "esm_reader.hpp" +#include namespace ESM { - /* * Books, magic scrolls, notes and so on */ +class ESMReader; +class ESMWriter; + struct Book { struct BKDTstruct { - float weight; - int value, isScroll, skillID, enchant; + float mWeight; + int mValue, mIsScroll, mSkillID, mEnchant; }; - BKDTstruct data; - std::string name, model, icon, script, enchant, text; + BKDTstruct mData; + std::string mName, mModel, mIcon, mScript, mEnchant, mText; + std::string mId; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadbsgn.cpp b/components/esm/loadbsgn.cpp index 976cb7d20..b58071644 100644 --- a/components/esm/loadbsgn.cpp +++ b/components/esm/loadbsgn.cpp @@ -1,15 +1,27 @@ #include "loadbsgn.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void BirthSign::load(ESMReader &esm) { - name = esm.getHNString("FNAM"); - texture = esm.getHNOString("TNAM"); - description = esm.getHNOString("DESC"); + mName = esm.getHNString("FNAM"); + mTexture = esm.getHNOString("TNAM"); + mDescription = esm.getHNOString("DESC"); - powers.load(esm); + mPowers.load(esm); +} + +void BirthSign::save(ESMWriter &esm) +{ + esm.writeHNCString("FNAM", mName); + esm.writeHNOCString("TNAM", mTexture); + esm.writeHNOCString("DESC", mDescription); + + mPowers.save(esm); } } diff --git a/components/esm/loadbsgn.hpp b/components/esm/loadbsgn.hpp index 53964b02c..ac4050878 100644 --- a/components/esm/loadbsgn.hpp +++ b/components/esm/loadbsgn.hpp @@ -1,20 +1,25 @@ -#ifndef _ESM_BSGN_H -#define _ESM_BSGN_H +#ifndef OPENMW_ESM_BSGN_H +#define OPENMW_ESM_BSGN_H -#include "defs.hpp" -#include "esm_reader.hpp" +#include + +#include "spelllist.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + struct BirthSign { - std::string name, description, texture; + std::string mName, mDescription, mTexture; // List of powers and abilities that come with this birth sign. - SpellList powers; + SpellList mPowers; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadcell.cpp b/components/esm/loadcell.cpp index 158cc0867..97ce17775 100644 --- a/components/esm/loadcell.cpp +++ b/components/esm/loadcell.cpp @@ -3,68 +3,164 @@ #include #include +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { +void CellRef::save(ESMWriter &esm) +{ + esm.writeHNT("FRMR", mRefnum); + esm.writeHNCString("NAME", mRefID); + + if (mScale != 1.0) { + esm.writeHNT("XSCL", mScale); + } + + esm.writeHNOCString("ANAM", mOwner); + esm.writeHNOCString("BNAM", mGlob); + esm.writeHNOCString("XSOL", mSoul); + + esm.writeHNOCString("CNAM", mFaction); + if (mFactIndex != -2) { + esm.writeHNT("INDX", mFactIndex); + } + + if (mCharge != -1.0) { + esm.writeHNT("XCHG", mCharge); + } + + if (mIntv != -1) { + esm.writeHNT("INTV", mIntv); + } + if (mNam9 != 0) { + esm.writeHNT("NAM9", mNam9); + } + + if (mTeleport) + { + esm.writeHNT("DODT", mDoorDest); + esm.writeHNOCString("DNAM", mDestCell); + } + + if (mLockLevel != -1) { + esm.writeHNT("FLTV", mLockLevel); + } + esm.writeHNOCString("KNAM", mKey); + esm.writeHNOCString("TNAM", mTrap); + + if (mUnam != -1) { + esm.writeHNT("UNAM", mUnam); + } + if (mFltv != 0) { + esm.writeHNT("FLTV", mFltv); + } + + esm.writeHNT("DATA", mPos, 24); + if (mNam0 != 0) { + esm.writeHNT("NAM0", mNam0); + } +} + void Cell::load(ESMReader &esm) { // Ignore this for now, it might mean we should delete the entire // cell? - if (esm.isNextSub("DELE")) + if (esm.isNextSub("DELE")) { esm.skipHSub(); + } - esm.getHNT(data, "DATA", 12); + esm.getHNT(mData, "DATA", 12); // Water level - water = 0; + mWater = -1; + mNAM0 = 0; - if (data.flags & Interior) + if (mData.mFlags & Interior) { // Interior cells if (esm.isNextSub("INTV")) { int waterl; esm.getHT(waterl); - water = (float) waterl; + mWater = (float) waterl; + mWaterInt = true; } else if (esm.isNextSub("WHGT")) - esm.getHT(water); + esm.getHT(mWater); // Quasi-exterior cells have a region (which determines the // weather), pure interior cells have ambient lighting // instead. - if (data.flags & QuasiEx) - region = esm.getHNOString("RGNN"); + if (mData.mFlags & QuasiEx) + mRegion = esm.getHNOString("RGNN"); else - esm.getHNT(ambi, "AMBI", 16); + esm.getHNT(mAmbi, "AMBI", 16); } else { // Exterior cells - region = esm.getHNOString("RGNN"); - esm.getHNOT(mapColor, "NAM5"); + mRegion = esm.getHNOString("RGNN"); + + mMapColor = 0; + esm.getHNOT(mMapColor, "NAM5"); + } + if (esm.isNextSub("NAM0")) { + esm.getHT(mNAM0); } // Save position of the cell references and move on - context = esm.getContext(); + mContext = esm.getContext(); esm.skipRecord(); } +void Cell::save(ESMWriter &esm) +{ + esm.writeHNT("DATA", mData, 12); + if (mData.mFlags & Interior) + { + if (mWater != -1) { + if (mWaterInt) { + int water = + (mWater >= 0) ? (int) (mWater + 0.5) : (int) (mWater - 0.5); + esm.writeHNT("INTV", water); + } else { + esm.writeHNT("WHGT", mWater); + } + } + + if (mData.mFlags & QuasiEx) + esm.writeHNOCString("RGNN", mRegion); + else + esm.writeHNT("AMBI", mAmbi, 16); + } + else + { + esm.writeHNOCString("RGNN", mRegion); + if (mMapColor != 0) + esm.writeHNT("NAM5", mMapColor); + } + + if (mNAM0 != 0) + esm.writeHNT("NAM0", mNAM0); +} + void Cell::restore(ESMReader &esm) const { - esm.restoreContext(context); + esm.restoreContext(mContext); } std::string Cell::getDescription() const { - if (data.flags & Interior) + if (mData.mFlags & Interior) { - return name; + return mName; } else { std::ostringstream stream; - stream << data.gridX << ", " << data.gridY; + stream << mData.mX << ", " << mData.mY; return stream.str(); } } @@ -74,60 +170,62 @@ bool Cell::getNextRef(ESMReader &esm, CellRef &ref) if (!esm.hasMoreSubs()) return false; - // Number of references in the cell? Maximum once in each cell, - // but not always at the beginning, and not always right. In other - // words, completely useless. - { - int i; - esm.getHNOT(i, "NAM0"); - } - - esm.getHNT(ref.refnum, "FRMR"); - ref.refID = esm.getHNString("NAME"); + esm.getHNT(ref.mRefnum, "FRMR"); + ref.mRefID = esm.getHNString("NAME"); // getHNOT will not change the existing value if the subrecord is // missing - ref.scale = 1.0; - esm.getHNOT(ref.scale, "XSCL"); + ref.mScale = 1.0; + esm.getHNOT(ref.mScale, "XSCL"); - ref.owner = esm.getHNOString("ANAM"); - ref.glob = esm.getHNOString("BNAM"); - ref.soul = esm.getHNOString("XSOL"); + ref.mOwner = esm.getHNOString("ANAM"); + ref.mGlob = esm.getHNOString("BNAM"); + ref.mSoul = esm.getHNOString("XSOL"); - ref.faction = esm.getHNOString("CNAM"); - ref.factIndex = -1; - esm.getHNOT(ref.factIndex, "INDX"); + ref.mFaction = esm.getHNOString("CNAM"); + ref.mFactIndex = -2; + esm.getHNOT(ref.mFactIndex, "INDX"); - ref.charge = -1.0; - esm.getHNOT(ref.charge, "XCHG"); + ref.mCharge = -1.0; + esm.getHNOT(ref.mCharge, "XCHG"); - ref.intv = 0; - ref.nam9 = 0; - esm.getHNOT(ref.intv, "INTV"); - esm.getHNOT(ref.nam9, "NAM9"); + ref.mIntv = -1; + ref.mNam9 = 0; + esm.getHNOT(ref.mIntv, "INTV"); + esm.getHNOT(ref.mNam9, "NAM9"); // Present for doors that teleport you to another cell. if (esm.isNextSub("DODT")) { - ref.teleport = true; - esm.getHT(ref.doorDest); - ref.destCell = esm.getHNOString("DNAM"); + ref.mTeleport = true; + esm.getHT(ref.mDoorDest); + ref.mDestCell = esm.getHNOString("DNAM"); + } else { + ref.mTeleport = false; } - else - ref.teleport = false; // Integer, despite the name suggesting otherwise - ref.lockLevel = 0; - esm.getHNOT(ref.lockLevel, "FLTV"); - ref.key = esm.getHNOString("KNAM"); - ref.trap = esm.getHNOString("TNAM"); + ref.mLockLevel = -1; + esm.getHNOT(ref.mLockLevel, "FLTV"); + ref.mKey = esm.getHNOString("KNAM"); + ref.mTrap = esm.getHNOString("TNAM"); - ref.unam = 0; - ref.fltv = 0; - esm.getHNOT(ref.unam, "UNAM"); - esm.getHNOT(ref.fltv, "FLTV"); + ref.mUnam = -1; + ref.mFltv = 0; + esm.getHNOT(ref.mUnam, "UNAM"); + esm.getHNOT(ref.mFltv, "FLTV"); - esm.getHNT(ref.pos, "DATA", 24); + esm.getHNT(ref.mPos, "DATA", 24); + + // Number of references in the cell? Maximum once in each cell, + // but not always at the beginning, and not always right. In other + // words, completely useless. + ref.mNam0 = 0; + if (esm.isNextSub("NAM0")) + { + esm.getHT(ref.mNam0); + //esm.getHNOT(NAM0, "NAM0"); + } return true; } diff --git a/components/esm/loadcell.hpp b/components/esm/loadcell.hpp index 8070f9c03..fbd7c0456 100644 --- a/components/esm/loadcell.hpp +++ b/components/esm/loadcell.hpp @@ -1,10 +1,16 @@ -#ifndef _ESM_CELL_H -#define _ESM_CELL_H +#ifndef OPENMW_ESM_CELL_H +#define OPENMW_ESM_CELL_H -#include "esm_reader.hpp" +#include + +#include "esmcommon.hpp" #include "defs.hpp" -namespace ESM { +namespace ESM +{ + +class ESMReader; +class ESMWriter; /* Cell reference. This represents ONE object (of many) inside the cell. The cell references are not loaded as part of the normal @@ -14,63 +20,66 @@ namespace ESM { class CellRef { public: - int refnum; // Reference number - std::string refID; // ID of object being referenced + int mRefnum; // Reference number + std::string mRefID; // ID of object being referenced - float scale; // Scale applied to mesh + float mScale; // Scale applied to mesh // The NPC that owns this object (and will get angry if you steal // it) - std::string owner; + std::string mOwner; // I have no idea, looks like a link to a global variable? - std::string glob; + std::string mGlob; // ID of creature trapped in this soul gem (?) - std::string soul; + std::string mSoul; // ?? CNAM has a faction name, might be for objects/beds etc // belonging to a faction. - std::string faction; + std::string mFaction; // INDX might be PC faction rank required to use the item? Sometimes // is -1, which I assume means "any rank". - int factIndex; + int mFactIndex; // Depends on context - possibly weapon health, number of uses left // or weapon magic charge? - float charge; + float mCharge; // I have no idea, these are present some times, often along with // owner (ANAM) and sometimes otherwise. They are often (but not // always) 1. INTV is big for lights (possibly a float?), might have // something to do with remaining light "charge". - int intv, nam9; + int mIntv, mNam9; // For doors - true if this door teleports to somewhere else, false // if it should open through animation. - bool teleport; + bool mTeleport; // Teleport location for the door, if this is a teleporting door. - Position doorDest; + Position mDoorDest; // Destination cell for doors (optional) - std::string destCell; + std::string mDestCell; // Lock level for doors and containers - int lockLevel; - std::string key, trap; // Key and trap ID names, if any + int mLockLevel; + std::string mKey, mTrap; // Key and trap ID names, if any // No idea - occurs ONCE in Morrowind.esm, for an activator - char unam; + char mUnam; // Occurs in Tribunal.esm, eg. in the cell "Mournhold, Plaza // Brindisi Dorom", where it has the value 100. Also only for // activators. - int fltv; + int mFltv; + int mNam0; // Position and rotation of this object within the cell - Position pos; + Position mPos; + + void save(ESMWriter &esm); }; /* Cells hold data about objects, creatures, statics (rocks, walls, @@ -94,44 +103,47 @@ struct Cell struct DATAstruct { - int flags; - int gridX, gridY; + int mFlags; + int mX, mY; }; struct AMBIstruct { - Color ambient, sunlight, fog; - float fogDensity; + Color mAmbient, mSunlight, mFog; + float mFogDensity; }; // Interior cells are indexed by this (it's the 'id'), for exterior // cells it is optional. - std::string name, + std::string mName; // Optional region name for exterior and quasi-exterior cells. - region; + std::string mRegion; - ESM_Context context; // File position - DATAstruct data; - AMBIstruct ambi; - float water; // Water level - int mapColor; + ESM_Context mContext; // File position + DATAstruct mData; + AMBIstruct mAmbi; + float mWater; // Water level + bool mWaterInt; + int mMapColor; + int mNAM0; void load(ESMReader &esm); + void save(ESMWriter &esm); bool isExterior() const { - return !(data.flags & Interior); + return !(mData.mFlags & Interior); } int getGridX() const { - return data.gridX; + return mData.mX; } int getGridY() const { - return data.gridY; + return mData.mY; } // Restore the given reader to the stored position. Will try to open diff --git a/components/esm/loadclas.cpp b/components/esm/loadclas.cpp index b15852cc2..a62668950 100644 --- a/components/esm/loadclas.cpp +++ b/components/esm/loadclas.cpp @@ -1,15 +1,18 @@ #include "loadclas.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { -const Class::Specialization Class::specializationIds[3] = { +const Class::Specialization Class::sSpecializationIds[3] = { Class::Combat, Class::Magic, Class::Stealth }; -const char *Class::gmstSpecializationIds[3] = { +const char *Class::sGmstSpecializationIds[3] = { "sSpecializationCombat", "sSpecializationMagic", "sSpecializationStealth" @@ -17,13 +20,19 @@ const char *Class::gmstSpecializationIds[3] = { void Class::load(ESMReader &esm) { - name = esm.getHNString("FNAM"); - esm.getHNT(data, "CLDT", 60); + mName = esm.getHNString("FNAM"); + esm.getHNT(mData, "CLDT", 60); - if (data.isPlayable > 1) + if (mData.mIsPlayable > 1) esm.fail("Unknown bool value"); - description = esm.getHNOString("DESC"); + mDescription = esm.getHNOString("DESC"); +} +void Class::save(ESMWriter &esm) +{ + esm.writeHNCString("FNAM", mName); + esm.writeHNT("CLDT", mData, 60); + esm.writeHNOString("DESC", mDescription); } } diff --git a/components/esm/loadclas.hpp b/components/esm/loadclas.hpp index 08412c838..0311002b8 100644 --- a/components/esm/loadclas.hpp +++ b/components/esm/loadclas.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_CLAS_H -#define _ESM_CLAS_H +#ifndef OPENMW_ESM_CLAS_H +#define OPENMW_ESM_CLAS_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Character class definitions */ @@ -43,24 +46,25 @@ struct Class Stealth = 2 }; - static const Specialization specializationIds[3]; - static const char *gmstSpecializationIds[3]; + static const Specialization sSpecializationIds[3]; + static const char *sGmstSpecializationIds[3]; struct CLDTstruct { - int attribute[2]; // Attributes that get class bonus - int specialization; // 0 = Combat, 1 = Magic, 2 = Stealth - int skills[5][2]; // Minor and major skills. - int isPlayable; // 0x0001 - Playable class + int mAttribute[2]; // Attributes that get class bonus + int mSpecialization; // 0 = Combat, 1 = Magic, 2 = Stealth + int mSkills[5][2]; // Minor and major skills. + int mIsPlayable; // 0x0001 - Playable class // I have no idea how to autocalculate these items... - int calc; + int mCalc; }; // 60 bytes - std::string name, description; - CLDTstruct data; + std::string mName, mDescription; + CLDTstruct mData; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadclot.cpp b/components/esm/loadclot.cpp index 16fd0598c..a37fbe8a4 100644 --- a/components/esm/loadclot.cpp +++ b/components/esm/loadclot.cpp @@ -1,21 +1,37 @@ #include "loadclot.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Clothing::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNOString("FNAM"); - esm.getHNT(data, "CTDT", 12); + mModel = esm.getHNString("MODL"); + mName = esm.getHNOString("FNAM"); + esm.getHNT(mData, "CTDT", 12); - script = esm.getHNOString("SCRI"); - icon = esm.getHNOString("ITEX"); + mScript = esm.getHNOString("SCRI"); + mIcon = esm.getHNOString("ITEX"); - parts.load(esm); + mParts.load(esm); - enchant = esm.getHNOString("ENAM"); + mEnchant = esm.getHNOString("ENAM"); +} +void Clothing::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNOCString("FNAM", mName); + esm.writeHNT("CTDT", mData, 12); + + esm.writeHNOCString("SCRI", mScript); + esm.writeHNOCString("ITEX", mIcon); + + mParts.save(esm); + + esm.writeHNOCString("ENAM", mEnchant); } } diff --git a/components/esm/loadclot.hpp b/components/esm/loadclot.hpp index 8fa06e7e4..df64c87d3 100644 --- a/components/esm/loadclot.hpp +++ b/components/esm/loadclot.hpp @@ -1,12 +1,16 @@ -#ifndef _ESM_CLOT_H -#define _ESM_CLOT_H +#ifndef OPENMW_ESM_CLOT_H +#define OPENMW_ESM_CLOT_H + +#include -#include "esm_reader.hpp" #include "loadarmo.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Clothing */ @@ -29,18 +33,19 @@ struct Clothing struct CTDTstruct { - int type; - float weight; - short value; - short enchant; + int mType; + float mWeight; + short mValue; + short mEnchant; }; - CTDTstruct data; + CTDTstruct mData; - PartReferenceList parts; + PartReferenceList mParts; - std::string name, model, icon, enchant, script; + std::string mName, mModel, mIcon, mEnchant, mScript; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadcont.cpp b/components/esm/loadcont.cpp index 14699ccc5..e6ba91e7c 100644 --- a/components/esm/loadcont.cpp +++ b/components/esm/loadcont.cpp @@ -1,5 +1,8 @@ #include "loadcont.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { @@ -9,25 +12,45 @@ void InventoryList::load(ESMReader &esm) while (esm.isNextSub("NPCO")) { esm.getHT(ci, 36); - list.push_back(ci); + mList.push_back(ci); + } +} + +void InventoryList::save(ESMWriter &esm) +{ + for (std::vector::iterator it = mList.begin(); it != mList.end(); ++it) + { + esm.writeHNT("NPCO", *it, 36); } } void Container::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNOString("FNAM"); - esm.getHNT(weight, "CNDT", 4); - esm.getHNT(flags, "FLAG", 4); + mModel = esm.getHNString("MODL"); + mName = esm.getHNOString("FNAM"); + esm.getHNT(mWeight, "CNDT", 4); + esm.getHNT(mFlags, "FLAG", 4); - if (flags & 0xf4) + if (mFlags & 0xf4) esm.fail("Unknown flags"); - if (!(flags & 0x8)) + if (!(mFlags & 0x8)) esm.fail("Flag 8 not set"); - script = esm.getHNOString("SCRI"); + mScript = esm.getHNOString("SCRI"); - inventory.load(esm); + mInventory.load(esm); +} + +void Container::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNOCString("FNAM", mName); + esm.writeHNT("CNDT", mWeight, 4); + esm.writeHNT("FLAG", mFlags, 4); + + esm.writeHNOCString("SCRI", mScript); + + mInventory.save(esm); } } diff --git a/components/esm/loadcont.hpp b/components/esm/loadcont.hpp index 4614c4230..eb1f64d6f 100644 --- a/components/esm/loadcont.hpp +++ b/components/esm/loadcont.hpp @@ -1,26 +1,33 @@ -#ifndef _ESM_CONT_H -#define _ESM_CONT_H +#ifndef OPENMW_ESM_CONT_H +#define OPENMW_ESM_CONT_H -#include "esm_reader.hpp" +#include +#include + +#include "esmcommon.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Container definition */ struct ContItem { - int count; - NAME32 item; + int mCount; + NAME32 mItem; }; struct InventoryList { - std::vector list; + std::vector mList; void load(ESMReader &esm); + void save(ESMWriter &esm); }; struct Container @@ -32,13 +39,14 @@ struct Container Unknown = 8 }; - std::string name, model, script; + std::string mName, mModel, mScript; - float weight; // Not sure, might be max total weight allowed? - int flags; - InventoryList inventory; + float mWeight; // Not sure, might be max total weight allowed? + int mFlags; + InventoryList mInventory; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadcrea.cpp b/components/esm/loadcrea.cpp index e72944787..b59835bd6 100644 --- a/components/esm/loadcrea.cpp +++ b/components/esm/loadcrea.cpp @@ -1,23 +1,24 @@ #include "loadcrea.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { -void Creature::load(ESMReader &esm, const std::string& id) +void Creature::load(ESMReader &esm) { - mId = id; + mModel = esm.getHNString("MODL"); + mOriginal = esm.getHNOString("CNAM"); + mName = esm.getHNOString("FNAM"); + mScript = esm.getHNOString("SCRI"); - model = esm.getHNString("MODL"); - original = esm.getHNOString("CNAM"); - name = esm.getHNOString("FNAM"); - script = esm.getHNOString("SCRI"); + esm.getHNT(mData, "NPDT", 96); - esm.getHNT(data, "NPDT", 96); + esm.getHNT(mFlags, "FLAG"); + mScale = 1.0; + esm.getHNOT(mScale, "XSCL"); - esm.getHNT(flags, "FLAG"); - scale = 1.0; - esm.getHNOT(scale, "XSCL"); - - inventory.load(esm); + mInventory.load(esm); mSpells.load(esm); if (esm.isNextSub("AIDT")) @@ -32,4 +33,24 @@ void Creature::load(ESMReader &esm, const std::string& id) esm.skipRecord(); } +void Creature::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNOCString("CNAM", mOriginal); + esm.writeHNOCString("FNAM", mName); + esm.writeHNOCString("SCRI", mScript); + esm.writeHNT("NPDT", mData, 96); + esm.writeHNT("FLAG", mFlags); + if (mScale != 1.0) { + esm.writeHNT("XSCL", mScale); + } + + mInventory.save(esm); + mSpells.save(esm); + if (mHasAI) { + esm.writeHNT("AIDT", mAiData, sizeof(mAiData)); + } + mAiPackage.save(esm); +} + } diff --git a/components/esm/loadcrea.hpp b/components/esm/loadcrea.hpp index 59e926446..1c93d995a 100644 --- a/components/esm/loadcrea.hpp +++ b/components/esm/loadcrea.hpp @@ -1,14 +1,18 @@ -#ifndef _ESM_CREA_H -#define _ESM_CREA_H +#ifndef OPENMW_ESM_CREA_H +#define OPENMW_ESM_CREA_H + +#include -#include "esm_reader.hpp" #include "loadcont.hpp" -#include "defs.hpp" +#include "spelllist.hpp" #include "aipackage.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Creature definition * @@ -19,58 +23,68 @@ struct Creature // Default is 0x48? enum Flags { - Biped = 0x001, Respawn = 0x002, Weapon = 0x004, // Has weapon and shield - None = 0x008, // ?? - Swims = 0x010, - Flies = 0x020, // Don't know what happens if several - Walks = 0x040, // of these are set - Essential = 0x080, - Skeleton = 0x400, // Does not have normal blood - Metal = 0x800 - // Has 'golden' blood + Biped = 0x001, + Respawn = 0x002, + Weapon = 0x004, // Has weapon and shield + None = 0x008, // ?? + Swims = 0x010, + Flies = 0x020, // Don't know what happens if several + Walks = 0x040, // of these are set + Essential = 0x080, + Skeleton = 0x400, // Does not have normal blood + Metal = 0x800 // Has 'golden' blood }; enum Type { Creatures = 0, - Deadra = 1, + Deadra = 1, Undead = 2, Humanoid = 3 }; struct NPDTstruct { - int type; + int mType; // For creatures we obviously have to use ints, not shorts and // bytes like we use for NPCs.... this file format just makes so // much sense! (Still, _much_ easier to decode than the NIFs.) - int level; - int strength, intelligence, willpower, agility, speed, endurance, - personality, luck, health, mana, fatigue; // Stats - int soul; // The creatures soul value (used with soul gems.) - int combat, magic, stealth; // Don't know yet. - int attack[6]; // AttackMin1, AttackMax1, ditto2, ditto3 - int gold; + int mLevel; + int mStrength, + mIntelligence, + mWillpower, + mAgility, + mSpeed, + mEndurance, + mPersonality, + mLuck; + + int mHealth, mMana, mFatigue; // Stats + int mSoul; // The creatures soul value (used with soul gems.) + int mCombat, mMagic, mStealth; // Don't know yet. + int mAttack[6]; // AttackMin1, AttackMax1, ditto2, ditto3 + int mGold; }; // 96 bytes - NPDTstruct data; + NPDTstruct mData; - int flags; - float scale; + int mFlags; + float mScale; - std::string model, name, script, original; // Base creature that this is a modification of + std::string mId, mModel, mName, mScript; + std::string mOriginal; // Base creature that this is a modification of - // Defined in loadcont.hpp - InventoryList inventory; + InventoryList mInventory; SpellList mSpells; + bool mHasAI; AIData mAiData; AIPackageList mAiPackage; - std::string mId; - - void load(ESMReader &esm, const std::string& id); + void load(ESMReader &esm); + void save(ESMWriter &esm); }; + } #endif diff --git a/components/esm/loadcrec.hpp b/components/esm/loadcrec.hpp index 4d38d4a23..a95656f63 100644 --- a/components/esm/loadcrec.hpp +++ b/components/esm/loadcrec.hpp @@ -1,29 +1,41 @@ -#ifndef _ESM_CREC_H -#define _ESM_CREC_H +#ifndef OPENMW_ESM_CREC_H +#define OPENMW_ESM_CREC_H -#include "esm_reader.hpp" +// TODO create implementation files and remove this one +#include "esmreader.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* These two are only used in save games. They are not decoded yet. */ /// Changes a creature struct LoadCREC { - void load(ESMReader &esm) + void load(ESMReader &esm) { esm.skipRecord(); } + + void save(ESMWriter &esm) + { + } }; /// Changes an item list / container struct LoadCNTC { - void load(ESMReader &esm) + void load(ESMReader &esm) { esm.skipRecord(); } + + void save(ESMWriter &esm) + { + } }; } #endif diff --git a/components/esm/loaddial.cpp b/components/esm/loaddial.cpp index d2283d351..fb50d5e9f 100644 --- a/components/esm/loaddial.cpp +++ b/components/esm/loaddial.cpp @@ -1,5 +1,8 @@ #include "loaddial.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { @@ -9,17 +12,28 @@ void Dialogue::load(ESMReader &esm) esm.getSubHeader(); int si = esm.getSubSize(); if (si == 1) - esm.getT(type); + esm.getT(mType); else if (si == 4) { // These are just markers, their values are not used. int i; esm.getT(i); esm.getHNT(i, "DELE"); - type = Deleted; + mType = Deleted; } else esm.fail("Unknown sub record size"); } +void Dialogue::save(ESMWriter &esm) +{ + if (mType != Deleted) + esm.writeHNT("DATA", mType); + else + { + esm.writeHNT("DATA", (int)1); + esm.writeHNT("DELE", (int)1); + } +} + } diff --git a/components/esm/loaddial.hpp b/components/esm/loaddial.hpp index 1f18a49d0..078c78811 100644 --- a/components/esm/loaddial.hpp +++ b/components/esm/loaddial.hpp @@ -1,14 +1,17 @@ -#ifndef _ESM_DIAL_H -#define _ESM_DIAL_H +#ifndef OPENMW_ESM_DIAL_H +#define OPENMW_ESM_DIAL_H +#include #include -#include "esm_reader.hpp" #include "loadinfo.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Dialogue topic and journal entries. The actual data is contained in * the INFO records following the DIAL. @@ -26,10 +29,12 @@ struct Dialogue Deleted = -1 }; - char type; + std::string mId; + char mType; std::vector mInfo; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loaddoor.cpp b/components/esm/loaddoor.cpp index d3cc69bd4..b8ef029c5 100644 --- a/components/esm/loaddoor.cpp +++ b/components/esm/loaddoor.cpp @@ -1,15 +1,27 @@ #include "loaddoor.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Door::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNOString("FNAM"); - script = esm.getHNOString("SCRI"); - openSound = esm.getHNOString("SNAM"); - closeSound = esm.getHNOString("ANAM"); + mModel = esm.getHNString("MODL"); + mName = esm.getHNOString("FNAM"); + mScript = esm.getHNOString("SCRI"); + mOpenSound = esm.getHNOString("SNAM"); + mCloseSound = esm.getHNOString("ANAM"); +} + +void Door::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNOCString("FNAM", mName); + esm.writeHNOCString("SCRI", mScript); + esm.writeHNOCString("SNAM", mOpenSound); + esm.writeHNOCString("ANAM", mCloseSound); } } diff --git a/components/esm/loaddoor.hpp b/components/esm/loaddoor.hpp index 2c0db4064..5c0af52e4 100644 --- a/components/esm/loaddoor.hpp +++ b/components/esm/loaddoor.hpp @@ -1,16 +1,20 @@ -#ifndef _ESM_DOOR_H -#define _ESM_DOOR_H +#ifndef OPENMW_ESM_DOOR_H +#define OPENMW_ESM_DOOR_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + struct Door { - std::string name, model, script, openSound, closeSound; + std::string mName, mModel, mScript, mOpenSound, mCloseSound; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadench.cpp b/components/esm/loadench.cpp index b2787492d..c4e278368 100644 --- a/components/esm/loadench.cpp +++ b/components/esm/loadench.cpp @@ -1,12 +1,21 @@ #include "loadench.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Enchantment::load(ESMReader &esm) { - esm.getHNT(data, "ENDT", 16); - effects.load(esm); + esm.getHNT(mData, "ENDT", 16); + mEffects.load(esm); +} + +void Enchantment::save(ESMWriter &esm) +{ + esm.writeHNT("ENDT", mData, 16); + mEffects.save(esm); } } diff --git a/components/esm/loadench.hpp b/components/esm/loadench.hpp index 449589e25..d89549322 100644 --- a/components/esm/loadench.hpp +++ b/components/esm/loadench.hpp @@ -1,12 +1,14 @@ -#ifndef _ESM_ENCH_H -#define _ESM_ENCH_H +#ifndef OPENMW_ESM_ENCH_H +#define OPENMW_ESM_ENCH_H -#include "esm_reader.hpp" -#include "defs.hpp" +#include "effectlist.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Enchantments */ @@ -23,17 +25,18 @@ struct Enchantment struct ENDTstruct { - int type; - int cost; - int charge; - int autocalc; // Guessing this is 1 if we are supposed to auto + int mType; + int mCost; + int mCharge; + int mAutocalc; // Guessing this is 1 if we are supposed to auto // calculate }; - ENDTstruct data; - EffectList effects; + ENDTstruct mData; + EffectList mEffects; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadfact.cpp b/components/esm/loadfact.cpp index 346ad2a2e..6ea66977d 100644 --- a/components/esm/loadfact.cpp +++ b/components/esm/loadfact.cpp @@ -1,30 +1,53 @@ #include "loadfact.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Faction::load(ESMReader &esm) { - name = esm.getHNString("FNAM"); + mName = esm.getHNString("FNAM"); // Read rank names. These are optional. int i = 0; while (esm.isNextSub("RNAM") && i < 10) - ranks[i++] = esm.getHString(); + mRanks[i++] = esm.getHString(); // Main data struct - esm.getHNT(data, "FADT", 240); + esm.getHNT(mData, "FADT", 240); - if (data.isHidden > 1) + if (mData.mIsHidden > 1) esm.fail("Unknown flag!"); // Read faction response values while (esm.hasMoreSubs()) { Reaction r; - r.faction = esm.getHNString("ANAM"); - esm.getHNT(r.reaction, "INTV"); - reactions.push_back(r); + r.mFaction = esm.getHNString("ANAM"); + esm.getHNT(r.mReaction, "INTV"); + mReactions.push_back(r); + } +} +void Faction::save(ESMWriter &esm) +{ + esm.writeHNCString("FNAM", mName); + + for (int i = 0; i < 10; i++) + { + if (mRanks[i].empty()) + break; + + esm.writeHNString("RNAM", mRanks[i], 32); + } + + esm.writeHNT("FADT", mData, 240); + + for (std::vector::iterator it = mReactions.begin(); it != mReactions.end(); ++it) + { + esm.writeHNString("ANAM", it->mFaction); + esm.writeHNT("INTV", it->mReaction); } } diff --git a/components/esm/loadfact.hpp b/components/esm/loadfact.hpp index 85874aa78..49898b1cf 100644 --- a/components/esm/loadfact.hpp +++ b/components/esm/loadfact.hpp @@ -1,11 +1,15 @@ -#ifndef _ESM_FACT_H -#define _ESM_FACT_H +#ifndef OPENMW_ESM_FACT_H +#define OPENMW_ESM_FACT_H -#include "esm_reader.hpp" +#include +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Faction definitions */ @@ -13,46 +17,47 @@ namespace ESM // Requirements for each rank struct RankData { - int attribute1, attribute2; // Attribute level + int mAttribute1, mAttribute2; // Attribute level - int skill1, skill2; // Skill level (faction skills given in + int mSkill1, mSkill2; // Skill level (faction skills given in // skillID below.) You need one skill at // level 'skill1' and two skills at level // 'skill2' to advance to this rank. - int factReaction; // Reaction from faction members + int mFactReaction; // Reaction from faction members }; struct Faction { - std::string id, name; + std::string mId, mName; struct FADTstruct { // Which attributes we like - int attribute1, attribute2; + int mAttribute1, mAttribute2; - RankData rankData[10]; + RankData mRankData[10]; - int skillID[6]; // IDs of skills this faction require - int unknown; // Always -1? - int isHidden; // 1 - hidden from player + int mSkillID[6]; // IDs of skills this faction require + int mUnknown; // Always -1? + int mIsHidden; // 1 - hidden from player }; // 240 bytes - FADTstruct data; + FADTstruct mData; struct Reaction { - std::string faction; - int reaction; + std::string mFaction; + int mReaction; }; - std::vector reactions; + std::vector mReactions; // Name of faction ranks (may be empty for NPC factions) - std::string ranks[10]; + std::string mRanks[10]; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadglob.cpp b/components/esm/loadglob.cpp index c946b3fa0..39c07fb31 100644 --- a/components/esm/loadglob.cpp +++ b/components/esm/loadglob.cpp @@ -1,24 +1,47 @@ #include "loadglob.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Global::load(ESMReader &esm) { - VarType t; std::string tmp = esm.getHNString("FNAM"); if (tmp == "s") - t = VT_Short; + mType = VT_Short; else if (tmp == "l") - t = VT_Int; + mType = VT_Int; else if (tmp == "f") - t = VT_Float; + mType = VT_Float; else esm.fail("Illegal global variable type " + tmp); - type = t; // Note: Both floats and longs are represented as floats. - esm.getHNT(value, "FLTV"); + esm.getHNT(mValue, "FLTV"); +} + +void Global::save(ESMWriter &esm) +{ + switch(mType) + { + case VT_Short: + esm.writeHNString("FNAM", "s"); + break; + + case VT_Int: + esm.writeHNString("FNAM", "l"); + break; + + case VT_Float: + esm.writeHNString("FNAM", "f"); + break; + + default: + return; + } + esm.writeHNT("FLTV", mValue); } } diff --git a/components/esm/loadglob.hpp b/components/esm/loadglob.hpp index 5028679dd..b85af74bc 100644 --- a/components/esm/loadglob.hpp +++ b/components/esm/loadglob.hpp @@ -1,22 +1,25 @@ -#ifndef _ESM_GLOB_H -#define _ESM_GLOB_H +#ifndef OPENMW_ESM_GLOB_H +#define OPENMW_ESM_GLOB_H -#include "esm_reader.hpp" #include "defs.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Global script variables */ struct Global { - unsigned value; - VarType type; + unsigned mValue; + VarType mType; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadgmst.cpp b/components/esm/loadgmst.cpp index 491592bb9..dcc500125 100644 --- a/components/esm/loadgmst.cpp +++ b/components/esm/loadgmst.cpp @@ -2,7 +2,8 @@ #include -#include "defs.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" namespace ESM { @@ -11,15 +12,15 @@ namespace ESM /// working properly in its current state and I doubt it can be fixed without breaking other stuff. // Some handy macros -#define cI(s,x) { if(id == (s)) return (i == (x)); } -#define cF(s,x) { if(id == (s)) return (f == (x)); } -#define cS(s,x) { if(id == (s)) return (str == (x)); } +#define cI(s,x) { if(mId == (s)) return (mI == (x)); } +#define cF(s,x) { if(mId == (s)) return (mF == (x)); } +#define cS(s,x) { if(mId == (s)) return (mStr == (x)); } bool GameSetting::isDirtyTribunal() { /* - Here, id contains the game setting name, and we check the - setting for certain values. If it matches, this is a "dirty" + Here, mId contains the game setting name, and we check the + setting for certain values. If it matches, this is a "mDirty" entry. The correct entry (as defined in Tribunal and Bloodmoon esms) are given in the comments. Many of the values are correct, and are marked as 'same'. We still ignore them though, as they @@ -49,8 +50,8 @@ bool GameSetting::isDirtyTribunal() // or goods to bring his Profit to a positive value.' // [The difference here is "Profit Value" -> "Profit"] - // Strings that matches the id - cS("sEffectSummonFabricant", id);// 'Summon Fabricant' + // Strings that matches the mId + cS("sEffectSummonFabricant", mId);// 'Summon Fabricant' return false; } @@ -67,17 +68,17 @@ bool GameSetting::isDirtyBloodmoon() "You have been detected changing from a werewolf state."); // 'You have been detected as a known werewolf.' - // Strings that matches the id - cS("sMagicCreature01ID", id); // 'BM_wolf_grey_summon' - cS("sMagicCreature02ID", id); // 'BM_bear_black_summon' - cS("sMagicCreature03ID", id); // 'BM_wolf_bone_summon' - cS("sMagicCreature04ID", id); // same - cS("sMagicCreature05ID", id); // same - cS("sEffectSummonCreature01", id); // 'Calf Wolf' - cS("sEffectSummonCreature02", id); // 'Calf Bear' - cS("sEffectSummonCreature03", id); // 'Summon Bonewolf' - cS("sEffectSummonCreature04", id); // same - cS("sEffectSummonCreature05", id); // same + // Strings that matches the mId + cS("sMagicCreature01ID", mId); // 'BM_wolf_grey_summon' + cS("sMagicCreature02ID", mId); // 'BM_bear_black_summon' + cS("sMagicCreature03ID", mId); // 'BM_wolf_bone_summon' + cS("sMagicCreature04ID", mId); // same + cS("sMagicCreature05ID", mId); // same + cS("sEffectSummonCreature01", mId); // 'Calf Wolf' + cS("sEffectSummonCreature02", mId); // 'Calf Bear' + cS("sEffectSummonCreature03", mId); // 'Summon Bonewolf' + cS("sEffectSummonCreature04", mId); // same + cS("sEffectSummonCreature05", mId); // same // Integers cI("iWereWolfBounty", 10000); // 1000 @@ -133,14 +134,14 @@ bool GameSetting::isDirtyBloodmoon() void GameSetting::load(ESMReader &esm) { - assert(id != ""); + assert(mId != ""); - dirty = false; + mDirty = false; // We are apparently allowed to be empty if (!esm.hasMoreSubs()) { - type = VT_None; + mType = VT_None; return; } @@ -149,59 +150,69 @@ void GameSetting::load(ESMReader &esm) NAME n = esm.retSubName(); if (n == "STRV") { - str = esm.getHString(); - type = VT_String; + mStr = esm.getHString(); + mType = VT_String; } else if (n == "INTV") { - esm.getHT(i); - type = VT_Int; + esm.getHT(mI); + mType = VT_Int; } else if (n == "FLTV") { - esm.getHT(f); - type = VT_Float; + esm.getHT(mF); + mType = VT_Float; } else esm.fail("Unwanted subrecord type"); int spf = esm.getSpecial(); - // Check if this is one of the dirty values mentioned above. If it - // is, we set the dirty flag. This will ONLY work if you've set + // Check if this is one of the mDirty values mentioned above. If it + // is, we set the mDirty flag. This will ONLY work if you've set // the 'id' string correctly before calling load(). if ((spf != SF_Tribunal && isDirtyTribunal()) || (spf != SF_Bloodmoon && isDirtyBloodmoon())) - dirty = true; + mDirty = true; +} +void GameSetting::save(ESMWriter &esm) +{ + switch(mType) + { + case VT_String: esm.writeHNString("STRV", mStr); break; + case VT_Int: esm.writeHNT("INTV", mI); break; + case VT_Float: esm.writeHNT("FLTV", mF); break; + default: break; + } } int GameSetting::getInt() const { - switch (type) + switch (mType) { - case VT_Float: return static_cast (f); - case VT_Int: return i; - default: throw std::runtime_error ("GMST " + id + " is not of a numeric type"); + case VT_Float: return static_cast (mF); + case VT_Int: return mI; + default: throw std::runtime_error ("GMST " + mId + " is not of a numeric type"); } } float GameSetting::getFloat() const { - switch (type) + switch (mType) { - case VT_Float: return f; - case VT_Int: return i; - default: throw std::runtime_error ("GMST " + id + " is not of a numeric type"); + case VT_Float: return mF; + case VT_Int: return mI; + default: throw std::runtime_error ("GMST " + mId + " is not of a numeric type"); } } std::string GameSetting::getString() const { - if (type==VT_String) - return str; + if (mType==VT_String) + return mStr; - throw std::runtime_error ("GMST " + id + " is not a string"); + throw std::runtime_error ("GMST " + mId + " is not a string"); } } diff --git a/components/esm/loadgmst.hpp b/components/esm/loadgmst.hpp index df6003462..a3471598c 100644 --- a/components/esm/loadgmst.hpp +++ b/components/esm/loadgmst.hpp @@ -1,12 +1,16 @@ -#ifndef _ESM_GMST_H -#define _ESM_GMST_H +#ifndef OPENMW_ESM_GMST_H +#define OPENMW_ESM_GMST_H + +#include -#include "esm_reader.hpp" #include "defs.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Game setting, with automatic cleaning of "dirty" entries. * @@ -14,16 +18,15 @@ namespace ESM struct GameSetting { - std::string id; - + std::string mId; // One of these is used depending on the variable type - std::string str; - int i; - float f; - VarType type; + std::string mStr; + int mI; + float mF; + VarType mType; // Set to true if this is a 'dirty' entry which should be ignored - bool dirty; + bool mDirty; /* These functions check if this game setting is one of the "dirty" @@ -92,6 +95,8 @@ struct GameSetting std::string getString() const; ///< Throwns an exception if GMST is not of type string. + + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadinfo.cpp b/components/esm/loadinfo.cpp index 0f08b3c8a..f237cf780 100644 --- a/components/esm/loadinfo.cpp +++ b/components/esm/loadinfo.cpp @@ -1,17 +1,21 @@ #include "loadinfo.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void DialInfo::load(ESMReader &esm) { - id = esm.getHNString("INAM"); - prev = esm.getHNString("PNAM"); - next = esm.getHNString("NNAM"); + mId = esm.getHNString("INAM"); + mPrev = esm.getHNString("PNAM"); + mNext = esm.getHNString("NNAM"); // Not present if deleted - if (esm.isNextSub("DATA")) - esm.getHT(data, 12); + if (esm.isNextSub("DATA")) { + esm.getHT(mData, 12); + } // What follows is somewhat spaghetti-ish, but it's worth if for // an extra speedup. INFO is by far the most common record type. @@ -24,53 +28,53 @@ void DialInfo::load(ESMReader &esm) if (subName.val == REC_ONAM) { - actor = esm.getHString(); + mActor = esm.getHString(); if (esm.isEmptyOrGetName()) return; } if (subName.val == REC_RNAM) { - race = esm.getHString(); + mRace = esm.getHString(); if (esm.isEmptyOrGetName()) return; } if (subName.val == REC_CNAM) { - clas = esm.getHString(); + mClass = esm.getHString(); if (esm.isEmptyOrGetName()) return; } - factionLess = false; + mFactionLess = false; if (subName.val == REC_FNAM) { - npcFaction = esm.getHString(); - if (npcFaction == "FFFF") - factionLess = true; + mNpcFaction = esm.getHString(); + if (mNpcFaction == "FFFF") + mFactionLess = true; if (esm.isEmptyOrGetName()) return; } if (subName.val == REC_ANAM) { - cell = esm.getHString(); + mCell = esm.getHString(); if (esm.isEmptyOrGetName()) return; } if (subName.val == REC_DNAM) { - pcFaction = esm.getHString(); + mPcFaction = esm.getHString(); if (esm.isEmptyOrGetName()) return; } if (subName.val == REC_SNAM) { - sound = esm.getHString(); + mSound = esm.getHString(); if (esm.isEmptyOrGetName()) return; } if (subName.val == REC_NAME) { - response = esm.getHString(); + mResponse = esm.getHString(); if (esm.isEmptyOrGetName()) return; } @@ -79,25 +83,25 @@ void DialInfo::load(ESMReader &esm) { SelectStruct ss; - ss.selectRule = esm.getHString(); + ss.mSelectRule = esm.getHString(); esm.isEmptyOrGetName(); if (subName.val == REC_INTV) { - ss.type = VT_Int; - esm.getHT(ss.i); + ss.mType = VT_Int; + esm.getHT(ss.mI); } else if (subName.val == REC_FLTV) { - ss.type = VT_Float; - esm.getHT(ss.f); + ss.mType = VT_Float; + esm.getHT(ss.mF); } else esm.fail( "INFO.SCVR must precede INTV or FLTV, not " + subName.toString()); - selects.push_back(ss); + mSelects.push_back(ss); if (esm.isEmptyOrGetName()) return; @@ -105,29 +109,67 @@ void DialInfo::load(ESMReader &esm) if (subName.val == REC_BNAM) { - resultScript = esm.getHString(); + mResultScript = esm.getHString(); if (esm.isEmptyOrGetName()) return; } - questStatus = QS_None; + mQuestStatus = QS_None; if (subName.val == REC_QSTN) - questStatus = QS_Name; + mQuestStatus = QS_Name; else if (subName.val == REC_QSTF) - questStatus = QS_Finished; + mQuestStatus = QS_Finished; else if (subName.val == REC_QSTR) - questStatus = QS_Restart; + mQuestStatus = QS_Restart; else if (subName.val == REC_DELE) - questStatus = QS_Deleted; + mQuestStatus = QS_Deleted; else esm.fail( "Don't know what to do with " + subName.toString() - + " in INFO " + id); + + " in INFO " + mId); - if (questStatus != QS_None) + if (mQuestStatus != QS_None) // Skip rest of record esm.skipRecord(); } +void DialInfo::save(ESMWriter &esm) +{ + esm.writeHNCString("INAM", mId); + esm.writeHNCString("PNAM", mPrev); + esm.writeHNCString("NNAM", mNext); + esm.writeHNT("DATA", mData, 12); + esm.writeHNOCString("ONAM", mActor); + esm.writeHNOCString("RNAM", mRace); + esm.writeHNOCString("CNAM", mClass); + esm.writeHNOCString("FNAM", mNpcFaction); + esm.writeHNOCString("ANAM", mCell); + esm.writeHNOCString("DNAM", mPcFaction); + esm.writeHNOCString("SNAM", mSound); + esm.writeHNOString("NAME", mResponse); + + for (std::vector::iterator it = mSelects.begin(); it != mSelects.end(); ++it) + { + esm.writeHNString("SCVR", it->mSelectRule); + switch(it->mType) + { + case VT_Int: esm.writeHNT("INTV", it->mI); break; + case VT_Float: esm.writeHNT("FLTV", it->mF); break; + default: break; + } + } + + esm.writeHNOString("BNAM", mResultScript); + + switch(mQuestStatus) + { + case QS_Name: esm.writeHNT("QSTN",'\1'); break; + case QS_Finished: esm.writeHNT("QSTF", '\1'); break; + case QS_Restart: esm.writeHNT("QSTR", '\1'); break; + case QS_Deleted: esm.writeHNT("DELE", '\1'); break; + default: break; + } +} + } diff --git a/components/esm/loadinfo.hpp b/components/esm/loadinfo.hpp index c47af341e..f04fe862e 100644 --- a/components/esm/loadinfo.hpp +++ b/components/esm/loadinfo.hpp @@ -1,12 +1,17 @@ -#ifndef _ESM_INFO_H -#define _ESM_INFO_H +#ifndef OPENMW_ESM_INFO_H +#define OPENMW_ESM_INFO_H + +#include +#include -#include "esm_reader.hpp" #include "defs.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + // NOT DONE /* @@ -25,22 +30,22 @@ struct DialInfo struct DATAstruct { - int unknown1; - int disposition; - char rank; // Rank of NPC - char gender; // See Gender enum - char PCrank; // Player rank - char unknown2; + int mUnknown1; + int mDisposition; + char mRank; // Rank of NPC + char mGender; // See Gender enum + char mPCrank; // Player rank + char mUnknown2; }; // 12 bytes - DATAstruct data; + DATAstruct mData; // The rules for whether or not we will select this dialog item. struct SelectStruct { - std::string selectRule; // This has a complicated format - float f; // Only one of 'f' or 'i' is used - int i; - VarType type; + std::string mSelectRule; // This has a complicated format + float mF; // Only one of 'f' or 'i' is used + int mI; + VarType mType; }; // Journal quest indices (introduced with the quest system in Tribunal) @@ -55,26 +60,26 @@ struct DialInfo // Rules for when to include this item in the final list of options // visible to the player. - std::vector selects; + std::vector mSelects; // Id of this, previous and next INFO items - std::string id, prev, next, + std::string mId, mPrev, mNext; // Various references used in determining when to select this item. - actor, race, clas, npcFaction, pcFaction, cell, + std::string mActor, mRace, mClass, mNpcFaction, mPcFaction, mCell; - // Sound and text associated with this item - sound, response, + // Sound and text associated with this item + std::string mSound, mResponse; - // Result script (uncomiled) to run whenever this dialog item is - // selected - resultScript; + // Result script (uncomiled) to run whenever this dialog item is + // selected + std::string mResultScript; // ONLY include this item the NPC is not part of any faction. - bool factionLess; + bool mFactionLess; // Status of this quest item - QuestStatus questStatus; + QuestStatus mQuestStatus; // Hexadecimal versions of the various subrecord names. enum SubNames @@ -98,6 +103,7 @@ struct DialInfo }; void load(ESMReader &esm); + void save(ESMWriter &esm); }; /* diff --git a/components/esm/loadingr.cpp b/components/esm/loadingr.cpp index ddc9de0d5..4312dc05b 100644 --- a/components/esm/loadingr.cpp +++ b/components/esm/loadingr.cpp @@ -1,29 +1,49 @@ #include "loadingr.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { -void Ingredient::load(ESMReader &esm, const std::string& id) +void Ingredient::load(ESMReader &esm) { - mId = id; - - model = esm.getHNString("MODL"); - name = esm.getHNString("FNAM"); - esm.getHNT(data, "IRDT", 56); - script = esm.getHNOString("SCRI"); - icon = esm.getHNOString("ITEX"); - + mModel = esm.getHNString("MODL"); + mName = esm.getHNString("FNAM"); + esm.getHNT(mData, "IRDT", 56); + mScript = esm.getHNOString("SCRI"); + mIcon = esm.getHNOString("ITEX"); // horrible hack to fix broken data in records for (int i=0; i<4; ++i) { - if (data.effectID[i]!=85 && data.effectID[i]!=22 && data.effectID[i]!=17 && data.effectID[i]!=79 && - data.effectID[i]!=74) - data.attributes[i] = -1; - - if (data.effectID[i]!=89 && data.effectID[i]!=26 && data.effectID[i]!=21 && data.effectID[i]!=83 && - data.effectID[i]!=78) - data.skills[i] = -1; + if (mData.mEffectID[i] != 85 && + mData.mEffectID[i] != 22 && + mData.mEffectID[i] != 17 && + mData.mEffectID[i] != 79 && + mData.mEffectID[i] != 74) + { + mData.mAttributes[i] = -1; + } + + // is this relevant in cycle from 0 to 4? + if (mData.mEffectID[i] != 89 && + mData.mEffectID[i] != 26 && + mData.mEffectID[i] != 21 && + mData.mEffectID[i] != 83 && + mData.mEffectID[i] != 78) + { + mData.mSkills[i] = -1; + } } } +void Ingredient::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNCString("FNAM", mName); + esm.writeHNT("IRDT", mData, 56); + esm.writeHNOCString("SCRI", mScript); + esm.writeHNOCString("ITEX", mIcon); +} + } diff --git a/components/esm/loadingr.hpp b/components/esm/loadingr.hpp index 5c1c3bd75..cd63cf39a 100644 --- a/components/esm/loadingr.hpp +++ b/components/esm/loadingr.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_INGR_H -#define _ESM_INGR_H +#ifndef OPENMW_ESM_INGR_H +#define OPENMW_ESM_INGR_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Alchemy ingredient */ @@ -14,19 +17,18 @@ struct Ingredient { struct IRDTstruct { - float weight; - int value; - int effectID[4]; // Effect, 0 or -1 means none - int skills[4]; // SkillEnum related to effect - int attributes[4]; // Attribute related to effect + float mWeight; + int mValue; + int mEffectID[4]; // Effect, 0 or -1 means none + int mSkills[4]; // SkillEnum related to effect + int mAttributes[4]; // Attribute related to effect }; - IRDTstruct data; - std::string name, model, icon, script; + IRDTstruct mData; + std::string mId, mName, mModel, mIcon, mScript; - std::string mId; - - void load(ESMReader &esm, const std::string& id); + void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadland.cpp b/components/esm/loadland.cpp index 05cadae7f..e1af0ee7c 100644 --- a/components/esm/loadland.cpp +++ b/components/esm/loadland.cpp @@ -1,25 +1,83 @@ #include "loadland.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { +void Land::LandData::save(ESMWriter &esm) +{ + if (mDataTypes & Land::DATA_VNML) { + esm.writeHNT("VNML", mNormals, sizeof(VNML)); + } + if (mDataTypes & Land::DATA_VHGT) { + static VHGT offsets; + offsets.mHeightOffset = mHeights[0] / HEIGHT_SCALE; + offsets.mUnk1 = mUnk1; + offsets.mUnk2 = mUnk2; + + float prevY = mHeights[0], prevX; + int number = 0; // avoid multiplication + for (int i = 0; i < LAND_SIZE; ++i) { + float diff = (mHeights[number] - prevY) / HEIGHT_SCALE; + offsets.mHeightData[number] = + (diff >= 0) ? (int8_t) (diff + 0.5) : (int8_t) (diff - 0.5); + + prevX = prevY = mHeights[number]; + ++number; + + for (int j = 1; j < LAND_SIZE; ++j) { + diff = (mHeights[number] - prevX) / HEIGHT_SCALE; + offsets.mHeightData[number] = + (diff >= 0) ? (int8_t) (diff + 0.5) : (int8_t) (diff - 0.5); + + prevX = mHeights[number]; + ++number; + } + } + esm.writeHNT("VHGT", offsets, sizeof(VHGT)); + } + if (mDataTypes & Land::DATA_WNAM) { + esm.writeHNT("WNAM", mWnam, 81); + } + if (mDataTypes & Land::DATA_VCLR) { + esm.writeHNT("VCLR", mColours, 3*LAND_NUM_VERTS); + } + if (mDataTypes & Land::DATA_VTEX) { + static uint16_t vtex[LAND_NUM_TEXTURES]; + transposeTextureData(mTextures, vtex); + esm.writeHNT("VTEX", vtex, sizeof(vtex)); + } +} + +void Land::LandData::transposeTextureData(uint16_t *in, uint16_t *out) +{ + int readPos = 0; //bit ugly, but it works + for ( int y1 = 0; y1 < 4; y1++ ) + for ( int x1 = 0; x1 < 4; x1++ ) + for ( int y2 = 0; y2 < 4; y2++) + for ( int x2 = 0; x2 < 4; x2++ ) + out[(y1*4+y2)*16+(x1*4+x2)] = in[readPos++]; +} + Land::Land() - : flags(0) - , X(0) - , Y(0) + : mFlags(0) + , mX(0) + , mY(0) , mEsm(NULL) - , hasData(false) - , dataLoaded(false) - , landData(NULL) +// , hasData(false) + , mDataTypes(0) + , mDataLoaded(false) + , mLandData(NULL) { } Land::~Land() { - delete landData; + delete mLandData; } - void Land::load(ESMReader &esm) { mEsm = &esm; @@ -27,129 +85,159 @@ void Land::load(ESMReader &esm) // Get the grid location esm.getSubNameIs("INTV"); esm.getSubHeaderIs(8); - esm.getT(X); - esm.getT(Y); + esm.getT(mX); + esm.getT(mY); - esm.getHNT(flags, "DATA"); + esm.getHNT(mFlags, "DATA"); // Store the file position - context = esm.getContext(); + mContext = esm.getContext(); - hasData = false; - int cnt = 0; + mHasData = false; // Skip these here. Load the actual data when the cell is loaded. if (esm.isNextSub("VNML")) { esm.skipHSubSize(12675); - cnt++; + mDataTypes |= DATA_VNML; } if (esm.isNextSub("VHGT")) { esm.skipHSubSize(4232); - cnt++; + mDataTypes |= DATA_VHGT; } if (esm.isNextSub("WNAM")) { esm.skipHSubSize(81); + mDataTypes |= DATA_WNAM; } if (esm.isNextSub("VCLR")) { esm.skipHSubSize(12675); + mDataTypes |= DATA_VCLR; } if (esm.isNextSub("VTEX")) { esm.skipHSubSize(512); - cnt++; + mDataTypes |= DATA_VTEX; } // We need all three of VNML, VHGT and VTEX in order to use the - // landscape. - hasData = (cnt == 3); + // landscape. (Though Morrowind seems to accept terrain without VTEX/VCLR entries) + mHasData = mDataTypes & (DATA_VNML|DATA_VHGT|DATA_WNAM); - dataLoaded = false; - landData = NULL; + mDataLoaded = 0; + mLandData = NULL; } -void Land::loadData() +void Land::save(ESMWriter &esm) { - if (dataLoaded) - { + esm.startSubRecord("INTV"); + esm.writeT(mX); + esm.writeT(mY); + esm.endRecord("INTV"); + + esm.writeHNT("DATA", mFlags); + + // TODO: Land! + bool wasLoaded = mDataLoaded; + if (mDataTypes) { + // Try to load all available data before saving + loadData(mDataTypes); + } + if (mDataLoaded) + mLandData->save(esm); + + if (!wasLoaded) + unloadData(); // Don't need to keep the data loaded if it wasn't already +} + +/// \todo remove memory allocation when only defaults needed +void Land::loadData(int flags) +{ + // Try to load only available data + int actual = flags & mDataTypes; + // Return if all required data is loaded + if (flags == 0 || (actual != 0 && (mDataLoaded & actual) == actual)) { return; } + // Create storage if nothing is loaded + if (mLandData == NULL) { + mLandData = new LandData; + mLandData->mDataTypes = mDataTypes; + } + mEsm->restoreContext(mContext); - landData = new LandData; + memset(mLandData->mNormals, 0, LAND_NUM_VERTS * 3); - if (hasData) - { - mEsm->restoreContext(context); + if (mEsm->isNextSub("VNML")) { + condLoad(actual, DATA_VNML, mLandData->mNormals, sizeof(VNML)); + } - //mEsm->getHNExact(landData->normals, sizeof(VNML), "VNML"); - if (mEsm->isNextSub("VNML")) - { - mEsm->skipHSubSize(12675); - } + if (mEsm->isNextSub("VHGT")) { + static VHGT vhgt; + if (condLoad(actual, DATA_VHGT, &vhgt, sizeof(vhgt))) { + float rowOffset = vhgt.mHeightOffset; + for (int y = 0; y < LAND_SIZE; y++) { + rowOffset += vhgt.mHeightData[y * LAND_SIZE]; - VHGT rawHeights; + mLandData->mHeights[y * LAND_SIZE] = rowOffset * HEIGHT_SCALE; - mEsm->getHNExact(&rawHeights, sizeof(VHGT), "VHGT"); - int currentHeightOffset = rawHeights.heightOffset; - for (int y = 0; y < LAND_SIZE; y++) - { - currentHeightOffset += rawHeights.heightData[y * LAND_SIZE]; - landData->heights[y * LAND_SIZE] = currentHeightOffset * HEIGHT_SCALE; - - int tempOffset = currentHeightOffset; - for (int x = 1; x < LAND_SIZE; x++) - { - tempOffset += rawHeights.heightData[y * LAND_SIZE + x]; - landData->heights[x + y * LAND_SIZE] = tempOffset * HEIGHT_SCALE; + float colOffset = rowOffset; + for (int x = 1; x < LAND_SIZE; x++) { + colOffset += vhgt.mHeightData[y * LAND_SIZE + x]; + mLandData->mHeights[x + y * LAND_SIZE] = colOffset * HEIGHT_SCALE; + } } + mLandData->mUnk1 = vhgt.mUnk1; + mLandData->mUnk2 = vhgt.mUnk2; } - - if (mEsm->isNextSub("WNAM")) - { - mEsm->skipHSubSize(81); - } - if (mEsm->isNextSub("VCLR")) - { - landData->usingColours = true; - mEsm->getHExact(&landData->colours, 3*LAND_NUM_VERTS); - }else{ - landData->usingColours = false; - } - //TODO fix magic numbers - uint16_t vtex[512]; - mEsm->getHNExact(&vtex, 512, "VTEX"); - - int readPos = 0; //bit ugly, but it works - for ( int y1 = 0; y1 < 4; y1++ ) - for ( int x1 = 0; x1 < 4; x1++ ) - for ( int y2 = 0; y2 < 4; y2++) - for ( int x2 = 0; x2 < 4; x2++ ) - landData->textures[(y1*4+y2)*16+(x1*4+x2)] = vtex[readPos++]; - } - else - { - landData->usingColours = false; - memset(&landData->textures, 0, 512 * sizeof(uint16_t)); - for (int i = 0; i < LAND_NUM_VERTS; i++) - { - landData->heights[i] = -256.0f * HEIGHT_SCALE; + } else if ((flags & DATA_VHGT) && (mDataLoaded & DATA_VHGT) == 0) { + for (int i = 0; i < LAND_NUM_VERTS; ++i) { + mLandData->mHeights[i] = -256.0f * HEIGHT_SCALE; } + mDataLoaded |= DATA_VHGT; } - dataLoaded = true; + if (mEsm->isNextSub("WNAM")) { + condLoad(actual, DATA_WNAM, mLandData->mWnam, 81); + } + if (mEsm->isNextSub("VCLR")) { + mLandData->mUsingColours = true; + condLoad(actual, DATA_VCLR, mLandData->mColours, 3 * LAND_NUM_VERTS); + } else { + mLandData->mUsingColours = false; + } + if (mEsm->isNextSub("VTEX")) { + static uint16_t vtex[LAND_NUM_TEXTURES]; + if (condLoad(actual, DATA_VTEX, vtex, sizeof(vtex))) { + LandData::transposeTextureData(vtex, mLandData->mTextures); + } + } else if ((flags & DATA_VTEX) && (mDataLoaded & DATA_VTEX) == 0) { + memset(mLandData->mTextures, 0, sizeof(mLandData->mTextures)); + mDataLoaded |= DATA_VTEX; + } } void Land::unloadData() { - if (dataLoaded) + if (mDataLoaded) { - delete landData; - landData = NULL; - dataLoaded = false; + delete mLandData; + mLandData = NULL; + mDataLoaded = 0; } } +bool Land::condLoad(int flags, int dataFlag, void *ptr, unsigned int size) +{ + if ((mDataLoaded & dataFlag) == 0 && (flags & dataFlag) != 0) { + mEsm->getHExact(ptr, size); + mDataLoaded |= dataFlag; + return true; + } + mEsm->skipHSubSize(size); + return false; +} + } diff --git a/components/esm/loadland.hpp b/components/esm/loadland.hpp index ebc314a28..5bc439c96 100644 --- a/components/esm/loadland.hpp +++ b/components/esm/loadland.hpp @@ -1,10 +1,16 @@ -#ifndef _ESM_LAND_H -#define _ESM_LAND_H +#ifndef OPENMW_ESM_LAND_H +#define OPENMW_ESM_LAND_H -#include "esm_reader.hpp" +#include + +#include "esmcommon.hpp" namespace ESM { + +class ESMReader; +class ESMWriter; + /* * Landscape data. */ @@ -14,18 +20,27 @@ struct Land Land(); ~Land(); - int flags; // Only first four bits seem to be used, don't know what + int mFlags; // Only first four bits seem to be used, don't know what // they mean. - int X, Y; // Map coordinates. + int mX, mY; // Map coordinates. // File context. This allows the ESM reader to be 'reset' to this // location later when we are ready to load the full data set. ESMReader* mEsm; - ESM_Context context; + ESM_Context mContext; - bool hasData; + bool mHasData; + int mDataTypes; + int mDataLoaded; - bool dataLoaded; + enum + { + DATA_VNML = 1, + DATA_VHGT = 2, + DATA_WNAM = 4, + DATA_VCLR = 8, + DATA_VTEX = 16 + }; // number of vertices per side static const int LAND_SIZE = 65; @@ -47,10 +62,10 @@ struct Land #pragma pack(push,1) struct VHGT { - float heightOffset; - int8_t heightData[LAND_NUM_VERTS]; - short unknown1; - char unknown2; + float mHeightOffset; + int8_t mHeightData[LAND_NUM_VERTS]; + short mUnk1; + char mUnk2; }; #pragma pack(pop) @@ -58,32 +73,52 @@ struct Land struct LandData { - float heightOffset; - float heights[LAND_NUM_VERTS]; - //float normals[LAND_NUM_VERTS * 3]; - uint16_t textures[LAND_NUM_TEXTURES]; + float mHeightOffset; + float mHeights[LAND_NUM_VERTS]; + VNML mNormals; + uint16_t mTextures[LAND_NUM_TEXTURES]; - bool usingColours; - char colours[3 * LAND_NUM_VERTS]; + bool mUsingColours; + char mColours[3 * LAND_NUM_VERTS]; + int mDataTypes; + + uint8_t mWnam[81]; + short mUnk1; + uint8_t mUnk2; + + void save(ESMWriter &esm); + static void transposeTextureData(uint16_t *in, uint16_t *out); }; - LandData *landData; + LandData *mLandData; void load(ESMReader &esm); + void save(ESMWriter &esm); /** * Actually loads data */ - void loadData(); + void loadData(int flags); /** * Frees memory allocated for land data */ void unloadData(); + /// Check if given data type is loaded + /// \todo reimplement this + bool isDataLoaded(int flags) { + return (mDataLoaded & flags) == flags; + } + private: Land(const Land& land); Land& operator=(const Land& land); + + /// Loads data and marks it as loaded + /// \return true if data is actually loaded from file, false otherwise + /// including the case when data is already loaded + bool condLoad(int flags, int dataFlag, void *ptr, unsigned int size); }; } diff --git a/components/esm/loadlevlist.cpp b/components/esm/loadlevlist.cpp index d1bff7972..4cba1119b 100644 --- a/components/esm/loadlevlist.cpp +++ b/components/esm/loadlevlist.cpp @@ -1,18 +1,21 @@ #include "loadlevlist.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void LeveledListBase::load(ESMReader &esm) { - esm.getHNT(flags, "DATA"); - esm.getHNT(chanceNone, "NNAM"); + esm.getHNT(mFlags, "DATA"); + esm.getHNT(mChanceNone, "NNAM"); if (esm.isNextSub("INDX")) { int len; esm.getHT(len); - list.resize(len); + mList.resize(len); } else return; @@ -23,11 +26,23 @@ void LeveledListBase::load(ESMReader &esm) // items. Also, some times we don't want to merge lists, just // overwrite. Figure out a way to give the user this option. - for (size_t i = 0; i < list.size(); i++) + for (size_t i = 0; i < mList.size(); i++) { - LevelItem &li = list[i]; - li.id = esm.getHNString(recName); - esm.getHNT(li.level, "INTV"); + LevelItem &li = mList[i]; + li.mId = esm.getHNString(mRecName); + esm.getHNT(li.mLevel, "INTV"); + } +} +void LeveledListBase::save(ESMWriter &esm) +{ + esm.writeHNT("DATA", mFlags); + esm.writeHNT("NNAM", mChanceNone); + esm.writeHNT("INDX", mList.size()); + + for (std::vector::iterator it = mList.begin(); it != mList.end(); ++it) + { + esm.writeHNCString(mRecName, it->mId); + esm.writeHNT("INTV", it->mLevel); } } diff --git a/components/esm/loadlevlist.hpp b/components/esm/loadlevlist.hpp index 4affce539..72b4af92f 100644 --- a/components/esm/loadlevlist.hpp +++ b/components/esm/loadlevlist.hpp @@ -1,11 +1,15 @@ -#ifndef _ESM_LEVLISTS_H -#define _ESM_LEVLISTS_H +#ifndef OPENMW_ESM_LEVLISTS_H +#define OPENMW_ESM_LEVLISTS_H -#include "esm_reader.hpp" +#include +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Leveled lists. Since these have identical layout, I only bothered * to implement it once. @@ -27,29 +31,30 @@ struct LeveledListBase }; // (used when a container has more // than one instance of one leveled // list.) - int flags; - unsigned char chanceNone; // Chance that none are selected (0-255?) + int mFlags; + unsigned char mChanceNone; // Chance that none are selected (0-255?) // Record name used to read references. Must be set before load() is // called. - const char *recName; + const char *mRecName; struct LevelItem { - std::string id; - short level; + std::string mId; + short mLevel; }; - std::vector list; + std::vector mList; void load(ESMReader &esm); + void save(ESMWriter &esm); }; struct CreatureLevList: LeveledListBase { CreatureLevList() { - recName = "CNAM"; + mRecName = "CNAM"; } }; @@ -57,7 +62,7 @@ struct ItemLevList: LeveledListBase { ItemLevList() { - recName = "INAM"; + mRecName = "INAM"; } }; diff --git a/components/esm/loadligh.cpp b/components/esm/loadligh.cpp index 721a818f7..48a56db3c 100644 --- a/components/esm/loadligh.cpp +++ b/components/esm/loadligh.cpp @@ -1,17 +1,29 @@ #include "loadligh.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Light::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNOString("FNAM"); - icon = esm.getHNOString("ITEX"); - assert(sizeof(data) == 24); - esm.getHNT(data, "LHDT", 24); - script = esm.getHNOString("SCRI"); - sound = esm.getHNOString("SNAM"); + mModel = esm.getHNString("MODL"); + mName = esm.getHNOString("FNAM"); + mIcon = esm.getHNOString("ITEX"); + assert(sizeof(mData) == 24); + esm.getHNT(mData, "LHDT", 24); + mScript = esm.getHNOString("SCRI"); + mSound = esm.getHNOString("SNAM"); +} +void Light::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNOCString("FNAM", mName); + esm.writeHNOCString("ITEX", mIcon); + esm.writeHNT("LHDT", mData, 24); + esm.writeHNOCString("SCRI", mScript); + esm.writeHNOCString("SNAM", mSound); } } diff --git a/components/esm/loadligh.hpp b/components/esm/loadligh.hpp index 9e7934b15..c425af6b3 100644 --- a/components/esm/loadligh.hpp +++ b/components/esm/loadligh.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_LIGH_H -#define _ESM_LIGH_H +#ifndef OPENMW_ESM_LIGH_H +#define OPENMW_ESM_LIGH_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Lights. Includes static light sources and also carryable candles * and torches. @@ -15,32 +18,33 @@ struct Light { enum Flags { - Dynamic = 0x001, - Carry = 0x002, // Can be carried - Negative = 0x004, // Negative light - i.e. darkness - Flicker = 0x008, - Fire = 0x010, - OffDefault = 0x020, // Off by default + Dynamic = 0x001, + Carry = 0x002, // Can be carried + Negative = 0x004, // Negative light - i.e. darkness + Flicker = 0x008, + Fire = 0x010, + OffDefault = 0x020, // Off by default FlickerSlow = 0x040, - Pulse = 0x080, - PulseSlow = 0x100 + Pulse = 0x080, + PulseSlow = 0x100 }; struct LHDTstruct { - float weight; - int value; - int time; // Duration - int radius; - int color; // 4-byte rgba value - int flags; + float mWeight; + int mValue; + int mTime; // Duration + int mRadius; + int mColor; // 4-byte rgba value + int mFlags; }; // Size = 24 bytes - LHDTstruct data; + LHDTstruct mData; - std::string sound, script, model, icon, name; + std::string mSound, mScript, mModel, mIcon, mName; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadlocks.cpp b/components/esm/loadlocks.cpp index 79e882d94..057da595e 100644 --- a/components/esm/loadlocks.cpp +++ b/components/esm/loadlocks.cpp @@ -1,30 +1,65 @@ #include "loadlocks.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Tool::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNString("FNAM"); + mModel = esm.getHNString("MODL"); + mName = esm.getHNString("FNAM"); esm.getSubName(); NAME n = esm.retSubName(); // The data name varies, RIDT for repair items, LKDT for lock // picks, PBDT for probes - esm.getHT(data, 16); + esm.getHT(mData, 16); if (n == "RIDT") { + mType = Type_Repair; // Swap t.data.quality and t.data.uses for repair items (sigh) - float tmp = *((float*) &data.uses); - data.uses = *((int*) &data.quality); - data.quality = tmp; + float tmp = *((float*) &mData.mUses); + mData.mUses = *((int*) &mData.mQuality); + mData.mQuality = tmp; + } + else if (n == "LKDT") + mType = Type_Pick; + else if (n == "PBDT") + mType = Type_Probe; + + mScript = esm.getHNOString("SCRI"); + mIcon = esm.getHNOString("ITEX"); +} + +void Tool::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNCString("FNAM", mName); + + std::string typeName; + switch(mType) + { + case Type_Repair: typeName = "RIDT"; break; + case Type_Pick: typeName = "LKDT"; break; + case Type_Probe: typeName = "PBDT"; break; + } + + Data write = mData; + if (mType == Type_Repair) + { + float tmp = *((float*) &write.mUses); + write.mUses = *((int*) &write.mQuality); + write.mQuality = tmp; } - script = esm.getHNOString("SCRI"); - icon = esm.getHNOString("ITEX"); + esm.writeHNT(typeName, write, 16); + esm.writeHNOString("SCRI", mScript); + esm.writeHNOCString("ITEX", mIcon); } + } diff --git a/components/esm/loadlocks.hpp b/components/esm/loadlocks.hpp index a1e537a4c..72d375cbb 100644 --- a/components/esm/loadlocks.hpp +++ b/components/esm/loadlocks.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_LOCKS_H -#define _ESM_LOCKS_H +#ifndef OPENMW_ESM_LOCKS_H +#define OPENMW_ESM_LOCKS_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * This file covers lockpicks (LOCK), probes (PROB) and armor repair * items (REPA). These have nearly identical data structures. @@ -13,31 +16,40 @@ namespace ESM struct Tool { + enum Type + { + Type_Pick, + Type_Probe, + Type_Repair + }; + struct Data { - float weight; - int value; + float mWeight; + int mValue; - float quality; // And when I say nearly identical structure, I - int uses; // mean perfectly identical except that these two + float mQuality; // And when I say nearly identical structure, I + int mUses; // mean perfectly identical except that these two // variables are swaped for repair items. Don't ask // me why. }; // Size = 16 - Data data; - std::string name, model, icon, script; + Data mData; + Type mType; + std::string mName, mModel, mIcon, mScript; void load(ESMReader &esm); + void save(ESMWriter &esm); }; struct Probe: Tool { - + Probe() { mType = Type_Probe; } }; struct Repair: Tool { - + Repair() { mType = Type_Repair; } }; } diff --git a/components/esm/loadltex.cpp b/components/esm/loadltex.cpp index 08b1cf6dc..e523e9fa7 100644 --- a/components/esm/loadltex.cpp +++ b/components/esm/loadltex.cpp @@ -1,12 +1,20 @@ #include "loadltex.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void LandTexture::load(ESMReader &esm) { - esm.getHNT(index, "INTV"); - texture = esm.getHNString("DATA"); + esm.getHNT(mIndex, "INTV"); + mTexture = esm.getHNString("DATA"); +} +void LandTexture::save(ESMWriter &esm) +{ + esm.writeHNT("INTV", mIndex); + esm.writeHNCString("DATA", mTexture); } } diff --git a/components/esm/loadltex.hpp b/components/esm/loadltex.hpp index fa4cac10a..6e6d987d4 100644 --- a/components/esm/loadltex.hpp +++ b/components/esm/loadltex.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_LTEX_H -#define _ESM_LTEX_H +#ifndef OPENMW_ESM_LTEX_H +#define OPENMW_ESM_LTEX_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Texture used for texturing landscape. * @@ -24,10 +27,11 @@ namespace ESM struct LandTexture { - std::string id, texture; - int index; + std::string mId, mTexture; + int mIndex; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadmgef.cpp b/components/esm/loadmgef.cpp index 9aa6b26e3..be588fbb0 100644 --- a/components/esm/loadmgef.cpp +++ b/components/esm/loadmgef.cpp @@ -1,5 +1,8 @@ #include "loadmgef.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace { const int NumberOfHardcodedFlags = 143; @@ -30,27 +33,50 @@ namespace ESM void MagicEffect::load(ESMReader &esm) { - esm.getHNT(index, "INDX"); + esm.getHNT(mIndex, "INDX"); - esm.getHNT(data, "MEDT", 36); - - if (index>=0 && index=0 && mIndex=0 && mIndex namespace ESM { +class ESMReader; +class ESMWriter; + struct MagicEffect { enum Flags @@ -19,21 +22,21 @@ struct MagicEffect struct MEDTstruct { - int school; // SpellSchool, see defs.hpp - float baseCost; - int flags; + int mSchool; // SpellSchool, see defs.hpp + float mBaseCost; + int mFlags; // Properties of the fired magic 'ball' I think - int red, blue, green; - float speed, size, sizeCap; + int mRed, mBlue, mGreen; + float mSpeed, mSize, mSizeCap; }; // 36 bytes - MEDTstruct data; + MEDTstruct mData; - std::string icon, particle, // Textures - casting, hit, area, // Statics - bolt, // Weapon - castSound, boltSound, hitSound, areaSound, // Sounds - description; + std::string mIcon, mParticle; // Textures + std::string mCasting, mHit, mArea; // Statics + std::string mBolt; // Weapon + std::string mCastSound, mBoltSound, mHitSound, mAreaSound; // Sounds + std::string mDescription; // Index of this magical effect. Corresponds to one of the // hard-coded effects in the original engine: @@ -44,9 +47,10 @@ struct MagicEffect // there. They can be redefined in mods by setting the name in GMST // sEffectSummonCreature04/05 creature id in // sMagicCreature04ID/05ID. - int index; + int mIndex; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadmisc.cpp b/components/esm/loadmisc.cpp index 0206661c4..3a5dded15 100644 --- a/components/esm/loadmisc.cpp +++ b/components/esm/loadmisc.cpp @@ -1,15 +1,26 @@ #include "loadmisc.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Miscellaneous::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNOString("FNAM"); - esm.getHNT(data, "MCDT", 12); - script = esm.getHNOString("SCRI"); - icon = esm.getHNOString("ITEX"); + mModel = esm.getHNString("MODL"); + mName = esm.getHNOString("FNAM"); + esm.getHNT(mData, "MCDT", 12); + mScript = esm.getHNOString("SCRI"); + mIcon = esm.getHNOString("ITEX"); +} +void Miscellaneous::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNOCString("FNAM", mName); + esm.writeHNT("MCDT", mData, 12); + esm.writeHNOCString("SCRI", mScript); + esm.writeHNOCString("ITEX", mIcon); } } diff --git a/components/esm/loadmisc.hpp b/components/esm/loadmisc.hpp index 7e151f797..1a34e6504 100644 --- a/components/esm/loadmisc.hpp +++ b/components/esm/loadmisc.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_MISC_H -#define _ESM_MISC_H +#ifndef OPENMW_ESM_MISC_H +#define OPENMW_ESM_MISC_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Misc inventory items, basically things that have no use but can be * carried, bought and sold. It also includes keys. @@ -15,17 +18,18 @@ struct Miscellaneous { struct MCDTstruct { - float weight; - int value; - int isKey; // There are many keys in Morrowind.esm that has this + float mWeight; + int mValue; + int mIsKey; // There are many keys in Morrowind.esm that has this // set to 0. TODO: Check what this field corresponds to // in the editor. }; - MCDTstruct data; + MCDTstruct mData; - std::string name, model, icon, script; + std::string mName, mModel, mIcon, mScript; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadnpc.cpp b/components/esm/loadnpc.cpp index 637aa0e62..72d0b3736 100644 --- a/components/esm/loadnpc.cpp +++ b/components/esm/loadnpc.cpp @@ -1,38 +1,45 @@ #include "loadnpc.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { -void NPC::load(ESMReader &esm, const std::string& id) +void NPC::load(ESMReader &esm) { - mId = id; + mNpdt52.mGold = -10; - npdt52.gold = -10; + mModel = esm.getHNOString("MODL"); + mName = esm.getHNOString("FNAM"); - model = esm.getHNOString("MODL"); - name = esm.getHNOString("FNAM"); + mRace = esm.getHNString("RNAM"); + mClass = esm.getHNString("CNAM"); + mFaction = esm.getHNString("ANAM"); + mHead = esm.getHNString("BNAM"); + mHair = esm.getHNString("KNAM"); - race = esm.getHNString("RNAM"); - cls = esm.getHNString("CNAM"); - faction = esm.getHNString("ANAM"); - head = esm.getHNString("BNAM"); - hair = esm.getHNString("KNAM"); - - script = esm.getHNOString("SCRI"); + mScript = esm.getHNOString("SCRI"); esm.getSubNameIs("NPDT"); esm.getSubHeader(); if (esm.getSubSize() == 52) - esm.getExact(&npdt52, 52); + { + mNpdtType = 52; + esm.getExact(&mNpdt52, 52); + } else if (esm.getSubSize() == 12) - esm.getExact(&npdt12, 12); + { + mNpdtType = 12; + esm.getExact(&mNpdt12, 12); + } else esm.fail("NPC_NPDT must be 12 or 52 bytes long"); - esm.getHNT(flags, "FLAG"); + esm.getHNT(mFlags, "FLAG"); - inventory.load(esm); - spells.load(esm); + mInventory.load(esm); + mSpells.load(esm); if (esm.isNextSub("AIDT")) { @@ -54,5 +61,36 @@ void NPC::load(ESMReader &esm, const std::string& id) mAiPackage.load(esm); esm.skipRecord(); } +void NPC::save(ESMWriter &esm) +{ + esm.writeHNOCString("MODL", mModel); + esm.writeHNOCString("FNAM", mName); + esm.writeHNCString("RNAM", mRace); + esm.writeHNCString("CNAM", mClass); + esm.writeHNCString("ANAM", mFaction); + esm.writeHNCString("BNAM", mHead); + esm.writeHNCString("KNAM", mHair); + esm.writeHNOCString("SCRI", mScript); + + if (mNpdtType == 52) + esm.writeHNT("NPDT", mNpdt52, 52); + else if (mNpdtType == 12) + esm.writeHNT("NPDT", mNpdt12, 12); + + esm.writeHNT("FLAG", mFlags); + + mInventory.save(esm); + mSpells.save(esm); + if (mHasAI) { + esm.writeHNT("AIDT", mAiData, sizeof(mAiData)); + } + + typedef std::vector::iterator DestIter; + for (DestIter it = mTransport.begin(); it != mTransport.end(); ++it) { + esm.writeHNT("DODT", it->mPos, sizeof(it->mPos)); + esm.writeHNOCString("DNAM", it->mCellName); + } + mAiPackage.save(esm); +} } diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index eec978e9f..ee9ef6b0b 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -1,13 +1,19 @@ -#ifndef _ESM_NPC_H -#define _ESM_NPC_H +#ifndef OPENMW_ESM_NPC_H +#define OPENMW_ESM_NPC_H + +#include +#include -#include "esm_reader.hpp" -#include "loadcont.hpp" #include "defs.hpp" +#include "loadcont.hpp" #include "aipackage.hpp" +#include "spelllist.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * NPC definition */ @@ -50,43 +56,52 @@ struct NPC Metal = 0x0800 // Metal blood effect (golden?) }; -#pragma pack(push) -#pragma pack(1) - struct NPDTstruct52 - { - short level; - char strength, intelligence, willpower, agility, - speed, endurance, personality, luck; - char skills[27]; - char reputation; - short health, mana, fatigue; - char disposition, factionID, rank; - char unknown; - int gold; - }; // 52 bytes + #pragma pack(push) + #pragma pack(1) - struct NPDTstruct12 - { - short level; - char disposition, reputation, rank, - unknown1, unknown2, unknown3; - int gold; // ?? not certain - }; // 12 bytes -#pragma pack(pop) + struct NPDTstruct52 + { + short mLevel; + char mStrength, + mIntelligence, + mWillpower, + mAgility, + mSpeed, + mEndurance, + mPersonality, + mLuck; + + char mSkills[27]; + char mReputation; + short mHealth, mMana, mFatigue; + char mDisposition, mFactionID, mRank; + char mUnknown; + int mGold; + }; // 52 bytes + + struct NPDTstruct12 + { + short mLevel; + char mDisposition, mReputation, mRank; + char mUnknown1, mUnknown2, mUnknown3; + int mGold; // ?? not certain + }; // 12 bytes struct Dest { Position mPos; std::string mCellName; }; + #pragma pack(pop) - NPDTstruct52 npdt52; - NPDTstruct12 npdt12; // Use this if npdt52.gold == -10 + char mNpdtType; + NPDTstruct52 mNpdt52; + NPDTstruct12 mNpdt12; // Use this if npdt52.gold == -10 - int flags; + int mFlags; - InventoryList inventory; - SpellList spells; + InventoryList mInventory; + SpellList mSpells; AIData mAiData; bool mHasAI; @@ -94,15 +109,14 @@ struct NPC std::vector mTransport; AIPackageList mAiPackage; - std::string name, model, race, cls, faction, script; + std::string mId, mName, mModel, mRace, mClass, mFaction, mScript; // body parts - std::string hair, head; - - std::string mId; + std::string mHair, mHead; // Implementation moved to load_impl.cpp - void load(ESMReader &esm, const std::string& id); + void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadnpcc.hpp b/components/esm/loadnpcc.hpp index 592d5b57f..3da14655f 100644 --- a/components/esm/loadnpcc.hpp +++ b/components/esm/loadnpcc.hpp @@ -1,10 +1,14 @@ -#ifndef _ESM_NPCC_H -#define _ESM_NPCC_H +#ifndef OPENMW_ESM_NPCC_H +#define OPENMW_ESM_NPCC_H -#include "esm_reader.hpp" +// TODO: create implementation files to remove this +#include "esmreader.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * NPC change information (found in savegame files only). We can't * read these yet. @@ -76,6 +80,9 @@ struct LoadNPCC { esm.skipRecord(); } + void save(ESMWriter &esm) + { + } }; } #endif diff --git a/components/esm/loadpgrd.cpp b/components/esm/loadpgrd.cpp index dc63ce335..56c2f8c74 100644 --- a/components/esm/loadpgrd.cpp +++ b/components/esm/loadpgrd.cpp @@ -1,12 +1,15 @@ #include "loadpgrd.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Pathgrid::load(ESMReader &esm) { - esm.getHNT(data, "DATA", 12); - cell = esm.getHNString("NAME"); + esm.getHNT(mData, "DATA", 12); + mCell = esm.getHNString("NAME"); // keep track of total connections so we can reserve edge vector size int edgeCount = 0; @@ -16,18 +19,18 @@ void Pathgrid::load(ESMReader &esm) esm.getSubHeader(); int size = esm.getSubSize(); // Check that the sizes match up. Size = 16 * s2 (path points) - if (size != static_cast (sizeof(Point) * data.s2)) + if (size != static_cast (sizeof(Point) * mData.mS2)) esm.fail("Path point subrecord size mismatch"); else { - int pointCount = data.s2; - points.reserve(pointCount); + int pointCount = mData.mS2; + mPoints.reserve(pointCount); for (int i = 0; i < pointCount; ++i) { Point p; esm.getExact(&p, sizeof(Point)); - points.push_back(p); - edgeCount += p.connectionNum; + mPoints.push_back(p); + edgeCount += p.mConnectionNum; } } } @@ -52,20 +55,45 @@ void Pathgrid::load(ESMReader &esm) std::vector::const_iterator rawIt = rawConnections.begin(); int pointIndex = 0; - edges.reserve(edgeCount); - for(PointList::const_iterator it = points.begin(); it != points.end(); it++, pointIndex++) + mEdges.reserve(edgeCount); + for(PointList::const_iterator it = mPoints.begin(); it != mPoints.end(); it++, pointIndex++) { - unsigned char connectionNum = (*it).connectionNum; + unsigned char connectionNum = (*it).mConnectionNum; for (int i = 0; i < connectionNum; ++i) { Edge edge; - edge.v0 = pointIndex; - edge.v1 = *rawIt; + edge.mV0 = pointIndex; + edge.mV1 = *rawIt; rawIt++; - edges.push_back(edge); + mEdges.push_back(edge); } } } } } +void Pathgrid::save(ESMWriter &esm) +{ + esm.writeHNT("DATA", mData, 12); + esm.writeHNCString("NAME", mCell); + + if (!mPoints.empty()) + { + esm.startSubRecord("PGRP"); + for (PointList::iterator it = mPoints.begin(); it != mPoints.end(); ++it) + { + esm.writeT(*it); + } + esm.endRecord("PGRP"); + } + + if (!mEdges.empty()) + { + esm.startSubRecord("PGRC"); + for (std::vector::iterator it = mEdges.begin(); it != mEdges.end(); ++it) + { + esm.writeT(it->mV1); + } + esm.endRecord("PGRC"); + } +} } diff --git a/components/esm/loadpgrd.hpp b/components/esm/loadpgrd.hpp index 6e2c6e134..c3f50fc4d 100644 --- a/components/esm/loadpgrd.hpp +++ b/components/esm/loadpgrd.hpp @@ -1,11 +1,15 @@ -#ifndef _ESM_PGRD_H -#define _ESM_PGRD_H +#ifndef OPENMW_ESM_PGRD_H +#define OPENMW_ESM_PGRD_H -#include "esm_reader.hpp" +#include +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Path grid. */ @@ -13,35 +17,36 @@ struct Pathgrid { struct DATAstruct { - int x, y; // Grid location, matches cell for exterior cells - short s1; // ?? Usually but not always a power of 2. Doesn't seem + int mX, mY; // Grid location, matches cell for exterior cells + short mS1; // ?? Usually but not always a power of 2. Doesn't seem // to have any relation to the size of PGRC. - short s2; // Number of path points. + short mS2; // Number of path points. }; // 12 bytes struct Point // path grid point { - int x, y, z; // Location of point - unsigned char autogenerated; // autogenerated vs. user coloring flag? - unsigned char connectionNum; // number of connections for this point - short unknown; + int mX, mY, mZ; // Location of point + unsigned char mAutogenerated; // autogenerated vs. user coloring flag? + unsigned char mConnectionNum; // number of connections for this point + short mUnknown; }; // 16 bytes struct Edge // path grid edge { - int v0, v1; // index of points connected with this edge + int mV0, mV1; // index of points connected with this edge }; // 8 bytes - std::string cell; // Cell name - DATAstruct data; + std::string mCell; // Cell name + DATAstruct mData; typedef std::vector PointList; - PointList points; + PointList mPoints; typedef std::vector EdgeList; - EdgeList edges; + EdgeList mEdges; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadrace.cpp b/components/esm/loadrace.cpp index ce64f5f72..139ef081c 100644 --- a/components/esm/loadrace.cpp +++ b/components/esm/loadrace.cpp @@ -1,14 +1,24 @@ #include "loadrace.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Race::load(ESMReader &esm) { - name = esm.getHNString("FNAM"); - esm.getHNT(data, "RADT", 140); - powers.load(esm); - description = esm.getHNOString("DESC"); + mName = esm.getHNString("FNAM"); + esm.getHNT(mData, "RADT", 140); + mPowers.load(esm); + mDescription = esm.getHNOString("DESC"); +} +void Race::save(ESMWriter &esm) +{ + esm.writeHNCString("FNAM", mName); + esm.writeHNT("RADT", mData, 140); + mPowers.save(esm); + esm.writeHNOString("DESC", mDescription); } } diff --git a/components/esm/loadrace.hpp b/components/esm/loadrace.hpp index d4506dbef..42b2c91a7 100644 --- a/components/esm/loadrace.hpp +++ b/components/esm/loadrace.hpp @@ -1,12 +1,16 @@ -#ifndef _ESM_RACE_H -#define _ESM_RACE_H +#ifndef OPENMW_ESM_RACE_H +#define OPENMW_ESM_RACE_H -#include "esm_reader.hpp" -#include "defs.hpp" +#include + +#include "spelllist.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Race definition */ @@ -15,18 +19,18 @@ struct Race { struct SkillBonus { - int skill; // SkillEnum - int bonus; + int mSkill; // SkillEnum + int mBonus; }; struct MaleFemale { - int male, female; + int mMale, mFemale; }; struct MaleFemaleF { - float male, female; + float mMale, mFemale; }; enum Flags @@ -38,26 +42,34 @@ struct Race struct RADTstruct { // List of skills that get a bonus - SkillBonus bonus[7]; + SkillBonus mBonus[7]; // Attribute values for male/female - MaleFemale strength, intelligence, willpower, agility, speed, - endurance, personality, luck; + MaleFemale mStrength, + mIntelligence, + mWillpower, + mAgility, + mSpeed, + mEndurance, + mPersonality, + mLuck; // The actual eye level height (in game units) is (probably) given // as 'height' times 128. This has not been tested yet. - MaleFemaleF height, weight; + MaleFemaleF mHeight, mWeight; - int flags; // 0x1 - playable, 0x2 - beast race + int mFlags; // 0x1 - playable, 0x2 - beast race }; // Size = 140 bytes - RADTstruct data; + RADTstruct mData; - std::string name, description; - SpellList powers; + std::string mName, mDescription; + SpellList mPowers; void load(ESMReader &esm); + void save(ESMWriter &esm); }; + } #endif diff --git a/components/esm/loadregn.cpp b/components/esm/loadregn.cpp index f31c9a827..d39a29454 100644 --- a/components/esm/loadregn.cpp +++ b/components/esm/loadregn.cpp @@ -1,28 +1,48 @@ #include "loadregn.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Region::load(ESMReader &esm) { - name = esm.getHNString("FNAM"); + mName = esm.getHNString("FNAM"); if (esm.getVer() == VER_12) - esm.getHNExact(&data, sizeof(data) - 2, "WEAT"); + esm.getHNExact(&mData, sizeof(mData) - 2, "WEAT"); else if (esm.getVer() == VER_13) - esm.getHNExact(&data, sizeof(data), "WEAT"); + esm.getHNExact(&mData, sizeof(mData), "WEAT"); else esm.fail("Don't know what to do in this version"); - sleepList = esm.getHNOString("BNAM"); + mSleepList = esm.getHNOString("BNAM"); - esm.getHNT(mapColor, "CNAM"); + esm.getHNT(mMapColor, "CNAM"); while (esm.hasMoreSubs()) { SoundRef sr; esm.getHNT(sr, "SNAM", 33); - soundList.push_back(sr); + mSoundList.push_back(sr); + } +} +void Region::save(ESMWriter &esm) +{ + esm.writeHNCString("FNAM", mName); + + if (esm.getVersion() == VER_12) + esm.writeHNT("WEAT", mData, sizeof(mData) - 2); + else + esm.writeHNT("WEAT", mData); + + esm.writeHNOCString("BNAM", mSleepList); + + esm.writeHNT("CNAM", mMapColor); + for (std::vector::iterator it = mSoundList.begin(); it != mSoundList.end(); ++it) + { + esm.writeHNT("SNAM", *it); } } diff --git a/components/esm/loadregn.hpp b/components/esm/loadregn.hpp index 1748b3d28..fd0863b5b 100644 --- a/components/esm/loadregn.hpp +++ b/components/esm/loadregn.hpp @@ -1,11 +1,17 @@ -#ifndef _ESM_REGN_H -#define _ESM_REGN_H +#ifndef OPENMW_ESM_REGN_H +#define OPENMW_ESM_REGN_H -#include "esm_reader.hpp" +#include +#include + +#include "esmcommon.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Region data */ @@ -17,30 +23,31 @@ struct Region struct WEATstruct { // I guess these are probabilities - char clear, cloudy, foggy, overcast, rain, thunder, ash, blight, + char mClear, mCloudy, mFoggy, mOvercast, mRain, mThunder, mAsh, mBlight, // Unknown weather, probably snow and something. Only // present in file version 1.3. - a, b; + mA, mB; }; // 10 bytes // Reference to a sound that is played randomly in this region struct SoundRef { - NAME32 sound; - char chance; + NAME32 mSound; + char mChance; }; // 33 bytes #pragma pack(pop) - WEATstruct data; - int mapColor; // RGBA + WEATstruct mData; + int mMapColor; // RGBA // sleepList refers to a eveled list of creatures you can meet if // you sleep outside in this region. - std::string name, sleepList; + std::string mName, mSleepList; - std::vector soundList; + std::vector mSoundList; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadscpt.cpp b/components/esm/loadscpt.cpp index 9c0176725..dc28166d4 100644 --- a/components/esm/loadscpt.cpp +++ b/components/esm/loadscpt.cpp @@ -1,29 +1,32 @@ #include "loadscpt.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Script::load(ESMReader &esm) { - esm.getHNT(data, "SCHD", 52); + esm.getHNT(mData, "SCHD", 52); // List of local variables if (esm.isNextSub("SCVR")) { - int s = data.stringTableSize; + int s = mData.mStringTableSize; char* tmp = new char[s]; esm.getHExact(tmp, s); // Set up the list of variable names - varNames.resize(data.numShorts + data.numLongs + data.numFloats); + mVarNames.resize(mData.mNumShorts + mData.mNumLongs + mData.mNumFloats); // The tmp buffer is a null-byte separated string list, we // just have to pick out one string at a time. char* str = tmp; - for (size_t i = 0; i < varNames.size(); i++) + for (size_t i = 0; i < mVarNames.size(); i++) { - varNames[i] = std::string(str); - str += varNames[i].size() + 1; + mVarNames[i] = std::string(str); + str += mVarNames[i].size() + 1; if (str - tmp > s) esm.fail("String table overflow"); @@ -31,12 +34,37 @@ void Script::load(ESMReader &esm) delete[] tmp; } - // Script data - scriptData.resize(data.scriptDataSize); - esm.getHNExact(&scriptData[0], scriptData.size(), "SCDT"); + // Script mData + mScriptData.resize(mData.mScriptDataSize); + esm.getHNExact(&mScriptData[0], mScriptData.size(), "SCDT"); // Script text - scriptText = esm.getHNOString("SCTX"); + mScriptText = esm.getHNOString("SCTX"); +} +void Script::save(ESMWriter &esm) +{ + std::string varNameString; + if (!mVarNames.empty()) + for (std::vector::iterator it = mVarNames.begin(); it != mVarNames.end(); ++it) + varNameString.append(*it); + + esm.writeHNT("SCHD", mData, 52); + + if (!mVarNames.empty()) + { + esm.startSubRecord("SCVR"); + for (std::vector::iterator it = mVarNames.begin(); it != mVarNames.end(); ++it) + { + esm.writeHCString(*it); + } + esm.endRecord("SCVR"); + } + + esm.startSubRecord("SCDT"); + esm.write(&mScriptData[0], mData.mScriptDataSize); + esm.endRecord("SCDT"); + + esm.writeHNOString("SCTX", mScriptText); } } diff --git a/components/esm/loadscpt.hpp b/components/esm/loadscpt.hpp index 3ce3d9636..db8f85057 100644 --- a/components/esm/loadscpt.hpp +++ b/components/esm/loadscpt.hpp @@ -1,11 +1,17 @@ -#ifndef _ESM_SCPT_H -#define _ESM_SCPT_H +#ifndef OPENMW_ESM_SCPT_H +#define OPENMW_ESM_SCPT_H -#include "esm_reader.hpp" +#include +#include + +#include "esmcommon.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Script definitions */ @@ -36,20 +42,21 @@ public: approach though. */ - NAME32 name; + NAME32 mName; // These describe the sizes we need to allocate for the script // data. - int numShorts, numLongs, numFloats, scriptDataSize, stringTableSize; + int mNumShorts, mNumLongs, mNumFloats, mScriptDataSize, mStringTableSize; }; // 52 bytes - SCHDstruct data; + SCHDstruct mData; - std::vector varNames; // Variable names - std::vector scriptData; // Compiled bytecode - std::string scriptText; // Uncompiled script + std::vector mVarNames; // Variable names + std::vector mScriptData; // Compiled bytecode + std::string mScriptText; // Uncompiled script void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadskil.cpp b/components/esm/loadskil.cpp index 52869f440..a4d21c591 100644 --- a/components/esm/loadskil.cpp +++ b/components/esm/loadskil.cpp @@ -1,5 +1,8 @@ #include "loadskil.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { const std::string Skill::sSkillNameIds[Length] = { @@ -60,7 +63,7 @@ namespace ESM "stealth_speechcraft.dds", "stealth_handtohand.dds", }; - const boost::array Skill::skillIds = {{ + const boost::array Skill::sSkillIds = {{ Block, Armorer, MediumArmor, @@ -92,8 +95,14 @@ namespace ESM void Skill::load(ESMReader &esm) { - esm.getHNT(index, "INDX"); - esm.getHNT(data, "SKDT", 24); - description = esm.getHNOString("DESC"); + esm.getHNT(mIndex, "INDX"); + esm.getHNT(mData, "SKDT", 24); + mDescription = esm.getHNOString("DESC"); +} +void Skill::save(ESMWriter &esm) +{ + esm.writeHNT("INDX", mIndex); + esm.writeHNT("SKDT", mData, 24); + esm.writeHNOString("DESC", mDescription); } } diff --git a/components/esm/loadskil.hpp b/components/esm/loadskil.hpp index f56ec2fcb..05bac717b 100644 --- a/components/esm/loadskil.hpp +++ b/components/esm/loadskil.hpp @@ -1,13 +1,17 @@ -#ifndef _ESM_SKIL_H -#define _ESM_SKIL_H +#ifndef OPENMW_ESM_SKIL_H +#define OPENMW_ESM_SKIL_H + +#include #include -#include "esm_reader.hpp" #include "defs.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + /* * Skill information * @@ -17,20 +21,20 @@ struct Skill { struct SKDTstruct { - int attribute; // see defs.hpp - int specialization;// 0 - Combat, 1 - Magic, 2 - Stealth - float useValue[4]; // How much skill improves through use. Meaning + int mAttribute; // see defs.hpp + int mSpecialization;// 0 - Combat, 1 - Magic, 2 - Stealth + float mUseValue[4]; // How much skill improves through use. Meaning // of each field depends on what skill this // is. We should document this better later. }; // Total size: 24 bytes - SKDTstruct data; + SKDTstruct mData; // Skill index. Skils don't have an id ("NAME") like most records, // they only have a numerical index that matches one of the // hard-coded skills in the game. - int index; + int mIndex; - std::string description; + std::string mDescription; enum SkillEnum { @@ -65,9 +69,10 @@ struct Skill }; static const std::string sSkillNameIds[Length]; static const std::string sIconNames[Length]; - static const boost::array skillIds; + static const boost::array sSkillIds; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadsndg.cpp b/components/esm/loadsndg.cpp index b7b568132..42d524226 100644 --- a/components/esm/loadsndg.cpp +++ b/components/esm/loadsndg.cpp @@ -1,14 +1,23 @@ #include "loadsndg.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void SoundGenerator::load(ESMReader &esm) { - esm.getHNT(type, "DATA", 4); + esm.getHNT(mType, "DATA", 4); - creature = esm.getHNOString("CNAM"); - sound = esm.getHNOString("SNAM"); + mCreature = esm.getHNOString("CNAM"); + mSound = esm.getHNOString("SNAM"); +} +void SoundGenerator::save(ESMWriter &esm) +{ + esm.writeHNT("DATA", mType, 4); + esm.writeHNOCString("CNAM", mCreature); + esm.writeHNOCString("SNAM", mSound); } } diff --git a/components/esm/loadsndg.hpp b/components/esm/loadsndg.hpp index 2953369c4..dadfbd239 100644 --- a/components/esm/loadsndg.hpp +++ b/components/esm/loadsndg.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_SNDG_H -#define _ESM_SNDG_H +#ifndef OPENMW_ESM_SNDG_H +#define OPENMW_ESM_SNDG_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Sound generator. This describes the sounds a creature make. */ @@ -25,11 +28,12 @@ struct SoundGenerator }; // Type - int type; + int mType; - std::string creature, sound; + std::string mCreature, mSound; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadsoun.cpp b/components/esm/loadsoun.cpp index cd47f0f17..87a08d2d3 100644 --- a/components/esm/loadsoun.cpp +++ b/components/esm/loadsoun.cpp @@ -1,12 +1,15 @@ #include "loadsoun.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Sound::load(ESMReader &esm) { - sound = esm.getHNString("FNAM"); - esm.getHNT(data, "DATA", 3); + mSound = esm.getHNString("FNAM"); + esm.getHNT(mData, "DATA", 3); /* cout << "vol=" << (int)data.volume << " min=" << (int)data.minRange @@ -14,5 +17,10 @@ void Sound::load(ESMReader &esm) << endl; */ } +void Sound::save(ESMWriter &esm) +{ + esm.writeHNCString("FNAM", mSound); + esm.writeHNT("DATA", mData, 3); +} } diff --git a/components/esm/loadsoun.hpp b/components/esm/loadsoun.hpp index 775a664be..5443c6cb9 100644 --- a/components/esm/loadsoun.hpp +++ b/components/esm/loadsoun.hpp @@ -1,22 +1,26 @@ -#ifndef _ESM_SOUN_H -#define _ESM_SOUN_H +#ifndef OPENMW_ESM_SOUN_H +#define OPENMW_ESM_SOUN_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + struct SOUNstruct { - unsigned char volume, minRange, maxRange; + unsigned char mVolume, mMinRange, mMaxRange; }; struct Sound { - SOUNstruct data; - std::string sound; + SOUNstruct mData; + std::string mSound; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadspel.cpp b/components/esm/loadspel.cpp index c3c928ce6..b0f1ca64b 100644 --- a/components/esm/loadspel.cpp +++ b/components/esm/loadspel.cpp @@ -1,13 +1,23 @@ #include "loadspel.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Spell::load(ESMReader &esm) { - name = esm.getHNOString("FNAM"); - esm.getHNT(data, "SPDT", 12); - effects.load(esm); + mName = esm.getHNOString("FNAM"); + esm.getHNT(mData, "SPDT", 12); + mEffects.load(esm); +} + +void Spell::save(ESMWriter &esm) +{ + esm.writeHNOCString("FNAM", mName); + esm.writeHNT("SPDT", mData, 12); + mEffects.save(esm); } } diff --git a/components/esm/loadspel.hpp b/components/esm/loadspel.hpp index c97d037cd..5ad184126 100644 --- a/components/esm/loadspel.hpp +++ b/components/esm/loadspel.hpp @@ -1,12 +1,16 @@ -#ifndef _ESM_SPEL_H -#define _ESM_SPEL_H +#ifndef OPENMW_ESM_SPEL_H +#define OPENMW_ESM_SPEL_H -#include "esm_reader.hpp" -#include "defs.hpp" +#include + +#include "effectlist.hpp" namespace ESM { +class ESMReader; +class ESMWriter; + struct Spell { enum SpellType @@ -28,16 +32,17 @@ struct Spell struct SPDTstruct { - int type; // SpellType - int cost; // Mana cost - int flags; // Flags + int mType; // SpellType + int mCost; // Mana cost + int mFlags; // Flags }; - SPDTstruct data; - std::string name; - EffectList effects; + SPDTstruct mData; + std::string mName; + EffectList mEffects; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadsscr.cpp b/components/esm/loadsscr.cpp index f4e79271c..ae50de517 100644 --- a/components/esm/loadsscr.cpp +++ b/components/esm/loadsscr.cpp @@ -1,13 +1,20 @@ #include "loadsscr.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void StartScript::load(ESMReader &esm) { - esm.getSubNameIs("DATA"); - esm.skipHSub(); - script = esm.getHNString("NAME"); + mData = esm.getHNString("DATA"); + mScript = esm.getHNString("NAME"); +} +void StartScript::save(ESMWriter &esm) +{ + esm.writeHNString("DATA", mData); + esm.writeHNString("NAME", mScript); } } diff --git a/components/esm/loadsscr.hpp b/components/esm/loadsscr.hpp index d18bde101..d180bfcff 100644 --- a/components/esm/loadsscr.hpp +++ b/components/esm/loadsscr.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_SSCR_H -#define _ESM_SSCR_H +#ifndef OPENMW_ESM_SSCR_H +#define OPENMW_ESM_SSCR_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* Startup script. I think this is simply a 'main' script that is run from the begining. The SSCR records contain a DATA identifier which @@ -16,10 +19,12 @@ namespace ESM struct StartScript { - std::string script; + std::string mData; + std::string mScript; // Load a record and add it to the list void load(ESMReader &esm); + void save(ESMWriter &esm); }; } diff --git a/components/esm/loadstat.cpp b/components/esm/loadstat.cpp index 654bf290a..92c9ebc71 100644 --- a/components/esm/loadstat.cpp +++ b/components/esm/loadstat.cpp @@ -1,11 +1,18 @@ #include "loadstat.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Static::load(ESMReader &esm) { - model = esm.getHNString("MODL"); + mModel = esm.getHNString("MODL"); +} +void Static::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); } } diff --git a/components/esm/loadstat.hpp b/components/esm/loadstat.hpp index 4f3121d18..ba35fa718 100644 --- a/components/esm/loadstat.hpp +++ b/components/esm/loadstat.hpp @@ -1,10 +1,13 @@ -#ifndef _ESM_STAT_H -#define _ESM_STAT_H +#ifndef OPENMW_ESM_STAT_H +#define OPENMW_ESM_STAT_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Definition of static object. * @@ -19,9 +22,10 @@ namespace ESM { struct Static { - std::string model; + std::string mModel; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/loadweap.cpp b/components/esm/loadweap.cpp index 1910631bc..18d37e56c 100644 --- a/components/esm/loadweap.cpp +++ b/components/esm/loadweap.cpp @@ -1,16 +1,28 @@ #include "loadweap.hpp" +#include "esmreader.hpp" +#include "esmwriter.hpp" + namespace ESM { void Weapon::load(ESMReader &esm) { - model = esm.getHNString("MODL"); - name = esm.getHNOString("FNAM"); - esm.getHNT(data, "WPDT", 32); - script = esm.getHNOString("SCRI"); - icon = esm.getHNOString("ITEX"); - enchant = esm.getHNOString("ENAM"); + mModel = esm.getHNString("MODL"); + mName = esm.getHNOString("FNAM"); + esm.getHNT(mData, "WPDT", 32); + mScript = esm.getHNOString("SCRI"); + mIcon = esm.getHNOString("ITEX"); + mEnchant = esm.getHNOString("ENAM"); +} +void Weapon::save(ESMWriter &esm) +{ + esm.writeHNCString("MODL", mModel); + esm.writeHNOCString("FNAM", mName); + esm.writeHNT("WPDT", mData, 32); + esm.writeHNOCString("SCRI", mScript); + esm.writeHNOCString("ITEX", mIcon); + esm.writeHNOCString("ENAM", mEnchant); } } diff --git a/components/esm/loadweap.hpp b/components/esm/loadweap.hpp index 8bd3b147c..341a2c86e 100644 --- a/components/esm/loadweap.hpp +++ b/components/esm/loadweap.hpp @@ -1,11 +1,14 @@ -#ifndef _ESM_WEAP_H -#define _ESM_WEAP_H +#ifndef OPENMW_ESM_WEAP_H +#define OPENMW_ESM_WEAP_H -#include "esm_reader.hpp" +#include namespace ESM { +class ESMReader; +class ESMWriter; + /* * Weapon definition */ @@ -40,22 +43,23 @@ struct Weapon #pragma pack(1) struct WPDTstruct { - float weight; - int value; - short type; - short health; - float speed, reach; - short enchant; // Enchantment points - unsigned char chop[2], slash[2], thrust[2]; // Min and max - int flags; + float mWeight; + int mValue; + short mType; + short mHealth; + float mSpeed, mReach; + short mEnchant; // Enchantment points + unsigned char mChop[2], mSlash[2], mThrust[2]; // Min and max + int mFlags; }; // 32 bytes #pragma pack(pop) - WPDTstruct data; + WPDTstruct mData; - std::string name, model, icon, enchant, script; + std::string mName, mModel, mIcon, mEnchant, mScript; void load(ESMReader &esm); + void save(ESMWriter &esm); }; } #endif diff --git a/components/esm/records.hpp b/components/esm/records.hpp index 704a11609..0662c797c 100644 --- a/components/esm/records.hpp +++ b/components/esm/records.hpp @@ -1,6 +1,7 @@ -#ifndef _ESM_RECORDS_H -#define _ESM_RECORDS_H +#ifndef OPENMW_ESM_RECORDS_H +#define OPENMW_ESM_RECORDS_H +#include "defs.hpp" #include "loadacti.hpp" #include "loadalch.hpp" #include "loadappa.hpp" @@ -45,57 +46,4 @@ // Special records which are not loaded from ESM #include "attr.hpp" - -namespace ESM { - -// Integer versions of all the record names, used for faster lookup -enum RecNameInts - { - REC_ACTI = 0x49544341, - REC_ALCH = 0x48434c41, - REC_APPA = 0x41505041, - REC_ARMO = 0x4f4d5241, - REC_BODY = 0x59444f42, - REC_BOOK = 0x4b4f4f42, - REC_BSGN = 0x4e475342, - REC_CELL = 0x4c4c4543, - REC_CLAS = 0x53414c43, - REC_CLOT = 0x544f4c43, - REC_CNTC = 0x43544e43, - REC_CONT = 0x544e4f43, - REC_CREA = 0x41455243, - REC_CREC = 0x43455243, - REC_DIAL = 0x4c414944, - REC_DOOR = 0x524f4f44, - REC_ENCH = 0x48434e45, - REC_FACT = 0x54434146, - REC_GLOB = 0x424f4c47, - REC_GMST = 0x54534d47, - REC_INFO = 0x4f464e49, - REC_INGR = 0x52474e49, - REC_LAND = 0x444e414c, - REC_LEVC = 0x4356454c, - REC_LEVI = 0x4956454c, - REC_LIGH = 0x4847494c, - REC_LOCK = 0x4b434f4c, - REC_LTEX = 0x5845544c, - REC_MGEF = 0x4645474d, - REC_MISC = 0x4353494d, - REC_NPC_ = 0x5f43504e, - REC_NPCC = 0x4343504e, - REC_PGRD = 0x44524750, - REC_PROB = 0x424f5250, - REC_RACE = 0x45434152, - REC_REGN = 0x4e474552, - REC_REPA = 0x41504552, - REC_SCPT = 0x54504353, - REC_SKIL = 0x4c494b53, - REC_SNDG = 0x47444e53, - REC_SOUN = 0x4e554f53, - REC_SPEL = 0x4c455053, - REC_SSCR = 0x52435353, - REC_STAT = 0x54415453, - REC_WEAP = 0x50414557 - }; -} #endif diff --git a/components/esm/spelllist.cpp b/components/esm/spelllist.cpp new file mode 100644 index 000000000..dd886cf7f --- /dev/null +++ b/components/esm/spelllist.cpp @@ -0,0 +1,22 @@ +#include "spelllist.hpp" + +#include "esmreader.hpp" +#include "esmwriter.hpp" + +namespace ESM { + +void SpellList::load(ESMReader &esm) +{ + while (esm.isNextSub("NPCS")) { + mList.push_back(esm.getHString()); + } +} + +void SpellList::save(ESMWriter &esm) +{ + for (std::vector::iterator it = mList.begin(); it != mList.end(); ++it) { + esm.writeHNString("NPCS", *it, 32); + } +} + +} diff --git a/components/esm/spelllist.hpp b/components/esm/spelllist.hpp new file mode 100644 index 000000000..52999270a --- /dev/null +++ b/components/esm/spelllist.hpp @@ -0,0 +1,25 @@ +#ifndef OPENMW_ESM_SPELLLIST_H +#define OPENMW_ESM_SPELLLIST_H + +#include +#include + +namespace ESM +{ + class ESMReader; + class ESMWriter; + + /** A list of references to spells and spell effects. This is shared + between the records BSGN, NPC and RACE. + */ + struct SpellList + { + std::vector mList; + + void load(ESMReader &esm); + void save(ESMWriter &esm); + }; +} + +#endif + diff --git a/components/esm_store/reclists.hpp b/components/esm_store/reclists.hpp index ffecfc8de..24580a79c 100644 --- a/components/esm_store/reclists.hpp +++ b/components/esm_store/reclists.hpp @@ -173,7 +173,8 @@ namespace ESMS void load(ESMReader &esm, const std::string &id) { std::string id2 = toLower (id); - list[id2].load(esm, id2); + list[id2].mId = id2; + list[id2].load(esm); } // Find the given object ID, or return NULL if not found. @@ -225,7 +226,7 @@ namespace ESMS std::string id2 = toLower (id); X& ref = list[id2]; - ref.id = id; + ref.mId = id; ref.load(esm); } @@ -292,14 +293,14 @@ namespace ESMS { LandTexture lt; lt.load(esm); - lt.id = id; + lt.mId = id; // Make sure we have room for the structure - if(lt.index + 1 > (int)ltex.size()) - ltex.resize(lt.index+1); + if(lt.mIndex + 1 > (int)ltex.size()) + ltex.resize(lt.mIndex+1); // Store it - ltex[lt.index] = lt; + ltex[lt.mIndex] = lt; } }; @@ -327,7 +328,7 @@ namespace ESMS virtual void listIdentifier (std::vector& identifier) const {} - // Find land for the given coordinates. Return null if no data. + // Find land for the given coordinates. Return null if no mData. Land *search(int x, int y) const { LandMap::const_iterator itr = lands.find(std::make_pair(x, y)); @@ -349,7 +350,7 @@ namespace ESMS land->load(esm); // Store the structure - lands[std::make_pair(land->X, land->Y)] = land; + lands[std::make_pair(land->mX, land->mY)] = land; } }; @@ -377,7 +378,7 @@ namespace ESMS typedef std::map IntCells; IntCells intCells; - // List of exterior cells. Indexed as extCells[gridX][gridY]. + // List of exterior cells. Indexed as extCells[mX][mY]. typedef std::map, ESM::Cell*> ExtCells; ExtCells extCells; @@ -439,7 +440,7 @@ namespace ESMS { for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter) { - if (toLower (iter->second->name) == toLower (id)) + if (toLower (iter->second->mName) == toLower (id)) return iter->second; } @@ -451,7 +452,7 @@ namespace ESMS std::string id2 = toLower (id); for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter) - if (toLower (iter->second->region)==id) + if (toLower (iter->second->mRegion)==id) return iter->second; return 0; @@ -463,12 +464,12 @@ namespace ESMS // All cells have a name record, even nameless exterior cells. ESM::Cell *cell = new ESM::Cell; - cell->name = id; + cell->mName = id; // The cell itself takes care of all the hairy details cell->load(esm); - if(cell->data.flags & ESM::Cell::Interior) + if(cell->mData.mFlags & ESM::Cell::Interior) { // Store interior cell by name intCells[id] = cell; @@ -476,7 +477,7 @@ namespace ESMS else { // Store exterior cells by grid position - extCells[std::make_pair (cell->data.gridX, cell->data.gridY)] = cell; + extCells[std::make_pair (cell->mData.mX, cell->mData.mY)] = cell; } } }; @@ -489,7 +490,7 @@ namespace ESMS typedef std::map IntGrids; IntGrids intGrids; - // List of grids for exterior cells. Indexed as extCells[gridX][gridY]. + // List of grids for exterior cells. Indexed as extCells[mX][mY]. typedef std::map, ESM::Pathgrid*> ExtGrids; ExtGrids extGrids; @@ -516,13 +517,13 @@ namespace ESMS count++; ESM::Pathgrid *grid = new ESM::Pathgrid; grid->load(esm); - if (grid->data.x == 0 && grid->data.y == 0) + if (grid->mData.mX == 0 && grid->mData.mY == 0) { - intGrids[grid->cell] = grid; + intGrids[grid->mCell] = grid; } else { - extGrids[std::make_pair(grid->data.x, grid->data.y)] = grid; + extGrids[std::make_pair(grid->mData.mX, grid->mData.mY)] = grid; } } @@ -557,16 +558,16 @@ namespace ESMS Pathgrid *search(const ESM::Cell &cell) const { int cellX, cellY; - if (cell.data.flags & ESM::Cell::Interior) + if (cell.mData.mFlags & ESM::Cell::Interior) { cellX = cellY = 0; } else { - cellX = cell.data.gridX; - cellY = cell.data.gridY; + cellX = cell.mData.mX; + cellY = cell.mData.mY; } - return search(cellX, cellY, cell.name); + return search(cellX, cellY, cell.mName); } }; @@ -585,7 +586,7 @@ namespace ESMS X ref; ref.load (esm); - std::string realId = toLower (ref.data.name.toString()); + std::string realId = toLower (ref.mData.mName.toString()); std::swap (list[realId], ref); } @@ -636,7 +637,7 @@ namespace ESMS { X ref; ref.load (esm); - int index = ref.index; + int index = ref.mIndex; list[index] = ref; } diff --git a/components/esm_store/store.cpp b/components/esm_store/store.cpp index c676601e5..d1fe9b10b 100644 --- a/components/esm_store/store.cpp +++ b/components/esm_store/store.cpp @@ -96,8 +96,8 @@ void ESMStore::load(ESMReader &esm) for (int i = 0; i < Attribute::Length; ++i) { - Attribute::AttributeID id = Attribute::attributeIds[i]; - attributes.list.insert(std::make_pair(id, Attribute(id, Attribute::gmstAttributeIds[i], Attribute::gmstAttributeDescIds[i]))); + Attribute::AttributeID id = Attribute::sAttributeIds[i]; + attributes.list.insert(std::make_pair(id, Attribute(id, Attribute::sGmstAttributeIds[i], Attribute::sGmstAttributeDescIds[i]))); } /* This information isn't needed on screen. But keep the code around diff --git a/components/esm_store/store.hpp b/components/esm_store/store.hpp index 991925bd4..7329386d4 100644 --- a/components/esm_store/store.hpp +++ b/components/esm_store/store.hpp @@ -34,7 +34,7 @@ namespace ESMS RecListT appas; RecListT armors; RecListT bodyParts; - RecListT books; + RecListWithIDT books; RecListT birthSigns; RecListT classes; RecListT clothes; diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 5127af966..ad51d50b9 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -152,6 +152,28 @@ static void fail(const std::string &msg) } +static void insertTextKeys(const Nif::NiTextKeyExtraData *tk, TextKeyMap *textkeys) +{ + for(size_t i = 0;i < tk->list.size();i++) + { + const std::string &str = tk->list[i].text; + std::string::size_type pos = 0; + while(pos < str.length()) + { + while(pos < str.length() && ::isspace(str[pos])) + pos++; + if(pos >= str.length()) + break; + + std::string::size_type nextpos = std::min(str.find('\r', pos), str.find('\n', pos)); + textkeys->insert(std::make_pair(tk->list[i].time, str.substr(pos, nextpos-pos))); + + pos = nextpos; + } + } +} + + void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, std::vector &ctrls, Ogre::Bone *parent=NULL) { Ogre::Bone *bone; @@ -274,23 +296,18 @@ void loadResource(Ogre::Resource *resource) if(scaleiter != scalekeys.mKeys.end()) lastscale = curscale = Ogre::Vector3(scaleiter->mValue) / startscale; bool didlast = false; - + while(!didlast) { float curtime = kfc->timeStop; - //Get latest time - if(quatiter != quatkeys.mKeys.end()){ + if(quatiter != quatkeys.mKeys.end()) curtime = std::min(curtime, quatiter->mTime); - } - if(traniter != trankeys.mKeys.end()){ + if(traniter != trankeys.mKeys.end()) curtime = std::min(curtime, traniter->mTime); - - } - if(scaleiter != scalekeys.mKeys.end()){ + if(scaleiter != scalekeys.mKeys.end()) curtime = std::min(curtime, scaleiter->mTime); - } curtime = std::max(curtime, kfc->timeStart); if(curtime >= kfc->timeStop) @@ -299,15 +316,33 @@ void loadResource(Ogre::Resource *resource) curtime = kfc->timeStop; } - bool rinterpolate = quatiter != quatkeys.mKeys.end() && quatiter != quatkeys.mKeys.begin() && curtime != quatiter->mTime; - bool tinterpolate = traniter != trankeys.mKeys.end() && traniter != trankeys.mKeys.begin() && curtime != traniter->mTime; - bool sinterpolate = scaleiter != scalekeys.mKeys.end() && scaleiter != scalekeys.mKeys.begin() && curtime != scaleiter->mTime; + // Get the latest quaternions, translations, and scales for the + // current time + while(quatiter != quatkeys.mKeys.end() && curtime >= quatiter->mTime) + { + lastquat = curquat; + quatiter++; + if(quatiter != quatkeys.mKeys.end()) + curquat = startquat.Inverse() * quatiter->mValue ; + } + while(traniter != trankeys.mKeys.end() && curtime >= traniter->mTime) + { + lasttrans = curtrans; + traniter++; + if(traniter != trankeys.mKeys.end()) + curtrans = traniter->mValue - starttrans; + } + while(scaleiter != scalekeys.mKeys.end() && curtime >= scaleiter->mTime) + { + lastscale = curscale; + scaleiter++; + if(scaleiter != scalekeys.mKeys.end()) + curscale = Ogre::Vector3(scaleiter->mValue) / startscale; + } - - Ogre::TransformKeyFrame *kframe; kframe = nodetrack->createNodeKeyFrame(curtime); - if(!rinterpolate) + if(quatiter == quatkeys.mKeys.end() || quatiter == quatkeys.mKeys.begin()) kframe->setRotation(curquat); else { @@ -315,7 +350,7 @@ void loadResource(Ogre::Resource *resource) float diff = (curtime-last->mTime) / (quatiter->mTime-last->mTime); kframe->setRotation(Ogre::Quaternion::nlerp(diff, lastquat, curquat)); } - if(!tinterpolate) + if(traniter == trankeys.mKeys.end() || traniter == trankeys.mKeys.begin()) kframe->setTranslate(curtrans); else { @@ -323,7 +358,7 @@ void loadResource(Ogre::Resource *resource) float diff = (curtime-last->mTime) / (traniter->mTime-last->mTime); kframe->setTranslate(lasttrans + ((curtrans-lasttrans)*diff)); } - if(!sinterpolate) + if(scaleiter == scalekeys.mKeys.end() || scaleiter == scalekeys.mKeys.begin()) kframe->setScale(curscale); else { @@ -331,31 +366,6 @@ void loadResource(Ogre::Resource *resource) float diff = (curtime-last->mTime) / (scaleiter->mTime-last->mTime); kframe->setScale(lastscale + ((curscale-lastscale)*diff)); } - - // Get the latest quaternion, translation, and scale for the - // current time - while(quatiter != quatkeys.mKeys.end() && curtime >= quatiter->mTime) - { - quatiter++; - lastquat = curquat; - if(quatiter != quatkeys.mKeys.end()) - curquat = startquat.Inverse() * quatiter->mValue ; - } - while(traniter != trankeys.mKeys.end() && curtime >= traniter->mTime) - { - traniter++; - lasttrans = curtrans; - if(traniter != trankeys.mKeys.end()) - curtrans = traniter->mValue - starttrans; - } - while(scaleiter != scalekeys.mKeys.end() && curtime >= scaleiter->mTime) - { - scaleiter++; - lastscale = curscale; - if(scaleiter != scalekeys.mKeys.end()) - curscale = Ogre::Vector3(scaleiter->mValue) / startscale; - } - } } anim->optimise(); @@ -371,8 +381,7 @@ bool createSkeleton(const std::string &name, const std::string &group, TextKeyMa if(e->recType == Nif::RC_NiTextKeyExtraData) { const Nif::NiTextKeyExtraData *tk = static_cast(e.getPtr()); - for(size_t i = 0;i < tk->list.size();i++) - (*textkeys)[tk->list[i].time] = tk->list[i].text; + insertTextKeys(tk, textkeys); } e = e->extra; } diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index b6610d8a7..a203112b5 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -59,7 +59,7 @@ namespace NifOgre { // FIXME: These should not be in NifOgre, it works agnostic of what model format is used -typedef std::map TextKeyMap; +typedef std::multimap TextKeyMap; struct EntityList { std::vector mEntities; Ogre::Entity *mSkelBase; diff --git a/components/terrain/esm_land_factory.cpp b/components/terrain/esm_land_factory.cpp index a6335c6dc..5cab7ed5d 100644 --- a/components/terrain/esm_land_factory.cpp +++ b/components/terrain/esm_land_factory.cpp @@ -3,7 +3,7 @@ // The first one already includes the others implicitly, but it // doesn't hurt to be explicit. #include "../esm_store/store.hpp" -#include "../esm/esm_reader.hpp" +#include "../esm/esmreader.hpp" #include "../esm/loadland.hpp" using namespace Terrain; diff --git a/components/to_utf8/to_utf8.cpp b/components/to_utf8/to_utf8.cpp index 6bcbbd0e6..6f0ed8bfd 100644 --- a/components/to_utf8/to_utf8.cpp +++ b/components/to_utf8/to_utf8.cpp @@ -193,3 +193,167 @@ std::string ToUTF8::getUtf8(ToUTF8::FromType from) return std::string(&output[0], outlen); } +static size_t getLength2(const char *arr, const char* input, bool &ascii) +{ + ascii = true; + size_t len = 0; + const char* ptr = input; + unsigned char inp = *ptr; + + // Do away with the ascii part of the string first (this is almost + // always the entire string.) + while(inp && inp < 128) + inp = *(++ptr); + len += (ptr-input); + + // If we're not at the null terminator at this point, then there + // were some non-ascii characters to deal with. Go to slow-mode for + // the rest of the string. + if(inp) + { + ascii = false; + while(inp) + { + len += 1; + // Find the translated length of this character in the + // lookup table. + switch(inp) + { + case 0xe2: len -= 2; break; + case 0xc2: + case 0xcb: + case 0xc4: + case 0xc6: + case 0xc3: + case 0xd0: + case 0xd1: + case 0xd2: + case 0xc5: len -= 1; break; + } + + inp = *(++ptr); + } + } + return len; +} + +#include +#include + +static void copyFromArray2(const char *arr, char*& chp, char* &out) +{ + unsigned char ch = *(chp++); + // Optimize for ASCII values + if(ch < 128) + { + *(out++) = ch; + return; + } + + int len = 1; + switch (ch) + { + case 0xe2: len = 3; break; + case 0xc2: + case 0xcb: + case 0xc4: + case 0xc6: + case 0xc3: + case 0xd0: + case 0xd1: + case 0xd2: + case 0xc5: len = 2; break; + } + + if (len == 1) // There is no 1 length utf-8 glyph that is not 0x20 (empty space) + { + *(out++) = ch; + return; + } + + unsigned char ch2 = *(chp++); + unsigned char ch3 = '\0'; + if (len == 3) + ch3 = *(chp++); + + for (int i = 128; i < 256; i++) + { + unsigned char b1 = arr[i*6 + 1], b2 = arr[i*6 + 2], b3 = arr[i*6 + 3]; + if (b1 == ch && b2 == ch2 && (len != 3 || b3 == ch3)) + { + *(out++) = (char)i; + return; + } + } + + std::cout << "Could not find glyph " << std::hex << (int)ch << " " << (int)ch2 << " " << (int)ch3 << std::endl; + + *(out++) = ch; // Could not find glyph, just put whatever +} + +std::string ToUTF8::getLegacyEnc(ToUTF8::FromType to) +{ + // Pick translation array + const char *arr; + switch (to) + { + case ToUTF8::WINDOWS_1252: + { + arr = ToUTF8::windows_1252; + break; + } + case ToUTF8::WINDOWS_1250: + { + arr = ToUTF8::windows_1250; + break; + } + case ToUTF8::WINDOWS_1251: + { + arr = ToUTF8::windows_1251; + break; + } + default: + { + assert(0); + } + } + + // Double check that the input string stops at some point (it might + // contain zero terminators before this, inside its own data, which + // is also ok.) + char* input = &buf[0]; + assert(input[size] == 0); + + // TODO: The rest of this function is designed for single-character + // input encodings only. It also assumes that the input the input + // encoding shares its first 128 values (0-127) with ASCII. These + // conditions must be checked again if you add more input encodings + // later. + + // Compute output length, and check for pure ascii input at the same + // time. + bool ascii; + size_t outlen = getLength2(arr, input, ascii); + + // If we're pure ascii, then don't bother converting anything. + if(ascii) + return std::string(input, outlen); + + // Make sure the output is large enough + resize(output, outlen); + char *out = &output[0]; + + // Translate + while(*input) + copyFromArray2(arr, input, out); + + // Make sure that we wrote the correct number of bytes + assert((out-&output[0]) == (int)outlen); + + // And make extra sure the output is null terminated + assert(output.size() > outlen); + assert(output[outlen] == 0); + + // Return a string + return std::string(&output[0], outlen); +} diff --git a/components/to_utf8/to_utf8.hpp b/components/to_utf8/to_utf8.hpp index 4cbee1019..69e9fc92c 100644 --- a/components/to_utf8/to_utf8.hpp +++ b/components/to_utf8/to_utf8.hpp @@ -21,6 +21,7 @@ namespace ToUTF8 // Convert the previously written buffer to UTF8 from the given code // page. std::string getUtf8(FromType from); + std::string getLegacyEnc(FromType to); } #endif diff --git a/extern/shiny b/extern/shiny index 4750676ac..ffd078843 160000 --- a/extern/shiny +++ b/extern/shiny @@ -1 +1 @@ -Subproject commit 4750676ac46a7aaa86bca53dc68c5a1ba11f3bc1 +Subproject commit ffd078843c11586107024ccbc2493d0ec2df896c diff --git a/libs/openengine/bullet/BtOgreExtras.h b/libs/openengine/bullet/BtOgreExtras.h index f3e1aa87a..423924eda 100644 --- a/libs/openengine/bullet/BtOgreExtras.h +++ b/libs/openengine/bullet/BtOgreExtras.h @@ -206,6 +206,8 @@ public: } mLineDrawer->setMaterial("BtOgre/DebugLines"); + + mLineDrawer->setVisibilityFlags (1024); } ~DebugDrawer()