Compare commits

..
19 changed files with 145 additions and 681 deletions
+1 -1
View File
@@ -337,7 +337,7 @@ jobs:
uses: actions/cache@v4
with:
path: out
key: windows-${{ matrix.arch }}-cmake-v3
key: windows-${{ matrix.arch }}-cmake-v4
- name: Configure
shell: cmd
+8 -2
View File
@@ -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
@@ -312,7 +314,7 @@ endif()
if(WIN32)
target_link_libraries(${EXECUTABLE_NAME}
winmm
libcpmt
# libcpmt # Disabled, was causing issues on VS2019 builing from UI
)
endif()
@@ -323,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
+3 -2
View File
@@ -30,8 +30,8 @@
],
"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>"
@@ -61,7 +61,8 @@
},
"cacheVariables": {
"FALLOUT_VENDORED": "OFF"
}
},
"generator": "Unix Makefiles"
},
{
"name": "linux-x86-base",
+1 -1
View File
@@ -125,7 +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
IFACE_BAR_WIDTH=640
```
Recommendations:
+1 -2
View File
@@ -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 -1
View File
@@ -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
-71
View File
@@ -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
-15
View File
@@ -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
+1 -1
View File
@@ -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);
+9 -74
View File
@@ -11,10 +11,10 @@ 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
@@ -22,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
@@ -48,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
+1 -1
View File
@@ -291,7 +291,7 @@ static FrmImage _yellowLightFrmImage;
static FrmImage _redLightFrmImage;
int gInterfaceBarContentOffset = 0;
int gInterfaceBarWidth = 800; // will fall back to 640 if screen width is too narrow or asset is absent
int gInterfaceBarWidth = -1;
bool gInterfaceBarIsCustom = false;
static Art* gCustomInterfaceBarBackground = nullptr;
+9
View File
@@ -3183,6 +3183,15 @@ int programStackPopInteger(Program* program)
return programValue.integerValue;
}
float programStackPopFloat(Program* program)
{
ProgramValue programValue = programStackPopValue(program);
if (programValue.opcode != VALUE_TYPE_INT) {
programFatalError("float expected, got %x", programValue.opcode);
}
return programValue.floatValue;
}
char* programStackPopString(Program* program)
{
ProgramValue programValue = programStackPopValue(program);
+1
View File
@@ -230,6 +230,7 @@ void programStackPushPointer(Program* program, void* value);
ProgramValue programStackPopValue(Program* program);
int programStackPopInteger(Program* program);
float programStackPopFloat(Program* program);
char* programStackPopString(Program* program);
void* programStackPopPointer(Program* program);
-2
View File
@@ -70,8 +70,6 @@ bool sfallConfigInit(int argc, char** argv)
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_AUTO_OPEN_DOORS, 0);
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_GAPLESS_MUSIC, 0);
configSetBool(&gSfallConfig, SFALL_CONFIG_MAIN_KEY, SFALL_CONFIG_ENABLE_HIRES_STENCIL, true);
char path[COMPAT_MAX_PATH];
char* executable = argv[0];
char* ch = strrchr(executable, '\\');
-1
View File
@@ -77,7 +77,6 @@ namespace fallout {
#define SFALL_CONFIG_CONFIG_FILE "ConfigFile"
#define SFALL_CONFIG_PATCH_FILE "PatchFile"
#define SFALL_CONFIG_HIRES_MODE "HiResMode"
#define SFALL_CONFIG_ENABLE_HIRES_STENCIL "EnableHighResolutionStencil"
#define SFALL_CONFIG_PIPBOY_AVAILABLE_AT_GAMESTART "PipBoyAvailableAtGameStart"
#define SFALL_CONFIG_USE_WALK_DISTANCE "UseWalkDistance"
#define SFALL_CONFIG_AUTO_OPEN_DOORS "AutoOpenDoors"
+1 -9
View File
@@ -1,7 +1,6 @@
#include "sfall_metarules.h"
#include <algorithm>
#include <math.h>
#include <memory>
#include <string.h>
#include <string>
@@ -55,7 +54,6 @@ static void mf_string_compare(Program* program, int args);
static void mf_string_find(Program* program, int args);
static void mf_string_to_case(Program* program, int args);
static void mf_string_format(Program* program, int args);
static void mf_floor2(Program* program, int args);
// ref. https://github.com/sfall-team/sfall/blob/42556141127895c27476cd5242a73739cbb0fade/sfall/Modules/Scripting/Handlers/Metarule.cpp#L72
constexpr MetaruleInfo kMetarules[] = {
@@ -76,7 +74,7 @@ constexpr MetaruleInfo kMetarules[] = {
// {"draw_image", mf_draw_image, 1, 5, -1, {ARG_INTSTR, ARG_INT, ARG_INT, ARG_INT, ARG_INT}},
// {"draw_image_scaled", mf_draw_image_scaled, 1, 6, -1, {ARG_INTSTR, ARG_INT, ARG_INT, ARG_INT, ARG_INT, ARG_INT}},
// {"exec_map_update_scripts", mf_exec_map_update_scripts, 0, 0},
{ "floor2", mf_floor2, 1, 1 },
// {"floor2", mf_floor2, 1, 1, 0, {ARG_NUMBER}},
// {"get_can_rest_on_map", mf_get_rest_on_map, 2, 2, -1, {ARG_INT, ARG_INT}},
// {"get_combat_free_move", mf_get_combat_free_move, 0, 0},
// {"get_current_inven_size", mf_get_current_inven_size, 1, 1, 0, {ARG_OBJECT}},
@@ -486,12 +484,6 @@ void mf_string_format(Program* program, int args)
sprintf_lite(program, args, "string_format");
}
void mf_floor2(Program* program, int args)
{
ProgramValue programValue = programStackPopValue(program);
programStackPushInteger(program, static_cast<int>(floor(programValue.asFloat())));
}
void sprintf_lite(Program* program, int args, const char* infoOpcodeName)
{
auto format = programStackPopString(program); // Pop the format string
+94 -497
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -405,7 +405,7 @@ void tile_hires_stencil_draw(Rect* rect, unsigned char* buffer, int windowWidth,
void tile_hires_stencil_init()
{
configGetBool(&gSfallConfig, SFALL_CONFIG_MAIN_KEY, SFALL_CONFIG_ENABLE_HIRES_STENCIL, &gIsTileHiresStencilEnabled);
configGetBool(&gSfallConfig, SFALL_CONFIG_MAIN_KEY, SFALL_CONFIG_HIRES_MODE, &gIsTileHiresStencilEnabled);
if (!gIsTileHiresStencilEnabled) {
return;
}
+13
View File
@@ -16,6 +16,19 @@
#include "platform/ios/paths.h"
#endif
#if defined(_WIN32) && !defined(_WIN64)
#ifndef _WIN32_WINNT
#error "_WIN32_WINNT is not defined. It must be set to 0x0501 for Windows XP compatibility."
#elif _WIN32_WINNT != 0x0501
#error "_WIN32_WINNT must be exactly 0x0501 for Windows XP compatibility in 32-bit builds."
#endif
#ifndef TOOLSET_V141_XP
#error "TOOLSET_V141_XP is not used."
#endif
#endif
namespace fallout {
// 0x51E444