Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SFall arrays and patry_member_list opcodes #269

Merged
merged 89 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
c6612d2
Add stubs for new sFall functions
roginvs Apr 15, 2023
7e3d188
Add stub for array funcs
roginvs Apr 15, 2023
a8058ac
Rename STRUCT_519DA8 -> PartyMemberListItem
roginvs Apr 15, 2023
0b533ce
Some steps with arrays
roginvs Apr 19, 2023
9e579c3
Adding arrays
roginvs Apr 19, 2023
6ba7961
Remove warning
roginvs Apr 19, 2023
53096b5
Add create_temp_array
roginvs Apr 19, 2023
55774c2
Add get_array_key
roginvs Apr 19, 2023
e934cf1
Add get_array_key
roginvs Apr 19, 2023
3e1f04c
Add get_array
roginvs Apr 19, 2023
a764634
Add function to get all party members for sFall
roginvs Apr 19, 2023
f01a3e3
Add op_party_member_list
roginvs Apr 19, 2023
da814a6
Reorganize files
roginvs Apr 19, 2023
a93c7fb
Small updates
roginvs Apr 19, 2023
4662314
Add FreeArray
roginvs Apr 19, 2023
9549bab
Add setArray
roginvs Apr 19, 2023
a51ece6
Add TODO
roginvs Apr 19, 2023
1d3e61f
Add opFixArray
roginvs Apr 19, 2023
09da584
Remove temp arrays in scripts.cc
roginvs Apr 20, 2023
0c083a8
Add sfallArraysReset
roginvs Apr 20, 2023
c30474d
Merge remote-tracking branch 'alex/main' into add_party_member_list
roginvs Apr 20, 2023
7ff024b
Revert newline
roginvs Apr 20, 2023
601f9ba
SFallScriptValue updates
roginvs Apr 20, 2023
2841130
Remove move constructor
roginvs Apr 20, 2023
4a84e0c
Remove destructor
roginvs Apr 20, 2023
8385c67
Add TODO
roginvs Apr 20, 2023
43c847a
Rename data -> values
roginvs Apr 20, 2023
5b50673
Merge remote-tracking branch 'alex/main' into add_party_member_list
roginvs Apr 23, 2023
4ed00c7
Use unique_ptr for arrays
roginvs Apr 23, 2023
a06a2c9
Use abstract class
roginvs Apr 23, 2023
a7800a6
Adding assoc arrays
roginvs Apr 23, 2023
d092ed3
Adding assoc arrays
roginvs Apr 23, 2023
517deb5
Add assoc set array
roginvs Apr 23, 2023
bb37025
Add resizearray for assoc arrays
roginvs Apr 23, 2023
71f37d0
Add MapSort
roginvs Apr 23, 2023
8932468
Remove TODO
roginvs Apr 23, 2023
75cc266
Remove TODO
roginvs Apr 23, 2023
89ba7fd
Adding GetArray for strings
roginvs Apr 24, 2023
b3e838e
Move SFallScriptValue into ProgramValue
roginvs Apr 24, 2023
c25a553
Remove SFallScriptValue
roginvs Apr 24, 2023
f03f7bd
Fix ProgramValue for strings
roginvs Apr 24, 2023
75eecf7
Add todo for GetArray subscript operator
roginvs Apr 24, 2023
0570004
Small refactor
roginvs Apr 24, 2023
3d86c2d
Remove wild "kek"
roginvs Apr 24, 2023
882e905
Remove unnessesary type alias
roginvs Apr 24, 2023
2810f2d
Remove random_shuffle because it is deprecated
roginvs Apr 24, 2023
d4f3ddd
Merge remote-tracking branch 'alex/main' into add_party_member_list
roginvs Apr 27, 2023
2320855
Do not spoil arrays map if array is not found
roginvs Apr 27, 2023
2c0254a
Return plain poiner in get_array_by_id
roginvs Apr 27, 2023
d437713
Add virtual destructor (https://github.com/isocpp/CppCoreGuidelines/b…
roginvs Apr 29, 2023
7b45097
Merge remote-tracking branch 'alex/main' into add_party_member_list
roginvs May 11, 2023
d1705df
Add type_of opcode
roginvs May 11, 2023
2f732ef
Add op_arrayexpr
roginvs May 11, 2023
2dcae64
Add scan_array opcode
roginvs May 11, 2023
7faccc9
Add string subscript
roginvs May 14, 2023
b3fb03d
Use ArrayElement for sfall array
roginvs May 14, 2023
3d36f41
Add comment
roginvs May 14, 2023
e770295
Moving into ArrayElement
roginvs May 14, 2023
9441d5f
Moving into ArrayElement
roginvs May 14, 2023
c463583
Moving into ArrayElement
roginvs May 14, 2023
81a8b75
Removing TODOs
roginvs May 14, 2023
cfc1747
Removing TODOs
roginvs May 14, 2023
9bb3f73
Add destructor
roginvs May 14, 2023
216bba5
Remove comment
roginvs May 14, 2023
7a0e537
Fix typo
roginvs May 14, 2023
4321e55
Fix typo
roginvs May 14, 2023
f97fc32
Add substr
roginvs May 14, 2023
f206a62
Fix typo for wrong opcode
roginvs May 14, 2023
9373719
Fixes
roginvs May 14, 2023
f90542f
Register opcode for string split
roginvs May 14, 2023
b24f607
Add StringSplit opcode
roginvs May 15, 2023
22aeafd
Fix max string size for arrays
roginvs May 15, 2023
fdbf69d
Fix map override
roginvs May 15, 2023
cf01118
Add comment
roginvs May 15, 2023
141d011
Small update
roginvs May 15, 2023
5a05df6
Add a comment why method is not implemented
roginvs May 15, 2023
d01f04e
Dummy
roginvs May 15, 2023
d084b72
Fix move assignment operator
roginvs May 15, 2023
b21b141
Improve move constructor
roginvs May 15, 2023
d18fc56
Improve lambda call
roginvs May 15, 2023
c3426d1
This should fix Windows build
roginvs May 15, 2023
6f68a05
Slightly better initialization
roginvs May 15, 2023
79d40f5
Maybe this will fix Windows build
roginvs May 15, 2023
ecef591
Merge remote-tracking branch 'alex/main' into add_party_member_list
roginvs May 25, 2023
7ef17bf
Fix issue with keys order
roginvs May 25, 2023
287ed6d
Use build-in method erase
roginvs May 25, 2023
cae990b
Refactor
alexbatalov May 27, 2023
30090c9
Fix swap
alexbatalov May 27, 2023
17e5676
Add namespace comments
alexbatalov May 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 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 @@ -271,6 +271,8 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/sfall_lists.h"
"src/sfall_opcodes.cc"
"src/sfall_opcodes.h"
"src/sfall_arrays.cc"
"src/sfall_arrays.h"
"src/touch.cc"
"src/touch.h"
)
Expand All @@ -297,7 +299,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 @@ -377,7 +379,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
8 changes: 8 additions & 0 deletions src/game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "random.h"
#include "scripts.h"
#include "settings.h"
#include "sfall_arrays.h"
#include "sfall_config.h"
#include "sfall_global_vars.h"
#include "sfall_lists.h"
Expand Down Expand Up @@ -348,6 +349,11 @@ int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int a4
return -1;
}

