示例#1
0
/**
 * Loads only the basic information from a scenario.
 *  rct2: 0x006761D6
 */
int scenario_load_basic(const char *path)
{
	FILE *file;
	rct_s6_header *s6Header = (rct_s6_header*)0x009E34E4;
	rct_s6_info *s6Info = (rct_s6_info*)0x0141F570;

	file = fopen(path, "rb");
	if (file != NULL) {
		// Read first chunk
		sawyercoding_read_chunk(file, (uint8*)s6Header);
		if (s6Header->type == S6_TYPE_SCENARIO) {
			// Read second chunk
			sawyercoding_read_chunk(file, (uint8*)s6Info);
			fclose(file);
			RCT2_GLOBAL(0x009AA00C, uint8) = 0;

			// Checks for a scenario string object (possibly for localisation)
			if ((s6Info->entry.flags & 0xFF) != 255) {
				if (object_get_scenario_text(&s6Info->entry)) {
					int ebp = RCT2_GLOBAL(0x009ADAF8, uint32);
					format_string(s6Info->name, RCT2_GLOBAL(ebp, sint16), NULL);
					format_string(s6Info->details, RCT2_GLOBAL(ebp + 4, sint16), NULL);
					RCT2_GLOBAL(0x009AA00C, uint8) = RCT2_GLOBAL(ebp + 6, uint8);
					object_free_scenario_text();
				}
			}
			return 1;
		}
		fclose(file);
	}

	RCT2_GLOBAL(0x009AC31B, sint8) = -1;
	RCT2_GLOBAL(0x009AC31C, sint16) = 3011;
	return 0;
}
示例#2
0
/**
 * 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)
{
	FILE *file;

	log_verbose("loading scenario details, %s", path);

	file = fopen(path, "rb");
	if (file != NULL) {
		// Read first chunk
		sawyercoding_read_chunk(file, (uint8*)header);
		if (header->type == S6_TYPE_SCENARIO) {
			// Read second chunk
			sawyercoding_read_chunk(file, (uint8*)info);
			fclose(file);
			RCT2_GLOBAL(0x009AA00C, uint8) = 0;

			// 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();
				}
			}
/**
 * 
 *  rct2: 0x006AB079
 */
static void window_editor_object_selection_scroll_mouseover()
{
	rct_window *w;
	rct_object_entry *installedEntry;
	int selectedObject;
	short x, y, scrollIndex;
	uint8 objectSelectionFlags;

	window_scrollmouse_get_registers(w, scrollIndex, x, y);

	selectedObject = get_object_from_object_selection(
		w->selected_tab & 0xFF, y, &objectSelectionFlags, &installedEntry
	);
	if (objectSelectionFlags & 0x20)
		selectedObject = -1;

	if (selectedObject == w->selected_list_item)
		return;

	w->selected_list_item = selectedObject;
	w->var_494 = (uint32)installedEntry;
	object_free_scenario_text();
	if (selectedObject != -1)
		object_get_scenario_text(installedEntry);

	window_invalidate(w);
}
示例#4
0
/**
 * 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();
					}
				}
			}
示例#5
0
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();
            }
        }
    }