Skip to content

Commit

Permalink
20250101
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangboyang committed Dec 31, 2024
1 parent 0bcb8d4 commit 0d66dc5
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/PAL3Apatch/src/PAL3Apatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ static void init_stage2()
INIT_PATCHSET(disableime);
INIT_PATCHSET(regredirect);
INIT_PATCHSET(console);
INIT_PATCHSET(timerresolution);
INIT_PATCHSET(relativetimer);
INIT_PATCHSET(audiofreq);
INIT_PATCHSET(showfps);
INIT_PATCHSET(timerresolution);
INIT_PATCHSET(reduceinputlatency); // should after INIT_PATCHSET(showfps)
INIT_PATCHSET(terminateatexit);
INIT_PATCHSET(preciseresmgr);
Expand Down
4 changes: 0 additions & 4 deletions src/PAL3Apatch/src/patch_relativetimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ static BOOL WINAPI My_QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)

MAKE_PATCHSET(relativetimer)
{
TIMECAPS tc;
if (timeGetDevCaps(&tc, sizeof(tc)) == TIMERR_NOERROR) {
timeBeginPeriod(tc.wPeriodMin);
}
timeOffset = timeGetTime();

if (QueryPerformanceFrequency(&countFrequency) && QueryPerformanceCounter(&countOffset)) {
Expand Down
12 changes: 10 additions & 2 deletions src/PAL3Apatch/src/patch_timerresolution.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ static void reset_timer_res()
MAKE_PATCHSET(timerresolution)
{
timer_res = flag;
timeBeginPeriod(timer_res);
add_atexit_hook(reset_timer_res);

TIMECAPS tc;
if (timeGetDevCaps(&tc, sizeof(tc)) == TIMERR_NOERROR) {
timer_res = imax(timer_res, tc.wPeriodMin);
timer_res = imin(timer_res, tc.wPeriodMax);
}

if (timeBeginPeriod(timer_res) == TIMERR_NOERROR) {
add_atexit_hook(reset_timer_res);
}
}
4 changes: 0 additions & 4 deletions src/PAL3patch/src/patch_relativetimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ static BOOL WINAPI My_QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)

MAKE_PATCHSET(relativetimer)
{
TIMECAPS tc;
if (timeGetDevCaps(&tc, sizeof(tc)) == TIMERR_NOERROR) {
timeBeginPeriod(tc.wPeriodMin);
}
timeOffset = timeGetTime();

if (QueryPerformanceFrequency(&countFrequency) && QueryPerformanceCounter(&countOffset)) {
Expand Down
12 changes: 10 additions & 2 deletions src/PAL3patch/src/patch_timerresolution.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ static void reset_timer_res()
MAKE_PATCHSET(timerresolution)
{
timer_res = flag;
timeBeginPeriod(timer_res);
add_atexit_hook(reset_timer_res);

TIMECAPS tc;
if (timeGetDevCaps(&tc, sizeof(tc)) == TIMERR_NOERROR) {
timer_res = imax(timer_res, tc.wPeriodMin);
timer_res = imin(timer_res, tc.wPeriodMax);
}

if (timeBeginPeriod(timer_res) == TIMERR_NOERROR) {
add_atexit_hook(reset_timer_res);
}
}
2 changes: 1 addition & 1 deletion src/PatchConfig/PatchConfig.rc
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ BEGIN
IDS_NODESC "��˵����"
IDS_CORRUPTFILE "��⵽�����ļ���ʧ���𻵣�\n\n%s\n�ֱ��ʲ����ܿ����޷������������Ƿ������"
IDS_CORRUPTFILE_TITLE "�ļ���"
IDS_CORRUPTCONFIG "���������ļ����𻵣��Ƿ�������������ΪĬ��ֵ��"
IDS_CORRUPTCONFIG "���������ļ����𻵣��Ƿ�������������ΪĬ��ֵ�����ò����޷�������"
IDS_CORRUPTCONFIG_TITLE "�޷���������"
IDS_WAITINGVERIFY "����У�鲹���ļ������Ժ� ..."
IDS_WAITINGLOADCFG "���ڼ��������ļ������Ժ� ..."
Expand Down
48 changes: 19 additions & 29 deletions src/PatchConfig/wstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

char *utf16_to_utf8(const wchar_t *s)
{
std::vector<char> v;
char *buf = (char *)Malloc(wcslen(s) * 3 + 1);
char *p = buf;
while (*s) {
unsigned c = 0xfffd;
unsigned short w1 = *s++;
Expand All @@ -16,34 +17,29 @@ char *utf16_to_utf8(const wchar_t *s)
}
}
if (c < (1 << 7)) {
v.push_back(c);
*p++ = c;
} else if (c < (1 << 11)) {
v.push_back(0xc0 | (c >> 6));
v.push_back(0x80 | (c & 0x3f));
*p++ = 0xc0 | (c >> 6);
*p++ = 0x80 | (c & 0x3f);
} else if (c < (1 << 16)) {
v.push_back(0xe0 | (c >> 12));
v.push_back(0x80 | ((c >> 6) & 0x3f));
v.push_back(0x80 | (c & 0x3f));
*p++ = 0xe0 | (c >> 12);
*p++ = 0x80 | ((c >> 6) & 0x3f);
*p++ = 0x80 | (c & 0x3f);
} else {
v.push_back(0xf0 | (c >> 18));
v.push_back(0x80 | ((c >> 12) & 0x3f));
v.push_back(0x80 | ((c >> 6) & 0x3f));
v.push_back(0x80 | (c & 0x3f));
*p++ = 0xf0 | (c >> 18);
*p++ = 0x80 | ((c >> 12) & 0x3f);
*p++ = 0x80 | ((c >> 6) & 0x3f);
*p++ = 0x80 | (c & 0x3f);
}
}
size_t l = v.size();
char *buf = (char *) Malloc(l + 1);
size_t i;
for (i = 0; i < l; i++) {
buf[i] = v[i];
}
buf[l] = 0;
*p = 0;
return buf;
}

wchar_t *utf8_to_utf16(const char *s)
{
std::vector<wchar_t> v;
wchar_t *buf = (wchar_t *)Malloc(sizeof(wchar_t) * (strlen(s) + 1));
wchar_t *p = buf;
while (*s) {
int i, n;
unsigned c;
Expand Down Expand Up @@ -79,20 +75,14 @@ wchar_t *utf8_to_utf16(const char *s)
s++;
}
if (c < 0x10000) {
v.push_back(c);
*p++ = c;
} else {
c -= 0x10000;
v.push_back(0xd800 | (c >> 10));
v.push_back(0xdc00 | (c & 0x3ff));
*p++ = 0xd800 | (c >> 10);
*p++ = 0xdc00 | (c & 0x3ff);
}
}
size_t l = v.size();
wchar_t *buf = (wchar_t *) Malloc((l + 1) * sizeof(wchar_t));
size_t i;
for (i = 0; i < l; i++) {
buf[i] = v[i];
}
buf[l] = 0;
*p = 0;
return buf;
}

Expand Down

0 comments on commit 0d66dc5

Please sign in to comment.