diff --git a/src/management/research.c b/src/management/research.c index 1a2d1ecc28..f44ed4c5b2 100644 --- a/src/management/research.c +++ b/src/management/research.c @@ -57,10 +57,9 @@ void research_update_uncompleted_types() { int uncompletedResearchTypes = 0; rct_research_item *researchItem = gResearchItems; - while (researchItem->entryIndex != -1) - researchItem++; - researchItem++; - for (; researchItem->entryIndex != -2; researchItem++) + while (researchItem++->entryIndex != RESEARCHED_ITEMS_SEPERATOR); + + for (; researchItem->entryIndex != RESEARCHED_ITEMS_END; researchItem++) uncompletedResearchTypes |= (1 << researchItem->category); gResearchUncompletedCategories = uncompletedResearchTypes; @@ -163,7 +162,7 @@ static void research_next_design() */ void research_finish_item(sint32 entryIndex) { - int i, ebx, ecx, rideEntryIndex, subSceneryEntryIndex; + int i, ebx, base_ride_type, rideEntryIndex, subSceneryEntryIndex; rct_ride_type *rideEntry, *rideEntry2; rct_scenery_set_entry *scenerySetEntry; @@ -171,35 +170,35 @@ void research_finish_item(sint32 entryIndex) research_invalidate_related_windows(); if (entryIndex >= 0x10000) { // Ride - ecx = (entryIndex >> 8) & 0xFF; + base_ride_type = (entryIndex >> 8) & 0xFF; rideEntryIndex = entryIndex & 0xFF; rideEntry = GET_RIDE_ENTRY(rideEntryIndex); - RCT2_ADDRESS(0x01357404, uint32)[ecx >> 5] |= (1 << (ecx & 0x1F)); - RCT2_ADDRESS(0x01357444, uint32)[ecx] = RCT2_ADDRESS(0x0097C468, uint32)[ecx]; - RCT2_ADDRESS(0x01357644, uint32)[ecx] = RCT2_ADDRESS(0x0097C5D4, uint32)[ecx]; - if (RCT2_GLOBAL(0x0097D4F2 + (ecx * 8), uint16) & 8) { - ebx = RCT2_GLOBAL(0x0097D4F5 + (ecx * 8), uint8); + RCT2_ADDRESS(0x01357404, uint32)[base_ride_type >> 5] |= (1 << (base_ride_type & 0x1F)); + RCT2_ADDRESS(0x01357444, uint32)[base_ride_type] = RCT2_ADDRESS(0x0097C468, uint32)[base_ride_type]; + RCT2_ADDRESS(0x01357644, uint32)[base_ride_type] = RCT2_ADDRESS(0x0097C5D4, uint32)[base_ride_type]; + if (RCT2_GLOBAL(0x0097D4F2 + (base_ride_type * 8), uint16) & 8) { + ebx = RCT2_GLOBAL(0x0097D4F5 + (base_ride_type * 8), uint8); RCT2_ADDRESS(0x01357444, uint32)[ebx] = RCT2_ADDRESS(0x0097C468, uint32)[ebx]; RCT2_ADDRESS(0x01357644, uint32)[ebx] = RCT2_ADDRESS(0x0097C5D4, uint32)[ebx]; } RCT2_ADDRESS(0x001357424, uint32)[rideEntryIndex >> 5] |= 1 << (rideEntryIndex & 0x1F); - if (!(rideEntry->var_008 & 0x2000)) { + if (!(rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE)) { for (i = 0; i < 128; i++) { rideEntry2 = GET_RIDE_ENTRY(i); if (rideEntry2 == (rct_ride_type*)-1) continue; - if (rideEntry2->var_008 & 0x2000) + if (rideEntry2->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE) continue; - if (rideEntry2->ride_type[0] == ecx || rideEntry2->ride_type[1] == ecx || rideEntry2->ride_type[2] == ecx) + if (rideEntry2->ride_type[0] == base_ride_type || rideEntry2->ride_type[1] == base_ride_type || rideEntry2->ride_type[2] == base_ride_type) RCT2_ADDRESS(0x001357424, uint32)[i >> 5] |= 1 << (i & 0x1F); } } // I don't think 0x009AC06C is ever not 0, so probably redundant if (RCT2_GLOBAL(0x009AC06C, uint8) == 0) { - RCT2_GLOBAL(0x013CE952, rct_string_id) = rideEntry->var_008 & 0x1000 ? - rideEntry->name : ecx + 2; + RCT2_GLOBAL(0x013CE952, rct_string_id) = rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME ? + rideEntry->name : base_ride_type + 2; if (!gSilentResearch) news_item_add_to_queue(NEWS_ITEM_RESEARCH, 2249, entryIndex); } @@ -292,7 +291,7 @@ void sub_684AC3(){ if ((research + 1)->entryIndex == inner_research->entryIndex){ ebp = inner_research; } - } while ((inner_research++)->entryIndex != -2); + } while ((inner_research++)->entryIndex != RESEARCHED_ITEMS_END); edx->entryIndex = research->entryIndex; ebp->entryIndex = (research + 1)->entryIndex; @@ -352,7 +351,9 @@ void research_remove_non_separate_vehicle_types() researchItem->entryIndex >= 0x10000 ) { rct_ride_type *rideEntry = GET_RIDE_ENTRY(researchItem->entryIndex & 0xFF); - if (!(rideEntry->var_008 & 0x3000)) { + if (!(rideEntry->flags & + (RIDE_ENTRY_FLAG_SEPERATE_RIDE | + RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME))) { // Check if ride type already exists further up for a vehicle type that isn't displayed as a ride researchItem2 = researchItem - 1; do { @@ -361,13 +362,16 @@ void research_remove_non_separate_vehicle_types() researchItem2->entryIndex >= 0x10000 ) { rideEntry = GET_RIDE_ENTRY(researchItem2->entryIndex & 0xFF); - if (!(rideEntry->var_008 & 0x3000)) { + if (!(rideEntry->flags & + (RIDE_ENTRY_FLAG_SEPERATE_RIDE | + RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME))) { + if (((researchItem->entryIndex >> 8) & 0xFF) == ((researchItem2->entryIndex >> 8) & 0xFF)) { // Remove item researchItem2 = researchItem; do { *researchItem2 = *(researchItem2 + 1); - } while ((researchItem2++)->entryIndex != RESEARCHED_ITEMS_END); + } while ((researchItem2++)->entryIndex != RESEARCHED_ITEMS_END_2); goto loopBeginning; } } diff --git a/src/management/research.h b/src/management/research.h index 02dcf714a9..e26725b6db 100644 --- a/src/management/research.h +++ b/src/management/research.h @@ -29,8 +29,16 @@ typedef struct { uint8 category; } rct_research_item; +enum{ + RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED = (1 << 29), + RESEARCH_ENTRY_FLAG_RIDE_ALWAYS_RESEARCHED = (1 << 30), +}; + +// Everything before this point has been researched #define RESEARCHED_ITEMS_SEPERATOR -1 +// Everything before this point and after seperator still requires research #define RESEARCHED_ITEMS_END -2 +// Extra end of list entry. Unsure why? #define RESEARCHED_ITEMS_END_2 -3 enum { diff --git a/src/object.c b/src/object.c index 64414d549f..ca77dfe2c9 100644 --- a/src/object.c +++ b/src/object.c @@ -677,7 +677,7 @@ int paint_ride_entry(int flags, int ebx, int ecx, int edx, rct_drawpixelinfo* dp int di = ride_type->ride_type[0] | (ride_type->ride_type[1] << 8) | (ride_type->ride_type[2] << 16); - if (ride_type->var_008 & 0x1000) di |= 0x1000000; + if (ride_type->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME) di |= 0x1000000; RCT2_GLOBAL(0xF433DD, uint32) = di; return 0;// flags; @@ -755,7 +755,7 @@ int paint_ride_entry(int flags, int ebx, int ecx, int edx, rct_drawpixelinfo* dp int width = w->x + w->width - x - 4; int format_args = ride_type->description; - if (!(ride_type->var_008 & 0x1000)) + if (!(ride_type->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME)) { format_args = ride_type->ride_type[0]; if ((format_args & 0xFF) == 0xFF) diff --git a/src/object_list.c b/src/object_list.c index 9dcbf199d0..4082f7e22f 100644 --- a/src/object_list.c +++ b/src/object_list.c @@ -647,7 +647,7 @@ static uint32 install_object_entry(rct_object_entry* entry, rct_object_entry* in uint8* chunk = RCT2_GLOBAL(RCT2_ADDRESS_CURR_OBJECT_CHUNK_POINTER, uint8*); // Loaded in object_load // When made of two parts i.e Wooden Roller Coaster (Dream Woodie Cars) - if ((objectType == OBJECT_TYPE_RIDE) && !((((rct_ride_type*)chunk)->var_008) & 0x1000)) { + if ((objectType == OBJECT_TYPE_RIDE) && !((((rct_ride_type*)chunk)->flags) & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME)) { rct_ride_type* ride_type = (rct_ride_type*)chunk; rct_string_id obj_string = ride_type->ride_type[0]; if (obj_string == 0xFF){ diff --git a/src/ride/ride.c b/src/ride/ride.c index 031ee4654a..39b4e49e1d 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -1624,7 +1624,7 @@ static int ride_get_new_breakdown_problem(rct_ride *ride) RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RAIN_LEVEL, uint8) == 0 ? 3 : 20; entry = ride_get_entry(ride); - if (entry->var_008 & 0x4000) + if (entry->flags & RIDE_ENTRY_FLAG_14) return -1; availableBreakdownProblems = RideAvailableBreakdowns[ride->type]; @@ -3147,7 +3147,7 @@ void game_command_set_ride_setting(int *eax, int *ebx, int *ecx, int *edx, int * for (int i = 0; i < ride->type; i++) { while (*(available_modes++) != 255) {} } - if (ride_entry->var_008 & (1 << 17)){ + if (ride_entry->flags & RIDE_ENTRY_FLAG_17){ available_modes += 2; } @@ -3160,7 +3160,7 @@ void game_command_set_ride_setting(int *eax, int *ebx, int *ecx, int *edx, int * if (*available_modes == 0xFF) new_value = default_mode; if (available_modes[1] == 0xFF){ - if (ride_entry->var_008 & (1 << 15)) + if (ride_entry->flags & RIDE_ENTRY_FLAG_15) new_value = default_mode; } @@ -3701,14 +3701,14 @@ int ride_is_valid_for_test(int rideIndex, int goingToBeOpen, int isApplying) if (ride->subtype != 255) { rct_ride_type *rideType = GET_RIDE_ENTRY(ride->subtype); - if (rideType->var_008 & 2) { + if (rideType->flags & RIDE_ENTRY_FLAG_1) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN; if (ride_check_track_suitability_a(&trackElement, &problematicTrackElement)) { loc_6B528A(&problematicTrackElement); return 0; } } - if (rideType->var_008 & 4) { + if (rideType->flags & RIDE_ENTRY_FLAG_2) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN; if (ride_check_track_suitability_b(&trackElement, &problematicTrackElement)) { loc_6B528A(&problematicTrackElement); @@ -3830,14 +3830,14 @@ int ride_is_valid_for_open(int rideIndex, int goingToBeOpen, int isApplying) if (ride->subtype != 255) { rct_ride_type *rideType = GET_RIDE_ENTRY(ride->subtype); - if (rideType->var_008 & 2) { + if (rideType->flags & RIDE_ENTRY_FLAG_1) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN; if (ride_check_track_suitability_a(&trackElement, &problematicTrackElement)) { loc_6B528A(&problematicTrackElement); return 0; } } - if (rideType->var_008 & 4) { + if (rideType->flags & RIDE_ENTRY_FLAG_2) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN; if (ride_check_track_suitability_b(&trackElement, &problematicTrackElement)) { loc_6B528A(&problematicTrackElement); diff --git a/src/ride/ride.h b/src/ride/ride.h index d0e8103045..21ef800a64 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -101,7 +101,7 @@ typedef struct { rct_string_id name; // 0x000 rct_string_id description; // 0x002 uint32 images_offset; // 0x004 - uint32 var_008; + uint32 flags; // 0x008 uint8 ride_type[3]; // 0x00C uint8 min_cars_in_train; // 0x00F uint8 max_cars_in_train; // 0x010 @@ -371,6 +371,42 @@ enum { RIDE_LIFECYCLE_CRASHED_WINDOW_OPENED = 1 << 20 }; +// Constants used by the ride_type->flags property at 0x008 +enum { + RIDE_ENTRY_FLAG_0 = 1 << 0, // 0x1 + RIDE_ENTRY_FLAG_1 = 1 << 1, // 0x2 + RIDE_ENTRY_FLAG_2 = 1 << 2, // 0x4 + RIDE_ENTRY_FLAG_3 = 1 << 3, // 0x8 + RIDE_ENTRY_FLAG_4 = 1 << 4, // 0x10 + RIDE_ENTRY_FLAG_5 = 1 << 5, // 0x20 + RIDE_ENTRY_FLAG_6 = 1 << 6, // 0x40 + RIDE_ENTRY_FLAG_7 = 1 << 7, // 0x80 + RIDE_ENTRY_FLAG_8 = 1 << 8, // 0x100 + RIDE_ENTRY_FLAG_9 = 1 << 9, // 0x200 + RIDE_ENTRY_FLAG_COVERED_RIDE = 1 << 10, // 0x400 + RIDE_ENTRY_FLAG_11 = 1 << 11, // 0x800 + RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME = 1 << 12, // 0x1000 + RIDE_ENTRY_FLAG_SEPERATE_RIDE = 1 << 13, // 0x2000 + RIDE_ENTRY_FLAG_14 = 1 << 14, // 0x4000 + RIDE_ENTRY_FLAG_15 = 1 << 15, // 0x8000 + RIDE_ENTRY_FLAG_16 = 1 << 16, // 0x10000 + RIDE_ENTRY_FLAG_17 = 1 << 17, // 0x20000 + RIDE_ENTRY_FLAG_18 = 1 << 18, // 0x40000 + RIDE_ENTRY_FLAG_19 = 1 << 19, // 0x80000 + RIDE_ENTRY_FLAG_20 = 1 << 20, // 0x100000 + RIDE_ENTRY_FLAG_21 = 1 << 21, // 0x200000 + RIDE_ENTRY_FLAG_22 = 1 << 22, // 0x400000 + RIDE_ENTRY_FLAG_23 = 1 << 23, // 0x800000 + RIDE_ENTRY_FLAG_24 = 1 << 24, // 0x1000000 + RIDE_ENTRY_FLAG_25 = 1 << 25, // 0x2000000 + RIDE_ENTRY_FLAG_26 = 1 << 26, // 0x4000000 + RIDE_ENTRY_FLAG_27 = 1 << 27, // 0x8000000 + RIDE_ENTRY_FLAG_28 = 1 << 28, // 0x10000000 + RIDE_ENTRY_FLAG_29 = 1 << 29, // 0x20000000 + RIDE_ENTRY_FLAG_30 = 1 << 30, // 0x40000000 + RIDE_ENTRY_FLAG_31 = 1 << 31, // 0x80000000 +}; + enum { RIDE_TYPE_NULL = 255, RIDE_TYPE_SPIRAL_ROLLER_COASTER = 0, diff --git a/src/ride/ride_ratings.c b/src/ride/ride_ratings.c index 41de6c3e3e..dfe0f87721 100644 --- a/src/ride/ride_ratings.c +++ b/src/ride/ride_ratings.c @@ -535,7 +535,7 @@ static void ride_ratings_apply_adjustments(rct_ride *ride, rating_tuple *ratings uint16 flags = RCT2_GLOBAL(0x0097D4F2 + ride->type * 8, uint16); if (flags & 0x80) { uint16 totalAirTime = ride->total_air_time; - if (rideEntry->var_008 & 0x800) { + if (rideEntry->flags & RIDE_ENTRY_FLAG_11) { if (totalAirTime >= 96) { totalAirTime -= 96; ratings->excitement -= totalAirTime / 8; @@ -608,7 +608,7 @@ static int sub_65E72D(rct_ride *ride) int dh = numShelteredEighths; rct_ride_type *rideType = GET_RIDE_ENTRY(ride->subtype); - if (rideType->var_008 & RIDE_TYPE_FLAG_HAS_DROPS) + if (rideType->flags & RIDE_ENTRY_FLAG_COVERED_RIDE) numShelteredEighths = 7; return (dh << 8) | numShelteredEighths; diff --git a/src/ride/track.c b/src/ride/track.c index 8960ba81bb..c5d28d804f 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -344,7 +344,10 @@ void track_list_populate(ride_list_item item, uint8* track_list_cache){ } else{ if (find_object_in_entry_group(track_object, &entry_type, &entry_index)){ - if (GET_RIDE_ENTRY(entry_index)->var_008 & 0x3000)continue; + if (GET_RIDE_ENTRY(entry_index)->flags & + (RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME | + RIDE_ENTRY_FLAG_SEPERATE_RIDE)) + continue; } else{ uint32* esi = sub_6AB49A(track_object); @@ -393,7 +396,7 @@ void track_load_list(ride_list_item item) if (item.type < 0x80){ rct_ride_type* ride_type = gRideTypeList[item.entry_index]; - if (!(ride_type->var_008 & 0x2000)){ + if (!(ride_type->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE)){ item.entry_index = 0xFF; } } diff --git a/src/windows/editor_inventions_list.c b/src/windows/editor_inventions_list.c index 4e4edfc01f..2e1b5296d8 100644 --- a/src/windows/editor_inventions_list.c +++ b/src/windows/editor_inventions_list.c @@ -158,19 +158,126 @@ rct_research_item *_editorInventionsListDraggedItem; #define WindowHighlightedItem(w) *((rct_research_item**)&(w->var_494)) static void window_editor_inventions_list_drag_open(rct_research_item *researchItem); +static void move_research_item(rct_research_item *beforeItem); static int research_item_is_always_researched(rct_research_item *researchItem) { - return (researchItem->entryIndex & 0x60000000) != 0; + return (researchItem->entryIndex & (RESEARCH_ENTRY_FLAG_RIDE_ALWAYS_RESEARCHED | RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED)) != 0; +} + +/* rct2: 0x0068596F + * Sets rides that are in use to be always researched + */ +static void research_rides_setup(){ + // Reset all objects to not required + for (uint8 object_type = OBJECT_TYPE_RIDE; object_type < 11; object_type++){ + uint8* in_use = RCT2_ADDRESS(0x0098DA38, uint8*)[object_type]; + for (uint8 num_objects = object_entry_group_counts[object_type]; num_objects != 0; num_objects--){ + *in_use++ = 0; + } + } + + // Set research required for rides in use + for (uint16 rideIndex = 0; rideIndex < 255; rideIndex++){ + rct_ride* ride = &g_ride_list[rideIndex]; + if (ride->type == RIDE_TYPE_NULL)continue; + RCT2_ADDRESS(0x0098DA38, uint8*)[OBJECT_TYPE_RIDE][ride->subtype] |= 1; + } + + for (rct_research_item* research = gResearchItems; research->entryIndex != RESEARCHED_ITEMS_END; research++){ + if (research->entryIndex & RESEARCH_ENTRY_FLAG_RIDE_ALWAYS_RESEARCHED) + continue; + + // If not a ride + if ((research->entryIndex & 0xFFFFFF) < 0x10000) + continue; + + uint8 ride_base_type = (research->entryIndex >> 8) & 0xFF; + + uint8 object_index = research->entryIndex & 0xFF; + rct_ride_type* ride_entry = GET_RIDE_ENTRY(object_index); + + uint8 master_found = 0; + if (!(ride_entry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE)){ + + for (uint8 rideType = 0; rideType < object_entry_group_counts[OBJECT_TYPE_RIDE]; rideType++){ + rct_ride_type* master_ride = GET_RIDE_ENTRY(rideType); + if (master_ride == NULL || (uint32)master_ride == 0xFFFFFFFF) + continue; + + if (master_ride->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE) + continue; + + // If master ride not in use + if (!(RCT2_ADDRESS(0x0098DA38, uint8*)[OBJECT_TYPE_RIDE][rideType] & (1 << 0))) + continue; + + if (ride_base_type == master_ride->ride_type[0] || + ride_base_type == master_ride->ride_type[1] || + ride_base_type == master_ride->ride_type[2]){ + master_found = 1; + break; + } + } + } + + if (!master_found){ + // If not in use + if (!(RCT2_ADDRESS(0x0098DA38, uint8*)[OBJECT_TYPE_RIDE][object_index] & (1 << 0))) + continue; + if (ride_base_type != ride_entry->ride_type[0] && + ride_base_type != ride_entry->ride_type[1] && + ride_base_type != ride_entry->ride_type[2]){ + continue; + } + } + + research->entryIndex |= RESEARCH_ENTRY_FLAG_RIDE_ALWAYS_RESEARCHED; + _editorInventionsListDraggedItem = research; + move_research_item(gResearchItems); + _editorInventionsListDraggedItem = NULL; + research--; + } +} + +/* rct2: 0x0068590C + * Sets the critical scenery sets to always researched + */ +static void research_scenery_sets_setup(){ + + for (rct_object_entry* object = RCT2_ADDRESS(0x0098DA74, rct_object_entry); + (object->flags & 0xFF) != 0xFF; + object++){ + + uint8 entry_type, entry_index; + if (!find_object_in_entry_group(object, &entry_type, &entry_index)) + continue; + + if (entry_type != OBJECT_TYPE_SCENERY_SETS) + continue; + + rct_research_item* research = gResearchItems; + for (; research->entryIndex != RESEARCHED_ITEMS_END; research++){ + + if ((research->entryIndex & 0xFFFFFF) != entry_index) + continue; + + research->entryIndex |= RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED; + _editorInventionsListDraggedItem = research; + move_research_item(gResearchItems); + _editorInventionsListDraggedItem = NULL; + } + } } /** * * rct2: 0x00685901 */ -static void sub_685901() +static void research_always_researched_setup() { - RCT2_CALLPROC_EBPSAFE(0x00685901); + research_rides_setup(); + research_scenery_sets_setup(); } /** @@ -183,7 +290,8 @@ static void sub_685A79() research->entryIndex != RESEARCHED_ITEMS_END_2; research++){ - if (research->entryIndex < RESEARCHED_ITEMS_END_2){ + // Clear the always researched flags. + if (research->entryIndex > RESEARCHED_ITEMS_SEPERATOR){ research->entryIndex &= 0x00FFFFFF; } } @@ -210,7 +318,7 @@ static rct_string_id research_item_get_name(uint32 researchItem) if (rideEntry == NULL || rideEntry == (rct_ride_type*)0xFFFFFFFF) return 0; - if (rideEntry->var_008 & 0x1000) + if (rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME) return rideEntry->name; return ((researchItem >> 8) & 0xFF) + 2; @@ -311,7 +419,8 @@ static void move_research_item(rct_research_item *beforeItem) do { *researchItem = *(researchItem + 1); researchItem++; - } while ((researchItem - 1)->entryIndex != RESEARCHED_ITEMS_END); + } while (researchItem->entryIndex != RESEARCHED_ITEMS_END_2); + // At end of this researchItem points to the end of the list if (beforeItem > _editorInventionsListDraggedItem) beforeItem--; @@ -372,13 +481,13 @@ static rct_research_item *window_editor_inventions_list_get_item_from_scroll_y_i researchItem++; } - for (; researchItem->entryIndex != RESEARCHED_ITEMS_END_2; researchItem++) { + for (; researchItem->entryIndex != RESEARCHED_ITEMS_SEPERATOR && researchItem->entryIndex != RESEARCHED_ITEMS_END; researchItem++) { y -= 10; if (y < 0) return researchItem; } - return researchItem - 1; + return researchItem; } static rct_research_item *get_research_item_at(int x, int y) @@ -421,7 +530,7 @@ void window_editor_inventions_list_open() if (w != NULL) return; - sub_685901(); + research_always_researched_setup(); w = window_create_centred( 600, @@ -474,10 +583,12 @@ static void window_editor_inventions_list_mouseup() break; case WIDX_MOVE_ITEMS_TO_TOP: research_items_make_all_researched(); + window_init_scroll_widgets(w); window_invalidate(w); break; case WIDX_MOVE_ITEMS_TO_BOTTOM: research_items_make_all_unresearched(); + window_init_scroll_widgets(w); window_invalidate(w); break; } @@ -687,7 +798,8 @@ static void window_editor_inventions_list_paint() researchItem = _editorInventionsListDraggedItem; if (researchItem == NULL) researchItem = WindowHighlightedItem(w); - if (researchItem == NULL) + // If the research item is null or a list seperator. + if (researchItem == NULL || researchItem->entryIndex < 0) return; // Preview image @@ -754,8 +866,10 @@ static void window_editor_inventions_list_scrollpaint() researchItemEndMarker = RESEARCHED_ITEMS_SEPERATOR; } - itemY = 0; - for (; researchItem->entryIndex != researchItemEndMarker; researchItem++, itemY += 10) { + // Since this is now a do while need to conteract the +10 + itemY = -10; + do{ + itemY += 10; if (itemY + 10 < dpi->y || itemY >= dpi->y + dpi->height) continue; @@ -804,7 +918,7 @@ static void window_editor_inventions_list_scrollpaint() left = 1; top = itemY - 1; gfx_draw_string(dpi, buffer, colour, left, top); - } + }while(researchItem++->entryIndex != researchItemEndMarker); } #pragma region Drag item diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index e37a9470d1..adfbca1e3f 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -317,7 +317,7 @@ static void window_new_ride_populate_list() if (currentCategory != rideEntry->category[0] && currentCategory != rideEntry->category[1]) continue; - if (rideEntry->var_008 & 0x2000) { + if (rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE) { dh &= ~4; nextListItem->type = rideType; nextListItem->entry_index = rideEntryIndex; @@ -785,7 +785,7 @@ static void window_new_ride_paint() uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_ITEM, uint32); if (typeId >= 0x10000) { rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); - stringId = rideEntry->var_008 & 0x1000 ? + stringId = rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME ? rideEntry->name : (typeId & 0xFF00) + 2; } @@ -823,7 +823,7 @@ static void window_new_ride_paint() if (typeId != 0xFFFFFFFF) { if (typeId >= 0x10000) { rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); - stringId = rideEntry->var_008 & 0x1000 ? + stringId = rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME ? rideEntry->name : ((typeId >> 8) & 0xFF) + 2; @@ -942,7 +942,7 @@ static void window_new_ride_paint_ride_information(rct_window *w, rct_drawpixeli // Ride name and description rct_string_id rideName = rideEntry->name; rct_string_id rideDescription = rideEntry->description; - if (!(rideEntry->var_008 & 0x1000)) { + if (!(rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME)) { rideName = item.type + 2; rideDescription = item.type + 512; } diff --git a/src/windows/research.c b/src/windows/research.c index e06ca46dbb..32c5792a6f 100644 --- a/src/windows/research.c +++ b/src/windows/research.c @@ -359,7 +359,7 @@ static void window_research_development_paint() uint32 typeId = RCT2_GLOBAL(RCT2_ADDRESS_NEXT_RESEARCH_ITEM, uint32); if (typeId >= 0x10000) { rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); - stringId = rideEntry->var_008 & 0x1000 ? + stringId = rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME ? rideEntry->name : ((typeId >> 8) & 0xFF) + 2; } @@ -397,7 +397,7 @@ static void window_research_development_paint() if (typeId != 0xFFFFFFFF) { if (typeId >= 0x10000) { rct_ride_type *rideEntry = RCT2_GLOBAL(0x009ACFA4 + (typeId & 0xFF) * 4, rct_ride_type*); - stringId = rideEntry->var_008 & 0x1000 ? + stringId = rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME ? rideEntry->name : ((typeId >> 8) & 0xFF) + 2; diff --git a/src/windows/ride.c b/src/windows/ride.c index c184097530..7a0735031e 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -1028,7 +1028,7 @@ static void window_ride_draw_tab_vehicle(rct_drawpixelinfo *dpi, rct_window *w) RCT2_CALLPROC_X(0x006DE4CD, (ride->num_cars_per_train << 8) | ride->subtype, 0, 0, 0, 0, 0, 0); rideEntry = ride_get_entry(ride); - if (rideEntry->var_008 & 1) { + if (rideEntry->flags & RIDE_ENTRY_FLAG_0) { dpi->zoom_level = 1; dpi->width *= 2; dpi->height *= 2; @@ -1141,7 +1141,7 @@ void window_ride_disable_tabs(rct_window *w) rct_ride_type *type = GET_RIDE_ENTRY(ride->subtype); - if ((type->var_008 & 0x80000) != 0) + if ((type->flags & RIDE_ENTRY_FLAG_19) != 0) disabled_tabs |= (1 << WIDX_TAB_5); // 0x100 w->disabled_widgets = disabled_tabs; @@ -2287,7 +2287,7 @@ static void window_ride_vehicle_mousedown(int widgetIndex, rct_window *w, rct_wi rideEntryIndex = *currentRideEntryIndex; currentRideEntry = GET_RIDE_ENTRY(rideEntryIndex); // Skip if vehicle has the same track type, but not same subtype, unless subtype switching is enabled - if ((currentRideEntry->var_008 & 0x3000) && !gConfigInterface.allow_subtype_switching) + if ((currentRideEntry->flags & (RIDE_ENTRY_FLAG_SEPERATE_RIDE | RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME)) && !gConfigInterface.allow_subtype_switching) continue; quadIndex = rideEntryIndex >> 5; @@ -2448,7 +2448,7 @@ static void window_ride_vehicle_invalidate() // Vehicle type window_ride_vehicle_widgets[WIDX_VEHICLE_TYPE].image = rideEntry->name; // Always show a dropdown button when changing subtypes is allowed - if ((var_496(w) <= 1 || (rideEntry->var_008 & (1 << 13))) && !gConfigInterface.allow_subtype_switching ) { + if ((var_496(w) <= 1 || (rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE)) && !gConfigInterface.allow_subtype_switching) { window_ride_vehicle_widgets[WIDX_VEHICLE_TYPE].type = WWT_14; window_ride_vehicle_widgets[WIDX_VEHICLE_TYPE_DROPDOWN].type = WWT_EMPTY; w->enabled_widgets &= ~(1 << WIDX_VEHICLE_TYPE); @@ -2522,7 +2522,7 @@ static void window_ride_vehicle_paint() gfx_draw_string_left(dpi, 3142, &stringId, 0, x, y); y += 15; - if (!(rideEntry->var_008 & 0x2000) && var_496(w) > 1) { + if (!(rideEntry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE) && var_496(w) > 1) { // Excitement Factor factor = rideEntry->excitement_multipler; if (factor > 0) { @@ -2749,11 +2749,11 @@ static void window_ride_mode_dropdown(rct_window *w, rct_widget *widget) } while (*(mode++) != 255); // ? - if (rideEntry->var_008 & 0x8000) + if (rideEntry->flags & RIDE_ENTRY_FLAG_15) numAvailableModes--; // ? - if (rideEntry->var_008 & 0x20000) { + if (rideEntry->flags & RIDE_ENTRY_FLAG_17) { availableModes += 2; numAvailableModes -= 2; } diff --git a/src/windows/track_list.c b/src/windows/track_list.c index 92d4546a5f..77228d4252 100644 --- a/src/windows/track_list.c +++ b/src/windows/track_list.c @@ -349,7 +349,7 @@ static void window_track_list_invalidate() entry = GET_RIDE_ENTRY(_window_track_list_item.entry_index); stringId = entry->name; - if (!(entry->var_008 & 0x1000)) + if (!(entry->flags & RIDE_ENTRY_FLAG_SEPERATE_RIDE_NAME)) stringId = _window_track_list_item.type + 2; RCT2_GLOBAL(0x013CE952, uint16) = stringId;