/** * Loads only the basic information from a scenario. * rct2: 0x006761D6 */ int scenario_load_basic(const char *path, rct_s6_header *header, rct_s6_info *info) { SDL_RWops* rw; log_verbose("loading scenario details, %s", path); rw = SDL_RWFromFile(path, "rb"); if (rw != NULL) { // Read first chunk sawyercoding_read_chunk(rw, (uint8*)header); if (header->type == S6_TYPE_SCENARIO) { // Read second chunk sawyercoding_read_chunk(rw, (uint8*)info); SDL_RWclose(rw); RCT2_GLOBAL(0x009AA00C, uint8) = 0; // Get filename utf8 filename[MAX_PATH]; const char *temp_filename = path_get_filename(path); int len = strnlen(temp_filename, MAX_PATH); safe_strncpy(filename, temp_filename, MAX_PATH); if (len == MAX_PATH) { filename[MAX_PATH - 1] = '\0'; log_warning("truncated string %s", filename); } path_remove_extension(filename); rct_string_id localisedStringIds[3]; if (language_get_localised_scenario_strings(filename, localisedStringIds)) { if (localisedStringIds[0] != (rct_string_id)STR_NONE) { safe_strncpy(info->name, language_get_string(localisedStringIds[0]), 64); } if (localisedStringIds[2] != (rct_string_id)STR_NONE) { safe_strncpy(info->details, language_get_string(localisedStringIds[2]), 256); } } else { // Checks for a scenario string object (possibly for localisation) if ((info->entry.flags & 0xFF) != 255) { if (object_get_scenario_text(&info->entry)) { rct_stex_entry* stex_entry = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TEXT_TEMP_CHUNK, rct_stex_entry*); format_string(info->name, stex_entry->scenario_name, NULL); format_string(info->details, stex_entry->details, NULL); RCT2_GLOBAL(0x009AA00C, uint8) = stex_entry->var_06; object_free_scenario_text(); } } }
static void scenario_translate(scenario_index_entry *scenarioEntry, const rct_object_entry *stexObjectEntry) { rct_string_id localisedStringIds[3]; if (language_get_localised_scenario_strings(scenarioEntry->name, localisedStringIds)) { if (localisedStringIds[0] != STR_NONE) { safe_strcpy(scenarioEntry->name, language_get_string(localisedStringIds[0]), 64); } if (localisedStringIds[2] != STR_NONE) { safe_strcpy(scenarioEntry->details, language_get_string(localisedStringIds[2]), 256); } } else { // Checks for a scenario string object (possibly for localisation) if ((stexObjectEntry->flags & 0xFF) != 255) { if (object_get_scenario_text((rct_object_entry*)stexObjectEntry)) { rct_stex_entry* stex_entry = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TEXT_TEMP_CHUNK, rct_stex_entry*); format_string(scenarioEntry->name, stex_entry->scenario_name, NULL); format_string(scenarioEntry->details, stex_entry->details, NULL); object_free_scenario_text(); } } }