abaire / roguetech_macos_installer

Script to install RogueTech without relying on Wine
The Unlicense
1 stars 0 forks source link

Thank you!!!: Bad CPU type in executable #1

Open quickratio opened 2 years ago

quickratio commented 2 years ago

Bro, you are down right FU KING AWESOME! how lucky am i that i decided to try and install roguetech on my mac, only to find you wrote a script and posted it only 5 hours ago!!!! heavens align! you good sir, have a pleasant day where ever you are!

EDIT: unfortunately ran into an issue, i get this from bash, and no further messages, any help would be appreciated! :)

roguetech_install_macos.sh: line 103: /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono: Bad CPU type in executable

mac: m1 macbook pro 2021 macOS: monterey 12.5.1

somethings ive tried is following the guide here https://roguetech.fandom.com/wiki/Installation for macOS

i've got the rogueTech Launcher running with wine64, however it wont launch or install saying it can't find "BattleTech.exe" which is fair, because macOS doesnt have them!

abaire commented 2 years ago

This script is still a work in progress, the version you tried only attempted the core install and probably wouldn't have worked anyway.

I'm not a mono user, but after a quick search it looks like that message indicates mono is running 32-bit instead of 64-bit, which I don't think would ever work on modern versions of macOS. Oddly it works for me with the same configuration; how did you install mono?

If you run file /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono do you get /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono: Mach-O 64-bit executable x86_64 or something else?

abaire commented 2 years ago

Also worth checking your mono version, mine is:

mono --version Mono JIT compiler version 6.12.0.182 (2020-02/6051b710727 Tue Jun 14 15:01:21 EDT 2022) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS:
SIGSEGV: altstack Notification: kqueue Architecture: amd64 Disabled: none Misc: softdebug Interpreter: yes LLVM: yes(610) Suspend: hybrid GC: sgen (concurrent by default)

If yours is something different please let me know and I'll add a version check to the script to prevent failures for any future users.

abaire commented 2 years ago

You should also pull the latest version of this repo. As of right now I have what appears to be a working RT install using this script (and the default RT options).

quickratio commented 2 years ago

I'll be honest, i have no idea what mono is haha, it appears that if i use mono64 it works. This is an awesome effort by the way, if theres anything i can do to help let me know :)

Using the RT launcher (with wine) appears to have corrupted my entire battletech install, so i'll need to download the whole game again which takes ages for me, so i'll give it a shot later this week :)

May i ask if how you tricked the RT launcher about finding battletech.exe?

sigma@MacBook-Pro ~ % mono --version
zsh: bad CPU type in executable: mono
sigma@MacBook-Pro ~ % mono64 --version
Mono JIT compiler version 4.8.0 (mono-4.8.0-branch/9d74414 Fri Mar 17 16:12:02 EDT 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    LLVM:          yes(3.6.0svn-mono-master/8b1520c)
    GC:            sgen
sigma@MacBook-Pro ~ % 
abaire commented 2 years ago

I'll be honest, i have no idea what mono is haha, it appears that if i use mono64 it works. This is an awesome effort by the way, if theres anything i can do to help let me know :)

Thanks, I've updated the script to just use mono64 directly since it appears it's also installed automatically by the latest mono installer. Hopefully this will totally resolve the issue, if not you may need to update to a newer version of mono since yours is pretty ancient (2017).

May i ask if how you tricked the RT launcher about finding battletech.exe? I don't use the RTLauncher and haven't tried using it. From the RT website it looks like the launcher can't be used to actually launch the game on macOS (it's only used to sync the resource packs and do configuration), so jumping through Wine didn't seem worthwhile to me. I'm hoping that it can safely be bypassed entirely for anybody willing to accept the defaults or edit the config XML manually.

quickratio commented 2 years ago

Really appreciate it, i think i almost got there, currently i get stuck at the "Press [esc] to skip" intro screen, its just a black screen, and nothing happens, when i push any button.

ModTek starts up when i load the game, but after that, just above, oddly modtek tries to initialise each time i try and boot up the game; no errors from the script that i could see, not sure whats going wrong

abaire commented 2 years ago

