Skip to content

Commit

Permalink
Update Steamworks SDK from v1.57 to v1.58a (#2363)
Browse files Browse the repository at this point in the history
The next PR after #2350 and #2343.

This PR contains the following changes:

 1. Update SDK from v1.57 to v1.58a.
2. Improved the Shell Makefile (the part related to the Steamworks
extension).
- Moved building the fake API process inside a separate Makefile
specific to the fake API.
 3. Cleaned some comments including flushing the Steamworks Makefile.
 4. Fixed the README.md file.
 5. Improved documentation.
 6. Created a separate Makefile for the fake Steamworks API.
 7. Added v1.58a official headers.
 8. Fixed .gitignore file.

---------

Signed-off-by: Saif Kandil <74428638+k0T0z@users.noreply.github.com>
  • Loading branch information
k0T0z committed Mar 19, 2024
1 parent af54cea commit 3590b68
Show file tree
Hide file tree
Showing 60 changed files with 33,204 additions and 178 deletions.
3 changes: 0 additions & 3 deletions ENIGMAsystem/SHELL/Makefile
Expand Up @@ -125,9 +125,6 @@ include Bridges/$(PLATFORM)-$(GRAPHICS)/Makefile
# Else build the fake library.
ifeq (,$(findstring Universal_System/Extensions/Steamworks, $(EXTENSIONS)))
include Universal_System/StubExtensions/Steamworks/Makefile
else
compile_game: $(STEAM_FAKE_LIB)
clean: steam_clean
endif

# If DataStructures extension not enabled, enable DataStructures stub.
Expand Down
Expand Up @@ -22,6 +22,3 @@
# gb stands for Global Backup and it shouldn't be committed to git
# gb is auto-generated by the example game
/*.gb*/*

# This is only temporary, it will be removed once the Midterm review is done.
# /steamworks_demo/*
61 changes: 8 additions & 53 deletions ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/Makefile
Expand Up @@ -16,64 +16,19 @@
# with this code. If not, see <http://www.gnu.org/licenses/>
############################################################################

# Directories
STEAM_SDK_PATH := $(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv157/sdk
STEAM_FAKE_SDK_PATH := $(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/SteamFake/sdk
STEAMWORKS_API_VERSION := 158a

LINUX32 := linux32
LINUX64 := linux64
OSX := osx
WIN64 := win64
# Directories
STEAM_SDK_PATH := $(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv${STEAMWORKS_API_VERSION}/sdk

SOURCES += $(wildcard Universal_System/Extensions/Steamworks/*.cpp) \
$(wildcard Universal_System/Extensions/Steamworks/gameclient/*.cpp) \
$(wildcard Universal_System/Extensions/Steamworks/gameclient/utils/*.cpp) \
$(wildcard Universal_System/Extensions/Steamworks/gameclient/steambinder/*.cpp)

override CXXFLAGS += -I$(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv157/sdk/public/ \
-DENIGMA_STEAMWORKS_EXTENSION_ROOT=\"$(abspath .)/Universal_System/Extensions/Steamworks\"

FAKE_API_SRC_FILES := $(wildcard Universal_System/Extensions/Steamworks/gameclient/steambinder/SteamFake/sdk/public/steam/*.cpp)

STEAM_FAKE_LIB_NAME := fake_steam_api

STEAM_FAKE_LIB := $(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(LINUX64)/lib$(STEAM_FAKE_LIB_NAME).so

$(STEAM_FAKE_LIB): $(FAKE_API_SRC_FILES)
@echo "Building fake API..."
$(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^

steam_clean:
rm -rf $(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(LINUX32)/* \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(LINUX64)/* \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(OSX)/* \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(BIN_DIR)/* \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(WIN64)/*

$(shell mkdir -p $(STEAM_FAKE_SDK_PATH)/redistributable_bin \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(LINUX32) \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(LINUX64) \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(OSX) \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(BIN_DIR) \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(WIN64))

# ifeq ($(TARGET-PLATFORM), Windows)

# # defining directory of 64-bit lib file
# override LDFLAGS += -L$(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv157/sdk/redistributable_bin/win64/

# # check https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html#:~:text=Static%20Library%20vs.%20Shared%20Library
# # adding 64-bit lib file
# # this is static linking (maybe)
# override LDLIBS += -lsteam_api64

# else ifeq ($(TARGET-PLATFORM), Linux)

# # defining directory of 64-bit lib file
# override LDFLAGS += -L$(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv157/sdk/redistributable_bin/linux64

# # check https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html#:~:text=Static%20Library%20vs.%20Shared%20Library
# # adding 64-bit lib file
# override LDLIBS += -lsteam_api
# TODO: This macro won't help as the developer will have to run LGM twice in order to set the macro.
override CXXFLAGS += -I$(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv${STEAMWORKS_API_VERSION}/sdk/public/ \
-DENIGMA_STEAMWORKS_EXTENSION_ROOT=\"$(abspath .)/Universal_System/Extensions/Steamworks\" \
-DSTEAMWORKS_API_VERSION=\"$(STEAMWORKS_API_VERSION)\"

# endif
include Universal_System/Extensions/Steamworks/gameclient/steambinder/SteamFake/sdk/public/steam/Makefile
73 changes: 28 additions & 45 deletions ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/README.md
Expand Up @@ -8,12 +8,14 @@ me on ENIGMA's official Discord server.

- Ubuntu Linux.

## Building Steamworks Extension for Ubuntu Linux 64-bit
## Building Steamworks Extension

### Ubuntu Linux 64-bit

1. Download [Steam](https://store.steampowered.com/about/download).
2. Download [Steamworks SDK v157](https://partner.steamgames.com/downloads/steamworks_sdk_157.zip).
2. Download [Steamworks SDK v158a](https://partner.steamgames.com/downloads/steamworks_sdk_158a.zip).
3. Unzip the Steamworks SDK.
4. Copy the `redistributable_bin/` directory to `enigma-dev/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv157/sdk/`.
4. Copy the `redistributable_bin/` directory to `enigma-dev/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv158a/sdk/`.
5. [An alternative to step 4] Set the `STEAM_SDK_PATH` environment variable to the path of the `sdk/` directory in your unzipped Steamworks SDK by appending this line inside `.bashrc`.
```bash
cd ~
Expand All @@ -25,26 +27,26 @@ vim .bashrc
export STEAM_SDK_PATH=/path/to/steamworks/sdk
```
6. Find the path to your `gameoverlayrenderer.so` file:
```
```bash
find ~ -name gameoverlayrenderer.so
```
7. Now modify the `.bashrc` again and append these two lines (DON'T forget to change the path to your `gameoverlayrenderer.so` file):
- 64-bit
```bash
export LD_LIBRARY_PATH=~/Desktop/enigma-dev/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv157/sdk/redistributable_bin/linux64:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=~/Desktop/enigma-dev/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv158a/sdk/redistributable_bin/linux64:${LD_LIBRARY_PATH}

export LD_PRELOAD=/path/to/ubuntu12_64/gameoverlayrenderer.so:${LD_PRELOAD}
```
- 32-bit
```bash
export LD_LIBRARY_PATH=~/Desktop/enigma-dev/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv157/sdk/redistributable_bin/linux32:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=~/Desktop/enigma-dev/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/Steamv158a/sdk/redistributable_bin/linux32:${LD_LIBRARY_PATH}

export LD_PRELOAD=/path/to/ubuntu12_32/gameoverlayrenderer.so:${LD_PRELOAD}
```
8. Enable the Steamworks and Json extensions inside the IDE (LGM/RGM).
9. Run the demo to make sure everything is working fine `enigma-dev/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/steamworks_demo/demo.project.gmx`.

## Building Steamworks Extension for Windows 64-bit
### Windows 64-bit

```
Note: Windows support will be postponed due to an ABI issue as ENIGMA doesn't support MSVC yet, I recommend using Ubuntu Linux - 20/06/2023 00:45
Expand All @@ -55,31 +57,32 @@ Note: Currently, the Steam Binder doesn't support Windows.
```

1. Download [Steam](https://store.steampowered.com/about/download).
2. Download [Steamworks SDK v157](https://partner.steamgames.com/downloads/steamworks_sdk_157.zip).
2. Download [Steamworks SDK v158a](https://partner.steamgames.com/downloads/steamworks_sdk_158a.zip).
3. Unzip the Steamworks SDK.
4. Copy the `redistributable_bin\` directory to `enigma-dev\ENIGMAsystem\SHELL\Universal_System\Extensions\Steamworks\gameclient\steambinder\Steamv157\sdk\`.
4. Copy the `redistributable_bin\` directory to `enigma-dev\ENIGMAsystem\SHELL\Universal_System\Extensions\Steamworks\gameclient\steambinder\Steamv158a\sdk\`.
5. [An alternative to step 4] Set the `STEAM_SDK_PATH` environment variable to the path of the `sdk` directory in your unzipped Steamworks SDK (Note that if you used this step, you will have to run LGM/RGM from the same terminal):
```bash
STEAM_SDK_PATH="\path\to\steamworks\sdk"
```
6. Copy the `steam_api64.dll` from `enigma-dev\ENIGMAsystem\SHELL\Universal_System\Extensions\Steamworks\gameclient\steambinder\Steamv157\sdk\redistributable_bin\win64\` and then paste it into `C:\msys64\tmp\` directory. This must be done as LGM exports the executable in that location and we need that DLL to be with the executable.
6. Copy the `steam_api64.dll` from `enigma-dev\ENIGMAsystem\SHELL\Universal_System\Extensions\Steamworks\gameclient\steambinder\Steamv158a\sdk\redistributable_bin\win64\` and then paste it into `C:\msys64\tmp\` directory. This must be done as LGM exports the executable in that location and we need that DLL to be with the executable.
7. Enable the Steamworks and Json extensions inside the IDE (LGM/RGM).
8. Run the demo to make sure everything is working fine `enigma-dev\ENIGMAsystem\SHELL\Universal_System\Extensions\Steamworks\steamworks_demo\demo.project.gmx`.

## Steamworks Extension's Structure

```bash
```
Steamworks <------- 4th layer
├── gameclient <------- 3rd layer
│ ├── steambinder <------- 2nd layer
│ │ ├── SteamFake <------- Fake 1st layer
│ │ │ └── sdk
│ │ │ ├── public
│ │ │ │ └── steam
│ │ │ │ ├── Makefile
│ │ │ │ ├── *.h
│ │ │ │ └── *.cpp
│ │ │ │
│ │ │ └── Readme.txt
│ │ │ └── README.md
│ │ │
│ │ ├── SteamvXXX <------- Real 1st layer
│ │ │ └── sdk
Expand All @@ -90,6 +93,7 @@ Steamworks <------- 4th layer
│ │ │ └── Readme.txt
│ │ │
│ │ ├── .gitignore
│ │ ├── versioned_accessor_name_macros.h
│ │ ├── steambinder.h
│ │ └── steambinder.cpp
│ │
Expand Down Expand Up @@ -265,40 +269,19 @@ These are my critical sections:

## Integrating New Version of Steamworks SDK

1. Create a new version directory inside `Steamworks/gameclient/`,
1. Create a new version directory inside `Steamworks/gameclient/steambinder/`,
2. Download the new version of Steamworks SDK and extract it.
3. Copy only the `sdk` directory to `Steamworks/gameclient/steambinder/SteamvXXX/`.
4. Modify `Steamworks/Makefile` to point to the newer Steamworks SDK.
5. [Skip this step] Modify `Steamworks/CMakelists.txt` to point to the newer Steamworks SDK.
6. Add the new libraries to git inside `Steamworks/gameclient/steambinder/.gitignore` Leaving the old ones there.
7. Run the demo to make sure everything is working fine.
3. Copy `sdk/` directory to `Steamworks/gameclient/steambinder/SteamvXXX/`.
4. Modify `STEAMWORKS_API_VERSION` variable inside `Steamworks/Makefile` to point to the newer Steamworks SDK.
5. Modify `Steamworks/gameclient/steambinder/steambinder.h` to point to the newer Steamworks SDK interfaces.
6. [Skip this step] Modify `Steamworks/CMakelists.txt` to point to the newer Steamworks SDK.
7. Update the version link in the [Building Steamworks Extension](#building-steamworks-extension).
8. Run the demo to make sure everything is working fine.

## Incompatibility with GMS

1. ``steam_activate_overlay_user();`` function
- GMS:
```c++
steam_activate_overlay_user(string dialog_name, int64 steamid);
```
- ENIGMA
```c++
steam_activate_overlay_user(int dialog, int64 steamid);
```

dialog constants:
- `user_ov_steamid`
- `user_ov_chat`
- `user_ov_jointrade`
- `user_ov_stats`
- `user_ov_achievements`
- `user_ov_friendadd`
- `user_ov_friendremove`
- `user_ov_friendrequestaccept`
- `user_ov_friendrequestignore`

2. The user can set the maximum leaderboard entries to display using the user variable: ``lb_max_entries``.

3. steam_set_rich_presence();
- GMS: Returns ``void``
- ENIGMA: Returns ``bool``
| Incompatibility | ENIGMA | GMS | Notes | Breaks code? |
| --- | --- | --- | --- | --- |
| ``steam_activate_overlay_user`` function definition | steam_activate_overlay_user(int dialog, int64 steamid); | steam_activate_overlay_user(string dialog_name, int64 steamid); | dialog constants: `user_ov_steamid`, `user_ov_chat`, `user_ov_jointrade`, `user_ov_stats`, `user_ov_achievements`, `user_ov_friendadd`, `user_ov_friendremove`, `user_ov_friendrequestaccept`, and `user_ov_friendrequestignore` | Yes |
| Maximum leaderboard entries: ``lb_max_entries`` | The user can set | - | - | No |
| ``steam_set_rich_presence`` function return type | Returns ``bool`` | Returns ``void`` | - | No |
Expand Up @@ -72,29 +72,38 @@ class GCMain {
* @brief This function performs the following steps:
* @c 1. Calls @c GCMain::restart_app_if_necessary() function.
* @c 2. Calls @c SteamBinder::Init() function. Initializes the Steamworks API. A Steam client must
* be running in order for @c GCMain::init() to pass. If you are running If you're running your application
* from the executable or debugger directly then you must have a steam_appid.txt in your game directory
* next to the executable, with your app ID in it and nothing else.
* @c 3. Calls @c GameClient::is_user_logged_on() function. Checks if the user has logged into Steam. We can't proceed
* with anything if the user is not logged in right?!
* be running in order for @c GCMain::init() to pass. If you are running your application
* from the executable or debugger directly then you must have a steam_appid.txt in your game
* directory next to the executable, with your app ID in it and nothing else.
* @c 3. Calls @c GameClient::is_user_logged_on() function. Checks if the user has logged into Steam. We
* can't proceed with anything if the user is not logged in right?!
* @c 4. Instantiates the Game Client. This includes instantiating all the other clients.
* @c 5. Sets @c GCMain::is_initialised_ to true if all the above steps succeed. This variable can be accessed by
* calling @c GCMain::is_initialised() function.
* @c 5. Sets @c GCMain::is_initialised_ to true if all the above steps succeed. This variable can be
* accessed by calling @c GCMain::is_initialised() function.
*
* @note Maybe no need to call gameclient::is_user_logged_on() as advised by Steamworks here:
* https://partner.steamgames.com/doc/api/ISteamUser#BLoggedOn.
*
* @note Check https://partner.steamgames.com/doc/api/steam_api#SteamAPI_Init for more information.
*
* @return true
* @return false
* @return true If everything goes well.
* @return false in the below conditions:
* - If @c GCMain::restart_app_if_necessary() function succeeds.
* - If Steam client is not running.
* - If you are running your application from the executable or debugger directly and you don't have
* steam_appid.txt in your game directory.
* - [ @c v1.58 ] If the installed Steam client needs to be updated to support the game's version of
* the SDK.
* - If user is not logged in.
*/
inline static bool init() {
if (GCMain::restart_app_if_necessary()) {
return false;
}

if (!steamworks_b::SteamBinder::Init()) {
SteamErrMsg errMsg;
if (steamworks_b::SteamBinder::Init(NULL, &errMsg) != k_ESteamAPIInitResult_OK) {
DEBUG_MESSAGE(errMsg, M_ERROR);
return false;
}

Expand Down
Expand Up @@ -17,24 +17,32 @@
############################################################################

# Ignore everything.
/Steamv157/sdk/**/*
/SteamFake/sdk/**/*
/**/*

# Don't ignore Readme.txt file.
!/Steamv157/sdk/Readme.txt
!/SteamFake/sdk/Readme.txt
# Don't ignore me.
!.gitignore

# Don't ignore files inside the SteamvXXX/sdk/public/steam/ folder.
# Note that this code ignores directories inside the SteamvXXX/sdk/public/steam/ folder.
!/Steamv157/sdk/public/
!/Steamv157/sdk/public/steam/
!/Steamv157/sdk/public/steam/*
# Don't ignore source and header files.
!*.cpp
!*.h

# Don't ignore the SteamvXXX/ and SteamFake/ folders.
!/Steamv*/
!/SteamFake/
!/Steamv*/sdk/
!/SteamFake/sdk/

# Don't ignore README files.
!/Steamv*/sdk/Readme.txt
!/SteamFake/sdk/README.md

!/Steamv*/sdk/public/
!/SteamFake/sdk/public/
!/Steamv*/sdk/public/steam/
!/SteamFake/sdk/public/steam/
!/SteamFake/sdk/public/steam/*

# Don't ignore everything inside the SteamvXXX/sdk/redistributable_bin/ folder.
# !/Steamv157/sdk/redistributable_bin/
# !/Steamv157/sdk/redistributable_bin/**/*
# !/SteamFake/sdk/redistributable_bin/
# !/SteamFake/sdk/redistributable_bin/**/*
# Don't ignore files inside the SteamvXXX/sdk/public/steam/ folder.
# Note that this ignores directories inside the SteamvXXX/sdk/public/steam/ folder. This
# includes the SteamvXXX/sdk/public/steam/lib/ folder. This is intentional.
!/Steamv*/sdk/public/steam/*
!/SteamFake/sdk/public/steam/*
@@ -0,0 +1,52 @@
############################################################################
# Copyright (C) 2023-2024 Saif Kandil (k0T0z)
#
# This file is a part of the ENIGMA Development Environment.
#
# ENIGMA is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, version 3 of the license or any later version.
#
# This application and its source code is distributed AS-IS, WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with this code. If not, see <http://www.gnu.org/licenses/>
############################################################################

STEAM_FAKE_SDK_PATH := $(ENIGMA_ROOT)/ENIGMAsystem/SHELL/Universal_System/Extensions/Steamworks/gameclient/steambinder/SteamFake/sdk

STEAM_FAKE_SDK_LINUX32 := linux32
STEAM_FAKE_SDK_LINUX64 := linux64
STEAM_FAKE_SDK_OSX := osx
STEAM_FAKE_SDK_WIN64 := win64

FAKE_STEAMWORKS_API_SOURCES := $(wildcard Universal_System/Extensions/Steamworks/gameclient/steambinder/SteamFake/sdk/public/steam/*.cpp)

STEAM_FAKE_LIB_NAME := fake_steam_api

STEAM_FAKE_LIB := $(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(STEAM_FAKE_SDK_LINUX64)/lib$(STEAM_FAKE_LIB_NAME).so

$(STEAM_FAKE_LIB): $(FAKE_STEAMWORKS_API_SOURCES)
@echo "Building fake Steamworks API..."
$(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^

steam_clean:
rm -rf $(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(STEAM_FAKE_SDK_LINUX32)/* \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(STEAM_FAKE_SDK_LINUX64)/* \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(STEAM_FAKE_SDK_OSX)/* \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(STEAM_FAKE_SDK_WIN64)/*

$(shell mkdir -p $(STEAM_FAKE_SDK_PATH)/redistributable_bin \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(STEAM_FAKE_SDK_LINUX32) \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(STEAM_FAKE_SDK_LINUX64) \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(STEAM_FAKE_SDK_OSX) \
$(STEAM_FAKE_SDK_PATH)/redistributable_bin/$(STEAM_FAKE_SDK_WIN64))

# This is for building the fake API, you can find compile_game target in the SHELL Makefile.
compile_game: $(STEAM_FAKE_LIB)

clean: steam_clean

0 comments on commit 3590b68

Please sign in to comment.