Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DELE sub-record handling #678

Merged
merged 50 commits into from Nov 14, 2015
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
926c825
Add NAME and DELE handling to ESM records.
smbas Jul 7, 2015
9ac20a3
Add NAME and DELE handling to ESM records.
smbas Jul 7, 2015
d2c1564
Add NAME and DELE handling to Script record
smbas Jul 7, 2015
19ac4e9
Change DELE sub-record value to 0 (4 bytes)
smbas Jul 7, 2015
0b53718
Add NAME and DELE handling to Dialogue record
smbas Jul 7, 2015
847614c
Add DELE handling to Info record
smbas Jul 7, 2015
b667338
Add NAME and DELE handling to Cell record
smbas Jul 7, 2015
8c3654a
Add NAME handling to Race record
smbas Jul 7, 2015
30b42bf
Remove redundant code
smbas Jul 7, 2015
09a3358
Add NAME and DELE handling to Global record
smbas Jul 7, 2015
b2f3ccb
Add NAME handling to GameSetting record
smbas Jul 8, 2015
89e44c8
Remove explicit record ID in load/read methods of MWWorld::Store
smbas Jul 8, 2015
9301bc1
Remove NAME handling from MWWorld::ESMStore
smbas Jul 8, 2015
897a52c
Remove NAME handling from MWWorld::Globals
smbas Jul 8, 2015
00bf87b
Convert IDs of loaded records to lower case in MWWorld::Store
smbas Jul 9, 2015
2072358
Letter case fix for MWWorld::Globals
smbas Jul 9, 2015
7ecb54a
Set Deleted flag to false when initializing ESM records
smbas Jul 9, 2015
e0983c8
Some fixes for ESM Dialogues and Infos
smbas Jul 11, 2015
adec0cb
Add removing of deleted Infos to Dialogue::clearDeletedInfos()
smbas Jul 11, 2015
2ed182b
Update to upstream/master. Resolve merge conflicts in MWWorld::Store
smbas Jul 12, 2015
c266315
Load/read methods in MWWorld::Store return a pair (record ID, deleted…
smbas Jul 12, 2015
42f9136
Remove DELE and NAME handling from RefIdCollection and RefIdData
smbas Jul 12, 2015
74a055f
Remove NAME and DELE handling from IdCollection
smbas Jul 13, 2015
c8c79dc
Move ID loading into a separate method for Dialogue and DialInfo records
smbas Jul 13, 2015
71e5fc7
Remove INAM handling from InfoCollection
smbas Jul 13, 2015
b55a499
Add NAME handling to DebugProfile and Filter records
smbas Jul 13, 2015
5e623a2
Rework RefIdData code. Update the index map when a new record is loaded
smbas Jul 14, 2015
a1389b8
Return a correct index for a loaded record that was deleted
smbas Jul 14, 2015
e8a9567
Move DELE handling to CellRef record
smbas Jul 15, 2015
3ba73f5
Handle deleted records in RefCollection
smbas Jul 15, 2015
ad353e6
Refine DELE handling in ESM records. Add position-independent DELE se…
smbas Jul 16, 2015
e65ff72
More ESM records have DELE handling.
smbas Jul 16, 2015
5fd48ef
Some refactoring. Remove unused code
smbas Jul 16, 2015
a4d3e59
Add a separate method to check whether a record is deleted or not for…
smbas Jul 18, 2015
e04e32b
Delete infos of deleted dialogue when loading a content file
smbas Jul 18, 2015
8e6a7be
Implement saving of deleted records
smbas Jul 19, 2015
ede4bfc
Rework EsmTool code. Remove explicit NAME handling
smbas Jul 19, 2015
6b21da7
Rework ESS importer code. Remove explicit NAME handling for ESM records
smbas Jul 19, 2015
f574574
Remove <cstdint> include file from loaddial.cpp
smbas Jul 19, 2015
1e81822
Fix build errors & warnings
smbas Jul 19, 2015
4a16eba
Make deleted flag a parameter of load/save methods (instead of a reco…
smbas Jul 20, 2015
67c8f95
Load/read methods (for ESM records) accept a deleted flag in OpenMW
smbas Jul 21, 2015
13bb6be
Load methods (for ESM records) accept a deleted flag in OpenCS
smbas Jul 21, 2015
8243fb2
Load methods (for ESM records) accept a deleted flag in ESMTool
smbas Jul 21, 2015
0c6ab6c
Load methods (for ESM records) accept a deleted flag in ESSImporter
smbas Jul 21, 2015
daaff12
Remove unused includes
smbas Jul 22, 2015
9a8ca81
Fix missing break in switch statement
smbas Jul 26, 2015
f9b0b7e
Make saving of deleted ESM records more consistent
smbas Jul 28, 2015
f15adb4
Store::load() overwrites loaded records with the same IDs
smbas Jul 30, 2015
d13766c
Remove redundant template specializations
smbas Jul 30, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
97 changes: 43 additions & 54 deletions apps/esmtool/esmtool.cpp
Expand Up @@ -27,7 +27,8 @@ struct ESMData
std::vector<ESM::Header::MasterData> masters;

std::deque<EsmTool::RecordBase *> mRecords;
std::map<ESM::Cell *, std::deque<ESM::CellRef> > mCellRefs;
// Value: (Reference, Deleted flag)
std::map<ESM::Cell *, std::deque<std::pair<ESM::CellRef, bool> > > mCellRefs;
std::map<int, int> mRecordStats;

static const std::set<int> sLabeledRec;
Expand Down Expand Up @@ -255,7 +256,7 @@ void loadCell(ESM::Cell &cell, ESM::ESMReader &esm, Arguments& info)
while(cell.getNextRef(esm, ref, deleted))
{
if (save) {
info.data.mCellRefs[&cell].push_back(ref);
info.data.mCellRefs[&cell].push_back(std::make_pair(ref, deleted));
}

if(quiet) continue;
Expand Down Expand Up @@ -352,61 +353,58 @@ int load(Arguments& info)
uint32_t flags;
esm.getRecHeader(flags);

EsmTool::RecordBase *record = EsmTool::RecordBase::create(n);
if (record == 0)
{
if (std::find(skipped.begin(), skipped.end(), n.val) == skipped.end())
{
std::cout << "Skipping " << n.toString() << " records." << std::endl;
skipped.push_back(n.val);
}

esm.skipRecord();
if (quiet) break;
std::cout << " Skipping\n";

continue;
}

record->setFlags(static_cast<int>(flags));
record->setPrintPlain(info.plain_given);
record->load(esm);

// Is the user interested in this record type?
bool interested = true;
if (!info.types.empty())
{
std::vector<std::string>::iterator match;
match = std::find(info.types.begin(), info.types.end(),
n.toString());
match = std::find(info.types.begin(), info.types.end(), n.toString());
if (match == info.types.end()) interested = false;
}

std::string id = esm.getHNOString("NAME");
if (id.empty())
id = esm.getHNOString("INAM");

if (!info.name.empty() && !Misc::StringUtils::ciEqual(info.name, id))
if (!info.name.empty() && !Misc::StringUtils::ciEqual(info.name, record->getId()))
interested = false;

if(!quiet && interested)
std::cout << "\nRecord: " << n.toString()
<< " '" << id << "'\n";

EsmTool::RecordBase *record = EsmTool::RecordBase::create(n);

if (record == 0) {
if (std::find(skipped.begin(), skipped.end(), n.val) == skipped.end())
{
std::cout << "Skipping " << n.toString() << " records." << std::endl;
skipped.push_back(n.val);
}
{
std::cout << "\nRecord: " << n.toString() << " '" << record->getId() << "'\n";
record->print();
}

esm.skipRecord();
if (quiet) break;
std::cout << " Skipping\n";
} else {
if (record->getType().val == ESM::REC_GMST) {
// preset id for GameSetting record
record->cast<ESM::GameSetting>()->get().mId = id;
}
record->setId(id);
record->setFlags((int) flags);
record->setPrintPlain(info.plain_given);
record->load(esm);
if (!quiet && interested) record->print();

if (record->getType().val == ESM::REC_CELL && loadCells && interested) {
loadCell(record->cast<ESM::Cell>()->get(), esm, info);
}
if (record->getType().val == ESM::REC_CELL && loadCells && interested)
{
loadCell(record->cast<ESM::Cell>()->get(), esm, info);
}

if (save) {
info.data.mRecords.push_back(record);
} else {
delete record;
}
++info.data.mRecordStats[n.val];
if (save)
{
info.data.mRecords.push_back(record);
}
else
{
delete record;
}
++info.data.mRecordStats[n.val];
}

} catch(std::exception &e) {
Expand Down Expand Up @@ -493,28 +491,19 @@ int clone(Arguments& info)
for (Records::iterator it = records.begin(); it != records.end() && i > 0; ++it)
{
EsmTool::RecordBase *record = *it;

name.val = record->getType().val;

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<ESM::Cell>()->get();
if (!info.data.mCellRefs[ptr].empty()) {
typedef std::deque<ESM::CellRef> RefList;
typedef std::deque<std::pair<ESM::CellRef, bool> > RefList;
RefList &refs = info.data.mCellRefs[ptr];
for (RefList::iterator refIt = refs.begin(); refIt != refs.end(); ++refIt)
{
refIt->save(esm);
refIt->first.save(esm, refIt->second);
}
}
}
Expand Down