Check ~/Library/Application Support/Steam/steamapps/common/BATTLETECH/Mods and see if there's a RogueTechPerfFix directory. If there is, delete it and it should fix the issue you're seeing.

I'm guessing the Mods folder didn't get cleaned out when you reinstalled and the older version of the script installed the perf fix before I discovered that it doesn't seem to work on the M1 (it causes exactly the behavior you're seeing).

quickratio commented 2 years ago

Mate, you are legendary! All working! is there anyway i can donate you a coffee or something like that? otherwise do you like learning languages? I just launched a mobile app that's kind of like duolingo, and happy to give you a free premium account haha.

May i ask what you do for a living? how do you work this shit out??!

quickratio commented 2 years ago

Ahhh its very unstable and crashes every time i start a mission, i give up lol i really dont have time to spend playing games anyway haha; but my offer still stands and still very grateful for your efforts!

abaire commented 2 years ago

It's crashing for me as well (I haven't actually had time to try to play either).

I found a significant error in the way the script was installing mods that caused a lot of the sprites to fail to load; that's now fixed. You can try deleting the contents of your ~/Library/Application Support/Steam/steamapps/common/BATTLETECH/Mods directory and re-running the latest version to see if it acts any different for you.

When it crashes for me, in the ~/Library/Application Support/Steam/steamapps/common/BATTLETECH/BattleTech.app/Contents/Resources/Mods/.modtek/battletech_log.txt log I see

05:32:39.768 CombatLog.RoundSequence [LOG] [[[[[[<<<<<<===============================================--------- Encounter Begin! ---------===============================================>>>>>>]]]]]]
05:32:39.848 CombatLog.RoundSequence [LOG] TurnDirector.CheckCameraIntroAndDropshipComplete - checking
05:32:39.849 Unity [LOG] mission started, refreshing music
05:32:39.863 EncounterLogic [LOG] Issue Follow Lance AI order on Encounter Start.AlwaysTrueConditional - Evaluating message[OnEncounterBegin]
05:32:39.864 EncounterLogic [LOG] Issue Follow Lance AI order on Encounter Start.AlwaysTrueConditional - PASSED - Always true is always true.
05:32:39.864 EncounterLogic [LOG] Issue Follow Lance AI order on Encounter Start - Conditional passed, sending 0 transmission(s) and firing 1 result(s)
05:32:39.864 EncounterLogic [LOG] Issue Follow Lance AI order on Encounter Start - Only triggering once.
05:32:39.864 EncounterLogic [LOG] Transmitting Issue Follow Lance AI order on Encounter Start from OnEncounterBegin
05:32:39.865 MissionControl [LOG] [IssueCustomAIOrderResult] Triggered
05:32:39.867 MissionControl [DEBUG] [IssueAIOrder] Handling order: MissionControl.AI.FollowLanceOrder
05:32:39.867 MissionControl [DEBUG] [IssueAIOrder] Received 'FOLLOW_LANCE' AI order. Following entity with tags 'Player 1'
05:32:39.879 Unity [LOG] handling order:  (AddMagicKnowledgeByTagAIOrder)
05:32:39.880 Unity [LOG] handling order:  (AddMagicKnowledgeByTagAIOrder)
05:32:39.880 Unity [LOG] handling order:  (AddMagicKnowledgeByTagAIOrder)
05:32:39.880 Unity [LOG] handling order:  (AddMagicKnowledgeByTagAIOrder)
05:32:40.301 Unity [ERROR] StackOverflowException: The requested operation caused a stack overflow.

which isn't particularly informative at a glance, but does at least indicate the type of error. Hopefully I'll have some time to debug further in the coming days.

abaire commented 2 years ago

There's a little more info in ~/Library/Logs/Unity/Player.log

