Upgrading Mods to 0.10.25 and Later

Discuss modding questions and implementation details.
User avatar
Interkarma
Posts: 5826
Joined: Sun Mar 22, 2015 1:51 am

Re: Upgrading Mods to 0.10.25 and Later

Post by Interkarma »

Yeah, probably the enum. Following constructor signature doesn't raise that error in build.

Code: Select all

namespace DaggerfallWorkshop.Game.UserInterfaceWindows
{
    public partial class LGSTradeWindowText : DaggerfallTradeWindow, IMacroContextProvider
    {
        public LGSTradeWindowText(IUserInterfaceManager uiManager, DaggerfallBaseWindow previous = null)
            : base(uiManager, previous)
        {
            
        }
    }
}
I know that doesn't exactly help, but it's information. :)

User avatar
Magicono43
Posts: 505
Joined: Tue Nov 06, 2018 7:06 am

Re: Upgrading Mods to 0.10.25 and Later

Post by Magicono43 »

I only have that constructor so I can inherit from "DaggerfallTradeWindow", otherwise I would remove it, as you can probably tell, I pretty much go the Todd Howard route of "It Just Works" so I don't really have much of an idea how to get around this problem in that regard atm, lol.

But it's strange that suddenly that would be causing a problem in this new version, but not in 0.10.24. :?

User avatar
Interkarma
Posts: 5826
Joined: Sun Mar 22, 2015 1:51 am

Re: Upgrading Mods to 0.10.25 and Later

Post by Interkarma »

I also don't know why that would work in 0.10.24 and raise an error in 0.10.25. Hopefully TheLacus will loop back and have some insight.

User avatar
Ralzar
Posts: 1584
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Upgrading Mods to 0.10.25 and Later

Post by Ralzar »

Both me and Magicono are seeing some weird behaviour with mod loading. Me with Climates & Cloaks, him with the GoldShop mod. I also saw it with his PhysicalCombat mod yesterday.

This is all testing done today exclusively with the new 0.10.25a code:

1: Error is only visible if you use a built mod in the editor. Loose files will not produce the error.

2: The error happens during game load, after you click the "Play" button in the DFU launcher.

3: A mod with the error will cause all other mods loaded after it to fail.

4: Exception: the very last mod in the list. This will also load normally.



DFU attempts to load mods:
It hits Climates & Cloaks, loads this normally and then mods after that start failing until it hits the last mod in the load list.
errorLog1.png
errorLog1.png (53.65 KiB) Viewed 732 times

Later in the logs, it attempts to initialize the mods. But is unable to initialize any mods that did not load correctly. Note that the mod "Torch Taker" at the end is loads normally.
errorLog2.png
errorLog2.png (24.69 KiB) Viewed 732 times

The error message:
errorLog3.png
errorLog3.png (72 KiB) Viewed 729 times

Which links to this code:

Code: Select all

public static Assembly CompileFromSourceAssets(string[] source)
        {
            if (source == null || source.Length < 1)
            {
                Debug.Log("nothing to compile");
                return null;
            }

            Assembly assembly;

            try
            {
                assembly = Compiler.CompileSource(source, true);
                return assembly;
            }
            catch (Exception ex)
            {
                Debug.LogError(ex.Message);
                return null;
            }
        }
This was in the new Unity editor with 0.10.25a, and no code changes or additions. Simply the .dfmod files (built with 0.1025a) placed in the StreamingAssets folder.
Last edited by Ralzar on Sat Jul 18, 2020 12:14 pm, edited 1 time in total.
My released mods

"I feel like Ralzar specifically wrote those mods for me and then said "Use them". Just so he could watch me die more."
-FuzzyBeanPlays

User avatar
TheLacus
Posts: 1264
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Upgrading Mods to 0.10.25 and Later

Post by TheLacus »

Interkarma wrote: Sat Jul 18, 2020 1:55 am I also don't know why that would work in 0.10.24 and raise an error in 0.10.25. Hopefully TheLacus will loop back and have some insight.
Must be the same issue of which i wrote here. I thought the problem affected all arguments with default value, but after further testing it seems to be actually only for enum arguments. Using multiple overloads should be a viable workaround.

Magicono43, try to use the following:

Code: Select all

