Giter Club home page Giter Club logo

sourcehold's Introduction

Sourcehold

Notice

This project is frozen until we know what the new Definitive Edition of Stronghold from Firefly will be able to do!

Looking for a Stronghold (Crusader) community? Join the UCP Discord Discord

Project description

Build Status

Open source engine implementation of Stronghold by Firefly Studios. This project is currently in an early stage of development. Once completed, it should be able to replace all editions of classic Stronghold, including the HD remaster.


Imgur

About

Stronghold is a castle sim created by Firefly Studios in 2001. It was released for Windows and supports MacOS since its HD remaster. The purpose of this project is to make Stronghold playable on platforms it didn't support originally. It is not intended to be a 100% accurate source port, so there will be differences.

Building

Sourcehold uses the following libraries:

  • SDL2
  • OpenAL
  • FFmpeg (avcodec, avutil, avformat, swscale)
  • zlib's blast for PKWARE decompression
  • EnTT as submodule
  • filesystem as submodule
  • cxxopts as submodule

After cloning the repository, make sure to run git submodule init and git submodule update to fetch EnTT, filesystem and cxxopts.

Run cmake in your build directory.

Windows

You will have to build the dependencies from source and the most convenient way is to use vcpkg.
This may take a long time, depending on your machine.
Alternatively you may install everything manually (not recommended).

Quickstart

Installing vcpkg:

git clone https://github.com/microsoft/vcpkg
cd vcpkg
./bootstrap-vcpkg.bat
vcpkg integrate install

Installing the dependencies:

vcpkg --triplet x64-windows install sdl2 ffmpeg openal-soft

Then continue building Sourcehold with CMake:

cmake -H. -B build -DCMAKE_TOOLCHAIN_FILE=%VCPKG_FOLDER%\scripts\buildsystems\vcpkg.cmake
cmake --build build

Mac OS

Simply run build.sh macos from apple directory in the repository root. This script will install Homebrew and all necessary dependencies and build project. To build debug configuration pass -t Debug option to build.sh.

Note: You should install Xcode before trying to build project using build.sh script. Also do not forget to pass -c option to build.sh if you build Mac OS version of the Sourcehold after iOS version.

iOS

Currently you can not build for iOS devices. Only iOS simulator is supported. To build Sourcehold for the iOS simulator run build.sh ios-simulator from apple directory in the repository root. Script will install Homebrew and all necessary tools. Also it will compile and install SDL2 and FFmpeg libraries to thirdparty/ios directory in the repository root. To build debug configuration pass -t Debug option to build.sh.

After building project with build.sh script you may also peform subsequent builds using Xcode. To do that simply open Stronghold.xcodeproj from cmake build directory.

Note: You should install Xcode before trying to build project using build.sh script. Also do not forget to pass -c option to build.sh if you build iOS version of the Sourcehold after Mac OS version.

Running

Make sure you point Sourcehold to where your game data is located, which you can do using --path=/your/path or copy the files to a directory called data in the main folder of Sourcehold. The directory should look like this:

data
├── binks/
├── fx/
├── gfx/
├── gfx8/
├── gm/
├── help/
├── maps/
├── stronghold.mlb
├── sh.tex
├── delete.ani
├── hand.ani
├── jester.ani
└── sword.ani

iOS

You may run iOS version on the simulator using run-on-ios-simulator.sh script. You should pass simulator UUID to this script. Run it without parameters to get list of available simulators and their UUIDs. By default run-on-ios-simulator.sh tries to run release configuration. Pass -t Debug option to alter this behaviour.

You also may just drag'n'drop application bundle (Stronghold.app) to the simulator and run it manually.

Note: Currently data folder is embedded into application bundle resources, thus you should put it in the main folder of Sourcehold before you build the project.

Configuration

This is either done by reading an existing Stronghold config file, found in your documents folder under Stronghold/stronghold.cfg, via command line or both. Options from the command line will overwrite the ones from the config. Available options are listed with the --help argument. You can also add your command line options to a file called settings.ini, in the form option=value.

iOS

On iOS configuration is not currently supported.

sourcehold's People

Contributors

antisc2 avatar apodrugin avatar atmaxinger avatar baalex avatar danielduel avatar filipjanitor avatar gynt avatar janso3 avatar natewind avatar nostritius avatar skrax avatar yiran001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sourcehold's Issues

refactor: TexutreAtlas

  • inherit from a static texture
  • remove alloc/destroy -> constructors/destructors/helper class
  • remove surface member
  • use overloads or make members public, instead of Get*/Set*

