Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FNA update script for Terraria -requires running the game in 64bit
#!/bin/bash
# This script it outdated - please see the original for updates
#
# FNA Update Script
# Written by Ethan "flibitijibibo" Lee
# Edited by TheDaftRick
#
# Released under public domain.
# No warranty implied; use at your own risk.
#
# Linux guide:
# Place this file fnaUpdate.sh in your Terraria folder
# Open your Terraria folder in terminal and run these two commands
# chmod +x fnaUpdate.sh
# ./fnaUpdate.sh -autoarch
# Add a Non-Steam game and select Terraria.bin.x86_64 in your Terraria folder
# Use this to run Terraria (Steam will still see you running the regular version of Terraria with all Steam features working)
#
# If you want to run the 32bit version of Terraria then use this script to update FNA to 1707
# https://gist.github.com/TheDaftRick/d5e49ebbfd8f09ddfb66dc29e775ece1
#
# Run this script in the game's executable folder.
# For OSX this will be Game.app/Contents/MacOS/.
#
# This script requires the following programs:
# - git
# - make
# - dmcs, the Mono C# compiler
# Be Smart. Be Safe.
set -e
# Move to script's directory
cd "`dirname "$0"`"
# Get the system architecture
UNAME=`uname`
ARCH=`uname -m`
# Grab native libraries
curl -O fna.flibitijibibo.com/archive/fnalibs.tar.bz2
if [ "$UNAME" == "Darwin" ]; then
tar xvfj fnalibs.tar.bz2 osx
else
if [ "$ARCH" == "x86_64" ]; then
tar xvfj fnalibs.tar.bz2 lib64
else
tar xvfj fnalibs.tar.bz2 lib
fi
fi
rm fnalibs.tar.bz2 # Wouldn't want to waste disk space, would we...
# Download and build latest FNA
if [ -d "FNA" ]; then
cd FNA
git pull
git submodule update
else
git clone --recursive git://github.com/FNA-XNA/FNA.git
cd FNA
fi
sed -i 's/IntPtr mem,/byte[] mem,/g' lib/SDL2-CS/src/SDL2.cs
make release
cd ..
cp FNA/bin/Release/* .
# We out.
echo Complete!
@elenapan

This comment has been minimized.

Copy link

@elenapan elenapan commented Jun 2, 2019

Only tested this on multiplayer. It worked extremely well at first, however the more I played the more performance degraded back to "normal". Also the game crashed a couple of times. Anyway it is worth a shot if you have performance issues like I did.

Ubuntu 18.04, Nvidia GPU

@TheDaftRick

This comment has been minimized.

Copy link
Owner Author

@TheDaftRick TheDaftRick commented Jun 2, 2019

Only tested this on multiplayer. It worked extremely well at first, however the more I played the more performance degraded back to "normal". Also the game crashed a couple of times. Anyway it is worth a shot if you have performance issues like I did.

Ubuntu 18.04, Nvidia GPU

https://gist.github.com/TheDaftRick/d5e49ebbfd8f09ddfb66dc29e775ece1
Give the FNA 1707 update a try with the 32bit version of Terraria

@elenapan

This comment has been minimized.

Copy link

@elenapan elenapan commented Jun 3, 2019

@TheDaftRick
Thank you! After some testing in single player, the FNA1707 update for 32bit Terraria seems to be working just fine. I will report back if something goes wrong.

EDIT - Some things I noticed:

  • Pressing F1 makes the game crash.
  • Opening the settings while ingame (inside a world) makes the game crash. Opening it in the main menu is fine though.
@Art10001

This comment has been minimized.

Copy link

@Art10001 Art10001 commented Jun 4, 2019

Hello. I ask this here because I did not find a discussion about this exact issue anywhere.
When I start Terraria in Linux, the CPU usage is normal, but when I load a world, one core goes up to 100% usage. When I am creating a world of any size, the amount of 100% used cores rises to 2. Why is that and how can I stop it? I think that it's Mono related. Could a FNA update fix it?
Thank you!

@weijiangan

This comment has been minimized.

Copy link

@weijiangan weijiangan commented Aug 14, 2019

I get "sed: 1: "lib/SDL2-CS/src/SDL2.cs": extra characters at the end of l command" when running the script on Mac. Any advice? Should I replace all IntPtr to byte[]?

UPDATE:
Changing L60 to

sed -i '' 's/IntPtr mem,/byte[] mem,/g' lib/SDL2-CS/src/SDL2.cs

fixed it for me. On a side note: OMG. The performance improvements are incredible! No problems so far

@MultivlaaiTaart

This comment has been minimized.

Copy link

@MultivlaaiTaart MultivlaaiTaart commented Sep 26, 2019

Unfortunately it does not seem to work for me. After running the script with weijlangan's changes I get an exception on starting the game:

System.TypeLoadException: Could not load type 'Microsoft.Xna.Framework.Input.Touch.TouchPanel' from assembly 'FNA, Version=19.9.0.0, Culture=neutral, PublicKeyToken=null'.
  at Terraria.Main..ctor () [0x001ae] in <dbf8f2c5510e46d38b1131a5bdc5c30d>:0 
  at Terraria.Program.LaunchGame (System.String[] args, System.Boolean monoArgs) [0x0005d] in <dbf8f2c5510e46d38b1131a5bdc5c30d>:0 
  at Terraria.MacLaunch.Main (System.String[] args) [0x00038] in <dbf8f2c5510e46d38b1131a5bdc5c30d>:0

This is on MacOS 10.14.6 using the current version of FNA. I have tried manually using version 19.08 of FNA instead of pulling the latest version, but I run into the same problem.
Any ideas?

Edit: I have got it to work by removing the src/Input/Touch/* files from the make file, and then removing all functionality that uses the contents of these files.

@lsaa

This comment has been minimized.

Copy link

@lsaa lsaa commented Jan 5, 2020

Unfortunately it does not seem to work for me. After running the script with weijlangan's changes I get an exception on starting the game:

System.TypeLoadException: Could not load type 'Microsoft.Xna.Framework.Input.Touch.TouchPanel' from assembly 'FNA, Version=19.9.0.0, Culture=neutral, PublicKeyToken=null'.
  at Terraria.Main..ctor () [0x001ae] in <dbf8f2c5510e46d38b1131a5bdc5c30d>:0 
  at Terraria.Program.LaunchGame (System.String[] args, System.Boolean monoArgs) [0x0005d] in <dbf8f2c5510e46d38b1131a5bdc5c30d>:0 
  at Terraria.MacLaunch.Main (System.String[] args) [0x00038] in <dbf8f2c5510e46d38b1131a5bdc5c30d>:0

This is on MacOS 10.14.6 using the current version of FNA. I have tried manually using version 19.08 of FNA instead of pulling the latest version, but I run into the same problem.
Any ideas?

Edit: I have got it to work by removing the src/Input/Touch/* files from the make file, and then removing all functionality that uses the contents of these files.

Got the same error on Arch Linux running the 5.3.11-1 kernel, haven't tried to remove Touch from compiling yet

Edit: Removing the touch functionality works! Was a bit of a hastle since I don't really program in C#

Edit 2: Thanks man, I can play the later Calamity bosses with this :D

@guihkx

This comment has been minimized.

Copy link

@guihkx guihkx commented Jan 30, 2020

I'm getting the same Microsoft.Xna.Framework.Input.Touch.TouchPanel error. Can you guys share a patch file to disable the touch functionality altogether? Thanks!

@guixxx

This comment has been minimized.

Copy link

@guixxx guixxx commented Feb 4, 2020

@guihkx

Here's a patch file:

https://gist.github.com/guixxx/fb30995ba299fc24d67a9cd06b5e9046

Save it inside your FNA/ folder, as terraria.patch. Apply it by running git apply terraria.patch. Then, just run the fnaUpdate.sh script again.

macOS users, beware: That patch file removes some files related to Metal API, so it might not work for you. The patch file was tested only on Linux.

@yaomtc

This comment has been minimized.

Copy link

@yaomtc yaomtc commented May 1, 2020

@guixxx That patch doesn't seem to be valid anymore. And I'm getting a lot of errors trying to remove Metal related code, since that causes a failure too. Don't really know what I'm doing.

EDIT: After looking at your patch and making the same changes, I found there were a few additional changes that needed to be made. I don't know how to make a patch file, but:

src/FNAPlatform/SDL2_FNAPlatform.cs(269,7): error CS1519: Unexpected symbol `else' in class, struct, or interface member declaration
src/FNAPlatform/SDL2_FNAPlatform.cs(269,29): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
src/FNAPlatform/SDL2_FNAPlatform.cs(269,34): error CS1519: Unexpected symbol `iOS' in class, struct, or interface member declaration
src/FNAPlatform/SDL2_FNAPlatform.cs(269,56): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
src/FNAPlatform/SDL2_FNAPlatform.cs(269,62): error CS1519: Unexpected symbol `tvOS' in class, struct, or interface member declaration
src/FNAPlatform/SDL2_FNAPlatform.cs(270,4): error CS9010: Primary constructor body is not allowed
src/FNAPlatform/SDL2_FNAPlatform.cs(278,9): error CS1519: Unexpected symbol `return' in class, struct, or interface member declaration
src/FNAPlatform/SDL2_FNAPlatform.cs(281,17): error CS1525: Unexpected symbol `bool', expecting `class', `delegate', `enum', `interface', `partial', `ref', or `struct'                                                                                                                                
src/FNAPlatform/SDL2_FNAPlatform.cs(283,3): error CS1525: Unexpected symbol `if', expecting `class', `delegate', `enum', `interface', `partial', `ref', or `struct'                                                                                                                                   
src/FNAPlatform/SDL2_FNAPlatform.cs(283,29): error CS1525: Unexpected symbol `(', expecting `class', `delegate', `enum', `interface', `partial', `ref', or `struct'                                                                                                                                   
src/FNAPlatform/SDL2_FNAPlatform.cs(284,26): error CS1525: Unexpected symbol `(', expecting `class', `delegate', `enum', `interface', `partial', `ref', or `struct'                                                                                                                                   
src/FNAPlatform/SDL2_FNAPlatform.cs(285,26): error CS1525: Unexpected symbol `(', expecting `class', `delegate', `enum', `interface', `partial', `ref', or `struct'                                                                                                                                   
src/FNAPlatform/SDL2_FNAPlatform.cs(286,26): error CS1525: Unexpected symbol `(', expecting `class', `delegate', `enum', `interface', `partial', `ref', or `struct'                                                                                                                                   
src/FNAPlatform/SDL2_FNAPlatform.cs(288,4): error CS1525: Unexpected symbol `return', expecting `class', `delegate', `enum', `interface', `partial', `ref', or `struct'                                                                                                                               
src/FNAPlatform/SDL2_FNAPlatform.cs(289,4): error CS1514: Unexpected symbol `}', expecting `.' or `{'
src/FNAPlatform/SDL2_FNAPlatform.cs(411,16): error CS1525: Unexpected symbol `GameWindow', expecting `class', `delegate', `enum', `interface', `partial', `ref', or `struct' 

My first step was deleting the section of code in SDL2_FNAPlatform.cs starting at line 269. The line at 411, I think I deleted that....

src/FNAPlatform/FNAPlatform.cs(117,4): error CS0103: The name `SupportsOrientationChanges' does not exist in the current context
src/GraphicsDeviceManager.cs(221,39): error CS0117: `Microsoft.Xna.Framework.FNAPlatform' does not contain a definition for `SupportsOrientationChanges'                                                                                                                                              

Then I deleted the sections for "SupportsOrientationChanges". This fixed things, and now I can play.

@guixxx

This comment has been minimized.

Copy link

@guixxx guixxx commented May 1, 2020

@yaomtc

Thanks for the heads up! I've updated the patch file.

@Architector4

This comment has been minimized.

Copy link

@Architector4 Architector4 commented May 17, 2020

After running into the touch panel related exception, using @guixxx's patch and applying the FNA update script and launching Terraria.bin.x86_64, the game launches, gives a window, but then shortly quits with this error:

[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method 'SDL2.SDL.SDL_RWFromMem' not found.
  at (wrapper managed-to-native) System.RuntimeMethodHandle:GetFunctionPointer (intptr)
  at System.RuntimeMethodHandle.GetFunctionPointer () [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0 
  at Terraria.Program.ForceJITOnAssembly (System.Reflection.Assembly assembly) [0x00041] in <bc6c5926d41342ccb266189290fc9342>:0 
  at Terraria.Program.ForceLoadAssembly (System.Reflection.Assembly assembly, System.Boolean initializeStaticMembers) [0x0000d] in <bc6c5926d41342ccb266189290fc9342>:0 
  at Terraria.Program.ForceLoadThread (System.Object threadContext) [0x00005] in <bc6c5926d41342ccb266189290fc9342>:0 
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x0002c] in <1170fb08300b4d0db71c1d1db8555768>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x0008d] in <1170fb08300b4d0db71c1d1db8555768>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00031] in <1170fb08300b4d0db71c1d1db8555768>:0 
  at System.Threading.ThreadHelper.ThreadStart (System.Object obj) [0x00012] in <1170fb08300b4d0db71c1d1db8555768>:0 

I'm on Arch Linux. What do?

Doing cd FNA then make gives this:

src/FNAPlatform/SDL2_FNAPlatform.cs(278,3): error CS1525: Unexpected symbol `else'
Compilation failed: 1 error(s), 0 warnings

Editing the reported file fixes the compilation fail, but Terraria still doesn't launch. Here's the final git diff of the file, including @guixxx's patch on it (might want to edit it so it includes this):

@@ -268,39 +267,6 @@ namespace Microsoft.Xna.Framework
                                return false;
                        }
 
-#if DEBUG
-                       // Always enable the validation layer in debug mode
-                       Environment.SetEnvironmentVariable(
-                               "METAL_DEVICE_WRAPPER_TYPE",
-                               "1"
-                       );
-#endif
-
-                       if (OSVersion.Equals("Mac OS X"))
-                       {
-                               // Let's find out if the OS supports Metal...
-                               try
-                               {
-                                       if (MetalDevice.MTLCreateSystemDefaultDevice() != IntPtr.Zero)
-                                       {
-                                               // We're good to go!
-                                               return true;
-                                       }
-                               }
-                               catch
-                               {
-                                       // The OS is too old for Metal!
-                                       return false;
-                               }
-                       }
-                       else if (OSVersion.Equals("iOS") || OSVersion.Equals("tvOS"))
-                       {
-                               /* We only support iOS/tvOS 11.0+ so
-                                * Metal is guaranteed to be supported.
-                                */
-                               return true;
-                       }
-
                        // Oh well, to OpenGL we go!
                        return false;
                }
