FOnline: Reloaded

Development => The Workshop => Topic started by: Mickmelon on August 17, 2018, 12:46:23 am

Title: WorldEditor Fixed
Post by: Mickmelon on August 17, 2018, 12:46:23 am
I came across an issue when using the WorldEditor tool. Loading it first time worked, but when you close it and re-open it crashed. Deleting the cache.dat file was a simple work-around. I dived into the code and discovered the issue in Cache.cs. It looks like the DateTime was being saved into cache.dat in multiple region formats. For example, one record had 16/3/13 while the other had 3/16/13

Here's another thread showing the same issue I had: https://forum.fonline-reloaded.net/index.php?topic=10870.0

Download: https://drive.google.com/file/d/1f7eMUjZtU4NGMnK1ruSD7UTGIWnhoOdg/view

Manual Fix:
Change these lines in Cache.cs - all we are doing is adding checks to ensure it's in the correct format ("M/d/yyyy h:mm:ss tt")
Line 54:
Code: [Select]
_mapHeaders[param[1]] = new MapHeaderCache(DateTime.ParseExact(param[2], "M/d/yyyy h:mm:ss tt", CultureInfo.InvariantCulture), param[3], param[4], param[5], param[6] == "1");

Line 64-65:
Code: [Select]
sw.WriteLine(String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", (int)CacheType.MapHeader, kvp.Key, kvp.Value.LastWriteTime.ToString("M/d/yyyy h:mm:ss tt"), kvp.Value.Data.ScriptFunc,
                    kvp.Value.Data.ScriptModule, kvp.Value.Data.Time, (kvp.Value.Data.NoLogOut == true ? "1" : "0")));

Don't forget to compile it and delete cache.dat before running it first time as it may still contain invalid dates.