#92

Upgrading to C++17

The current master has dependencies to C++17 libraries.
Either we upgrade the codebase to use C++17, or we need to find substitutes for the following dependencies:

  • EnTT

#52

feature: OpenAL Interface

  • OpenAL instantiator class
    • RAII
    • created at app initialization
  • OpenAL Source interface
    • Accesors/Settors, e.g. Vector3<float> Position(); void Position(Vector3<float> pos);
    • plays nice with <algorithm>
  • OpenAL buffer interface
    • generic buffer allocation uint8_t/uint16_t/float

Sourcehold under Linux

Hi,

is the launcher made to run under Linux? At this moment I could compile the Sourcehold launcher, but I run into an error: "There appears to be no settings.ini in your installation path!"

It seems like that the settings.ini is auto generated by installation of original game. I have the original game, but I cannot run the original setup on Linux. So I never will get the settings.ini file.
For data folder I used unshield (https://github.com/twogood/unshield) to extract the cab files from original game.

Is it possible that the Sourcehold launcher creates the settings file? Thanks.

Need Help GM2 Converter

Hello metalvoidzz,

i write a new GM2 Exporter/Importer for easier editing the Images in the files but i do something wrong when i load the ByteArray for the Images
I complete to load the:
File Header
Palette
Image offset list
Image sizes list
Image Headers
Images as ByteArray

As an example i have the anim_armourer.gm1 loaded, the first picture there is 760 bytes big, but the decoding is not working right, do i have there a big mistake, maybe u can help me?

Picture of my code for decoding the bytearray:
help

ImageHeader of the first imgfile in anim_armourer.gm1
help

my decoded picture:
help

Make map alive - ECS/Deers

AC:

  • Create a very simple ECS
    One that can be rewritten in the future, so implementation should be done in a separate folder and the main code should call API of ECS.

  • Add Deer entity

  • Add system that can render deer
    Make it in a way that is can be easily used for other entities

  • Add system that is teleporting deers (nearby coordinates) on the map
    The throw-away system will be removed in the future, just to make things blink for now.

Note:

I want to make a proper movement system as the follow-up.

If somebody has knowledge about spawn spread pattern, please write and discuss in the comments :)
(not part of this one - just discussion point, excluded for the future:)

  • Figure out spawn pattern of entities
    This little spread at the start
    I think something detects that:
  1. "more than 1" entities are on the same coordinates
  2. It sends each entity on some nearby coordinates basing on the number of entities -> if you have 2-3 entities the spread is different than having f.e. 15 entities in 1 place.

Tgx file issue

The tgx parser will encounter errors when parsing files from the
data/gfx8/ directory.

refactor: TileSet

  • inherit from a static texture
  • remove alloc/create/destroy -> constructors/destructors/helper class
  • use overloads instead of Get/Set
  • remove surface member

#92
#96

refactor: Texture

  • use as a prototype for SDL_Texture
  • differ between Static/Streaming/Target texture types
  • only allow read/write access on streaming textures
  • remove alloc/destroy functions -> constructors/destructors
  • remove unused functions/members
  • add RAII texture locking

#90

Imported targets on MacOS

As you know, I have started cleaning up CMakeLists.txt and while doing so added imported targets like this:

find_package(OpenAL REQUIRED)
add_library(OpenAL::OpenAL UNKNOWN IMPORTED)
set_target_properties(OpenAL::OpenAL PROPERTIES
  IMPORTED_LOCATION ${OPENAL_LIBRARY}
  INTERFACE_INCLUDE_DIRECTORIES ${OPENAL_INCLUDE_DIR})

As it turns out, on MacOS this will not fly, since it fails to link frameworks correctly.
As a result, I have found this solution:

find_package(OpenAL REQUIRED)
if(APPLE)
  add_library(OpenAL::OpenAL INTERFACE IMPORTED)
  set_target_properties(OpenAL::OpenAL PROPERTIES
    APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${OPENAL_LIBRARY}
    INTERFACE_INCLUDE_DIRECTORIES ${OPENAL_INCLUDE_DIR})
else()
  add_library(OpenAL::OpenAL UNKNOWN IMPORTED)
  set_target_properties(OpenAL::OpenAL PROPERTIES
    IMPORTED_LOCATION ${OPENAL_LIBRARY}
    INTERFACE_INCLUDE_DIRECTORIES ${OPENAL_INCLUDE_DIR})
 endif()

