Do I HAVE to use <update> or can I completely overwrite an XML file?

Kruelgor

Emperor
Joined
May 12, 2010
Messages
1,165
Location
The United States
Do I HAVE to use the <update> and <delete> commands, or can I instead just completely write new XML code from scratch and overwrite existing files?

To avoid conflicts, I would prefer to avoid using the <update> tags and just overwrite XML files with brand new code.

Does anyone know if this is possible? Will it work? Anything special I need to know to make it work properly?

Thanks in advance
 
I used delete function for my mod and it works perfectly :P

P.S.
I haven't released it yet
 
But say I want re-write over the whole thing. I have to manually delete EVERYTHING line by line?! That's a shame if true.

No. There are ways to make an open-ended Delete. If you say <Delete Type="UNIT_SETTLER"/>, then it'll delete the settler unit, but a <Delete /> should wipe out the whole table (although it doesn't work on every type of table). Since Delete and Where commands use an inherent "AND" syntax, having no conditions set means every entry succeeds in the check.

Then, you can just use a <DeleteMissingReferences Table="Units" Column="Type"/> command; it'll go through the Units table, find any entries that have had the Type removed/unset (which in this case is all of them) and remove any entries in any OTHER tables that refer to those entries. This'll wipe out all of those other little tables later in the file, plus any related entries in other files (like the civilization UU definitions).

The only catch is that deletion tends to not work well for certain entry types, because of how the <ID> field increments. But if you're effectively rebuilding the entire file from scratch, that's not as much of an issue, as long as you remember to restart the count.
Also, you're not ACTUALLY replacing the entire file. You're using <Row> entries instead of <Update> entries, sure. But you can't change the table definition at the top of the file this way.
 
Back
Top Bottom