Skip to content

Commit 523b693

Browse files
committed
20250525
1 parent 26effcd commit 523b693

File tree

16 files changed

+50
-61
lines changed

16 files changed

+50
-61
lines changed

COMPILE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
(1)按实际情况修改 Makefile (如 freetype 库的路径、DirectX SDK 的路径等)
102102
(2)运行 MSYS,在命令行中切换目录到 src 目录下,执行 make 命令即可编译
103103
(3)编译好的程序位于:
104+
src\PAL3\Release\PAL3.dll
104105
src\PAL3patch\PAL3patch.dll
105106
src\PatchConfig\Release_PAL3\PatchConfig.exe
106107
注意:

src/PAL3Apatch/include/PAL3Apatch/fsutil.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ extern PATCHAPI int create_dir(const char *dirpath);
1414
extern PATCHAPI int dir_exists(const char *dirpath);
1515
extern PATCHAPI int file_exists(const char *filepath);
1616
extern PATCHAPI int reset_attrib(const char *filepath);
17-
extern PATCHAPI int batch_delete(const char *filepath[], int n);
17+
extern PATCHAPI int robust_delete(const char *filepath[], int n);
18+
extern PATCHAPI int robust_delete1(const char *filepath);
1819

1920

2021
#ifdef PATCHAPI_EXPORTS
2122
// INTERNAL DEFINITIONS
2223

2324
// don't pass CRT objects (FILE *, errno, etc.) across DLL boundary
24-
extern FILE *robust_fopen(const char *filename, const char *mode);
25+
extern FILE *robust_fopen(const char *filepath, const char *mode);
2526
extern int safe_fclose(FILE **fp);
26-
extern int robust_unlink(const char *filename);
2727

2828
#endif
2929
#endif

src/PAL3Apatch/src/PAL3Apatch.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void process_temp_command()
100100
if (!prepare_d3denum(config)) die(1);
101101
}
102102

103-
if (robust_unlink(PATCH_TEMP_IN) != 0) {
103+
if (!robust_delete1(PATCH_TEMP_IN)) {
104104
MessageBoxW_format(NULL, wstr_cantdeltemp_text, wstr_cantdeltemp_title, MB_ICONERROR | MB_TOPMOST | MB_SETFOREGROUND, PATCH_TEMP_IN);
105105
die(1);
106106
}
@@ -115,8 +115,7 @@ static void process_temp_command()
115115
fclose(fp);
116116
die(success ? 0 : 1);
117117
}
118-
const char *temp[2] = { PATCH_TEMP_IN, PATCH_TEMP_OUT };
119-
batch_delete(temp, 2);
118+
robust_delete((const char *[]) { PATCH_TEMP_IN, PATCH_TEMP_OUT }, 2);
120119
release_mutex(temp_mutex); temp_mutex = NULL;
121120
}
122121

@@ -293,7 +292,7 @@ static int try_fix_unpacker()
293292
const unsigned char oldcode[] = "\x83\x7C\x24\x08\x01\x75\x10\x8B\x44\x24\x04";
294293
const unsigned char newcode[] = "\x59\x58\x5A\x83\xFA\x01\x5A\x51\x75\x0D\x90";
295294
unsigned char buf[sizeof(oldcode) - 1];
296-
robust_unlink(EXTERNAL_UNPACKER_FIXED);
295+
robust_delete1(EXTERNAL_UNPACKER_FIXED);
297296
if (!CopyFile(EXTERNAL_UNPACKER, EXTERNAL_UNPACKER_FIXED, FALSE)) return 0;
298297
FILE *fp = robust_fopen(EXTERNAL_UNPACKER_FIXED, "r+bc");
299298
if (!fp) return 0;

src/PAL3Apatch/src/badfiles.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void check_badfiles()
4242

