Merge branch 'main' into feature/code-readibility-3-new-repo

This commit is contained in:
APAmk2
2025-01-26 01:18:59 +04:00
committed by GitHub
24 changed files with 236 additions and 20 deletions
+62
View File
@@ -0,0 +1,62 @@
name: Build and deploy webassembly version
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
jobs:
build_webassembly_version:
name: Build webassembly version
runs-on: ubuntu-latest
container: emscripten/emsdk:3.1.74
permissions: write-all
steps:
- name: Clone
uses: actions/checkout@v4
- name: Build fallout2 wasm module
run: |
git config --global --add safe.directory "*"
mkdir -p build
cd build
emcmake cmake ../ -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release && emmake make VERBOSE=1 -j 4
cd ..
- name: Add node
if: github.ref == 'refs/heads/main'
uses: actions/setup-node@v2
with:
node-version: '22'
- name: Checkout web interface
if: github.ref == 'refs/heads/main'
uses: actions/checkout@v4
with:
repository: ololoken/fallout2-ce-ems
ref: 46ac3be3da9d01ef204779073b1c1254fa037021
path: fallout2-ce-ems
- name: Build web interface
if: github.ref == 'refs/heads/main'
run: |
cd fallout2-ce-ems
npm install
cp ../build/fallout2-ce.js src/assets/fallout2ce
cp ../build/fallout2-ce.wasm src/assets/fallout2ce
sed -i 's/\/fallout2-ce-ems/\/fallout2-ce/' vite.config.ts
npm run build
- name: Install rsync (required for the next step)
run: |
apt-get update && apt-get install -y rsync
- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
if: github.ref == 'refs/heads/main'
with:
branch: gh-pages
folder: fallout2-ce-ems/dist
+2 -1
View File
@@ -9,6 +9,7 @@
*.user
*.userosscache
*.sln.docstates
.DS_Store
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
@@ -393,4 +394,4 @@ FodyWeavers.xsd
/build
# versioning header
src/platform/git_version.h
src/platform/git_version.h
+35 -5
View File
@@ -368,12 +368,42 @@ endif()
add_subdirectory("third_party/fpattern")
target_link_libraries(${EXECUTABLE_NAME} fpattern::fpattern)
if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux") AND (NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") AND (NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD"))
add_subdirectory("third_party/zlib")
add_subdirectory("third_party/sdl2")
if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten"))
if((NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux") AND (NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") AND (NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD"))
add_subdirectory("third_party/zlib")
add_subdirectory("third_party/sdl2")
else()
find_package(ZLIB)
find_package(SDL2)
endif()
else()
find_package(ZLIB)
find_package(SDL2)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
--use-port=sdl2 \
--use-port=sdl2_mixer \
--use-port=zlib" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
--use-port=sdl2 \
--use-port=sdl2_mixer \
--use-port=zlib" )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O1")
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O1")
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sASYNCIFY" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sASYNCIFY_STACK_SIZE=20480" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sENVIRONMENT=web" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sALLOW_MEMORY_GROWTH" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sNO_DISABLE_EXCEPTION_CATCHING" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-lidbfs.js" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sCASE_INSENSITIVE_FS" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sMODULARIZE" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sEXPORTED_RUNTIME_METHODS=callMain,addRunDependency,removeRunDependency" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sEXPORT_ALL" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sEXPORT_NAME=fallout2ce" )
target_link_options( ${EXECUTABLE_NAME} PRIVATE "$<$<CONFIG:DEBUG>:-g>" )
endif()
target_link_libraries(${EXECUTABLE_NAME} ${ZLIB_LIBRARIES})
+8
View File
@@ -66,6 +66,14 @@ $ sudo apt install libsdl2-2.0-0
- Use Finder (macOS Catalina and later) or iTunes (Windows and macOS Mojave or earlier) to copy `master.dat`, `critter.dat`, `patch000.dat`, and `data` folder to "Fallout 2" app ([how-to](https://support.apple.com/HT210598)). Watch for file names - keep (or make) them lowercased (see [Configuration](#configuration)).
### Browser
> **NOTE**: WebAssebly build with emscripten
```
docker run --rm -v $(pwd):/src emscripten/emsdk:3.1.74 sh -c 'git config --global --add safe.directory "*" && mkdir -p build && cd build && emcmake cmake ../ -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/Emscripten.cmake && emmake make'
```
- Demo available at https://github.com/ololoken/fallout2-ce-ems.git
## Configuration
The main configuration file is `fallout2.cfg`. There are several important settings you might need to adjust for your installation. Depending on your Fallout distribution main game assets `master.dat`, `critter.dat`, `patch000.dat`, and `data` folder might be either all lowercased, or all uppercased. You can either update `master_dat`, `critter_dat`, `master_patches` and `critter_patches` settings to match your file names, or rename files to match entries in your `fallout2.cfg`.
+9
View File
@@ -0,0 +1,9 @@
set( CMAKE_SYSTEM_NAME "Emscripten" )
add_compile_definitions("DEBUG=$<CONFIG:Debug>")
set( CMAKE_C_COMPILER "emcc" )
set( CMAKE_CXX_COMPILER "em++" )
set( EXECUTABLE_NAME fallout2-ce.js )
+2
View File
@@ -320,6 +320,7 @@ void automapShow(bool isInGame, bool isUsingScanner)
int oldFont = fontGetCurrent();
fontSetCurrent(101);
touch_set_touchscreen_mode(true);
int automapWindowX = (screenGetWidth() - AUTOMAP_WINDOW_WIDTH) / 2;
int automapWindowY = (screenGetHeight() - AUTOMAP_WINDOW_HEIGHT) / 2;
@@ -492,6 +493,7 @@ void automapShow(bool isInGame, bool isUsingScanner)
windowDestroy(window);
fontSetCurrent(oldFont);
touch_set_touchscreen_mode(false);
}
// Renders automap in Map window.
+3
View File
@@ -21,6 +21,7 @@
#include "scripts.h"
#include "sfall_config.h"
#include "svga.h"
#include "touch.h"
#include "window_manager.h"
namespace fallout {
@@ -347,6 +348,7 @@ int elevatorSelectLevel(int elevator, int* mapPtr, int* elevationPtr, int* tileP
}
const ElevatorDescription* elevatorDescription = gElevatorDescriptions[elevator];
touch_set_touchscreen_mode(true);
int index;
for (index = 0; index < ELEVATOR_LEVEL_MAX; index++) {
@@ -465,6 +467,7 @@ int elevatorSelectLevel(int elevator, int* mapPtr, int* elevationPtr, int* tileP
}
elevatorWindowFree();
touch_set_touchscreen_mode(false);
if (keyCode != KEY_ESCAPE) {
const ElevatorDescription* description = &(elevatorDescription[keyCode]);
+1
View File
@@ -3,6 +3,7 @@
#include "game_vars.h"
#include "message.h"
#include "touch.h"
namespace fallout {
+16
View File
@@ -8,6 +8,10 @@
#include "main.h"
#include "platform_compat.h"
#if defined(__EMSCRIPTEN__)
#include <emscripten.h>
#endif
namespace fallout {
static void gameConfigResolvePath(const char* section, const char* key);
@@ -197,6 +201,14 @@ bool gameConfigInit(bool isMapper, int argc, char** argv)
return true;
}
#if defined(__EMSCRIPTEN__)
// clang-format off
EM_ASYNC_JS(void, do_save_idbfs_gameconfig, (), {
await new Promise((resolve, reject) => FS.syncfs(err => err ? reject(err) : resolve()))
});
// clang-format on
#endif
// Saves game config into `fallout2.cfg`.
//
// 0x444C14
@@ -210,6 +222,10 @@ bool gameConfigSave()
return false;
}
#if defined(__EMSCRIPTEN__)
do_save_idbfs_gameconfig();
#endif
return true;
}
+6
View File
@@ -1410,6 +1410,12 @@ void gameMouseSetMode(int mode)
_combat_outline_off();
break;
}
if (mode == GAME_MOUSE_MODE_MOVE) {
touch_set_touchscreen_mode(true);
} else {
touch_set_touchscreen_mode(false);
}
}
// 0x44CB6C
+4
View File
@@ -1518,6 +1518,8 @@ static bool _setup_inventory(int inventoryWindowType)
bool isoWasEnabled = isoDisable();
_gmouse_disable(0);
touch_set_touchscreen_mode(true);
touch_set_pan_mode(true);
return isoWasEnabled;
}
@@ -1561,6 +1563,8 @@ static void _exit_inventory(bool shouldEnableIso)
windowDestroy(gInventoryWindow);
_gmouse_enable();
touch_set_touchscreen_mode(false);
touch_set_pan_mode(false);
if (_dropped_explosive) {
Attack attack;
+20
View File
@@ -59,6 +59,9 @@
#include "window_manager.h"
#include "word_wrap.h"
#include "worldmap.h"
#if defined(__EMSCRIPTEN__)
#include <emscripten.h>
#endif
namespace fallout {
@@ -446,6 +449,8 @@ int lsgSaveGame(int mode)
return -1;
}
touch_set_touchscreen_mode(mode == LOAD_SAVE_MODE_NORMAL);
if (_GetSlotList() == -1) {
windowRefresh(gLoadSaveWindow);
@@ -963,6 +968,8 @@ int lsgLoadGame(int mode)
return -1;
}
touch_set_touchscreen_mode(windowType == LOAD_SAVE_WINDOW_TYPE_LOAD_GAME || windowType == LOAD_SAVE_WINDOW_TYPE_LOAD_GAME_FROM_MAIN_MENU);
if (_GetSlotList() == -1) {
gameMouseSetCursor(MOUSE_CURSOR_ARROW);
windowRefresh(gLoadSaveWindow);
@@ -1525,10 +1532,19 @@ static int lsgWindowFree(int windowType)
colorCycleEnable();
gameMouseSetCursor(MOUSE_CURSOR_ARROW);
touch_set_touchscreen_mode(false);
return 0;
}
#if defined(__EMSCRIPTEN__)
// clang-format off
EM_ASYNC_JS(void, do_save_idbfs_loadsave, (), {
await new Promise((resolve, reject) => FS.syncfs(err => err ? reject(err) : resolve()))
});
// clang-format on
#endif
// 0x47D88C
static int lsgPerformSaveGame()
{
@@ -1679,6 +1695,10 @@ static int lsgPerformSaveGame()
snprintf(_gmpath, sizeof(_gmpath), "%s\\%s%.2d\\", "SAVEGAME", "SLOT", _slot_cursor + 1);
MapDirErase(_gmpath, "BAK");
#if defined(__EMSCRIPTEN__)
do_save_idbfs_loadsave();
#endif
gLoadSaveMessageListItem.num = 140;
if (messageListGetItem(&gLoadSaveMessageList, &gLoadSaveMessageListItem)) {
displayMonitorAddMessage(gLoadSaveMessageListItem.text);
+2
View File
@@ -279,6 +279,7 @@ void mainMenuWindowHide(bool animate)
}
windowHide(gMainMenuWindow);
touch_set_touchscreen_mode(false);
gMainMenuWindowHidden = true;
}
@@ -295,6 +296,7 @@ void mainMenuWindowUnhide(bool animate)
}
windowShow(gMainMenuWindow);
touch_set_touchscreen_mode(true);
if (animate) {
colorPaletteLoad("color.pal");
+3
View File
@@ -1260,6 +1260,9 @@ int mapHandleTransition()
} else {
if (!isInCombat()) {
if (gMapTransition.map != gMapHeader.index || gElevation == gMapTransition.elevation) {
// SFALL: Remove text floaters after moving to another map.
textObjectsReset();
mapLoadById(gMapTransition.map);
}
+4 -4
View File
@@ -409,11 +409,11 @@ void _mouse_info()
_mouse_simulate_input(gesture.x - prevx, gesture.y - prevy, MOUSE_STATE_RIGHT_BUTTON_DOWN);
}
} else if (gesture.type == kPan) {
if (gesture.numberOfTouches == 1) {
if (!touch_get_pan_mode() && gesture.numberOfTouches == 1) {
_mouse_simulate_input(gesture.x - prevx, gesture.y - prevy, 0);
} else if (gesture.numberOfTouches == 2) {
gMouseWheelX = (prevx - gesture.x) / 2;
gMouseWheelY = (gesture.y - prevy) / 2;
} else if (touch_get_pan_mode() || gesture.numberOfTouches == 2) {
gMouseWheelX = (prevx - gesture.x) / 8;
gMouseWheelY = (gesture.y - prevy) / 8;
if (gMouseWheelX != 0 || gMouseWheelY != 0) {
gMouseEvent |= MOUSE_EVENT_WHEEL;
+1 -1
View File
@@ -1299,7 +1299,7 @@ static void _MVE_sndSync()
}
v0 = true;
#ifdef EMSCRIPTEN
#if defined(__EMSCRIPTEN__)
delay_ms(1);
#endif
}
+3
View File
@@ -1476,6 +1476,9 @@ int objectSetLocation(Object* obj, int tile, int elevation, Rect* rect)
}
if (elevation != oldElevation) {
// SFALL: Remove text floaters after moving to another elevation.
textObjectsReset();
mapSetElevation(elevation);
tileSetCenter(tile, TILE_SET_CENTER_REFRESH_WINDOW | TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS);
if (isInCombat()) {
+4
View File
@@ -95,6 +95,8 @@ int showOptions()
return -1;
}
touch_set_touchscreen_mode(true);
int rc = -1;
while (rc == -1) {
sharedFpsLimiter.mark();
@@ -320,6 +322,8 @@ static int optionsWindowFree()
isoEnable();
}
touch_set_touchscreen_mode(false);
return 0;
}
+2
View File
@@ -414,6 +414,7 @@ int pipboyOpen(int intent)
return -1;
}
touch_set_touchscreen_mode(true);
mouseGetPositionInWindow(gPipboyWindow, &gPipboyPreviousMouseX, &gPipboyPreviousMouseY);
gPipboyLastEventTimestamp = getTicks();
@@ -480,6 +481,7 @@ int pipboyOpen(int intent)
}
pipboyWindowFree();
touch_set_touchscreen_mode(false);
return 0;
}
+3
View File
@@ -1195,6 +1195,7 @@ static int preferencesWindowFree()
fontSetCurrent(_oldFont);
messageListFree(&gPreferencesMessageList);
touch_set_touchscreen_mode(false);
return 0;
}
@@ -1214,6 +1215,8 @@ int doPreferences(bool animated)
mouseShowCursor();
}
touch_set_touchscreen_mode(true);
if (animated) {
colorPaletteLoad("color.pal");
paletteFadeTo(_cmap);

Some files were not shown because too many files have changed in this diff Show More