if (!sfallArraysInit()) {
debugPrint("Failed on sfallArraysInit");
return -1;
}

messageListRepositorySetStandardMessageList(STANDARD_MESSAGE_LIST_MISC, &gMiscMessageList);

return 0;
Expand Down Expand Up @@ -395,6 +401,7 @@ void gameReset()
sfallGlobalVarsReset();
sfallListsReset();
messageListRepositoryReset();
sfallArraysReset();
}

// 0x442C34
Expand All @@ -403,6 +410,7 @@ void gameExit()
debugPrint("\nGame Exit\n");

// SFALL
sfallArraysExit();
sfallListsExit();
sfallGlobalVarsExit();
premadeCharactersExit();
Expand Down
46 changes: 42 additions & 4 deletions src/interpreter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3252,7 +3252,7 @@ void* programReturnStackPopPointer(Program* program)
return programValue.pointerValue;
}

bool ProgramValue::isEmpty()
bool ProgramValue::isEmpty() const
{
switch (opcode) {
case VALUE_TYPE_INT:
Expand All @@ -3269,19 +3269,19 @@ bool ProgramValue::isEmpty()
}

// Matches Sfall implementation.
bool ProgramValue::isInt()
bool ProgramValue::isInt() const
{
return opcode == VALUE_TYPE_INT;
}

// Matches Sfall implementation.
bool ProgramValue::isFloat()
bool ProgramValue::isFloat() const
{
return opcode == VALUE_TYPE_FLOAT;
}

// Matches Sfall implementation.
float ProgramValue::asFloat()
float ProgramValue::asFloat() const
{
switch (opcode) {
case VALUE_TYPE_INT:
Expand All @@ -3293,4 +3293,42 @@ float ProgramValue::asFloat()
}
}

bool ProgramValue::isString() const
{
return opcode == VALUE_TYPE_STRING || opcode == VALUE_TYPE_DYNAMIC_STRING;
}

ProgramValue::ProgramValue()
{
opcode = VALUE_TYPE_INT;
integerValue = 0;
}
ProgramValue::ProgramValue(int value)
{
opcode = VALUE_TYPE_INT;
integerValue = value;
};
ProgramValue::ProgramValue(Object* value)
{
opcode = VALUE_TYPE_PTR;
pointerValue = value;
};

bool ProgramValue::isPointer() const
{
return opcode == VALUE_TYPE_PTR;
}

int ProgramValue::asInt() const
{
switch (opcode) {
case VALUE_TYPE_INT:
return integerValue;
case VALUE_TYPE_FLOAT:
return static_cast<int>(floatValue);
default:
return 0;
}
}

} // namespace fallout
21 changes: 15 additions & 6 deletions src/interpreter.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef INTERPRETER_H
#define INTERPRETER_H

#include "object.h"
#include <setjmp.h>

#include <vector>
Expand Down Expand Up @@ -140,19 +141,27 @@ typedef struct Procedure {
int field_14;
} Procedure;

typedef struct ProgramValue {
class ProgramValue {
public:
ProgramValue();
ProgramValue(int value);
ProgramValue(Object* value);

opcode_t opcode;
union {
int integerValue;
float floatValue;
void* pointerValue;
};

bool isEmpty();
bool isInt();
bool isFloat();
float asFloat();
} ProgramValue;
bool isEmpty() const;
bool isInt() const;
bool isFloat() const;
bool isString() const;
float asFloat() const;
bool isPointer() const;
int asInt() const;
};

typedef std::vector<ProgramValue> ProgramStack;

Expand Down
Loading