mirror of
https://github.com/cave-story-randomizer/cave-story-randomizer
synced 2025-01-02 18:26:41 +00:00
add patch to read version from file
This commit is contained in:
parent
902dcd71d9
commit
fad711364b
17
.gitignore
vendored
17
.gitignore
vendored
|
@ -1,12 +1,6 @@
|
||||||
data/*
|
data/*
|
||||||
notes/*
|
notes/*
|
||||||
|
|
||||||
pre_edited_cs/Doukutsu\.exe\.blbkp
|
|
||||||
|
|
||||||
pre_edited_cs/Profile*
|
|
||||||
|
|
||||||
pre_edited_cs/window\.rect
|
|
||||||
|
|
||||||
*Copy/
|
*Copy/
|
||||||
|
|
||||||
venv/
|
venv/
|
||||||
|
@ -17,9 +11,12 @@ dist/
|
||||||
|
|
||||||
cave_story_randomizer.egg-info/
|
cave_story_randomizer.egg-info/
|
||||||
|
|
||||||
*/__pycache__
|
**/__pycache__
|
||||||
caver/version.py
|
|
||||||
|
|
||||||
pre_edited_cs/data/Stage/_version.txt
|
pre_edited_cs/**/Doukutsu\.exe\.blbkp
|
||||||
|
pre_edited_cs/**/Profile*
|
||||||
|
pre_edited_cs/**/window\.rect
|
||||||
|
|
||||||
pre_edited_cs/freeware/window.rect
|
pre_edited_cs/data/version.txt
|
||||||
|
|
||||||
|
pre_edited_cs/freeware/Doukutsu_backup.exe
|
||||||
|
|
|
@ -98,10 +98,10 @@ def patch_files(
|
||||||
def ensure_base_files_exist(platform: CSPlatform, output_dir: Path) -> None:
|
def ensure_base_files_exist(platform: CSPlatform, output_dir: Path) -> None:
|
||||||
internal_copy = pre_edited_cs.get_path()
|
internal_copy = pre_edited_cs.get_path()
|
||||||
|
|
||||||
with internal_copy.joinpath("data", "Stage", "_version.txt").open() as version_file:
|
with internal_copy.joinpath("data", "version.txt").open() as version_file:
|
||||||
latest_version = version_file.readline()
|
latest_version = version_file.readline()
|
||||||
|
|
||||||
version = output_dir.joinpath("data", "Stage", "_version.txt")
|
version = output_dir.joinpath("data", "version.txt")
|
||||||
current_version = "v0.0.0.0"
|
current_version = "v0.0.0.0"
|
||||||
if version.exists():
|
if version.exists():
|
||||||
with version.open() as version_file:
|
with version.open() as version_file:
|
||||||
|
|
103
cs-hacks/VersionFromFile/version_from_file.txt
Normal file
103
cs-hacks/VersionFromFile/version_from_file.txt
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
; Reads version number from data\version.txt
|
||||||
|
; The file must start with the version string in the format shown at the bottom of this file
|
||||||
|
; Made by periwinkle
|
||||||
|
|
||||||
|
#define
|
||||||
|
gDataPath=49E220
|
||||||
|
gVersionString=48C2BC
|
||||||
|
sprintf=481010
|
||||||
|
fopen=480FFD
|
||||||
|
rb=48C28C
|
||||||
|
fread=480F55
|
||||||
|
fclose=480E1B
|
||||||
|
sscanf=4817E8
|
||||||
|
call VirtualProtect=data ff 15 84 c0 48 00
|
||||||
|
filePath=[ebp-114]
|
||||||
|
bufchk=[ebp-10]
|
||||||
|
tmp=[ebp-c]
|
||||||
|
oldProtect=[ebp-8]
|
||||||
|
fp=[ebp-4]
|
||||||
|
v1=[ebp+8]
|
||||||
|
v2=[ebp+c]
|
||||||
|
v3=[ebp+10]
|
||||||
|
v4=[ebp+14]
|
||||||
|
#enddefine
|
||||||
|
|
||||||
|
offset 410990 ; GetCompileVersion
|
||||||
|
push ebp
|
||||||
|
mov ebp, esp
|
||||||
|
sub esp, 114
|
||||||
|
mov eax, [498B20]
|
||||||
|
mov bufchk, eax
|
||||||
|
|
||||||
|
; Get path to data\version.txt file
|
||||||
|
push gDataPath
|
||||||
|
push :VersionPath ; "%s\version.txt"
|
||||||
|
lea edx, filePath
|
||||||
|
push edx
|
||||||
|
call sprintf
|
||||||
|
add esp, c
|
||||||
|
|
||||||
|
; Open file
|
||||||
|
push rb ; "rb"
|
||||||
|
lea ecx, filePath
|
||||||
|
push ecx
|
||||||
|
call fopen
|
||||||
|
add esp, 8
|
||||||
|
test eax, eax
|
||||||
|
jz :ReadVersion
|
||||||
|
mov fp, eax
|
||||||
|
|
||||||
|
; Mark gVersionString as read/write (it's normally in a read-only segment)
|
||||||
|
lea eax, oldProtect
|
||||||
|
push eax
|
||||||
|
push 4 ; PAGE_READWRITE
|
||||||
|
push 40 ; Max size of gVersionString (including null character)
|
||||||
|
push gVersionString
|
||||||
|
call VirtualProtect
|
||||||
|
test eax, eax
|
||||||
|
jz :CloseFile
|
||||||
|
|
||||||
|
; Read contents of file into gVersionString
|
||||||
|
push fp
|
||||||
|
|
||||||
|
push 3F ; count (excluding null character)
|
||||||
|
push 1 ; size
|
||||||
|
push gVersionString
|
||||||
|
call fread
|
||||||
|
add esp, 10
|
||||||
|
mov byte [eax+gVersionString], 0 ; Write null terminator
|
||||||
|
|
||||||
|
; Restore previous protection status
|
||||||
|
lea eax, tmp
|
||||||
|
push eax
|
||||||
|
push oldProtect
|
||||||
|
push 40
|
||||||
|
push gVersionString
|
||||||
|
call VirtualProtect
|
||||||
|
|
||||||
|
:CloseFile
|
||||||
|
push fp
|
||||||
|
call fclose
|
||||||
|
pop ecx
|
||||||
|
|
||||||
|
:ReadVersion
|
||||||
|
; Parse the version string
|
||||||
|
push v4
|
||||||
|
push v3
|
||||||
|
push v2
|
||||||
|
push v1
|
||||||
|
push :VersionString
|
||||||
|
push gVersionString
|
||||||
|
call sscanf
|
||||||
|
add esp, 18
|
||||||
|
|
||||||
|
mov ecx, bufchk
|
||||||
|
call 480DC1
|
||||||
|
leave
|
||||||
|
retn
|
||||||
|
|
||||||
|
:VersionPath
|
||||||
|
data 25 73 5C 76 65 72 73 69 6F 6E 2E 74 78 74 00 00 ; "%s\version.txt"
|
||||||
|
:VersionString
|
||||||
|
data 76 25 64 2E 25 64 2E 25 64 2E 25 64 00 ; "v%d.%d.%d.%d"
|
Binary file not shown.
3
pre_edited_cs/freeware/data/version.txt
Normal file
3
pre_edited_cs/freeware/data/version.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
v0.0.0.0
|
||||||
|
2019/03/07 - ????/??/??
|
||||||
|
duncathan_salt
|
|
@ -3,9 +3,10 @@ requires = ["setuptools>=44.0.0", "setuptools_scm[toml]>=3.4.3"]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[tool.setuptools_scm]
|
[tool.setuptools_scm]
|
||||||
version_file_template = "v{version_tuple[0]}.{version_tuple[1]}.{version_tuple[2]}.{scm_version.distance}\n2019/03/07 - {scm_version.node_date.year:04}/{scm_version.node_date.month:02}/{scm_version.node_date.day:02}\nduncathan_salt"
|
version_file_template = "v{scm_version.tag}.{scm_version.distance}\n2019/03/07 - {scm_version.node_date.year:04}/{scm_version.node_date.month:02}/{scm_version.node_date.day:02}\nduncathan_salt"
|
||||||
local_scheme = "no-local-version"
|
local_scheme = "no-local-version"
|
||||||
version_file = "pre_edited_cs/data/Stage/_version.txt"
|
version_scheme = "no-guess-dev"
|
||||||
|
version_file = "pre_edited_cs/data/version.txt"
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
line-length = 120
|
line-length = 120
|
||||||
|
|
Loading…
Reference in a new issue