6 Commits
Author SHA1 Message Date
kichikuou d800e12f59 Math: Replace rand() with mt19937
On Windows RAND_MAX is 0x7fff, which makes Rand() and RandF() far too
coarse. Use mt19937 instead so that seeded sequences reproduce the
original engine's behavior.
2026-08-14 09:31:32 +09:00
kichikuou 65fa898d9f Destruct struct members in reverse order of declaration
Class members are destroyed in the reverse order of their declaration
(like C++). The previous code destroyed members in declaration order,
which caused a use-after-free in Rance 9's T_Map class.

Added a test to verify the reverse destruction order.
2026-03-29 16:13:46 +09:00
kichikuou 1ad7cbb2c5 Fix array.Alloc(negative number)
array.Alloc(negative number) should create an empty array.

This fixes crash in C_HOSPITAL_ABILITY_SWITCH_PADDING::Create() in
Pastel Chime 3.
2026-03-07 11:31:43 +09:00
kichikuou d4121032db system.ExistFile() should return false if path ends with a backslash
The system.ExistsFile() system call returns 1 if a file or directory
exists, but returns 0 when the provided path ends with a directory
separator, regardless of whether a directory exists at that location.

This subtle difference in behavior caused problems in Pastel Chime 3.
2026-03-07 11:31:43 +09:00
kichikuou 30ac11e74b Fix use-after-free in custom string array sort
Custom comparison functions for string arrays receive their arguments by
value. Create a copy of the strings before pushing them to the stack to
prevent them from being prematurely freed after the function call.
2026-02-16 08:49:33 +09:00
Nunuhara Cabbage f59158648f Check in test .ain file 2025-10-21 17:42:52 -07:00