Skip to content

Commit

Permalink
Merge branch 'main' into use_delay_ms
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbatalov committed Jan 16, 2024
2 parents e29ffc4 + 601f0c7 commit e8741e0
Show file tree
Hide file tree
Showing 101 changed files with 8,349 additions and 1,060 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
BasedOnStyle: WebKit
AllowShortIfStatementsOnASingleLine: WithoutElse
FixNamespaceComments: true
24 changes: 17 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

set(EXECUTABLE_NAME fallout2-ce)

if (APPLE)
if(APPLE)
if(IOS)
set(CMAKE_OSX_DEPLOYMENT_TARGET "11" CACHE STRING "")
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "")
Expand All @@ -20,7 +20,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)

if (ANDROID)
if(ANDROID)
add_library(${EXECUTABLE_NAME} SHARED)
else()
add_executable(${EXECUTABLE_NAME} WIN32 MACOSX_BUNDLE)
Expand Down Expand Up @@ -253,6 +253,8 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
target_sources(${EXECUTABLE_NAME} PUBLIC
"src/audio_engine.cc"
"src/audio_engine.h"
"src/delay.cc"
"src/delay.h"
"src/fps_limiter.cc"
"src/fps_limiter.h"
"src/platform_compat.cc"
Expand All @@ -267,12 +269,20 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/sfall_config.h"
"src/sfall_global_vars.cc"
"src/sfall_global_vars.h"
"src/sfall_global_scripts.cc"
"src/sfall_global_scripts.h"
"src/sfall_ini.cc"
"src/sfall_ini.h"
"src/sfall_kb_helpers.cc"
"src/sfall_kb_helpers.h"
"src/sfall_lists.cc"
"src/sfall_lists.h"
"src/sfall_metarules.cc"
"src/sfall_metarules.h"
"src/sfall_opcodes.cc"
"src/sfall_opcodes.h"
"src/delay.cc"
"src/delay.h"
"src/sfall_arrays.cc"
"src/sfall_arrays.h"
"src/touch.cc"
"src/touch.h"
)
Expand All @@ -299,7 +309,7 @@ if(WIN32)
)
endif()

if (WIN32)
if(WIN32)
target_sources(${EXECUTABLE_NAME} PUBLIC
"os/windows/fallout2-ce.ico"
"os/windows/fallout2-ce.rc"
Expand Down Expand Up @@ -354,7 +364,7 @@ add_subdirectory("third_party/fpattern")
target_link_libraries(${EXECUTABLE_NAME} ${FPATTERN_LIBRARY})
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${FPATTERN_INCLUDE_DIR})

if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
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()
Expand All @@ -379,7 +389,7 @@ if(APPLE)
else()
install(TARGETS ${EXECUTABLE_NAME} DESTINATION .)

