mirror of https://github.com/OpenRCT2/OpenRCT2.git
add desync debug checks for scenario_rand
This commit is contained in:
parent
366e5ced03
commit
c7a85c5114
|
@ -366,7 +366,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<StructMemberAlignment>1Byte</StructMemberAlignment>
|
||||
<PreprocessorDefinitions>DEBUG;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>DEBUG;DEBUG_DESYNC;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<ObjectFileName>$(IntDir)fake\%(RelativeDir)</ObjectFileName>
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
|
||||
int gGameSpeed = 1;
|
||||
float gDayNightCycle = 0;
|
||||
bool gInUpdateCode = false;
|
||||
|
||||
GAME_COMMAND_CALLBACK_POINTER* game_command_callback = 0;
|
||||
GAME_COMMAND_CALLBACK_POINTER* game_command_callback_table[] = {
|
||||
|
@ -335,6 +336,9 @@ void game_update()
|
|||
|
||||
void game_logic_update()
|
||||
{
|
||||
///////////////////////////
|
||||
gInUpdateCode = true;
|
||||
///////////////////////////
|
||||
network_update();
|
||||
if (network_get_mode() == NETWORK_MODE_CLIENT && network_get_status() == NETWORK_STATUS_CONNECTED) {
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) >= network_get_server_tick()) {
|
||||
|
@ -361,6 +365,10 @@ void game_logic_update()
|
|||
research_update();
|
||||
ride_ratings_update_all();
|
||||
ride_measurements_update();
|
||||
///////////////////////////
|
||||
gInUpdateCode = false;
|
||||
///////////////////////////
|
||||
|
||||
map_animation_invalidate_all();
|
||||
vehicle_sounds_update();
|
||||
peep_update_crowd_noise();
|
||||
|
|
|
@ -114,6 +114,7 @@ GAME_COMMAND_CALLBACK_POINTER* game_command_callback_get_callback(int index);
|
|||
|
||||
extern int gGameSpeed;
|
||||
extern float gDayNightCycle;
|
||||
extern bool gInUpdateCode;
|
||||
|
||||
void game_increase_game_speed();
|
||||
void game_reduce_game_speed();
|
||||
|
|
|
@ -715,6 +715,13 @@ static int scenario_create_ducks()
|
|||
*/
|
||||
unsigned int scenario_rand()
|
||||
{
|
||||
#if DEBUG_DESYNC
|
||||
if (!gInUpdateCode) {
|
||||
log_warning("scenario_rand called from outside game update");
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
int eax = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_0, uint32);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_0, uint32) += ror32(RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_1, uint32) ^ 0x1234567F, 7);
|
||||
return RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_1, uint32) = ror32(eax, 3);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "../audio/mixer.h"
|
||||
#include "../config.h"
|
||||
#include "../drawing/drawing.h"
|
||||
#include "../game.h"
|
||||
#include "../localisation/date.h"
|
||||
#include "../scenario.h"
|
||||
#include "../interface/window.h"
|
||||
|
@ -69,7 +70,7 @@ static unsigned int _thunderSoundId;
|
|||
static int _thunderVolume;
|
||||
static int _thunderStereoEcho = 0;
|
||||
|
||||
static void climate_determine_future_weather();
|
||||
static void climate_determine_future_weather(int randomDistribution);
|
||||
|
||||
static void climate_update_rain_sound();
|
||||
static void climate_update_thunder_sound();
|
||||
|
@ -114,7 +115,7 @@ void climate_reset(int climate)
|
|||
_rainVolume = 1;
|
||||
}
|
||||
|
||||
climate_determine_future_weather();
|
||||
climate_determine_future_weather(rand());
|
||||
}
|
||||
|
||||
sint8 step_weather_level(sint8 cur_weather_level, sint8 next_weather_level) {
|
||||
|
@ -171,7 +172,7 @@ void climate_update()
|
|||
|
||||
if (cur_rain == next_rain) {
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) = gClimateNextWeather;
|
||||
climate_determine_future_weather();
|
||||
climate_determine_future_weather(scenario_rand());
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_BTM_TOOLBAR_DIRTY_FLAGS, uint32) |= BTM_TB_DIRTY_FLAG_CLIMATE;
|
||||
} else if (next_rain <= 2) { // Safe-guard
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_RAIN_LEVEL, sint8) = step_weather_level(cur_rain, next_rain);
|
||||
|
@ -209,7 +210,7 @@ void climate_force_weather(uint8 weather){
|
|||
*
|
||||
* rct2: 0x006C461C
|
||||
*/
|
||||
static void climate_determine_future_weather()
|
||||
static void climate_determine_future_weather(int randomDistribution)
|
||||
{
|
||||
sint8 climate = RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, sint8);
|
||||
const rct_weather_transition* climate_table = climate_transitions[climate];
|
||||
|
@ -217,7 +218,7 @@ static void climate_determine_future_weather()
|
|||
rct_weather_transition transition = climate_table[month];
|
||||
|
||||
// Generate a random variable with values 0 upto distribution_size-1 and chose weather from the distribution table accordingly
|
||||
sint8 next_weather = transition.distribution[ ((scenario_rand() & 0xFF) * transition.distribution_size) >> 8 ];
|
||||
sint8 next_weather = transition.distribution[ ((randomDistribution & 0xFF) * transition.distribution_size) >> 8 ];
|
||||
gClimateNextWeather = next_weather;
|
||||
|
||||
_climateNextTemperature = transition.base_temperature + climate_weather_data[next_weather].temp_delta;
|
||||
|
|
Loading…
Reference in New Issue