veywrn / StardewValley

Decompiled Stardew Valley. Batteries not included.
270 stars 68 forks source link

Netcode issues while building, attached log. #3

Open EverWinter23 opened 3 years ago

EverWinter23 commented 3 years ago

I get this weird error while building in multiple places->

Monsters/Monster.cs(86,56): error CS0311: The type 'Netcode.NetVector2' cannot be used as type parameter 'TField' in the generic type or method 'NetEvent1Field<T, TField>'. There is no implicit reference conversion from 'Netcode.NetVector2' to 'Netcode.NetField<Microsoft.Xna.Framework.Vector2, Netcode.NetVector2>'. [/home/frost/workspace/r2d2/monogame/StardewValley/StardewValley/StardewValley.csproj]

LOG: build.log

Can I resolve it in anyway?

veywrn commented 3 years ago

Howdy!

Judging by the log and warnings before the errors, it looks like you may be building this with dotnet tools and the Monogame framework in a non-Windows system. I will caution that this disassembly is based on the Windows Steam version of the game and may not be equivalent to the build for another platform, so there may be a non-trivial amount of work to get it to run in that context.

For reference, this repo is based on using ILSpy 5.0.x targeting C# 7.3 and Visual Studio 2019 Community edition running under Windows 10.

That disclaimer out of the way, these warnings are suspicious to me, since all of the errors involve an XNA framework type [edit: being used by the type that is actually providing the error]:

/usr/share/dotnet/sdk/3.1.108/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Xna.Framework.Game". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/frost/workspace/r2d2/monogame/StardewValley/StardewValley/StardewValley.csproj]
/usr/share/dotnet/sdk/3.1.108/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Xna.Framework.Graphics". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/frost/workspace/r2d2/monogame/StardewValley/StardewValley/StardewValley.csproj]
/usr/share/dotnet/sdk/3.1.108/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Xna.Framework.Xact". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/frost/workspace/r2d2/monogame/StardewValley/StardewValley/StardewValley.csproj]

Although that type is located in the Microsoft.Xna.Framework assembly, which isn't listed as missing, so these warnings may be a non-issue. I'm unfamiliar with the Monogame framework and how it works as a substitute for XNA.

Also, the first warning in the log states the project is trying to build under .NET Core, which may or may not lead to interesting differences:

/home/frost/workspace/r2d2/monogame/StardewValley/StardewValley/StardewValley.csproj : warning NU1701: Package 'System.Windows.Forms 4.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.

I did try building using dotnet build out of curiosity and here's the log I get from a clean checkout: build.log

Sorry, not sure if any of this is helpful. Without access to your context, I'm just guessing at possibilities based on the log.

