MV Core glitch Savefile index

as the title said, I believe there is a bug or glitch in the core file on savefile index.

what do I mean with that, (as I'm clueless here)

while plugin can alter the amount of saves (default 20) it can be fine, but the bug/glitch here
is very ANNOYING.

once you start a game, save the game and save it on slot 5.
now, if you continue, it select this file just fine.

now, rewind to the title scene, select new game, and save, now the index start on 6!

why 6? why not 1 for this reason?

is there any way to select 1 if you start a new game? and how can you reset that?
(easy to replicate (1.6.1 version of MV)
I think it is a feature.
When you start a new game it just find the max save id + 1 as the default slot.
Unless the file is already the last one, it will try to start from 1.
If all slots have saves, it will find the oldest save (with smallest timestamp).

I think it makes sense to me, but if you don't like, you can edit
DataManager.selectSavefileForNewGame to always search for empty slot or something like that.
Spoiler: a reply for MZ
You could try this short plugin (untested):
JavaScript:
/*:
 * @target MZ
 * @plugindesc Minimise emptySavefileId slot index.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/176194/
 * @help Free to use and/or modify for any project, no credit required.
 */
// Override!
DataManager.emptySavefileId = function() {
  const max  = this.maxSavefiles() + 1;
  const slot = this._globalInfo.slice(1, max).findIndex(x => !x);
  return slot >= 0 ? slot + 1 : -1;
};
I.e. "return the first empty save slot from 1 to max, or -1 if all slots are filled".

[Edit: wait no, this thread is tagged MV, sorry. 😴]
This is the vanilla version of RPGmaker?

It is not doing this with a test project I made.
(No other plugins added)
Edit: wait no, this thread is tagged MV, sorry. 😴]
I believe I saw this one before, so no worries.

This is the vanilla version of RPGmaker?

It is not doing this with a test project I made.
(No other plugins added)
this is vanilla project and with TSR_Save that I help others with.

it always go to the next index, rather starting from 1.

because if it has saved in index 8, delete savefile => new game => save index = 9
instead of 0, so this doesn't make sense to me.
Gotcha.
I'm not at my PC now, but if no one responds with a fix by then, I'll look into this
It SEEMS like it'll be a simple fix.
Key phrase: AND with the other plugin. That makes it not a core bug. Especially as others posted they are not replicating it.

You should focus on fixing the other plugin.
I'm not at my PC now, but if no one responds with a fix by then, I'll look into this
It SEEMS like it'll be a simple fix.
if your at home, the ideal fix if your able too (alias/rewrite) would be this:

new game => save => save id = 1 (default)
new game => save on save id 9 = > (1~8 empty), new game should be 1
so its the first empty slot available.

rather than last savefile +1 as it never resets if no file exists.

loadgame is basicly the same, so it shouldn't mess there, which takes the
last saved file, its just purely the new game that mess up the slot id if all is empty.

Key phrase: AND with the other plugin. That makes it not a core bug. Especially as others posted they are not replicating it.
it IS a core bug because no save file should start at 0 if last save file = 6 and no
file exist anymore, no need to go to 7, but 1 instead.

this is WITHOUT any plugin.
I believe I saw this one before, so no worries.


this is vanilla project and with TSR_Save that I help others with.
You admit here it is not a blank project. Test it with NO OTHER PLUGINS AT ALL.

Also many computers start at 0 not 1. 0 I believe is for the autosave. ACE and even older ones started at 0 as that is standard computer notation.

You will need to fix the other plugin to adjust for starting at 0.
You admit here it is not a blank project. Test it with NO OTHER PLUGINS AT ALL.
if you read it, I did it in BOTH "VANILLA" and WITH TST_Save and BOTH cases happens.

vanilla start => save game => save slot 1, but select save id 8 => delete saves and
do new game.

new game => save => start with save slot 9 (CLEAN VANILLA)!


edit:
sorry for the attitude earlier, but it was tested with both and without in a vanilla project.
All done!

Please dl the plugin snippet below and add it to the top of your plugins
LINK - Pastebin

edit:
sorry for the attitude earlier, but it was tested with both and without in a vanilla project.
As long as you realize you WERE coming off a bit spicy.
We're all here to help each other.
You won't go far here if you approach us with a foul attitude.
(I only say this to you because I know you are better than that.)

Thanks to @utunnels for pointing out the function to edit.
I can guess why it happens. The engine doesn't expect you delete a save.
When the plugin deletes a save, it doesn't shrink the array of the saves infos (stored in global info).
For example, if you have only one save on slot 5, the array's length is 5. If you delete it, the array's length is still 5 (just 5 empty elements). You can manually fix that in DataManager.loadGlobalInfo, or DataManager.selectSavefileForNewGame to always check from the first slot.
Thank you to @Maliki79. I have noticed that my projects do something similar what ShadowDragon described, but by the time that there is enough gameplay to be worth saving, many of the plugins that I intend to use are installed. When playtesting, if I do anything that might disturb the code used or assigned memory, such as add a new plugin or increase the maximum common events, I like to start a new game. Sometimes I use different saves to be convenient to playtest events in different areas. In short, I end up with quite a few saves, some of which should not be used.

One thing that I have noticed is that when I deployed, the deployed versions don't come with either previous saves or save history, which was a relief.

I will try this plugin very soon, as I want to get passed a certain map in the current playtest that I have worked on recently first.

Edit: Tried the plugin. It works on my current project. 🙂
As long as you realize you WERE coming off a bit spicy.
it was a bit overreacted as I wasn't clear enough.

I test it quickly with few saves => continue => works
(kept saves 1-6 empty for new game) new game => first empty was 1 => works.

1-3 saves, 5-7 saves => new game => first slot 4 (works)

this was basic tests, but it seems to do it's jobs correctly now.
thanks for the fixing it 🙂


I can guess why it happens. The engine doesn't expect you delete a save.
When the plugin deletes a save, it doesn't shrink the array of the saves infos (stored in global info).
that's why I think it was a glitch/bug in the core file as why select a later file +1
if the previous or the first one is empty?

I tried to fix, but got more errors and didn't mess with global info's, so I didn't
understand it, it should be by default if you ask me though.

Thank you for your help Mailiki79/untunnels 🙂
Happy to help and it indeed seems to be a bug, albeit a difficult one to encounter without actively TRYING to find it. 🙂
But yeah, I'm def gonna add the fix to my project as well.
(I wonder if it does that in MZ too...?)
This thread is closed due to being reported as solved. If you need it reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/core-glitch-savefile-index.176194/