Skip to content

Commit 0d66dc5

Browse files
committed
20250101
1 parent 0bcb8d4 commit 0d66dc5

File tree

7 files changed

+41
-43
lines changed

7 files changed

+41
-43
lines changed

src/PAL3Apatch/src/PAL3Apatch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ static void init_stage2()
181181
INIT_PATCHSET(disableime);
182182
INIT_PATCHSET(regredirect);
183183
INIT_PATCHSET(console);
184+
INIT_PATCHSET(timerresolution);
184185
INIT_PATCHSET(relativetimer);
185186
INIT_PATCHSET(audiofreq);
186187
INIT_PATCHSET(showfps);
187-
INIT_PATCHSET(timerresolution);
188188
INIT_PATCHSET(reduceinputlatency); // should after INIT_PATCHSET(showfps)
189189
INIT_PATCHSET(terminateatexit);
190190
INIT_PATCHSET(preciseresmgr);

src/PAL3Apatch/src/patch_relativetimer.c

-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ static BOOL WINAPI My_QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
3131

3232
MAKE_PATCHSET(relativetimer)
3333
{
34-
TIMECAPS tc;
35-
if (timeGetDevCaps(&tc, sizeof(tc)) == TIMERR_NOERROR) {
36-
timeBeginPeriod(tc.wPeriodMin);
37-
}
3834
timeOffset = timeGetTime();
3935

4036
if (QueryPerformanceFrequency(&countFrequency) && QueryPerformanceCounter(&countOffset)) {

src/PAL3Apatch/src/patch_timerresolution.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ static void reset_timer_res()
99
MAKE_PATCHSET(timerresolution)
1010
{
1111
timer_res = flag;
12-
timeBeginPeriod(timer_res);
13-
add_atexit_hook(reset_timer_res);
12+
13+
TIMECAPS tc;
14+
if (timeGetDevCaps(&tc, sizeof(tc)) == TIMERR_NOERROR) {
15+
timer_res = imax(timer_res, tc.wPeriodMin);
16+
timer_res = imin(timer_res, tc.wPeriodMax);
17+
}
18+
19+
if (timeBeginPeriod(timer_res) == TIMERR_NOERROR) {
20+
add_atexit_hook(reset_timer_res);
21+
}
1422
}

src/PAL3patch/src/patch_relativetimer.c

-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ static BOOL WINAPI My_QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
3131

3232
MAKE_PATCHSET(relativetimer)
3333
{
34-
TIMECAPS tc;
35-
if (timeGetDevCaps(&tc, sizeof(tc)) == TIMERR_NOERROR) {
36-
timeBeginPeriod(tc.wPeriodMin);
37-
}
3834
timeOffset = timeGetTime();
3935

4036
if (QueryPerformanceFrequency(&countFrequency) && QueryPerformanceCounter(&countOffset)) {

src/PAL3patch/src/patch_timerresolution.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ static void reset_timer_res()
99
MAKE_PATCHSET(timerresolution)
1010
{
1111
timer_res = flag;
12-
timeBeginPeriod(timer_res);
13-
add_atexit_hook(reset_timer_res);
12+
13+
TIMECAPS tc;
14+
if (timeGetDevCaps(&tc, sizeof(tc)) == TIMERR_NOERROR) {
15+
timer_res = imax(timer_res, tc.wPeriodMin);
16+
timer_res = imin(timer_res, tc.wPeriodMax);
17+
}
18+
19+
if (timeBeginPeriod(timer_res) == TIMERR_NOERROR) {
20+
add_atexit_hook(reset_timer_res);
21+
}
1422
}

src/PatchConfig/PatchConfig.rc

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ BEGIN
187187
IDS_NODESC "��˵����"
188188
IDS_CORRUPTFILE "��⵽�����ļ���ʧ���𻵣�\n\n%s\n�ֱ��ʲ����ܿ����޷������������Ƿ������"
189189
IDS_CORRUPTFILE_TITLE "�ļ���"
190-
IDS_CORRUPTCONFIG "���������ļ����𻵣��Ƿ�������������ΪĬ��ֵ��"
190+
IDS_CORRUPTCONFIG "���������ļ����𻵣��Ƿ�������������ΪĬ��ֵ�����ò����޷�������"
191191
IDS_CORRUPTCONFIG_TITLE "�޷���������"
192192
IDS_WAITINGVERIFY "����У�鲹���ļ������Ժ� ..."
193193
IDS_WAITINGLOADCFG "���ڼ��������ļ������Ժ� ..."

src/PatchConfig/wstr.cpp

+19-29
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
char *utf16_to_utf8(const wchar_t *s)
44
{
5-
std::vector<char> v;
5+
char *buf = (char *)Malloc(wcslen(s) * 3 + 1);
6+
char *p = buf;
67
while (*s) {
78
unsigned c = 0xfffd;
89
unsigned short w1 = *s++;
@@ -16,34 +17,29 @@ char *utf16_to_utf8(const wchar_t *s)
1617
}
1718
}
1819
if (c < (1 << 7)) {
19-
v.push_back(c);
20+
*p++ = c;
2021
} else if (c < (1 << 11)) {
21-
v.push_back(0xc0 | (c >> 6));
22-
v.push_back(0x80 | (c & 0x3f));
22+
*p++ = 0xc0 | (c >> 6);
23+
*p++ = 0x80 | (c & 0x3f);
2324
} else if (c < (1 << 16)) {
24-
v.push_back(0xe0 | (c >> 12));
25-
v.push_back(0x80 | ((c >> 6) & 0x3f));
26-
v.push_back(0x80 | (c & 0x3f));
25+
*p++ = 0xe0 | (c >> 12);
26+
*p++ = 0x80 | ((c >> 6) & 0x3f);
27+
*p++ = 0x80 | (c & 0x3f);
2728
} else {
28-
v.push_back(0xf0 | (c >> 18));
29-
v.push_back(0x80 | ((c >> 12) & 0x3f));
30-
v.push_back(0x80 | ((c >> 6) & 0x3f));
31-
v.push_back(0x80 | (c & 0x3f));
29+
*p++ = 0xf0 | (c >> 18);
30+
*p++ = 0x80 | ((c >> 12) & 0x3f);
31+
*p++ = 0x80 | ((c >> 6) & 0x3f);
32+
*p++ = 0x80 | (c & 0x3f);
3233
}
3334
}
34-
size_t l = v.size();
35-
char *buf = (char *) Malloc(l + 1);
36-
size_t i;
37-
for (i = 0; i < l; i++) {
38-
buf[i] = v[i];
39-
}
40-
buf[l] = 0;
35+
*p = 0;
4136
return buf;
4237
}
4338

4439
wchar_t *utf8_to_utf16(const char *s)
4540
{
46-
std::vector<wchar_t> v;
41+
wchar_t *buf = (wchar_t *)Malloc(sizeof(wchar_t) * (strlen(s) + 1));
42+
wchar_t *p = buf;
4743
while (*s) {
4844
int i, n;
4945
unsigned c;
@@ -79,20 +75,14 @@ wchar_t *utf8_to_utf16(const char *s)
7975
s++;
8076
}
8177
if (c < 0x10000) {
82-
v.push_back(c);
78+
*p++ = c;
8379
} else {
8480
c -= 0x10000;
85-
v.push_back(0xd800 | (c >> 10));
86-
v.push_back(0xdc00 | (c & 0x3ff));
81+
*p++ = 0xd800 | (c >> 10);
82+
*p++ = 0xdc00 | (c & 0x3ff);
8783
}
8884
}
89-
size_t l = v.size();
90-
wchar_t *buf = (wchar_t *) Malloc((l + 1) * sizeof(wchar_t));
91-
size_t i;
92-
for (i = 0; i < l; i++) {
93-
buf[i] = v[i];
94-
}
95-
buf[l] = 0;
85+
*p = 0;
9686
return buf;
9787
}
9888

0 commit comments

Comments
 (0)