Skip to content

Commit

Permalink
Fix STLport version checks and decompctx.py version define passthroug…
Browse files Browse the repository at this point in the history
…hs (#237)

* Fix STLport version define checks
Previously caused issues when no version was defined

* Fix/unify decompctx.py version list
Made the same typo as I made in macros.h initially lol
  • Loading branch information
TheNathannator authored Jun 3, 2024
1 parent 0dfe175 commit 21a5673
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
14 changes: 5 additions & 9 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
is_windows,
)

from tools.cflags_common import cflags_includes

# Game versions
# Be sure to update macros.h if this list changes!
DEFAULT_VERSION = 1
VERSIONS = [
"SZBE69", # 0
"SZBE69_B8", # 1
]
from tools.defines_common import (
cflags_includes,
DEFAULT_VERSION,
VERSIONS
)

parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down
4 changes: 2 additions & 2 deletions src/system/stlport/stl/_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ class __node_alloc {
#endif /* _STLP_USE_NO_IOSTREAMS */

// Decomp hack: converts an allocator from one type to another
#if defined(VERSION_SZBE69)
#ifdef VERSION_SZBE69
// Note: does not preserve state! This is fine since StlNodeAlloc has no state,
// and no other allocators are used as far as we've seen
# define _STLP_CONVERT_ALLOCATOR(__a, _Alloc, _Tp) _Alloc_traits<_Tp, _Alloc>::allocator_type()
#elif defined(VERSION_SZBE69_B8)
#else
# define _STLP_CONVERT_ALLOCATOR(__a, _Alloc, _Tp) __a
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/system/stlport/stl/_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ class _Vector_base {

// _M_inc_finish_idx in retail doesn't match with size_type as the parameter,
// but symbols in bank 8 indicate it uses size_type
#if defined(VERSION_SZBE69)
#ifdef VERSION_SZBE69
void _M_inc_finish_idx(_Size increment) {
#elif defined(VERSION_SZBE69_B8)
#else
void _M_inc_finish_idx(size_type increment) {
#endif
_STLP_VEC_RANGE_ASSERT(_M_finish_idx + increment, (_Size)~0);
Expand Down
11 changes: 6 additions & 5 deletions tools/decompctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
from contextlib import redirect_stdout
from typing import Optional

# Note: requires being in the same directory as cflags_common.py
from cflags_common import cflags_includes
# Note: requires being in the same directory as defines_common.py
from tools.defines_common import (
cflags_includes,
VERSIONS
)

#region Regex Patterns
at_address_pattern = re.compile(r"(?:.*?)(?:[a-zA-Z_$][\w$]*\s*\*?\s[a-zA-Z_$][\w$]*)\s*((?:AT_ADDRESS|:)(?:\s*\(?\s*)(0x[0-9a-fA-F]+|[a-zA-Z_$][\w$]*)\)?);")
Expand Down Expand Up @@ -49,9 +52,7 @@
"__STDC_VERSION__",

# Game version defines
"GAME_VERSION",
"VERSION_SZBE69"
"VERSION_SZBE69_BE"
*[f"VERSION_{version}" for version in VERSIONS],

# Debug defines
"NDEBUG",
Expand Down
8 changes: 8 additions & 0 deletions tools/cflags_common.py → tools/defines_common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Game versions
DEFAULT_VERSION = 1
VERSIONS = [
"SZBE69", # 0
"SZBE69_B8", # 1
]

# Include paths
cflags_includes = [
# C/C++ stdlib
# STLport requires that it comes first in the include path list
Expand Down

0 comments on commit 21a5673

Please sign in to comment.