Record Cloning

Involved development of the OpenMW construction set.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka »

Is there no risk of conflicts in case of adding new dependency to the content file?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini »

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.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka »

That makes sense.

Ok, after getting some sleep :lol: 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.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini »

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.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka »

I want to implement that. Should I start new branch or is it ok to do this in cloning?
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini »

Doing it in the cloning branch is okay. Only a very minor fix after all.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka »

Damn. Damn.

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;
}
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:

Code: Select all

const CSMWorld::UniversalId& toClone = getUniversalId(selectedRows.begin()->row());
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini »

Is is somehow related to the fact that IDs are not displayed when editing exisiting file?
I am not aware of this problem.

There shouldn't be any difference between records from the currently edited content file and dependency content files.
User avatar
sirherrbatka
Posts: 2159
Joined: 07 Aug 2011, 17:21

Re: Record Cloning

Post by sirherrbatka »

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.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Cloning

Post by Zini »

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.
Post Reply