if (CPACK_BUNDLE_APPLE_CERT_APP)
if(CPACK_BUNDLE_APPLE_CERT_APP)
install(CODE "
execute_process(COMMAND codesign --deep --force --options runtime --sign \"${CPACK_BUNDLE_APPLE_CERT_APP}\" ${CMAKE_BINARY_DIR}/Fallout II Community Edition.app)
"
Expand Down
3 changes: 3 additions & 0 deletions src/actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ typedef enum ScienceRepairTargetType {
// 0x5106D0
static bool _action_in_explode = false;

// 0x5106D4
int rotation;

// 0x5106E0
static const int gNormalDeathAnimations[DAMAGE_TYPE_COUNT] = {
ANIM_DANCING_AUTOFIRE,
Expand Down
2 changes: 2 additions & 0 deletions src/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace fallout {

extern int rotation;

int _action_attack(Attack* attack);
int _action_use_an_item_on_object(Object* a1, Object* a2, Object* a3);
int _action_use_an_object(Object* a1, Object* a2);
Expand Down
47 changes: 24 additions & 23 deletions src/animation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,7 @@ int _make_path(Object* object, int from, int to, unsigned char* rotations, int a
return pathfinderFindPath(object, from, to, rotations, a5, _obj_blocking_at);
}

// TODO: move pathfinding into another unit
// 0x415EFC
int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotations, int a5, PathBuilderCallback* callback)
{
Expand Down Expand Up @@ -1939,18 +1940,18 @@ static int _tile_idistance(int tile1, int tile2)
}

// 0x4163AC
int _make_straight_path(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6)
int _make_straight_path(Object* obj, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6)
{
return _make_straight_path_func(a1, from, to, straightPathNodeList, obstaclePtr, a6, _obj_blocking_at);
return _make_straight_path_func(obj, from, to, straightPathNodeList, obstaclePtr, a6, _obj_blocking_at);
}

// TODO: Rather complex, but understandable, needs testing.
//
// 0x4163C8
int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback)
int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback)
{
if (obstaclePtr != NULL) {
Object* obstacle = callback(a1, from, a1->elevation);
Object* obstacle = callback(obj, from, obj->elevation);
if (obstacle != NULL) {
if (obstacle != *obstaclePtr && (a6 != 32 || (obstacle->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obstacle;
Expand All @@ -1961,13 +1962,13 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str

int fromX;
int fromY;
tileToScreenXY(from, &fromX, &fromY, a1->elevation);
tileToScreenXY(from, &fromX, &fromY, obj->elevation);
fromX += 16;
fromY += 8;

int toX;
int toY;
tileToScreenXY(to, &toX, &toY, a1->elevation);
tileToScreenXY(to, &toX, &toY, obj->elevation);
toX += 16;
toY += 8;

Expand Down Expand Up @@ -2005,7 +2006,7 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
if (ddx <= ddy) {
int middle = ddx - ddy / 2;
while (true) {
tile = tileFromScreenXY(tileX, tileY, a1->elevation);
tile = tileFromScreenXY(tileX, tileY, obj->elevation);

v22 += 1;
if (v22 == a6) {
Expand All @@ -2016,9 +2017,9 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
if (straightPathNodeList != NULL) {
StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]);
pathNode->tile = tile;
pathNode->elevation = a1->elevation;
pathNode->elevation = obj->elevation;

tileToScreenXY(tile, &fromX, &fromY, a1->elevation);
tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
Expand All @@ -2044,10 +2045,10 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str

if (tile != prevTile) {
if (obstaclePtr != NULL) {
Object* obj = callback(a1, tile, a1->elevation);
if (obj != NULL) {
if (obj != *obstaclePtr && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obj;
Object* obstacle = callback(obj, tile, obj->elevation);
if (obstacle != NULL) {
if (obstacle != *obstaclePtr && (a6 != 32 || (obstacle->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obstacle;
break;
}
}
Expand All @@ -2058,7 +2059,7 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
} else {
int middle = ddy - ddx / 2;
while (true) {
tile = tileFromScreenXY(tileX, tileY, a1->elevation);
tile = tileFromScreenXY(tileX, tileY, obj->elevation);

v22 += 1;
if (v22 == a6) {
Expand All @@ -2069,9 +2070,9 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
if (straightPathNodeList != NULL) {
StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]);
pathNode->tile = tile;
pathNode->elevation = a1->elevation;
pathNode->elevation = obj->elevation;

tileToScreenXY(tile, &fromX, &fromY, a1->elevation);
tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
Expand All @@ -2097,10 +2098,10 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str

if (tile != prevTile) {
if (obstaclePtr != NULL) {
Object* obj = callback(a1, tile, a1->elevation);
if (obj != NULL) {
if (obj != *obstaclePtr && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obj;
Object* obstacle = callback(obj, tile, obj->elevation);
if (obstacle != NULL) {
if (obstacle != *obstaclePtr && (a6 != 32 || (obstacle->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obstacle;
break;
}
}
Expand All @@ -2118,17 +2119,17 @@ int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* str
if (straightPathNodeList != NULL) {
StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]);
pathNode->tile = tile;
pathNode->elevation = a1->elevation;
pathNode->elevation = obj->elevation;

tileToScreenXY(tile, &fromX, &fromY, a1->elevation);
tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}

pathNodeIndex += 1;
} else {
if (pathNodeIndex > 0 && straightPathNodeList != NULL) {
straightPathNodeList[pathNodeIndex - 1].elevation = a1->elevation;
straightPathNodeList[pathNodeIndex - 1].elevation = obj->elevation;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ int animationRegisterAnimateForever(Object* owner, int anim, int delay);
int animationRegisterPing(int flags, int delay);
int _make_path(Object* object, int from, int to, unsigned char* a4, int a5);
int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotations, int a5, PathBuilderCallback* callback);
int _make_straight_path(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6);
int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback);
int _make_straight_path(Object* object, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6);
int _make_straight_path_func(Object* object, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback);
void _object_animate();
int _check_move(int* actionPointsPtr);
int _dude_move(int actionPoints);
Expand Down
8 changes: 8 additions & 0 deletions src/art.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ void artRender(int fid, unsigned char* dest, int width, int height, int pitch)
artUnlock(handle);
}

// mapper2.exe: 0x40A03C
int art_list_str(int fid, char* name)
{
// TODO: Incomplete.

return -1;
}

// 0x419160
Art* artLock(int fid, CacheEntry** handlePtr)
{
Expand Down
1 change: 1 addition & 0 deletions src/art.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ char* artGetObjectTypeName(int objectType);
int artIsObjectTypeHidden(int objectType);
int artGetFidgetCount(int headFid);
void artRender(int fid, unsigned char* dest, int width, int height, int pitch);
int art_list_str(int fid, char* name);
Art* artLock(int fid, CacheEntry** cache_entry);
unsigned char* artLockFrameData(int fid, int frame, int direction, CacheEntry** out_cache_entry);
unsigned char* artLockFrameDataReturningSize(int fid, CacheEntry** out_cache_entry, int* widthPtr, int* heightPtr);
Expand Down
Loading

0 comments on commit e8741e0

Please sign in to comment.