public void ResetVM()
{
VMNetDriver driver;
driver = new VMServerDriver(Port, NetClosed);
var vm = new VM(new VMContext(null), driver, new VMNullHeadlineProvider());
state = vm;
vm.Init();
vm.OnChatEvent += Vm_OnChatEvent;
var path = Settings.Default.GamePath + "housedata/blueprints/" + Settings.Default.DebugLot;
string filename = Path.GetFileName(path);
try
{
//try to load from FSOV first.
LoadState(vm, "Content/LocalHouse/" + filename.Substring(0, filename.Length - 4) + ".fsov");
}
catch (Exception)
{
try
{
Console.WriteLine("Failed FSOV load... Trying Backup");
LoadState(vm, "Content/LocalHouse/" + filename.Substring(0, filename.Length - 4) + "_backup.fsov");
}
catch (Exception)
{
Console.WriteLine("CRITICAL::: Failed FSOV load... Trying Blueprint (first run or something went wrong)");
short jobLevel = -1;
//quick hack to find the job level from the chosen blueprint
//the final server will know this from the fact that it wants to create a job lot in the first place...
try
{
if (filename.StartsWith("nightclub") || filename.StartsWith("restaurant") || filename.StartsWith("robotfactory"))
jobLevel = Convert.ToInt16(filename.Substring(filename.Length - 9, 2));
}
catch (Exception) { }
vm.SendCommand(new VMBlueprintRestoreCmd
{
JobLevel = jobLevel,
XMLData = File.ReadAllBytes(path)
});
vm.Context.Clock.Hours = 10;
}
}
vm.MyUID = uint.MaxValue-1;
vm.SendCommand(new VMNetSimJoinCmd
{
ActorUID = uint.MaxValue - 1,
Name = "server"
});
}