I was thinking of writing a python script for this with a "for" loop that incremented the Version automatically after deleting / wiping the info. Example:
Find tunnel info and all versions associated with it
Delete all rows associated with that modfication (noted by the level flag of 22 and the versions before that that change from 60000 decrementing to 0)
reset all "Version" entries to 0 for the TerID associated with the tunnel
Use python script or SQL query to increment the entries from 1 to X (max entries for that TerID)
Change Version entry in terrain_blocks to reflect new Version Max entry
Would that work? Seems like it would. Maybe just a simple SQL query would work too, but I couldn't find a simple enough one that did the incrementing job.
I tried something like the following but kept getting a syntax error:
- Code: Select all
SET @newver := 0;
UPDATE geo_patch
SET Version = (@newver := @newver + 1)
WHERE TerID= xxx
ORDER BY id;
Not a pro at SQL so if you see something horribly wrong, let me know
EDIT: OK so I noticed where and why this wouldn't work, but working on a new plan using this as a basis
EDIT 2: Alright so I think I got it. It's a bit time consuming, but it seems to work.
Steps:
Find out the geodataid of the tile you want to work with by standing on it in the game. Find that id in the database and delete everything for it except the changeindex 1 entry. I then ran the following SQL queries:
- Code: Select all
UPDATE geo_patch SET Version = 1 WHERE TerID = XXX;
Where the TerID matches whatever ID your geodataid is in. I then ran the following SQL query:
- Code: Select all
SET @newver := 1;
UPDATE geo_patch SET Version = (@newver := @newver +1) WHERE TerID = XXX AND ChangeIndex = 1;
This gives me an accurate number of total changes made for the terrain ID that I'll put into the terrain_blocks table. Now, if it hasn't been very long since you made the tunnel and now decided you want to get rid of it, the amount of fixing the matching changeindex 2s 3s 4s, etc should be minimal. You'll have a bunch of version 1s left in the DB if your tunnel was big with changeindexes above 1. You'll need to match these based on ID and geodataid to see what version they need to be assigned. This is where I need to make a SQL query that will take the version as a variable from the current id - 1 and set the version to that number. Example:
id 202 terid 449 version 1 changeindex 2 geodataid 11771773
id 201 terid 449 version 567 changeindex 1 geodataid 117771773
id 202 should be version 567 to match, but it's not. I need a SQL query that will go "take version 567 from id 201 and set id 202 version to 567, if that makes sense. I'm sure I could write a Python script to do that (or all of this), but I'm trying to keep it SQL only for now. There are some functions and procedures in this DB, so it should be doable, I've just not done that before with MySQL.
Now, I had a tunnel system that started in TerID 446 and apparently went into TerID 449, so just editing the tile for the tunnel entrance didn't work. However finding the info for the actual tunnel tiles looks like it holds the data for ALL the adjoining tunnels, but I can't be sure. You may have to edit all the information each time per TerID your tunnel spans, or you may have to edit out each tile. Haven't researched that far.
I invite anyone to also try this out and let me know if I'm way off base