MacOS should build fine now.

Type safety and consistency

Status Quo

  • Inconsistent interfaces across the subsystems
  • A high amount of type casting
  • Unclear definition and intention of types

Thesis

  • Revist current implementations and determine overlapping interfaces
  • Remove all type casting, if possible
  • Introduce aliases for common used types

Screenshots?

I think people will be more interested in testing this reimplementation and maybe collaborate with some code if you show its current state with some screenshots (even early ones!).

refactor: Surface

  • use Surface as a prototype for SDL_Surface (declare constants here)
  • remove alloc/destroy functions -> constructors/destructors
  • remove unused funtions/members
  • add RAII Surface locking

#90

I need data

Can someone tell me how to obtain the data file, or can you send me a copy directly. I'm stuck in the last step, God bless me

feature: FFMPEG interface

  • RAII objects std::unique_ptr
  • simple interface to decode entire files with FFMPEG (Video/Audio)
  • works nicely with OpenAL interface

I have a question

After running the project, all the options in the game do not have text descriptions or options to enter the game. Is this normal? What should I do if I want the project to play normally

Abandoned?

Hey, I'm not a contributor or something like this, I am closer of a potential user.
I am giving a look since months ago and now I realize that the last update was made 8 months ago.
Did you guys abandoned this project? It would be a great loss, the Stronghold series are one of these games that would benefit a lot of an open-source game engine re-implementation.

Don't give up now.

Pre-release

Stuff to do:

  • Windows compatibility
  • Working main menu
  • Working user interface
  • Correct cutscene rendering
  • Sound effects (ADPCM)
  • Loading / Saving
  • Placing buildings
  • Simple AI / path finding

Debug menu functionality

Add a basic menu (in the main menu) that can contain special worlds for testing functionality. Configs for those worlds should be loaded from an easy to edit file - for example json/xml/yml, or scripts - lua/js/ts/pyton which will return intermediate file.
After adding that - remove debug placeholders from in-game world loading.

See:
Lua: http://acamara.es/blog/2012/08/running-a-lua-5-2-script-from-c/
JS: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey
TS: transpiling TS to JS at the runtime and then running it as the point above
Python: https://www.codeproject.com/Articles/820116/Embedding-Python-program-in-a-C-Cplusplus-code

Note - exposing API for modding is not part of this issue. Just execute scripts, get generated json/xml/yml as the result, check if it is valid, parse and load a world with the generated config.

refactor: Renderer

  • move Resolutions to src/Common
  • remove init/destroy
  • remove unused
  • make full static class -> mandatory usage as Renderer::SomeFunc()
  • rename Render*() to Draw*()
  • overload Draw*()
  • rename *Display() to *()

#89

Placing buildings

Hi,

I am not sure whether this applies to stronghold, but it may interest you to know that in Stronghold Crusader Extreme buildings are stored in an array with buildings offset from each other by a span of 0x32C. Some things that I do know are stored for buildings within their block are owner, workers, etc.:
{ "Buildings": { "address": "0x00F9C6CA", "type": "integer", "category": "building", "owneroffset": "0x4", "workersneededoffset": "0xC6", "workersworkingoffset": "0xC8", "workersmissingoffset": "0xCA", "snoozedoffset": "0x1C4", "offset": "0x32C" } }

refactor: Display

  • remove init/destroy
  • make full static class -> force usage: Display::SomeFunc()
  • Use overloads instead of Set*/Get*

#89

Cfg file format

The current .cfg file has no specification.
My proposal is as follows.

Syntax

# This line is a comment
MusicVolume=42

# Whitespaces are ignored
Tax = .05f
  Username =     "Lord Stronghold"

Types

  • Integer
  • Floating Point
  • String

Some Stronghold and Crusader modding tools.

Hi. I remembered this project exists and thought that you might find those modding tools that I'm about to show you useful in this project.
Stronghold Image Toolbox: A program that can view and modify GM1 and TGX files. http://stronghold.heavengames.com/downloads/showfile.php?fileid=4474
Official Stronghold Crusader Modding Utilities: SHC Modding Utilities made by Firefly Studios themselves. This includes an AIV Editor, a BMP to TGX Converter, and a Text Compiling Tool for SHC. https://www.fileplanet.com/archive/p-78554/Stronghold-Crusader-Modding-Utilities/download (This is a download link I could find.)

Discord Link Invalid

The Discord link on the README is invalid:
https://discordapp.com/invite/736X9H