Stack overflow in unmanaged: IP: 0x114facc38, fault addr: 0x30886ed78
Stack overflow in unmanaged: IP: 0x114facc38, fault addr: 0x30886df98
Stack overflow in unmanaged: IP: 0x114facc38, fault addr: 0x30886cac8
Stack overflow in unmanaged: IP: 0x114facc38, fault addr: 0x30886bce8
Uploading Crash Report
StackOverflowException: The requested operation caused a stack overflow.
  at (wrapper managed-to-native) System.Reflection.MethodBase.GetMethodFromHandleInternalType_native(intptr,intptr,bool)
  at System.Reflection.MethodBase.GetMethodFromHandleNoGenericCheck (System.RuntimeMethodHandle handle) [0x00007] in <d7ac571ca2d04b2f981d0d886fa067cf>:0 
  at System.Delegate.GetMethodImpl () [0x0003b] in <d7ac571ca2d04b2f981d0d886fa067cf>:0 
  at System.MulticastDelegate.GetMethodImpl () [0x0001f] in <d7ac571ca2d04b2f981d0d886fa067cf>:0 
  at System.Delegate.get_Method () [0x00000] in <d7ac571ca2d04b2f981d0d886fa067cf>:0 
  at MessageSubscription.Name () [0x00026] in <766927273e9c49e8babdf418683af529>:0 
  at MessageSubscription.ToString () [0x00000] in <766927273e9c49e8babdf418683af529>:0 
  at MessageCenter.SendMessagesForType (MessageCenterMessageType messageType, MessageCenterMessage message) [0x0006f] in <766927273e9c49e8babdf418683af529>:0 
  at (wrapper dynamic-method) MessageCenter.PublishMessage_Patch2(object,MessageCenterMessage)
  at CustomUnits.CustomMechRepresentation._UpdateStateInfo () [0x00149] in <7e76cb6aa2b3444fa68630e44e072b61>:0 
  at CustomUnits.CustomMechRepresentation.PilotableActorRepresentation_Update () [0x00037] in <7e76cb6aa2b3444fa68630e44e072b61>:0 
  at CustomUnits.CustomMechRepresentation.Update () [0x00000] in <7e76cb6aa2b3444fa68630e44e072b61>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)
System.Reflection.MethodBase:GetMethodFromHandleInternalType_native(IntPtr, IntPtr, Boolean)
System.Reflection.MethodBase:GetMethodFromHandleNoGenericCheck(RuntimeMethodHandle)
System.Delegate:GetMethodImpl()
System.MulticastDelegate:GetMethodImpl()
System.Delegate:get_Method()
MessageSubscription:Name()
MessageSubscription:ToString()
MessageCenter:SendMessagesForType(MessageCenterMessageType, MessageCenterMessage)
MessageCenter:PublishMessage_Patch2(Object, MessageCenterMessage)
CustomUnits.CustomMechRepresentation:_UpdateStateInfo()
CustomUnits.CustomMechRepresentation:PilotableActorRepresentation_Update()
CustomUnits.CustomMechRepresentation:Update()

(Filename: <d7ac571ca2d04b2f981d0d886fa067cf> Line: 0)
abaire commented 2 years ago

I was able to track the issue down to a couple more bugs with the way the installer works:

  1. RtConfig.xml has a bug in the excludes where it excludes "Optional" but the actual directory in the RT data is "Optionals". It looks like this is gracefully handled in the RogueTechLauncher on Windows, so I added handling in the script. Fixing this prevents a handful of mods (including experimental ones) from being enabled regardless of the config having them disabled.
  2. The way I was merging mod.json files was naive and assumed there were no nested objects. This led to merges dropping data, which is probably what triggered the crash.

I also added support for the MultiComponentInstall type, so the Speed50x mod should work now.

The resultant Mods directory closely matches what I see in my Windows install, so I think things should work in general. At this point I can successfully get into a Skirmish mode level (I don't have time to play, but it seems like it's working).

You'll need to entirely delete your ~/Library/Application Support/Steam/steamapps/common/BATTLETECH/Mods directory and re-run the latest version of this installer bundle (in particular the hidden .modtek directory needs to be deleted since it has cached invalid data).

quickratio commented 2 years ago

Thanks for updating the repo! Tried the new script, it get's stuck on all loading screens, on new career it gets stuck on the loading screen after selecting your initial career settings; on load career stuck immediately on loading screen; same issue on skirmish, gets stuck on loading screen (the loading circle with the random quotes on the top left hand corner)