namespace DaggerfallWorkshop.Game.UserInterfaceWindows
{
    public partial class LGSTradeWindowText : DaggerfallTradeWindow, IMacroContextProvider
    {
        public LGSTradeWindowText(IUserInterfaceManager uiManager, DaggerfallBaseWindow previous = null)
            : this(uiManager, previous, WindowModes.Sell, null)
        {
            
        }
        
        public LGSTradeWindowText(IUserInterfaceManager uiManager, DaggerfallBaseWindow previous, WindowModes windowMode, IGuild guild = null)
            : base(uiManager, previous, windowMode, guild)
        {
            
        }
    }
}
Mod System documentation - Learn how to create mods for Daggerfall Unity.
Modder Discussion - General help and discussion for the mod system.
Github Issues - Submit a bug report for the game, including the mod system.

User avatar
TheLacus
Posts: 1264
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Upgrading Mods to 0.10.25 and Later

Post by TheLacus »

Ralzar wrote: Sat Jul 18, 2020 12:06 pm Both me and Magicono are seeing some weird behaviour with mod loading. Me with Climates & Cloaks, him with the GoldShop mod. I also saw it with his PhysicalCombat mod yesterday.

This is all testing done today exclusively with the new 0.10.25a code:

1: Error is only visible if you use a built mod in the editor. Loose files will not produce the error.

2: The error happens during game load, after you click the "Play" button in the DFU launcher.

3: A mod with the error will cause all other mods loaded after it to fail.

4: Exception: the very last mod in the list. This will also load normally.



DFU attempts to load mods:
It hits Climates & Cloaks, loads this normally and then mods after that start failing until it hits the last mod in the load list.
errorLog1.png


Later in the logs, it attempts to initialize the mods. But is unable to initialize any mods that did not load correctly. Note that the mod "Torch Taker" at the end is loads normally.
errorLog2.png


The error message:
errorLog3.png


Which links to this code:

Code: Select all

public static Assembly CompileFromSourceAssets(string[] source)
        {
            if (source == null || source.Length < 1)
            {
                Debug.Log("nothing to compile");
                return null;
            }

            Assembly assembly;

            try
            {
                assembly = Compiler.CompileSource(source, true);
                return assembly;
            }
            catch (Exception ex)
            {
                Debug.LogError(ex.Message);
                return null;
            }
        }
This was in the new Unity editor with 0.10.25a, and no code changes or additions. Simply the .dfmod files (built with 0.1025a) placed in the StreamingAssets folder.
Please send me the mod (only the .dfmod file) that causes the issue you're facing.
Mod System documentation - Learn how to create mods for Daggerfall Unity.
Modder Discussion - General help and discussion for the mod system.
Github Issues - Submit a bug report for the game, including the mod system.

User avatar
Ralzar
Posts: 1584
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Upgrading Mods to 0.10.25 and Later

Post by Ralzar »

Attached to post
climates & calories0.10.25a.zip
(221.78 KiB) Downloaded 20 times
My released mods

"I feel like Ralzar specifically wrote those mods for me and then said "Use them". Just so he could watch me die more."
-FuzzyBeanPlays

User avatar
Ralzar
Posts: 1584
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Upgrading Mods to 0.10.25 and Later

Post by Ralzar »

TheLacus wrote: Sat Jul 18, 2020 12:15 pm Please send me the mod (only the .dfmod file) that causes the issue you're facing.
And here's the repository for it:

https://github.com/Ralzar81/Climates-Calories
My released mods

"I feel like Ralzar specifically wrote those mods for me and then said "Use them". Just so he could watch me die more."
-FuzzyBeanPlays

User avatar
Magicono43
Posts: 505
Joined: Tue Nov 06, 2018 7:06 am

Re: Upgrading Mods to 0.10.25 and Later

Post by Magicono43 »

@TheLacus, Nope adding that overload and rebuilding the mod still caused that same "Constant Does Not Match" error on mod initialization. When I tried keeping the one you added and removing the old one with the default argument, it throws a compile error on the "this" because the referred method does not have only 4 arguments.

Edit 1: No wait! I changed your added Overload's "this" to "base" and the error did not show up, will test if mod is functional.

Edit 2: Alright, the mod appears to be working fine after that change, so it seems that "default" argument was definitely the cause in this particular case.

User avatar
TheLacus
Posts: 1264
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Upgrading Mods to 0.10.25 and Later

Post by TheLacus »