@dowttie

This comment has been minimized.

Copy link

@dowttie dowttie commented May 17, 2020

Seeing the same problem here, nothing without the patch, black window for a second then crash with patch.
Running Arch here too.

[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method 'SDL2.SDL.SDL_RWFromMem' not found.
at (wrapper managed-to-native) System.RuntimeMethodHandle:GetFunctionPointer (intptr)
at System.RuntimeMethodHandle.GetFunctionPointer () [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0
at Terraria.Program.ForceJITOnAssembly (System.Reflection.Assembly assembly) [0x00041] in :0
at Terraria.Program.ForceLoadAssembly (System.Reflection.Assembly assembly, System.Boolean initializeStaticMembers) [0x0000d] in :0
at Terraria.Program.ForceLoadThread (System.Object threadContext) [0x00005] in :0
at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x0002c] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x0008d] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00031] in <1170fb08300b4d0db71c1d1db8555768>:0
at System.Threading.ThreadHelper.ThreadStart (System.Object obj) [0x00012] in <1170fb08300b4d0db71c1d1db8555768>:0

@yaomtc

This comment has been minimized.

Copy link

@yaomtc yaomtc commented May 17, 2020

One of the changes made in the newly released 1.4 is that the game now uses a different version of FNA, 18.06. So yet more changes will need to be made to this patch.