[edit: I realize I may have been unclear now, but the build as given expects you to create a directory named lib in the root of the repository and put the libraries listed in the README in there. If you have the assemblies listed and you're getting these warnings, that may be why.]

EverWinter23 commented 3 years ago

Hey!

Thanks for the info. I have a couple of questions.

Monogame acts as a substitue for XNA Framework right down to each namespace, I'm not having problems with XNA , everything w.r.t XNA is not throwing an error. I have had success in being able to compile XNA based projects with Monogame on linux.

I downloaded the app through steam on linux, Netcode.dll was missing in the steamapps directory. So, I thought I would install Stardew Valley from Steam on Windows [8.1] and copy it onto linux.

All errors seem to originate from this Netcode.dll thing. I get that I might not be able to build it on linux, but I think if I can resolve these errors, I should get somewhere closer to it.

Monsters/Monster.cs(86,56): error CS0311: The type 'Netcode.NetVector2' cannot be used as type parameter 'TField' in the generic type or method 'NetEvent1Field<T, TField>'. There is no implicit reference conversion from 'Netcode.NetVector2' to 'Netcode.NetField<Microsoft.Xna.Framework.Vector2, Netcode.NetVector2>'. [/home/frost/workspace/r2d2/monogame/StardewValley/StardewValley/StardewValley.csproj]

Is it a problem with my Netcode.dll file?

This is my directory structure, which seems about right.

.
├── README.md
├── StardewValley
│   ├── Force.DeepCloner
│   │   ├── DeepClonerExtensions.cs
│   │   └── Helpers
│   ├── Ionic
│   │   ├── Crc
│   │   └── Zlib
│   ├── lib
│   │   ├── BmFont.dll
│   │   ├── GalaxyCSharp.dll
│   │   ├── GalaxyCSharp.dll.config
│   │   ├── Lidgren.Network.dll
│   │   ├── Microsoft.Xna.Framework.dll
│   │   ├── Netcode.dll
│   │   ├── steam_api.dll
│   │   ├── Steamworks.NET.dll
│   │   └── xTile.dll
│   ├── Microsoft.Xna.Framework.Graphics
│   │   └── ViewportExtensions.cs
│   ├── Microsoft.Xna.Framework.RuntimeProfile
│   ├── README.md
│   ├── Sickhead.Engine.Util
│   │   └── MemberInfoExtensions.cs
│   ├── StardewValley
│   │   ├── AbortNetSynchronizerException.cs
...
...
veywrn commented 3 years ago

Interesting! I'm not sure why it would be missing on Linux. I've avoided poking the libraries as much as possible as I'm less sure there what's from Stardew Valley and what's a third-party product, which may have a far less permissive perspective on my doing something like this.

It looks like Netcode.dll does have Stardew Valley specific extensions and is not just a separate product, so it may be in-house? I'll include it as a library project when I push the 1.5.1 update. I don't know that it'll fix your issue just being able to build it, but it will at least give you access to the code to try and make changes to get it to work.

I should have that out here in a little bit, but if not, by sometime this weekend.

veywrn commented 3 years ago

Well, that went smoothly. Merged update, and Netcode library is now part of the build. Hope that does something for you.

EverWinter23 commented 3 years ago

@veywrn Thanks!

If I'm able to run it I'll upload steps or submit a PR, and maybe this repo can have a linux branch for targeting linux.

Using the Netcode assembly all the errors related to Netcode have been fixed. Facing some other errors w.r.t linux specific libs, but it's looking promising.

I'm pretty sure that Netcode.dll is in-house-- it came in with the multi-player update.

EverWinter23 commented 3 years ago

Hey!

I am able to build it successfully. :partying_face: Here is the build.log.

However while running I'm running into issues :sob:. This is the run.log.

I will caution that this disassembly is based on the Windows Steam version of the game and may not be equivalent to the build for another platform, so there may be a non-trivial amount of work to get it to run in that context.

So then I decompiled the linux version, just to make sure that maybe I missed something, but I ran into the same error. I have to edit the .csproj manually, and this seems like an architecture error. Everything seems to be compile to 32 bit version-- and all dll files are 32 bit. Am I missing something?

I verified the architecture of my dll files using this python script:

import os
import struct
import sys

def arch_of(dll_file):
    with open(dll_file, 'rb') as f:
        doshdr = f.read(64)
        magic, padding, offset = struct.unpack('2s58si', doshdr)
        # print magic, offset
        if magic != b'MZ':
            return None
        f.seek(offset, os.SEEK_SET)
        pehdr = f.read(6)
        # careful! H == unsigned short, x64 is negative with signed
        magic, padding, machine = struct.unpack('2s2sH', pehdr)
        # print magic, hex(machine)
        if magic != b'PE':
            return None
        if machine == 0x014c:
            return 'i386'
        if machine == 0x0200:
            return 'IA64'
        if machine == 0x8664:
            return 'x64'
        return 'unknown'

print(arch_of(sys.argv[1]))

This is the log file when I only try to target the x86.log architecture by replacing <Platforms> with <PlatformTarget> in StardewValley.csproj:

  <PropertyGroup Label="Globals">
    <TargetFramework>netcoreapp3.1</TargetFramework> <--- [netcoreapp3.1 is net40 for linux]
    <PlatformTarget>x86</PlatformTarget>  
  </PropertyGroup>

Thank you for your time!

veywrn commented 3 years ago

Nope, you're not missing anything that I can see. For the Windows side everything targets 32-bit as XNA is a 32-bit only framework. Monogame apparently relaxes that constraint and can target either 32- or 64-bit platforms. I can also confirm that all the libraries on my end return i386 using that script.

I'm surprised that the <Platforms>x86</Platforms> in StardewValley.csproj isn't enough here. Is there perhaps a different build of Monogame you need when targeting 32-bit?