Skip to content

Commit

Permalink
Merge pull request #2605 from OpenRCT2/vehicle-update
Browse files Browse the repository at this point in the history
Vehicle Update
  • Loading branch information
duncanspumpkin committed Jan 10, 2016
2 parents 052254c + b16337a commit 8997f2a
Show file tree
Hide file tree
Showing 28 changed files with 9,236 additions and 545 deletions.
6 changes: 6 additions & 0 deletions OpenRCT2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
D43532601C34730200BA219B /* libpng.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D435325E1C3472E500BA219B /* libpng.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
D46105CE1C38828D00DB1EE3 /* scenario_sources.c in Sources */ = {isa = PBXBuildFile; fileRef = D46105CD1C38828D00DB1EE3 /* scenario_sources.c */; };
D4ABAB061C2F812B0080CAD9 /* news_options.c in Sources */ = {isa = PBXBuildFile; fileRef = D4ABAB051C2F812B0080CAD9 /* news_options.c */; };
D4B85B5B1C41C7F3005C568A /* cable_lift.c in Sources */ = {isa = PBXBuildFile; fileRef = D4B85B591C41C7F3005C568A /* cable_lift.c */; };
D4B8C2A81C41EADF00B006AC /* argparse.c in Sources */ = {isa = PBXBuildFile; fileRef = D4B8C2A61C41EADF00B006AC /* argparse.c */; };
D4D4DF141C34697B0048BE43 /* image_io.c in Sources */ = {isa = PBXBuildFile; fileRef = D4D4DF121C34697B0048BE43 /* image_io.c */; };
D4EC47DF1C26342F0024B507 /* addresses.c in Sources */ = {isa = PBXBuildFile; fileRef = D4EC46D61C26342F0024B507 /* addresses.c */; };
Expand Down Expand Up @@ -221,6 +222,8 @@
D4895D321C23EFDD000CD788 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = distribution/osx/Info.plist; sourceTree = SOURCE_ROOT; };
D497D0781C20FD52002BF46A /* OpenRCT2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OpenRCT2.app; sourceTree = BUILT_PRODUCTS_DIR; };
D4ABAB051C2F812B0080CAD9 /* news_options.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = news_options.c; sourceTree = "<group>"; };
D4B85B591C41C7F3005C568A /* cable_lift.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cable_lift.c; sourceTree = "<group>"; };
D4B85B5A1C41C7F3005C568A /* cable_lift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cable_lift.h; sourceTree = "<group>"; };
D4B8C2A61C41EADF00B006AC /* argparse.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = argparse.c; sourceTree = "<group>"; };
D4B8C2A71C41EADF00B006AC /* argparse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = argparse.h; sourceTree = "<group>"; };
D4D4DF121C34697B0048BE43 /* image_io.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = image_io.c; path = src/image_io.c; sourceTree = "<group>"; };
Expand Down Expand Up @@ -856,6 +859,8 @@
D4EC475C1C26342F0024B507 /* ride */ = {
isa = PBXGroup;
children = (
D4B85B591C41C7F3005C568A /* cable_lift.c */,
D4B85B5A1C41C7F3005C568A /* cable_lift.h */,
D4EC475D1C26342F0024B507 /* ride.c */,
D4EC475E1C26342F0024B507 /* ride.h */,
D4EC475F1C26342F0024B507 /* ride_data.c */,
Expand Down Expand Up @@ -1425,6 +1430,7 @@
D4EC48111C26342F0024B507 /* network.cpp in Sources */,
D4EC47FF1C26342F0024B507 /* widget.c in Sources */,
D4EC48691C26342F0024B507 /* title_options.c in Sources */,
D4B85B5B1C41C7F3005C568A /* cable_lift.c in Sources */,
D4EC48471C26342F0024B507 /* map_tooltip.c in Sources */,
D4EC483F1C26342F0024B507 /* guest.c in Sources */,
D4EC487A1C26342F0024B507 /* map_helpers.c in Sources */,
Expand Down
4 changes: 3 additions & 1 deletion openrct2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<ClCompile Include="src\platform\windows.c" />
<ClCompile Include="src\rct1.c" />
<ClCompile Include="src\rct2.c" />
<ClCompile Include="src\ride\cable_lift.c" />
<ClCompile Include="src\ride\ride.c" />
<ClCompile Include="src\ride\ride_data.c" />
<ClCompile Include="src\ride\ride_ratings.c" />
Expand Down Expand Up @@ -247,6 +248,7 @@
<ClInclude Include="src\platform\platform.h" />
<ClInclude Include="src\rct1.h" />
<ClInclude Include="src\rct2.h" />
<ClInclude Include="src\ride\cable_lift.h" />
<ClInclude Include="src\ride\ride.h" />
<ClInclude Include="src\ride\ride_data.h" />
<ClInclude Include="src\ride\ride_ratings.h" />
Expand Down Expand Up @@ -370,4 +372,4 @@
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>
</Project>
13 changes: 11 additions & 2 deletions openrct2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,11 @@
<ClCompile Include="src\addresses.c">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="src\ride\cable_lift.c">
<Filter>Source\Ride</Filter>
</ClCompile>
<ClCompile Include="src\drawing\supports.c">
<Filter>Source</Filter>
<Filter>Source\Drawing</Filter>
</ClCompile>
<ClCompile Include="src\windows\news_options.c">
<Filter>Source\Windows</Filter>
Expand Down Expand Up @@ -830,6 +833,12 @@
<ClInclude Include="src\interface\colour.h">
<Filter>Source\Interface</Filter>
</ClInclude>
<ClInclude Include="src\ride\cable_lift.h">
<Filter>Source\Ride</Filter>
</ClInclude>
<ClInclude Include="src\core\Util.hpp">
<Filter>Source\Core</Filter>
</ClInclude>
<ClInclude Include="src\drawing\supports.h">
<Filter>Source\Drawing</Filter>
</ClInclude>
Expand All @@ -852,4 +861,4 @@
<Filter>Source\argparse</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions src/audio/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ void* Mixer_Play_Effect(size_t id, int loop, int volume, float pan, double rate,
return 0;
}
if (id >= Util::CountOf(gMixer.css1sources)) {
log_error("Tried to play an invalid sound id. %i", id);
return 0;
}
gMixer.Lock();
Expand Down
4 changes: 2 additions & 2 deletions src/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ void hookfunc(int address, int newaddress, int stacksize, int registerargs[], in
data[i++] = 0x89; //mov eax, esp
data[i++] = 0xE0;
data[i++] = 0x83; //sub eax, (0xC + numargs*4) & 0xF
data[i++] = 0xE8;
data[i++] = 0xE8;
data[i++] = (0xC + numrargs * 4) & 0xF;
data[i++] = 0x83; //and eax, 0xC
data[i++] = 0xE0;
data[i++] = 0x0C;
data[i++] = 0xA3; //mov [0x9ABDA8], eax
data[i++] = 0xA8;
data[i++] = 0xBD;
data[i++] = 0x9A;
data[i++] = 0x9A;
data[i++] = 0x00;
data[i++] = 0x58; //pop eax
data[i++] = 0x2B; //sub esp, [0x9ABDA8]
Expand Down
33 changes: 19 additions & 14 deletions src/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,14 @@ static bool object_type_ride_load(void *objectEntry, uint32 entryIndex)

if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_FLAT) {
int al = 1;
if (vehicleEntry->var_14 & 2) {
if (vehicleEntry->flags_b & VEHICLE_ENTRY_FLAG_B_SWINGING) {
al = 13;
if ((vehicleEntry->var_14 & 0x820) != 0x820) {
if ((vehicleEntry->flags_b & (VEHICLE_ENTRY_FLAG_B_5 | VEHICLE_ENTRY_FLAG_B_11)) != (VEHICLE_ENTRY_FLAG_B_5 | VEHICLE_ENTRY_FLAG_B_11)) {
al = 7;
if (!(vehicleEntry->var_14 & 0x20)) {
if (!(vehicleEntry->var_14 & 0x800)) {
if (!(vehicleEntry->flags_b & VEHICLE_ENTRY_FLAG_B_5)) {
if (!(vehicleEntry->flags_b & VEHICLE_ENTRY_FLAG_B_11)) {
al = 5;
if (vehicleEntry->var_14 & 0x200) {
if (vehicleEntry->flags_b & VEHICLE_ENTRY_FLAG_B_9) {
al = 3;
}
}
Expand All @@ -519,18 +519,18 @@ static bool object_type_ride_load(void *objectEntry, uint32 entryIndex)
// 0x6DE90B

al = 0x20;
if (!(vehicleEntry->var_12 & 0x4000)) {
if (!(vehicleEntry->flags_a & VEHICLE_ENTRY_FLAG_A_14)) {
al = 1;
if (vehicleEntry->var_14 & 0x80) {
if (vehicleEntry->flags_b & VEHICLE_ENTRY_FLAG_B_7) {
if (vehicleEntry->var_11 != 6) {
al = 2;
if (!(vehicleEntry->var_12 & 0x80)) {
if (!(vehicleEntry->flags_a & VEHICLE_ENTRY_FLAG_A_7)) {
al = 4;
}
}
}
}
if (vehicleEntry->var_12 & 0x1000) {
if (vehicleEntry->flags_a & VEHICLE_ENTRY_FLAG_A_12) {
al = vehicleEntry->special_frames;
}
vehicleEntry->var_02 = al;
Expand All @@ -543,7 +543,7 @@ static bool object_type_ride_load(void *objectEntry, uint32 entryIndex)
if (vehicleEntry->car_visual != VEHICLE_VISUAL_RIVER_RAPIDS) {
int b = vehicleEntry->var_16 * 32;

if (vehicleEntry->var_12 & 0x800) b /= 2;
if (vehicleEntry->flags_a & VEHICLE_ENTRY_FLAG_A_11) b /= 2;
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_15) b /= 8;

image_index += b;
Expand All @@ -552,7 +552,7 @@ static bool object_type_ride_load(void *objectEntry, uint32 entryIndex)
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_GENTLE_SLOPES) {
vehicleEntry->var_20 = image_index;
b = vehicleEntry->var_16 * 72;
if (vehicleEntry->var_12 & 0x4000)
if (vehicleEntry->flags_a & VEHICLE_ENTRY_FLAG_A_14)
b = vehicleEntry->var_16 * 16;

image_index += b;
Expand All @@ -564,12 +564,14 @@ static bool object_type_ride_load(void *objectEntry, uint32 entryIndex)
b = vehicleEntry->var_16 * 80;
image_index += b;
}

// Verticle
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES) {
vehicleEntry->var_28 = image_index;
b = vehicleEntry->var_16 * 116;
image_index += b;
}

// Unknown
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_DIAGONAL_SLOPES) {
vehicleEntry->var_2C = image_index;
Expand All @@ -596,12 +598,14 @@ static bool object_type_ride_load(void *objectEntry, uint32 entryIndex)
b = vehicleEntry->var_16 * 128;
image_index += b;
}

// Unknown
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_DIAGONAL_GENTLE_SLOPE_BANKED_TRANSITIONS) {
vehicleEntry->var_3C = image_index;
b = vehicleEntry->var_16 * 16;
image_index += b;
}

// Unknown
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_GENTLE_SLOPE_BANKED_TRANSITIONS) {
vehicleEntry->var_40 = image_index;
Expand All @@ -626,6 +630,7 @@ static bool object_type_ride_load(void *objectEntry, uint32 entryIndex)
b = vehicleEntry->var_16 * 80;
image_index += b;
}

// Unknown
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_RESTRAINT_ANIMATION) {
vehicleEntry->var_1C = image_index;
Expand All @@ -649,9 +654,9 @@ static bool object_type_ride_load(void *objectEntry, uint32 entryIndex)
cur_vehicle_images_offset = image_index + vehicleEntry->no_seating_rows * vehicleEntry->no_vehicle_images;
// 0x6DEB0D

if (!(vehicleEntry->var_12 & 0x400)) {
if (!(vehicleEntry->flags_a & VEHICLE_ENTRY_FLAG_A_10)) {
int num_images = cur_vehicle_images_offset - vehicleEntry->base_image_id;
if (vehicleEntry->var_12 & 0x2000) {
if (vehicleEntry->flags_a & VEHICLE_ENTRY_FLAG_A_13) {
num_images *= 2;
}

Expand Down Expand Up @@ -734,7 +739,7 @@ static void object_type_ride_unload(void *objectEntry)
rideVehicleEntry->no_vehicle_images = 0;
rideVehicleEntry->var_16 = 0;

if (!(rideVehicleEntry->var_12 & 0x400)) {
if (!(rideVehicleEntry->flags_a & VEHICLE_ENTRY_FLAG_A_10)) {
rideVehicleEntry->sprite_width = 0;
rideVehicleEntry->sprite_height_negative = 0;
rideVehicleEntry->sprite_height_positive = 0;
Expand Down
36 changes: 18 additions & 18 deletions src/peep/peep.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "../world/footpath.h"
#include "../management/marketing.h"
#include "../game.h"
#include "../ride/track.h"
#include "peep.h"
#include "staff.h"

Expand Down Expand Up @@ -1657,8 +1658,8 @@ static void peep_go_to_ride_entrance(rct_peep* peep, rct_ride* ride){

uint8 shift_multiplier = 21;
rct_ride_type* ride_type = GET_RIDE_ENTRY(ride->subtype);
if (ride_type->vehicles[ride_type->default_vehicle].var_12 & (1 << 3) ||
ride_type->vehicles[ride_type->default_vehicle].var_14 & 0x5000){
if (ride_type->vehicles[ride_type->default_vehicle].flags_a & VEHICLE_ENTRY_FLAG_A_3 ||
ride_type->vehicles[ride_type->default_vehicle].flags_b & (VEHICLE_ENTRY_FLAG_B_12 | VEHICLE_ENTRY_FLAG_B_14)){
shift_multiplier = 32;
}

Expand Down Expand Up @@ -1736,7 +1737,7 @@ static void peep_update_ride_sub_state_0(rct_peep* peep){
}
}
else{
chosen_train = ride->var_066[peep->current_ride_station];
chosen_train = ride->train_at_station[peep->current_ride_station];
}
if (chosen_train == 0xFF){
return;
Expand Down Expand Up @@ -1862,8 +1863,8 @@ void peep_update_ride_sub_state_1(rct_peep* peep){
{
uint8 vehicle = ride_entry->default_vehicle;

if (ride_entry->vehicles[vehicle].var_12 & (1 << 3) ||
ride_entry->vehicles[vehicle].var_14 & ((1 << 14) | (1<<12)))
if (ride_entry->vehicles[vehicle].flags_a & VEHICLE_ENTRY_FLAG_A_3 ||
ride_entry->vehicles[vehicle].flags_b & (VEHICLE_ENTRY_FLAG_B_12 | VEHICLE_ENTRY_FLAG_B_14))
RCT2_GLOBAL(0xF1AECA, uint16) = 0x1C;
else
RCT2_GLOBAL(0xF1AECA, uint16) = 0x10;
Expand Down Expand Up @@ -1964,7 +1965,7 @@ void peep_update_ride_sub_state_1(rct_peep* peep){
ride_entry = GET_RIDE_ENTRY(vehicle->ride_subtype);
rct_ride_type_vehicle* vehicle_type = &ride_entry->vehicles[vehicle->vehicle_type];

if (vehicle_type->var_14 & (1 << 10)){
if (vehicle_type->flags_b & VEHICLE_ENTRY_FLAG_B_10){
sint16 x, y, z;
x = ride->entrances[peep->current_ride_station] & 0xFF;
y = ride->entrances[peep->current_ride_station] >> 8;
Expand Down Expand Up @@ -2021,7 +2022,7 @@ void peep_update_ride_sub_state_1(rct_peep* peep){
return;
}

if (vehicle_type->var_14 & (1 << 15)){
if (vehicle_type->flags_b & VEHICLE_ENTRY_FLAG_B_15){
peep->destination_x = vehicle->x;
peep->destination_y = vehicle->y;
peep->destination_tolerence = 15;
Expand Down Expand Up @@ -2074,8 +2075,8 @@ static void peep_go_to_ride_exit(rct_peep* peep, rct_ride* ride, sint16 x, sint1

rct_ride_type* ride_type = GET_RIDE_ENTRY(ride->subtype);
rct_ride_type_vehicle* vehicle_entry = &ride_type->vehicles[ride_type->default_vehicle];
if (vehicle_entry->var_12 & (1 << 3) ||
vehicle_entry->var_14 & 0x5000){
if (vehicle_entry->flags_a & VEHICLE_ENTRY_FLAG_A_3 ||
vehicle_entry->flags_b & (VEHICLE_ENTRY_FLAG_B_12 | VEHICLE_ENTRY_FLAG_B_14)){
shift_multiplier = 32;
}

Expand Down Expand Up @@ -2226,7 +2227,7 @@ static void peep_update_ride_sub_state_2(rct_peep* peep){

rct_ride_type* ride_entry = GET_RIDE_ENTRY(vehicle->ride_subtype);

if (ride_entry->vehicles[0].var_12 & (1 << 3)){
if (ride_entry->vehicles[0].flags_a & VEHICLE_ENTRY_FLAG_A_3){
vehicle->var_D5 &= ~(1 << 5);


Expand Down Expand Up @@ -2272,8 +2273,7 @@ static void peep_update_ride_sub_state_2(rct_peep* peep){
rct_vehicle *currentTrain = GET_VEHICLE(ride->vehicles[peep->current_train]);
if (ride->status == RIDE_STATUS_OPEN &&
++peep->var_AC != 0 &&
!(vehicle->update_flags & VEHICLE_UPDATE_FLAG_TRAIN_READY_DEPART)
) {
!(currentTrain->update_flags & VEHICLE_UPDATE_FLAG_TRAIN_READY_DEPART)){
return;
}

Expand Down Expand Up @@ -2378,7 +2378,7 @@ void peep_update_ride_sub_state_7(rct_peep* peep){
rct_ride_type* ride_entry = GET_RIDE_ENTRY(vehicle->ride_subtype);
rct_ride_type_vehicle* vehicle_entry = &ride_entry->vehicles[vehicle->vehicle_type];

if (!(vehicle_entry->var_14 & (1 << 10))){
if (!(vehicle_entry->flags_b & VEHICLE_ENTRY_FLAG_B_10)){
sint16 x, y, z;
x = ride->exits[peep->current_ride_station] & 0xFF;
y = ride->exits[peep->current_ride_station] >> 8;
Expand All @@ -2393,7 +2393,7 @@ void peep_update_ride_sub_state_7(rct_peep* peep){

for (; vehicle->is_child; vehicle = GET_VEHICLE(vehicle->prev_vehicle_on_ride)){
uint16 trackType = vehicle->track_type >> 2;
if (trackType == 0 || trackType > 3)
if (trackType == TRACK_ELEM_FLAT || trackType > TRACK_ELEM_MIDDLE_STATION)
continue;

rct_map_element* inner_map = map_get_first_element_at(vehicle->track_x / 32, vehicle->track_y / 32);
Expand All @@ -2413,12 +2413,12 @@ void peep_update_ride_sub_state_7(rct_peep* peep){
vehicle_entry = &ride_entry->vehicles[ride_entry->default_vehicle];

uint8 shift_multiplier = 12;
if (vehicle_entry->var_14 & (1 << 14)){
if (vehicle_entry->flags_b & VEHICLE_ENTRY_FLAG_B_14){
shift_multiplier = 9;
}

uint8 direction = exit_direction;
if (vehicle_entry->var_14 & ((1 << 14) | (1 << 12))){
if (vehicle_entry->flags_b & (VEHICLE_ENTRY_FLAG_B_12 | VEHICLE_ENTRY_FLAG_B_14)){
direction = ((vehicle->sprite_direction + 3) / 8) + 1;
direction &= 3;

Expand Down Expand Up @@ -2559,7 +2559,7 @@ static void peep_update_ride_prepare_for_state_9(rct_peep* peep){

rct_ride_type* ride_type = GET_RIDE_ENTRY(ride->subtype);
rct_ride_type_vehicle* vehicle_entry = &ride_type->vehicles[ride_type->default_vehicle];
if (vehicle_entry->var_14 & 0x5000){
if (vehicle_entry->flags_b & (VEHICLE_ENTRY_FLAG_B_12 | VEHICLE_ENTRY_FLAG_B_14)){
shift_multiplier = 32;
}

Expand Down Expand Up @@ -2775,7 +2775,7 @@ static void peep_update_ride_sub_state_13(rct_peep* peep){

rct_ride_type* ride_type = GET_RIDE_ENTRY(ride->subtype);
rct_ride_type_vehicle* vehicle_entry = &ride_type->vehicles[ride_type->default_vehicle];
if (vehicle_entry->var_14 & 0x5000){
if (vehicle_entry->flags_b & (VEHICLE_ENTRY_FLAG_B_12 | VEHICLE_ENTRY_FLAG_B_14)){
shift_multiplier = 32;
}

Expand Down
2 changes: 1 addition & 1 deletion src/peep/peep.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ typedef struct {
uint16 next_y; // 0x26
uint8 next_z; // 0x28
uint8 next_var_29; // 0x29
uint8 outside_of_park; // 0x2A
uint8 outside_of_park; // 0x2A
uint8 state; // 0x2B
uint8 sub_state; // 0x2C
uint8 sprite_type; // 0x2D
Expand Down
2 changes: 1 addition & 1 deletion src/rct1.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ static void rct1_fix_z()
for (int i = 0; i < 4; i++) {
ride->station_heights[i] /= 2;
}
ride->var_116 /= 2;
ride->start_drop_height /= 2;
ride->highest_drop_height = 1;
if (ride->var_11F != 255) {
ride->var_11F /= 2;
Expand Down

0 comments on commit 8997f2a

Please sign in to comment.