@TheDaftRick

This comment has been minimized.

Copy link
Owner Author

@TheDaftRick TheDaftRick commented May 17, 2020

Sorry I haven't kept up with this. This script doesn't work with the newest version of Terraria 1.4, but Ethan Lee updated his original script so please check there

@Architector4

This comment has been minimized.

Copy link

@Architector4 Architector4 commented May 17, 2020

YES!!

Using the script linked in the previous comment (the patch in its comments is unapplicable, don't worry about it), and then applying the patch linked by @guixxx above, and it works, IT WORKS! Big thanks guys, and big thanks to Ethan Lee for the patch.

@anzharip

This comment has been minimized.

Copy link

@anzharip anzharip commented May 18, 2020

YES!!

Using the script linked in the previous comment (the patch in its comments is unapplicable, don't worry about it), and then applying the patch linked by @guixxx above, and it works, IT WORKS! Big thanks guys, and big thanks to Ethan Lee for the patch.

Thanks! I tried this step on my mac and it is working.

However, the performance seems to be the same to before the update was performed.

@guihkx

This comment has been minimized.

Copy link

@guihkx guihkx commented May 18, 2020

I did the FNA upgrade too, but unfortunately the performance doesn't even compare to playing using Proton + DXVK.

But apparently FNA is getting a Vulkan back-end in the near future, though, so hopefully that will change...

@yaomtc

This comment has been minimized.

Copy link

@yaomtc yaomtc commented May 22, 2020

Just wondering if this still only works with the 64-bit version of the game, or if there's a way to get Steam integration working with the 64-bit version for achievements?

EDIT: last time I did this, Steam achievements weren't working properly - but I see the script does say all Steam features should be working, so I'll try it again. Might have been a temporary issue

EDIT2: Never mind, not a temporary issue. Achievements and other Steam features aside from the overlay still do not work. And 32-bit doesn't seem to be an option anymore, as the archive no longer includes a "lib" folder, with the README saying Linux is 64-bit only.

EDIT3: I realized you can put -autoarch in the launch options for Terraria in Steam (not a non-Steam addition), this makes Steam use the 64-bit executable. The point of this process for me was so I could run the game at 1280x720 with 2X nearest neighbor scaling on my 2560x1440 display, using the FNA_OPENGL_BACKBUFFER_SCALE_NEAREST=1 environment variable. However this is not practical to use, as game is setting itself to 1080p regardless of the resolution I set in the config file, and when I alt-tab out of the game, the resolution automatically resets itself again... And whichever resolution it's in, the cursor can never reach the bottom right corner if I'm in fullscreen.

It's wild to me that this game received a major update in 2020 and it still does not support 1440p properly.

@AaronBottegal

This comment has been minimized.

Copy link

@AaronBottegal AaronBottegal commented May 28, 2020

Why do all this garbage in a gist and whatnot, instead of using github as intended and applying changes to make it work together?

None of these work for me, the release build is always borked for me. A testament of why not to do it this way.

@dowttie

This comment has been minimized.

Copy link

@dowttie dowttie commented May 28, 2020

@AaronBottegal

This comment has been minimized.

Copy link

@AaronBottegal AaronBottegal commented May 28, 2020

If it was ever in a state of use, maybe I'd consider. But I'm not cleaning up your guy's garbage.

@felipe19930

This comment has been minimized.

Copy link

@felipe19930 felipe19930 commented May 28, 2020

I heard it's needed an IQ of 80+ to apply the patch successfully.

@dowttie

This comment has been minimized.

Copy link

@dowttie dowttie commented May 28, 2020

@CyberShadow

This comment has been minimized.

Copy link

@CyberShadow CyberShadow commented Jun 7, 2020

Trying to get this to work on Arch Linux with the GOG version (1.4.0.5).


Problem 1, the sed invocation doesn't seem to be quite right, fails with sed: can't read s/IntPtr mem,/byte[] mem,/g: No such file or directory.
Solution, move the -i to the end (not sure if this works on macOS):

diff --git a/game/fnaUpdate.sh b/game/fnaUpdate.sh
index 57db48f..5be4d22 100755
--- a/game/fnaUpdate.sh
+++ b/game/fnaUpdate.sh
@@ -57,7 +57,7 @@ else
 	git clone --recursive git://github.com/FNA-XNA/FNA.git
 	cd FNA
 fi
-sed -i '' 's/IntPtr mem,/byte[] mem,/g' lib/SDL2-CS/src/SDL2.cs
+sed 's/IntPtr mem,/byte[] mem,/g' lib/SDL2-CS/src/SDL2.cs -i
 make release
 cd ..
 cp FNA/bin/Release/* .

Problem 2, getting the TouchInput exception ([ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'Microsoft.Xna.Framework.Input.Touch.TouchPanel' from assembly 'FNA, Version=20.6.0.0, Culture=neutral, PublicKeyToken=null'.).
Solution, apply guixxx's patch:

diff --git a/game/fnaUpdate.sh b/game/fnaUpdate.sh
index 5be4d22..99eb129 100755
--- a/game/fnaUpdate.sh
+++ b/game/fnaUpdate.sh
@@ -49,6 +49,7 @@ fi
 rm fnalibs.tar.bz2 # Wouldn't want to waste disk space, would we...
 
 # Download and build latest FNA
+curl -O https://gist.githubusercontent.com/guixxx/fb30995ba299fc24d67a9cd06b5e9046/raw/a9743bab74b7f8e747d74db51e4937409b00a886/fna-terraria.patch
 if [ -d "FNA" ]; then
 	cd FNA
 	git pull
@@ -58,6 +59,7 @@ else
 	cd FNA
 fi
 sed 's/IntPtr mem,/byte[] mem,/g' lib/SDL2-CS/src/SDL2.cs -i
+git apply ../fna-terraria.patch
 make release
 cd ..
 cp FNA/bin/Release/* .

Problem 3, the Mono segmentation fault (Got a SIGSEGV while executing native code.).
Solution, update the game binaries with flibitijibibo's MonoKickstart:

diff --git a/game/fnaUpdate.sh b/game/fnaUpdate.sh
index 99eb129..5d9e55c 100755
--- a/game/fnaUpdate.sh
+++ b/game/fnaUpdate.sh
@@ -64,5 +64,13 @@ make release
 cd ..
 cp FNA/bin/Release/* .
 
+if [ -d "MonoKickstart" ]; then
+	git -C MonoKickstart pull
+else
+	git clone https://github.com/flibitijibibo/MonoKickstart
+fi
+cp -v MonoKickstart/precompiled/* ./
+mv -v kick.bin.x86_64 ./Terraria.bin.x86_64
+
 # We out.
 echo Complete!
\ No newline at end of file

Problem 4, the SDL_RWFromMem crash (Exception: System.MissingMethodException: Method not found: intptr SDL2.SDL.SDL_RWFromMem(intptr,int)).

Solution: Delete the sed invocation altogether:

diff --git a/game/fnaUpdate.sh b/game/fnaUpdate.sh
index 5d9e55c..cc83aca 100755
--- a/game/fnaUpdate.sh
+++ b/game/fnaUpdate.sh
@@ -58,7 +58,6 @@ else
 	git clone --recursive git://github.com/FNA-XNA/FNA.git
 	cd FNA
 fi
-sed 's/IntPtr mem,/byte[] mem,/g' lib/SDL2-CS/src/SDL2.cs -i
 git apply ../fna-terraria.patch
 make release
 cd ..

Problem 5, Terraria now no longer crashes, but looks like this:


Solution: ??? Is this the end of the line?

@zauberparacelsus

This comment has been minimized.

Copy link

@zauberparacelsus zauberparacelsus commented Aug 13, 2020

This doesn't seem to work with the steam version of tModLoader. When I try to start tModLoader (64bit), the game just crashes or something right away, so no game window comes up.

@Hirato

This comment has been minimized.

Copy link

@Hirato Hirato commented Sep 9, 2020

I tried myself, managed to make it ingame and update it successfully.
There were a bunch of issues however...

  1. SDL_RWFromMem
    For this we need to make a second extern in SDL.cs
    I had this:

     /* mem refers to a void*, IntPtr to an SDL_RWops* */
     [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
     public static extern IntPtr SDL_RWFromMem(IntPtr mem, int size);
    
     /* mem refers to a void*, IntPtr to an SDL_RWops* */
     [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
     public static extern IntPtr SDL_RWFromMem(byte[] mem, int size);
    

This stems from an update for supporting SDL_image 2.0.2 over 3 years ago.

  1. Null deref in GLCallLocker
    This is a tmodloader thing - basically FNA 20.09 made some refactoring that split the graphics devices into a separate FNA3D library, so the last comaptible version is 20.08.
    tmodloader uses reflection to see and interact with some internal classes it really shouldn't as soon as the game starts.

  2. Black screen once ingame
    Not sure which one actually fixed it, but you need to compile mojoshader with some non-default flags set
    at the very least you should use -DBUILD_SHARED_LIBS='ON' -DDEPTH_CLIPPING='ON' -DFLIP_VIEWPORT='ON'
    It was probably FLIP_VIEWPORT, since the guide was going up the screen as I was flying up, rather than down.

  3. SDL init around touch and controllers
    Just delete the existing SDL and SDL_Image inside the lib64 folder, might help if you update that 'kickstart' thing too.

And with that, I was ingame with an updated FNA.
but alas, the Solar pillar still makes tmodloader blow up; I was hoping this whole foray would fix it, but it would seem I have no such luck, and will have to stick with the one it shipped with... maybe for 1.4...

@Tomsod

This comment has been minimized.

Copy link

@Tomsod Tomsod commented Oct 24, 2020

Problem 5, Terraria now no longer crashes, but looks like this:


Solution: ??? Is this the end of the line?

It's a bit off-topic, but I must thank you for providing an insight for my own problem. I've just updated from 1.4.0.5, and your screenshots are what Terraria 1.4.1.1 looks for me. Everything is flickering rectangles -- sprites, letters, cursor, everything. But now that I know it's an FNA issue, I was able to rid of this graphics glitch by downgrading FNA.dll to the one provided with 1.4.0.5, and the game seems to work fine. Not the most elegant solution, but I'll take whatever works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.