The compiler fails to parse source code from your mod:

Code: Select all

IndexOutOfRangeException: Index was outside the bounds of the array.
Mono.CSharp.Location..ctor (Mono.CSharp.SourceFile file, System.Int32 row, System.Int32 column) (at D:/Copy/UNITY/CSharpCompiler/Source of mcs.dll (mono compiler)/Source of mcs.dll (mono compiler)/mcs/mcs/location.cs:265)
Mono.CSharp.Tokenizer.get_Location () (at D:/Copy/UNITY/CSharpCompiler/Source of mcs.dll (mono compiler)/Source of mcs.dll (mono compiler)/mcs/mcs/cs-tokenizer.cs:933)
Mono.CSharp.CSharpParser.parse () (at D:/Copy/UNITY/CSharpCompiler/Source of mcs.dll (mono compiler)/Source of mcs.dll (mono compiler)/mcs/mcs/cs-parser.jay:7624)
CSharpCompiler.CustomDynamicDriver.Parse (Mono.CSharp.SeekableStreamReader reader, Mono.CSharp.SourceFile sourceFile, Mono.CSharp.ModuleContainer module, Mono.CSharp.ParserSession session, Mono.CSharp.Report report) (at Assets/Game/Addons/CSharpCompiler/CustomDynamicDriver.cs:156)
CSharpCompiler.CustomDynamicDriver.Parse (Mono.CSharp.SourceFile file, Mono.CSharp.ModuleContainer module, Mono.CSharp.ParserSession session, Mono.CSharp.Report report) (at Assets/Game/Addons/CSharpCompiler/CustomDynamicDriver.cs:137)
CSharpCompiler.CustomDynamicDriver.Parse (Mono.CSharp.ModuleContainer module) (at Assets/Game/Addons/CSharpCompiler/CustomDynamicDriver.cs:105)
CSharpCompiler.CustomDynamicDriver.Compile (System.Reflection.Emit.AssemblyBuilder& outAssembly, System.AppDomain domain, System.Boolean generateInMemory) (at Assets/Game/Addons/CSharpCompiler/CustomDynamicDriver.cs:195)
CSharpCompiler.CodeCompiler.CompileFromCompilerSettings (Mono.CSharp.CompilerSettings settings, System.Boolean generateInMemory) (at Assets/Game/Addons/CSharpCompiler/CodeCompiler.cs:244)
UnityEngine.Debug:LogException(Exception)
CSharpCompiler.CodeCompiler:CompileFromCompilerSettings(CompilerSettings, Boolean) (at Assets/Game/Addons/CSharpCompiler/CodeCompiler.cs:248)
CSharpCompiler.CodeCompiler:CompileAssemblyFromSourceBatch(CompilerParameters, String[]) (at Assets/Game/Addons/CSharpCompiler/CodeCompiler.cs:232)
DaggerfallWorkshop.Game.Utility.Compiler:CompileSource(String[], Boolean, Boolean) (at Assets/Game/Addons/CSharpCompiler/Compiler.cs:81)
DaggerfallWorkshop.Game.Utility.ModSupport.ModManager:CompileFromSourceAssets(String[]) (at Assets/Game/Addons/ModSupport/ModManager.cs:743)
This is the source code of mcs-ICodeCompiler, which unfortunately is not receiving updates anymore:

Code: Select all

			
// TODO: For eval only, need better handling of empty
int file_index = file == null ? 0 : file.Index;

// FIXME: This value is certainly wrong but what was the intension
int max = checkpoint_index < 10 ?
	checkpoint_index : 10;
for (int i = 0; i < max; i++) {
	int offset = checkpoints [checkpoint_index - i].LineOffset; <-- line 265
	delta = row - offset;
	if (delta >= 0 &&
		delta < (1 << line_delta_bits) &&
		checkpoints[checkpoint_index - i].File == file_index) {
		target = checkpoint_index - i;
		break;
	}
}
Your mod is relatively big so it's not easy to find out what exactly is causing this issue. I'd suggest to consider compiling most, if not all, of your mod using Visual Studio and load the assembly at run time from resulting .dll file, but I understand this might be overwhelming.
Mod System documentation - Learn how to create mods for Daggerfall Unity.
Modder Discussion - General help and discussion for the mod system.
Github Issues - Submit a bug report for the game, including the mod system.

Post Reply