Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisias committed Oct 8, 2020
1 parent 48ed4e9 commit 730f597
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
9 changes: 6 additions & 3 deletions KNOWN_ISSUES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# FMRS :: Known Issues

* I could not make the thing to work on Unity5, ruling out KSP \<= 1.3.1
+ See [this code](https://github.com/net-lisias-kspu/FMRS/blob/e6008f51fc60dc2608de78b11fb44cd2daa85aae/Source/FMRS/FMRS_Util.cs#L206) (link to github) for a full explanation for this problem.
- I'm bafled. =/
* There's a nasty problem (probably a stack overflow on OnAwake) affecting Unity 5 and 2017 that played havoc with the KSPe logging.
+ Heavy disk I/O may aggravate the problem.
+ This was the real issue when I first realised the problem on [this code](https://github.com/net-lisias-kspu/FMRS/blob/e6008f51fc60dc2608de78b11fb44cd2daa85aae/Source/FMRS/FMRS_Util.cs#L206).
+ This can affect also [1.4.0 \<= KSP \<= 1.7.3], so Unity 2017 also have the problem
+ Unity 2019 (KSP \>= 1.8) **is not affected**.
+ Complete history on [KSPe's Issue #7](https://github.com/net-lisias-ksp/KSPAPIExtensions/issues/7)
22 changes: 0 additions & 22 deletions Source/FMRS/FMRS_Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,28 +203,6 @@ public void set_save_value(save_cat cat, string key, string value)
{
Log.dbg("!ContainsKey {0}, {1}, {2}", cat, key, value);
Log.dbg("Save_File_Content[{0}] check = {1}", cat, Save_File_Content.ContainsKey(cat));

/*
* Believe it of not, the line ahead was crashing KSP **on the spot!**
*
* Behaviour detected on KSP 1.3.1 (Mono 3.5, Unity5). Same for KSP 1.2.2.
*
* On KSP 1.4 (Mono 3.5, Unity 2017) things work fine!
*
* I tried many different solutions, but all I managed to do is to delay the crash to the next occurence of
* the Dictionary access. It's not a concurrency problem, I refactored all the access to the Save_File_Content
* and protected them on a critical section, no dice.
*
* This code is here since commmit 826baad (2014-0812), we are talking KSP V0.90 or older here. This could not pass unoticed
* all these years, the damn thing is crashing my KSP on Awake (on Main Menu), God Damnit!
*
* I don't have the slightest idea about what's happening, but it appears to be Unity5 related and I'm guessing it's something
* related to me using a MacOS machine for development (could not think on any other reason, and on Unity2017 I can't compile
* against the KSP/MAC Managed DLLs or the thing will not work on Windows, while by compiling using the Windows DLLs the damned thing runs
* on everything, including Macs.
*
* In a way or another, I'm dropping KSP 1.3.1 for while.
*/
Save_File_Content[cat].Add(key, value);

}
Expand Down
34 changes: 32 additions & 2 deletions Source/FMRS/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,70 @@ namespace FMRS
{
public static class Log
{
#if UNITY2019
private static readonly Logger log = Logger.CreateForType<Startup>();

#endif
internal static void force(string msg, params object[] @params)
{
#if UNITY2019
log.force(msg, @params);
#else
if (null != @params && @params.Length > 0) UnityEngine.Debug.LogFormat(msg, @params);
else UnityEngine.Debug.Log(msg);
#endif
}

[ConditionalAttribute("DEBUG")]
internal static void info(string msg, params object[] @params)
{
#if UNITY2019
Log.info(msg, @params);
#endif
}

[ConditionalAttribute("DEBUG")]
internal static void warn(string msg, params object[] @params)
{
#if UNITY2019
log.warn(msg, @params);
#endif
}

[ConditionalAttribute("DEBUG")]
internal static void detail(string msg, params object[] @params)
{
#if UNITY2019
log.detail(msg, @params);
#endif
}

[ConditionalAttribute("DEBUG")]
internal static void error(Exception e, object offended)
{
#if UNITY2019
log.error(offended, e);
#else
UnityEngine.Debug.LogException(e);
#endif
}

[ConditionalAttribute("DEBUG")]
internal static void error(string msg, params object[] @params)
{
#if UNITY2019
log.error(msg, @params);
#else
if (null != @params && @params.Length > 0) UnityEngine.Debug.LogErrorFormat(msg, @params);
else UnityEngine.Debug.LogError(msg);
#endif
}

[ConditionalAttribute("DEBUG")]
internal static void dbg(string msg, params object[] @params)
{
#if UNITY2019
log.trace(msg, @params);
#endif
}

#if DEBUG
Expand All @@ -87,7 +115,9 @@ internal static void dbgOnce(string msg, params object[] @params)
if (DBG_SET.Contains(new_msg)) return;
DBG_SET.Add(new_msg);
#endif
#if UNITY2019
log.trace(new_msg);
#endif
}

[ConditionalAttribute("DEBUG")]
Expand Down Expand Up @@ -122,8 +152,8 @@ public static void PopStackInfo(string msg)
}
else
Log.warn("Pop failed, no values on stack");
#endif
Log.detail(msg);
#endif
}
}
}

0 comments on commit 730f597

Please sign in to comment.