Set default value for Environmental Value

I want to set a default value for an environmental variable, but there seems to be no way to do this. It seems to default to the first option provided to it, so I solved this problem as follows:

environ_cb = cb;
// TODO: Sets the default value to 4, this is very hackish, but there doesn't seem to be a better way.
retro_variable vars[] = {
        { "sfb_max_players", "Maximum number of players allowed (Requires restart); 4|2|3|1|5|6|7|8" },
        { nullptr, nullptr },
};
cb(RETRO_ENVIRONMENT_SET_VARIABLES, vars);
vars[0] = { "sfb_max_players", "Maximum number of players allowed (Requires restart); 1|2|3|4|5|6|7|8" };
cb(RETRO_ENVIRONMENT_SET_VARIABLES, vars);

The code should give sfb_max_players the option of 1,2,3,4,5,6,7, or 8, with 4 being the default value. The solution I chose is very hacky, is there a better solution?

why would you want to change it from source? you just have to choose what option you wanted and the next time you launch core, this will restore your last setting.

Because I want 4 to be the option that is returned on RETRO_ENVIRONMENT_GET_VARIABLE if nothing has been set by the user.

The problem is that the first time RETRO_ENVIRONMENT_SET_VARIABLES is called it sets the value to the first option in the list, which is not what I want. There should be a self contained way to do this in the framework, without telling the user which values should be set by default.

Imagine the following use case:

retro_variable vars[] = {
        { "use_experimental_features", "Uses experimental features that might cause the core to crash; enabled|disabled" },
        { nullptr, nullptr },
};

In this case the default value might break the core.

for the longest time i have been modifying some of the cores, there has not been an issue that the dafault is always and still initialized first if you already have set this at least once. you probably have overrides or something or something is re-initializing whatever variable that option was suppose to set after this was called.