/** * * rct2: 0x00685675 */ void research_populate_list_random() { research_reset_items(); // Rides for (int32_t i = 0; i < MAX_RIDE_OBJECTS; i++) { rct_ride_entry* rideEntry = get_ride_entry(i); if (rideEntry == nullptr) { continue; } int32_t researched = (scenario_rand() & 0xFF) > 128; for (auto rideType : rideEntry->ride_type) { if (rideType != RIDE_TYPE_NULL) { research_insert(researched, RESEARCH_ENTRY_RIDE_MASK | (rideType << 8) | i, rideEntry->category[0]); } } } // Scenery for (int32_t i = 0; i < MAX_SCENERY_GROUP_OBJECTS; i++) { rct_scenery_group_entry* sceneryGroupEntry = get_scenery_group_entry(i); if (sceneryGroupEntry == nullptr) { continue; } int32_t researched = (scenario_rand() & 0xFF) > 85; research_insert(researched, i, RESEARCH_CATEGORY_SCENERY_GROUP); } }
void research_process_random_items() { rct_research_item* research = gResearchItems; for (; research->rawValue != RESEARCHED_ITEMS_END; research++) { } research++; for (; research->rawValue != RESEARCHED_ITEMS_END_2; research += 2) { if (scenario_rand() & 1) { continue; } rct_research_item* edx = nullptr; rct_research_item* ebp = nullptr; rct_research_item* inner_research = gResearchItems; do { if (research->rawValue == inner_research->rawValue) { edx = inner_research; } if ((research + 1)->rawValue == inner_research->rawValue) { ebp = inner_research; } } while ((inner_research++)->rawValue != RESEARCHED_ITEMS_END); assert(edx != nullptr); edx->rawValue = research->rawValue; assert(ebp != nullptr); ebp->rawValue = (research + 1)->rawValue; uint8_t cat = edx->category; edx->category = ebp->category; ebp->category = cat; } }
/** * Set climate and determine start weather. */ void climate_reset(sint32 climate) { uint8 weather = WEATHER_PARTIALLY_CLOUDY; sint32 month = date_get_month(gDateMonthsElapsed); const WeatherTransition * transition = &ClimateTransitions[climate][month]; const WeatherState * weatherState = &ClimateWeatherData[weather]; gClimate = climate; gClimateCurrent.Weather = weather; gClimateCurrent.Temperature = transition->BaseTemperature + weatherState->TemperatureDelta; gClimateCurrent.WeatherEffect = weatherState->EffectLevel; gClimateCurrent.WeatherGloom = weatherState->GloomLevel; gClimateCurrent.RainLevel = weatherState->RainLevel; _lightningTimer = 0; _thunderTimer = 0; if (_rainVolume != 1) { audio_stop_rain_sound(); _rainVolume = 1; } climate_determine_future_weather(scenario_rand()); }
/** * Weather & climate update iteration. * Gradually changes the weather parameters towards their determined next values. */ void climate_update() { // Only do climate logic if playing (not in scenario editor or title screen) if (gScreenFlags & (~SCREEN_FLAGS_PLAYING)) return; if (!gCheatsFreezeClimate) { if (gClimateUpdateTimer) { if (gClimateUpdateTimer == 960) { auto intent = Intent(INTENT_ACTION_UPDATE_CLIMATE); context_broadcast_intent(&intent); } gClimateUpdateTimer--; } else if (!(gCurrentTicks & 0x7F)) { if (gClimateCurrent.Temperature == gClimateNext.Temperature) { if (gClimateCurrent.WeatherGloom == gClimateNext.WeatherGloom) { gClimateCurrent.WeatherEffect = gClimateNext.WeatherEffect; _thunderTimer = 0; _lightningTimer = 0; if (gClimateCurrent.RainLevel == gClimateNext.RainLevel) { gClimateCurrent.Weather = gClimateNext.Weather; climate_determine_future_weather(scenario_rand()); auto intent = Intent(INTENT_ACTION_UPDATE_CLIMATE); context_broadcast_intent(&intent); } else if (gClimateNext.RainLevel <= RAIN_LEVEL_HEAVY) { gClimateCurrent.RainLevel = climate_step_weather_level(gClimateCurrent.RainLevel, gClimateNext.RainLevel); } } else { gClimateCurrent.WeatherGloom = climate_step_weather_level(gClimateCurrent.WeatherGloom, gClimateNext.WeatherGloom); gfx_invalidate_screen(); } } else { gClimateCurrent.Temperature = climate_step_weather_level(gClimateCurrent.Temperature, gClimateNext.Temperature); auto intent = Intent(INTENT_ACTION_UPDATE_CLIMATE); context_broadcast_intent(&intent); } } } if (_thunderTimer != 0) { climate_update_lightning(); climate_update_thunder(); } else if (gClimateCurrent.WeatherEffect == WEATHER_EFFECT_STORM) { // Create new thunder and lightning uint32 randomNumber = util_rand(); if ((randomNumber & 0xFFFF) <= 0x1B4) { randomNumber >>= 16; _thunderTimer = 43 + (randomNumber % 64); _lightningTimer = randomNumber % 32; }
/** * * rct2: 0x00673DBA (water) * rct2: 0x00673F51 (snow) */ void jumping_fountain_begin(int type, int x, int y, rct_map_element *mapElement) { int i, randomIndex; int z = mapElement->base_height * 8; // Change pattern approximately every 51 seconds int pattern = (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) >> 11) & 7; switch (pattern) { case PATTERN_CYCLIC_SQUARES: // 0, 1, 2, 3 for (i = 0; i < 4; i++) { jumping_fountain_create( type, x + dword_97F020[i].x, y + dword_97F020[i].y, z, _fountainDirections[i], _fountainDirectionFlags[i] | _fountainPatternFlags[pattern], 0 ); } break; case PATTERN_BOUNCING_PAIRS: // random [0, 2 or 1, 3] randomIndex = scenario_rand() & 1; for (i = randomIndex; i < 4; i += 2) { jumping_fountain_create( type, x + dword_97F020[i].x, y + dword_97F020[i].y, z, _fountainDirections[i], _fountainDirectionFlags[i] | _fountainPatternFlags[pattern], 0 ); } break; case PATTERN_RACING_PAIRS: // random [0 - 3 and 4 - 7] z = mapElement->base_height * 8; randomIndex = scenario_rand() & 3; jumping_fountain_create( type, x + dword_97F020[randomIndex].x, y + dword_97F020[randomIndex].y, z, _fountainDirections[randomIndex], _fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0 ); randomIndex += 4; jumping_fountain_create( type, x + dword_97F020[randomIndex].x, y + dword_97F020[randomIndex].y, z, _fountainDirections[randomIndex], _fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0 ); break; default: // random [0 - 7] randomIndex = scenario_rand() & 7; jumping_fountain_create( type, x + dword_97F020[randomIndex].x, y + dword_97F020[randomIndex].y, z, _fountainDirections[randomIndex], _fountainDirectionFlags[randomIndex] | _fountainPatternFlags[pattern], 0 ); break; } }