1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 03:53:07 +01:00

Merge pull request #1343 from LRFLEW/develop

Some Cleanup of Past PRs
This commit is contained in:
Ted John
2015-06-14 23:43:53 +01:00
6 changed files with 18 additions and 20 deletions

View File

@@ -3619,7 +3619,7 @@ STR_5282 :RCT1 Ride Open/Close Lights
STR_5283 :RCT1 Park Open/Close Lights
STR_5284 :RCT1 Scenario Selection Font
STR_5285 :EXPLODE!!!
STR_5286 :{MEDIUMFONT}{BLACK}Makes guests explode
STR_5286 :{MEDIUMFONT}{BLACK}Makes some guests explode
STR_5287 :Ride is already broken down
STR_5288 :Ride is closed
STR_5289 :No breakdowns available for this ride

View File

@@ -187,14 +187,7 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx,
}
if (count > 0) {
uint32 max = ((uint32)0xFFFFFFFF) - (((uint32)0xFFFFFFFF) % count) - 1;
if (max + count == 0) max = ((uint32)0xFFFFFFFF);
uint32 rand;
do {
rand = scenario_rand();
} while (rand > max);
rand %= count;
uint32 rand = scenario_rand_max(count);
for (i = 0; i < 4; ++i) {
if (RCT2_ADDRESS(RCT2_ADDRESS_PARK_ENTRANCE_X, uint16)[i] != SPRITE_LOCATION_NULL) {
if (rand == 0) break;
@@ -215,14 +208,7 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx,
z = newPeep->z;
}
} else {
uint32 max = ((uint32)0xFFFFFFFF) - (((uint32)0xFFFFFFFF) % count) - 1;
if (max + count == 0) max = ((uint32)0xFFFFFFFF);
uint32 rand;
do {
rand = scenario_rand();
} while (rand > max);
rand %= count;
uint32 rand = scenario_rand_max(count);
FOR_ALL_GUESTS(sprite_index, guest)
if (guest->state == PEEP_STATE_WALKING) {
if (rand == 0) break;

View File

@@ -648,6 +648,18 @@ unsigned int scenario_rand()
return RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_1, uint32) = ror32(eax, 3);
}
unsigned int scenario_rand_max(unsigned int max)
{
if (max < 2) return 0;
if ((max & (max - 1)) == 0)
return scenario_rand() & (max - 1);
unsigned int rand, cap = ~((unsigned int)0) - (~((unsigned int)0) % max) - 1;
do {
rand = scenario_rand();
} while (rand > cap);
return rand % max;
}
/**
* Prepare rides, for the finish five rollercoasters objective.
* rct2: 0x006788F7

View File

@@ -411,6 +411,7 @@ int scenario_load_and_play(const rct_scenario_basic *scenario);
int scenario_load_and_play_from_path(const char *path);
void scenario_update();
unsigned int scenario_rand();
unsigned int scenario_rand_max(unsigned int max);
int scenario_prepare_for_save();
int scenario_save(char *path, int flags);
void scenario_set_filename(const char *value);

View File

@@ -158,4 +158,4 @@ int strcicmp(char const *a, char const *b)
bool utf8_is_bom(const char *str)
{
return str[0] == 0xEF && str[1] == 0xBB && str[2] == 0xBF;
}
}

View File

@@ -538,8 +538,7 @@ static void cheat_explode_guests()
rct_peep *peep;
FOR_ALL_GUESTS(sprite_index, peep) {
unsigned int rand = scenario_rand();
if ((rand & 0x07) == 0) {
if (scenario_rand_max(6) == 0) {
peep->flags |= PEEP_FLAGS_EXPLODE;
}
}