Also, I just want to say, I'm excited to see this project. Really love Stronghold Crusader and I hope to be able to contribute.

Menu boxes

The boxes used throughout the game to display messages (menu, victory screen, etc.).
Related functions can be found in GUI/MenuUtils.cpp.

  • Find an easy-to-use solution for rendering of different types
  • Make transparency/alpha blending work with SDL_Texture
  • (maybe) find an easy way to handle UI elements (i.e. buttons)

Tex file format

Stores all of the text strings, but also additional info, most likely
where the string appears.

Bink video fps isn't used in game loop

Hi,

all Bink videos are playing very fast when I run the game.
It occurs after changes of 2a1902d

I have figured out that the game loop doesn't used FPS rate of the video. Here is my fix:

UIState Startup::Begin()
{
...
    while(Running()) {
...
            switch(currentStartupState) {
...
            case STARTUP_INTRO:
...
              // respect FPS of Bink video (29.97fps)
              if(delta > 1.0 / intro->Fps()*2) {
                  startTime = now;
                  intro->Update();
              }

Fps getter have to be added to BinkVideo class too.

In my tests the video speed was correct but the audio track sounds not clear. In addition, I have no idea why the fps have to multiply by 2.

Perhaps it is better to implement a timer directly in the Update() function of the BinkVideo class.

Tidying up CMake

I think the CMakeLists needs some tidying up, alas moving it to to a more modern version.

Make ingame UI alive

Currently part of the UI is not rendered at all. Corresponding actions are not performed.
Here is an action plan which allows make ingame UI more or less alive:

  • Refactor Widget class and related subclasses
    -- Merge Container class functionality with Widget class to simplify widget hierarchies management.
    -- Add events processing to Widget class. This will allow us properly route events to subwidgets.
    -- Clean up Update methods in all widgets.
    -- Get rid of StaticElement. Use Widget subclass instead.
    -- Make Button widget more generic so it can be used with different background images.
  • Implement game menu (info, revert, etc.) rendering.
  • Implement game menu actions handling (show all necessary dialogs with minimal implementation).
  • Implement buildings selection menu rendering (render all buildings types, no animations).
  • Implement switching between tabs in buildings menu.

Unable to open GM1 file

First of all, thank you very much for this project! Stronghold Crusader was a big part of my youth and even though I never really played Stronghold 1 itself, being able to play a FOSS version of it on my favorite OS (Linux) natively is absolutely awesome!

After linking my Stronghold 1 installation to the directory the application seems to expect (../data), the game loads up fine. However, the console logs various parser errors.

[ GAME ] -> Starting version 0.1.4 (Linux)
[ALSOFT] (EE) Failed to set real-time priority for thread: Operation not permitted (1)
[ GAME ] -> Detected edition: Stronghold HD
[ GAME ] -> Done
[ PARSERS ] -> Unable to open Gm1 file '../data/../data/gm/body_deer.gm1'!
[ PARSERS ] -> Unable to open Gm1 file '../data/../data/gm/body_lord.gm1'!
[ PARSERS ] -> Unable to open Gm1 file '../data/../data/gm/tree_apple.gm1'!
[ PARSERS ] -> Unable to open Gm1 file '../data/../data/gm/tree_birch.gm1'!
[ PARSERS ] -> Unable to open Gm1 file '../data/../data/gm/Tree_Chestnut.gm1'!
[ PARSERS ] -> Unable to open Gm1 file '../data/../data/gm/tree_oak.gm1'!
[ PARSERS ] -> Unable to open Gm1 file '../data/../data/gm/tree_pine.gm1'!
[ PARSERS ] -> Unable to open Gm1 file '../data/../data/gm/tree_shrub1.gm1'!
[ PARSERS ] -> Unable to open Gm1 file '../data/../data/gm/tree_shrub2.gm1'!
[ PARSERS ] -> Unable to open Tgx file '"../data/gfx/logo2.tgx"'!

Is this to be expected in the current stage of development and should I just have patience, or is something going wrong here?

Stronghold Definitive Edition

The title pretty much says it all, Firefly Studios recently announced the release of the Stronghold Definitive Edition, which will (or at least is trying to be) be a remaster of Stronghold 1.

What do you think of that regarding this project specifically? Will you continue or is it already pretty much dead (looks like it)? The remaster will probably address all the points you wanted to improve upon on the original game. Well, maybe all except the open-source nature of course. And oh well, I hope they make a working game and don't just release another trashy game.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.