Wargus / wargus

Importer and scripts for Warcraft II: Tides of Darkness, the expansion Beyond the Dark Portal, and Aleonas Tales
GNU General Public License v2.0
356 stars 55 forks source link

[macOS] Wartool requires resources in source code folder #438

Open shinra-electric opened 1 year ago

shinra-electric commented 1 year ago

Describe the bug It is possible to make a macOS app bundle that works fine for playing the game.

However, Wartool will try to copy over the campaigns, contrib, maps, scripts, and shaders folders from the source code folder, and merge them with the extracted game data. If the Wargus source folder is not there, the game extraction will fail.

To Reproduce

  1. Download the source code
  2. Build a macOS app bundle
  3. Launch the game, and extract the game data on first run. It should succeed. (BNE or GOG).
  4. Delete the game data in Application Support
  5. Delete the source code folder
  6. Launch the game again and try to extract game data. It should fail.

Expected behavior The data extraction step should work if the source code folder is not present.

Edit: I noticed that the bundle.sh script does actually copy these files into the app bundle in Wargus.app/Contents/MacOS. So the issue here is that wartool is not looking for them in the correct place.

Desktop: macOS Ventura 13.2.1 / M1 Pro

rtrzebinski commented 1 year ago

Would that be possible to build the latest MacOS app with Github actions?

shinra-electric commented 1 year ago

Would that be possible to build the latest MacOS app with Github actions?

This issue would prevent the data extractor tool from working

YunaBraska commented 7 months ago

I am technically too far away to debug this. But I am also interested to get it working. I followed the Stargus MacOs build instruction. Everything went fine except of the data extraction from any of my Warcraft copies. GOG and CD. F1 / Help Screenshot 2023-12-19 at 16 28 53 Screenshot 2023-12-19 at 16 28 36 Screenshot 2023-12-19 at 16 28 21 Screenshot 2023-12-19 at 16 27 41

shinra-electric commented 7 months ago

Did you try to use innoextract (command-line tool) or MSP's Extractor tool on the GoG install exe?

YunaBraska commented 7 months ago

No, but just downloaded now. Do you have instructions how to continue? From where to where, extract files?

shinra-electric commented 7 months ago

Hmm, now I'm having trouble with it... 😅

shinra-electric commented 7 months ago

Sorry, looks like there was a regression. I can't get the wartool extractor to work at all...

FYI Wargus was the only one that was extracting data properly before, war1gus and Stargus both missed files.

If you use Wine or Wineskin maybe try to extract the data with the Windows version of Wargus? I'll be giving that a try now...

YunaBraska commented 7 months ago

I also have wargus running on Windows. Is there a way to use these files from Windows? I copied the stargus folder to my home folder but wagus on macOS didn't accept that.

shinra-electric commented 7 months ago

If you have already extracted the data on Windows, there should be a data.Wargus folder that you should be able to use (as well as data.War1gus and data.Stargus if you have those too). You can copy them into the Stratagus folder in ~/Library/Application Support, where ~ represents your user name. If the Stratagus folder isn't there you can create it.

FYI I know that War1gus and Wargus both work, but I've never gotten Stargus to work...

YunaBraska commented 7 months ago

Ah, now it starts :) But can't start a game. The fonts and button positions seems to be broken :( But this is just a workaround anyway. Would be nice to know how we can support to make wargus working again. It seems to run... so it's possible, just need fixes. :D Screenshot 2023-12-19 at 17 18 31 Screenshot 2023-12-19 at 17 17 06

shinra-electric commented 7 months ago

Ah, now it starts :) But can't start a game. The fonts and button positions seems to be broken :(

The app actually works fine if you have the properly extracted game data:

Screenshot 2023-12-19 at 17 29 08

It's just the extractor tools that are broken on macOS (war1tool, wartool and startool)

But this is just a workaround anyway. Would be nice to know how we can support to make wargus working again. It seems to run... so it's possible, just need fixes. :D

Absolutely. But the main devs don't have Macs....

YunaBraska commented 7 months ago

