Record Cloning
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Record Cloning
Is there no risk of conflicts in case of adding new dependency to the content file?
Re: Record Cloning
You can not add a dependency without re-loading the content file list and these IDs don't persist across save/load cycles. They exist purely to make each reference uniquely identifiable within an editing session.
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Record Cloning
That makes sense.
Ok, after getting some sleep I see where is the problem.
My cloneRecord method in the table is basicly copy-paste of editRecord and it uses getUniversalId function. Unofortunatly, said function calls constructor CSMWorld::UniversalId::UniversalId (Type type, const std::string& id). This works just fine for some of the tables, however it triggers exception
throw std::logic_error ("invalid ID argument UniversalId type");
In others (references, topics, journals, journal infos) for both edit action, and clone action. Is there something missing or this is unknown bug?
It prevents me from finishing my task, so I would like to fix it, if possible.
Ok, after getting some sleep I see where is the problem.
My cloneRecord method in the table is basicly copy-paste of editRecord and it uses getUniversalId function. Unofortunatly, said function calls constructor CSMWorld::UniversalId::UniversalId (Type type, const std::string& id). This works just fine for some of the tables, however it triggers exception
throw std::logic_error ("invalid ID argument UniversalId type");
In others (references, topics, journals, journal infos) for both edit action, and clone action. Is there something missing or this is unknown bug?
It prevents me from finishing my task, so I would like to fix it, if possible.
Re: Record Cloning
Found the problem. apps/opencs/model/world/data.cpp CSMWorld::Data::Data. As you can see this function adds the colums to the various ID collections. The record type information (via FixedRecordTypeColumn) is expected in column 2 (actually we moved away from fixed column numbers, but that is a fix for another day). Unfortunately some of the collections seem to be still missing the column and that is why you can't get the type from rows in these tables.
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Record Cloning
I want to implement that. Should I start new branch or is it ok to do this in cloning?
Re: Record Cloning
Doing it in the cloning branch is okay. Only a very minor fix after all.
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Record Cloning
Damn. Damn.
I just realized that cloning will not work when creating a new addon.
This code throws throw std::logic_error ("invalid local index type") because it seems to be unable to find RefIdDataContainerBase with proper type key. However, this works when editing existing file. In fact I'm also able to clone when creating new addon, but only records that I add myself with add command.
Is is somehow related to the fact that IDs are not displayed when editing exisiting file?
PS
Excatly this line gives me the problem as it seems:
I just realized that cloning will not work when creating a new addon.
Code: Select all
int CSMWorld::RefIdData::localToGlobalIndex (const LocalIndex& index)
const
{
std::map<UniversalId::Type, RefIdDataContainerBase *>::const_iterator end =
mRecordContainers.find (index.second);
if (end==mRecordContainers.end())
throw std::logic_error ("invalid local index type");
int globalIndex = index.first;
for (std::map<UniversalId::Type, RefIdDataContainerBase *>::const_iterator iter (
mRecordContainers.begin()); iter!=end; ++iter)
globalIndex += iter->second->getSize();
return globalIndex;
}
Is is somehow related to the fact that IDs are not displayed when editing exisiting file?
PS
Excatly this line gives me the problem as it seems:
Code: Select all
const CSMWorld::UniversalId& toClone = getUniversalId(selectedRows.begin()->row());
Re: Record Cloning
I am not aware of this problem.Is is somehow related to the fact that IDs are not displayed when editing exisiting file?
There shouldn't be any difference between records from the currently edited content file and dependency content files.
- sirherrbatka
- Posts: 2159
- Joined: 07 Aug 2011, 17:21
Re: Record Cloning
http://wstaw.org/m/2014/01/23/zrzut69.png
This demonstrate said issue. Can you try to replicate this? Simply try to create a new addon for morrowind.esm using opencs.
This demonstrate said issue. Can you try to replicate this? Simply try to create a new addon for morrowind.esm using opencs.
Re: Record Cloning
Confirmed. Well, we figured out that there are bugs in the container for referencables a while back (I think you posted the bug report yourself). It is not surprising that this bug shows up in other usage scenarios.