mirror of
https://github.com/fallout2-ce/fallout2-ce.git
synced 2026-07-27 16:47:11 -07:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bf90077a9 | ||
|
|
779eb87f53 | ||
|
|
3d10e54852 | ||
|
|
65ed0fcde2 | ||
|
|
f08c427a52 | ||
|
|
7ff64df022 | ||
|
|
5e6f2a0b1b | ||
|
|
224b76bf1c |
@@ -14,16 +14,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
permissions: write-all
|
||||
steps:
|
||||
- name: start deployment
|
||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: bobheadxi/deployments@v1
|
||||
id: deployment
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
step: start
|
||||
debug: true
|
||||
env: preview-${{ github.event.pull_request.number }}
|
||||
|
||||
- name: Clone
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -86,10 +76,6 @@ jobs:
|
||||
SITE_BASE: ${{ steps.set-path.outputs.SITE_BASE }}
|
||||
F2_GAME_VERSION: Game=${{github.event.pull_request.head.sha || github.sha }}
|
||||
|
||||
- name: Place hash file
|
||||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
|
||||
run: echo "$GITHUB_SHA" > fallout2-ce-ems/dist/site_hash.txt
|
||||
|
||||
- name: Install rsync (required for the next step)
|
||||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
|
||||
run: |
|
||||
@@ -105,37 +91,10 @@ jobs:
|
||||
clean: false
|
||||
single-commit: true
|
||||
|
||||
|
||||
|
||||
- name: Check that site is deployed
|
||||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
|
||||
run: |
|
||||
URL="$SITE_ORIGIN""$SITE_BASE""site_hash.txt"
|
||||
echo "Expecting $GITHUB_SHA from $URL"
|
||||
for i in `seq 1 80`; do
|
||||
got="$(curl -fsSL --max-time 10 "$URL" | tr -d '\r\n' || true)"
|
||||
if [ "$got" = "$GITHUB_SHA" ]; then
|
||||
echo "âś… Match on attempt $i: ${got}"
|
||||
exit 0
|
||||
fi
|
||||
echo "Received $got, waiting"
|
||||
sleep 5
|
||||
done
|
||||
exit 1
|
||||
|
||||
env:
|
||||
SITE_ORIGIN: https://${{ github.repository_owner }}.github.io
|
||||
SITE_BASE: ${{ steps.set-path.outputs.SITE_BASE }}
|
||||
|
||||
- name: Update deployment status
|
||||
- name: Comment preview URL on PR
|
||||
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: bobheadxi/deployments@v1
|
||||
with:
|
||||
step: finish
|
||||
status: success
|
||||
debug: true
|
||||
env: ${{ steps.deployment.outputs.env }}
|
||||
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
env_url: https://${{ github.repository_owner }}.github.io/fallout2-ce/PR-${{ github.event.pull_request.number }}/
|
||||
|
||||
run: |
|
||||
gh pr comment ${{ github.event.pull_request.number }} \
|
||||
--body "🚀 WebAssembly PR Preview for ${{github.event.pull_request.head.sha || github.sha }} is available at: https://${{ github.repository_owner }}.github.io/fallout2-ce/PR-${{ github.event.pull_request.number }}/"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
@@ -87,7 +87,7 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: os/android/app/.cxx
|
||||
key: android-cmake-v101
|
||||
key: android-cmake-v2
|
||||
|
||||
- name: Setup signing config
|
||||
if: env.KEYSTORE_FILE_BASE64 != '' && env.KEYSTORE_PROPERTIES_FILE_BASE64 != ''
|
||||
@@ -128,7 +128,7 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: out
|
||||
key: ios-cmake-v101
|
||||
key: ios-cmake-v5
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
@@ -183,7 +183,7 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: out
|
||||
key: linux-${{ matrix.arch }}-cmake-v101
|
||||
key: linux-${{ matrix.arch }}-cmake-v3
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
@@ -288,7 +288,7 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: out
|
||||
key: macos-cmake-v101
|
||||
key: macos-cmake-v6
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
@@ -328,16 +328,16 @@ jobs:
|
||||
- name: Clone
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Visual Studio 2022 Build Tools with v141_xp
|
||||
- name: Install Visual Studio 2019 Build Tools with v141_xp
|
||||
shell: cmd
|
||||
run: |
|
||||
choco install visualstudio2022buildtools -y --package-parameters="'--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.Component.VC.v141.xp --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.10240 --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.WinXP --add Microsoft.VisualStudio.Component.WinXP'"
|
||||
choco install visualstudio2019buildtools -y --package-parameters="'--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.Component.VC.v141.xp --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.10240 --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.WinXP --add Microsoft.VisualStudio.Component.WinXP'"
|
||||
|
||||
- name: Cache cmake build
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: out
|
||||
key: windows-${{ matrix.arch }}-cmake-v102
|
||||
key: windows-${{ matrix.arch }}-cmake-v3
|
||||
|
||||
- name: Configure
|
||||
shell: cmd
|
||||
@@ -432,4 +432,4 @@ jobs:
|
||||
tag_name: continious
|
||||
draft: false
|
||||
prerelease: true
|
||||
name: Fallout2-CE Continuous Build
|
||||
name: Fallout2-CE Continuous Build
|
||||
@@ -12,7 +12,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
deployments: write
|
||||
steps:
|
||||
- name: Checkout gh-pages branch
|
||||
uses: actions/checkout@v4
|
||||
@@ -44,12 +43,4 @@ jobs:
|
||||
else
|
||||
git commit --amend -m "đźš® Remove preview for closed PR #${{ github.event.pull_request.number }}"
|
||||
git push --force
|
||||
fi
|
||||
|
||||
- name: mark environment as deactivated
|
||||
uses: bobheadxi/deployments@v1
|
||||
with:
|
||||
step: deactivate-env
|
||||
env: preview-${{ github.event.pull_request.number }}
|
||||
desc: Environment was pruned
|
||||
debug: true
|
||||
fi
|
||||
+8
-10
@@ -24,8 +24,10 @@ option(FALLOUT_VENDORED "Use vendored third-party libraries" ON)
|
||||
|
||||
if(ANDROID)
|
||||
add_library(${EXECUTABLE_NAME} SHARED)
|
||||
elseif(APPLE)
|
||||
add_executable(${EXECUTABLE_NAME} MACOSX_BUNDLE)
|
||||
else()
|
||||
add_executable(${EXECUTABLE_NAME} WIN32 MACOSX_BUNDLE)
|
||||
add_executable(${EXECUTABLE_NAME})
|
||||
endif()
|
||||
|
||||
# Git Info
|
||||
@@ -286,19 +288,12 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
|
||||
"src/sfall_metarules.h"
|
||||
"src/sfall_opcodes.cc"
|
||||
"src/sfall_opcodes.h"
|
||||
"src/sfall_script_hooks.cc"
|
||||
"src/sfall_arrays.cc"
|
||||
"src/sfall_arrays.h"
|
||||
"src/sfall_callbacks.cc"
|
||||
"src/sfall_callbacks.h"
|
||||
"src/touch.cc"
|
||||
"src/touch.h"
|
||||
"src/scan_unimplemented.cc"
|
||||
"third_party/lodepng/lodepng.cpp"
|
||||
)
|
||||
|
||||
target_include_directories(${EXECUTABLE_NAME} PUBLIC "third_party/lodepng")
|
||||
|
||||
if(IOS)
|
||||
target_sources(${EXECUTABLE_NAME} PUBLIC
|
||||
"src/platform/ios/paths.h"
|
||||
@@ -319,8 +314,7 @@ endif()
|
||||
if(WIN32)
|
||||
target_link_libraries(${EXECUTABLE_NAME}
|
||||
winmm
|
||||
debug libcpmtd
|
||||
optimized libcpmt
|
||||
# libcpmt # Disabled, was causing issues on VS2019 builing from UI
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -331,6 +325,10 @@ if(WIN32)
|
||||
)
|
||||
endif()
|
||||
|
||||
if (MSVC AND CMAKE_GENERATOR_TOOLSET STREQUAL "v141_xp")
|
||||
add_definitions(-DTOOLSET_V141_XP)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
if(IOS)
|
||||
set(RESOURCES
|
||||
|
||||
+5
-4
@@ -28,10 +28,10 @@
|
||||
"inherits": [
|
||||
"windows-base"
|
||||
],
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"generator": "Visual Studio 16 2019",
|
||||
"architecture": "Win32",
|
||||
"toolset": "v141_xp",
|
||||
"cacheVariables": {
|
||||
"CMAKE_GENERATOR_TOOLSET": "v141_xp",
|
||||
"CMAKE_C_FLAGS": "/D_WIN32_WINNT=0x0501",
|
||||
"CMAKE_CXX_FLAGS": "/D_WIN32_WINNT=0x0501 /D_STATIC_CPPLIB",
|
||||
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
||||
@@ -42,7 +42,7 @@
|
||||
"inherits": [
|
||||
"windows-base"
|
||||
],
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"generator": "Visual Studio 16 2019",
|
||||
"architecture": "x64",
|
||||
"cacheVariables": {
|
||||
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
||||
@@ -61,7 +61,8 @@
|
||||
},
|
||||
"cacheVariables": {
|
||||
"FALLOUT_VENDORED": "OFF"
|
||||
}
|
||||
},
|
||||
"generator": "Unix Makefiles"
|
||||
},
|
||||
{
|
||||
"name": "linux-x86-base",
|
||||
|
||||
@@ -44,7 +44,7 @@ $ sudo apt install libsdl2-2.0-0
|
||||
|
||||
- Alternatively you can use Fallout 2 from Macplay/The Omni Group as a base - you need to extract game assets from the original bundle. Mount CD/DMG, right click `Fallout 2` -> `Show Package Contents`, navigate to `Contents/Resources`. Copy `GameData` folder somewhere, for example `/Applications/Fallout2`.
|
||||
|
||||
- Or if you're a Terminal user and have Homebrew installed you can extract the needed files from the GoG installer. **Note**: You must use "Offline backup game installer", not the main game installer.
|
||||
- Or if you're a Terminal user and have Homebrew installed you can extract the needed files from the GoG installer:
|
||||
|
||||
```console
|
||||
$ brew install innoextract
|
||||
@@ -125,18 +125,7 @@ IFACE_BAR_SIDES_ORI=0
|
||||
;This will increase the width of the interface bar expanding the area used to display text.
|
||||
;if IFACE_BAR_WIDTH=640 - Interface bar will remain at it's original width.
|
||||
;if IFACE_BAR_WIDTH=800 - Interface bar will use 800pix wide asset from f2_res.dat.
|
||||
;IFACE_BAR_WIDTH=640
|
||||
|
||||
[STATIC_SCREENS]
|
||||
;if SPLASH_SCRN_SIZE=0 - Splash screen shows at original size if it fits, otherwise scales down while preserving aspect ratio.
|
||||
;if SPLASH_SCRN_SIZE=1 - Splash screen scales to fit the screen while preserving aspect ratio.
|
||||
;if SPLASH_SCRN_SIZE=2 - Splash screen stretches to fill the entire screen.
|
||||
SPLASH_SCRN_SIZE=0
|
||||
|
||||
[MAPS]
|
||||
;if IGNORE_MAP_EDGES=0 - Hi-Res map scroll edges are enabled.
|
||||
;if IGNORE_MAP_EDGES=1 - Hi-Res map scroll edges are ignored.
|
||||
IGNORE_MAP_EDGES=0
|
||||
IFACE_BAR_WIDTH=640
|
||||
```
|
||||
|
||||
Recommendations:
|
||||
|
||||
+1
-2
@@ -4,8 +4,7 @@
|
||||
[Main]
|
||||
|
||||
;Set to one to hide areas outside map bounds when using higher than 640x480 resolution, and to zero to disable
|
||||
;EnableHighResolutionStencil=1
|
||||
|
||||
;HiResMode=1
|
||||
|
||||
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
[Misc]
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
*.int
|
||||
sfall
|
||||
@@ -166,7 +166,7 @@ procedure array_test_suite begin
|
||||
|
||||
display_msg("All tests finished with "+test_suite_errors+" errors.");
|
||||
|
||||
call report_test_results("arrays");
|
||||
call report_test_results("Arrays");
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#include "test_utils.h"
|
||||
#include "sfall.h"
|
||||
|
||||
procedure start begin
|
||||
display_msg("Testing iface_tag functions...");
|
||||
// assumes no iface tags active in the save game
|
||||
|
||||
// SNEAK
|
||||
show_iface_tag(0);
|
||||
call assertTrue("show_iface_tag(SNEAK)", is_iface_tag_active(0));
|
||||
hide_iface_tag(0);
|
||||
call assertFalse("hide_iface_tag(SNEAK)", is_iface_tag_active(0));
|
||||
|
||||
// LEVEL
|
||||
show_iface_tag(3);
|
||||
call assertTrue("show_iface_tag(LEVEL)", is_iface_tag_active(3));
|
||||
hide_iface_tag(3);
|
||||
call assertFalse("hide_iface_tag(LEVEL)", is_iface_tag_active(3));
|
||||
|
||||
// ADDICTED
|
||||
show_iface_tag(4);
|
||||
call assertTrue("show_iface_tag(ADDICTED)", is_iface_tag_active(4));
|
||||
hide_iface_tag(4);
|
||||
call assertFalse("hide_iface_tag(ADDICTED)", is_iface_tag_active(4));
|
||||
|
||||
// POISONED
|
||||
call assertFalse("hide_iface_tag(POISONED)", is_iface_tag_active(1));
|
||||
|
||||
// RADIATED
|
||||
call assertFalse("hide_iface_tag(RADIATED)", is_iface_tag_active(2));
|
||||
|
||||
call report_test_results("iface_tag");
|
||||
end
|
||||
@@ -1,69 +0,0 @@
|
||||
#include "lib.arrays.h" // For arrays_equal, len_array, etc.
|
||||
#include "test_utils.h" // For assertEquals, VALTYPE_STR, report_test_results
|
||||
|
||||
// To test: copy test.ini into the game folder before running
|
||||
procedure ini_test_suite begin
|
||||
variable result_array, expected_array, key_type, value_type, count, key_val_pair;
|
||||
|
||||
display_msg("--- Testing ini functions");
|
||||
|
||||
// Test Case 1: Valid file, valid section
|
||||
result_array := get_ini_section("test.ini", "ValidSection");
|
||||
expected_array := {"Key1": "Value1", "Key2": "2"};
|
||||
call assertEquals("TC1 Size", len_array(result_array), 2);
|
||||
call assertEquals("TC1 Content", arrays_equal(result_array, expected_array), true);
|
||||
count := 0;
|
||||
foreach key_val_pair in result_array begin
|
||||
count += 1;
|
||||
call assertEquals("TC1 Key Type " + count, typeof(key_val_pair[0]), VALTYPE_STR);
|
||||
call assertEquals("TC1 Value Type " + count, typeof(key_val_pair[1]), VALTYPE_STR);
|
||||
end
|
||||
|
||||
// basic fetchers
|
||||
call assertEquals("TC2 Specific Key1 Value", result_array["Key1"], "Value1");
|
||||
call assertEquals("TC2 get_ini_setting string", get_ini_setting("test.ini|ValidSection|Key1"), 0);
|
||||
call assertEquals("TC2 get_ini_string string", get_ini_string("test.ini|ValidSection|Key1"), "Value1");
|
||||
call assertEquals("TC2 get_ini_setting int", get_ini_setting("test.ini|ValidSection|Key2"), 2);
|
||||
call assertEquals("TC2 get_ini_string int", get_ini_string("test.ini|ValidSection|Key2"), "2");
|
||||
|
||||
// INI file not found
|
||||
result_array := get_ini_section("nonexistent.ini", "AnySection");
|
||||
call assertEquals("TC3 Size", len_array(result_array), 0);
|
||||
call assertEquals("TC3 Is Map", array_key(result_array, -1), 1); // Should still be an associative array
|
||||
call assertEquals("TC3 get_ini_setting", get_ini_setting("notexist.ini|ValidSection|Key2"), 0);
|
||||
call assertEquals("TC3 get_ini_string", get_ini_string("notexist.ini|ValidSection|Key2"), "");
|
||||
|
||||
// Valid file, section not found
|
||||
result_array := get_ini_section("test.ini", "NonExistentSection");
|
||||
call assertEquals("TC4 Size", len_array(result_array), 0);
|
||||
call assertEquals("TC4 Is Map", array_key(result_array, -1), 1);
|
||||
call assertEquals("TC4 get_ini_setting", get_ini_setting("test.ini|NonExistentSection|Key2"), 0);
|
||||
call assertEquals("TC4 get_ini_string", get_ini_string("test.ini|NonExistentSection|Key2"), "");
|
||||
|
||||
|
||||
// Valid file, empty section
|
||||
result_array := get_ini_section("test.ini", "EmptySection");
|
||||
call assertEquals("TC5 Size", len_array(result_array), 0);
|
||||
call assertEquals("TC5 Is Map", array_key(result_array, -1), 1);
|
||||
call assertEquals("TC5 get_ini_setting", get_ini_setting("test.ini|EmptySection|Key2"), 0);
|
||||
call assertEquals("TC5 get_ini_string", get_ini_string("test.ini|EmptySection|Key2"), "");
|
||||
|
||||
// set ini setting
|
||||
set_ini_setting("test_set.ini|ValidSection|Key3", "OldValue");
|
||||
call assertEquals("TC6 set_ini_setting 1", get_ini_string("test_set.ini|ValidSection|Key3"), "OldValue");
|
||||
set_ini_setting("test_set.ini|ValidSection|Key3", "NewValue");
|
||||
call assertEquals("TC6 set_ini_setting 2", get_ini_string("test_set.ini|ValidSection|Key3"), "NewValue");
|
||||
set_ini_setting("test_set.ini|ValidSection|Key3", 2);
|
||||
call assertEquals("TC6 set_ini_setting int", get_ini_setting("test_set.ini|ValidSection|Key3"), 2);
|
||||
|
||||
// get_init_sections
|
||||
result_array := get_ini_sections("test.ini");
|
||||
call assertEquals("TC7 get_ini_sections size", len_array(result_array), 3);
|
||||
call assertTrue("TC7 get_ini_sections", scan_array(result_array, "TestMisc") >= 0);
|
||||
|
||||
call report_test_results("ini");
|
||||
end
|
||||
|
||||
procedure start begin
|
||||
call ini_test_suite();
|
||||
end
|
||||
@@ -1,71 +0,0 @@
|
||||
#include "test_utils.h"
|
||||
#include "sfall.h"
|
||||
|
||||
procedure start begin
|
||||
|
||||
display_msg("Testing math functions...");
|
||||
|
||||
call assertFloat("sin(0)", sin(0), 0.0);
|
||||
call assertFloat("sin(PI/2)", sin(1.5708), 1.0);
|
||||
call assertFloat("sin(PI)", sin(3.1416), 0.0);
|
||||
call assertFloat("sin(-PI/2)", sin(-1.5708), -1.0);
|
||||
|
||||
call assertFloat("cos(0)", cos(0), 1.0);
|
||||
call assertFloat("cos(PI/2)", cos(1.5708), 0.0);
|
||||
call assertFloat("cos(PI)", cos(3.1416), -1.0);
|
||||
call assertFloat("cos(-PI)", cos(-3.1416), -1.0);
|
||||
|
||||
call assertFloat("tan(0)", tan(0), 0.0);
|
||||
call assertFloat("tan(PI/4)", tan(0.7854), 1.0);
|
||||
call assertFloat("tan(-PI/4)", tan(-0.7854), -1.0);
|
||||
|
||||
call assertFloat("arctan(0, 1)", arctan(0, 1), 0.0);
|
||||
call assertFloat("arctan(1, 1)", arctan(1, 1), 0.7854);
|
||||
call assertFloat("arctan(-1, 1)", arctan(-1, 1), -0.7854);
|
||||
call assertFloat("arctan(1, 0)", arctan(1, 0), 1.5708);
|
||||
|
||||
call assertFloat("log(1)", log(1), 0.0);
|
||||
call assertFloat("log(e)", log(2.7183), 1.0);
|
||||
call assertFloat("log(10)", log(10), 2.3026);
|
||||
|
||||
call assertFloat("exponent(0)", exponent(0), 1.0);
|
||||
call assertFloat("exponent(1)", exponent(1), 2.7183);
|
||||
call assertFloat("exponent(2)", exponent(2), 7.3891);
|
||||
call assertFloat("exponent(-1)", exponent(-1), 0.3679);
|
||||
|
||||
call assertEquals("ceil(2.1)", ceil(2.1), 3);
|
||||
call assertEquals("ceil(2.0)", ceil(2.0), 2);
|
||||
call assertEquals("ceil(-2.1)", ceil(-2.1), -2);
|
||||
call assertEquals("ceil(-2.9)", ceil(-2.9), -2);
|
||||
|
||||
call assertEquals("floor2(2.1)", floor2(2.1), 2);
|
||||
call assertEquals("floor2(2.9)", floor2(2.9), 2);
|
||||
call assertEquals("floor2(-2.1)", floor2(-2.1), -3);
|
||||
call assertEquals("floor2(-2.9)", floor2(-2.9), -3);
|
||||
|
||||
call assertEquals("2^3", 2^3, 8);
|
||||
call assertEquals("4^2", 4^2, 16);
|
||||
call assertEquals("3^0", 3^0, 1);
|
||||
call assertFloat("2^-1", 2^-1, 0); // note: int truncation
|
||||
call assertFloat("2^-1", 2^-1.0, 0.5);
|
||||
call assertFloat("4^0.5", 4^0.5, 2.0);
|
||||
call assertFloat("8^(1/3)", 8^(1.0/3.0), 2.0);
|
||||
call assertFloat("2.5^2", 2.5^2, 6.25);
|
||||
|
||||
call assertEquals("round(2.3)", round(2.3), 2);
|
||||
call assertEquals("round(2.5)", round(2.5), 3);
|
||||
call assertEquals("round(2.7)", round(2.7), 3);
|
||||
call assertEquals("round(-2.3)", round(-2.3), -2);
|
||||
call assertEquals("round(-2.5)", round(-2.5), -3);
|
||||
call assertEquals("round(-2.7)", round(-2.7), -3);
|
||||
call assertEquals("round(0.0)", round(0.0), 0);
|
||||
call assertEquals("round(1.0)", round(1.0), 1);
|
||||
call assertEquals("round(<int>)", round(1), 1);
|
||||
|
||||
call assertFloat("sin(arctan(1, 1))", sin(arctan(1, 1)), 0.7071);
|
||||
call assertFloat("cos(arctan(1, 1))", cos(arctan(1, 1)), 0.7071);
|
||||
call assertFloat("log(ceil(2.7))", log(ceil(2.7)), 1.0986);
|
||||
call assertFloat("exponent(log(5))", exponent(log(5)), 5.0);
|
||||
|
||||
call report_test_results("math");
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
#include "sfall.h"
|
||||
|
||||
// this is the basic message_box function used by RPU and Et Tu
|
||||
#define message_box_warning(text) message_box4(text, 0x01, 134, 145)
|
||||
|
||||
procedure start begin
|
||||
// I don't see a practice way to auto test message_box, so this is just a way to do manual testing
|
||||
variable ret = message_box1("Basic Dialog\nwith multiple lines\nand such.");
|
||||
display_msg("chose: " + ret);
|
||||
message_box2("Basic Dialog\nwith default flags.", -1); // -1 means use default flags
|
||||
message_box2("Basic Dialog\nsmall.", 0x02);
|
||||
message_box_warning("Missing config values\n(just testing).");
|
||||
end
|
||||
@@ -1,30 +0,0 @@
|
||||
#include "test_utils.h"
|
||||
#include "sfall.h"
|
||||
|
||||
procedure start begin
|
||||
|
||||
display_msg("Testing metarule_exist functions...");
|
||||
|
||||
call assertEquals("string_format", metarule_exist("string_format"), 1);
|
||||
call assertEquals("metarule_exist", metarule_exist("metarule_exist"), 1);
|
||||
|
||||
// This will fail on sFall
|
||||
call assertEquals("opcode_exists", metarule_exist("opcode_exists"), 1);
|
||||
|
||||
if metarule_exist("opcode_exists") then begin // And example if how to use it
|
||||
#define opcode_exists(opcode) sfall_func1("opcode_exists", opcode)
|
||||
#define OP_GET_UPTIME 0x81B3
|
||||
#define OP_NOOP 0x8000
|
||||
#define OP_WRITE_INT 0x81D1
|
||||
|
||||
call assertEquals("opcode_exists OP_GET_UPTIME", opcode_exists(OP_GET_UPTIME), 1);
|
||||
call assertEquals("opcode_exists OP_NOOP", opcode_exists(OP_NOOP), 1);
|
||||
// Probably will never be implemented on fallout2-ce
|
||||
call assertEquals("opcode_exists OP_WRITE_INT", opcode_exists(OP_WRITE_INT), 0);
|
||||
call assertEquals("opcode_exists 0xFFFF", opcode_exists(0xFFFF), 0);
|
||||
end else begin
|
||||
display_msg("Opcode exists metarule is not available, skipping tests.");
|
||||
end
|
||||
|
||||
call report_test_results("metarule_exist");
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
#include "test_utils.h"
|
||||
#include "sfall.h"
|
||||
|
||||
procedure start begin
|
||||
// TODO: move this to a more suitable place, once we have more functions implemented
|
||||
// These are in the "Other" category in the sfall documentation
|
||||
display_msg("Testing misc functions...");
|
||||
variable hand := active_hand;
|
||||
toggle_active_hand;
|
||||
call assertEquals("active_hand toggled", active_hand, 1 - hand);
|
||||
toggle_active_hand;
|
||||
call assertEquals("active_hand toggled", active_hand, hand);
|
||||
|
||||
call report_test_results("misc");
|
||||
end
|
||||
@@ -154,7 +154,7 @@ procedure start begin
|
||||
call test_derived_base_stat_critter(dude_obj);
|
||||
call test_derived_base_stat_critter(closest_critter);
|
||||
|
||||
call report_test_results("stats");
|
||||
call report_test_results("Stats");
|
||||
|
||||
|
||||
// set_pc_base_stat(STAT_lu, 10);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "sfall.h"
|
||||
|
||||
procedure start begin
|
||||
// this isn't a unit test, just a way to easily test different values manually
|
||||
display_msg("Setting world map mult");
|
||||
set_map_time_multi(1.0);
|
||||
end
|
||||
@@ -1,87 +0,0 @@
|
||||
#include "../sfall/sfall.h"
|
||||
#include "../sfall/dik.h"
|
||||
#include "../sfall/define_lite.h"
|
||||
|
||||
procedure test_with_args(variable arg1) begin
|
||||
display_msg("test_w_arg" + arg1);
|
||||
end
|
||||
|
||||
procedure test_wo_args begin
|
||||
display_msg("test_wo_args");
|
||||
end
|
||||
|
||||
procedure tohit_handler begin
|
||||
variable
|
||||
attacker := get_sfall_arg_at(1),
|
||||
target := get_sfall_arg_at(2),
|
||||
chanceRaw := get_sfall_arg_at(7);
|
||||
|
||||
display_msg(string_format("tohit %s -> %s (%d)", obj_name(attacker), obj_name(target), chanceRaw));
|
||||
if (attacker == dude_obj) then
|
||||
set_sfall_return(100);
|
||||
else if (target == dude_obj) then
|
||||
set_sfall_return(0);
|
||||
|
||||
end
|
||||
|
||||
procedure useobj_handler begin
|
||||
variable
|
||||
user := get_sfall_arg,
|
||||
item := get_sfall_arg;
|
||||
|
||||
display_msg(string_format("useobj %s (%s)", obj_name(user), obj_name(item)));
|
||||
set_sfall_return(2);
|
||||
end
|
||||
|
||||
procedure useobjon_handler begin
|
||||
variable args := get_sfall_args,
|
||||
target := args[0],
|
||||
user := args[1],
|
||||
item := args[2];
|
||||
|
||||
display_msg(string_format("useobjon %s (%s) -> %s [len: %d]", obj_name(user), obj_name(item), obj_name(target), len_array(args)));
|
||||
set_sfall_return(0);
|
||||
end
|
||||
|
||||
procedure keypress_handler begin
|
||||
variable
|
||||
pressed := get_sfall_arg_at(0),
|
||||
key := get_sfall_arg_at(1);
|
||||
|
||||
display_msg(string_format("keypress %d dx: %d", pressed, key));
|
||||
|
||||
if (not pressed) then return;
|
||||
|
||||
if (key == DIK_F2) then begin
|
||||
display_msg(string_format("tile %d, elev %d, map %d", tile_under_cursor, elevation(dude_obj), cur_map_index));
|
||||
end if (key == DIK_F3) then begin
|
||||
if (key_pressed(DIK_LCONTROL)) then begin
|
||||
variable cr := obj_under_cursor(true, false);
|
||||
if (cr) then
|
||||
critter_dmg(cr, 1000, DMG_BYPASS_ARMOR);
|
||||
end else
|
||||
move_to(dude_obj, tile_under_cursor, elevation(dude_obj));
|
||||
end
|
||||
end
|
||||
|
||||
procedure start begin
|
||||
//call test_with_args(777);
|
||||
display_msg("start hook test");
|
||||
|
||||
if (not game_loaded) then return;
|
||||
|
||||
add_obj_to_inven(dude_obj, create_object_sid(40, 0, 0, -1));
|
||||
add_obj_to_inven(dude_obj, create_object_sid(76, 0, 0, -1));
|
||||
add_obj_to_inven(dude_obj, create_object_sid(85, 0, 0, -1));
|
||||
|
||||
register_hook_proc(HOOK_KEYPRESS, keypress_handler);
|
||||
register_hook_proc(HOOK_TOHIT, tohit_handler);
|
||||
register_hook_proc(HOOK_USEOBJ, useobj_handler);
|
||||
register_hook_proc(HOOK_USEOBJON, useobjon_handler);
|
||||
end
|
||||
|
||||
|
||||
procedure map_enter_p_proc begin
|
||||
display_msg("Map Enter hook test");
|
||||
end
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
[ValidSection]
|
||||
Key1=Value1
|
||||
Key2=2
|
||||
|
||||
[SectionWithSpaces]
|
||||
LeadingSpaceKey = LeadingSpaceValue
|
||||
TrailingSpaceKey = TrailingSpaceValue
|
||||
Both Sides Space Key = Both Sides Space Value
|
||||
SimpleKey=SimpleValue
|
||||
|
||||
[EmptySection]
|
||||
|
||||
; This is TestMisc, it's not empty but won't be directly tested for content here.
|
||||
[TestMisc]
|
||||
Alpha=Beta
|
||||
Gamma=Delta
|
||||
@@ -7,36 +7,14 @@ variable test_suite_errors := 0;
|
||||
variable test_suite_verbose := false;
|
||||
variable test_suite_assertions := 0;
|
||||
|
||||
procedure assertTrue(variable desc, variable a) begin
|
||||
test_suite_assertions++;
|
||||
|
||||
if (not a) then begin
|
||||
display_msg("Assertion failed \""+desc+"\": is not true");
|
||||
test_suite_errors ++;
|
||||
end else if (test_suite_verbose) then begin
|
||||
display_msg("Assert \""+desc+"\" ok");
|
||||
end
|
||||
end
|
||||
|
||||
procedure assertFalse(variable desc, variable a) begin
|
||||
test_suite_assertions++;
|
||||
|
||||
if (a) then begin
|
||||
display_msg("Assertion failed \""+desc+"\": is not false");
|
||||
test_suite_errors ++;
|
||||
end else if (test_suite_verbose) then begin
|
||||
display_msg("Assert \""+desc+"\" ok");
|
||||
end
|
||||
end
|
||||
|
||||
procedure assertEquals(variable desc, variable a, variable b) begin
|
||||
test_suite_assertions++;
|
||||
|
||||
if (a != b or typeof(a) != typeof(b)) then begin
|
||||
display_msg("FAIL \""+desc+"\": "+a+" != "+b);
|
||||
display_msg("Assertion failed \""+desc+"\": "+a+" != "+b);
|
||||
test_suite_errors ++;
|
||||
end else if (test_suite_verbose) then begin
|
||||
display_msg("ok \""+desc+"\"");
|
||||
display_msg("Assert \""+desc+"\" ok");
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,23 +22,10 @@ procedure assertNotEquals(variable desc, variable a, variable b) begin
|
||||
test_suite_assertions++;
|
||||
|
||||
if (a == b) then begin
|
||||
display_msg("FAIL \""+desc+"\": "+a+" == "+b);
|
||||
display_msg("Assertion failed \""+desc+"\": "+a+" == "+b);
|
||||
test_suite_errors ++;
|
||||
end else if (test_suite_verbose) then begin
|
||||
display_msg("ok \""+desc+"\"");
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
procedure assertFloat(variable desc, variable a, variable b, variable tolerance = 0.001) begin
|
||||
test_suite_assertions++;
|
||||
|
||||
variable diff := abs(a - b);
|
||||
if (diff > tolerance) then begin
|
||||
display_msg("FAIL \""+desc+"\": "+a+" != "+b+" (diff: "+diff+")");
|
||||
test_suite_errors ++;
|
||||
end else if (test_suite_verbose) then begin
|
||||
display_msg("ok \""+desc+"\"");
|
||||
display_msg("Assert \""+desc+"\" ok");
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,64 +35,12 @@ procedure report_test_results(variable desc) begin
|
||||
(test_suite_assertions-test_suite_errors) + "/" + test_suite_assertions + "");
|
||||
display_msg("================");
|
||||
|
||||
|
||||
#define GL_VAR_TESTING_INFO_ARRAY_ID "TestArra"
|
||||
#define TEST_ARR_IDENTIFIER_KEY "__testing_info_array__"
|
||||
variable arr_id = get_sfall_global_int(GL_VAR_TESTING_INFO_ARRAY_ID);
|
||||
if arr_id != 0 then begin
|
||||
// Let's check that it is actually our testing array
|
||||
if array_key(arr_id, -1) == 0 then begin
|
||||
// It is not even associative array, so it is not our testing array
|
||||
arr_id = 0;
|
||||
end else begin
|
||||
if arr_id[TEST_ARR_IDENTIFIER_KEY] != 1 then begin
|
||||
// It is associative array, but it is not our testing array
|
||||
arr_id = 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
if arr_id == 0 then begin
|
||||
arr_id = create_array(-1, 0);
|
||||
arr_id[TEST_ARR_IDENTIFIER_KEY] = 1;
|
||||
set_sfall_global(GL_VAR_TESTING_INFO_ARRAY_ID, arr_id);
|
||||
end
|
||||
|
||||
|
||||
#define TEST_SUITES "Test suites"
|
||||
#define TEST_ASSERTIONS_TOTAL "Tests assertings total"
|
||||
#define TEST_ASSERTIONS_FAILED "Tests assertings failed"
|
||||
|
||||
if arr_id[TEST_SUITES] == 0 then begin
|
||||
arr_id[TEST_SUITES] = create_array(-1, 0);
|
||||
end
|
||||
|
||||
//set_sfall_global("test_suite_errors", test_suite_errors);
|
||||
|
||||
arr_id[TEST_ASSERTIONS_TOTAL] += test_suite_assertions;
|
||||
arr_id[TEST_ASSERTIONS_FAILED] += test_suite_errors;
|
||||
arr_id[TEST_SUITES][desc] += 1;
|
||||
|
||||
variable total_suites_names = "";
|
||||
variable total_suites_count = 0;
|
||||
|
||||
variable key, item;
|
||||
foreach (key: item in arr_id[TEST_SUITES]) begin
|
||||
total_suites_count += item;
|
||||
if (total_suites_names != "") then begin
|
||||
total_suites_names += ", ";
|
||||
end
|
||||
total_suites_names += key;
|
||||
end
|
||||
|
||||
|
||||
variable assertions_stats_str = (arr_id[TEST_ASSERTIONS_TOTAL]-arr_id[TEST_ASSERTIONS_FAILED]) +
|
||||
"/" + arr_id[TEST_ASSERTIONS_TOTAL];
|
||||
if (arr_id[TEST_ASSERTIONS_FAILED] == 0) then begin
|
||||
float_msg(dude_obj, "Tested " + total_suites_count + " cases: " + total_suites_names + ". " +
|
||||
assertions_stats_str + " assertions passed!", FLOAT_MSG_GREEN);
|
||||
if (test_suite_errors == 0) then begin
|
||||
float_msg(dude_obj, desc + " tests passed " +
|
||||
(test_suite_assertions-test_suite_errors) + "/" +test_suite_assertions + "!", FLOAT_MSG_GREEN);
|
||||
end else begin
|
||||
float_msg(dude_obj, "Tested " + total_suites_count + " cases: " + total_suites_names + ". " +
|
||||
assertions_stats_str + " assertions passed", FLOAT_MSG_RED);
|
||||
float_msg(dude_obj, desc + " failed " + test_suite_errors + " tests from " +
|
||||
test_suite_assertions + "!", FLOAT_MSG_RED);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user