Make empty-server restarts configurable in the mission menu
Add persistent last-disconnect and idle-interval controls with enabled/five-hour defaults. Apply saved settings immediately, reset idle time while occupied, and cover migration, routing, layout and restart behavior.
This commit is contained in:
@@ -55,6 +55,27 @@ int main(){
|
||||
assert(!ERR_Settings::Randomizable("startMode")&&!ERR_Settings::ValidSelection("startMode",-1)&&!ERR_Settings::ValidSelection("startMode",-2));
|
||||
disk["old"]={{"reportIntervalSeconds",10},{"supportSquadLimit",4},{"responseRadiusMetres",2000},{"aiIntelChancePercent",60},{"intelRevealChancePercent",15},{"radioDefenceSeconds",180}};
|
||||
ERR_Settings settings;assert(settings.Read("old",settings.m_Values)&&settings.Get("startMode")==0);
|
||||
// Older configurations gain the enabled/five-hour defaults. Each restart
|
||||
// setting survives a save/reload, while invalid selections cannot change it.
|
||||
for(string key:{"restartOnEmpty","emptyRestartHours"}){
|
||||
int expected=key=="restartOnEmpty"?1:5;
|
||||
assert(ERR_Settings::AddedDefault(key)==expected&&settings.Get(key)==expected);
|
||||
assert(!ERR_Settings::Randomizable(key));
|
||||
for(float bad:{-2.f,-1.f,.5f,169.f}){
|
||||
disk["bad"]=disk["old"];disk["bad"][key]=bad;Values ignored;
|
||||
assert(!settings.Read("bad",ignored));
|
||||
}
|
||||
int choice=key=="restartOnEmpty"?0:168;
|
||||
assert(settings.Set(key,choice));
|
||||
ERR_Settings restored;assert(restored.Read("settings",restored.m_Values));
|
||||
assert(restored.Get(key)==choice);
|
||||
failSave=true;assert(!settings.Set(key,expected));failSave=false;
|
||||
assert(settings.Get(key)==choice);
|
||||
assert(settings.Set(key,expected));
|
||||
}
|
||||
int restartSelection=-1;
|
||||
assert(ERR_CommandArguments::Selection("restartOnEmpty","on",restartSelection)&&restartSelection==1);
|
||||
assert(ERR_CommandArguments::Selection("restartOnEmpty","off",restartSelection)&&restartSelection==0);
|
||||
for(float bad:{-1.f,-2.f,2.f,.5f}){disk["bad"]=disk["old"];disk["bad"]["startMode"]=bad;Values ignored;assert(!settings.Read("bad",ignored));}
|
||||
|
||||
// Newly introduced doctrine choices migrate safely and survive the same transaction.
|
||||
|
||||
Reference in New Issue
Block a user