Nope :( I get this message and then it starts broken :( I just installed wargus 3.3.2 on windows. did everything again and still broken :/ Screenshot 2023-12-19 at 17 44 19

YunaBraska commented 7 months ago

Hm, i managed to find the button to start the game. Everything in the game is fine. Just everything with text is not readable. It is now not only a strategic game, it's also a guessing game :/ Warcraft 1 and Warcraft 2, both have same font issues. I guess its the extractor again as it tries to migrate something

shinra-electric commented 7 months ago

Ok, I got wartool working again...

  1. You need to still have the Wargus source code folder still around (It's not needed after you have the game data).
  2. You need to use innoextract or Extractor on the GoG installer
  3. Use wartool from the command line. It can be found in the Wargus build folder or else within the app bundle.
  4. use the command ./wartool -v -r [source folder] [destination folder] where the source folder is wherever you extracted the GoG data to, and the destination folder is ~/Library/Application Support/Stratagus/data.Wargus

However, the game doesn't launch by opening the app bundle. you can run it from the command line.

All the game data seems to be extracting, but there is one folder called shaders that I have in my old game data that is missing. The whole thing is 14.6MB smaller, so I think it's missing more files.

Edit: Bizzarely, I'm getting black text on the menu now, even if I go back to my old data and old wargus build....

Edit 2: I've confirmed that the black text on the menu is a regression in Stratagus. I've built checking out older commits and it works fine. I'll bisect and report the PR with the regression....

shinra-electric commented 7 months ago

The last commit that seems to work without issue is #584.

So you can add a checkout instruction to the script:

For example:

...
cd stratagus
git checkout 7b2d62e10098f2f310aca352de84568936a0fafb
mkdir build && cd build
...
YunaBraska commented 7 months ago

@shinra-electric You are the hero of the day!!! That worked!!! Even the data extraction works now for me. So the master is unfortunately unstable.

BTW: Here is my script out of the build instructions, where you easily can exchange versions:

Requirements

Build Script

(Plain POSIX sh)

#!/usr/bin/env bash
set -e

# Clone repositories
clone_and_checkout() {
    repo_url="$1"
    dir_name="$2"
    revision="$3"

    # Clone the repository
    if [ ! -d "$dir_name" ]; then
      echo "########## CLONE [$2]"
      git clone --recurse-submodules "$repo_url" "$dir_name"
    fi

    # Checkout the specific tag if the repository was cloned
    if [ -d "$dir_name" ]; then
      echo "########## CHECKOUT [$2] [$revision]"
      cd "$dir_name"
      git add . > /dev/null 2>&1 || true
      git stash > /dev/null 2>&1 || true
      rm -rf build > /dev/null 2>&1 || true
      mkdir -p build || true
      git fetch --tags
      git checkout -f "$revision" || true
      git submodule foreach --recursive git clean -xfd || true
      git submodule foreach --recursive git reset --hard || true
      cd ..
    fi
}

clone_and_checkout https://github.com/Wargus/stratagus stratagus "7b2d62e10098f2f310aca352de84568936a0fafb"
clone_and_checkout https://github.com/Wargus/war1gus war1gus "3.3.2"
clone_and_checkout https://github.com/Wargus/wargus wargus "3.3.2"
clone_and_checkout https://github.com/Wargus/stargus stargus "3.3.2"

# Build STRATAGUS
echo "########## Build [stratagus]"
cd stratagus
mkdir -p build && cd build
cmake .. -Wno-dev -DBUILD_VENDORED_LUA=ON && make
cd ../..

export STRATAGUS_INCLUDE_DIR="$PWD"/stratagus/gameheaders
export STRATAGUS="$PWD"/stratagus/build/stratagus

# Build WAR1GUS
echo "########## Build [war1gus]"
cd war1gus
cd build
cmake .. -Wno-dev -DSTRATAGUS_INCLUDE_DIR="$STRATAGUS_INCLUDE_DIR" -DSTRATAGUS="$STRATAGUS" && make
cd ../mac
./bundle.sh
cp -a War1gus.app ../../
cd ../..

# Build WARGUS
echo "########## Build [wargus]"
cd wargus
cd build
cmake .. -Wno-dev -DSTRATAGUS_INCLUDE_DIR="$STRATAGUS_INCLUDE_DIR" -DSTRATAGUS="$STRATAGUS" && make
cd ../mac
./bundle.sh
cp -a Wargus.app ../../
cd ../..

# Build STARGUS
echo "########## Build [stargus]"
cd stargus
meson setup -DSTRATAGUS_INCLUDE_DIR="$STRATAGUS_INCLUDE_DIR" -DSTRATAGUS_BIN="$STRATAGUS" build
ninja -C build
cd mac
./bundle.sh
cp -a Stargus.app ../../
cd ..
echo "########## Done"

System

Apple M1 14" 2021 OS: macOS 14.2 (Sonoma)

YunaBraska commented 7 months ago

Only Warcraft 1 campaign is now crashing for me. I tried several commits but haven't found jet one which is working.

shinra-electric commented 7 months ago

@YunaBraska We should chat about it on the Stratagus discord channel so we don't derail this issue.

shamilovtim commented 2 months ago

Lua5.1 is no longer available so I cannot make Mac work at all anymore

shinra-electric commented 2 months ago

Lua5.1 is no longer available so I cannot make Mac work at all anymore

Let's keep this issue on topic. Create a new issue if you are having problems with Lua. For what it's worth, I just built Wargus using the latest version of Lua (5.4.6) and didn't have issues.

shamilovtim commented 2 months ago

Lua5.1 is no longer available so I cannot make Mac work at all anymore

Let's keep this issue on topic. Create a new issue if you are having problems with Lua. For what it's worth, I just build Wargus using the latest version of Lua (5.4.6) and didn't have issues.

I was using the Wiki and those steps no longer worked and failed at Lua. But then I used these steps from the txt file:

# Stratagus/Stargus/Wargus build instructions:
# It is assumed you have Xcode command-line tools and Homebrew already installed

# Install the following dependencies (There may be more than listed here, add as required)
brew install cmake sdl2 sdl2_mixer sdl2_image lua libpng ninja meson ffmpeg

# Copy and paste everything below into terminal
# You should find the Warg1us, Wargus and Stargus apps in the folder where you started

git clone --recurse-submodules https://github.com/Wargus/stratagus
git clone --recurse-submodules https://github.com/Wargus/war1gus
git clone --recurse-submodules https://github.com/Wargus/wargus
git clone https://github.com/Wargus/stargus

# STRATAGUS
cd stratagus 
mkdir build && cd build
cmake .. -DBUILD_VENDORED_LUA=ON && make
cd ... 
export STRATAGUS_INCLUDE_DIR=${PWD}/stratagus/gameheaders
export STRATAGUS=${PWD}/stratagus/build/stratagus

# WAR1GUS
cd war1gus
mkdir build && cd build
cmake .. -DSTRATAGUS_INCLUDE_DIR=${PWD}/../../stratagus/gameheaders -DSTRATAGUS=${PWD}/../../stratagus/build/stratagus && make
cd ../mac
./bundle.sh
cp -a War1gus.app ... 
cd ...

# WARGUS
cd wargus
mkdir build && cd build
cmake .. -DSTRATAGUS_INCLUDE_DIR=${PWD}/../../stratagus/gameheaders -DSTRATAGUS=${PWD}/../../stratagus/build/stratagus && make
cd ../mac
./bundle.sh
cp -a Wargus.app ... 
cd ...

# STARGUS
cd stargus
meson setup -DSTRATAGUS_INCLUDE_DIR=$STRATAGUS_INCLUDE_DIR -DSTRATAGUS_BIN=$STRATAGUS build
ninja -C build
cd mac  
./bundle.sh
cp -a Stargus.app ... 
cd ...

Unfortunately the extractor for the MS DOS version is completely busted now. I specify a mounted CD at /Volumes/WAR2 and the extractor is creating broken extracted files. If these files came from the game I'm not sure how it made them 0 bytes. It does seem to extract a bunch of campaign files and music MIDs successfully. Tried Wartool in various ways and no luck with that either.