From 20635921c2dbebfbed84177b1295ef6a075e5807 Mon Sep 17 00:00:00 2001 From: Dethrace Labs <78985374+dethrace-labs@users.noreply.github.com> Date: Tue, 2 Sep 2025 06:31:59 +1200 Subject: [PATCH] SubsStringJob matches --- src/DETHRACE/common/input.c | 6 ++---- src/DETHRACE/common/loading.c | 3 +-- src/DETHRACE/common/utility.c | 8 ++------ 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/DETHRACE/common/input.c b/src/DETHRACE/common/input.c index 7192b7e3..8a86c824 100644 --- a/src/DETHRACE/common/input.c +++ b/src/DETHRACE/common/input.c @@ -102,6 +102,7 @@ void PollKeys(void) { // FUNCTION: CARM95 0x00471c03 void CyclePollKeys(void) { int i; + for (i = 0; i < COUNT_OF(gKey_array); i++) { if (gKey_array[i] > gKey_poll_counter) { gKey_array[i] = 0; @@ -239,10 +240,7 @@ int AnyKeyDown(void) { int the_key; the_key = PDAnyKeyDown(); - if ((the_key != -1 && the_key != 4) || EitherMouseButtonDown() != 0) { - return 1; - } - return 0; + return the_key != -1 && the_key != 4 || EitherMouseButtonDown(); } // IDA: tU32* __cdecl KevKeyService() diff --git a/src/DETHRACE/common/loading.c b/src/DETHRACE/common/loading.c index 5178efb4..a2b5e3b3 100644 --- a/src/DETHRACE/common/loading.c +++ b/src/DETHRACE/common/loading.c @@ -2880,8 +2880,7 @@ void LoadOpponents(void) { gOpponents[i].text_chunk_count = GetAnInt(f); gOpponents[i].text_chunks = BrMemAllocate(sizeof(tText_chunk) * gOpponents[i].text_chunk_count, kMem_oppo_text_chunk); - for (j = 0; j < gOpponents[i].text_chunk_count; j++) { - the_chunk = &gOpponents[i].text_chunks[j]; + for (j = 0, the_chunk = gOpponents[i].text_chunks; j < gOpponents[i].text_chunk_count; j++, the_chunk++) { PossibleService(); GetPairOfInts(f, &the_chunk->x_coord, &the_chunk->y_coord); GetPairOfInts(f, &the_chunk->frame_cue, &the_chunk->frame_end); diff --git a/src/DETHRACE/common/utility.c b/src/DETHRACE/common/utility.c index 39c93d9e..bdb54947 100644 --- a/src/DETHRACE/common/utility.c +++ b/src/DETHRACE/common/utility.c @@ -1430,18 +1430,14 @@ void SubsStringJob(char* pStr, ...) { va_list ap; va_start(ap, pStr); - for (;;) { - sub_pt = strchr(pStr, '%'); - if (sub_pt == NULL) { - va_end(ap); - return; - } + while ((sub_pt = strchr(pStr, '%')) != NULL) { sub_str = va_arg(ap, char*); StripCR(sub_str); strcpy(temp_str, &sub_pt[1]); strcpy(sub_pt, sub_str); strcat(pStr, temp_str); } + va_end(ap); } // IDA: void __usercall DecodeLine2(char *pS@)