From 5bfe2d52f576f05520f32151f216f79cb29c1ae2 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 14 Aug 2014 18:35:19 +0100 Subject: [PATCH 1/3] Added object_scenario_load_custom_text function --- src/object.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/object.c b/src/object.c index e503fd9f88..a614660d05 100644 --- a/src/object.c +++ b/src/object.c @@ -94,8 +94,34 @@ static int object_calculate_checksum(rct_object_entry *entry, char *data, int da return checksum; } +/** + * rct2: 0x66B355 part + * If al is 0 + * chunk : esi + */ +int object_scenario_load_custom_text(char* chunk){ + int ebp = &((uint32*)chunk)[2]; + int edx = 0; + int eax, ebx, ecx, edi; + RCT2_CALLFUNC_X(0x6A9E24, &eax, &ebx, &ecx, &edx, &chunk, &edi, &ebp); + *((uint16*)chunk) = eax; + edx++; + RCT2_CALLFUNC_X(0x6A9E24, &eax, &ebx, &ecx, &edx, &chunk, &edi, &ebp); + *((uint16*)chunk + 1) = eax; + edx++; + RCT2_CALLFUNC_X(0x6A9E24, &eax, &ebx, &ecx, &edx, &chunk, &edi, &ebp); + *((uint16*)chunk + 2) = eax; + + if (RCT2_GLOBAL(0x9ADAF4, int) == -1)return 0; + else *(RCT2_GLOBAL(0x9ADAF4, uint32*)) = 0; + return 1; +} + int object_paint(int type, int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp) { + if (type == 10){ + if (eax == 0) return object_scenario_load_custom_text((char*)esi); + } RCT2_CALLPROC_X(RCT2_ADDRESS(0x0098D9D4, uint32)[type], eax, ebx, ecx, edx, esi, edi, ebp); #ifdef _MSC_VER __asm jb success From 0251cf7679e33aee48bc88d83567bc4e85b4e9e7 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 14 Aug 2014 19:27:13 +0100 Subject: [PATCH 2/3] Added comments capability to language.txt. Now reads string number --- data/language/english.txt | 5 +++++ src/string_ids.c | 28 ++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/data/language/english.txt b/data/language/english.txt index 61b3873735..86cf22e001 100644 --- a/data/language/english.txt +++ b/data/language/english.txt @@ -1,3 +1,6 @@ +# STR_XXXX part is read and XXXX becomes the string id number. +# Everything after the colon and before the new line will be saved as the string. +# Use # at the beginning of a line to leave a comment. STR_0000 : STR_0001 :{STRINGID} {COMMA16} STR_0002 :Ride @@ -2758,6 +2761,7 @@ STR_2756 :??? STR_2757 :??? STR_2758 :??? STR_2759 :??? +# New strings used in the cheats window previously these were ??? STR_2760 :+5K Money STR_2761 :Pay For Entrance STR_2762 :Pay For Rides @@ -2771,6 +2775,7 @@ STR_2769 :Open Park STR_2770 :Close Park STR_2771 :Slower Gamespeed STR_2772 :Faster Gamespeed +# End of new strings STR_2773 :??? STR_2774 :??? STR_2775 :??? diff --git a/src/string_ids.c b/src/string_ids.c index 9fafdc888b..40da3f789c 100644 --- a/src/string_ids.c +++ b/src/string_ids.c @@ -1720,8 +1720,9 @@ const char *get_string(rct_string_id id) * read / write strings in some way is decompiled. The original game used a DIY extended 8-bit extended ASCII set for special * characters, format codes and accents. * - * In terms of reading the language files, the STR_XXXX part is completely ignored at the moment. It just parses each line from - * the colon and thus not allowing gaps in the string indices. + * In terms of reading the language files, the STR_XXXX part is read and XXXX becomes the string id number. Everything after the + * colon and before the new line will be saved as the string. Tokens are written with inside curly braces {TOKEN}. + * Use # at the beginning of a line to leave a comment. */ int language_open(const char *filename) { @@ -1740,18 +1741,29 @@ int language_open(const char *filename) char *dst, *token; char tokenBuffer[64]; - int i, stringIndex = 0, mode = 0; + int i, stringIndex = 0, mode = 0, string_no; for (i = 0; i < language_buffer_size; i++) { char *src = &language_buffer[i]; switch (mode) { case 0: - // Search for colon - if (*src == ':') { + // Search for a comment + if (*src == '#'){ + mode = 3; + } + else if (*src == ':' && string_no != -1) { + // Search for colon dst = src + 1; - language_strings[stringIndex++] = dst; + language_strings[string_no] = dst; + stringIndex++; mode = 1; } + else if (!strncmp(src, "STR_", 4)){ + // Copy in the string number + if (sscanf(src, "STR_%d", &string_no) != 1){ + string_no = -1; + } + } break; case 1: // Copy string over, stop at line break @@ -1778,6 +1790,10 @@ int language_open(const char *filename) mode = 1; } break; + case 3: + if (*src == '\n' || *src == '\r'){ + mode = 0; + } } } language_num_strings = stringIndex; From 12800b8d74c01c5ccf229eb51f6ce9751232bc9e Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 14 Aug 2014 23:08:46 +0100 Subject: [PATCH 3/3] Removed warnings. Only reads 4 characters for string id --- src/object.c | 8 ++++---- src/string_ids.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/object.c b/src/object.c index a614660d05..1df31a9b79 100644 --- a/src/object.c +++ b/src/object.c @@ -100,16 +100,16 @@ static int object_calculate_checksum(rct_object_entry *entry, char *data, int da * chunk : esi */ int object_scenario_load_custom_text(char* chunk){ - int ebp = &((uint32*)chunk)[2]; + int ebp = (int)(&((uint32*)chunk)[2]); int edx = 0; int eax, ebx, ecx, edi; - RCT2_CALLFUNC_X(0x6A9E24, &eax, &ebx, &ecx, &edx, &chunk, &edi, &ebp); + RCT2_CALLFUNC_X(0x6A9E24, &eax, &ebx, &ecx, &edx, (int*)&chunk, &edi, &ebp); *((uint16*)chunk) = eax; edx++; - RCT2_CALLFUNC_X(0x6A9E24, &eax, &ebx, &ecx, &edx, &chunk, &edi, &ebp); + RCT2_CALLFUNC_X(0x6A9E24, &eax, &ebx, &ecx, &edx, (int*)&chunk, &edi, &ebp); *((uint16*)chunk + 1) = eax; edx++; - RCT2_CALLFUNC_X(0x6A9E24, &eax, &ebx, &ecx, &edx, &chunk, &edi, &ebp); + RCT2_CALLFUNC_X(0x6A9E24, &eax, &ebx, &ecx, &edx, (int*)&chunk, &edi, &ebp); *((uint16*)chunk + 2) = eax; if (RCT2_GLOBAL(0x9ADAF4, int) == -1)return 0; diff --git a/src/string_ids.c b/src/string_ids.c index 40da3f789c..eb142f1204 100644 --- a/src/string_ids.c +++ b/src/string_ids.c @@ -1759,8 +1759,8 @@ int language_open(const char *filename) mode = 1; } else if (!strncmp(src, "STR_", 4)){ - // Copy in the string number - if (sscanf(src, "STR_%d", &string_no) != 1){ + // Copy in the string number, 4 characters only + if (sscanf(src, "STR_%4d", &string_no) != 1){ string_no = -1; } }