abaire commented 2 years ago

Odd, both career and skirmish work on my system with the new script. A couple things to try:

1) To double check: Did you completely delete the Mods directory? The bugs in the old script may have left things in an odd state, particularly the .modtek cache. 2) Check your maxfiles limit with launchctl limit maxfiles. According to the RogueTech install guide you may need to increase it (I did this prior to writing the install script and am unsure what the default value is; mine is currently maxfiles 65536 200000 3) While I don't think anything outside of the Mods directory could've been touched, it may be worth doing a "verify files," then deleting the Mods dir, then installing via the script again. I don't expect this will actually change anything, but seems like a good thing to try as a last resort.

Also to double check, when you say "stuck" do you have a pinwheel where the process is actually frozen or does it just not seem to be updating the screen? The load time is quite long, and I think the first time I fully loaded the game with RogueTech it was especially long - sticking for up to a minute or two at a time on the black screen with the loading circle in skirmish mode, then updating to show that some blocks were completed but also increasing the count of pending blocks.

quickratio commented 2 years ago

Yup, i deleted pretty much everything, i waited maybe 10 minutes? maybe i'll just let it go for a few hours and see what happens, if nothing i'll try the other suggestions and report back, thanks! :)

abaire commented 2 years ago

In my experience it should not take 10 minutes and definitely should not appear to be frozen for that long. I'd say my first time loading was maybe 5 minutes in total with one or two long freezes in there. It'd be interesting to see if the force quit window (command-option-escape) thinks that the process is frozen or not.

Just to be certain, if by "pretty much everything" you mean "not everything was deleted in the Mods directory" I'd strongly suggest starting with that. All of the content in the Mods directory is copied from (or linked to) the rtlcache directory, so it should be completely safe to delete the Mods directory entirely; you won't have to re-download anything. Depending on when you ran them, earlier versions of the install script could have left files in incorrect places, duplicated things incorrectly, and corrupted some of the json files so it's quite important to completely wipe out that mess.

You might also want to look at the log files in ~/Library/Application Support/Steam/steamapps/common/BATTLETECH/Mods/.modtek, ModTek.log and battletech_log.txt contain a lot of info about the loading process.

quickratio commented 2 years ago

oh sorry, some more clarification:

  1. Doesnt freeze, the pinwheel keeps spinning, but nothing happens, the quotes still continue to change next to the pinwheel (left it going for 2 hours with no result);
  2. Activity monitor shows it as running normally;
  3. I deleted the whole "Mod" folder and any other files that looked related i.e. that had RT in it outside of the mod folder;
  4. I also deleted the Cache.

I will try later this week to just delete everything (including the install) and try again from scratch, that way we will know it has nothing to do with errant files! :)

FYI I have all the DLCs too, so that shouldnt be an issue.

quickratio commented 2 years ago

Tried again on fresh install, and fresh python script run, i noticed this which seems unusual (last line in log), not sure if it means anything to you, i didnt see this string in your error handling either.

unfortunately i can't find the log files you mentioned

Resolving deltas: 100% (35/35), done.
Updating files: 100% (107/107), done.
INFO:root:Installing ModTek...
INFO:root:Copying RogueTech config...
INFO:root:Performing install...
WARNING:root:Skipping unsupported install type MThreadBootConfig for task mThreadRender
abaire commented 2 years ago

Tried again on fresh install, and fresh python script run, i noticed this which seems unusual (last line in log), not sure if it means anything to you, i didnt see this string in your error handling either.

That's normal, one of the default selected packages is supposed to enable multithreaded rendering, but I haven't looked into what the MThreadBootConfig action actually does yet. For now it's ignored and just uses the game's default rendering which appears to work fine.

EDIT: I just pushed a new version of the script that handles the multithreaded rendering option. I didn't see an obvious difference in performance in a brief Skirmish mode battle.

unfortunately i can't find the log files you mentioned They're only created after you run the game. They'll be interesting once you get into the broken state where the loading appears to freeze.

quickratio commented 2 years ago

thanks mate, appreciated, i'll give it a whirl :)