4343
if (!cstr_empty(&buf)) {
4444
if (MessageBoxW_format(NULL, wstr_havebadfile_text, wstr_havebadfile_title, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON1 | MB_TOPMOST | MB_SETFOREGROUND, cstr_getstr(&buf)) == IDYES) {
45-
if (!batch_delete(bad_files, n)) {
45+
if (!robust_delete(bad_files, n)) {
4646
cstr_clear(&buf);
4747
for (ptr = bad_files; *ptr; ptr++) {
4848
if (file_exists(*ptr)) {

src/PAL3Apatch/src/fsutil.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@ int reset_attrib(const char *filepath)
229229
#define ROBUST_MAXTRY 10
230230
#define ROBUST_WAIT 100
231231

232-
FILE *robust_fopen(const char *filename, const char *mode)
232+
FILE *robust_fopen(const char *filepath, const char *mode)
233233
{
234234
FILE *ret;
235235
int i;
236236
for (i = 0; i < ROBUST_MAXTRY; i++) {
237237
if (i) Sleep(ROBUST_WAIT);
238-
reset_attrib(filename);
239-
ret = fopen(filename, mode);
238+
reset_attrib(filepath);
239+
ret = fopen(filepath, mode);
240240
if (ret || errno == ENOENT) break;
241241
}
242242
return ret;
@@ -252,20 +252,7 @@ int safe_fclose(FILE **fp)
252252
return ret;
253253
}
254254

255-
int robust_unlink(const char *filename)
256-
{
257-
int ret;
258-
int i;
259-
for (i = 0; i < ROBUST_MAXTRY; i++) {
260-
if (i) Sleep(ROBUST_WAIT);
261-
reset_attrib(filename);
262-
ret = _unlink(filename);
263-
if (ret == 0 || errno == ENOENT) break;
264-
}
265-
return ret;
266-
}
267-
268-
int batch_delete(const char *filepath[], int n)
255+
int robust_delete(const char *filepath[], int n)
269256
{
270257
int i, j;
271258
for (i = 0; i < ROBUST_MAXTRY; i++) {
@@ -279,3 +266,8 @@ int batch_delete(const char *filepath[], int n)
279266
}
280267
return 0;
281268
}
269+
270+
int robust_delete1(const char *filepath)
271+
{
272+
return robust_delete(&filepath, 1);
273+
}

src/PAL3Apatch/src/patch_improvearchive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ static MAKE_THISCALL(BOOL, my_Archive_Delete, struct Archive *this, int index)
308308
sprintf(s, "save\\pal3a%02d.arc", index);
309309
arc_wal_init(&rm, s);
310310
arc_wal_check(&rm);
311-
if (!batch_delete((const char **) rm.dst, ARC_FILE_COUNT)) ret = FALSE;
311+
if (!robust_delete((const char **) rm.dst, ARC_FILE_COUNT)) ret = FALSE;
312312
arc_wal_free(&rm);
313313
}
314314
return ret;

src/PAL3Apatch/src/wal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static int do_overwrite(const char *dst[], const char *src[], int n, const char
101101
// internal: delete checksum and src
102102
static int do_cleanup(const char *src[], int n, const char *sum)
103103
{
104-
return batch_delete(&sum, 1) && batch_delete(src, n);
104+
return robust_delete1(sum) && robust_delete(src, n);
105105
}
106106

107107
// internal: commit changes

src/PAL3patch/include/PAL3patch/fsutil.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ extern PATCHAPI int create_dir(const char *dirpath);
1414
extern PATCHAPI int dir_exists(const char *dirpath);
1515
extern PATCHAPI int file_exists(const char *filepath);
1616
extern PATCHAPI int reset_attrib(const char *filepath);
17-
extern PATCHAPI int batch_delete(const char *filepath[], int n);
17+
extern PATCHAPI int robust_delete(const char *filepath[], int n);
18+
extern PATCHAPI int robust_delete1(const char *filepath);
1819

1920

2021
#ifdef PATCHAPI_EXPORTS
2122
// INTERNAL DEFINITIONS
2223

2324
// don't pass CRT objects (FILE *, errno, etc.) across DLL boundary
24-
extern FILE *robust_fopen(const char *filename, const char *mode);
25+
extern FILE *robust_fopen(const char *filepath, const char *mode);
2526
extern int safe_fclose(FILE **fp);
26-
extern int robust_unlink(const char *filename);
2727

2828
#endif
2929
#endif

src/PAL3patch/src/PAL3patch.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static void process_temp_command()
103103
if (!prepare_d3denum(config)) die(1);
104104
}
105105

106-
if (robust_unlink(PATCH_TEMP_IN) != 0) {
106+
if (!robust_delete1(PATCH_TEMP_IN)) {
107107
MessageBoxW_format(NULL, wstr_cantdeltemp_text, wstr_cantdeltemp_title, MB_ICONERROR | MB_TOPMOST | MB_SETFOREGROUND, PATCH_TEMP_IN);
108108
die(1);
109109
}
@@ -118,8 +118,7 @@ static void process_temp_command()
118118
fclose(fp);
119119
die(success ? 0 : 1);
120120
}
121-
const char *temp[2] = { PATCH_TEMP_IN, PATCH_TEMP_OUT };
122-
batch_delete(temp, 2);
121+
robust_delete((const char *[]) { PATCH_TEMP_IN, PATCH_TEMP_OUT }, 2);
123122
release_mutex(temp_mutex); temp_mutex = NULL;
124123
}
125124

@@ -293,7 +292,7 @@ static int try_fix_unpacker()
293292
const unsigned char oldcode[] = "\x83\x7C\x24\x08\x01\x75\x10\x8B\x44\x24\x04";
294293
const unsigned char newcode[] = "\x59\x58\x5A\x83\xFA\x01\x5A\x51\x75\x0D\x90";
295294
unsigned char buf[sizeof(oldcode) - 1];
296-
robust_unlink(EXTERNAL_UNPACKER_FIXED);
295+
robust_delete1(EXTERNAL_UNPACKER_FIXED);
297296
if (!CopyFile(EXTERNAL_UNPACKER, EXTERNAL_UNPACKER_FIXED, FALSE)) return 0;
298297
FILE *fp = robust_fopen(EXTERNAL_UNPACKER_FIXED, "r+bc");
299298
if (!fp) return 0;

src/PAL3patch/src/fsutil.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@ int reset_attrib(const char *filepath)
229229
#define ROBUST_MAXTRY 10
230230
#define ROBUST_WAIT 100
231231

232-
FILE *robust_fopen(const char *filename, const char *mode)
232+
FILE *robust_fopen(const char *filepath, const char *mode)
233233
{
234234
FILE *ret;
235235
int i;
236236
for (i = 0; i < ROBUST_MAXTRY; i++) {
237237
if (i) Sleep(ROBUST_WAIT);
238-
reset_attrib(filename);
239-
ret = fopen(filename, mode);
238+
reset_attrib(filepath);
239+
ret = fopen(filepath, mode);
240240
if (ret || errno == ENOENT) break;
241241
}
242242
return ret;
@@ -252,20 +252,7 @@ int safe_fclose(FILE **fp)
252252
return ret;
253253
}
254254

255-
int robust_unlink(const char *filename)
256-
{
257-
int ret;
258-
int i;
259-
for (i = 0; i < ROBUST_MAXTRY; i++) {
260-
if (i) Sleep(ROBUST_WAIT);
261-
reset_attrib(filename);
262-
ret = _unlink(filename);
263-
if (ret == 0 || errno == ENOENT) break;
264-
}
265-
return ret;
266-
}
267-
268-
int batch_delete(const char *filepath[], int n)
255+
int robust_delete(const char *filepath[], int n)
269256
{
270257
int i, j;
271258
for (i = 0; i < ROBUST_MAXTRY; i++) {
@@ -279,3 +266,8 @@ int batch_delete(const char *filepath[], int n)
279266
}
280267
return 0;
281268
}
269+
270+
int robust_delete1(const char *filepath)
271+
{
272+
return robust_delete(&filepath, 1);
273+
}

0 commit comments

Comments
 (0)