kieranmillar
Level: Smitemaster
Rank Points: 3778
Registered: 07-11-2014
IP: Logged
|
Re: Undo hides exploration (+5)
Been code-diving into this. Yuck. We refactored how map state is tracked when implementing minimap icons, it used to be a series of booleans, but is now a single enum. Ideally, the room can be in one of 5 states, in the following order of preference:
1) Explored - This means the room is shown in full on the map. Happens when you enter a room, pick up a full reveal map item, or use the script command to add the room to the map fully revealed.
2) Preview - Room is shown full on the map, but dimmed. Implies you have explored the room on a previous playthrough.
3) No Detail - Room is just a faded white square, like when you pick up a normal map item.
4) Invisible - Added due to the minimap icon feature, stating the room still needs to exist for its data, but is not to be drawn on the map yet.
5) Not present - Not a real map state, but listed for completeness. A room that has never been interacted with by this player doesn't show up in any saved games, only in the level data.
We want the rooms to always be the best state that we've ever seen them in, with one exception; Explored should only ever be for rooms explored in the current game, we want explored rooms in previous playthroughs to be downgraded to a preview if we've not explored it yet this session.
So how do we even know which rooms we've seen in previous playthroughs? Incredibly, when we load a game, we also load every other saved game the player has for that hold (except highscore demos waiting to be sent to CaravelNet, which is a special type of save game), and loop through every single one, to check for what rooms it has seen, which is crazy!
To make things a little funnier, one of the special "invisible" save games we keep per player per hold is one called ST_PlayerTotal, this is used to keep a tally of all rooms we've explored, so the number can be shown in the bottom-left of the load game (restore) screen. That's right, we have a special saved game whose whole purpose is to keep a record of what rooms we've seen. However we don't store map state in this saved game, just a list of room ids.
So the current system is inefficient, but it works, so what's the issue? The problem for this thread specifically is with undoing.
Undoing room state changes is a little awkward. We need to undo room data for minimaps. They are room data, and we have to be able to undo a script command to change the minimap icon. But what else needs to be undone? For example, if I pick up a normal map item to turn the rest of the level into white squares, then undo, should we undo this? I think there's an argument that the answer is actually no, the minimap is a weird "best of" that persists across game states, once a room is on the map, it should stay there forever (to a maximum of preview state).
Due to the confusing way we currently handle the minimap states, trying to patch the current explored room list with the best states from all other saved games, the bug this thread is about is us "downgrading" room states when undoing to the one for the current game, not the best of all games. So rooms with minimap icons that we haven't explored yet are "Invisible" for the current game state, even though the best of all worlds says it should be a preview. We lose this information when undoing as part of a way to maintain the integrity of the current game state.
This has really all come about because the way this is done is quite confusing. Sadly, the best of all worlds for the minimap isn't solely a front end concern, it affects what rooms we can quick travel to, what rooms we can scroll to when previewing rooms remotely, and what we can click on the map.
What I'm thinking we should do, is make a special save game, or extend the current ST_PlayerTotal, to track the "best of" state for each room in the hold. Every time we update a room state, we can also look at the room state in that saved game, and upgrade it if it's better (except Explored, the special saved game will only ever be Preview). We can load this on a load game and maintain a pointer to it, save it whenever we update it, and every time we actually care about the historical data, we can cross-reference its list, and keep the integrity of the current game room states intact. Don't try to merge the two, when we need to draw the map, just take which ever list has the better state, and use that for drawing.
The problem with this is this is a rework of how we currently do it, and so existing player profiles would suddenly lose sight of all their historical room states. Maybe we could have a special import process for RPG 1 profiles that updates ST_PlayerTotal one time by reading all previous saved games like we currently do, and player profiles imported from the demo beta will just lose it, it was a beta, too bad.
This would have to be done before release though, and time's ticking!
[Last edited by kieranmillar at 06-28-2025 03:11 PM]
|