From 0935ac6ea9037a90bca1c86a63fe4d373159f97f Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 24 Aug 2016 13:19:25 +0200 Subject: [PATCH 01/71] Start drawing debug test --- OpenRCT2.xcodeproj/project.pbxproj | 360 ++++++++++++ PaintTest/compat.c | 141 +++++ PaintTest/data.c | 628 +++++++++++++++++++++ PaintTest/main.c | 189 +++++++ src/ride/coaster/reverser_roller_coaster.c | 2 + src/ride/water/river_rapids.c | 2 + src/ride/water/splash_boats.c | 2 + src/ride/water/submarine_ride.c | 2 + 8 files changed, 1326 insertions(+) create mode 100644 PaintTest/compat.c create mode 100644 PaintTest/data.c create mode 100644 PaintTest/main.c diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index 4d3aff2c87..45fcaa252d 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -22,6 +22,90 @@ C61FB7201CF6180C004CE991 /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38BA1CF3006400659A24 /* libssl.dylib */; }; C61FB7211CF618BA004CE991 /* libssl.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38BA1CF3006400659A24 /* libssl.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; C61FB7241CF86356004CE991 /* NetworkUser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C61FB7221CF86356004CE991 /* NetworkUser.cpp */; }; + C64FDA641D6D9A2100F259B9 /* air_powered_vertical_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8BB1CDBC3B7009F9BFC /* air_powered_vertical_coaster.c */; }; + C64FDA651D6D9A2100F259B9 /* bobsleigh_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8BC1CDBC3B7009F9BFC /* bobsleigh_coaster.c */; }; + C64FDA661D6D9A2100F259B9 /* compact_inverted_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8BD1CDBC3B7009F9BFC /* compact_inverted_coaster.c */; }; + C64FDA671D6D9A2100F259B9 /* corkscrew_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8BE1CDBC3B7009F9BFC /* corkscrew_roller_coaster.c */; }; + C64FDA681D6D9A2100F259B9 /* flying_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8BF1CDBC3B7009F9BFC /* flying_roller_coaster.c */; }; + C64FDA691D6D9A2100F259B9 /* giga_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8C01CDBC3B7009F9BFC /* giga_coaster.c */; }; + C64FDA6A1D6D9A2100F259B9 /* heartline_twister_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8C11CDBC3B7009F9BFC /* heartline_twister_coaster.c */; }; + C64FDA6B1D6D9A2100F259B9 /* inverted_hairpin_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8C21CDBC3B7009F9BFC /* inverted_hairpin_coaster.c */; }; + C64FDA6C1D6D9A2100F259B9 /* inverted_impulse_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8C31CDBC3B7009F9BFC /* inverted_impulse_coaster.c */; }; + C64FDA6D1D6D9A2100F259B9 /* inverted_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8C41CDBC3B7009F9BFC /* inverted_roller_coaster.c */; }; + C64FDA6E1D6D9A2100F259B9 /* junior_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8C51CDBC3B7009F9BFC /* junior_roller_coaster.c */; }; + C64FDA6F1D6D9A2100F259B9 /* lay_down_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8C61CDBC3B7009F9BFC /* lay_down_roller_coaster.c */; }; + C64FDA701D6D9A2100F259B9 /* lim_launched_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8C71CDBC3B7009F9BFC /* lim_launched_roller_coaster.c */; }; + C64FDA711D6D9A2100F259B9 /* looping_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8C81CDBC3B7009F9BFC /* looping_roller_coaster.c */; }; + C64FDA721D6D9A2100F259B9 /* mine_ride.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8C91CDBC3B7009F9BFC /* mine_ride.c */; }; + C64FDA731D6D9A2100F259B9 /* mine_train_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8CA1CDBC3B7009F9BFC /* mine_train_coaster.c */; }; + C64FDA741D6D9A2100F259B9 /* mini_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8CB1CDBC3B7009F9BFC /* mini_roller_coaster.c */; }; + C64FDA751D6D9A2100F259B9 /* mini_suspended_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8CC1CDBC3B7009F9BFC /* mini_suspended_coaster.c */; }; + C64FDA761D6D9A2100F259B9 /* multi_dimension_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8CD1CDBC3B7009F9BFC /* multi_dimension_roller_coaster.c */; }; + C64FDA771D6D9A2100F259B9 /* reverse_freefall_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8CE1CDBC3B7009F9BFC /* reverse_freefall_coaster.c */; }; + C64FDA781D6D9A2100F259B9 /* reverser_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8CF1CDBC3B7009F9BFC /* reverser_roller_coaster.c */; }; + C64FDA791D6D9A2100F259B9 /* side_friction_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8D01CDBC3B7009F9BFC /* side_friction_roller_coaster.c */; }; + C64FDA7A1D6D9A2100F259B9 /* spiral_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8D11CDBC3B7009F9BFC /* spiral_roller_coaster.c */; }; + C64FDA7B1D6D9A2100F259B9 /* stand_up_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8D21CDBC3B7009F9BFC /* stand_up_roller_coaster.c */; }; + C64FDA7C1D6D9A2100F259B9 /* steeplechase.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8D31CDBC3B7009F9BFC /* steeplechase.c */; }; + C64FDA7D1D6D9A2100F259B9 /* suspended_swinging_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8D41CDBC3B7009F9BFC /* suspended_swinging_coaster.c */; }; + C64FDA7E1D6D9A2100F259B9 /* twister_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8D51CDBC3B7009F9BFC /* twister_roller_coaster.c */; }; + C64FDA7F1D6D9A2100F259B9 /* vertical_drop_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8D61CDBC3B7009F9BFC /* vertical_drop_roller_coaster.c */; }; + C64FDA801D6D9A2100F259B9 /* virginia_reel.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8D71CDBC3B7009F9BFC /* virginia_reel.c */; }; + C64FDA811D6D9A2100F259B9 /* wild_mouse.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8D81CDBC3B7009F9BFC /* wild_mouse.c */; }; + C64FDA821D6D9A2100F259B9 /* wooden_roller_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8D91CDBC3B7009F9BFC /* wooden_roller_coaster.c */; }; + C64FDA831D6D9A2100F259B9 /* wooden_wild_mouse.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8DA1CDBC3B7009F9BFC /* wooden_wild_mouse.c */; }; + C64FDA841D6D9A2100F259B9 /* car_ride.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8DC1CDBC3B7009F9BFC /* car_ride.c */; }; + C64FDA851D6D9A2100F259B9 /* circus_show.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8DD1CDBC3B7009F9BFC /* circus_show.c */; }; + C64FDA861D6D9A2100F259B9 /* crooked_house.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8DE1CDBC3B7009F9BFC /* crooked_house.c */; }; + C64FDA871D6D9A2100F259B9 /* dodgems.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8DF1CDBC3B7009F9BFC /* dodgems.c */; }; + C64FDA881D6D9A2100F259B9 /* ferris_wheel.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8E01CDBC3B7009F9BFC /* ferris_wheel.c */; }; + C64FDA891D6D9A2100F259B9 /* flying_saucers.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8E11CDBC3B7009F9BFC /* flying_saucers.c */; }; + C64FDA8A1D6D9A2100F259B9 /* ghost_train.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8E21CDBC3B7009F9BFC /* ghost_train.c */; }; + C64FDA8B1D6D9A2100F259B9 /* haunted_house.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8E31CDBC3B7009F9BFC /* haunted_house.c */; }; + C64FDA8C1D6D9A2100F259B9 /* maze.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8E41CDBC3B7009F9BFC /* maze.c */; }; + C64FDA8D1D6D9A2100F259B9 /* merry_go_round.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8E51CDBC3B7009F9BFC /* merry_go_round.c */; }; + C64FDA8E1D6D9A2100F259B9 /* mini_golf.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8E61CDBC3B7009F9BFC /* mini_golf.c */; }; + C64FDA8F1D6D9A2100F259B9 /* mini_helicopters.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8E71CDBC3B7009F9BFC /* mini_helicopters.c */; }; + C64FDA901D6D9A2100F259B9 /* monorail_cycles.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8E81CDBC3B7009F9BFC /* monorail_cycles.c */; }; + C64FDA911D6D9A2100F259B9 /* observation_tower.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8E91CDBC3B7009F9BFC /* observation_tower.c */; }; + C64FDA921D6D9A2100F259B9 /* space_rings.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8EA1CDBC3B7009F9BFC /* space_rings.c */; }; + C64FDA931D6D9A2100F259B9 /* spiral_slide.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8EB1CDBC3B7009F9BFC /* spiral_slide.c */; }; + C64FDA941D6D9A2100F259B9 /* facility.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8ED1CDBC3B7009F9BFC /* facility.c */; }; + C64FDA951D6D9A2100F259B9 /* misc.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8EE1CDBC3B7009F9BFC /* misc.c */; }; + C64FDA961D6D9A2100F259B9 /* shop.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8EF1CDBC3B7009F9BFC /* shop.c */; }; + C64FDA971D6D9A2100F259B9 /* 3d_cinema.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8F11CDBC3B7009F9BFC /* 3d_cinema.c */; }; + C64FDA981D6D9A2100F259B9 /* enterprise.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8F21CDBC3B7009F9BFC /* enterprise.c */; }; + C64FDA991D6D9A2100F259B9 /* go_karts.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8F31CDBC3B7009F9BFC /* go_karts.c */; }; + C64FDA9A1D6D9A2100F259B9 /* launched_freefall.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8F41CDBC3B7009F9BFC /* launched_freefall.c */; }; + C64FDA9B1D6D9A2100F259B9 /* magic_carpet.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8F51CDBC3B7009F9BFC /* magic_carpet.c */; }; + C64FDA9C1D6D9A2100F259B9 /* motion_simulator.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8F61CDBC3B7009F9BFC /* motion_simulator.c */; }; + C64FDA9D1D6D9A2100F259B9 /* pirate_ship.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8F71CDBC3B7009F9BFC /* pirate_ship.c */; }; + C64FDA9E1D6D9A2100F259B9 /* roto_drop.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8F81CDBC3B7009F9BFC /* roto_drop.c */; }; + C64FDA9F1D6D9A2100F259B9 /* swinging_inverter_ship.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8F91CDBC3B7009F9BFC /* swinging_inverter_ship.c */; }; + C64FDAA01D6D9A2100F259B9 /* top_spin.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8FA1CDBC3B7009F9BFC /* top_spin.c */; }; + C64FDAA11D6D9A2100F259B9 /* twist.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8FB1CDBC3B7009F9BFC /* twist.c */; }; + C64FDAA21D6D9A2100F259B9 /* chairlift.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8FD1CDBC3B7009F9BFC /* chairlift.c */; }; + C64FDAA31D6D9A2100F259B9 /* lift.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8FE1CDBC3B7009F9BFC /* lift.c */; }; + C64FDAA41D6D9A2100F259B9 /* minature_railway.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F8FF1CDBC3B7009F9BFC /* minature_railway.c */; }; + C64FDAA51D6D9A2100F259B9 /* monorail.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9001CDBC3B7009F9BFC /* monorail.c */; }; + C64FDAA61D6D9A2100F259B9 /* suspended_monorail.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9011CDBC3B7009F9BFC /* suspended_monorail.c */; }; + C64FDAA71D6D9A2100F259B9 /* boat_ride.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9031CDBC3B7009F9BFC /* boat_ride.c */; }; + C64FDAA81D6D9A2100F259B9 /* dingy_slide.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9041CDBC3B7009F9BFC /* dingy_slide.c */; }; + C64FDAA91D6D9A2100F259B9 /* log_flume.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9051CDBC3B7009F9BFC /* log_flume.c */; }; + C64FDAAA1D6D9A2100F259B9 /* river_rafts.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9061CDBC3B7009F9BFC /* river_rafts.c */; }; + C64FDAAB1D6D9A2100F259B9 /* river_rapids.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9071CDBC3B7009F9BFC /* river_rapids.c */; }; + C64FDAAC1D6D9A2100F259B9 /* splash_boats.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9081CDBC3B7009F9BFC /* splash_boats.c */; }; + C64FDAAD1D6D9A2100F259B9 /* submarine_ride.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F9091CDBC3B7009F9BFC /* submarine_ride.c */; }; + C64FDAAE1D6D9A2100F259B9 /* water_coaster.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F90A1CDBC3B7009F9BFC /* water_coaster.c */; }; + C64FDABC1D6D9C8800F259B9 /* addresses.c in Sources */ = {isa = PBXBuildFile; fileRef = D44270CD1CC81B3200D84D28 /* addresses.c */; }; + C64FDABE1D6D9CD900F259B9 /* ride_data.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271731CC81B3200D84D28 /* ride_data.c */; }; + C64FDABF1D6D9CEA00F259B9 /* map_element.c in Sources */ = {isa = PBXBuildFile; fileRef = C686F89B1CDBC37E009F9BFC /* map_element.c */; }; + C64FDAC01D6D9E3B00F259B9 /* track_data.c in Sources */ = {isa = PBXBuildFile; fileRef = D442717B1CC81B3200D84D28 /* track_data.c */; }; + C64FDAC21D6DA0B800F259B9 /* diagnostic.c in Sources */ = {isa = PBXBuildFile; fileRef = D44270FE1CC81B3200D84D28 /* diagnostic.c */; }; + C64FDAC31D6DA41000F259B9 /* track_paint.c in Sources */ = {isa = PBXBuildFile; fileRef = D442717D1CC81B3200D84D28 /* track_paint.c */; }; + C64FDAC51D6DA55E00F259B9 /* compat.c in Sources */ = {isa = PBXBuildFile; fileRef = C64FDAC41D6DA55E00F259B9 /* compat.c */; }; + C64FDAC81D6DA72400F259B9 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = C64FDAC71D6DA72400F259B9 /* main.c */; }; + C64FDACA1D6DA92D00F259B9 /* data.c in Sources */ = {isa = PBXBuildFile; fileRef = C64FDAC91D6DA92D00F259B9 /* data.c */; }; C650B2191CCABBDD00B4D91C /* S4Importer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B2151CCABBDD00B4D91C /* S4Importer.cpp */; }; C650B21A1CCABBDD00B4D91C /* tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B2171CCABBDD00B4D91C /* tables.cpp */; }; C650B21C1CCABC4400B4D91C /* ConvertCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B21B1CCABC4400B4D91C /* ConvertCommand.cpp */; }; @@ -356,6 +440,15 @@ /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ + C64FDA5B1D6D99F400F259B9 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; D41B74201C210B190080A7B9 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -401,6 +494,10 @@ C612A8981D64825300B634CA /* vehicle_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vehicle_data.h; sourceTree = ""; }; C61FB7221CF86356004CE991 /* NetworkUser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkUser.cpp; sourceTree = ""; usesTabs = 0; }; C61FB7231CF86356004CE991 /* NetworkUser.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = NetworkUser.h; sourceTree = ""; usesTabs = 0; }; + C64FDA5D1D6D99F400F259B9 /* PaintTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = PaintTest; sourceTree = BUILT_PRODUCTS_DIR; }; + C64FDAC41D6DA55E00F259B9 /* compat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = compat.c; sourceTree = ""; }; + C64FDAC71D6DA72400F259B9 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; + C64FDAC91D6DA92D00F259B9 /* data.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = data.c; sourceTree = ""; }; C650B2151CCABBDD00B4D91C /* S4Importer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = S4Importer.cpp; sourceTree = ""; usesTabs = 0; }; C650B2161CCABBDD00B4D91C /* S4Importer.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = S4Importer.h; sourceTree = ""; usesTabs = 0; }; C650B2171CCABBDD00B4D91C /* tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tables.cpp; sourceTree = ""; usesTabs = 0; }; @@ -1022,6 +1119,13 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + C64FDA5A1D6D99F400F259B9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; D497D0751C20FD52002BF46A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1042,6 +1146,16 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + C64FDA5E1D6D99F400F259B9 /* PaintTest */ = { + isa = PBXGroup; + children = ( + C64FDAC41D6DA55E00F259B9 /* compat.c */, + C64FDAC71D6DA72400F259B9 /* main.c */, + C64FDAC91D6DA92D00F259B9 /* data.c */, + ); + path = PaintTest; + sourceTree = ""; + }; C650B2141CCABBDD00B4D91C /* rct1 */ = { isa = PBXGroup; children = ( @@ -1941,6 +2055,7 @@ D41B72431C21015A0080A7B9 /* Sources */, D497D07A1C20FD52002BF46A /* Resources */, D41B73ED1C21017D0080A7B9 /* Libraries */, + C64FDA5E1D6D99F400F259B9 /* PaintTest */, D497D0791C20FD52002BF46A /* Products */, ); sourceTree = ""; @@ -1950,6 +2065,7 @@ isa = PBXGroup; children = ( D497D0781C20FD52002BF46A /* OpenRCT2.app */, + C64FDA5D1D6D99F400F259B9 /* PaintTest */, ); name = Products; sourceTree = ""; @@ -2018,6 +2134,24 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + C64FDA5C1D6D99F400F259B9 /* PaintTest */ = { + isa = PBXNativeTarget; + buildConfigurationList = C64FDA631D6D99F400F259B9 /* Build configuration list for PBXNativeTarget "PaintTest" */; + buildPhases = ( + C64FDAC61D6DA64A00F259B9 /* Create Segment Files */, + C64FDA591D6D99F400F259B9 /* Sources */, + C64FDA5A1D6D99F400F259B9 /* Frameworks */, + C64FDA5B1D6D99F400F259B9 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = PaintTest; + productName = PaintTest; + productReference = C64FDA5D1D6D99F400F259B9 /* PaintTest */; + productType = "com.apple.product-type.tool"; + }; D497D0771C20FD52002BF46A /* OpenRCT2 */ = { isa = PBXNativeTarget; buildConfigurationList = D497D0891C20FD53002BF46A /* Build configuration list for PBXNativeTarget "OpenRCT2" */; @@ -2050,6 +2184,9 @@ LastUpgradeCheck = 0800; ORGANIZATIONNAME = OpenRCT2; TargetAttributes = { + C64FDA5C1D6D99F400F259B9 = { + CreatedOnToolsVersion = 7.3.1; + }; D497D0771C20FD52002BF46A = { CreatedOnToolsVersion = 7.2; }; @@ -2069,6 +2206,7 @@ projectRoot = ""; targets = ( D497D0771C20FD52002BF46A /* OpenRCT2 */, + C64FDA5C1D6D99F400F259B9 /* PaintTest */, ); }; /* End PBXProject section */ @@ -2090,6 +2228,23 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + C64FDAC61D6DA64A00F259B9 /* Create Segment Files */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/openrct2.exe", + ); + name = "Create Segment Files"; + outputPaths = ( + "$(DERIVED_FILE_DIR)/openrct2_text", + "$(DERIVED_FILE_DIR)/openrct2_data", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "dd if=\"${SRCROOT}/openrct2.exe\" of=\"${DERIVED_FILE_DIR}/openrct2_text\" bs=4096 skip=1 count=1187\ndd if=\"${SRCROOT}/openrct2.exe\" of=\"${DERIVED_FILE_DIR}/openrct2_data\" bs=4096 skip=1188 count=318\ndd if=/dev/zero of=\"${DERIVED_FILE_DIR}/openrct2_data\" bs=4096 seek=318 count=2630 conv=notrunc\ndd if=\"${SRCROOT}/openrct2.exe\" of=\"${DERIVED_FILE_DIR}/openrct2_data\" bs=4096 skip=1506 seek=2948 count=1 conv=notrunc"; + }; D40F4E1D1C2528D5009582C9 /* Create Segment Files */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -2186,6 +2341,97 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + C64FDA591D6D99F400F259B9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C64FDAC31D6DA41000F259B9 /* track_paint.c in Sources */, + C64FDAC21D6DA0B800F259B9 /* diagnostic.c in Sources */, + C64FDAC01D6D9E3B00F259B9 /* track_data.c in Sources */, + C64FDABF1D6D9CEA00F259B9 /* map_element.c in Sources */, + C64FDABE1D6D9CD900F259B9 /* ride_data.c in Sources */, + C64FDABC1D6D9C8800F259B9 /* addresses.c in Sources */, + C64FDA641D6D9A2100F259B9 /* air_powered_vertical_coaster.c in Sources */, + C64FDA651D6D9A2100F259B9 /* bobsleigh_coaster.c in Sources */, + C64FDA661D6D9A2100F259B9 /* compact_inverted_coaster.c in Sources */, + C64FDA671D6D9A2100F259B9 /* corkscrew_roller_coaster.c in Sources */, + C64FDA681D6D9A2100F259B9 /* flying_roller_coaster.c in Sources */, + C64FDA691D6D9A2100F259B9 /* giga_coaster.c in Sources */, + C64FDA6A1D6D9A2100F259B9 /* heartline_twister_coaster.c in Sources */, + C64FDA6B1D6D9A2100F259B9 /* inverted_hairpin_coaster.c in Sources */, + C64FDA6C1D6D9A2100F259B9 /* inverted_impulse_coaster.c in Sources */, + C64FDA6D1D6D9A2100F259B9 /* inverted_roller_coaster.c in Sources */, + C64FDA6E1D6D9A2100F259B9 /* junior_roller_coaster.c in Sources */, + C64FDA6F1D6D9A2100F259B9 /* lay_down_roller_coaster.c in Sources */, + C64FDA701D6D9A2100F259B9 /* lim_launched_roller_coaster.c in Sources */, + C64FDA711D6D9A2100F259B9 /* looping_roller_coaster.c in Sources */, + C64FDAC81D6DA72400F259B9 /* main.c in Sources */, + C64FDA721D6D9A2100F259B9 /* mine_ride.c in Sources */, + C64FDA731D6D9A2100F259B9 /* mine_train_coaster.c in Sources */, + C64FDA741D6D9A2100F259B9 /* mini_roller_coaster.c in Sources */, + C64FDA751D6D9A2100F259B9 /* mini_suspended_coaster.c in Sources */, + C64FDA761D6D9A2100F259B9 /* multi_dimension_roller_coaster.c in Sources */, + C64FDA771D6D9A2100F259B9 /* reverse_freefall_coaster.c in Sources */, + C64FDA781D6D9A2100F259B9 /* reverser_roller_coaster.c in Sources */, + C64FDA791D6D9A2100F259B9 /* side_friction_roller_coaster.c in Sources */, + C64FDACA1D6DA92D00F259B9 /* data.c in Sources */, + C64FDA7A1D6D9A2100F259B9 /* spiral_roller_coaster.c in Sources */, + C64FDA7B1D6D9A2100F259B9 /* stand_up_roller_coaster.c in Sources */, + C64FDA7C1D6D9A2100F259B9 /* steeplechase.c in Sources */, + C64FDA7D1D6D9A2100F259B9 /* suspended_swinging_coaster.c in Sources */, + C64FDA7E1D6D9A2100F259B9 /* twister_roller_coaster.c in Sources */, + C64FDA7F1D6D9A2100F259B9 /* vertical_drop_roller_coaster.c in Sources */, + C64FDA801D6D9A2100F259B9 /* virginia_reel.c in Sources */, + C64FDA811D6D9A2100F259B9 /* wild_mouse.c in Sources */, + C64FDA821D6D9A2100F259B9 /* wooden_roller_coaster.c in Sources */, + C64FDA831D6D9A2100F259B9 /* wooden_wild_mouse.c in Sources */, + C64FDA841D6D9A2100F259B9 /* car_ride.c in Sources */, + C64FDA851D6D9A2100F259B9 /* circus_show.c in Sources */, + C64FDA861D6D9A2100F259B9 /* crooked_house.c in Sources */, + C64FDA871D6D9A2100F259B9 /* dodgems.c in Sources */, + C64FDA881D6D9A2100F259B9 /* ferris_wheel.c in Sources */, + C64FDA891D6D9A2100F259B9 /* flying_saucers.c in Sources */, + C64FDA8A1D6D9A2100F259B9 /* ghost_train.c in Sources */, + C64FDA8B1D6D9A2100F259B9 /* haunted_house.c in Sources */, + C64FDA8C1D6D9A2100F259B9 /* maze.c in Sources */, + C64FDA8D1D6D9A2100F259B9 /* merry_go_round.c in Sources */, + C64FDA8E1D6D9A2100F259B9 /* mini_golf.c in Sources */, + C64FDA8F1D6D9A2100F259B9 /* mini_helicopters.c in Sources */, + C64FDA901D6D9A2100F259B9 /* monorail_cycles.c in Sources */, + C64FDA911D6D9A2100F259B9 /* observation_tower.c in Sources */, + C64FDA921D6D9A2100F259B9 /* space_rings.c in Sources */, + C64FDA931D6D9A2100F259B9 /* spiral_slide.c in Sources */, + C64FDA941D6D9A2100F259B9 /* facility.c in Sources */, + C64FDAC51D6DA55E00F259B9 /* compat.c in Sources */, + C64FDA951D6D9A2100F259B9 /* misc.c in Sources */, + C64FDA961D6D9A2100F259B9 /* shop.c in Sources */, + C64FDA971D6D9A2100F259B9 /* 3d_cinema.c in Sources */, + C64FDA981D6D9A2100F259B9 /* enterprise.c in Sources */, + C64FDA991D6D9A2100F259B9 /* go_karts.c in Sources */, + C64FDA9A1D6D9A2100F259B9 /* launched_freefall.c in Sources */, + C64FDA9B1D6D9A2100F259B9 /* magic_carpet.c in Sources */, + C64FDA9C1D6D9A2100F259B9 /* motion_simulator.c in Sources */, + C64FDA9D1D6D9A2100F259B9 /* pirate_ship.c in Sources */, + C64FDA9E1D6D9A2100F259B9 /* roto_drop.c in Sources */, + C64FDA9F1D6D9A2100F259B9 /* swinging_inverter_ship.c in Sources */, + C64FDAA01D6D9A2100F259B9 /* top_spin.c in Sources */, + C64FDAA11D6D9A2100F259B9 /* twist.c in Sources */, + C64FDAA21D6D9A2100F259B9 /* chairlift.c in Sources */, + C64FDAA31D6D9A2100F259B9 /* lift.c in Sources */, + C64FDAA41D6D9A2100F259B9 /* minature_railway.c in Sources */, + C64FDAA51D6D9A2100F259B9 /* monorail.c in Sources */, + C64FDAA61D6D9A2100F259B9 /* suspended_monorail.c in Sources */, + C64FDAA71D6D9A2100F259B9 /* boat_ride.c in Sources */, + C64FDAA81D6D9A2100F259B9 /* dingy_slide.c in Sources */, + C64FDAA91D6D9A2100F259B9 /* log_flume.c in Sources */, + C64FDAAA1D6D9A2100F259B9 /* river_rafts.c in Sources */, + C64FDAAB1D6D9A2100F259B9 /* river_rapids.c in Sources */, + C64FDAAC1D6D9A2100F259B9 /* splash_boats.c in Sources */, + C64FDAAD1D6D9A2100F259B9 /* submarine_ride.c in Sources */, + C64FDAAE1D6D9A2100F259B9 /* water_coaster.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; D497D0741C20FD52002BF46A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -2518,6 +2764,112 @@ /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ + C64FDA611D6D99F400F259B9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CODE_SIGN_IDENTITY = "-"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + "NO_VEHICLES=1", + ); + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(SRCROOT)/libxc/include", + "$(SRCROOT)/libxc/include/SDL2", + ); + LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/libxc/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + OTHER_LDFLAGS = ( + "-sectcreate", + rct2_text, + __text, + "$(DERIVED_FILE_DIR)/openrct2_text", + "-segaddr", + rct2_text, + 0x401000, + "-segprot", + rct2_text, + rwx, + rx, + "-sectcreate", + rct2_data, + __data, + "$(DERIVED_FILE_DIR)/openrct2_data", + "-segaddr", + rct2_data, + 0x8a4000, + "-segprot", + rct2_data, + rw, + rw, + "-segaddr", + __TEXT, + 0x2000000, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + C64FDA621D6D99F400F259B9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CODE_SIGN_IDENTITY = "-"; + GCC_PREPROCESSOR_DEFINITIONS = ( + OPENGL_NO_LINK, + "OPENRCT2_BUILD_INFO_HEADER=\"\\\"$(DERIVED_FILE_DIR)/gitversion.h\\\"\"", + "NO_VEHICLES=1", + ); + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(SRCROOT)/libxc/include", + "$(SRCROOT)/libxc/include/SDL2", + ); + LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/libxc/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + OTHER_LDFLAGS = ( + "-sectcreate", + rct2_text, + __text, + "$(DERIVED_FILE_DIR)/openrct2_text", + "-segaddr", + rct2_text, + 0x401000, + "-segprot", + rct2_text, + rwx, + rx, + "-sectcreate", + rct2_data, + __data, + "$(DERIVED_FILE_DIR)/openrct2_data", + "-segaddr", + rct2_data, + 0x8a4000, + "-segprot", + rct2_data, + rw, + rw, + "-segaddr", + __TEXT, + 0x2000000, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; D497D0871C20FD53002BF46A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -2716,6 +3068,14 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + C64FDA631D6D99F400F259B9 /* Build configuration list for PBXNativeTarget "PaintTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C64FDA611D6D99F400F259B9 /* Debug */, + C64FDA621D6D99F400F259B9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; D497D0731C20FD52002BF46A /* Build configuration list for PBXProject "OpenRCT2" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/PaintTest/compat.c b/PaintTest/compat.c new file mode 100644 index 0000000000..faf2f3e069 --- /dev/null +++ b/PaintTest/compat.c @@ -0,0 +1,141 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#include "../src/config.h" +#include "../src/object.h" +#include "../src/interface/colour.h" +#include "../src/ride/ride.h" +#include "../src/ride/track.h" +#include "../src/world/sprite.h" + +#define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) +#define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) + +rct_map_element *gMapElements = (rct_map_element *) RCT2_ADDRESS_MAP_ELEMENTS; +rct_map_element **gMapElementTilePointers = (rct_map_element **) RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS; +rct_ride *gRideList = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride); +rct_sprite *sprite_list = RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite); + + +const rct_xy16 TileDirectionDelta[] = { + {-32, 0}, + {0, +32}, + {+32, 0}, + {0, -32}, + {-32, +32}, + {+32, +32}, + {+32, -32}, + {-32, -32} +}; + +uint8 get_current_rotation() { + return gCurrentRotation & 3; +} + +const uint32 construction_markers[] = { + COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_USE_PALETTE << 28, // White + 2 << 19 | 0b110000 << 19 | IMAGE_TYPE_MIX_BACKGROUND << 28, // Translucent +}; + +int object_entry_group_counts[] = { + 128, // rides + 252, // small scenery + 128, // large scenery + 128, // walls + 32, // banners + 16, // paths + 15, // path bits + 19, // scenery sets + 1, // park entrance + 1, // water + 1 // scenario text +}; + + +general_configuration gConfigGeneral; +uint32 gCurrentViewportFlags = 0; +uint16 gMapSelectFlags; +uint16 gMapSelectType; +rct_xy16 gMapSelectPositionA; +rct_xy16 gMapSelectPositionB; +rct_xyz16 gMapSelectArrowPosition; +uint8 gMapSelectArrowDirection; + +void entrance_paint(uint8 direction, int height, rct_map_element *map_element) { } +void banner_paint(uint8 direction, int height, rct_map_element *map_element) { } +void surface_paint(uint8 direction, uint16 height, rct_map_element *mapElement) { } +void path_paint(uint8 direction, uint16 height, rct_map_element *mapElement) { } +void scenery_paint(uint8 direction, int height, rct_map_element *mapElement) { } +void fence_paint(uint8 direction, int height, rct_map_element *mapElement) { } +void scenery_multiple_paint(uint8 direction, uint16 height, rct_map_element *mapElement) { } + +rct_ride *get_ride(int index) { + if (index < 0 || index >= MAX_RIDES) { + log_error("invalid index %d for ride", index); + return NULL; + } + return &gRideList[index]; +} + +rct_ride_entry *get_ride_entry(int index) { + if (index < 0 || index >= object_entry_group_counts[OBJECT_TYPE_RIDE]) { + log_error("invalid index %d for ride type", index); + return NULL; + } + return gRideEntries[index]; +} + +rct_ride_entry *get_ride_entry_by_ride(rct_ride *ride) { + rct_ride_entry *type = get_ride_entry(ride->subtype); + if (type == NULL) { + log_error("Invalid ride subtype for ride"); + } + return type; +} + +rct_sprite *get_sprite(size_t sprite_idx) { + assert(sprite_idx < MAX_SPRITES); + return &sprite_list[sprite_idx]; +} + +int map_element_is_last_for_tile(const rct_map_element *element) { + return element->flags & MAP_ELEMENT_FLAG_LAST_TILE; +} + +int map_element_get_type(const rct_map_element *element) { + return element->type & MAP_ELEMENT_TYPE_MASK; +} + +int map_element_get_direction(const rct_map_element *element) { + return element->type & MAP_ELEMENT_DIRECTION_MASK; +} + +rct_map_element *map_get_first_element_at(int x, int y) { + if (x < 0 || y < 0 || x > 255 || y > 255) { + log_error("Trying to access element outside of range"); + return NULL; + } + return gMapElementTilePointers[x + y * 256]; +} + +int map_get_station(rct_map_element *mapElement) { + return (mapElement->properties.track.sequence & 0x70) >> 4; +} + +bool ride_type_has_flag(int rideType, int flag) +{ + return (RideProperties[rideType].flags & flag) != 0; +} diff --git a/PaintTest/data.c b/PaintTest/data.c new file mode 100644 index 0000000000..bfb6047f76 --- /dev/null +++ b/PaintTest/data.c @@ -0,0 +1,628 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#include "../src/common.h" + +const utf8string RideNames[91] = { + "Spiral Roller Coaster", + "Stand-up Roller Coaster", + "Suspended Swinging Coaster", + "Inverted Roller Coaster", + "Junior Roller Coaster", + "Miniature Railway", + "Monorail", + "Mini Suspended Coaster", + "Boat Ride", + "Wooden Wild Mouse", + "Steeplechase", + "Car Ride", + "Launched Freefall", + "Bobsleigh Coaster", + "Observation Tower", + "Looping Roller Coaster", + "Dinghy Slide", + "Mine Train Coaster", + "Chairlift", + "Corkscrew Roller Coaster", + "Maze", + "Spiral Slide", + "Go Karts", + "Log Flume", + "River Rapids", + "Dodgems", + "Pirate Ship", + "Swinging Inverter Ship", + "Food Stall", + "Unknown Stall", + "Drink Stall", + "Unknown Stall", + "Shop", + "Merry-Go-Round", + "Unknown Stall", + "Information Kiosk", + "Toilets", + "Ferris Wheel", + "Motion Simulator", + "3D Cinema", + "Top Spin", + "Space Rings", + "Reverse Freefall Coaster", + "Lift", + "Vertical Drop Roller Coaster", + "Cash Machine", + "Twist", + "Haunted House", + "First Aid Room", + "Circus Show", + "Ghost Train", + "Steel Twister Roller Coaster", + "Wooden Roller Coaster", + "Side-Friction Roller Coaster", + "Wild Mouse", + "Multi-Dimension Roller Coaster", + "Unknown Ride", + "Flying Roller Coaster", + "Unknown Ride", + "Virginia Reel", + "Splash Boats", + "Mini Helicopters", + "Lay-down Roller Coaster", + "Suspended Monorail", + "Unknown Ride", + "Reverser Roller Coaster", + "Heartline Twister Coaster", + "Mini Golf", + "Giga Coaster", + "Roto-Drop", + "Flying Saucers", + "Crooked House", + "Monorail Cycles", + "Compact Inverted Coaster", + "Water Coaster", + "Air Powered Vertical Coaster", + "Inverted Hairpin Coaster", + "Magic Carpet", + "Submarine Ride", + "River Rafts", + "Unknown Ride", + "Enterprise", + "Unknown Ride", + "Unknown Ride", + "Unknown Ride", + "Unknown Ride", + "Inverted Impulse Coaster", + "Mini Roller Coaster", + "Mine Ride", + "Unknown Ride", + "LIM Launched Roller Coaster", +}; + +const utf8string TrackNames[256] = { + "Flat", + "End Station", + "Begin Station", + "Middle Station", + "25 Deg Up", + "60 Deg Up", + "Flat to 25 deg Up", + "25 Deg up to 60 deg Up", + "60 Deg up to 25 deg Up", + "25 Deg up to Flat", + "25 Deg Down", + "60 Deg Down", + "Flat to 25 deg Down", + "25 Deg Down to 60 deg Down", + "60 Deg Down to 25 deg Down", + "25 Deg Down to Flat", + "Left Quarter Turn 5 Tiles", + "Right Quarter Turn 5 Tiles", + "Flat to Left Bank", + "Flat to Right Bank", + "Left Bank to Flat", + "Right Bank to Flat", + "Banked Left Quarter Turn 5 Tiles", + "Banked Right Quarter Turn 5 Tiles", + "Left Bank to 25 deg Up", + "Right Bank to 25 deg Up", + "25 Deg up to Left Bank", + "25 Deg up to Right Bank", + "Left Bank to 25 deg Down", + "Right Bank to 25 deg Down", + "25 Deg Down to Left Bank", + "25 Deg Down to Right Bank", + "Left Bank", + "Right Bank", + "Left Quarter Turn 5 Tiles 25 deg Up", + "Right Quarter Turn 5 Tiles 25 deg Up", + "Left Quarter Turn 5 Tiles 25 deg Down", + "Right Quarter Turn 5 Tiles 25 deg Down", + "S Bend Left", + "S Bend Right", + "Left Vertical Loop", + "Right Vertical Loop", + "Left Quarter Turn 3 Tiles", + "Right Quarter Turn 3 Tiles", + "Left Quarter Turn 3 Tiles Bank", + "Right Quarter Turn 3 Tiles Bank", + "Left Quarter Turn 3 Tiles 25 deg Up", + "Right Quarter Turn 3 Tiles 25 deg Up", + "Left Quarter Turn 3 Tiles 25 deg Down", + "Right Quarter Turn 3 Tiles 25 deg Down", + "Left Quarter Turn 1 Tile", + "Right Quarter Turn 1 Tile", + "Left Twist Down to Up", + "Right Twist Down to Up", + "Left Twist up to Down", + "Right Twist up to Down", + "Half Loop Up", + "Half Loop Down", + "Left Corkscrew Up", + "Right Corkscrew Up", + "Left Corkscrew Down", + "Right Corkscrew Down", + "Flat to 60 deg Up", + "60 Deg up to Flat", + "Flat to 60 deg Down", + "60 Deg Down to Flat", + "Tower Base", + "Tower Section", + "Flat Covered", + "25 Deg up Covered", + "60 Deg up Covered", + "Flat to 25 deg up Covered", + "25 Deg up to 60 deg up Covered", + "60 Deg up to 25 deg up Covered", + "25 Deg up to Flat Covered", + "25 Deg Down Covered", + "60 Deg Down Covered", + "Flat to 25 deg Down Covered", + "25 Deg Down to 60 deg Down Covered", + "60 Deg Down to 25 deg Down Covered", + "25 Deg Down to Flat Covered", + "Left Quarter Turn 5 Tiles Covered", + "Right Quarter Turn 5 Tiles Covered", + "S Bend Left Covered", + "S Bend Right Covered", + "Left Quarter Turn 3 Tiles Covered", + "Right Quarter Turn 3 Tiles Covered", + "Left Half Banked Helix up Small", + "Right Half Banked Helix up Small", + "Left Half Banked Helix Down Small", + "Right Half Banked Helix Down Small", + "Left Half Banked Helix up Large", + "Right Half Banked Helix up Large", + "Left Half Banked Helix Down Large", + "Right Half Banked Helix Down Large", + "Left Quarter Turn 1 Tile 60 deg Up", + "Right Quarter Turn 1 Tile 60 deg Up", + "Left Quarter Turn 1 Tile 60 deg Down", + "Right Quarter Turn 1 Tile 60 deg Down", + "Brakes", + "Rotation Control Toggle", + "Inverted 90 deg up to Flat Quarter Loop/Maze", + "Left Quarter Banked Helix Large Up", + "Right Quarter Banked Helix Large Up", + "Left Quarter Banked Helix Large Down", + "Right Quarter Banked Helix Large Down", + "Left Quarter Helix Large Up", + "Right Quarter Helix Large Up", + "Left Quarter Helix Large Down", + "Right Quarter Helix Large Down", + "25 Deg up Left Banked", + "25 Deg up Right Banked", + "Waterfall", + "Rapids", + "On Ride Photo", + "25 Deg Down Left Banked", + "25 Deg Down Right Banked", + "Water Splash", + "Flat to 60 deg up Long Base", + "60 Deg up to Flat Long Base", + "Whirlpool", + "Flat to 60 deg Down Long Base", + "60 Deg up to Flat Long Base 122", + "Cable Lift Hill", + "Reverse Whoa Belly Slope", + "Reverse Whoa Belly Vertical", + "90 Deg Up", + "90 Deg Down", + "60 Deg up to 90 deg Up", + "90 Deg Down to 60 deg Down", + "90 Deg up to 60 deg Up", + "60 Deg Down to 90 deg Down", + "Brake for Drop", + "Left Eighth to Diag", + "Right Eighth to Diag", + "Left Eighth to Orthogonal", + "Right Eighth to Orthogonal", + "Left Eighth Bank to Diag", + "Right Eighth Bank to Diag", + "Left Eighth Bank to Orthogonal", + "Right Eighth Bank to Orthogonal", + "Diag Flat", + "Diag 25 deg Up", + "Diag 60 deg Up", + "Diag Flat to 25 deg Up", + "Diag 25 deg up to 60 deg Up", + "Diag 60 deg up to 25 deg Up", + "Diag 25 deg up to Flat", + "Diag 25 deg Down", + "Diag 60 deg Down", + "Diag Flat to 25 deg Down", + "Diag 25 deg Down to 60 deg Down", + "Diag 60 deg Down to 25 deg Down", + "Diag 25 deg Down to Flat", + "Diag Flat to 60 deg Up", + "Diag 60 deg up to Flat", + "Diag Flat to 60 deg Down", + "Diag 60 deg Down to Flat", + "Diag Flat to Left Bank", + "Diag Flat to Right Bank", + "Diag Left Bank to Flat", + "Diag Right Bank to Flat", + "Diag Left Bank to 25 deg Up", + "Diag Right Bank to 25 deg Up", + "Diag 25 deg up to Left Bank", + "Diag 25 deg up to Right Bank", + "Diag Left Bank to 25 deg Down", + "Diag Right Bank to 25 deg Down", + "Diag 25 deg Down to Left Bank", + "Diag 25 deg Down to Right Bank", + "Diag Left Bank", + "Diag Right Bank", + "Log Flume Reverser", + "Spinning Tunnel", + "Left Barrel Roll up to Down", + "Right Barrel Roll up to Down", + "Left Barrel Roll Down to Up", + "Right Barrel Roll Down to Up", + "Left Bank to Left Quarter Turn 3 Tiles 25 deg Up", + "Right Bank to Right Quarter Turn 3 Tiles 25 deg Up", + "Left Quarter Turn 3 Tiles 25 deg Down to Left Bank", + "Right Quarter Turn 3 Tiles 25 deg Down to Right Bank", + "Powered Lift", + "Left Large Half Loop Up", + "Right Large Half Loop Up", + "Right Large Half Loop Down", + "Left Large Half Loop Down", + "Left Flyer Twist Up", + "Right Flyer Twist Up", + "Left Flyer Twist Down", + "Right Flyer Twist Down", + "Flyer Half Loop Up", + "Flyer Half Loop Down", + "Left Flyer Corkscrew Up", + "Right Flyer Corkscrew Up", + "Left Flyer Corkscrew Down", + "Right Flyer Corkscrew Down", + "Heartline Transfer Up", + "Heartline Transfer Down", + "Left Heartline Roll", + "Right Heartline Roll", + "Mini Golf Hole A", + "Mini Golf Hole B", + "Mini Golf Hole C", + "Mini Golf Hole D", + "Mini Golf Hole E", + "Multidim Inverted Flat to 90 deg Quarter Loop Down", + "90 Deg to Inverted Flat Quarter Loop Up", + "Inverted Flat to 90 deg Quarter Loop Down", + "Left Curved Lift Hill", + "Right Curved Lift Hill", + "Left Reverser", + "Right Reverser", + "Air Thrust top Cap", + "Air Thrust Vertical Down", + "Air Thrust Vertical Down to Level", + "Block Brakes", + "Left Banked Quarter Turn 3 Tile 25 deg Up", + "Right Banked Quarter Turn 3 Tile 25 deg Up", + "Left Banked Quarter Turn 3 Tile 25 deg Down", + "Right Banked Quarter Turn 3 Tile 25 deg Down", + "Left Banked Quarter Turn 5 Tile 25 deg Up", + "Right Banked Quarter Turn 5 Tile 25 deg Up", + "Left Banked Quarter Turn 5 Tile 25 deg Down", + "Right Banked Quarter Turn 5 Tile 25 deg Down", + "25 Deg up to Left Banked 25 deg Up", + "25 Deg up to Right Banked 25 deg Up", + "Left Banked 25 deg up to 25 deg Up", + "Right Banked 25 deg up to 25 deg Up", + "25 Deg Down to Left Banked 25 deg Down", + "25 Deg Down to Right Banked 25 deg Down", + "Left Banked 25 deg Down to 25 deg Down", + "Right Banked 25 deg Down to 25 deg Down", + "Left Banked Flat to Left Banked 25 deg Up", + "Right Banked Flat to Right Banked 25 deg Up", + "Left Banked 25 deg up to Left Banked Flat", + "Right Banked 25 deg up to Right Banked Flat", + "Left Banked Flat to Left Banked 25 deg Down", + "Right Banked Flat to Right Banked 25 deg Down", + "Left Banked 25 deg Down to Left Banked Flat", + "Right Banked 25 deg Down to Right Banked Flat", + "Flat to Left Banked 25 deg Up", + "Flat to Right Banked 25 deg Up", + "Left Banked 25 deg up to Flat", + "Right Banked 25 deg up to Flat", + "Flat to Left Banked 25 deg Down", + "Flat to Right Banked 25 deg Down", + "Left Banked 25 deg Down to Flat", + "Right Banked 25 deg Down to Flat", + "Left Quarter Turn 1 Tile 90 deg Up", + "Right Quarter Turn 1 Tile 90 deg Up", + "Left Quarter Turn 1 Tile 90 deg Down", + "Right Quarter Turn 1 Tile 90 deg Down", + "Multidim 90 deg up to Inverted Flat Quarter Loop", + "Multidim Flat to 90 deg Down Quarter Loop", +}; + +const utf8string FlatTrackNames[256] = { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "FLAT_TRACK_ELEM_1_X_4_A = 95,", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "FLAT_TRACK_ELEM_2_X_2 = 110,", + "FLAT_TRACK_ELEM_4_X_4 = 111,", + "", + "", + "", + "", + "FLAT_TRACK_ELEM_1_X_5 = 116,", + "", + "FLAT_TRACK_ELEM_1_X_1_A = 118,", + "FLAT_TRACK_ELEM_1_X_4_B = 119,", + "", + "FLAT_TRACK_ELEM_1_X_1_B = 121,", + "FLAT_TRACK_ELEM_1_X_4_C = 122,", + "FLAT_TRACK_ELEM_3_X_3 = 123,", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", +}; diff --git a/PaintTest/main.c b/PaintTest/main.c new file mode 100644 index 0000000000..c1a17dfa24 --- /dev/null +++ b/PaintTest/main.c @@ -0,0 +1,189 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#include "../src/paint/paint.h" +#include "../src/ride/track_data.h" +#include "../src/ride/track_paint.h" +#include "../src/interface/viewport.h" + + + +#define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) +#define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) + +extern const utf8string RideNames[91]; +extern const utf8string TrackNames[256]; +extern const utf8string FlatTrackNames[256]; + +bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y) { + return false; +} + +paint_struct *sub_98196C( + uint32 image_id, + sint8 x_offset, sint8 y_offset, + sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, + sint16 z_offset, + uint32 rotation +) { + printf("sub_98196C(%d)\n", image_id & 0x7FFFF); + return NULL; +} + +paint_struct *sub_98197C( + uint32 image_id, + sint8 x_offset, sint8 y_offset, + sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, + sint16 z_offset, + sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, + uint32 rotation + ) { + printf("sub_98197C(%d)\n", image_id & 0x7FFFF); + return NULL; +} + +paint_struct *sub_98198C( + uint32 image_id, + sint8 x_offset, sint8 y_offset, + sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, + sint16 z_offset, + sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, + uint32 rotation + ) { + printf("sub_98198C(%d)\n", image_id & 0x7FFFF); + return NULL; +} + +paint_struct *sub_98199C( + uint32 image_id, + sint8 x_offset, sint8 y_offset, + sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, + sint16 z_offset, + sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, + uint32 rotation + ) { + printf("sub_98199C(%d)\n", image_id & 0x7FFFF); + return NULL; +} + +bool wooden_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags, bool *underground) { + return false; +} + +bool wooden_b_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags) { + return false; +} + +bool metal_a_supports_paint_setup(int supportType, int segment, int special, int height, uint32 imageColourFlags) { + return false; +} + +bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, int height, uint32 imageColourFlags) { + return false; +} + +int getTrackSequenceCount(uint8 rideType, uint8 trackType) { + int sequenceCount = 0; + const rct_preview_track **trackBlocks; + + if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) { + trackBlocks = FlatRideTrackBlocks; + } else { + trackBlocks = TrackBlocks; + } + + for (int i = 0; i < 256; i++) { + if (trackBlocks[trackType][i].index == 0xFF) { + break; + } + + sequenceCount++; + } + + return sequenceCount; +} + +bool testTrackElement(uint8 rideType, uint8 trackType) { + uint8 rideIndex = 0; + rct_map_element mapElement = {}; + rct_map_element_track_properties trackProperties = { .type = trackType, .ride_index = 0}; + mapElement.properties.track = trackProperties; + + g_currently_drawn_item = &mapElement; + + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; + RCT2_GLOBAL(0x00F44198, uint32) = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; + RCT2_GLOBAL(0x00F441A0, uint32) = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000; + RCT2_GLOBAL(0x00F441A4, uint32) = COLOUR_BRIGHT_PURPLE << 19 | COLOUR_DARK_BLUE << 24 | 0xA0000000; + RCT2_GLOBAL(0x00F4419C, uint32) = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; + + rct_drawpixelinfo dpi = { .zoom_level = 1 }; + unk_140E9A8 = &dpi; + + rct_vehicle vehicle = { }; + + rct_ride ride = { }; + + rct_ride_entry rideEntry = { }; + + gRideList[0] = ride; + gRideEntries[0] = &rideEntry; + + TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; + int sequenceCount = getTrackSequenceCount(rideType, trackType); + for (int currentRotation = 0; currentRotation < 4; currentRotation++) { + gCurrentRotation = currentRotation; + for (int direction = 0; direction < 4; direction++) { + TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); + for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { + newPaintFunction(rideIndex, trackSequence, direction, 48, &mapElement); + } + } + } + + return true; +} + +void testRide(int rideType) { + TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; + if (newPaintGetter == 0) { + return; + } + + printf("- %s (%d)\n", RideNames[rideType], rideType); + for (int trackType = 0; trackType < 256; trackType++) { + if (newPaintGetter(trackType, 0) == NULL) { + continue; + } + + bool success = testTrackElement(rideType, trackType); + + int sequenceCount = getTrackSequenceCount(rideType, trackType); + if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) { + printf(" - %s (%d)\n", FlatTrackNames[trackType], sequenceCount); + } else { + printf(" - %s (%d)\n", TrackNames[trackType], sequenceCount); + } + + } +} + +int main(int argc, const char *argv[]) { + for (int i = 0; i < 91; i++) { + testRide(i); + } + return 0; +} \ No newline at end of file diff --git a/src/ride/coaster/reverser_roller_coaster.c b/src/ride/coaster/reverser_roller_coaster.c index 4644c323de..fbcfd0ca7e 100644 --- a/src/ride/coaster/reverser_roller_coaster.c +++ b/src/ride/coaster/reverser_roller_coaster.c @@ -21,6 +21,7 @@ #include "../../paint/paint.h" #include "../vehicle_paint.h" +#ifndef NO_VEHICLES /** * * rct2: 0x006D4453 @@ -36,3 +37,4 @@ void vehicle_visual_reverser(int x, int imageDirection, int y, int z, rct_vehicl gUnk9DE56C = y; vehicle_visual_default(x, imageDirection, y, z, vehicle, vehicleEntry); } +#endif diff --git a/src/ride/water/river_rapids.c b/src/ride/water/river_rapids.c index fb7d67c7fd..8faa3da43e 100644 --- a/src/ride/water/river_rapids.c +++ b/src/ride/water/river_rapids.c @@ -183,6 +183,7 @@ static const uint32 river_rapids_track_pieces_25_deg_down_to_flat[][2] = { {SPR_RIVER_RAPIDS_25_DEG_DOWN_TO_FLAT_SE_NW, SPR_RIVER_RAPIDS_25_DEG_DOWN_TO_FLAT_FRONT_SE_NW}, }; +#ifndef NO_VEHICLES /** * * rct2: 0x006D5889 @@ -248,6 +249,7 @@ void vehicle_visual_river_rapids(int x, int imageDirection, int y, int z, rct_ve vehicle_visual_splash_effect(z, vehicle, vehicleEntry); } +#endif /** rct2: 0x00757650 */ static void paint_river_rapids_track_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) diff --git a/src/ride/water/splash_boats.c b/src/ride/water/splash_boats.c index 9bb7eb7877..f73c941482 100644 --- a/src/ride/water/splash_boats.c +++ b/src/ride/water/splash_boats.c @@ -21,6 +21,7 @@ #include "../../paint/paint.h" #include "../vehicle_paint.h" +#ifndef NO_VEHICLES /** * * rct2: 0x006D4295 @@ -38,3 +39,4 @@ void vehicle_visual_splash_boats_or_water_coaster(int x, int imageDirection, int gUnk9DE56C = vehicle->y; vehicle_paint(vehicle, imageDirection); } +#endif diff --git a/src/ride/water/submarine_ride.c b/src/ride/water/submarine_ride.c index 6284169b99..f1e4f95f4e 100644 --- a/src/ride/water/submarine_ride.c +++ b/src/ride/water/submarine_ride.c @@ -23,6 +23,7 @@ #include "../../paint/supports.h" #include "../ride_data.h" +#ifndef NO_VEHICLES /** * * rct2: 0x006D44D5 @@ -66,6 +67,7 @@ void vehicle_visual_submarine(int x, int imageDirection, int y, int z, rct_vehic assert(vehicleEntry->effect_visual == 1); } +#endif static void submarine_ride_paint_track_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { From 6e274c6354ba2ea6292751a782c095755622d846 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 24 Aug 2016 13:49:58 +0200 Subject: [PATCH 02/71] Add hooks --- OpenRCT2.xcodeproj/project.pbxproj | 4 + PaintTest/main.c | 160 +++++++++++++++++++++++++---- 2 files changed, 144 insertions(+), 20 deletions(-) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index 45fcaa252d..f92ee74b64 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -106,6 +106,7 @@ C64FDAC51D6DA55E00F259B9 /* compat.c in Sources */ = {isa = PBXBuildFile; fileRef = C64FDAC41D6DA55E00F259B9 /* compat.c */; }; C64FDAC81D6DA72400F259B9 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = C64FDAC71D6DA72400F259B9 /* main.c */; }; C64FDACA1D6DA92D00F259B9 /* data.c in Sources */ = {isa = PBXBuildFile; fileRef = C64FDAC91D6DA92D00F259B9 /* data.c */; }; + C64FDACB1D6DBCC700F259B9 /* hook.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271121CC81B3200D84D28 /* hook.c */; }; C650B2191CCABBDD00B4D91C /* S4Importer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B2151CCABBDD00B4D91C /* S4Importer.cpp */; }; C650B21A1CCABBDD00B4D91C /* tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B2171CCABBDD00B4D91C /* tables.cpp */; }; C650B21C1CCABC4400B4D91C /* ConvertCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B21B1CCABC4400B4D91C /* ConvertCommand.cpp */; }; @@ -1152,6 +1153,8 @@ C64FDAC41D6DA55E00F259B9 /* compat.c */, C64FDAC71D6DA72400F259B9 /* main.c */, C64FDAC91D6DA92D00F259B9 /* data.c */, + C64FDAC91D6DA92D00F259B9 /* data.c */, + C64FDAC71D6DA72400F259B9 /* main.c */, ); path = PaintTest; sourceTree = ""; @@ -2345,6 +2348,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + C64FDACB1D6DBCC700F259B9 /* hook.c in Sources */, C64FDAC31D6DA41000F259B9 /* track_paint.c in Sources */, C64FDAC21D6DA0B800F259B9 /* diagnostic.c in Sources */, C64FDAC01D6D9E3B00F259B9 /* track_data.c in Sources */, diff --git a/PaintTest/main.c b/PaintTest/main.c index c1a17dfa24..b37392d830 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -18,7 +18,7 @@ #include "../src/ride/track_data.h" #include "../src/ride/track_paint.h" #include "../src/interface/viewport.h" - +#include "../src/hook.h" #define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) @@ -50,7 +50,7 @@ paint_struct *sub_98197C( sint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation - ) { +) { printf("sub_98197C(%d)\n", image_id & 0x7FFFF); return NULL; } @@ -62,7 +62,7 @@ paint_struct *sub_98198C( sint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation - ) { +) { printf("sub_98198C(%d)\n", image_id & 0x7FFFF); return NULL; } @@ -74,7 +74,7 @@ paint_struct *sub_98199C( sint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation - ) { +) { printf("sub_98199C(%d)\n", image_id & 0x7FFFF); return NULL; } @@ -119,29 +119,31 @@ int getTrackSequenceCount(uint8 rideType, uint8 trackType) { bool testTrackElement(uint8 rideType, uint8 trackType) { uint8 rideIndex = 0; rct_map_element mapElement = {}; - rct_map_element_track_properties trackProperties = { .type = trackType, .ride_index = 0}; - mapElement.properties.track = trackProperties; - + g_currently_drawn_item = &mapElement; - + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; RCT2_GLOBAL(0x00F44198, uint32) = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; RCT2_GLOBAL(0x00F441A0, uint32) = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000; RCT2_GLOBAL(0x00F441A4, uint32) = COLOUR_BRIGHT_PURPLE << 19 | COLOUR_DARK_BLUE << 24 | 0xA0000000; RCT2_GLOBAL(0x00F4419C, uint32) = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; - - rct_drawpixelinfo dpi = { .zoom_level = 1 }; + + rct_drawpixelinfo dpi = {.zoom_level = 1}; unk_140E9A8 = &dpi; - - rct_vehicle vehicle = { }; - - rct_ride ride = { }; - - rct_ride_entry rideEntry = { }; - + + rct_vehicle vehicle = {}; + rct_ride ride = {}; + + rct_ride_entry rideEntry = {}; + rct_ride_entry_vehicle vehicleEntry = {.base_image_id = 0x70000}; + rideEntry.vehicles[0] = vehicleEntry; + + gRideList[0] = ride; gRideEntries[0] = &rideEntry; - + + int height = 48; + TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; int sequenceCount = getTrackSequenceCount(rideType, trackType); for (int currentRotation = 0; currentRotation < 4; currentRotation++) { @@ -149,11 +151,26 @@ bool testTrackElement(uint8 rideType, uint8 trackType) { for (int direction = 0; direction < 4; direction++) { TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { - newPaintFunction(rideIndex, trackSequence, direction, 48, &mapElement); + //newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + + TRACK_PAINT_FUNCTION **trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; + uint32 *trackDirectionList = (uint32 *) trackTypeList[trackType]; + + // Have to call from this point as it pushes esi and expects callee to pop it + RCT2_CALLPROC_X( + 0x006C4934, + rideType, + (int) trackDirectionList, + direction, + height, + (int) &mapElement, + rideIndex * sizeof(rct_ride), + trackSequence + ); } } } - + return true; } @@ -181,6 +198,109 @@ void testRide(int rideType) { } } +static void log_drawing_call(const char functionName[], registers regs, rct_xyz16 *bounds) { + + uint32 imageId = regs.ebx & 0x7FFFF; + + + printf("%s\t%d\t%d\t%d\t%d\t%d\t%d\t", functionName, imageId, regs.al, regs.cl, regs.di, regs.si, regs.ah); + + printf("%d", regs.dx); + + if (bounds != NULL) { + printf("\t%d\t%d\t%d", bounds->x, bounds->y, bounds->z); + } else { + printf("\t\t\t"); + } + + if ((regs.ebp & 0x03) != get_current_rotation()) { + printf("\t%d", regs.ebp & 0x03); + } else { + printf("\tget_current_rotation()"); + } + + printf("\n"); +} + +static int intercept_draw_6c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp) { + registers regs = {.eax =eax, .ebx = ebx, .ecx = ecx, .edx = edx, .esi = esi, .edi = edi, .ebp = ebp}; + if ((ebp & 0x03) != get_current_rotation()) { + // Log error + log_error("Ebp is different from current rotation"); + } + + log_drawing_call("sub_98196C", regs, NULL); + return (int) sub_98196C(ebx, regs.al, regs.cl, regs.di, regs.si, regs.ah, regs.dx, regs.ebp & 0x03); +} + +static int intercept_draw_7c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp) { + registers regs = {.eax =eax, .ebx = ebx, .ecx = ecx, .edx = edx, .esi = esi, .edi = edi, .ebp = ebp}; + if ((ebp & 0x03) != get_current_rotation()) { + // Log error + log_error("Ebp is different from current rotation"); + } + + rct_xyz16 boundOffset = {RCT2_GLOBAL(0x009DEA52, sint16), RCT2_GLOBAL(0x009DEA54, sint16), RCT2_GLOBAL(0x009DEA56, sint16)}; + + log_drawing_call("sub_98197C", regs, &boundOffset); + + return (int) sub_98197C(ebx, regs.al, regs.cl, regs.di, regs.si, regs.ah, regs.dx, boundOffset.x, boundOffset.y, boundOffset.z, regs.ebp & 0x03); +} + +static int intercept_draw_9c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp) { + registers regs = {.eax =eax, .ebx = ebx, .ecx = ecx, .edx = edx, .esi = esi, .edi = edi, .ebp = ebp}; + if ((ebp & 0x03) != get_current_rotation()) { + // Log error + log_error("Ebp is different from current rotation"); + } + + rct_xyz16 boundOffset = {RCT2_GLOBAL(0x009DEA52, sint16), RCT2_GLOBAL(0x009DEA54, sint16), RCT2_GLOBAL(0x009DEA56, sint16)}; + + log_drawing_call("sub_98199C", regs, &boundOffset); + + return (int) sub_98199C(ebx, regs.al, regs.cl, regs.di, regs.si, regs.ah, regs.dx, boundOffset.x, boundOffset.y, boundOffset.z, regs.ebp & 0x03); +} + +static void intercept_wooden_a_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { + registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; +} + +static void intercept_wooden_b_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { + registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; +} + +static void intercept_metal_a_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { + registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; +} + +static void intercept_metal_b_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { + registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; +} + + +void initHooks() { + addhook(0x00686806, (int) intercept_draw_7c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + addhook(0x006869B2, (int) intercept_draw_7c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + addhook(0x00686B6F, (int) intercept_draw_7c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + addhook(0x00686D31, (int) intercept_draw_7c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + + addhook(0x006861AC, (int) intercept_draw_6c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + addhook(0x00686337, (int) intercept_draw_6c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + addhook(0x006864D0, (int) intercept_draw_6c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + addhook(0x0068666B, (int) intercept_draw_6c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + + addhook(0x006874B0, (int) intercept_draw_9c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + addhook(0x00687618, (int) intercept_draw_9c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + addhook(0x0068778C, (int) intercept_draw_9c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + addhook(0x00687902, (int) intercept_draw_9c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); + + addhook(0x006629BC, (int) intercept_wooden_a_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, 0); + addhook(0x00662D5C, (int) intercept_wooden_b_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, 0); + + addhook(0x00663105, (int) intercept_metal_a_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, 0); + addhook(0x00663584, (int) intercept_metal_b_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, 0); +} + int main(int argc, const char *argv[]) { for (int i = 0; i < 91; i++) { testRide(i); From 1e8464f8b740b117b34e08ded9ea0d7e6cf29a28 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 24 Aug 2016 14:12:06 +0200 Subject: [PATCH 03/71] [temp] skip chairlift stations --- PaintTest/main.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index b37392d830..8722f84212 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -116,7 +116,14 @@ int getTrackSequenceCount(uint8 rideType, uint8 trackType) { return sequenceCount; } -bool testTrackElement(uint8 rideType, uint8 trackType) { +bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { + if (rideType == RIDE_TYPE_CHAIRLIFT) { + if (trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION || trackType == TRACK_ELEM_END_STATION) { + // These rides chechk neighbouring tiles for tracks + *error = "Skipped"; + return false; + } + } uint8 rideIndex = 0; rct_map_element mapElement = {}; @@ -186,15 +193,22 @@ void testRide(int rideType) { continue; } - bool success = testTrackElement(rideType, trackType); int sequenceCount = getTrackSequenceCount(rideType, trackType); if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) { - printf(" - %s (%d)\n", FlatTrackNames[trackType], sequenceCount); + printf(" - %s (%d)", FlatTrackNames[trackType], sequenceCount); } else { - printf(" - %s (%d)\n", TrackNames[trackType], sequenceCount); + printf(" - %s (%d)", TrackNames[trackType], sequenceCount); } + utf8string error; + bool success = testTrackElement(rideType, trackType, &error); + + if (success == false) { + printf(" FAILED!\n %s", error); + } + printf("\n"); + } } From 1b1b26aeb8f2ac7956778b5a6b8c620d60626c67 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 28 Aug 2016 19:15:54 +0200 Subject: [PATCH 04/71] Hack cmakelists to compile test project --- CMakeLists.txt | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 943d9eb082..ebc8ba08b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,14 +210,10 @@ set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG=${DEBUG_LEVEL}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}") -# include lib -include_directories("lib/") # add source files -file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "src/*.h" "src/*.hpp") -if (APPLE) - file(GLOB_RECURSE ORCT2_MM_SOURCES "src/*.m") - set_source_files_properties(${ORCT2_MM_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c -fmodules") -endif (APPLE) +file(GLOB_RECURSE ORCT2_SOURCES "PaintTest/*.c" "PaintTest/*.cpp" "PaintTest/*.h" "PaintTest/*.hpp" "src/ride/*/*.c" "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_VEHICLES") + if (APPLE AND NOT USE_MMAP) set(PIE_FLAG "-fno-pie") @@ -319,12 +315,6 @@ else (WIN32) if (NOT APPLE AND NOT USE_MMAP) add_dependencies(${PROJECT} linkable_sections) endif () - add_custom_command( - OUTPUT g2.dat - COMMAND ./openrct2 sprite build ${CMAKE_BINARY_DIR}/g2.dat ${CMAKE_CURRENT_SOURCE_DIR}/resources/g2/ - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - add_custom_target(g2 DEPENDS ${PROJECT} g2.dat) endif (WIN32) if (UNIX AND NOT APPLE) From 70491d06b372291cefeac0e06ff5aa752789e0f2 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 28 Aug 2016 19:16:19 +0200 Subject: [PATCH 05/71] Log drawing function calls --- PaintTest/main.c | 144 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 106 insertions(+), 38 deletions(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 8722f84212..2dbb316bc0 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -24,10 +24,33 @@ #define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) #define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) + +#define ANSI_COLOR_RED "\x1b[31m" +#define ANSI_COLOR_GREEN "\x1b[32m" +#define ANSI_COLOR_YELLOW "\x1b[33m" +#define ANSI_COLOR_BLUE "\x1b[34m" +#define ANSI_COLOR_MAGENTA "\x1b[35m" +#define ANSI_COLOR_CYAN "\x1b[36m" +#define ANSI_COLOR_RESET "\x1b[0m" + extern const utf8string RideNames[91]; extern const utf8string TrackNames[256]; extern const utf8string FlatTrackNames[256]; +typedef struct +{ + utf8string name; + uint32 image_id; + rct_xy16 offset; + rct_xyz16 bound_box_length; + sint16 z_offset; + rct_xyz16 bound_box_offset; + uint32 rotation; +} function_call; + +static uint8 callCount; +static function_call calls[256]; + bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y) { return false; } @@ -39,7 +62,18 @@ paint_struct *sub_98196C( sint16 z_offset, uint32 rotation ) { - printf("sub_98196C(%d)\n", image_id & 0x7FFFF); + function_call call = { + .name = "sub_98196C", + .image_id = image_id, + .offset = {x_offset, y_offset}, + .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, + .z_offset = z_offset, + .rotation = rotation + }; + + calls[callCount] = call; + callCount++; + return NULL; } @@ -51,7 +85,19 @@ paint_struct *sub_98197C( sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation ) { - printf("sub_98197C(%d)\n", image_id & 0x7FFFF); + function_call call = { + .name = "sub_98197C", + .image_id = image_id, + .offset = {x_offset, y_offset}, + .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, + .bound_box_offset = {bound_box_offset_x, bound_box_offset_y, bound_box_offset_z}, + .z_offset = z_offset, + .rotation = rotation + }; + + calls[callCount] = call; + callCount++; + return NULL; } @@ -63,7 +109,19 @@ paint_struct *sub_98198C( sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation ) { - printf("sub_98198C(%d)\n", image_id & 0x7FFFF); + function_call call = { + .name = "sub_98198C", + .image_id = image_id, + .offset = {x_offset, y_offset}, + .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, + .bound_box_offset = {bound_box_offset_x, bound_box_offset_y, bound_box_offset_z}, + .z_offset = z_offset, + .rotation = rotation + }; + + calls[callCount] = call; + callCount++; + return NULL; } @@ -75,7 +133,19 @@ paint_struct *sub_98199C( sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation ) { - printf("sub_98199C(%d)\n", image_id & 0x7FFFF); + function_call call = { + .name = "sub_98199C", + .image_id = image_id, + .offset = {x_offset, y_offset}, + .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, + .bound_box_offset = {bound_box_offset_x, bound_box_offset_y, bound_box_offset_z}, + .z_offset = z_offset, + .rotation = rotation + }; + + calls[callCount] = call; + callCount++; + return NULL; } @@ -158,7 +228,9 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { for (int direction = 0; direction < 4; direction++) { TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { - //newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + + callCount = 0; + bzero(calls, sizeof(calls)); TRACK_PAINT_FUNCTION **trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; uint32 *trackDirectionList = (uint32 *) trackTypeList[trackType]; @@ -174,6 +246,27 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { rideIndex * sizeof(rct_ride), trackSequence ); + // segment heights + // tunnels + + const uint8 oldCallCount = callCount; + const function_call oldCalls[256]; + bcopy(oldCalls, calls, sizeof(calls)); + + callCount = 0; + + newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + + const uint8 newCallCount = callCount; + const function_call newCalls[256]; + bcopy(newCalls, calls, sizeof(calls)); + + if (newCallCount != oldCallCount) { + // TODO: array with errors? + sprintf(*error, "Call counts don't match [direction:%d trackSequence:%d]", direction, trackSequence); + return false; + } + } } } @@ -193,7 +286,12 @@ void testRide(int rideType) { continue; } + utf8string error = malloc(256); + bool success = testTrackElement(rideType, trackType, &error); + if (!success) { + printf(ANSI_COLOR_RED); + } int sequenceCount = getTrackSequenceCount(rideType, trackType); if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) { printf(" - %s (%d)", FlatTrackNames[trackType], sequenceCount); @@ -201,41 +299,15 @@ void testRide(int rideType) { printf(" - %s (%d)", TrackNames[trackType], sequenceCount); } - utf8string error; - bool success = testTrackElement(rideType, trackType, &error); - if (success == false) { + if (!success) { printf(" FAILED!\n %s", error); } - printf("\n"); + printf(ANSI_COLOR_RESET "\n"); } } -static void log_drawing_call(const char functionName[], registers regs, rct_xyz16 *bounds) { - - uint32 imageId = regs.ebx & 0x7FFFF; - - - printf("%s\t%d\t%d\t%d\t%d\t%d\t%d\t", functionName, imageId, regs.al, regs.cl, regs.di, regs.si, regs.ah); - - printf("%d", regs.dx); - - if (bounds != NULL) { - printf("\t%d\t%d\t%d", bounds->x, bounds->y, bounds->z); - } else { - printf("\t\t\t"); - } - - if ((regs.ebp & 0x03) != get_current_rotation()) { - printf("\t%d", regs.ebp & 0x03); - } else { - printf("\tget_current_rotation()"); - } - - printf("\n"); -} - static int intercept_draw_6c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp) { registers regs = {.eax =eax, .ebx = ebx, .ecx = ecx, .edx = edx, .esi = esi, .edi = edi, .ebp = ebp}; if ((ebp & 0x03) != get_current_rotation()) { @@ -243,7 +315,6 @@ static int intercept_draw_6c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uin log_error("Ebp is different from current rotation"); } - log_drawing_call("sub_98196C", regs, NULL); return (int) sub_98196C(ebx, regs.al, regs.cl, regs.di, regs.si, regs.ah, regs.dx, regs.ebp & 0x03); } @@ -256,8 +327,6 @@ static int intercept_draw_7c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uin rct_xyz16 boundOffset = {RCT2_GLOBAL(0x009DEA52, sint16), RCT2_GLOBAL(0x009DEA54, sint16), RCT2_GLOBAL(0x009DEA56, sint16)}; - log_drawing_call("sub_98197C", regs, &boundOffset); - return (int) sub_98197C(ebx, regs.al, regs.cl, regs.di, regs.si, regs.ah, regs.dx, boundOffset.x, boundOffset.y, boundOffset.z, regs.ebp & 0x03); } @@ -270,8 +339,6 @@ static int intercept_draw_9c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uin rct_xyz16 boundOffset = {RCT2_GLOBAL(0x009DEA52, sint16), RCT2_GLOBAL(0x009DEA54, sint16), RCT2_GLOBAL(0x009DEA56, sint16)}; - log_drawing_call("sub_98199C", regs, &boundOffset); - return (int) sub_98199C(ebx, regs.al, regs.cl, regs.di, regs.si, regs.ah, regs.dx, boundOffset.x, boundOffset.y, boundOffset.z, regs.ebp & 0x03); } @@ -316,6 +383,7 @@ void initHooks() { } int main(int argc, const char *argv[]) { + initHooks(); for (int i = 0; i < 91; i++) { testRide(i); } From 8603f785e6c400a7f9e292d7b05eb076bc6ecc7b Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 28 Aug 2016 20:03:04 +0200 Subject: [PATCH 06/71] Track support drawing --- PaintTest/main.c | 155 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 121 insertions(+), 34 deletions(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 2dbb316bc0..7680e9dcfb 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -37,15 +37,39 @@ extern const utf8string RideNames[91]; extern const utf8string TrackNames[256]; extern const utf8string FlatTrackNames[256]; +enum +{ + PAINT_98196C, + PAINT_98197C, + PAINT_98198C, + PAINT_98199C, + + SUPPORTS_METAL_A, + SUPPORTS_METAL_B, + SUPPORTS_WOOD_A, + SUPPORTS_WOOD_B, +}; + typedef struct { - utf8string name; - uint32 image_id; - rct_xy16 offset; - rct_xyz16 bound_box_length; - sint16 z_offset; - rct_xyz16 bound_box_offset; - uint32 rotation; + uint8 function; + struct paint + { + uint32 image_id; + rct_xy16 offset; + rct_xyz16 bound_box_length; + sint16 z_offset; + rct_xyz16 bound_box_offset; + uint32 rotation; + } paint; + struct supports + { + int type; + uint8 segment; + int special; + int height; + uint32 colour_flags; + } supports; } function_call; static uint8 callCount; @@ -63,12 +87,14 @@ paint_struct *sub_98196C( uint32 rotation ) { function_call call = { - .name = "sub_98196C", - .image_id = image_id, - .offset = {x_offset, y_offset}, - .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, - .z_offset = z_offset, - .rotation = rotation + .function = PAINT_98196C, + .paint = { + .image_id = image_id, + .offset = {x_offset, y_offset}, + .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, + .z_offset = z_offset, + .rotation = rotation + }, }; calls[callCount] = call; @@ -86,13 +112,15 @@ paint_struct *sub_98197C( uint32 rotation ) { function_call call = { - .name = "sub_98197C", - .image_id = image_id, - .offset = {x_offset, y_offset}, - .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, - .bound_box_offset = {bound_box_offset_x, bound_box_offset_y, bound_box_offset_z}, - .z_offset = z_offset, - .rotation = rotation + .function = PAINT_98197C, + .paint = { + .image_id = image_id, + .offset = {x_offset, y_offset}, + .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, + .bound_box_offset = {bound_box_offset_x, bound_box_offset_y, bound_box_offset_z}, + .z_offset = z_offset, + .rotation = rotation, + }, }; calls[callCount] = call; @@ -110,13 +138,15 @@ paint_struct *sub_98198C( uint32 rotation ) { function_call call = { - .name = "sub_98198C", - .image_id = image_id, - .offset = {x_offset, y_offset}, - .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, - .bound_box_offset = {bound_box_offset_x, bound_box_offset_y, bound_box_offset_z}, - .z_offset = z_offset, - .rotation = rotation + .function = PAINT_98198C, + .paint = { + .image_id = image_id, + .offset = {x_offset, y_offset}, + .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, + .bound_box_offset = {bound_box_offset_x, bound_box_offset_y, bound_box_offset_z}, + .z_offset = z_offset, + .rotation = rotation, + }, }; calls[callCount] = call; @@ -134,13 +164,15 @@ paint_struct *sub_98199C( uint32 rotation ) { function_call call = { - .name = "sub_98199C", - .image_id = image_id, - .offset = {x_offset, y_offset}, - .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, - .bound_box_offset = {bound_box_offset_x, bound_box_offset_y, bound_box_offset_z}, - .z_offset = z_offset, - .rotation = rotation + .function = PAINT_98199C, + .paint = { + .image_id = image_id, + .offset = {x_offset, y_offset}, + .bound_box_length = {bound_box_length_x, bound_box_length_y, bound_box_length_z}, + .bound_box_offset = {bound_box_offset_x, bound_box_offset_y, bound_box_offset_z}, + .z_offset = z_offset, + .rotation = rotation, + }, }; calls[callCount] = call; @@ -150,18 +182,69 @@ paint_struct *sub_98199C( } bool wooden_a_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags, bool *underground) { + + function_call call = { + .function = SUPPORTS_WOOD_A, + .supports = { + .type = supportType, + .special = special, + .height = height, + .colour_flags = imageColourFlags, + } + }; + + calls[callCount] = call; + callCount++; return false; } bool wooden_b_supports_paint_setup(int supportType, int special, int height, uint32 imageColourFlags) { + + function_call call = { + .function = SUPPORTS_WOOD_B, + .supports = { + .type = supportType, + .special = special, + .height = height, + .colour_flags = imageColourFlags, + } + }; + + calls[callCount] = call; + callCount++; return false; } bool metal_a_supports_paint_setup(int supportType, int segment, int special, int height, uint32 imageColourFlags) { + + function_call call = { + .function = SUPPORTS_METAL_A, + .supports = { + .type = supportType, + .segment = segment, + .special = special, + .height = height, + .colour_flags = imageColourFlags, + } + }; + + calls[callCount] = call; + callCount++; return false; } bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, int height, uint32 imageColourFlags) { + + function_call call = { + .function = SUPPORTS_METAL_B, + .supports = { + .type = supportType, + .segment = segment, + .special = special, + .height = height, + .colour_flags = imageColourFlags, + } + }; return false; } @@ -344,18 +427,22 @@ static int intercept_draw_9c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uin static void intercept_wooden_a_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; + wooden_a_supports_paint_setup(regs.edi, (sint16) regs.ax, regs.dx, (uint32) regs.ebp, NULL); } static void intercept_wooden_b_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; + wooden_b_supports_paint_setup(regs.edi, (sint16) regs.ax, regs.dx, (uint32) regs.ebp); } static void intercept_metal_a_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; + metal_a_supports_paint_setup(regs.edi, regs.ebx, (sint16) regs.ax, regs.dx, (uint32) regs.ebp); } static void intercept_metal_b_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; + metal_b_supports_paint_setup(regs.edi, regs.ebx, (sint16) regs.ax, regs.dx, (uint32) regs.ebp); } From afd85a7df62926a95d134b006ad5efeec20e04b4 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 28 Aug 2016 20:03:53 +0200 Subject: [PATCH 07/71] Show actual/expected count --- PaintTest/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 7680e9dcfb..1f9b3a4028 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -346,7 +346,7 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { if (newCallCount != oldCallCount) { // TODO: array with errors? - sprintf(*error, "Call counts don't match [direction:%d trackSequence:%d]", direction, trackSequence); + sprintf(*error, "Call counts don't match (was %d, expected %d) [direction:%d trackSequence:%d]", newCallCount, oldCallCount, direction, trackSequence); return false; } From 807c5fcb4b5c83c541f5d1fe3b5d02639b62902f Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 28 Aug 2016 22:07:21 +0200 Subject: [PATCH 08/71] Dump offending paint lists --- PaintTest/main.c | 195 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 181 insertions(+), 14 deletions(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 1f9b3a4028..048e510e72 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -33,6 +33,11 @@ #define ANSI_COLOR_CYAN "\x1b[36m" #define ANSI_COLOR_RESET "\x1b[0m" +static const uint32 PALETTE_98 = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; +static const uint32 PALETTE_9C = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; +static const uint32 PALETTE_A0 = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000; +static const uint32 PALETTE_A4 = COLOUR_BRIGHT_PURPLE << 19 | COLOUR_DARK_BLUE << 24 | 0xA0000000; + extern const utf8string RideNames[91]; extern const utf8string TrackNames[256]; extern const utf8string FlatTrackNames[256]; @@ -73,6 +78,7 @@ typedef struct } function_call; static uint8 callCount; +static bool assertFunctionCallEquals(function_call expected, function_call actual); static function_call calls[256]; bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y) { @@ -245,9 +251,163 @@ bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, i .colour_flags = imageColourFlags, } }; + + calls[callCount] = call; + callCount++; return false; } +static bool assertFunctionCallEquals(function_call expected, function_call actual) { + if (expected.function != actual.function) { + return false; + } + + uint8 function = expected.function; + + if (function == SUPPORTS_WOOD_A || function == SUPPORTS_WOOD_B) { + if (expected.supports.type != actual.supports.type) return false; + if (expected.supports.special != actual.supports.special) return false; + if (expected.supports.height != actual.supports.height) return false; + if (expected.supports.colour_flags != actual.supports.colour_flags) return false; + + return true; + } + + if (function == SUPPORTS_METAL_A || function == SUPPORTS_METAL_B) { + if (expected.supports.type != actual.supports.type) return false; + if (expected.supports.segment != actual.supports.segment) return false; + if (expected.supports.special != actual.supports.special) return false; + if (expected.supports.height != actual.supports.height) return false; + if (expected.supports.colour_flags != actual.supports.colour_flags) return false; + + return true; + } + + if (expected.paint.image_id != actual.paint.image_id) return false; + if (expected.paint.offset.x != actual.paint.offset.x) return false; + if (expected.paint.offset.y != actual.paint.offset.y) return false; + if (expected.paint.bound_box_length.x != actual.paint.bound_box_length.x) return false; + if (expected.paint.bound_box_length.y != actual.paint.bound_box_length.y) return false; + if (expected.paint.bound_box_length.z != actual.paint.bound_box_length.z) return false; + if (function != PAINT_98196C) { + if (expected.paint.bound_box_offset.x != actual.paint.bound_box_offset.x) return false; + if (expected.paint.bound_box_offset.y != actual.paint.bound_box_offset.y) return false; + if (expected.paint.bound_box_offset.z != actual.paint.bound_box_offset.z) return false; + } + if (expected.paint.z_offset != actual.paint.z_offset) return false; + if (expected.paint.rotation != actual.paint.rotation) return false; + + return true; +} + +static bool assertFunctionCallArrayEquals(function_call expected[], uint8 expectedCount, function_call actual[], uint8 actualCount) { + if (expectedCount != actualCount) { + return false; + } + + for (int i = 0; i < expectedCount; i++) { + function_call expectedCall = expected[i]; + function_call actualCall = actual[i]; + + if (!assertFunctionCallEquals(expectedCall, actualCall)) { + return false; + } + } + + return true; +} + +static void printImageId(uint32 input, utf8string *out) { + uint32 image = input & 0x7FFFF; + uint32 palette = input & ~0x7FFFF; + + utf8string paletteName; + if (palette == PALETTE_98)paletteName = "PALETTE_98"; + else if (palette == PALETTE_9C)paletteName = "PALETTE_9C"; + else if (palette == PALETTE_A0)paletteName = "PALETTE_A0"; + else if (palette == PALETTE_A4)paletteName = "PALETTE_A4"; + else { + paletteName = malloc(16); + sprintf(paletteName, "0x%08X", palette); + } + + if (image == 0) { + sprintf(*out, "%s", paletteName); + } else if(image & 0x70000) { + sprintf(*out, "%s | vehicle.base_image_id + %d", paletteName, image & ~0x70000); + } else { + sprintf(*out, "%s | %d", paletteName, image); + } +} + +static void printFunctionCall(utf8string *out, function_call call) { + utf8string imageId = malloc(64); + printImageId(call.supports.colour_flags, &imageId); + switch (call.function) { + case SUPPORTS_WOOD_A: + sprintf(*out, "wooden_a_supports_paint_setup(%d, %d, %d, %s)", call.supports.type, call.supports.special, call.supports.height, imageId); + return; + case SUPPORTS_WOOD_B: + sprintf(*out, "wooden_a_supports_paint_setup(%d, %d, %d, %s)", call.supports.type, call.supports.special, call.supports.height, imageId); + return; + + case SUPPORTS_METAL_A: + sprintf(*out, "metal_a_supports_paint_setup(%d, %d, %d, %d, %s)", call.supports.type, call.supports.segment, call.supports.special, call.supports.height, imageId); + return; + case SUPPORTS_METAL_B: + sprintf(*out, "metal_b_supports_paint_setup(%d, %d, %d, %d, %s)", call.supports.type, call.supports.segment, call.supports.special, call.supports.height, imageId); + return; + } + + utf8string name; + switch (call.function) { + case PAINT_98196C: + name = "sub_98196C"; + break; + case PAINT_98197C: + name = "sub_98197C"; + break; + case PAINT_98198C: + name = "sub_98198C"; + break; + case PAINT_98199C: + name = "sub_98199C"; + break; + } + + int strlen; + + printImageId(call.paint.image_id, &imageId); + strlen = sprintf( + *out, + "%s(%s, %d, %d, %d, %d, %d, %d, ", + name, + imageId, + call.paint.offset.x, call.paint.offset.y, + call.paint.bound_box_length.x, call.paint.bound_box_length.y, call.paint.bound_box_length.z, + call.paint.z_offset, + NULL + ); + + if (call.function != PAINT_98196C) { + strlen += sprintf( + *out + strlen, + "%d, %d, %d, ", + call.paint.bound_box_offset.x, call.paint.bound_box_offset.y, call.paint.bound_box_offset.z + ); + } + + sprintf(*out + strlen, "%d)", call.paint.rotation); +} + +static void printFunctionCallArray(utf8string *out, function_call calls[], uint8 count) { + for (int i = 0; i < count; i++) { + utf8string callOut = malloc(128); + printFunctionCall(&callOut, calls[i]); + sprintf(*out + strlen(*out), "%s\n", callOut); + } +} + int getTrackSequenceCount(uint8 rideType, uint8 trackType) { int sequenceCount = 0; const rct_preview_track **trackBlocks; @@ -283,10 +443,10 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { g_currently_drawn_item = &mapElement; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; - RCT2_GLOBAL(0x00F44198, uint32) = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; - RCT2_GLOBAL(0x00F441A0, uint32) = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000; - RCT2_GLOBAL(0x00F441A4, uint32) = COLOUR_BRIGHT_PURPLE << 19 | COLOUR_DARK_BLUE << 24 | 0xA0000000; - RCT2_GLOBAL(0x00F4419C, uint32) = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; + RCT2_GLOBAL(0x00F44198, uint32) = PALETTE_98; + RCT2_GLOBAL(0x00F441A0, uint32) = PALETTE_A0; + RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; + RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; rct_drawpixelinfo dpi = {.zoom_level = 1}; unk_140E9A8 = &dpi; @@ -313,7 +473,7 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { callCount = 0; - bzero(calls, sizeof(calls)); + memset(&calls, sizeof(calls), 0); TRACK_PAINT_FUNCTION **trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; uint32 *trackDirectionList = (uint32 *) trackTypeList[trackType]; @@ -332,21 +492,28 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { // segment heights // tunnels - const uint8 oldCallCount = callCount; - const function_call oldCalls[256]; - bcopy(oldCalls, calls, sizeof(calls)); + uint8 oldCallCount = callCount; + function_call oldCalls[256]; + memcpy(&oldCalls, &calls, sizeof(calls)); callCount = 0; newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); - const uint8 newCallCount = callCount; - const function_call newCalls[256]; - bcopy(newCalls, calls, sizeof(calls)); + uint8 newCallCount = callCount; + function_call newCalls[256]; + memcpy(&newCalls, &calls, sizeof(calls)); - if (newCallCount != oldCallCount) { - // TODO: array with errors? + if (!assertFunctionCallArrayEquals(oldCalls, oldCallCount, newCalls, newCallCount)) { + utf8string diff = malloc(1024); + + sprintf(diff, "<<< EXPECTED\n"); + printFunctionCallArray(&diff, oldCalls, oldCallCount); + sprintf(diff + strlen(diff), "====\n"); + printFunctionCallArray(&diff, newCalls, newCallCount); + sprintf(diff + strlen(diff), ">>> ACTUAL\n"); sprintf(*error, "Call counts don't match (was %d, expected %d) [direction:%d trackSequence:%d]", newCallCount, oldCallCount, direction, trackSequence); + sprintf(*error + strlen(*error), "\n%s", diff); return false; } @@ -369,7 +536,7 @@ void testRide(int rideType) { continue; } - utf8string error = malloc(256); + utf8string error = malloc(1024); bool success = testTrackElement(rideType, trackType, &error); if (!success) { From 13b32e8044c111cbd973954878fb7c297d8de4ee Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 29 Aug 2016 19:32:39 +0200 Subject: [PATCH 09/71] Free after malloc --- PaintTest/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 048e510e72..6f5175dbc3 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -321,23 +321,29 @@ static void printImageId(uint32 input, utf8string *out) { uint32 image = input & 0x7FFFF; uint32 palette = input & ~0x7FFFF; + bool allocated = false; utf8string paletteName; if (palette == PALETTE_98)paletteName = "PALETTE_98"; else if (palette == PALETTE_9C)paletteName = "PALETTE_9C"; else if (palette == PALETTE_A0)paletteName = "PALETTE_A0"; else if (palette == PALETTE_A4)paletteName = "PALETTE_A4"; else { + allocated = true; paletteName = malloc(16); sprintf(paletteName, "0x%08X", palette); } if (image == 0) { sprintf(*out, "%s", paletteName); - } else if(image & 0x70000) { + } else if (image & 0x70000) { sprintf(*out, "%s | vehicle.base_image_id + %d", paletteName, image & ~0x70000); } else { sprintf(*out, "%s | %d", paletteName, image); } + + if (allocated) { + free(paletteName); + } } static void printFunctionCall(utf8string *out, function_call call) { @@ -405,6 +411,7 @@ static void printFunctionCallArray(utf8string *out, function_call calls[], uint8 utf8string callOut = malloc(128); printFunctionCall(&callOut, calls[i]); sprintf(*out + strlen(*out), "%s\n", callOut); + free(callOut); } } @@ -514,6 +521,8 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { sprintf(diff + strlen(diff), ">>> ACTUAL\n"); sprintf(*error, "Call counts don't match (was %d, expected %d) [direction:%d trackSequence:%d]", newCallCount, oldCallCount, direction, trackSequence); sprintf(*error + strlen(*error), "\n%s", diff); + + free(diff); return false; } @@ -553,6 +562,7 @@ void testRide(int rideType) { if (!success) { printf(" FAILED!\n %s", error); } + free(error); printf(ANSI_COLOR_RESET "\n"); } From f7302395bb02aa4a1353175dfee589903345e07c Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 29 Aug 2016 19:33:05 +0200 Subject: [PATCH 10/71] set ctxAboveGround --- PaintTest/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/PaintTest/main.c b/PaintTest/main.c index 6f5175dbc3..c144af953a 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -478,6 +478,7 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { for (int direction = 0; direction < 4; direction++) { TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { + RCT2_GLOBAL(0x9DE57C, bool) = true; // Above surface callCount = 0; memset(&calls, sizeof(calls), 0); From 1349219e013d540e2d57db905f0ec2ef2b2e8b7d Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 29 Aug 2016 19:37:47 +0200 Subject: [PATCH 11/71] revert free --- PaintTest/main.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index c144af953a..1f7c060f77 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -328,7 +328,6 @@ static void printImageId(uint32 input, utf8string *out) { else if (palette == PALETTE_A0)paletteName = "PALETTE_A0"; else if (palette == PALETTE_A4)paletteName = "PALETTE_A4"; else { - allocated = true; paletteName = malloc(16); sprintf(paletteName, "0x%08X", palette); } @@ -340,10 +339,6 @@ static void printImageId(uint32 input, utf8string *out) { } else { sprintf(*out, "%s | %d", paletteName, image); } - - if (allocated) { - free(paletteName); - } } static void printFunctionCall(utf8string *out, function_call call) { @@ -411,7 +406,6 @@ static void printFunctionCallArray(utf8string *out, function_call calls[], uint8 utf8string callOut = malloc(128); printFunctionCall(&callOut, calls[i]); sprintf(*out + strlen(*out), "%s\n", callOut); - free(callOut); } } @@ -523,7 +517,6 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { sprintf(*error, "Call counts don't match (was %d, expected %d) [direction:%d trackSequence:%d]", newCallCount, oldCallCount, direction, trackSequence); sprintf(*error + strlen(*error), "\n%s", diff); - free(diff); return false; } @@ -563,7 +556,7 @@ void testRide(int rideType) { if (!success) { printf(" FAILED!\n %s", error); } - free(error); + printf(ANSI_COLOR_RESET "\n"); } From 124905b2a7f7ad56c095fd5d1b0c3ae00b200440 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 29 Aug 2016 19:58:08 +0200 Subject: [PATCH 12/71] Canonicalize tracktype before comparing --- PaintTest/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/PaintTest/main.c b/PaintTest/main.c index 1f7c060f77..92c11c318f 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -257,7 +257,19 @@ bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, i return false; } +static void canonicalizeFunctionCall(function_call *call) { + if (call->function != PAINT_98197C) return; + if (call->paint.offset.x != call->paint.bound_box_offset.x) return; + if (call->paint.offset.y != call->paint.bound_box_offset.y) return; + if (call->paint.z_offset != call->paint.bound_box_offset.z) return; + + call->function = PAINT_98196C; +} + static bool assertFunctionCallEquals(function_call expected, function_call actual) { + canonicalizeFunctionCall(&actual); + canonicalizeFunctionCall(&expected); + if (expected.function != actual.function) { return false; } From 820903472ee42e376254c2ab5ae50a6330a8a6d8 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 29 Aug 2016 19:58:43 +0200 Subject: [PATCH 13/71] set TrackType on mapelement --- PaintTest/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/PaintTest/main.c b/PaintTest/main.c index 92c11c318f..62502af9ac 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -452,6 +452,7 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { } uint8 rideIndex = 0; rct_map_element mapElement = {}; + mapElement.properties.track.type = trackType; g_currently_drawn_item = &mapElement; From 1b25dc52740030d5b3f42d8ee6725c2adbc829a8 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 31 Aug 2016 14:02:11 +0200 Subject: [PATCH 14/71] Improve paint testing --- PaintTest/main.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 62502af9ac..d227cf3768 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -16,7 +16,6 @@ #include "../src/paint/paint.h" #include "../src/ride/track_data.h" -#include "../src/ride/track_paint.h" #include "../src/interface/viewport.h" #include "../src/hook.h" @@ -485,7 +484,9 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { for (int direction = 0; direction < 4; direction++) { TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { - RCT2_GLOBAL(0x9DE57C, bool) = true; // Above surface + RCT2_GLOBAL(0x009DE56A, sint16) = 64; // x + RCT2_GLOBAL(0x009DE56E, sint16) = 64; // y + RCT2_GLOBAL(0x9DE57C, bool) = true; // Above surface callCount = 0; memset(&calls, sizeof(calls), 0); @@ -609,24 +610,32 @@ static int intercept_draw_9c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uin return (int) sub_98199C(ebx, regs.al, regs.cl, regs.di, regs.si, regs.ah, regs.dx, boundOffset.x, boundOffset.y, boundOffset.z, regs.ebp & 0x03); } -static void intercept_wooden_a_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { +static uint32 intercept_wooden_a_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; wooden_a_supports_paint_setup(regs.edi, (sint16) regs.ax, regs.dx, (uint32) regs.ebp, NULL); + + return 0; } -static void intercept_wooden_b_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { +static uint32 intercept_wooden_b_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; wooden_b_supports_paint_setup(regs.edi, (sint16) regs.ax, regs.dx, (uint32) regs.ebp); + + return 0; } -static void intercept_metal_a_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { +static uint32 intercept_metal_a_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; metal_a_supports_paint_setup(regs.edi, regs.ebx, (sint16) regs.ax, regs.dx, (uint32) regs.ebp); + + return 0; } -static void intercept_metal_b_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { +static uint32 intercept_metal_b_supports(uint32 eax, uint32 ebx, uint32 edx, uint32 edi, uint32 ebp) { registers regs = {.eax =eax, .ebx = ebx, .edx = edx, .edi = edi, .ebp = ebp}; metal_b_supports_paint_setup(regs.edi, regs.ebx, (sint16) regs.ax, regs.dx, (uint32) regs.ebp); + + return 0; } @@ -646,11 +655,11 @@ void initHooks() { addhook(0x0068778C, (int) intercept_draw_9c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); addhook(0x00687902, (int) intercept_draw_9c, 0, (int[]) {EAX, EBX, ECX, EDX, ESI, EDI, EBP, END}, 0, EBP); - addhook(0x006629BC, (int) intercept_wooden_a_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, 0); - addhook(0x00662D5C, (int) intercept_wooden_b_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, 0); + addhook(0x006629BC, (int) intercept_wooden_a_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, EAX); + addhook(0x00662D5C, (int) intercept_wooden_b_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, EAX); - addhook(0x00663105, (int) intercept_metal_a_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, 0); - addhook(0x00663584, (int) intercept_metal_b_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, 0); + addhook(0x00663105, (int) intercept_metal_a_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, EAX); + addhook(0x00663584, (int) intercept_metal_b_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, EAX); } int main(int argc, const char *argv[]) { From 0cb3a05f5d14ebaa5bebc6789ff4779cea65e045 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 31 Aug 2016 14:33:18 +0200 Subject: [PATCH 15/71] Include google test for cmake --- CMakeLists.txt | 60 +++++++++++++++++++++++++++++++++++++++++++-- PaintTest/gtest.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++ PaintTest/main.c | 30 +++++++++++++++++------ PaintTest/main.h | 19 ++++++++++++++ 4 files changed, 160 insertions(+), 9 deletions(-) create mode 100644 PaintTest/gtest.cpp create mode 100644 PaintTest/main.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ebc8ba08b8..5cce470a6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,9 +210,14 @@ set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG=${DEBUG_LEVEL}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}") +# include lib +include_directories("lib/") # add source files -file(GLOB_RECURSE ORCT2_SOURCES "PaintTest/*.c" "PaintTest/*.cpp" "PaintTest/*.h" "PaintTest/*.hpp" "src/ride/*/*.c" "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_VEHICLES") +file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "src/*.h" "src/*.hpp") +if (APPLE) + file(GLOB_RECURSE ORCT2_MM_SOURCES "src/*.m") + set_source_files_properties(${ORCT2_MM_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c -fmodules") +endif (APPLE) if (APPLE AND NOT USE_MMAP) @@ -315,6 +320,12 @@ else (WIN32) if (NOT APPLE AND NOT USE_MMAP) add_dependencies(${PROJECT} linkable_sections) endif () + add_custom_command( + OUTPUT g2.dat + COMMAND ./openrct2 sprite build ${CMAKE_BINARY_DIR}/g2.dat ${CMAKE_CURRENT_SOURCE_DIR}/resources/g2/ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + add_custom_target(g2 DEPENDS ${PROJECT} g2.dat) endif (WIN32) if (UNIX AND NOT APPLE) @@ -353,6 +364,51 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/g2.dat" DESTINATION share/${PROJECT}) install(DIRECTORY data/ DESTINATION share/${PROJECT}) install(FILES ${DOC_FILES} DESTINATION share/doc/${PROJECT}) +INCLUDE(ExternalProject) +# Add gtest +# http://stackoverflow.com/questions/9689183/cmake-googletest +ExternalProject_Add( + googletest + URL https://github.com/google/googletest/archive/release-1.7.0.zip + TIMEOUT 10 + # # Force separate output paths for debug and release builds to allow easy + # # identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands + CMAKE_ARGS -DCMAKE_CXX_FLAGS=-m32 + # -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs + # -Dgtest_force_shared_crt=ON + # Disable install step + INSTALL_COMMAND "" + # Wrap download, configure and build steps in a script to log output + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON) + +# Specify include dir +ExternalProject_Get_Property(googletest source_dir) +set(GTEST_INCLUDE_DIR ${source_dir}/include) + +# Library +ExternalProject_Get_Property(googletest binary_dir) +set(GTEST_LIBRARY_PATH ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a) +set(GTEST_LIBRARY gtest) +add_library(${GTEST_LIBRARY} UNKNOWN IMPORTED) +set_property(TARGET ${GTEST_LIBRARY} PROPERTY IMPORTED_LOCATION + ${GTEST_LIBRARY_PATH} ) +add_dependencies(${GTEST_LIBRARY} googletest) + +include_directories(${GTEST_INCLUDE_DIR}) +add_definitions(-DUSE_GTEST) + +file(GLOB_RECURSE ORCT2_RIDE_SOURCES "src/ride/*/*.c") +file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") +file(GLOB_RECURSE ORCT2_PAINT_TEST_SOURCES "PaintTest/*.c" "PaintTest/*.cpp" "PaintTest/*.h") + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_VEHICLES") +string(REPLACE "-Wundef" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") +string(REPLACE "-Wundef" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +add_executable(test-paint ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES}) +target_link_libraries(test-paint gtest) + set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 0) set(CPACK_PACKAGE_VERSION_PATCH 5) diff --git a/PaintTest/gtest.cpp b/PaintTest/gtest.cpp new file mode 100644 index 0000000000..b55e25f914 --- /dev/null +++ b/PaintTest/gtest.cpp @@ -0,0 +1,60 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#ifdef USE_GTEST +#include "gtest/gtest.h" + +extern "C" { +#include "main.h" +#include "../src/rct2.h" +} + +int main(int argc, char *argv[]) { + initHooks(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + + +class RidePaintTest : public testing::TestWithParam { +}; + +TEST_P(RidePaintTest, TestRidePainting) { + bool success = testRide(GetParam()); + + ASSERT_TRUE(success); +} + +std::vector ReadTestCasesFromDisk() { + std::vector rides; + + for (int i = 0; i < 91; i++) { + if (!rideIsImplemented(i)) { + continue; + } + rides.push_back(i); + } + + return rides; +} + +INSTANTIATE_TEST_CASE_P( + Instab, // Instantiation name can be chosen arbitrarily. + RidePaintTest, + testing::ValuesIn(ReadTestCasesFromDisk()) +); + +#endif // USE_GTEST diff --git a/PaintTest/main.c b/PaintTest/main.c index d227cf3768..a952233705 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -541,11 +541,15 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { return true; } -void testRide(int rideType) { +bool rideIsImplemented(int rideType) { TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; - if (newPaintGetter == 0) { - return; - } + return (newPaintGetter != 0); +} + +bool testRide(int rideType) { + TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; + + bool returnSuccess = true; printf("- %s (%d)\n", RideNames[rideType], rideType); for (int trackType = 0; trackType < 256; trackType++) { @@ -558,6 +562,7 @@ void testRide(int rideType) { if (!success) { printf(ANSI_COLOR_RED); + returnSuccess = false; } int sequenceCount = getTrackSequenceCount(rideType, trackType); if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) { @@ -574,6 +579,8 @@ void testRide(int rideType) { printf(ANSI_COLOR_RESET "\n"); } + + return returnSuccess; } static int intercept_draw_6c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp) { @@ -662,10 +669,19 @@ void initHooks() { addhook(0x00663584, (int) intercept_metal_b_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, EAX); } +#if !defined(USE_GTEST) + int main(int argc, const char *argv[]) { initHooks(); + + bool success = true; for (int i = 0; i < 91; i++) { - testRide(i); + if (!testRide(i)) { + success = false; + } } - return 0; -} \ No newline at end of file + + return success ? 0 : 1; +} + +#endif diff --git a/PaintTest/main.h b/PaintTest/main.h new file mode 100644 index 0000000000..8e9f9403d0 --- /dev/null +++ b/PaintTest/main.h @@ -0,0 +1,19 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +bool testRide(int rideType); +void initHooks(); +bool rideIsImplemented(int rideType); From 2d704603321a71635e96f30e2257a5a7cf0714c8 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 2 Sep 2016 21:53:09 +0200 Subject: [PATCH 16/71] Fix Xcode tests --- .../xcshareddata/xcschemes/PaintTest.xcscheme | 91 +++++++++++++++++++ PaintTest/main.c | 4 + 2 files changed, 95 insertions(+) create mode 100644 OpenRCT2.xcodeproj/xcshareddata/xcschemes/PaintTest.xcscheme diff --git a/OpenRCT2.xcodeproj/xcshareddata/xcschemes/PaintTest.xcscheme b/OpenRCT2.xcodeproj/xcshareddata/xcschemes/PaintTest.xcscheme new file mode 100644 index 0000000000..bd9963e139 --- /dev/null +++ b/OpenRCT2.xcodeproj/xcshareddata/xcschemes/PaintTest.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PaintTest/main.c b/PaintTest/main.c index a952233705..728c6b7127 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -676,6 +676,10 @@ int main(int argc, const char *argv[]) { bool success = true; for (int i = 0; i < 91; i++) { + if (!rideIsImplemented(i)) { + continue; + } + if (!testRide(i)) { success = false; } From 88422e80433c9bebe3e12c75408886e532fcbccd Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 2 Sep 2016 22:03:06 +0200 Subject: [PATCH 17/71] Import map_element --- PaintTest/compat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/PaintTest/compat.c b/PaintTest/compat.c index faf2f3e069..4ae3a126f4 100644 --- a/PaintTest/compat.c +++ b/PaintTest/compat.c @@ -20,6 +20,7 @@ #include "../src/ride/ride.h" #include "../src/ride/track.h" #include "../src/world/sprite.h" +#include "../src/paint/map_element/map_element.h" #define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) #define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) From 901086abfb38a0945a6777651d47591dd9bafcff Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 3 Sep 2016 11:20:08 +0200 Subject: [PATCH 18/71] [temp?] Ignore some sprite groups --- PaintTest/main.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 728c6b7127..914b333aca 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -256,6 +256,31 @@ bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, i return false; } +enum { + SPRITEGROUP_NONE, + + SPRITEGROUP_FENCE_METAL_B, // 14990 + SPRITEGROUP_FLOOR_CORK, // 22134 + SPRITEGROUP_FENCE_ROPE, // 22138 + +}; + +static int getSpriteGroup(uint16 spriteIndex) { + if (spriteIndex >= 14990 && spriteIndex <= 14993) { + return SPRITEGROUP_FENCE_METAL_B; + } + + if (spriteIndex >= 22134 && spriteIndex <= 22137) { + return SPRITEGROUP_FLOOR_CORK; + } + + if (spriteIndex >= 22138 && spriteIndex <= 22141) { + return SPRITEGROUP_FENCE_ROPE; + } + + return SPRITEGROUP_NONE; +} + static void canonicalizeFunctionCall(function_call *call) { if (call->function != PAINT_98197C) return; if (call->paint.offset.x != call->paint.bound_box_offset.x) return; @@ -294,7 +319,17 @@ static bool assertFunctionCallEquals(function_call expected, function_call actua return true; } - if (expected.paint.image_id != actual.paint.image_id) return false; + if (expected.paint.image_id != actual.paint.image_id) { + int expectedSpriteGroup = getSpriteGroup(expected.paint.image_id & 0x7FFFF); + int actualSpriteGroup = getSpriteGroup(actual.paint.image_id & 0x7FFFF); + + if (expectedSpriteGroup != actualSpriteGroup) return false; + + if (expectedSpriteGroup == SPRITEGROUP_NONE) return false; + + return true; + } + if (expected.paint.offset.x != actual.paint.offset.x) return false; if (expected.paint.offset.y != actual.paint.offset.y) return false; if (expected.paint.bound_box_length.x != actual.paint.bound_box_length.x) return false; From b163d5e51b899d2e668107e5218dc0a0f8f878c6 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 3 Sep 2016 11:28:26 +0200 Subject: [PATCH 19/71] Attempt to fix VS warnings --- PaintTest/main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 914b333aca..4a3449e074 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -406,7 +406,7 @@ static void printFunctionCall(utf8string *out, function_call call) { return; } - utf8string name; + utf8string name = "_default"; switch (call.function) { case PAINT_98196C: name = "sub_98196C"; @@ -433,7 +433,6 @@ static void printFunctionCall(utf8string *out, function_call call) { call.paint.offset.x, call.paint.offset.y, call.paint.bound_box_length.x, call.paint.bound_box_length.y, call.paint.bound_box_length.z, call.paint.z_offset, - NULL ); if (call.function != PAINT_98196C) { @@ -485,7 +484,7 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { } } uint8 rideIndex = 0; - rct_map_element mapElement = {}; + rct_map_element mapElement = { 0 }; mapElement.properties.track.type = trackType; g_currently_drawn_item = &mapElement; @@ -499,10 +498,10 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { rct_drawpixelinfo dpi = {.zoom_level = 1}; unk_140E9A8 = &dpi; - rct_vehicle vehicle = {}; - rct_ride ride = {}; + rct_vehicle vehicle = { 0 }; + rct_ride ride = { 0 }; - rct_ride_entry rideEntry = {}; + rct_ride_entry rideEntry = { 0 }; rct_ride_entry_vehicle vehicleEntry = {.base_image_id = 0x70000}; rideEntry.vehicles[0] = vehicleEntry; From f5db036efda17e2deb8c487a9e1951e682489464 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 3 Sep 2016 11:40:09 +0200 Subject: [PATCH 20/71] Import `viewport.h` --- PaintTest/compat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/PaintTest/compat.c b/PaintTest/compat.c index 4ae3a126f4..a4cccc9503 100644 --- a/PaintTest/compat.c +++ b/PaintTest/compat.c @@ -17,6 +17,7 @@ #include "../src/config.h" #include "../src/object.h" #include "../src/interface/colour.h" +#include "../src/interface/viewport.h" #include "../src/ride/ride.h" #include "../src/ride/track.h" #include "../src/world/sprite.h" From 16cf28da36ab9d9ec51fb04ef53f870526145038 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 3 Sep 2016 12:47:50 +0200 Subject: [PATCH 21/71] Fix some linux build stuff --- PaintTest/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 4a3449e074..e8605f5245 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -15,6 +15,7 @@ #pragma endregion #include "../src/paint/paint.h" +#include "../src/paint/supports.h" #include "../src/ride/track_data.h" #include "../src/interface/viewport.h" #include "../src/hook.h" @@ -432,7 +433,7 @@ static void printFunctionCall(utf8string *out, function_call call) { imageId, call.paint.offset.x, call.paint.offset.y, call.paint.bound_box_length.x, call.paint.bound_box_length.y, call.paint.bound_box_length.z, - call.paint.z_offset, + call.paint.z_offset ); if (call.function != PAINT_98196C) { From bf4258d7795a4f9525655bc9ff8be98e1130e75d Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 3 Sep 2016 13:33:16 +0200 Subject: [PATCH 22/71] Fake surface element for mini golf --- PaintTest/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index e8605f5245..277f32ebf6 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -487,9 +487,14 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { uint8 rideIndex = 0; rct_map_element mapElement = { 0 }; mapElement.properties.track.type = trackType; + mapElement.base_height = 3; g_currently_drawn_item = &mapElement; + rct_map_element surfaceElement = { 0 }; + surfaceElement.type = MAP_ELEMENT_TYPE_SURFACE; + surfaceElement.base_height = 2; + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; RCT2_GLOBAL(0x00F44198, uint32) = PALETTE_98; RCT2_GLOBAL(0x00F441A0, uint32) = PALETTE_A0; @@ -521,7 +526,8 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { RCT2_GLOBAL(0x009DE56A, sint16) = 64; // x RCT2_GLOBAL(0x009DE56E, sint16) = 64; // y - RCT2_GLOBAL(0x9DE57C, bool) = true; // Above surface + RCT2_GLOBAL(0x009DE57C, bool) = true; // Above surface + RCT2_GLOBAL(0x009E3250, rct_map_element *) = &surfaceElement; callCount = 0; memset(&calls, sizeof(calls), 0); From ee61a6af1239a256ec47ab5334a3cfe1cee3c7af Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 3 Sep 2016 13:36:55 +0200 Subject: [PATCH 23/71] Fixup some memory stuff --- PaintTest/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 277f32ebf6..67c3a9faa9 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -480,7 +480,7 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { if (rideType == RIDE_TYPE_CHAIRLIFT) { if (trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION || trackType == TRACK_ELEM_END_STATION) { // These rides chechk neighbouring tiles for tracks - *error = "Skipped"; + sprintf(*error, "Skipped"); return false; } } @@ -562,7 +562,7 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { memcpy(&newCalls, &calls, sizeof(calls)); if (!assertFunctionCallArrayEquals(oldCalls, oldCallCount, newCalls, newCallCount)) { - utf8string diff = malloc(1024); + utf8string diff = malloc(2048); sprintf(diff, "<<< EXPECTED\n"); printFunctionCallArray(&diff, oldCalls, oldCallCount); @@ -571,6 +571,8 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { sprintf(diff + strlen(diff), ">>> ACTUAL\n"); sprintf(*error, "Call counts don't match (was %d, expected %d) [direction:%d trackSequence:%d]", newCallCount, oldCallCount, direction, trackSequence); sprintf(*error + strlen(*error), "\n%s", diff); + + free(diff); return false; } @@ -598,7 +600,7 @@ bool testRide(int rideType) { continue; } - utf8string error = malloc(1024); + utf8string error = malloc(2048); bool success = testTrackElement(rideType, trackType, &error); if (!success) { @@ -617,6 +619,7 @@ bool testRide(int rideType) { printf(" FAILED!\n %s", error); } + free(error); printf(ANSI_COLOR_RESET "\n"); } From fe0de811f1128e89dabc0c59819c5fc282e06c23 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 3 Sep 2016 13:40:22 +0200 Subject: [PATCH 24/71] =?UTF-8?q?Only=20show=20call=20count=20warning=20wh?= =?UTF-8?q?en=20counts=20don=E2=80=99t=20match?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PaintTest/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index 67c3a9faa9..86da168469 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -569,7 +569,13 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { sprintf(diff + strlen(diff), "====\n"); printFunctionCallArray(&diff, newCalls, newCallCount); sprintf(diff + strlen(diff), ">>> ACTUAL\n"); - sprintf(*error, "Call counts don't match (was %d, expected %d) [direction:%d trackSequence:%d]", newCallCount, oldCallCount, direction, trackSequence); + + if (oldCallCount != newCallCount) { + sprintf(*error, "Call counts don't match (was %d, expected %d) [direction:%d trackSequence:%d]", newCallCount, oldCallCount, direction, trackSequence); + } else { + sprintf(*error, "Calls don't match [direction:%d trackSequence:%d]", direction, trackSequence); + } + sprintf(*error + strlen(*error), "\n%s", diff); free(diff); From 576e314f6134982ad79fb91ecd20b93c2b35e3fd Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 3 Sep 2016 14:56:28 +0200 Subject: [PATCH 25/71] Fix Cmake project --- CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cce470a6a..bff418c322 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,6 +341,7 @@ endif (UNIX AND NOT APPLE) # libopenrct2.dll -> openrct2.dll set_target_properties(${PROJECT} PROPERTIES PREFIX "") +set_target_properties(${PROJECT} PROPERTIES COMPILE_FLAGS "-Wundef") # Link shared libs first TARGET_LINK_LIBRARIES(${PROJECT} ${GLLIBS}) @@ -397,17 +398,14 @@ set_property(TARGET ${GTEST_LIBRARY} PROPERTY IMPORTED_LOCATION add_dependencies(${GTEST_LIBRARY} googletest) include_directories(${GTEST_INCLUDE_DIR}) -add_definitions(-DUSE_GTEST) file(GLOB_RECURSE ORCT2_RIDE_SOURCES "src/ride/*/*.c") file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") file(GLOB_RECURSE ORCT2_PAINT_TEST_SOURCES "PaintTest/*.c" "PaintTest/*.cpp" "PaintTest/*.h") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_VEHICLES") -string(REPLACE "-Wundef" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") -string(REPLACE "-Wundef" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") add_executable(test-paint ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES}) target_link_libraries(test-paint gtest) +set_target_properties(test-paint PROPERTIES COMPILE_FLAGS "-DUSE_GTEST -DNO_VEHICLES") set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 0) From 6b525f5d6f5a1978f72b6e26160418f77d5583f9 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 3 Sep 2016 16:34:09 +0200 Subject: [PATCH 26/71] Update to googletest 1.8 --- CMakeLists.txt | 34 ++++++++++++++++++++++------------ PaintTest/gtest.cpp | 12 ++++++++++-- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bff418c322..18cbaebcb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -366,17 +366,26 @@ install(DIRECTORY data/ DESTINATION share/${PROJECT}) install(FILES ${DOC_FILES} DESTINATION share/doc/${PROJECT}) INCLUDE(ExternalProject) -# Add gtest -# http://stackoverflow.com/questions/9689183/cmake-googletest + +ExternalProject_Add( + googletest-distribution + URL https://github.com/google/googletest/archive/release-1.8.0.zip + TIMEOUT 10 + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" +) + +# Specify include dir +ExternalProject_Get_Property(googletest-distribution SOURCE_DIR) +set(GOOGLETEST_DISTRIB_SOURCE_DIR "${SOURCE_DIR}") + ExternalProject_Add( googletest - URL https://github.com/google/googletest/archive/release-1.7.0.zip - TIMEOUT 10 - # # Force separate output paths for debug and release builds to allow easy - # # identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands + DEPENDS googletest-distribution + DOWNLOAD_COMMAND "" + SOURCE_DIR "${GOOGLETEST_DISTRIB_SOURCE_DIR}/googletest" CMAKE_ARGS -DCMAKE_CXX_FLAGS=-m32 - # -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs - # -Dgtest_force_shared_crt=ON # Disable install step INSTALL_COMMAND "" # Wrap download, configure and build steps in a script to log output @@ -384,13 +393,14 @@ ExternalProject_Add( LOG_CONFIGURE ON LOG_BUILD ON) + # Specify include dir -ExternalProject_Get_Property(googletest source_dir) -set(GTEST_INCLUDE_DIR ${source_dir}/include) +set(GTEST_INCLUDE_DIR ${GOOGLETEST_DISTRIB_SOURCE_DIR}/googletest/include) # Library -ExternalProject_Get_Property(googletest binary_dir) -set(GTEST_LIBRARY_PATH ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a) +ExternalProject_Get_Property(googletest BINARY_DIR) +set(GOOGLETEST_BINARY_DIR "${BINARY_DIR}") +set(GTEST_LIBRARY_PATH ${GOOGLETEST_BINARY_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a) set(GTEST_LIBRARY gtest) add_library(${GTEST_LIBRARY} UNKNOWN IMPORTED) set_property(TARGET ${GTEST_LIBRARY} PROPERTY IMPORTED_LOCATION diff --git a/PaintTest/gtest.cpp b/PaintTest/gtest.cpp index b55e25f914..7f8733152a 100644 --- a/PaintTest/gtest.cpp +++ b/PaintTest/gtest.cpp @@ -15,6 +15,9 @@ #pragma endregion #ifdef USE_GTEST +#include +#include +#include #include "gtest/gtest.h" extern "C" { @@ -51,10 +54,15 @@ std::vector ReadTestCasesFromDisk() { return rides; } +inline std::string CustomParamNameFunction(const ::testing::TestParamInfo& info) { + return std::to_string(info.param); +} + INSTANTIATE_TEST_CASE_P( - Instab, // Instantiation name can be chosen arbitrarily. + ParameterizedTest, // Instantiation name can be chosen arbitrarily. RidePaintTest, - testing::ValuesIn(ReadTestCasesFromDisk()) + testing::ValuesIn(ReadTestCasesFromDisk()), + CustomParamNameFunction ); #endif // USE_GTEST From efc306b2afc3b7746be3cb5dca31b937bed0b8a9 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 4 Sep 2016 08:12:48 +0200 Subject: [PATCH 27/71] =?UTF-8?q?Don=E2=80=99t=20use=20google-test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 44 --- PaintTest/data.c | 680 ++++++++++++++++++++++---------------------- PaintTest/gtest.cpp | 151 +++++++--- PaintTest/main.c | 32 +++ PaintTest/main.h | 2 + 5 files changed, 487 insertions(+), 422 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18cbaebcb5..8fd50a45be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -365,56 +365,12 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/g2.dat" DESTINATION share/${PROJECT}) install(DIRECTORY data/ DESTINATION share/${PROJECT}) install(FILES ${DOC_FILES} DESTINATION share/doc/${PROJECT}) -INCLUDE(ExternalProject) - -ExternalProject_Add( - googletest-distribution - URL https://github.com/google/googletest/archive/release-1.8.0.zip - TIMEOUT 10 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" -) - -# Specify include dir -ExternalProject_Get_Property(googletest-distribution SOURCE_DIR) -set(GOOGLETEST_DISTRIB_SOURCE_DIR "${SOURCE_DIR}") - -ExternalProject_Add( - googletest - DEPENDS googletest-distribution - DOWNLOAD_COMMAND "" - SOURCE_DIR "${GOOGLETEST_DISTRIB_SOURCE_DIR}/googletest" - CMAKE_ARGS -DCMAKE_CXX_FLAGS=-m32 - # Disable install step - INSTALL_COMMAND "" - # Wrap download, configure and build steps in a script to log output - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON) - - -# Specify include dir -set(GTEST_INCLUDE_DIR ${GOOGLETEST_DISTRIB_SOURCE_DIR}/googletest/include) - -# Library -ExternalProject_Get_Property(googletest BINARY_DIR) -set(GOOGLETEST_BINARY_DIR "${BINARY_DIR}") -set(GTEST_LIBRARY_PATH ${GOOGLETEST_BINARY_DIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a) -set(GTEST_LIBRARY gtest) -add_library(${GTEST_LIBRARY} UNKNOWN IMPORTED) -set_property(TARGET ${GTEST_LIBRARY} PROPERTY IMPORTED_LOCATION - ${GTEST_LIBRARY_PATH} ) -add_dependencies(${GTEST_LIBRARY} googletest) - -include_directories(${GTEST_INCLUDE_DIR}) file(GLOB_RECURSE ORCT2_RIDE_SOURCES "src/ride/*/*.c") file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") file(GLOB_RECURSE ORCT2_PAINT_TEST_SOURCES "PaintTest/*.c" "PaintTest/*.cpp" "PaintTest/*.h") add_executable(test-paint ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES}) -target_link_libraries(test-paint gtest) set_target_properties(test-paint PROPERTIES COMPILE_FLAGS "-DUSE_GTEST -DNO_VEHICLES") set(CPACK_PACKAGE_VERSION_MAJOR 0) diff --git a/PaintTest/data.c b/PaintTest/data.c index bfb6047f76..09c69abdd7 100644 --- a/PaintTest/data.c +++ b/PaintTest/data.c @@ -17,355 +17,355 @@ #include "../src/common.h" const utf8string RideNames[91] = { - "Spiral Roller Coaster", - "Stand-up Roller Coaster", - "Suspended Swinging Coaster", - "Inverted Roller Coaster", - "Junior Roller Coaster", - "Miniature Railway", + "SpiralRollerCoaster", + "StandUpRollerCoaster", + "SuspendedSwingingCoaster", + "InvertedRollerCoaster", + "JuniorRollerCoaster", + "MiniatureRailway", "Monorail", - "Mini Suspended Coaster", - "Boat Ride", - "Wooden Wild Mouse", + "MiniSuspendedCoaster", + "BoatRide", + "WoodenWildMouse", "Steeplechase", - "Car Ride", - "Launched Freefall", - "Bobsleigh Coaster", - "Observation Tower", - "Looping Roller Coaster", - "Dinghy Slide", - "Mine Train Coaster", + "CarRide", + "LaunchedFreefall", + "BobsleighCoaster", + "ObservationTower", + "LoopingRollerCoaster", + "DinghySlide", + "MineTrainCoaster", "Chairlift", - "Corkscrew Roller Coaster", + "CorkscrewRollerCoaster", "Maze", - "Spiral Slide", - "Go Karts", - "Log Flume", - "River Rapids", + "SpiralSlide", + "GoKarts", + "LogFlume", + "RiverRapids", "Dodgems", - "Pirate Ship", - "Swinging Inverter Ship", - "Food Stall", - "Unknown Stall", - "Drink Stall", - "Unknown Stall", + "PirateShip", + "SwingingInverterShip", + "FoodStall", + "1D", + "DrinkStall", + "1F", "Shop", - "Merry-Go-Round", - "Unknown Stall", - "Information Kiosk", + "MerryGoRound", + "22", + "InformationKiosk", "Toilets", - "Ferris Wheel", - "Motion Simulator", - "3D Cinema", - "Top Spin", - "Space Rings", - "Reverse Freefall Coaster", + "FerrisWheel", + "MotionSimulator", + "3DCinema", + "TopSpin", + "SpaceRings", + "ReverseFreefallCoaster", "Lift", - "Vertical Drop Roller Coaster", - "Cash Machine", + "VerticalDropRollerCoaster", + "CashMachine", "Twist", - "Haunted House", - "First Aid Room", - "Circus Show", - "Ghost Train", - "Steel Twister Roller Coaster", - "Wooden Roller Coaster", - "Side-Friction Roller Coaster", - "Wild Mouse", - "Multi-Dimension Roller Coaster", - "Unknown Ride", - "Flying Roller Coaster", - "Unknown Ride", - "Virginia Reel", - "Splash Boats", - "Mini Helicopters", - "Lay-down Roller Coaster", - "Suspended Monorail", - "Unknown Ride", - "Reverser Roller Coaster", - "Heartline Twister Coaster", - "Mini Golf", - "Giga Coaster", - "Roto-Drop", - "Flying Saucers", - "Crooked House", - "Monorail Cycles", - "Compact Inverted Coaster", - "Water Coaster", - "Air Powered Vertical Coaster", - "Inverted Hairpin Coaster", - "Magic Carpet", - "Submarine Ride", - "River Rafts", - "Unknown Ride", + "HauntedHouse", + "FirstAid", + "CircusShow", + "GhostTrain", + "TwisterRollerCoaster", + "WoodenRollerCoaster", + "SideFrictionRollerCoaster", + "WildMouse", + "MultiDimensionRollerCoaster", + "MultiDimensionRollerCoasterAlt", + "FlyingRollerCoaster", + "FlyingRollerCoasterAlt", + "VirginiaReel", + "SplashBoats", + "MiniHelicopters", + "LayDownRollerCoaster", + "SuspendedMonorail", + "LayDownRollerCoasterAlt", + "ReverserRollerCoaster", + "HeartlineTwisterCoaster", + "MiniGolf", + "GigaCoaster", + "RoToDrop", + "FlyingSaucers", + "CrookedHouse", + "MonorailCycles", + "CompactInvertedCoaster", + "WaterCoaster", + "AirPoweredVerticalCoaster", + "InvertedHairpinCoaster", + "MagicCarpet", + "SubmarineRide", + "RiverRafts", + "50", "Enterprise", - "Unknown Ride", - "Unknown Ride", - "Unknown Ride", - "Unknown Ride", - "Inverted Impulse Coaster", - "Mini Roller Coaster", - "Mine Ride", - "Unknown Ride", - "LIM Launched Roller Coaster", + "52", + "53", + "54", + "55", + "InvertedImpulseCoaster", + "MiniRollerCoaster", + "MineRide", + "59", + "LimLaunchedRollerCoaster", }; const utf8string TrackNames[256] = { "Flat", - "End Station", - "Begin Station", - "Middle Station", - "25 Deg Up", - "60 Deg Up", - "Flat to 25 deg Up", - "25 Deg up to 60 deg Up", - "60 Deg up to 25 deg Up", - "25 Deg up to Flat", - "25 Deg Down", - "60 Deg Down", - "Flat to 25 deg Down", - "25 Deg Down to 60 deg Down", - "60 Deg Down to 25 deg Down", - "25 Deg Down to Flat", - "Left Quarter Turn 5 Tiles", - "Right Quarter Turn 5 Tiles", - "Flat to Left Bank", - "Flat to Right Bank", - "Left Bank to Flat", - "Right Bank to Flat", - "Banked Left Quarter Turn 5 Tiles", - "Banked Right Quarter Turn 5 Tiles", - "Left Bank to 25 deg Up", - "Right Bank to 25 deg Up", - "25 Deg up to Left Bank", - "25 Deg up to Right Bank", - "Left Bank to 25 deg Down", - "Right Bank to 25 deg Down", - "25 Deg Down to Left Bank", - "25 Deg Down to Right Bank", - "Left Bank", - "Right Bank", - "Left Quarter Turn 5 Tiles 25 deg Up", - "Right Quarter Turn 5 Tiles 25 deg Up", - "Left Quarter Turn 5 Tiles 25 deg Down", - "Right Quarter Turn 5 Tiles 25 deg Down", - "S Bend Left", - "S Bend Right", - "Left Vertical Loop", - "Right Vertical Loop", - "Left Quarter Turn 3 Tiles", - "Right Quarter Turn 3 Tiles", - "Left Quarter Turn 3 Tiles Bank", - "Right Quarter Turn 3 Tiles Bank", - "Left Quarter Turn 3 Tiles 25 deg Up", - "Right Quarter Turn 3 Tiles 25 deg Up", - "Left Quarter Turn 3 Tiles 25 deg Down", - "Right Quarter Turn 3 Tiles 25 deg Down", - "Left Quarter Turn 1 Tile", - "Right Quarter Turn 1 Tile", - "Left Twist Down to Up", - "Right Twist Down to Up", - "Left Twist up to Down", - "Right Twist up to Down", - "Half Loop Up", - "Half Loop Down", - "Left Corkscrew Up", - "Right Corkscrew Up", - "Left Corkscrew Down", - "Right Corkscrew Down", - "Flat to 60 deg Up", - "60 Deg up to Flat", - "Flat to 60 deg Down", - "60 Deg Down to Flat", - "Tower Base", - "Tower Section", - "Flat Covered", - "25 Deg up Covered", - "60 Deg up Covered", - "Flat to 25 deg up Covered", - "25 Deg up to 60 deg up Covered", - "60 Deg up to 25 deg up Covered", - "25 Deg up to Flat Covered", - "25 Deg Down Covered", - "60 Deg Down Covered", - "Flat to 25 deg Down Covered", - "25 Deg Down to 60 deg Down Covered", - "60 Deg Down to 25 deg Down Covered", - "25 Deg Down to Flat Covered", - "Left Quarter Turn 5 Tiles Covered", - "Right Quarter Turn 5 Tiles Covered", - "S Bend Left Covered", - "S Bend Right Covered", - "Left Quarter Turn 3 Tiles Covered", - "Right Quarter Turn 3 Tiles Covered", - "Left Half Banked Helix up Small", - "Right Half Banked Helix up Small", - "Left Half Banked Helix Down Small", - "Right Half Banked Helix Down Small", - "Left Half Banked Helix up Large", - "Right Half Banked Helix up Large", - "Left Half Banked Helix Down Large", - "Right Half Banked Helix Down Large", - "Left Quarter Turn 1 Tile 60 deg Up", - "Right Quarter Turn 1 Tile 60 deg Up", - "Left Quarter Turn 1 Tile 60 deg Down", - "Right Quarter Turn 1 Tile 60 deg Down", + "EndStation", + "BeginStation", + "MiddleStation", + "25DegUp", + "60DegUp", + "FlatTo25DegUp", + "25DegUpTo60DegUp", + "60DegUpTo25DegUp", + "25DegUpToFlat", + "25DegDown", + "60DegDown", + "FlatTo25DegDown", + "25DegDownTo60DegDown", + "60DegDownTo25DegDown", + "25DegDownToFlat", + "LeftQuarterTurn5Tiles", + "RightQuarterTurn5Tiles", + "FlatToLeftBank", + "FlatToRightBank", + "LeftBankToFlat", + "RightBankToFlat", + "BankedLeftQuarterTurn5Tiles", + "BankedRightQuarterTurn5Tiles", + "LeftBankTo25DegUp", + "RightBankTo25DegUp", + "25DegUpToLeftBank", + "25DegUpToRightBank", + "LeftBankTo25DegDown", + "RightBankTo25DegDown", + "25DegDownToLeftBank", + "25DegDownToRightBank", + "LeftBank", + "RightBank", + "LeftQuarterTurn5Tiles25DegUp", + "RightQuarterTurn5Tiles25DegUp", + "LeftQuarterTurn5Tiles25DegDown", + "RightQuarterTurn5Tiles25DegDown", + "SBendLeft", + "SBendRight", + "LeftVerticalLoop", + "RightVerticalLoop", + "LeftQuarterTurn3Tiles", + "RightQuarterTurn3Tiles", + "LeftQuarterTurn3TilesBank", + "RightQuarterTurn3TilesBank", + "LeftQuarterTurn3Tiles25DegUp", + "RightQuarterTurn3Tiles25DegUp", + "LeftQuarterTurn3Tiles25DegDown", + "RightQuarterTurn3Tiles25DegDown", + "LeftQuarterTurn1Tile", + "RightQuarterTurn1Tile", + "LeftTwistDownToUp", + "RightTwistDownToUp", + "LeftTwistUpToDown", + "RightTwistUpToDown", + "HalfLoopUp", + "HalfLoopDown", + "LeftCorkscrewUp", + "RightCorkscrewUp", + "LeftCorkscrewDown", + "RightCorkscrewDown", + "FlatTo60DegUp", + "60DegUpToFlat", + "FlatTo60DegDown", + "60DegDownToFlat", + "TowerBase", + "TowerSection", + "FlatCovered", + "25DegUpCovered", + "60DegUpCovered", + "FlatTo25DegUpCovered", + "25DegUpTo60DegUpCovered", + "60DegUpTo25DegUpCovered", + "25DegUpToFlatCovered", + "25DegDownCovered", + "60DegDownCovered", + "FlatTo25DegDownCovered", + "25DegDownTo60DegDownCovered", + "60DegDownTo25DegDownCovered", + "25DegDownToFlatCovered", + "LeftQuarterTurn5TilesCovered", + "RightQuarterTurn5TilesCovered", + "SBendLeftCovered", + "SBendRightCovered", + "LeftQuarterTurn3TilesCovered", + "RightQuarterTurn3TilesCovered", + "LeftHalfBankedHelixUpSmall", + "RightHalfBankedHelixUpSmall", + "LeftHalfBankedHelixDownSmall", + "RightHalfBankedHelixDownSmall", + "LeftHalfBankedHelixUpLarge", + "RightHalfBankedHelixUpLarge", + "LeftHalfBankedHelixDownLarge", + "RightHalfBankedHelixDownLarge", + "LeftQuarterTurn1Tile60DegUp", + "RightQuarterTurn1Tile60DegUp", + "LeftQuarterTurn1Tile60DegDown", + "RightQuarterTurn1Tile60DegDown", "Brakes", - "Rotation Control Toggle", - "Inverted 90 deg up to Flat Quarter Loop/Maze", - "Left Quarter Banked Helix Large Up", - "Right Quarter Banked Helix Large Up", - "Left Quarter Banked Helix Large Down", - "Right Quarter Banked Helix Large Down", - "Left Quarter Helix Large Up", - "Right Quarter Helix Large Up", - "Left Quarter Helix Large Down", - "Right Quarter Helix Large Down", - "25 Deg up Left Banked", - "25 Deg up Right Banked", + "RotationControlToggle", + "Inverted90DegUpToFlatQuarterLoop_Maze", + "LeftQuarterBankedHelixLargeUp", + "RightQuarterBankedHelixLargeUp", + "LeftQuarterBankedHelixLargeDown", + "RightQuarterBankedHelixLargeDown", + "LeftQuarterHelixLargeUp", + "RightQuarterHelixLargeUp", + "LeftQuarterHelixLargeDown", + "RightQuarterHelixLargeDown", + "25DegUpLeftBanked", + "25DegUpRightBanked", "Waterfall", "Rapids", - "On Ride Photo", - "25 Deg Down Left Banked", - "25 Deg Down Right Banked", - "Water Splash", - "Flat to 60 deg up Long Base", - "60 Deg up to Flat Long Base", + "OnRidePhoto", + "25DegDownLeftBanked", + "25DegDownRightBanked", + "WaterSplash", + "FlatTo60DegUpLongBase", + "60DegUpToFlatLongBase", "Whirlpool", - "Flat to 60 deg Down Long Base", - "60 Deg up to Flat Long Base 122", - "Cable Lift Hill", - "Reverse Whoa Belly Slope", - "Reverse Whoa Belly Vertical", - "90 Deg Up", - "90 Deg Down", - "60 Deg up to 90 deg Up", - "90 Deg Down to 60 deg Down", - "90 Deg up to 60 deg Up", - "60 Deg Down to 90 deg Down", - "Brake for Drop", - "Left Eighth to Diag", - "Right Eighth to Diag", - "Left Eighth to Orthogonal", - "Right Eighth to Orthogonal", - "Left Eighth Bank to Diag", - "Right Eighth Bank to Diag", - "Left Eighth Bank to Orthogonal", - "Right Eighth Bank to Orthogonal", - "Diag Flat", - "Diag 25 deg Up", - "Diag 60 deg Up", - "Diag Flat to 25 deg Up", - "Diag 25 deg up to 60 deg Up", - "Diag 60 deg up to 25 deg Up", - "Diag 25 deg up to Flat", - "Diag 25 deg Down", - "Diag 60 deg Down", - "Diag Flat to 25 deg Down", - "Diag 25 deg Down to 60 deg Down", - "Diag 60 deg Down to 25 deg Down", - "Diag 25 deg Down to Flat", - "Diag Flat to 60 deg Up", - "Diag 60 deg up to Flat", - "Diag Flat to 60 deg Down", - "Diag 60 deg Down to Flat", - "Diag Flat to Left Bank", - "Diag Flat to Right Bank", - "Diag Left Bank to Flat", - "Diag Right Bank to Flat", - "Diag Left Bank to 25 deg Up", - "Diag Right Bank to 25 deg Up", - "Diag 25 deg up to Left Bank", - "Diag 25 deg up to Right Bank", - "Diag Left Bank to 25 deg Down", - "Diag Right Bank to 25 deg Down", - "Diag 25 deg Down to Left Bank", - "Diag 25 deg Down to Right Bank", - "Diag Left Bank", - "Diag Right Bank", - "Log Flume Reverser", - "Spinning Tunnel", - "Left Barrel Roll up to Down", - "Right Barrel Roll up to Down", - "Left Barrel Roll Down to Up", - "Right Barrel Roll Down to Up", - "Left Bank to Left Quarter Turn 3 Tiles 25 deg Up", - "Right Bank to Right Quarter Turn 3 Tiles 25 deg Up", - "Left Quarter Turn 3 Tiles 25 deg Down to Left Bank", - "Right Quarter Turn 3 Tiles 25 deg Down to Right Bank", - "Powered Lift", - "Left Large Half Loop Up", - "Right Large Half Loop Up", - "Right Large Half Loop Down", - "Left Large Half Loop Down", - "Left Flyer Twist Up", - "Right Flyer Twist Up", - "Left Flyer Twist Down", - "Right Flyer Twist Down", - "Flyer Half Loop Up", - "Flyer Half Loop Down", - "Left Flyer Corkscrew Up", - "Right Flyer Corkscrew Up", - "Left Flyer Corkscrew Down", - "Right Flyer Corkscrew Down", - "Heartline Transfer Up", - "Heartline Transfer Down", - "Left Heartline Roll", - "Right Heartline Roll", - "Mini Golf Hole A", - "Mini Golf Hole B", - "Mini Golf Hole C", - "Mini Golf Hole D", - "Mini Golf Hole E", - "Multidim Inverted Flat to 90 deg Quarter Loop Down", - "90 Deg to Inverted Flat Quarter Loop Up", - "Inverted Flat to 90 deg Quarter Loop Down", - "Left Curved Lift Hill", - "Right Curved Lift Hill", - "Left Reverser", - "Right Reverser", - "Air Thrust top Cap", - "Air Thrust Vertical Down", - "Air Thrust Vertical Down to Level", - "Block Brakes", - "Left Banked Quarter Turn 3 Tile 25 deg Up", - "Right Banked Quarter Turn 3 Tile 25 deg Up", - "Left Banked Quarter Turn 3 Tile 25 deg Down", - "Right Banked Quarter Turn 3 Tile 25 deg Down", - "Left Banked Quarter Turn 5 Tile 25 deg Up", - "Right Banked Quarter Turn 5 Tile 25 deg Up", - "Left Banked Quarter Turn 5 Tile 25 deg Down", - "Right Banked Quarter Turn 5 Tile 25 deg Down", - "25 Deg up to Left Banked 25 deg Up", - "25 Deg up to Right Banked 25 deg Up", - "Left Banked 25 deg up to 25 deg Up", - "Right Banked 25 deg up to 25 deg Up", - "25 Deg Down to Left Banked 25 deg Down", - "25 Deg Down to Right Banked 25 deg Down", - "Left Banked 25 deg Down to 25 deg Down", - "Right Banked 25 deg Down to 25 deg Down", - "Left Banked Flat to Left Banked 25 deg Up", - "Right Banked Flat to Right Banked 25 deg Up", - "Left Banked 25 deg up to Left Banked Flat", - "Right Banked 25 deg up to Right Banked Flat", - "Left Banked Flat to Left Banked 25 deg Down", - "Right Banked Flat to Right Banked 25 deg Down", - "Left Banked 25 deg Down to Left Banked Flat", - "Right Banked 25 deg Down to Right Banked Flat", - "Flat to Left Banked 25 deg Up", - "Flat to Right Banked 25 deg Up", - "Left Banked 25 deg up to Flat", - "Right Banked 25 deg up to Flat", - "Flat to Left Banked 25 deg Down", - "Flat to Right Banked 25 deg Down", - "Left Banked 25 deg Down to Flat", - "Right Banked 25 deg Down to Flat", - "Left Quarter Turn 1 Tile 90 deg Up", - "Right Quarter Turn 1 Tile 90 deg Up", - "Left Quarter Turn 1 Tile 90 deg Down", - "Right Quarter Turn 1 Tile 90 deg Down", - "Multidim 90 deg up to Inverted Flat Quarter Loop", - "Multidim Flat to 90 deg Down Quarter Loop", + "FlatTo60DegDownLongBase", + "60DegUpToFlatLongBase122", + "CableLiftHill", + "ReverseWhoaBellySlope", + "ReverseWhoaBellyVertical", + "90DegUp", + "90DegDown", + "60DegUpTo90DegUp", + "90DegDownTo60DegDown", + "90DegUpTo60DegUp", + "60DegDownTo90DegDown", + "BrakeForDrop", + "LeftEighthToDiag", + "RightEighthToDiag", + "LeftEighthToOrthogonal", + "RightEighthToOrthogonal", + "LeftEighthBankToDiag", + "RightEighthBankToDiag", + "LeftEighthBankToOrthogonal", + "RightEighthBankToOrthogonal", + "DiagFlat", + "Diag25DegUp", + "Diag60DegUp", + "DiagFlatTo25DegUp", + "Diag25DegUpTo60DegUp", + "Diag60DegUpTo25DegUp", + "Diag25DegUpToFlat", + "Diag25DegDown", + "Diag60DegDown", + "DiagFlatTo25DegDown", + "Diag25DegDownTo60DegDown", + "Diag60DegDownTo25DegDown", + "Diag25DegDownToFlat", + "DiagFlatTo60DegUp", + "Diag60DegUpToFlat", + "DiagFlatTo60DegDown", + "Diag60DegDownToFlat", + "DiagFlatToLeftBank", + "DiagFlatToRightBank", + "DiagLeftBankToFlat", + "DiagRightBankToFlat", + "DiagLeftBankTo25DegUp", + "DiagRightBankTo25DegUp", + "Diag25DegUpToLeftBank", + "Diag25DegUpToRightBank", + "DiagLeftBankTo25DegDown", + "DiagRightBankTo25DegDown", + "Diag25DegDownToLeftBank", + "Diag25DegDownToRightBank", + "DiagLeftBank", + "DiagRightBank", + "LogFlumeReverser", + "SpinningTunnel", + "LeftBarrelRollUpToDown", + "RightBarrelRollUpToDown", + "LeftBarrelRollDownToUp", + "RightBarrelRollDownToUp", + "LeftBankToLeftQuarterTurn3Tiles25DegUp", + "RightBankToRightQuarterTurn3Tiles25DegUp", + "LeftQuarterTurn3Tiles25DegDownToLeftBank", + "RightQuarterTurn3Tiles25DegDownToRightBank", + "PoweredLift", + "LeftLargeHalfLoopUp", + "RightLargeHalfLoopUp", + "RightLargeHalfLoopDown", + "LeftLargeHalfLoopDown", + "LeftFlyerTwistUp", + "RightFlyerTwistUp", + "LeftFlyerTwistDown", + "RightFlyerTwistDown", + "FlyerHalfLoopUp", + "FlyerHalfLoopDown", + "LeftFlyerCorkscrewUp", + "RightFlyerCorkscrewUp", + "LeftFlyerCorkscrewDown", + "RightFlyerCorkscrewDown", + "HeartlineTransferUp", + "HeartlineTransferDown", + "LeftHeartlineRoll", + "RightHeartlineRoll", + "MiniGolfHoleA", + "MiniGolfHoleB", + "MiniGolfHoleC", + "MiniGolfHoleD", + "MiniGolfHoleE", + "MultidimInvertedFlatTo90DegQuarterLoopDown", + "90DegToInvertedFlatQuarterLoopUp", + "InvertedFlatTo90DegQuarterLoopDown", + "LeftCurvedLiftHill", + "RightCurvedLiftHill", + "LeftReverser", + "RightReverser", + "AirThrustTopCap", + "AirThrustVerticalDown", + "AirThrustVerticalDownToLevel", + "BlockBrakes", + "LeftBankedQuarterTurn3Tile25DegUp", + "RightBankedQuarterTurn3Tile25DegUp", + "LeftBankedQuarterTurn3Tile25DegDown", + "RightBankedQuarterTurn3Tile25DegDown", + "LeftBankedQuarterTurn5Tile25DegUp", + "RightBankedQuarterTurn5Tile25DegUp", + "LeftBankedQuarterTurn5Tile25DegDown", + "RightBankedQuarterTurn5Tile25DegDown", + "25DegUpToLeftBanked25DegUp", + "25DegUpToRightBanked25DegUp", + "LeftBanked25DegUpTo25DegUp", + "RightBanked25DegUpTo25DegUp", + "25DegDownToLeftBanked25DegDown", + "25DegDownToRightBanked25DegDown", + "LeftBanked25DegDownTo25DegDown", + "RightBanked25DegDownTo25DegDown", + "LeftBankedFlatToLeftBanked25DegUp", + "RightBankedFlatToRightBanked25DegUp", + "LeftBanked25DegUpToLeftBankedFlat", + "RightBanked25DegUpToRightBankedFlat", + "LeftBankedFlatToLeftBanked25DegDown", + "RightBankedFlatToRightBanked25DegDown", + "LeftBanked25DegDownToLeftBankedFlat", + "RightBanked25DegDownToRightBankedFlat", + "FlatToLeftBanked25DegUp", + "FlatToRightBanked25DegUp", + "LeftBanked25DegUpToFlat", + "RightBanked25DegUpToFlat", + "FlatToLeftBanked25DegDown", + "FlatToRightBanked25DegDown", + "LeftBanked25DegDownToFlat", + "RightBanked25DegDownToFlat", + "LeftQuarterTurn1Tile90DegUp", + "RightQuarterTurn1Tile90DegUp", + "LeftQuarterTurn1Tile90DegDown", + "RightQuarterTurn1Tile90DegDown", + "Multidim90DegUpToInvertedFlatQuarterLoop", + "MultidimFlatTo90DegDownQuarterLoop", }; const utf8string FlatTrackNames[256] = { @@ -464,7 +464,7 @@ const utf8string FlatTrackNames[256] = { "", "", "", - "FLAT_TRACK_ELEM_1_X_4_A = 95,", + "1x4_A", "", "", "", @@ -479,20 +479,20 @@ const utf8string FlatTrackNames[256] = { "", "", "", - "FLAT_TRACK_ELEM_2_X_2 = 110,", - "FLAT_TRACK_ELEM_4_X_4 = 111,", + "2x2", + "4x4", "", "", "", "", - "FLAT_TRACK_ELEM_1_X_5 = 116,", + "1x5", "", - "FLAT_TRACK_ELEM_1_X_1_A = 118,", - "FLAT_TRACK_ELEM_1_X_4_B = 119,", + "1x1_A", + "1x4_B", "", - "FLAT_TRACK_ELEM_1_X_1_B = 121,", - "FLAT_TRACK_ELEM_1_X_4_C = 122,", - "FLAT_TRACK_ELEM_3_X_3 = 123,", + "1x1_B", + "1x4_C", + "3x3", "", "", "", diff --git a/PaintTest/gtest.cpp b/PaintTest/gtest.cpp index 7f8733152a..802f959415 100644 --- a/PaintTest/gtest.cpp +++ b/PaintTest/gtest.cpp @@ -15,54 +15,129 @@ #pragma endregion #ifdef USE_GTEST + #include #include #include -#include "gtest/gtest.h" extern "C" { #include "main.h" #include "../src/rct2.h" +#include "../src/ride/ride.h" +#include "../src/ride/ride_data.h" +#include "../src/ride/track.h" +#include "../src/ride/track_data.h" } +typedef struct { + uint8 rideType; + std::vector trackTypes; +} TestCase; + +extern const utf8string RideNames[91]; +extern const utf8string TrackNames[256]; +extern const utf8string FlatTrackNames[256]; + int main(int argc, char *argv[]) { - initHooks(); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + std::vector testCases; + + bool gTestColor = true; + for (int i = 0; i < argc; ++i) { + char *arg = argv[i]; + if (strcmp(arg, "--gtest_color=no") == 0) { + gTestColor = false; + } + } + + const utf8 *ansiRed = gTestColor ? "\x1b[31m" : ""; + const utf8 *ansiGreen = gTestColor ? "\x1b[32m" : ""; + const utf8 *ansiReset = gTestColor ? "\x1b[0m" : ""; + + for (uint8 rideType = 0; rideType < 91; rideType++) { + if (!rideIsImplemented(rideType)) { + continue; + } + + TestCase testCase = { + .rideType = rideType + }; + + if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) { + testCase.trackTypes.push_back(RideConstructionDefaultTrackType[rideType]); + } else { + for (int trackType = 0; trackType < 256; trackType++) { + if (rideSupportsTrackType(rideType, trackType)) { + testCase.trackTypes.push_back(trackType); + } + } + } + + testCases.push_back(testCase); + } + + int testCaseCount = (int) testCases.size(); + int testCount = 0; + for (auto &&tc : testCases) { + testCount += tc.trackTypes.size(); + } + + printf("%s[==========]%s Running %d tests from %d test cases.\n", ansiGreen, ansiReset, testCount, testCaseCount); + printf("%s[----------]%s Global test environment set-up.\n", ansiGreen, ansiReset); + initHooks(); + + int successCount = 0; + std::vector failures; + for (auto &&tc : testCases) { + const utf8string rideTypeName = RideNames[tc.rideType]; + printf("%s[----------]%s %lu tests from %s\n", ansiGreen, ansiReset, tc.trackTypes.size(), rideTypeName); + + for (auto &&trackType : tc.trackTypes) { + utf8string trackTypeName; + if (ride_type_has_flag(tc.rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) { + trackTypeName = FlatTrackNames[trackType]; + } else { + trackTypeName = TrackNames[trackType]; + } + + printf("%s[ RUN ]%s %s.%s\n", ansiGreen, ansiReset, rideTypeName, trackTypeName); + bool success = testTrackPainting(tc.rideType, trackType); + if (!success) { + printf("%s[ FAILED ]%s %s.%s (0 ms)\n", ansiRed, ansiReset, rideTypeName, trackTypeName); + utf8string testCaseName = new utf8[64]; + sprintf(testCaseName, "%s.%s", rideTypeName, trackTypeName); + failures.push_back(testCaseName); + } else { + printf("%s[ OK ]%s %s.%s (0 ms)\n", ansiGreen, ansiReset, rideTypeName, trackTypeName); + successCount++; + } + } + + printf("%s[----------]%s %lu tests from %s (0 ms total)\n", ansiGreen, ansiReset, tc.trackTypes.size(), + rideTypeName); + } + printf("\n"); + + printf("%s[----------]%s Global test environment tear-down\n", ansiGreen, ansiReset); + printf("%s[==========]%s %d tests from %d test cases ran. (0 ms total).\n", ansiGreen, ansiReset, testCount, + testCaseCount); + printf("%s[ PASSED ]%s %d tests.\n", ansiGreen, ansiReset, successCount); + + if (failures.size() > 0) { + printf("%s[ FAILED ]%s %lu tests, listed below:\n", ansiRed, ansiReset, failures.size()); + + for (auto &&failure : failures) { + printf("%s[ FAILED ]%s %s\n", ansiRed, ansiReset, failure); + delete(failure); + } + + printf("\n"); + + printf("%lu FAILED TESTS\n", failures.size()); + + return 1; + } + + return 0; } - -class RidePaintTest : public testing::TestWithParam { -}; - -TEST_P(RidePaintTest, TestRidePainting) { - bool success = testRide(GetParam()); - - ASSERT_TRUE(success); -} - -std::vector ReadTestCasesFromDisk() { - std::vector rides; - - for (int i = 0; i < 91; i++) { - if (!rideIsImplemented(i)) { - continue; - } - rides.push_back(i); - } - - return rides; -} - -inline std::string CustomParamNameFunction(const ::testing::TestParamInfo& info) { - return std::to_string(info.param); -} - -INSTANTIATE_TEST_CASE_P( - ParameterizedTest, // Instantiation name can be chosen arbitrarily. - RidePaintTest, - testing::ValuesIn(ReadTestCasesFromDisk()), - CustomParamNameFunction -); - #endif // USE_GTEST diff --git a/PaintTest/main.c b/PaintTest/main.c index 86da168469..3902a8b4bd 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -476,6 +476,18 @@ int getTrackSequenceCount(uint8 rideType, uint8 trackType) { return sequenceCount; } +bool rideSupportsTrackType(int rideType, int trackType) { + TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; + + if (newPaintGetter == NULL) { + return false; + } + + bool supportsTrackType = (newPaintGetter(trackType, 0) != NULL); + + return supportsTrackType; +} + bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { if (rideType == RIDE_TYPE_CHAIRLIFT) { if (trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION || trackType == TRACK_ELEM_END_STATION) { @@ -595,6 +607,26 @@ bool rideIsImplemented(int rideType) { return (newPaintGetter != 0); } +bool testTrackPainting(int rideType, int trackType) { + TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; + if (newPaintGetter == NULL) { + return false; + } + + if (newPaintGetter(trackType, 0) == NULL) { + return false; + } + + utf8string error = malloc(2048); + bool success = testTrackElement(rideType, trackType, &error); + if (!success) { + printf("%s\n", error); + } + free(error); + + return success; +} + bool testRide(int rideType) { TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; diff --git a/PaintTest/main.h b/PaintTest/main.h index 8e9f9403d0..0254acc619 100644 --- a/PaintTest/main.h +++ b/PaintTest/main.h @@ -17,3 +17,5 @@ bool testRide(int rideType); void initHooks(); bool rideIsImplemented(int rideType); +bool rideSupportsTrackType(int rideType, int trackType); +bool testTrackPainting(int rideType, int trackType); From b0a43861e454368d8a64c8c6b49b1df86cc16176 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 17:25:39 +0200 Subject: [PATCH 28/71] Always use GTest output --- CMakeLists.txt | 2 +- OpenRCT2.xcodeproj/project.pbxproj | 9 ++- PaintTest/main.c | 21 ------ PaintTest/{gtest.cpp => main.cpp} | 112 +++++++++++++++++++++++------ 4 files changed, 97 insertions(+), 47 deletions(-) rename PaintTest/{gtest.cpp => main.cpp} (54%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fd50a45be..848bec1f1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -371,7 +371,7 @@ file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_ file(GLOB_RECURSE ORCT2_PAINT_TEST_SOURCES "PaintTest/*.c" "PaintTest/*.cpp" "PaintTest/*.h") add_executable(test-paint ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES}) -set_target_properties(test-paint PROPERTIES COMPILE_FLAGS "-DUSE_GTEST -DNO_VEHICLES") +set_target_properties(test-paint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES") set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 0) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index f92ee74b64..e7cd26d521 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 00EFEE721CF1D80B0035213B /* NetworkKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00EFEE701CF1D80B0035213B /* NetworkKey.cpp */; }; 791166FB1D7486EF005912EA /* NetworkServerAdvertiser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 791166F91D7486EF005912EA /* NetworkServerAdvertiser.cpp */; }; 8594C0601D885CF600235E93 /* track_data_old.c in Sources */ = {isa = PBXBuildFile; fileRef = 8594C05F1D885CF600235E93 /* track_data_old.c */; }; + 85AFA2111D7DB83E00221B42 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85AFA20F1D7DB83E00221B42 /* main.cpp */; }; C612A8991D64825300B634CA /* vehicle_data.c in Sources */ = {isa = PBXBuildFile; fileRef = C612A8971D64825300B634CA /* vehicle_data.c */; }; C61FB7201CF6180C004CE991 /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38BA1CF3006400659A24 /* libssl.dylib */; }; C61FB7211CF618BA004CE991 /* libssl.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38BA1CF3006400659A24 /* libssl.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; @@ -491,6 +492,8 @@ 791166F91D7486EF005912EA /* NetworkServerAdvertiser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkServerAdvertiser.cpp; sourceTree = ""; }; 791166FA1D7486EF005912EA /* NetworkServerAdvertiser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkServerAdvertiser.h; sourceTree = ""; }; 8594C05F1D885CF600235E93 /* track_data_old.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = track_data_old.c; sourceTree = ""; }; + 85AFA20F1D7DB83E00221B42 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 85AFA2101D7DB83E00221B42 /* main.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = main.h; sourceTree = ""; }; C612A8971D64825300B634CA /* vehicle_data.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vehicle_data.c; sourceTree = ""; }; C612A8981D64825300B634CA /* vehicle_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vehicle_data.h; sourceTree = ""; }; C61FB7221CF86356004CE991 /* NetworkUser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkUser.cpp; sourceTree = ""; usesTabs = 0; }; @@ -1151,10 +1154,10 @@ isa = PBXGroup; children = ( C64FDAC41D6DA55E00F259B9 /* compat.c */, - C64FDAC71D6DA72400F259B9 /* main.c */, - C64FDAC91D6DA92D00F259B9 /* data.c */, C64FDAC91D6DA92D00F259B9 /* data.c */, + 85AFA20F1D7DB83E00221B42 /* main.cpp */, C64FDAC71D6DA72400F259B9 /* main.c */, + 85AFA2101D7DB83E00221B42 /* main.h */, ); path = PaintTest; sourceTree = ""; @@ -2359,6 +2362,7 @@ C64FDA651D6D9A2100F259B9 /* bobsleigh_coaster.c in Sources */, C64FDA661D6D9A2100F259B9 /* compact_inverted_coaster.c in Sources */, C64FDA671D6D9A2100F259B9 /* corkscrew_roller_coaster.c in Sources */, + 85AFA2111D7DB83E00221B42 /* main.cpp in Sources */, C64FDA681D6D9A2100F259B9 /* flying_roller_coaster.c in Sources */, C64FDA691D6D9A2100F259B9 /* giga_coaster.c in Sources */, C64FDA6A1D6D9A2100F259B9 /* heartline_twister_coaster.c in Sources */, @@ -3079,6 +3083,7 @@ C64FDA621D6D99F400F259B9 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; D497D0731C20FD52002BF46A /* Build configuration list for PBXProject "OpenRCT2" */ = { isa = XCConfigurationList; diff --git a/PaintTest/main.c b/PaintTest/main.c index 3902a8b4bd..cd029696cf 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -750,24 +750,3 @@ void initHooks() { addhook(0x00663105, (int) intercept_metal_a_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, EAX); addhook(0x00663584, (int) intercept_metal_b_supports, 0, (int[]) {EAX, EBX, EDX, EDI, EBP, END}, 0, EAX); } - -#if !defined(USE_GTEST) - -int main(int argc, const char *argv[]) { - initHooks(); - - bool success = true; - for (int i = 0; i < 91; i++) { - if (!rideIsImplemented(i)) { - continue; - } - - if (!testRide(i)) { - success = false; - } - } - - return success ? 0 : 1; -} - -#endif diff --git a/PaintTest/gtest.cpp b/PaintTest/main.cpp similarity index 54% rename from PaintTest/gtest.cpp rename to PaintTest/main.cpp index 802f959415..648e14ddde 100644 --- a/PaintTest/gtest.cpp +++ b/PaintTest/main.cpp @@ -14,8 +14,6 @@ *****************************************************************************/ #pragma endregion -#ifdef USE_GTEST - #include #include #include @@ -38,10 +36,70 @@ extern const utf8string RideNames[91]; extern const utf8string TrackNames[256]; extern const utf8string FlatTrackNames[256]; +enum CLIColour { + RED, + GREEN, +}; + +bool gTestColor = true; + +bool CStringEquals(const char *lhs, const char *rhs) { + if (lhs == NULL) return rhs == NULL; + + if (rhs == NULL) return false; + + return strcmp(lhs, rhs) == 0; +} + +bool ShouldUseColor() { + if (gTestColor == false) { + return false; + } + + const char* const term = getenv("TERM"); + const bool term_supports_color = + CStringEquals(term, "xterm") || + CStringEquals(term, "xterm-color") || + CStringEquals(term, "xterm-256color") || + CStringEquals(term, "screen") || + CStringEquals(term, "screen-256color") || + CStringEquals(term, "tmux") || + CStringEquals(term, "tmux-256color") || + CStringEquals(term, "rxvt-unicode") || + CStringEquals(term, "rxvt-unicode-256color") || + CStringEquals(term, "linux") || + CStringEquals(term, "cygwin"); + + return term_supports_color; +} + +const char* GetAnsiColorCode(CLIColour color) { + switch (color) { + case RED: return "1"; + case GREEN: return "2"; + default: return NULL; + }; +} + +void ColouredPrintF(CLIColour colour, const char* fmt, ...) { + va_list args; + va_start(args, fmt); + + if(!ShouldUseColor()) { + vprintf(fmt, args); + va_end(args); + return; + } + + printf("\033[0;3%sm", GetAnsiColorCode(colour)); + vprintf(fmt, args); + printf("\033[m"); + va_end(args); +} + int main(int argc, char *argv[]) { std::vector testCases; - bool gTestColor = true; for (int i = 0; i < argc; ++i) { char *arg = argv[i]; if (strcmp(arg, "--gtest_color=no") == 0) { @@ -49,10 +107,6 @@ int main(int argc, char *argv[]) { } } - const utf8 *ansiRed = gTestColor ? "\x1b[31m" : ""; - const utf8 *ansiGreen = gTestColor ? "\x1b[32m" : ""; - const utf8 *ansiReset = gTestColor ? "\x1b[0m" : ""; - for (uint8 rideType = 0; rideType < 91; rideType++) { if (!rideIsImplemented(rideType)) { continue; @@ -81,15 +135,19 @@ int main(int argc, char *argv[]) { testCount += tc.trackTypes.size(); } - printf("%s[==========]%s Running %d tests from %d test cases.\n", ansiGreen, ansiReset, testCount, testCaseCount); - printf("%s[----------]%s Global test environment set-up.\n", ansiGreen, ansiReset); + ColouredPrintF(CLIColour::GREEN, "[==========] "); + printf("Running %d tests from %d test cases.\n", testCount, testCaseCount); + + ColouredPrintF(CLIColour::GREEN, "[----------] "); + printf("Global test environment set-up.\n"); initHooks(); int successCount = 0; std::vector failures; for (auto &&tc : testCases) { const utf8string rideTypeName = RideNames[tc.rideType]; - printf("%s[----------]%s %lu tests from %s\n", ansiGreen, ansiReset, tc.trackTypes.size(), rideTypeName); + ColouredPrintF(CLIColour::GREEN, "[----------] "); + printf("%lu tests from %s\n", tc.trackTypes.size(), rideTypeName); for (auto &&trackType : tc.trackTypes) { utf8string trackTypeName; @@ -99,34 +157,44 @@ int main(int argc, char *argv[]) { trackTypeName = TrackNames[trackType]; } - printf("%s[ RUN ]%s %s.%s\n", ansiGreen, ansiReset, rideTypeName, trackTypeName); + ColouredPrintF(CLIColour::GREEN, "[ RUN ] "); + printf("%s.%s\n", rideTypeName, trackTypeName); bool success = testTrackPainting(tc.rideType, trackType); if (!success) { - printf("%s[ FAILED ]%s %s.%s (0 ms)\n", ansiRed, ansiReset, rideTypeName, trackTypeName); utf8string testCaseName = new utf8[64]; sprintf(testCaseName, "%s.%s", rideTypeName, trackTypeName); + + ColouredPrintF(CLIColour::RED, "[ FAILED ] "); + printf("%s (0 ms)\n", testCaseName); failures.push_back(testCaseName); } else { - printf("%s[ OK ]%s %s.%s (0 ms)\n", ansiGreen, ansiReset, rideTypeName, trackTypeName); + ColouredPrintF(CLIColour::GREEN, "[ OK ] "); + printf("%s.%s (0 ms)\n", rideTypeName, trackTypeName); successCount++; } } - printf("%s[----------]%s %lu tests from %s (0 ms total)\n", ansiGreen, ansiReset, tc.trackTypes.size(), - rideTypeName); + ColouredPrintF(CLIColour::GREEN, "[----------] "); + printf("%lu tests from %s (0 ms total)\n", tc.trackTypes.size(), rideTypeName); } printf("\n"); - printf("%s[----------]%s Global test environment tear-down\n", ansiGreen, ansiReset); - printf("%s[==========]%s %d tests from %d test cases ran. (0 ms total).\n", ansiGreen, ansiReset, testCount, - testCaseCount); - printf("%s[ PASSED ]%s %d tests.\n", ansiGreen, ansiReset, successCount); + ColouredPrintF(CLIColour::GREEN, "[----------] "); + printf("Global test environment tear-down\n"); + + ColouredPrintF(CLIColour::GREEN, "[==========] "); + printf("%d tests from %d test cases ran. (0 ms total).\n", testCount, testCaseCount); + + ColouredPrintF(CLIColour::GREEN, "[ PASSED ] "); + printf("%d tests.\n", successCount); if (failures.size() > 0) { - printf("%s[ FAILED ]%s %lu tests, listed below:\n", ansiRed, ansiReset, failures.size()); + ColouredPrintF(CLIColour::RED, "[ FAILED ] "); + printf("%lu tests, listed below:\n", failures.size()); for (auto &&failure : failures) { - printf("%s[ FAILED ]%s %s\n", ansiRed, ansiReset, failure); + ColouredPrintF(CLIColour::RED, "[ FAILED ] "); + printf("%s\n", failure); delete(failure); } @@ -139,5 +207,3 @@ int main(int argc, char *argv[]) { return 0; } - -#endif // USE_GTEST From 99d3579c9fd795e9485e6d830361a2ef15d95bf8 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 17:26:08 +0200 Subject: [PATCH 29/71] Define gMapSizeUnits --- PaintTest/compat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/PaintTest/compat.c b/PaintTest/compat.c index a4cccc9503..beb511f8f5 100644 --- a/PaintTest/compat.c +++ b/PaintTest/compat.c @@ -30,6 +30,7 @@ rct_map_element *gMapElements = (rct_map_element *) RCT2_ADDRESS_MAP_ELEMENTS; rct_map_element **gMapElementTilePointers = (rct_map_element **) RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS; rct_ride *gRideList = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride); rct_sprite *sprite_list = RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite); +sint16 gMapSizeUnits; const rct_xy16 TileDirectionDelta[] = { From 5a44deac1bda13ceebd368ab588f81826e1184e4 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 17:26:20 +0200 Subject: [PATCH 30/71] Add dependency to segfiles --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 848bec1f1a..888be0bccc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -372,6 +372,7 @@ file(GLOB_RECURSE ORCT2_PAINT_TEST_SOURCES "PaintTest/*.c" "PaintTest/*.cpp" "Pa add_executable(test-paint ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES}) set_target_properties(test-paint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES") +add_dependencies(test-paint segfiles) set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 0) From 6d03980f204d8323576e93d923e60e8f69681f0f Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 17:26:33 +0200 Subject: [PATCH 31/71] Remove unoriginal junior RC tracks --- src/ride/coaster/junior_roller_coaster.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/ride/coaster/junior_roller_coaster.c b/src/ride/coaster/junior_roller_coaster.c index d0f1adce1c..3c0c3a9c3c 100644 --- a/src/ride/coaster/junior_roller_coaster.c +++ b/src/ride/coaster/junior_roller_coaster.c @@ -4570,15 +4570,6 @@ TRACK_PAINT_FUNCTION get_track_paint_function_junior_rc(int trackType, int direc case TRACK_ELEM_RIGHT_QUARTER_TURN_3_TILES_25_DEG_DOWN: return junior_rc_right_quarter_turn_3_tiles_25_deg_down_paint_setup; - case TRACK_ELEM_FLAT_TO_60_DEG_UP: - return junior_rc_flat_to_60_deg_up_paint_setup; - case TRACK_ELEM_60_DEG_UP_TO_FLAT: - return junior_rc_60_deg_up_to_flat_paint_setup; - case TRACK_ELEM_FLAT_TO_60_DEG_DOWN: - return junior_rc_flat_to_60_deg_down_paint_setup; - case TRACK_ELEM_60_DEG_DOWN_TO_FLAT: - return junior_rc_60_deg_down_to_flat_paint_setup; - case TRACK_ELEM_LEFT_HALF_BANKED_HELIX_UP_SMALL: return junior_rc_left_half_banked_helix_up_small_paint_setup; case TRACK_ELEM_RIGHT_HALF_BANKED_HELIX_UP_SMALL: From f412b67cc2757634f46509ab2cf8aa302c7f10e5 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 18:22:23 +0200 Subject: [PATCH 32/71] Fix main.c for gcc --- PaintTest/main.c | 55 ++++-------------------------------------------- PaintTest/main.h | 7 ++++++ 2 files changed, 11 insertions(+), 51 deletions(-) diff --git a/PaintTest/main.c b/PaintTest/main.c index cd029696cf..d01b3f133c 100644 --- a/PaintTest/main.c +++ b/PaintTest/main.c @@ -14,25 +14,16 @@ *****************************************************************************/ #pragma endregion +#include "main.h" #include "../src/paint/paint.h" #include "../src/paint/supports.h" #include "../src/ride/track_data.h" #include "../src/interface/viewport.h" #include "../src/hook.h" - #define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) #define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) - -#define ANSI_COLOR_RED "\x1b[31m" -#define ANSI_COLOR_GREEN "\x1b[32m" -#define ANSI_COLOR_YELLOW "\x1b[33m" -#define ANSI_COLOR_BLUE "\x1b[34m" -#define ANSI_COLOR_MAGENTA "\x1b[35m" -#define ANSI_COLOR_CYAN "\x1b[36m" -#define ANSI_COLOR_RESET "\x1b[0m" - static const uint32 PALETTE_98 = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; static const uint32 PALETTE_9C = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; static const uint32 PALETTE_A0 = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000; @@ -455,7 +446,7 @@ static void printFunctionCallArray(utf8string *out, function_call calls[], uint8 } } -int getTrackSequenceCount(uint8 rideType, uint8 trackType) { +static int getTrackSequenceCount(uint8 rideType, uint8 trackType) { int sequenceCount = 0; const rct_preview_track **trackBlocks; @@ -488,7 +479,7 @@ bool rideSupportsTrackType(int rideType, int trackType) { return supportsTrackType; } -bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { +static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { if (rideType == RIDE_TYPE_CHAIRLIFT) { if (trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION || trackType == TRACK_ELEM_END_STATION) { // These rides chechk neighbouring tiles for tracks @@ -542,7 +533,7 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { RCT2_GLOBAL(0x009E3250, rct_map_element *) = &surfaceElement; callCount = 0; - memset(&calls, sizeof(calls), 0); + memset(&calls, 0, sizeof(calls)); TRACK_PAINT_FUNCTION **trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; uint32 *trackDirectionList = (uint32 *) trackTypeList[trackType]; @@ -627,44 +618,6 @@ bool testTrackPainting(int rideType, int trackType) { return success; } -bool testRide(int rideType) { - TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; - - bool returnSuccess = true; - - printf("- %s (%d)\n", RideNames[rideType], rideType); - for (int trackType = 0; trackType < 256; trackType++) { - if (newPaintGetter(trackType, 0) == NULL) { - continue; - } - - utf8string error = malloc(2048); - bool success = testTrackElement(rideType, trackType, &error); - - if (!success) { - printf(ANSI_COLOR_RED); - returnSuccess = false; - } - int sequenceCount = getTrackSequenceCount(rideType, trackType); - if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) { - printf(" - %s (%d)", FlatTrackNames[trackType], sequenceCount); - } else { - printf(" - %s (%d)", TrackNames[trackType], sequenceCount); - } - - - if (!success) { - printf(" FAILED!\n %s", error); - } - - free(error); - printf(ANSI_COLOR_RESET "\n"); - - } - - return returnSuccess; -} - static int intercept_draw_6c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uint32 esi, uint32 edi, uint32 ebp) { registers regs = {.eax =eax, .ebx = ebx, .ecx = ecx, .edx = edx, .esi = esi, .edi = edi, .ebp = ebp}; if ((ebp & 0x03) != get_current_rotation()) { diff --git a/PaintTest/main.h b/PaintTest/main.h index 0254acc619..7288e89b87 100644 --- a/PaintTest/main.h +++ b/PaintTest/main.h @@ -14,8 +14,15 @@ *****************************************************************************/ #pragma endregion +#ifndef _TEST_PAINT_MAIN_H_ +#define _TEST_PAINT_MAIN_H_ + +#include "../src/common.h" + bool testRide(int rideType); void initHooks(); bool rideIsImplemented(int rideType); bool rideSupportsTrackType(int rideType, int trackType); bool testTrackPainting(int rideType, int trackType); + +#endif // #endif _TEST_PAINT_MAIN_H_ From bce52ea5f6b5a34be13b548084150f6fc429f0fe Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 18:38:32 +0200 Subject: [PATCH 33/71] Fix gcc warnings in main.cpp --- PaintTest/main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PaintTest/main.cpp b/PaintTest/main.cpp index 648e14ddde..2a2226e311 100644 --- a/PaintTest/main.cpp +++ b/PaintTest/main.cpp @@ -43,7 +43,7 @@ enum CLIColour { bool gTestColor = true; -bool CStringEquals(const char *lhs, const char *rhs) { +static bool CStringEquals(const char *lhs, const char *rhs) { if (lhs == NULL) return rhs == NULL; if (rhs == NULL) return false; @@ -51,7 +51,7 @@ bool CStringEquals(const char *lhs, const char *rhs) { return strcmp(lhs, rhs) == 0; } -bool ShouldUseColor() { +static bool ShouldUseColor() { if (gTestColor == false) { return false; } @@ -73,7 +73,7 @@ bool ShouldUseColor() { return term_supports_color; } -const char* GetAnsiColorCode(CLIColour color) { +static const char* GetAnsiColorCode(CLIColour color) { switch (color) { case RED: return "1"; case GREEN: return "2"; @@ -81,7 +81,7 @@ const char* GetAnsiColorCode(CLIColour color) { }; } -void ColouredPrintF(CLIColour colour, const char* fmt, ...) { +static void ColouredPrintF(CLIColour colour, const char* fmt, ...) { va_list args; va_start(args, fmt); @@ -147,7 +147,7 @@ int main(int argc, char *argv[]) { for (auto &&tc : testCases) { const utf8string rideTypeName = RideNames[tc.rideType]; ColouredPrintF(CLIColour::GREEN, "[----------] "); - printf("%lu tests from %s\n", tc.trackTypes.size(), rideTypeName); + printf("%d tests from %s\n", (int)tc.trackTypes.size(), rideTypeName); for (auto &&trackType : tc.trackTypes) { utf8string trackTypeName; @@ -175,7 +175,7 @@ int main(int argc, char *argv[]) { } ColouredPrintF(CLIColour::GREEN, "[----------] "); - printf("%lu tests from %s (0 ms total)\n", tc.trackTypes.size(), rideTypeName); + printf("%d tests from %s (0 ms total)\n", (int)tc.trackTypes.size(), rideTypeName); } printf("\n"); @@ -190,7 +190,7 @@ int main(int argc, char *argv[]) { if (failures.size() > 0) { ColouredPrintF(CLIColour::RED, "[ FAILED ] "); - printf("%lu tests, listed below:\n", failures.size()); + printf("%d tests, listed below:\n", (int)failures.size()); for (auto &&failure : failures) { ColouredPrintF(CLIColour::RED, "[ FAILED ] "); @@ -200,7 +200,7 @@ int main(int argc, char *argv[]) { printf("\n"); - printf("%lu FAILED TESTS\n", failures.size()); + printf("%d FAILED TESTS\n", (int)failures.size()); return 1; } From 51d8d3ace34781b4f4a878183ae0700210c7ac16 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 18:43:17 +0200 Subject: [PATCH 34/71] =?UTF-8?q?Don=E2=80=99t=20build=20test=20target=20b?= =?UTF-8?q?y=20default?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 888be0bccc..ef0ef5dbdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -370,7 +370,7 @@ file(GLOB_RECURSE ORCT2_RIDE_SOURCES "src/ride/*/*.c") file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") file(GLOB_RECURSE ORCT2_PAINT_TEST_SOURCES "PaintTest/*.c" "PaintTest/*.cpp" "PaintTest/*.h") -add_executable(test-paint ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES}) +add_executable(test-paint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES}) set_target_properties(test-paint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES") add_dependencies(test-paint segfiles) From ad2e8690bca926a8fb06568c4f19a12466694da3 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 19:10:29 +0200 Subject: [PATCH 35/71] Rename main.c to intercept.c --- OpenRCT2.xcodeproj/project.pbxproj | 12 ++++++------ PaintTest/{main.c => intercept.c} | 2 +- PaintTest/{main.h => intercept.h} | 6 +++--- PaintTest/main.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) rename PaintTest/{main.c => intercept.c} (99%) rename PaintTest/{main.h => intercept.h} (90%) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index e7cd26d521..766e06fb45 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -105,7 +105,7 @@ C64FDAC21D6DA0B800F259B9 /* diagnostic.c in Sources */ = {isa = PBXBuildFile; fileRef = D44270FE1CC81B3200D84D28 /* diagnostic.c */; }; C64FDAC31D6DA41000F259B9 /* track_paint.c in Sources */ = {isa = PBXBuildFile; fileRef = D442717D1CC81B3200D84D28 /* track_paint.c */; }; C64FDAC51D6DA55E00F259B9 /* compat.c in Sources */ = {isa = PBXBuildFile; fileRef = C64FDAC41D6DA55E00F259B9 /* compat.c */; }; - C64FDAC81D6DA72400F259B9 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = C64FDAC71D6DA72400F259B9 /* main.c */; }; + C64FDAC81D6DA72400F259B9 /* intercept.c in Sources */ = {isa = PBXBuildFile; fileRef = C64FDAC71D6DA72400F259B9 /* intercept.c */; }; C64FDACA1D6DA92D00F259B9 /* data.c in Sources */ = {isa = PBXBuildFile; fileRef = C64FDAC91D6DA92D00F259B9 /* data.c */; }; C64FDACB1D6DBCC700F259B9 /* hook.c in Sources */ = {isa = PBXBuildFile; fileRef = D44271121CC81B3200D84D28 /* hook.c */; }; C650B2191CCABBDD00B4D91C /* S4Importer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C650B2151CCABBDD00B4D91C /* S4Importer.cpp */; }; @@ -493,14 +493,14 @@ 791166FA1D7486EF005912EA /* NetworkServerAdvertiser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkServerAdvertiser.h; sourceTree = ""; }; 8594C05F1D885CF600235E93 /* track_data_old.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = track_data_old.c; sourceTree = ""; }; 85AFA20F1D7DB83E00221B42 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; - 85AFA2101D7DB83E00221B42 /* main.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = main.h; sourceTree = ""; }; + 85AFA2101D7DB83E00221B42 /* intercept.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = intercept.h; sourceTree = ""; }; C612A8971D64825300B634CA /* vehicle_data.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vehicle_data.c; sourceTree = ""; }; C612A8981D64825300B634CA /* vehicle_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vehicle_data.h; sourceTree = ""; }; C61FB7221CF86356004CE991 /* NetworkUser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkUser.cpp; sourceTree = ""; usesTabs = 0; }; C61FB7231CF86356004CE991 /* NetworkUser.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = NetworkUser.h; sourceTree = ""; usesTabs = 0; }; C64FDA5D1D6D99F400F259B9 /* PaintTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = PaintTest; sourceTree = BUILT_PRODUCTS_DIR; }; C64FDAC41D6DA55E00F259B9 /* compat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = compat.c; sourceTree = ""; }; - C64FDAC71D6DA72400F259B9 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; + C64FDAC71D6DA72400F259B9 /* intercept.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = intercept.c; sourceTree = ""; }; C64FDAC91D6DA92D00F259B9 /* data.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = data.c; sourceTree = ""; }; C650B2151CCABBDD00B4D91C /* S4Importer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = S4Importer.cpp; sourceTree = ""; usesTabs = 0; }; C650B2161CCABBDD00B4D91C /* S4Importer.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = S4Importer.h; sourceTree = ""; usesTabs = 0; }; @@ -1155,9 +1155,9 @@ children = ( C64FDAC41D6DA55E00F259B9 /* compat.c */, C64FDAC91D6DA92D00F259B9 /* data.c */, + C64FDAC71D6DA72400F259B9 /* intercept.c */, + 85AFA2101D7DB83E00221B42 /* intercept.h */, 85AFA20F1D7DB83E00221B42 /* main.cpp */, - C64FDAC71D6DA72400F259B9 /* main.c */, - 85AFA2101D7DB83E00221B42 /* main.h */, ); path = PaintTest; sourceTree = ""; @@ -2373,7 +2373,7 @@ C64FDA6F1D6D9A2100F259B9 /* lay_down_roller_coaster.c in Sources */, C64FDA701D6D9A2100F259B9 /* lim_launched_roller_coaster.c in Sources */, C64FDA711D6D9A2100F259B9 /* looping_roller_coaster.c in Sources */, - C64FDAC81D6DA72400F259B9 /* main.c in Sources */, + C64FDAC81D6DA72400F259B9 /* intercept.c in Sources */, C64FDA721D6D9A2100F259B9 /* mine_ride.c in Sources */, C64FDA731D6D9A2100F259B9 /* mine_train_coaster.c in Sources */, C64FDA741D6D9A2100F259B9 /* mini_roller_coaster.c in Sources */, diff --git a/PaintTest/main.c b/PaintTest/intercept.c similarity index 99% rename from PaintTest/main.c rename to PaintTest/intercept.c index d01b3f133c..1a02cc41c0 100644 --- a/PaintTest/main.c +++ b/PaintTest/intercept.c @@ -14,7 +14,7 @@ *****************************************************************************/ #pragma endregion -#include "main.h" +#include "intercept.h" #include "../src/paint/paint.h" #include "../src/paint/supports.h" #include "../src/ride/track_data.h" diff --git a/PaintTest/main.h b/PaintTest/intercept.h similarity index 90% rename from PaintTest/main.h rename to PaintTest/intercept.h index 7288e89b87..e5aaa28bfc 100644 --- a/PaintTest/main.h +++ b/PaintTest/intercept.h @@ -14,8 +14,8 @@ *****************************************************************************/ #pragma endregion -#ifndef _TEST_PAINT_MAIN_H_ -#define _TEST_PAINT_MAIN_H_ +#ifndef _TEST_PAINT_INTERCEPT_H_ +#define _TEST_PAINT_INTERCEPT_H_ #include "../src/common.h" @@ -25,4 +25,4 @@ bool rideIsImplemented(int rideType); bool rideSupportsTrackType(int rideType, int trackType); bool testTrackPainting(int rideType, int trackType); -#endif // #endif _TEST_PAINT_MAIN_H_ +#endif // #endif _TEST_PAINT_INTERCEPT_H_ diff --git a/PaintTest/main.cpp b/PaintTest/main.cpp index 2a2226e311..71d362521b 100644 --- a/PaintTest/main.cpp +++ b/PaintTest/main.cpp @@ -19,7 +19,7 @@ #include extern "C" { -#include "main.h" +#include "intercept.h" #include "../src/rct2.h" #include "../src/ride/ride.h" #include "../src/ride/ride_data.h" From d456d86f69e05473514a1336edb222ebc70d5398 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 19:16:46 +0200 Subject: [PATCH 36/71] Add header for data.h --- OpenRCT2.xcodeproj/project.pbxproj | 2 ++ PaintTest/data.h | 26 ++++++++++++++++++++++++++ PaintTest/main.cpp | 5 +---- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 PaintTest/data.h diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index 766e06fb45..fe50264b7b 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -494,6 +494,7 @@ 8594C05F1D885CF600235E93 /* track_data_old.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = track_data_old.c; sourceTree = ""; }; 85AFA20F1D7DB83E00221B42 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 85AFA2101D7DB83E00221B42 /* intercept.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = intercept.h; sourceTree = ""; }; + 85AFA2141D7DDFA100221B42 /* data.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = data.h; sourceTree = ""; }; C612A8971D64825300B634CA /* vehicle_data.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vehicle_data.c; sourceTree = ""; }; C612A8981D64825300B634CA /* vehicle_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vehicle_data.h; sourceTree = ""; }; C61FB7221CF86356004CE991 /* NetworkUser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkUser.cpp; sourceTree = ""; usesTabs = 0; }; @@ -1155,6 +1156,7 @@ children = ( C64FDAC41D6DA55E00F259B9 /* compat.c */, C64FDAC91D6DA92D00F259B9 /* data.c */, + 85AFA2141D7DDFA100221B42 /* data.h */, C64FDAC71D6DA72400F259B9 /* intercept.c */, 85AFA2101D7DB83E00221B42 /* intercept.h */, 85AFA20F1D7DB83E00221B42 /* main.cpp */, diff --git a/PaintTest/data.h b/PaintTest/data.h new file mode 100644 index 0000000000..6e6b55dd58 --- /dev/null +++ b/PaintTest/data.h @@ -0,0 +1,26 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#ifndef _TEST_PAINT_DATA_H_ +#define _TEST_PAINT_DATA_H_ + +#include "../src/common.h" + +extern const utf8string RideNames[91]; +extern const utf8string TrackNames[256]; +extern const utf8string FlatTrackNames[256]; + +#endif // #endif _TEST_PAINT_DATA_H_ diff --git a/PaintTest/main.cpp b/PaintTest/main.cpp index 71d362521b..775db022bd 100644 --- a/PaintTest/main.cpp +++ b/PaintTest/main.cpp @@ -19,6 +19,7 @@ #include extern "C" { +#include "data.h" #include "intercept.h" #include "../src/rct2.h" #include "../src/ride/ride.h" @@ -32,10 +33,6 @@ typedef struct { std::vector trackTypes; } TestCase; -extern const utf8string RideNames[91]; -extern const utf8string TrackNames[256]; -extern const utf8string FlatTrackNames[256]; - enum CLIColour { RED, GREEN, From fbc28186dd6e451a63e36916f4af5fe318dfbeec Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 19:31:01 +0200 Subject: [PATCH 37/71] Make TestCase initialisation VS-friendly --- PaintTest/main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PaintTest/main.cpp b/PaintTest/main.cpp index 775db022bd..551cb06786 100644 --- a/PaintTest/main.cpp +++ b/PaintTest/main.cpp @@ -109,9 +109,8 @@ int main(int argc, char *argv[]) { continue; } - TestCase testCase = { - .rideType = rideType - }; + TestCase testCase = {0}; + testCase.rideType = rideType; if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) { testCase.trackTypes.push_back(RideConstructionDefaultTrackType[rideType]); From 5f624436864fafbbfad0e44fb86d998183753aab Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 5 Sep 2016 18:38:07 +0100 Subject: [PATCH 38/71] Add VS project files. Add code to allow calling into RCT2.exe --- PaintTest/main.cpp | 30 ++++++ PaintUnitTest.vcxproj | 214 +++++++++++++++++++++++++++++++++++++ PaintUnitTest.vcxproj.user | 11 ++ 3 files changed, 255 insertions(+) create mode 100644 PaintUnitTest.vcxproj create mode 100644 PaintUnitTest.vcxproj.user diff --git a/PaintTest/main.cpp b/PaintTest/main.cpp index 551cb06786..0efafc9e3e 100644 --- a/PaintTest/main.cpp +++ b/PaintTest/main.cpp @@ -94,6 +94,36 @@ static void ColouredPrintF(CLIColour colour, const char* fmt, ...) { va_end(args); } +#if defined(__WINDOWS__) +int main(int argc, char *argv[]); + +#define OPENRCT2_DLL_MODULE_NAME "openrct2.dll" + +static HMODULE _dllModule = NULL; + +BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) +{ + _dllModule = (HMODULE)hModule; + return TRUE; +} + +__declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + + if (_dllModule == NULL) { + _dllModule = GetModuleHandleA(OPENRCT2_DLL_MODULE_NAME); + } + + RCT2_GLOBAL(RCT2_ADDRESS_HINSTANCE, HINSTANCE) = hInstance; + + int gExitCode = main(0, NULL); + + exit(gExitCode); + return gExitCode; +} + +#endif + int main(int argc, char *argv[]) { std::vector testCases; diff --git a/PaintUnitTest.vcxproj b/PaintUnitTest.vcxproj new file mode 100644 index 0000000000..634ec535b1 --- /dev/null +++ b/PaintUnitTest.vcxproj @@ -0,0 +1,214 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {57E60BA1-FB76-4316-909E-C1449C142327} + PaintUnitTest + 8.1 + + + + DynamicLibrary + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)bin\ + $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ + openrct2 + $(SolutionDir)lib\include;$(SolutionDir)lib\include\breakpad;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(SolutionDir)lib\include\zlib;$(IncludePath) + $(SolutionDir)lib;$(LibraryPath) + + + + Level3 + Disabled + true + $(OpenRCT2_DEFINES);DEBUG;NO_VEHICLES;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PaintUnitTest.vcxproj.user b/PaintUnitTest.vcxproj.user new file mode 100644 index 0000000000..2d0a6983e6 --- /dev/null +++ b/PaintUnitTest.vcxproj.user @@ -0,0 +1,11 @@ + + + + $(TargetDir)\openrct2.exe + $(TargetDir) + WindowsLocalDebugger + + + true + + \ No newline at end of file From df202d86a6f4282a9b79aed317ac2f002c90fbbe Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 5 Sep 2016 23:41:42 +0200 Subject: [PATCH 39/71] Change folder structure --- CMakeLists.txt | 8 ++++---- OpenRCT2.xcodeproj/project.pbxproj | 15 ++++++++++++--- PaintUnitTest.vcxproj | 12 ++++++------ {PaintTest => test/testpaint}/compat.c | 16 ++++++++-------- {PaintTest => test/testpaint}/data.c | 2 +- {PaintTest => test/testpaint}/data.h | 2 +- {PaintTest => test/testpaint}/intercept.c | 10 +++++----- {PaintTest => test/testpaint}/intercept.h | 2 +- {PaintTest => test/testpaint}/main.cpp | 10 +++++----- 9 files changed, 43 insertions(+), 34 deletions(-) rename {PaintTest => test/testpaint}/compat.c (93%) rename {PaintTest => test/testpaint}/data.c (99%) rename {PaintTest => test/testpaint}/data.h (97%) rename {PaintTest => test/testpaint}/intercept.c (99%) rename {PaintTest => test/testpaint}/intercept.h (97%) rename {PaintTest => test/testpaint}/main.cpp (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef0ef5dbdb..ae260cfc2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -368,11 +368,11 @@ install(FILES ${DOC_FILES} DESTINATION share/doc/${PROJECT}) file(GLOB_RECURSE ORCT2_RIDE_SOURCES "src/ride/*/*.c") file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") -file(GLOB_RECURSE ORCT2_PAINT_TEST_SOURCES "PaintTest/*.c" "PaintTest/*.cpp" "PaintTest/*.h") +file(GLOB_RECURSE ORCT2_PAINT_TEST_SOURCES "test/testpaint/*.c" "test/testpaint/*.cpp" "test/testpaint/*.h") -add_executable(test-paint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES}) -set_target_properties(test-paint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES") -add_dependencies(test-paint segfiles) +add_executable(testpaint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES}) +set_target_properties(testpaint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES") +add_dependencies(testpaint segfiles) set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 0) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index fe50264b7b..f0c3d7dd73 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -1151,7 +1151,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - C64FDA5E1D6D99F400F259B9 /* PaintTest */ = { + 8546F74A1D7E1D220004004C /* Tests */ = { + isa = PBXGroup; + children = ( + C64FDA5E1D6D99F400F259B9 /* Paint */, + ); + name = Tests; + sourceTree = ""; + }; + C64FDA5E1D6D99F400F259B9 /* Paint */ = { isa = PBXGroup; children = ( C64FDAC41D6DA55E00F259B9 /* compat.c */, @@ -1161,7 +1169,8 @@ 85AFA2101D7DB83E00221B42 /* intercept.h */, 85AFA20F1D7DB83E00221B42 /* main.cpp */, ); - path = PaintTest; + name = Paint; + path = test/testpaint; sourceTree = ""; }; C650B2141CCABBDD00B4D91C /* rct1 */ = { @@ -2062,8 +2071,8 @@ children = ( D41B72431C21015A0080A7B9 /* Sources */, D497D07A1C20FD52002BF46A /* Resources */, + 8546F74A1D7E1D220004004C /* Tests */, D41B73ED1C21017D0080A7B9 /* Libraries */, - C64FDA5E1D6D99F400F259B9 /* PaintTest */, D497D0791C20FD52002BF46A /* Products */, ); sourceTree = ""; diff --git a/PaintUnitTest.vcxproj b/PaintUnitTest.vcxproj index 634ec535b1..7355d87bb7 100644 --- a/PaintUnitTest.vcxproj +++ b/PaintUnitTest.vcxproj @@ -117,14 +117,14 @@ - - + + - - - - + + + + diff --git a/PaintTest/compat.c b/test/testpaint/compat.c similarity index 93% rename from PaintTest/compat.c rename to test/testpaint/compat.c index beb511f8f5..c8b7bb015c 100644 --- a/PaintTest/compat.c +++ b/test/testpaint/compat.c @@ -14,14 +14,14 @@ *****************************************************************************/ #pragma endregion -#include "../src/config.h" -#include "../src/object.h" -#include "../src/interface/colour.h" -#include "../src/interface/viewport.h" -#include "../src/ride/ride.h" -#include "../src/ride/track.h" -#include "../src/world/sprite.h" -#include "../src/paint/map_element/map_element.h" +#include "../../src/config.h" +#include "../../src/object.h" +#include "../../src/interface/colour.h" +#include "../../src/interface/viewport.h" +#include "../../src/ride/ride.h" +#include "../../src/ride/track.h" +#include "../../src/world/sprite.h" +#include "../../src/paint/map_element/map_element.h" #define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) #define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) diff --git a/PaintTest/data.c b/test/testpaint/data.c similarity index 99% rename from PaintTest/data.c rename to test/testpaint/data.c index 09c69abdd7..39b98da4a8 100644 --- a/PaintTest/data.c +++ b/test/testpaint/data.c @@ -14,7 +14,7 @@ *****************************************************************************/ #pragma endregion -#include "../src/common.h" +#include "../../src/common.h" const utf8string RideNames[91] = { "SpiralRollerCoaster", diff --git a/PaintTest/data.h b/test/testpaint/data.h similarity index 97% rename from PaintTest/data.h rename to test/testpaint/data.h index 6e6b55dd58..9e685786ed 100644 --- a/PaintTest/data.h +++ b/test/testpaint/data.h @@ -17,7 +17,7 @@ #ifndef _TEST_PAINT_DATA_H_ #define _TEST_PAINT_DATA_H_ -#include "../src/common.h" +#include "../../src/common.h" extern const utf8string RideNames[91]; extern const utf8string TrackNames[256]; diff --git a/PaintTest/intercept.c b/test/testpaint/intercept.c similarity index 99% rename from PaintTest/intercept.c rename to test/testpaint/intercept.c index 1a02cc41c0..4cf6a158fa 100644 --- a/PaintTest/intercept.c +++ b/test/testpaint/intercept.c @@ -15,11 +15,11 @@ #pragma endregion #include "intercept.h" -#include "../src/paint/paint.h" -#include "../src/paint/supports.h" -#include "../src/ride/track_data.h" -#include "../src/interface/viewport.h" -#include "../src/hook.h" +#include "../../src/paint/paint.h" +#include "../../src/paint/supports.h" +#include "../../src/ride/track_data.h" +#include "../../src/interface/viewport.h" +#include "../../src/hook.h" #define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) #define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) diff --git a/PaintTest/intercept.h b/test/testpaint/intercept.h similarity index 97% rename from PaintTest/intercept.h rename to test/testpaint/intercept.h index e5aaa28bfc..7adb7d3d42 100644 --- a/PaintTest/intercept.h +++ b/test/testpaint/intercept.h @@ -17,7 +17,7 @@ #ifndef _TEST_PAINT_INTERCEPT_H_ #define _TEST_PAINT_INTERCEPT_H_ -#include "../src/common.h" +#include "../../src/common.h" bool testRide(int rideType); void initHooks(); diff --git a/PaintTest/main.cpp b/test/testpaint/main.cpp similarity index 97% rename from PaintTest/main.cpp rename to test/testpaint/main.cpp index 0efafc9e3e..cf4e3572b2 100644 --- a/PaintTest/main.cpp +++ b/test/testpaint/main.cpp @@ -21,11 +21,11 @@ extern "C" { #include "data.h" #include "intercept.h" -#include "../src/rct2.h" -#include "../src/ride/ride.h" -#include "../src/ride/ride_data.h" -#include "../src/ride/track.h" -#include "../src/ride/track_data.h" +#include "../../src/rct2.h" +#include "../../src/ride/ride.h" +#include "../../src/ride/ride_data.h" +#include "../../src/ride/track.h" +#include "../../src/ride/track_data.h" } typedef struct { From 5f0f49be46e2244ddcc904681845595920fb1f16 Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 5 Sep 2016 23:39:36 +0100 Subject: [PATCH 40/71] Move testpaint vs project to new location --- PaintUnitTest.vcxproj => test/testpaint/testpaint.vcxproj | 0 .../testpaint/testpaint.vcxproj.user | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename PaintUnitTest.vcxproj => test/testpaint/testpaint.vcxproj (100%) rename PaintUnitTest.vcxproj.user => test/testpaint/testpaint.vcxproj.user (100%) diff --git a/PaintUnitTest.vcxproj b/test/testpaint/testpaint.vcxproj similarity index 100% rename from PaintUnitTest.vcxproj rename to test/testpaint/testpaint.vcxproj diff --git a/PaintUnitTest.vcxproj.user b/test/testpaint/testpaint.vcxproj.user similarity index 100% rename from PaintUnitTest.vcxproj.user rename to test/testpaint/testpaint.vcxproj.user From a30f2b8f7fedb0a7c05bd108c3b32855ff6c1680 Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 5 Sep 2016 23:40:44 +0100 Subject: [PATCH 41/71] Remove x64 configurations from vs project --- test/testpaint/testpaint.vcxproj | 47 -------------------------------- 1 file changed, 47 deletions(-) diff --git a/test/testpaint/testpaint.vcxproj b/test/testpaint/testpaint.vcxproj index 7355d87bb7..6db7680a22 100644 --- a/test/testpaint/testpaint.vcxproj +++ b/test/testpaint/testpaint.vcxproj @@ -9,14 +9,6 @@ Release Win32 - - Debug - x64 - - - Release - x64 - {57E60BA1-FB76-4316-909E-C1449C142327} @@ -37,19 +29,6 @@ true MultiByte - - Application - true - v140 - MultiByte - - - Application - false - v140 - true - MultiByte - @@ -61,12 +40,6 @@ - - - - - - $(SolutionDir)bin\ @@ -83,13 +56,6 @@ $(OpenRCT2_DEFINES);DEBUG;NO_VEHICLES;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - - - Level3 - Disabled - true - - Level3 @@ -103,19 +69,6 @@ true - - - Level3 - MaxSpeed - true - true - true - - - true - true - - From de5aa4b7d6a9c2e0e784db55cef766dc80bace8d Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 5 Sep 2016 23:50:32 +0100 Subject: [PATCH 42/71] Fix VS solution and test --- openrct2.sln | 16 +++ test/testpaint/testpaint.vcxproj | 187 ++++++++++++++++--------------- 2 files changed, 113 insertions(+), 90 deletions(-) diff --git a/openrct2.sln b/openrct2.sln index a23532f33a..a9f6803221 100644 --- a/openrct2.sln +++ b/openrct2.sln @@ -5,6 +5,12 @@ VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2", "openrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testpaint", "test\testpaint\testpaint.vcxproj", "{57E60BA1-FB76-4316-909E-C1449C142327}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2202A816-377D-4FA0-A7AF-7D4105F8A4FB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{480B577D-4E4A-4757-9A42-28A9AD33E6B0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -21,8 +27,18 @@ Global {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|x64.ActiveCfg = Release|x64 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|x64.Build.0 = Release|x64 + {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|Win32.ActiveCfg = Debug|Win32 + {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|Win32.Build.0 = Debug|Win32 + {57E60BA1-FB76-4316-909E-C1449C142327}.Debug|x64.ActiveCfg = Debug|Win32 + {57E60BA1-FB76-4316-909E-C1449C142327}.Release|Win32.ActiveCfg = Release|Win32 + {57E60BA1-FB76-4316-909E-C1449C142327}.Release|Win32.Build.0 = Release|Win32 + {57E60BA1-FB76-4316-909E-C1449C142327}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {D24D94F6-2A74-480C-B512-629C306CE92F} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB} + {57E60BA1-FB76-4316-909E-C1449C142327} = {480B577D-4E4A-4757-9A42-28A9AD33E6B0} + EndGlobalSection EndGlobal diff --git a/test/testpaint/testpaint.vcxproj b/test/testpaint/testpaint.vcxproj index 6db7680a22..3061cb2e8c 100644 --- a/test/testpaint/testpaint.vcxproj +++ b/test/testpaint/testpaint.vcxproj @@ -12,7 +12,7 @@ {57E60BA1-FB76-4316-909E-C1449C142327} - PaintUnitTest + testpaint 8.1 @@ -42,7 +42,14 @@ - $(SolutionDir)bin\ + $(SolutionDir)bin\testpaint + $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ + openrct2 + $(SolutionDir)lib\include;$(SolutionDir)lib\include\breakpad;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(SolutionDir)lib\include\zlib;$(IncludePath) + $(SolutionDir)lib;$(LibraryPath) + + + $(SolutionDir)bin\testpaint $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ openrct2 $(SolutionDir)lib\include;$(SolutionDir)lib\include\breakpad;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(SolutionDir)lib\include\zlib;$(IncludePath) @@ -70,96 +77,96 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From f354c0ec3f1c5472e6dca21ff01dde123b835364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Tue, 6 Sep 2016 14:55:44 +0200 Subject: [PATCH 43/71] Fix testpaint target for Linux --- CMakeLists.txt | 2 +- src/openrct2.c | 2 +- test/testpaint/main.cpp | 99 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae260cfc2d..7ab7d3572f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -370,7 +370,7 @@ file(GLOB_RECURSE ORCT2_RIDE_SOURCES "src/ride/*/*.c") file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") file(GLOB_RECURSE ORCT2_PAINT_TEST_SOURCES "test/testpaint/*.c" "test/testpaint/*.cpp" "test/testpaint/*.h") -add_executable(testpaint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES}) +add_executable(testpaint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES} ${RCT2_SECTIONS}) set_target_properties(testpaint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES") add_dependencies(testpaint segfiles) diff --git a/src/openrct2.c b/src/openrct2.c index 94a9546c67..44c980e5c7 100644 --- a/src/openrct2.c +++ b/src/openrct2.c @@ -594,7 +594,7 @@ bool openrct2_setup_rct2_segment() } #if !defined(USE_MMAP) // section: text - err = mprotect((void *)0x401000, 0x8a4000 - 0x401000, PROT_READ | PROT_EXEC); + err = mprotect((void *)0x401000, 0x8a4000 - 0x401000, PROT_READ | PROT_EXEC | PROT_WRITE); if (err != 0) { perror("mprotect"); diff --git a/test/testpaint/main.cpp b/test/testpaint/main.cpp index cf4e3572b2..7e3ac58b90 100644 --- a/test/testpaint/main.cpp +++ b/test/testpaint/main.cpp @@ -18,6 +18,11 @@ #include #include +#if defined(__unix__) +#include +#include +#endif // defined(__unix__) + extern "C" { #include "data.h" #include "intercept.h" @@ -124,6 +129,99 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta #endif +char *segments = (char *)(GOOD_PLACE_FOR_DATA_SEGMENT); + +static uint32 sawyercoding_calculate_checksum(const uint8* buffer, size_t length) +{ + size_t i; + uint32 checksum = 0; + for (i = 0; i < length; i++) + checksum += buffer[i]; + + return checksum; +} + +/** + * Loads RCT2's data model and remaps the addresses. + * @returns true if the data integrity check succeeded, otherwise false. + */ +static bool openrct2_setup_rct2_segment() +{ + // OpenRCT2 on Linux and macOS is wired to have the original Windows PE sections loaded + // necessary. Windows does not need to do this as OpenRCT2 runs as a DLL loaded from the Windows PE. + int len = 0x01429000 - 0x8a4000; // 0xB85000, 12079104 bytes or around 11.5MB + int err = 0; + +#if defined(__unix__) + int pageSize = getpagesize(); + int numPages = (len + pageSize - 1) / pageSize; + unsigned char *dummy = (unsigned char *)malloc(numPages); + + err = mincore((void *)segments, len, dummy); + bool pagesMissing = false; + if (err != 0) + { + err = errno; +#ifdef __LINUX__ + // On Linux ENOMEM means all requested range is unmapped + if (err != ENOMEM) + { + pagesMissing = true; + perror("mincore"); + } +#else + pagesMissing = true; + perror("mincore"); +#endif // __LINUX__ + } else { + for (int i = 0; i < numPages; i++) + { + if (dummy[i] != 1) + { + pagesMissing = true; + void *start = (void *)(segments + i * pageSize); + void *end = (void *)(segments + (i + 1) * pageSize - 1); + log_warning("required page %p - %p is not in memory!", start, end); + } + } + } + free(dummy); + if (pagesMissing) + { + log_error("At least one of required pages was not found in memory. This can cause segfaults later on."); + } + + // section: text + err = mprotect((void *)0x401000, 0x8a4000 - 0x401000, PROT_READ | PROT_EXEC | PROT_WRITE); + if (err != 0) + { + perror("mprotect"); + } + + // section: rw data + err = mprotect((void *)segments, 0x01429000 - 0x8a4000, PROT_READ | PROT_WRITE); + if (err != 0) + { + perror("mprotect"); + } +#endif // defined(__unix__) + + // Check that the expected data is at various addresses. + // Start at 0x9a6000, which is start of .data, to skip the region containing addresses to DLL + // calls, which can be changed by windows/wine loader. + const uint32 c1 = sawyercoding_calculate_checksum((const uint8*)(segments + (uintptr_t)(0x009A6000 - 0x8a4000)), 0x009E0000 - 0x009A6000); + const uint32 c2 = sawyercoding_calculate_checksum((const uint8*)(segments + (uintptr_t)(0x01428000 - 0x8a4000)), 0x014282BC - 0x01428000); + const uint32 exp_c1 = 10114815; + const uint32 exp_c2 = 23564; + if (c1 != exp_c1 || c2 != exp_c2) { + log_warning("c1 = %u, expected %u, match %d", c1, exp_c1, c1 == exp_c1); + log_warning("c2 = %u, expected %u, match %d", c2, exp_c2, c2 == exp_c2); + return false; + } + + return true; +} + int main(int argc, char *argv[]) { std::vector testCases; @@ -166,6 +264,7 @@ int main(int argc, char *argv[]) { ColouredPrintF(CLIColour::GREEN, "[----------] "); printf("Global test environment set-up.\n"); + openrct2_setup_rct2_segment(); initHooks(); int successCount = 0; From eb39f3fa1c098b9fddcc9ce87bb66537bde60200 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 6 Sep 2016 15:13:13 +0200 Subject: [PATCH 44/71] Only add testpaint on unix for standard builds --- CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ab7d3572f..629f1f4950 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -365,14 +365,15 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/g2.dat" DESTINATION share/${PROJECT}) install(DIRECTORY data/ DESTINATION share/${PROJECT}) install(FILES ${DOC_FILES} DESTINATION share/doc/${PROJECT}) +if (UNIX AND (NOT USE_MMAP) AND (NOT DISABLE_RCT2) AND (NOT FORCE64)) + file(GLOB_RECURSE ORCT2_RIDE_SOURCES "src/ride/*/*.c") + file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") + file(GLOB_RECURSE ORCT2_TESTPAINT_SOURCES "test/testpaint/*.c" "test/testpaint/*.cpp" "test/testpaint/*.h") -file(GLOB_RECURSE ORCT2_RIDE_SOURCES "src/ride/*/*.c") -file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") -file(GLOB_RECURSE ORCT2_PAINT_TEST_SOURCES "test/testpaint/*.c" "test/testpaint/*.cpp" "test/testpaint/*.h") - -add_executable(testpaint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_PAINT_TEST_SOURCES} ${RCT2_SECTIONS}) -set_target_properties(testpaint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES") -add_dependencies(testpaint segfiles) + add_executable(testpaint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_TESTPAINT_SOURCES} ${RCT2_SECTIONS}) + set_target_properties(testpaint PROPERTIES COMPILE_FLAGS "-DNO_VEHICLES") + add_dependencies(testpaint segfiles) +endif () set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 0) From 52e4800660eca9121d9bd74d593fcf4a7ce7f03d Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 6 Sep 2016 21:58:58 +0200 Subject: [PATCH 45/71] Add rough version of support segment checking --- OpenRCT2.xcodeproj/project.pbxproj | 4 + test/testpaint/intercept.c | 12 +- test/testpaint/intercept.h | 4 + test/testpaint/intercept_2.cpp | 271 +++++++++++++++++++++++++++++ test/testpaint/testpaint.vcxproj | 1 + 5 files changed, 289 insertions(+), 3 deletions(-) create mode 100644 test/testpaint/intercept_2.cpp diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index f0c3d7dd73..10a75cc3f8 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 791166FB1D7486EF005912EA /* NetworkServerAdvertiser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 791166F91D7486EF005912EA /* NetworkServerAdvertiser.cpp */; }; 8594C0601D885CF600235E93 /* track_data_old.c in Sources */ = {isa = PBXBuildFile; fileRef = 8594C05F1D885CF600235E93 /* track_data_old.c */; }; 85AFA2111D7DB83E00221B42 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85AFA20F1D7DB83E00221B42 /* main.cpp */; }; + 85B5C0B01D81D912001B99A8 /* intercept_2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85B5C0AF1D81D912001B99A8 /* intercept_2.cpp */; }; C612A8991D64825300B634CA /* vehicle_data.c in Sources */ = {isa = PBXBuildFile; fileRef = C612A8971D64825300B634CA /* vehicle_data.c */; }; C61FB7201CF6180C004CE991 /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38BA1CF3006400659A24 /* libssl.dylib */; }; C61FB7211CF618BA004CE991 /* libssl.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38BA1CF3006400659A24 /* libssl.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; @@ -495,6 +496,7 @@ 85AFA20F1D7DB83E00221B42 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 85AFA2101D7DB83E00221B42 /* intercept.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = intercept.h; sourceTree = ""; }; 85AFA2141D7DDFA100221B42 /* data.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = data.h; sourceTree = ""; }; + 85B5C0AF1D81D912001B99A8 /* intercept_2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = intercept_2.cpp; sourceTree = ""; }; C612A8971D64825300B634CA /* vehicle_data.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vehicle_data.c; sourceTree = ""; }; C612A8981D64825300B634CA /* vehicle_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vehicle_data.h; sourceTree = ""; }; C61FB7221CF86356004CE991 /* NetworkUser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkUser.cpp; sourceTree = ""; usesTabs = 0; }; @@ -1165,6 +1167,7 @@ C64FDAC41D6DA55E00F259B9 /* compat.c */, C64FDAC91D6DA92D00F259B9 /* data.c */, 85AFA2141D7DDFA100221B42 /* data.h */, + 85B5C0AF1D81D912001B99A8 /* intercept_2.cpp */, C64FDAC71D6DA72400F259B9 /* intercept.c */, 85AFA2101D7DB83E00221B42 /* intercept.h */, 85AFA20F1D7DB83E00221B42 /* main.cpp */, @@ -2417,6 +2420,7 @@ C64FDA8E1D6D9A2100F259B9 /* mini_golf.c in Sources */, C64FDA8F1D6D9A2100F259B9 /* mini_helicopters.c in Sources */, C64FDA901D6D9A2100F259B9 /* monorail_cycles.c in Sources */, + 85B5C0B01D81D912001B99A8 /* intercept_2.cpp in Sources */, C64FDA911D6D9A2100F259B9 /* observation_tower.c in Sources */, C64FDA921D6D9A2100F259B9 /* space_rings.c in Sources */, C64FDA931D6D9A2100F259B9 /* spiral_slide.c in Sources */, diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index 4cf6a158fa..863b0d4a12 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -21,8 +21,6 @@ #include "../../src/interface/viewport.h" #include "../../src/hook.h" -#define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) -#define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) static const uint32 PALETTE_98 = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; static const uint32 PALETTE_9C = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; @@ -446,7 +444,7 @@ static void printFunctionCallArray(utf8string *out, function_call calls[], uint8 } } -static int getTrackSequenceCount(uint8 rideType, uint8 trackType) { +int getTrackSequenceCount(uint8 rideType, uint8 trackType) { int sequenceCount = 0; const rct_preview_track **trackBlocks; @@ -479,6 +477,9 @@ bool rideSupportsTrackType(int rideType, int trackType) { return supportsTrackType; } + +extern bool testSupportSegments(uint8 rideType, uint8 trackType); + static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { if (rideType == RIDE_TYPE_CHAIRLIFT) { if (trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_MIDDLE_STATION || trackType == TRACK_ELEM_END_STATION) { @@ -590,6 +591,11 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) } } + bool segmentSuccess = testSupportSegments(rideType, trackType); + if (!segmentSuccess) { + return false; + } + return true; } diff --git a/test/testpaint/intercept.h b/test/testpaint/intercept.h index 7adb7d3d42..7971e733c2 100644 --- a/test/testpaint/intercept.h +++ b/test/testpaint/intercept.h @@ -19,8 +19,12 @@ #include "../../src/common.h" +#define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) +#define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) + bool testRide(int rideType); void initHooks(); +int getTrackSequenceCount(uint8 rideType, uint8 trackType); bool rideIsImplemented(int rideType); bool rideSupportsTrackType(int rideType, int trackType); bool testTrackPainting(int rideType, int trackType); diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp new file mode 100644 index 0000000000..959386069a --- /dev/null +++ b/test/testpaint/intercept_2.cpp @@ -0,0 +1,271 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#include + +extern "C" { + #include "intercept.h" + #include "../../src/paint/paint.h" + #include "../../src/paint/supports.h" + #include "../../src/ride/track_data.h" + #include "../../src/interface/viewport.h" + #include "../../src/hook.h" +} + +namespace Intercept2 +{ + + static const uint32 PALETTE_98 = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; + static const uint32 PALETTE_9C = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; + static const uint32 PALETTE_A0 = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000; + static const uint32 PALETTE_A4 = COLOUR_BRIGHT_PURPLE << 19 | COLOUR_DARK_BLUE << 24 | 0xA0000000; + + struct SegmentSupportCall + { + uint16 segments; + sint32 height; + sint16 slope; + }; + + bool SortSegmentSupportCalls(SegmentSupportCall lhs, SegmentSupportCall rhs) + { + if (lhs.height != rhs.height) { + return lhs.height < rhs.height; + } + + if (lhs.slope != rhs.slope) { + return lhs.slope < rhs.slope; + } + + return lhs.segments < rhs.segments; + } + + static std::vector getSegmentCalls(support_height supports[9], uint8 rotation) + { + uint16 positionsRemaining = SEGMENTS_ALL; + + for (int i = 0; i < 9; i++) { + if (supports[i].height == 0 && supports[i].slope == 0xFF) { + positionsRemaining &= ~segment_offsets[i]; + } + } + + std::vector calls; + + while (positionsRemaining != 0) { + SegmentSupportCall call = {0}; + call.height = -1; + call.slope = -1; + + support_height referenceSupport; + + for (int i = 0; i < 9; i++) { + if (positionsRemaining & segment_offsets[i]) { + referenceSupport = supports[i]; + if (supports[i].height != 0) { + call.height = supports[i].height; + } + if (supports[i].slope != 0xFF) { + call.slope = supports[i].slope; + } + break; + } + } + + uint16 positionsMatched = 0; + for (int i = 0; i < 9; i++) { + if (supports[i].height == referenceSupport.height && supports[i].slope == referenceSupport.slope) { + positionsMatched |= segment_offsets[i]; + } + } + positionsRemaining &= ~positionsMatched; + + call.segments = paint_util_rotate_segments(positionsMatched, (4 - rotation) % 4); + + calls.push_back(call); + } + + if (calls.size() > 1) { + std::sort(calls.begin(), calls.end(), SortSegmentSupportCalls); + } + + return calls; + } + + static bool SegmentCallEquals(std::vector lhs, std::vector rhs) + { + if (lhs.size() != rhs.size()) return false; + for (int i = 0; i < lhs.size(); ++i) { + if (lhs[i].segments != rhs[i].segments) + return false; + if (lhs[i].height != rhs[i].height) + return false; + if (lhs[i].slope != rhs[i].slope) + return false; + } + + return true; + } + + static bool segmentCallsMatch(std::vector tileSegmentSupportCalls[4]) + { + std::vector baseCallList = tileSegmentSupportCalls[0]; + for (int i = 1; i < 4; i++) { + if (!SegmentCallEquals(baseCallList, tileSegmentSupportCalls[i])) { + return false; + } + } + + return true; + } + + static void printSegmentSupports(utf8string * out, std::vector segmentCalls) + { + for (auto &&call : segmentCalls) { + int segmentsPrinted = 0; + for (int i = 0; i < 9; i++) { + if (call.segments & segment_offsets[i]) { + if (segmentsPrinted > 0) { + sprintf(*out + strlen(*out), " | "); + } + sprintf(*out + strlen(*out), "SEGMENT_%02X", 0xB4 + 4 * i); + segmentsPrinted++; + } + } + + if (call.height == 0xFFFF) { + sprintf(*out + strlen(*out), ", 0xFFFF"); + } else { + sprintf(*out + strlen(*out), ", %d", call.height); + } + + sprintf(*out + strlen(*out), ", 0x%02X\n", call.slope); + } + } + + static bool testSupportSegments(uint8 rideType, uint8 trackType) + { + uint8 rideIndex = 0; + rct_map_element mapElement = {0}; + mapElement.properties.track.type = trackType; + mapElement.base_height = 3; + + g_currently_drawn_item = &mapElement; + + rct_map_element surfaceElement = {0}; + surfaceElement.type = MAP_ELEMENT_TYPE_SURFACE; + surfaceElement.base_height = 2; + + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; + RCT2_GLOBAL(0x00F44198, uint32) = PALETTE_98; + RCT2_GLOBAL(0x00F441A0, uint32) = PALETTE_A0; + RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; + RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; + + rct_drawpixelinfo dpi = {.zoom_level = 1}; + unk_140E9A8 = &dpi; + + rct_vehicle vehicle = {0}; + rct_ride ride = {0}; + + rct_ride_entry rideEntry = {0}; + rct_ride_entry_vehicle vehicleEntry = {.base_image_id = 0x70000}; + rideEntry.vehicles[0] = vehicleEntry; + + + gRideList[0] = ride; + gRideEntries[0] = &rideEntry; + + int height = 48; + + TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; + int sequenceCount = getTrackSequenceCount(rideType, trackType); + + + for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { + std::vector tileSegmentSupportCalls[4]; + + for (int direction = 0; direction < 4; direction++) { + for (int s = 0; s < 9; ++s) { + gSupportSegments[s].height = 0; + gSupportSegments[s].slope = 0xFF; + } + + TRACK_PAINT_FUNCTION ** trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; + uint32 * trackDirectionList = (uint32 *) trackTypeList[trackType]; + + // Have to call from this point as it pushes esi and expects callee to pop it + RCT2_CALLPROC_X( + 0x006C4934, + rideType, + (int) trackDirectionList, + direction, + height, + (int) &mapElement, + rideIndex * sizeof(rct_ride), + trackSequence + ); + + tileSegmentSupportCalls[direction] = getSegmentCalls(gSupportSegments, direction); + } + + if (!segmentCallsMatch(tileSegmentSupportCalls)) { + // TODO: if 3 directions do share the same mask, use that call list as a reference. + printf("Original segment calls didn't match. [trackSequence:%d]\n", trackSequence); + continue; + } + + for (int direction = 0; direction < 4; direction++) { + for (int s = 0; s < 9; ++s) { + gSupportSegments[s].height = 0; + gSupportSegments[s].slope = 0xFF; + } + + TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); + newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + + std::vector newCalls = getSegmentCalls(gSupportSegments, direction); + + if (!SegmentCallEquals(tileSegmentSupportCalls[0], newCalls)) { + // TODO put this into *error + utf8string diff = new utf8[2048]; + sprintf(diff, "<<< EXPECTED\n"); + printSegmentSupports(&diff, tileSegmentSupportCalls[0]); + sprintf(diff + strlen(diff), "====\n"); + printSegmentSupports(&diff, newCalls); + sprintf(diff + strlen(diff), ">>> ACTUAL\n"); + + printf("Segment support heights didn't match. [direction:%d trackSequence:%d]\n", direction, + trackSequence); + printf("%s", diff); + delete[] diff; + return false; + } + } + } + + return true; + } +} + + +extern "C" +{ + bool testSupportSegments(uint8 rideType, uint8 trackType) + { + return Intercept2::testSupportSegments(rideType, trackType); + } +} diff --git a/test/testpaint/testpaint.vcxproj b/test/testpaint/testpaint.vcxproj index 3061cb2e8c..5610db872c 100644 --- a/test/testpaint/testpaint.vcxproj +++ b/test/testpaint/testpaint.vcxproj @@ -84,6 +84,7 @@ + From 66310a62859e2e1f05833ab34fb1a550af4ca63a Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 8 Sep 2016 19:34:13 +0200 Subject: [PATCH 46/71] Add check for general supports --- test/testpaint/intercept_2.cpp | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 959386069a..00ee22e8e0 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -40,6 +40,12 @@ namespace Intercept2 sint16 slope; }; + struct SupportCall + { + sint32 height; + sint16 slope; + }; + bool SortSegmentSupportCalls(SegmentSupportCall lhs, SegmentSupportCall rhs) { if (lhs.height != rhs.height) { @@ -132,6 +138,17 @@ namespace Intercept2 return true; } + static bool supportCallsMatch(SupportCall tileSupportCalls[4]) + { + SupportCall baseCall = tileSupportCalls[0]; + for (int i = 1; i < 4; i++) { + if (tileSupportCalls[i].height != baseCall.height) return false; + if (tileSupportCalls[i].slope != baseCall.slope) return false; + } + + return true; + } + static void printSegmentSupports(utf8string * out, std::vector segmentCalls) { for (auto &&call : segmentCalls) { @@ -197,6 +214,7 @@ namespace Intercept2 for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { std::vector tileSegmentSupportCalls[4]; + SupportCall tileGeneralSupportCalls[4]; for (int direction = 0; direction < 4; direction++) { for (int s = 0; s < 9; ++s) { @@ -204,6 +222,9 @@ namespace Intercept2 gSupportSegments[s].slope = 0xFF; } + gSupport.height = 0; + gSupport.slope = 0xFF; + TRACK_PAINT_FUNCTION ** trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; uint32 * trackDirectionList = (uint32 *) trackTypeList[trackType]; @@ -220,6 +241,15 @@ namespace Intercept2 ); tileSegmentSupportCalls[direction] = getSegmentCalls(gSupportSegments, direction); + + tileGeneralSupportCalls[direction].height = -1; + tileGeneralSupportCalls[direction].slope = -1; + if (gSupport.height != 0) { + tileGeneralSupportCalls[direction].height = gSupport.height; + } + if (gSupport.slope != 0xFF) { + tileGeneralSupportCalls[direction].height = gSupport.height; + } } if (!segmentCallsMatch(tileSegmentSupportCalls)) { @@ -255,6 +285,39 @@ namespace Intercept2 return false; } } + + if (!supportCallsMatch(tileGeneralSupportCalls)) { + // TODO: if 3 directions do share the output, use that. + printf("Original support calls didn't match. [trackSequence:%d]\n", trackSequence); + continue; + } + + SupportCall referenceGeneralSupportCall = tileGeneralSupportCalls[0]; + + + for (int direction = 0; direction < 4; direction++) { + gSupport.height = 0; + gSupport.slope = 0xFF; + + TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); + newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + + if (referenceGeneralSupportCall.height != -1) { + if (gSupport.height != referenceGeneralSupportCall.height) { + printf("General support heights didn't match. [direction:%d trackSequence:%d]\n", direction, + trackSequence); + return false; + } + } + if (referenceGeneralSupportCall.slope != -1) { + if (gSupport.slope != referenceGeneralSupportCall.slope) { + printf("General support slopes didn't match. [direction:%d trackSequence:%d]\n", direction, + trackSequence); + return false; + } + } + } + } return true; From a904391a6d5f245b10863211db2ec2de1dd2b532 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 9 Sep 2016 01:38:11 +0200 Subject: [PATCH 47/71] Get expected tunnel pattern --- test/testpaint/intercept.c | 6 + test/testpaint/intercept_2.cpp | 205 +++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+) diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index 863b0d4a12..aeca232fe3 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -479,6 +479,7 @@ bool rideSupportsTrackType(int rideType, int trackType) { extern bool testSupportSegments(uint8 rideType, uint8 trackType); +extern bool testTunnels(uint8 rideType, uint8 trackType); static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { if (rideType == RIDE_TYPE_CHAIRLIFT) { @@ -596,6 +597,11 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) return false; } + bool tunnelSuccess = testTunnels(rideType, trackType); + if (!tunnelSuccess) { + return false; + } + return true; } diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 00ee22e8e0..e0b4e83157 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -46,6 +46,18 @@ namespace Intercept2 sint16 slope; }; + enum { + TUNNELCALL_SKIPPED, + TUNNELCALL_NONE, + TUNNELCALL_CALL, + }; + + struct TunnelCall { + uint8 call; + uint8 height; + uint8 type; + }; + bool SortSegmentSupportCalls(SegmentSupportCall lhs, SegmentSupportCall rhs) { if (lhs.height != rhs.height) { @@ -173,6 +185,93 @@ namespace Intercept2 } } + static bool tunnelCallsLineUp(TunnelCall tunnelCalls[4][4]) + { + for (int side = 0; side < 4; ++side) { + TunnelCall * referenceCall = nullptr; + for (int direction = 0; direction < 4; ++direction) { + if (tunnelCalls[direction][side].call == TUNNELCALL_SKIPPED) { + continue; + } + + if (referenceCall == nullptr) { + referenceCall = &tunnelCalls[direction][side]; + continue; + } + + if (referenceCall->call != tunnelCalls[direction][side].call) return false; + + if (referenceCall->call == TUNNELCALL_CALL) { + if (referenceCall->type != tunnelCalls[direction][side].type) return false; + if (referenceCall->height != tunnelCalls[direction][side].height) return false; + } + } + } + + return true; + } + + static utf8string getTunnelEdgeString(TunnelCall edge) { + utf8string out = new utf8[5]; + + switch(edge.call) { + case TUNNELCALL_SKIPPED: + sprintf(out, " "); + break; + + case TUNNELCALL_NONE: + sprintf(out, " - "); + break; + + case TUNNELCALL_CALL: + sprintf(out, " %d ", edge.height); + break; + } + + return out; + } + + static void printTunnelCalls(TunnelCall tunnelCalls[4][4]) + { + for (int direction = 0; direction < 4; ++direction) { + printf(" + "); + } + printf("\n"); + + for (int direction = 0; direction < 4; ++direction) { + utf8string tlEdge = getTunnelEdgeString(tunnelCalls[direction][2]); + utf8string trEdge = getTunnelEdgeString(tunnelCalls[direction][3]); + printf(" %s %s ", tlEdge, trEdge); + delete tlEdge; + delete trEdge; + } + printf("\n"); + + for (int direction = 0; direction < 4; ++direction) { + printf(" + + "); + } + printf("\n"); + + for (int direction = 0; direction < 4; ++direction) { + utf8string brEdge = getTunnelEdgeString(tunnelCalls[direction][0]); + utf8string blEdge = getTunnelEdgeString(tunnelCalls[direction][1]); + printf(" %s %s ", blEdge, brEdge); + delete blEdge; + delete brEdge; + } + printf("\n"); + + for (int direction = 0; direction < 4; ++direction) { + printf(" + "); + } + printf("\n"); + + for (int direction = 0; direction < 4; ++direction) { + printf(" direction %d ", direction); + } + printf("\n"); + } + static bool testSupportSegments(uint8 rideType, uint8 trackType) { uint8 rideIndex = 0; @@ -322,6 +421,106 @@ namespace Intercept2 return true; } + + static bool testTunnels(uint8 rideType, uint8 trackType) + { + uint8 rideIndex = 0; + rct_map_element mapElement = {0}; + mapElement.properties.track.type = trackType; + mapElement.base_height = 3; + + g_currently_drawn_item = &mapElement; + + rct_map_element surfaceElement = {0}; + surfaceElement.type = MAP_ELEMENT_TYPE_SURFACE; + surfaceElement.base_height = 2; + + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; + RCT2_GLOBAL(0x00F44198, uint32) = PALETTE_98; + RCT2_GLOBAL(0x00F441A0, uint32) = PALETTE_A0; + RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; + RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; + + rct_drawpixelinfo dpi = {.zoom_level = 1}; + unk_140E9A8 = &dpi; + + rct_vehicle vehicle = {0}; + rct_ride ride = {0}; + + rct_ride_entry rideEntry = {0}; + rct_ride_entry_vehicle vehicleEntry = {.base_image_id = 0x70000}; + rideEntry.vehicles[0] = vehicleEntry; + + + gRideList[0] = ride; + gRideEntries[0] = &rideEntry; + + int height = 48; + + TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; + int sequenceCount = getTrackSequenceCount(rideType, trackType); + + + for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { + TunnelCall tileTunnelCalls[4][4]; + + for (int direction = 0; direction < 4; direction++) { + gLeftTunnelCount = 0; + gRightTunnelCount = 0; + + TRACK_PAINT_FUNCTION ** trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; + uint32 * trackDirectionList = (uint32 *) trackTypeList[trackType]; + + // Have to call from this point as it pushes esi and expects callee to pop it + RCT2_CALLPROC_X( + 0x006C4934, + rideType, + (int) trackDirectionList, + direction, + height, + (int) &mapElement, + rideIndex * sizeof(rct_ride), + trackSequence + ); + + uint8 rightIndex = (4 - direction) % 4; + uint8 leftIndex = (rightIndex + 1) % 4; + + for (int i = 0; i < 4; ++i) { + tileTunnelCalls[direction][i].call = TUNNELCALL_SKIPPED; + } + + if (gRightTunnelCount == 0) { + tileTunnelCalls[direction][rightIndex].call = TUNNELCALL_NONE; + } else if (gRightTunnelCount == 1) { + tileTunnelCalls[direction][rightIndex].call = TUNNELCALL_CALL; + tileTunnelCalls[direction][rightIndex].height = gRightTunnels[0].height; + tileTunnelCalls[direction][rightIndex].type = gRightTunnels[0].type; + } else { + printf("Multiple tunnels on one side aren't supported.\n"); + return false; + } + + if (gLeftTunnelCount == 0) { + tileTunnelCalls[direction][leftIndex].call = TUNNELCALL_NONE; + } else if (gLeftTunnelCount == 1) { + tileTunnelCalls[direction][leftIndex].call = TUNNELCALL_CALL; + tileTunnelCalls[direction][leftIndex].height = gLeftTunnels[0].height; + tileTunnelCalls[direction][leftIndex].type = gLeftTunnels[0].type; + } else { + printf("Multiple tunnels on one side aren't supported.\n"); + return false; + } + } + + if (!tunnelCallsLineUp(tileTunnelCalls)) { + printf("Tunnel calls don\'t line up. Skipping tunnel validation [trackSequence:%d].\n", trackSequence); + printTunnelCalls(tileTunnelCalls); + return false; + } + } + return true; + } } @@ -331,4 +530,10 @@ extern "C" { return Intercept2::testSupportSegments(rideType, trackType); } + + bool testTunnels(uint8 rideType, uint8 trackType) + { + return Intercept2::testTunnels(rideType, trackType); + } + } From 95f68a3e6a29ef7be7655e442413a387f0dc8b97 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 9 Sep 2016 13:54:47 +0200 Subject: [PATCH 48/71] Validate side tunnel calls --- test/testpaint/intercept_2.cpp | 99 ++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 5 deletions(-) diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index e0b4e83157..e9e013ce07 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -211,6 +211,21 @@ namespace Intercept2 return true; } + static void getTunnelCallReferencePattern(TunnelCall tunnelCalls[4][4], TunnelCall (*out)[4]) + { + for (int side = 0; side < 4; ++side) { + for (int direction = 0; direction < 4; ++direction) { + if (tunnelCalls[direction][side].call == TUNNELCALL_SKIPPED) { + continue; + } + + (*out)[side].call = tunnelCalls[direction][side].call; + (*out)[side].type = tunnelCalls[direction][side].type; + (*out)[side].height = tunnelCalls[direction][side].height; + } + } + } + static utf8string getTunnelEdgeString(TunnelCall edge) { utf8string out = new utf8[5]; @@ -224,7 +239,7 @@ namespace Intercept2 break; case TUNNELCALL_CALL: - sprintf(out, " %d ", edge.height); + sprintf(out, " %d,%X ", edge.height, edge.type); break; } @@ -422,6 +437,20 @@ namespace Intercept2 return true; } + static bool tunnelPatternsMatch(TunnelCall expected[4], TunnelCall actual[4]) + { + for (int side = 0; side < 4; side++) { + if (expected[side].call != actual[side].call) return false; + + if (expected[side].call == TUNNELCALL_CALL) { + if (expected[side].type != actual[side].type) return false; + if (expected[side].height != actual[side].height) return false; + } + } + + return true; + } + static bool testTunnels(uint8 rideType, uint8 trackType) { uint8 rideIndex = 0; @@ -489,7 +518,6 @@ namespace Intercept2 for (int i = 0; i < 4; ++i) { tileTunnelCalls[direction][i].call = TUNNELCALL_SKIPPED; } - if (gRightTunnelCount == 0) { tileTunnelCalls[direction][rightIndex].call = TUNNELCALL_NONE; } else if (gRightTunnelCount == 1) { @@ -513,11 +541,72 @@ namespace Intercept2 } } - if (!tunnelCallsLineUp(tileTunnelCalls)) { - printf("Tunnel calls don\'t line up. Skipping tunnel validation [trackSequence:%d].\n", trackSequence); - printTunnelCalls(tileTunnelCalls); + TunnelCall newTileTunnelCalls[4][4]; + for (int direction = 0; direction < 4; direction++) { + gLeftTunnelCount = 0; + gRightTunnelCount = 0; + + TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); + newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + + uint8 rightIndex = (4 - direction) % 4; + uint8 leftIndex = (rightIndex + 1) % 4; + + for (int i = 0; i < 4; ++i) { + newTileTunnelCalls[direction][i].call = TUNNELCALL_SKIPPED; + } + + if (gRightTunnelCount == 0) { + newTileTunnelCalls[direction][rightIndex].call = TUNNELCALL_NONE; + } else if (gRightTunnelCount == 1) { + newTileTunnelCalls[direction][rightIndex].call = TUNNELCALL_CALL; + newTileTunnelCalls[direction][rightIndex].height = gRightTunnels[0].height; + newTileTunnelCalls[direction][rightIndex].type = gRightTunnels[0].type; + } else { + printf("Multiple tunnels on one side aren't supported.\n"); + return false; + } + + if (gLeftTunnelCount == 0) { + newTileTunnelCalls[direction][leftIndex].call = TUNNELCALL_NONE; + } else if (gLeftTunnelCount == 1) { + newTileTunnelCalls[direction][leftIndex].call = TUNNELCALL_CALL; + newTileTunnelCalls[direction][leftIndex].height = gLeftTunnels[0].height; + newTileTunnelCalls[direction][leftIndex].type = gLeftTunnels[0].type; + } else { + printf("Multiple tunnels on one side aren't supported.\n"); + return false; + } + } + + if (!tunnelCallsLineUp(newTileTunnelCalls)) { + printf("Decompiled tunnel calls don\'t line up. [trackSequence:%d].\n", trackSequence); + printTunnelCalls(newTileTunnelCalls); return false; } + + + if (!tunnelCallsLineUp(tileTunnelCalls)) { + printf("Original tunnel calls don\'t line up. Skipping tunnel validation [trackSequence:%d].\n", trackSequence); + printTunnelCalls(tileTunnelCalls); + continue; + } + + TunnelCall referencePattern[4]; + getTunnelCallReferencePattern(tileTunnelCalls, &referencePattern); + + TunnelCall actualPattern[4]; + getTunnelCallReferencePattern(newTileTunnelCalls, &actualPattern); + + if(!tunnelPatternsMatch(referencePattern, actualPattern)) { + printf("Tunnel calls don't match expected pattern. [trackSequence:%d]\n", trackSequence); + printf("expected:\n"); + printTunnelCalls(tileTunnelCalls); + printf("actual:\n"); + printTunnelCalls(newTileTunnelCalls); + return false; + } + } return true; } From fdbb4998f64d13bd1bceaeccfb3094cc557e7aaf Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 9 Sep 2016 21:37:11 +0200 Subject: [PATCH 49/71] Add vertical tunnel testing --- test/testpaint/intercept.c | 5 ++ test/testpaint/intercept_2.cpp | 157 +++++++++++++++++++++++++++++++-- 2 files changed, 157 insertions(+), 5 deletions(-) diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index aeca232fe3..6620bbbf7a 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -480,6 +480,7 @@ bool rideSupportsTrackType(int rideType, int trackType) { extern bool testSupportSegments(uint8 rideType, uint8 trackType); extern bool testTunnels(uint8 rideType, uint8 trackType); +extern bool testVerticalTunnels(uint8 rideType, uint8 trackType); static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) { if (rideType == RIDE_TYPE_CHAIRLIFT) { @@ -602,6 +603,10 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) return false; } + bool verticalTunnelSuccess = testVerticalTunnels(rideType, trackType); + if (!verticalTunnelSuccess) { + return false; + } return true; } diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index e9e013ce07..72727d5b10 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -226,10 +226,11 @@ namespace Intercept2 } } - static utf8string getTunnelEdgeString(TunnelCall edge) { + static utf8string getTunnelEdgeString(TunnelCall edge) + { utf8string out = new utf8[5]; - switch(edge.call) { + switch (edge.call) { case TUNNELCALL_SKIPPED: sprintf(out, " "); break; @@ -587,7 +588,8 @@ namespace Intercept2 if (!tunnelCallsLineUp(tileTunnelCalls)) { - printf("Original tunnel calls don\'t line up. Skipping tunnel validation [trackSequence:%d].\n", trackSequence); + printf("Original tunnel calls don\'t line up. Skipping tunnel validation [trackSequence:%d].\n", + trackSequence); printTunnelCalls(tileTunnelCalls); continue; } @@ -598,7 +600,7 @@ namespace Intercept2 TunnelCall actualPattern[4]; getTunnelCallReferencePattern(newTileTunnelCalls, &actualPattern); - if(!tunnelPatternsMatch(referencePattern, actualPattern)) { + if (!tunnelPatternsMatch(referencePattern, actualPattern)) { printf("Tunnel calls don't match expected pattern. [trackSequence:%d]\n", trackSequence); printf("expected:\n"); printTunnelCalls(tileTunnelCalls); @@ -610,8 +612,148 @@ namespace Intercept2 } return true; } -} + static bool verticalTunnelHeightIsConsistent(uint8 heights[4]) + { + for (int i = 1; i < 4; ++i) { + if (heights[i] != heights[0]) return false; + } + + return true; + } + + static void printRelativeHeight(utf8string out, sint16 height) + { + if (height == 0) { + sprintf(out, "height"); + return; + } + + if (height > 0) { + sprintf(out, "height + %d", height); + return; + } + + if (height < 0) { + sprintf(out, "height - %d", abs(height)); + return; + } + } + + static bool testVerticalTunnels(uint8 rideType, uint8 trackType) + { + uint8 rideIndex = 0; + rct_map_element mapElement = {0}; + mapElement.properties.track.type = trackType; + mapElement.base_height = 3; + + g_currently_drawn_item = &mapElement; + + rct_map_element surfaceElement = {0}; + surfaceElement.type = MAP_ELEMENT_TYPE_SURFACE; + surfaceElement.base_height = 2; + + gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; + RCT2_GLOBAL(0x00F44198, uint32) = PALETTE_98; + RCT2_GLOBAL(0x00F441A0, uint32) = PALETTE_A0; + RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; + RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; + + rct_drawpixelinfo dpi = {.zoom_level = 1}; + unk_140E9A8 = &dpi; + + rct_vehicle vehicle = {0}; + rct_ride ride = {0}; + + rct_ride_entry rideEntry = {0}; + rct_ride_entry_vehicle vehicleEntry = {.base_image_id = 0x70000}; + rideEntry.vehicles[0] = vehicleEntry; + + + gRideList[0] = ride; + gRideEntries[0] = &rideEntry; + + int height = 48; + + TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; + int sequenceCount = getTrackSequenceCount(rideType, trackType); + + + for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { + uint8 verticalTunnelHeight[4]; + + for (int direction = 0; direction < 4; direction++) { + gVerticalTunnelHeight = 0; + + TRACK_PAINT_FUNCTION ** trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; + uint32 * trackDirectionList = (uint32 *) trackTypeList[trackType]; + + // Have to call from this point as it pushes esi and expects callee to pop it + RCT2_CALLPROC_X( + 0x006C4934, + rideType, + (int) trackDirectionList, + direction, + height, + (int) &mapElement, + rideIndex * sizeof(rct_ride), + trackSequence + ); + + verticalTunnelHeight[direction] = gVerticalTunnelHeight; + } + + if (!verticalTunnelHeightIsConsistent(verticalTunnelHeight)) { + printf( + "Original vertical tunnel height is inconsistent, skipping test. [trackSequence:%d]\n", + trackSequence + ); + continue; + } + + uint8 referenceHeight = verticalTunnelHeight[0]; + for (int direction = 0; direction < 4; direction++) { + gVerticalTunnelHeight = 0; + + TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); + newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + + if (gVerticalTunnelHeight != referenceHeight) { + if (referenceHeight == 0) { + printf( + "Expected no vertical tunnel. [trackSequence:%d direction:%d]\n", + trackSequence, + direction + ); + + return false; + } + + utf8string strExpectedTunnelHeight = new utf8[16]; + utf8string strActualTunnelHeight = new utf8[16]; + printRelativeHeight(strExpectedTunnelHeight, (referenceHeight * 16) - 48); + printRelativeHeight(strActualTunnelHeight, (gVerticalTunnelHeight * 16) - 48); + + printf( + "Expected vertical tunnel height to be `%s`, was `%s`. [trackSequence:%d direction:%d]\n", + strExpectedTunnelHeight, + strActualTunnelHeight, + trackSequence, + direction + ); + + delete []strExpectedTunnelHeight; + delete []strActualTunnelHeight; + + return false; + } + } + } + + return true; + } + +} extern "C" { @@ -625,4 +767,9 @@ extern "C" return Intercept2::testTunnels(rideType, trackType); } + bool testVerticalTunnels(uint8 rideType, uint8 trackType) + { + return Intercept2::testVerticalTunnels(rideType, trackType); + } + } From f13e5c9e3a16baf321329ba4d40e3ea1aa23203b Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 9 Sep 2016 22:42:35 +0100 Subject: [PATCH 50/71] Add painttest to openrct2.proj --- openrct2.proj | 24 +++++++++++++++++++----- test/testpaint/testpaint.vcxproj | 4 +++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/openrct2.proj b/openrct2.proj index d036d7468f..071a4d50a4 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -13,10 +13,8 @@ - - - + Win32 $(COMPUTERNAME) $(GIT_COMMIT_SHA1.Substring(0, 7)) @@ -36,6 +34,7 @@ $(MsBuildThisFileDirectory) $(RootDir)distribution\ $(RootDir)artifacts\ + $(RootDir)bin\ $(DistDir)windows\install.nsi @@ -141,7 +140,7 @@ - + @@ -154,9 +153,10 @@ + - + $(GIT_COMMIT_SHA1_SHORT) $(BuildString) ($(GIT_BRANCH)) @@ -169,6 +169,20 @@ + + + + + + + + + + + + + + diff --git a/test/testpaint/testpaint.vcxproj b/test/testpaint/testpaint.vcxproj index 5610db872c..c7ffe6dc80 100644 --- a/test/testpaint/testpaint.vcxproj +++ b/test/testpaint/testpaint.vcxproj @@ -42,7 +42,7 @@ - $(SolutionDir)bin\testpaint + $(SolutionDir)bin\testpaint\ $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ openrct2 $(SolutionDir)lib\include;$(SolutionDir)lib\include\breakpad;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(SolutionDir)lib\include\zlib;$(IncludePath) @@ -61,6 +61,7 @@ Disabled true $(OpenRCT2_DEFINES);DEBUG;NO_VEHICLES;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + true @@ -70,6 +71,7 @@ true true true + true true From eed46dc367afda36b63f401d0fd5e5ee412671e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 9 Sep 2016 21:49:53 +0200 Subject: [PATCH 51/71] Fixes for testpaint on Linux --- test/testpaint/intercept.h | 3 +++ test/testpaint/intercept_2.cpp | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/testpaint/intercept.h b/test/testpaint/intercept.h index 7971e733c2..3d008443e7 100644 --- a/test/testpaint/intercept.h +++ b/test/testpaint/intercept.h @@ -28,5 +28,8 @@ int getTrackSequenceCount(uint8 rideType, uint8 trackType); bool rideIsImplemented(int rideType); bool rideSupportsTrackType(int rideType, int trackType); bool testTrackPainting(int rideType, int trackType); +bool testSupportSegments(uint8 rideType, uint8 trackType); +bool testTunnels(uint8 rideType, uint8 trackType); +bool testVerticalTunnels(uint8 rideType, uint8 trackType); #endif // #endif _TEST_PAINT_INTERCEPT_H_ diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 72727d5b10..5a7fd268e3 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -15,6 +15,7 @@ #pragma endregion #include +#include extern "C" { #include "intercept.h" @@ -58,7 +59,7 @@ namespace Intercept2 uint8 type; }; - bool SortSegmentSupportCalls(SegmentSupportCall lhs, SegmentSupportCall rhs) + static bool SortSegmentSupportCalls(SegmentSupportCall lhs, SegmentSupportCall rhs) { if (lhs.height != rhs.height) { return lhs.height < rhs.height; @@ -635,7 +636,7 @@ namespace Intercept2 } if (height < 0) { - sprintf(out, "height - %d", abs(height)); + sprintf(out, "height - %d", int(abs(height))); return; } } From ef008d6fd2f3b337fc9a401c3dc0d285c05d9400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 9 Sep 2016 21:56:40 +0200 Subject: [PATCH 52/71] Fixes for GCC6.1 on Linux GCC6.1 does not support non-trivial designated initializers, but there are so few fields used, they don't have to be used. --- test/testpaint/intercept_2.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 5a7fd268e3..b04e95f513 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -308,14 +308,16 @@ namespace Intercept2 RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; - rct_drawpixelinfo dpi = {.zoom_level = 1}; + rct_drawpixelinfo dpi = { 0 }; + dpi.zoom_level = 1; unk_140E9A8 = &dpi; rct_vehicle vehicle = {0}; rct_ride ride = {0}; rct_ride_entry rideEntry = {0}; - rct_ride_entry_vehicle vehicleEntry = {.base_image_id = 0x70000}; + rct_ride_entry_vehicle vehicleEntry { 0 }; + vehicleEntry.base_image_id = 0x70000; rideEntry.vehicles[0] = vehicleEntry; @@ -472,14 +474,16 @@ namespace Intercept2 RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; - rct_drawpixelinfo dpi = {.zoom_level = 1}; + rct_drawpixelinfo dpi { 0 }; + dpi.zoom_level = 1; unk_140E9A8 = &dpi; rct_vehicle vehicle = {0}; rct_ride ride = {0}; rct_ride_entry rideEntry = {0}; - rct_ride_entry_vehicle vehicleEntry = {.base_image_id = 0x70000}; + rct_ride_entry_vehicle vehicleEntry { 0 }; + vehicleEntry.base_image_id = 0x70000; rideEntry.vehicles[0] = vehicleEntry; @@ -660,14 +664,16 @@ namespace Intercept2 RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; - rct_drawpixelinfo dpi = {.zoom_level = 1}; + rct_drawpixelinfo dpi = { 0 }; + dpi.zoom_level = 1; unk_140E9A8 = &dpi; rct_vehicle vehicle = {0}; rct_ride ride = {0}; rct_ride_entry rideEntry = {0}; - rct_ride_entry_vehicle vehicleEntry = {.base_image_id = 0x70000}; + rct_ride_entry_vehicle vehicleEntry = { 0 }; + vehicleEntry.base_image_id = 0x70000; rideEntry.vehicles[0] = vehicleEntry; From 88ffe5f8c249d845a9d07fce7a834b1d57dfde6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 9 Sep 2016 22:25:06 +0200 Subject: [PATCH 53/71] Fixes for testpaint Test of `paint_launched_freefall_tower_section` is invalid. Do note this function [expects another element right past the one just passed](https://github.com/OpenRCT2/OpenRCT2/blob/d00aa2c/src/ride/thrill/launched_freefall.c#L147): ``` rct_map_element * nextMapElement = mapElement + 1; ``` but you pass only a single map element, which is not marked as last for tile. The same prevails throughout other tests. --- test/testpaint/intercept.c | 1 + test/testpaint/intercept_2.cpp | 18 +++++++++++------- test/testpaint/main.cpp | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index 6620bbbf7a..a7f0512cc0 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -492,6 +492,7 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) } uint8 rideIndex = 0; rct_map_element mapElement = { 0 }; + mapElement.flags |= MAP_ELEMENT_FLAG_LAST_TILE; mapElement.properties.track.type = trackType; mapElement.base_height = 3; diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index b04e95f513..f819fba888 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -229,15 +229,15 @@ namespace Intercept2 static utf8string getTunnelEdgeString(TunnelCall edge) { - utf8string out = new utf8[5]; + utf8string out = new utf8[6]; switch (edge.call) { case TUNNELCALL_SKIPPED: - sprintf(out, " "); + sprintf(out, "%s", " "); break; case TUNNELCALL_NONE: - sprintf(out, " - "); + sprintf(out, "%s", " - "); break; case TUNNELCALL_CALL: @@ -259,8 +259,8 @@ namespace Intercept2 utf8string tlEdge = getTunnelEdgeString(tunnelCalls[direction][2]); utf8string trEdge = getTunnelEdgeString(tunnelCalls[direction][3]); printf(" %s %s ", tlEdge, trEdge); - delete tlEdge; - delete trEdge; + delete [] tlEdge; + delete [] trEdge; } printf("\n"); @@ -273,8 +273,8 @@ namespace Intercept2 utf8string brEdge = getTunnelEdgeString(tunnelCalls[direction][0]); utf8string blEdge = getTunnelEdgeString(tunnelCalls[direction][1]); printf(" %s %s ", blEdge, brEdge); - delete blEdge; - delete brEdge; + delete [] blEdge; + delete [] brEdge; } printf("\n"); @@ -293,12 +293,14 @@ namespace Intercept2 { uint8 rideIndex = 0; rct_map_element mapElement = {0}; + mapElement.flags |= MAP_ELEMENT_FLAG_LAST_TILE; mapElement.properties.track.type = trackType; mapElement.base_height = 3; g_currently_drawn_item = &mapElement; rct_map_element surfaceElement = {0}; + surfaceElement.flags |= MAP_ELEMENT_FLAG_LAST_TILE; surfaceElement.type = MAP_ELEMENT_TYPE_SURFACE; surfaceElement.base_height = 2; @@ -459,6 +461,7 @@ namespace Intercept2 { uint8 rideIndex = 0; rct_map_element mapElement = {0}; + mapElement.flags |= MAP_ELEMENT_FLAG_LAST_TILE; mapElement.properties.track.type = trackType; mapElement.base_height = 3; @@ -649,6 +652,7 @@ namespace Intercept2 { uint8 rideIndex = 0; rct_map_element mapElement = {0}; + mapElement.flags |= MAP_ELEMENT_FLAG_LAST_TILE; mapElement.properties.track.type = trackType; mapElement.base_height = 3; diff --git a/test/testpaint/main.cpp b/test/testpaint/main.cpp index 7e3ac58b90..735676eec0 100644 --- a/test/testpaint/main.cpp +++ b/test/testpaint/main.cpp @@ -320,7 +320,7 @@ int main(int argc, char *argv[]) { for (auto &&failure : failures) { ColouredPrintF(CLIColour::RED, "[ FAILED ] "); printf("%s\n", failure); - delete(failure); + delete [] failure; } printf("\n"); From 78f653ebb644f13450feb1adde6bc97601b5fea1 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 9 Sep 2016 23:13:12 +0100 Subject: [PATCH 54/71] Fix x64 build for Windows --- openrct2.proj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openrct2.proj b/openrct2.proj index 071a4d50a4..73dd8ca493 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -14,6 +14,7 @@ + Debug Win32 $(COMPUTERNAME) $(GIT_COMMIT_SHA1.Substring(0, 7)) @@ -40,7 +41,7 @@ $(TargetDir)openrct2.dll $(TargetDir)openrct2.exe - $(TargetPath) + $(TargetDir)openrct2_x64.exe $(TargetDir)openrct2_data $(TargetDir)data\g2.dat @@ -74,7 +75,7 @@ - + From 527d18c9f1fca603aa022af247de94c703a405ec Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 9 Sep 2016 23:18:54 +0100 Subject: [PATCH 55/71] Fix testpaint.vcxproj --- test/testpaint/testpaint.vcxproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/testpaint/testpaint.vcxproj b/test/testpaint/testpaint.vcxproj index c7ffe6dc80..4c615d238d 100644 --- a/test/testpaint/testpaint.vcxproj +++ b/test/testpaint/testpaint.vcxproj @@ -49,7 +49,7 @@ $(SolutionDir)lib;$(LibraryPath) - $(SolutionDir)bin\testpaint + $(SolutionDir)bin\testpaint\ $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ openrct2 $(SolutionDir)lib\include;$(SolutionDir)lib\include\breakpad;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(SolutionDir)lib\include\zlib;$(IncludePath) @@ -71,6 +71,7 @@ true true true + $(OpenRCT2_DEFINES);NO_VEHICLES;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) true From 8af6dd1577cc1424cb91e35bbb12cbf942f422da Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 10 Sep 2016 16:31:29 +0200 Subject: [PATCH 56/71] Attempt to fix size mismatch --- test/testpaint/intercept_2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index f819fba888..8cf07d323e 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -127,7 +127,7 @@ namespace Intercept2 static bool SegmentCallEquals(std::vector lhs, std::vector rhs) { if (lhs.size() != rhs.size()) return false; - for (int i = 0; i < lhs.size(); ++i) { + for (size_t i = 0; i < lhs.size(); ++i) { if (lhs[i].segments != rhs[i].segments) return false; if (lhs[i].height != rhs[i].height) From 2d688e1056a753312608581700f2e2809603080b Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 10 Sep 2016 16:32:51 +0200 Subject: [PATCH 57/71] Expand message for support height mismatch --- test/testpaint/intercept_2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 8cf07d323e..84a313118e 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -424,7 +424,7 @@ namespace Intercept2 if (referenceGeneralSupportCall.height != -1) { if (gSupport.height != referenceGeneralSupportCall.height) { - printf("General support heights didn't match. [direction:%d trackSequence:%d]\n", direction, + printf("General support heights didn't match. (expected %d, actual: %d) [direction:%d trackSequence:%d]\n", referenceGeneralSupportCall.height,gSupport.height, direction, trackSequence); return false; } From 0f51be809c0c46aeaf342969352026a6ea9ee168 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 12 Sep 2016 17:37:57 +0200 Subject: [PATCH 58/71] Update code to match develop --- test/testpaint/compat.c | 6 +++++- test/testpaint/intercept.c | 16 ++++++++-------- test/testpaint/intercept_2.cpp | 24 ++++++++++++------------ 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/test/testpaint/compat.c b/test/testpaint/compat.c index c8b7bb015c..99f4b2e58e 100644 --- a/test/testpaint/compat.c +++ b/test/testpaint/compat.c @@ -23,6 +23,8 @@ #include "../../src/world/sprite.h" #include "../../src/paint/map_element/map_element.h" +#define RCT2_ADDRESS_SPRITE_LIST 0x010E63BC + #define gRideEntries RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_entry*) #define gCurrentRotation RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8) @@ -31,7 +33,9 @@ rct_map_element **gMapElementTilePointers = (rct_map_element **) RCT2_ADDRESS_TI rct_ride *gRideList = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride); rct_sprite *sprite_list = RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite); sint16 gMapSizeUnits; - +sint16 gMapBaseZ; +bool gTrackDesignSaveMode = false; +uint8 gTrackDesignSaveRideIndex = 255; const rct_xy16 TileDirectionDelta[] = { {-32, 0}, diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index a7f0512cc0..e920e29791 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -359,10 +359,10 @@ static void printImageId(uint32 input, utf8string *out) { bool allocated = false; utf8string paletteName; - if (palette == PALETTE_98)paletteName = "PALETTE_98"; - else if (palette == PALETTE_9C)paletteName = "PALETTE_9C"; - else if (palette == PALETTE_A0)paletteName = "PALETTE_A0"; - else if (palette == PALETTE_A4)paletteName = "PALETTE_A4"; + if (palette == PALETTE_98)paletteName = "SCHEME_TRACK"; + else if (palette == PALETTE_9C)paletteName = "SCHEME_SUPPORTS"; + else if (palette == PALETTE_A0)paletteName = "SCHEME_MISC"; + else if (palette == PALETTE_A4)paletteName = "SCHEME_3"; else { paletteName = malloc(16); sprintf(paletteName, "0x%08X", palette); @@ -503,10 +503,10 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) surfaceElement.base_height = 2; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; - RCT2_GLOBAL(0x00F44198, uint32) = PALETTE_98; - RCT2_GLOBAL(0x00F441A0, uint32) = PALETTE_A0; - RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; - RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; + gTrackColours[SCHEME_TRACK] = PALETTE_98; + gTrackColours[SCHEME_SUPPORTS] = PALETTE_A0; + gTrackColours[SCHEME_MISC] = PALETTE_A4; + gTrackColours[SCHEME_3] = PALETTE_9C; rct_drawpixelinfo dpi = {.zoom_level = 1}; unk_140E9A8 = &dpi; diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 84a313118e..2e41d935db 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -305,10 +305,10 @@ namespace Intercept2 surfaceElement.base_height = 2; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; - RCT2_GLOBAL(0x00F44198, uint32) = PALETTE_98; - RCT2_GLOBAL(0x00F441A0, uint32) = PALETTE_A0; - RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; - RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; + gTrackColours[SCHEME_TRACK] = PALETTE_98; + gTrackColours[SCHEME_SUPPORTS] = PALETTE_A0; + gTrackColours[SCHEME_MISC] = PALETTE_A4; + gTrackColours[SCHEME_3] = PALETTE_9C; rct_drawpixelinfo dpi = { 0 }; dpi.zoom_level = 1; @@ -472,10 +472,10 @@ namespace Intercept2 surfaceElement.base_height = 2; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; - RCT2_GLOBAL(0x00F44198, uint32) = PALETTE_98; - RCT2_GLOBAL(0x00F441A0, uint32) = PALETTE_A0; - RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; - RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; + gTrackColours[SCHEME_TRACK] = PALETTE_98; + gTrackColours[SCHEME_SUPPORTS] = PALETTE_A0; + gTrackColours[SCHEME_MISC] = PALETTE_A4; + gTrackColours[SCHEME_3] = PALETTE_9C; rct_drawpixelinfo dpi { 0 }; dpi.zoom_level = 1; @@ -663,10 +663,10 @@ namespace Intercept2 surfaceElement.base_height = 2; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; - RCT2_GLOBAL(0x00F44198, uint32) = PALETTE_98; - RCT2_GLOBAL(0x00F441A0, uint32) = PALETTE_A0; - RCT2_GLOBAL(0x00F441A4, uint32) = PALETTE_A4; - RCT2_GLOBAL(0x00F4419C, uint32) = PALETTE_9C; + gTrackColours[SCHEME_TRACK] = PALETTE_98; + gTrackColours[SCHEME_SUPPORTS] = PALETTE_A0; + gTrackColours[SCHEME_MISC] = PALETTE_A4; + gTrackColours[SCHEME_3] = PALETTE_9C; rct_drawpixelinfo dpi = { 0 }; dpi.zoom_level = 1; From 1cc43d50126d7035c080aa4ee9abee883101b0b9 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 12 Sep 2016 22:56:52 +0200 Subject: [PATCH 59/71] Add missing compat function --- test/testpaint/compat.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/testpaint/compat.c b/test/testpaint/compat.c index 99f4b2e58e..188c4217fe 100644 --- a/test/testpaint/compat.c +++ b/test/testpaint/compat.c @@ -146,3 +146,8 @@ bool ride_type_has_flag(int rideType, int flag) { return (RideProperties[rideType].flags & flag) != 0; } + +sint16 get_height_marker_offset() +{ + return 0; +} From 4e4a07d1b03b1a8e9d63e70f3ab176cada19f72c Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Thu, 15 Sep 2016 19:10:33 +0200 Subject: [PATCH 60/71] Update testpaint to match develop --- CMakeLists.txt | 2 +- OpenRCT2.xcodeproj/project.pbxproj | 2 ++ test/testpaint/compat.c | 4 ++-- test/testpaint/intercept.c | 9 +++++---- test/testpaint/intercept_2.cpp | 9 +++------ test/testpaint/testpaint.vcxproj | 1 + 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 629f1f4950..f01b8ca80d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -367,7 +367,7 @@ install(FILES ${DOC_FILES} DESTINATION share/doc/${PROJECT}) if (UNIX AND (NOT USE_MMAP) AND (NOT DISABLE_RCT2) AND (NOT FORCE64)) file(GLOB_RECURSE ORCT2_RIDE_SOURCES "src/ride/*/*.c") - file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") + file(GLOB_RECURSE ORCT2_RIDE_DEP_SOURCES "src/ride/ride_data.c" "src/ride/track_data.c" "src/ride/track_data_old.c" "src/ride/track_paint.c" "src/addresses.c" "src/diagnostic.c" "src/hook.c" "src/paint/map_element/map_element.c") file(GLOB_RECURSE ORCT2_TESTPAINT_SOURCES "test/testpaint/*.c" "test/testpaint/*.cpp" "test/testpaint/*.h") add_executable(testpaint EXCLUDE_FROM_ALL ${ORCT2_RIDE_SOURCES} ${ORCT2_RIDE_DEP_SOURCES} ${ORCT2_TESTPAINT_SOURCES} ${RCT2_SECTIONS}) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index 10a75cc3f8..b01faed27b 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 008BF72C1CDAA5C30019A2AD /* track_design.c in Sources */ = {isa = PBXBuildFile; fileRef = 008BF7281CDAA5C30019A2AD /* track_design.c */; }; 00EFEE721CF1D80B0035213B /* NetworkKey.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 00EFEE701CF1D80B0035213B /* NetworkKey.cpp */; }; 791166FB1D7486EF005912EA /* NetworkServerAdvertiser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 791166F91D7486EF005912EA /* NetworkServerAdvertiser.cpp */; }; + 85060FD31D8C17CC00DFA2B3 /* track_data_old.c in Sources */ = {isa = PBXBuildFile; fileRef = 8594C05F1D885CF600235E93 /* track_data_old.c */; }; 8594C0601D885CF600235E93 /* track_data_old.c in Sources */ = {isa = PBXBuildFile; fileRef = 8594C05F1D885CF600235E93 /* track_data_old.c */; }; 85AFA2111D7DB83E00221B42 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85AFA20F1D7DB83E00221B42 /* main.cpp */; }; 85B5C0B01D81D912001B99A8 /* intercept_2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85B5C0AF1D81D912001B99A8 /* intercept_2.cpp */; }; @@ -2410,6 +2411,7 @@ C64FDA841D6D9A2100F259B9 /* car_ride.c in Sources */, C64FDA851D6D9A2100F259B9 /* circus_show.c in Sources */, C64FDA861D6D9A2100F259B9 /* crooked_house.c in Sources */, + 85060FD31D8C17CC00DFA2B3 /* track_data_old.c in Sources */, C64FDA871D6D9A2100F259B9 /* dodgems.c in Sources */, C64FDA881D6D9A2100F259B9 /* ferris_wheel.c in Sources */, C64FDA891D6D9A2100F259B9 /* flying_saucers.c in Sources */, diff --git a/test/testpaint/compat.c b/test/testpaint/compat.c index 188c4217fe..5ff4bd9855 100644 --- a/test/testpaint/compat.c +++ b/test/testpaint/compat.c @@ -53,8 +53,8 @@ uint8 get_current_rotation() { } const uint32 construction_markers[] = { - COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_USE_PALETTE << 28, // White - 2 << 19 | 0b110000 << 19 | IMAGE_TYPE_MIX_BACKGROUND << 28, // Translucent + COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_REMAP, // White + 2 << 19 | 0b110000 << 19 | IMAGE_TYPE_TRANSPARENT, // Translucent }; int object_entry_group_counts[] = { diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index e920e29791..c3f4cb1c0f 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -533,14 +533,13 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) for (int trackSequence = 0; trackSequence < sequenceCount; trackSequence++) { RCT2_GLOBAL(0x009DE56A, sint16) = 64; // x RCT2_GLOBAL(0x009DE56E, sint16) = 64; // y - RCT2_GLOBAL(0x009DE57C, bool) = true; // Above surface - RCT2_GLOBAL(0x009E3250, rct_map_element *) = &surfaceElement; + gDidPassSurface = true; // Above surface + gSurfaceElement = &surfaceElement; callCount = 0; memset(&calls, 0, sizeof(calls)); - TRACK_PAINT_FUNCTION **trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; - uint32 *trackDirectionList = (uint32 *) trackTypeList[trackType]; + uint32 *trackDirectionList = (uint32 *)RideTypeTrackPaintFunctionsOld[rideType][trackType]; // Have to call from this point as it pushes esi and expects callee to pop it RCT2_CALLPROC_X( @@ -594,6 +593,8 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) } } + sprintf(*error, ""); + bool segmentSuccess = testSupportSegments(rideType, trackType); if (!segmentSuccess) { return false; diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 2e41d935db..92eff337df 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -345,8 +345,7 @@ namespace Intercept2 gSupport.height = 0; gSupport.slope = 0xFF; - TRACK_PAINT_FUNCTION ** trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; - uint32 * trackDirectionList = (uint32 *) trackTypeList[trackType]; + uint32 *trackDirectionList = (uint32 *)RideTypeTrackPaintFunctionsOld[rideType][trackType]; // Have to call from this point as it pushes esi and expects callee to pop it RCT2_CALLPROC_X( @@ -506,8 +505,7 @@ namespace Intercept2 gLeftTunnelCount = 0; gRightTunnelCount = 0; - TRACK_PAINT_FUNCTION ** trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; - uint32 * trackDirectionList = (uint32 *) trackTypeList[trackType]; + uint32 *trackDirectionList = (uint32 *)RideTypeTrackPaintFunctionsOld[rideType][trackType]; // Have to call from this point as it pushes esi and expects callee to pop it RCT2_CALLPROC_X( @@ -696,8 +694,7 @@ namespace Intercept2 for (int direction = 0; direction < 4; direction++) { gVerticalTunnelHeight = 0; - TRACK_PAINT_FUNCTION ** trackTypeList = (TRACK_PAINT_FUNCTION **) RideTypeTrackPaintFunctionsOld[rideType]; - uint32 * trackDirectionList = (uint32 *) trackTypeList[trackType]; + uint32 *trackDirectionList = (uint32 *)RideTypeTrackPaintFunctionsOld[rideType][trackType]; // Have to call from this point as it pushes esi and expects callee to pop it RCT2_CALLPROC_X( diff --git a/test/testpaint/testpaint.vcxproj b/test/testpaint/testpaint.vcxproj index 4c615d238d..e3350e01d9 100644 --- a/test/testpaint/testpaint.vcxproj +++ b/test/testpaint/testpaint.vcxproj @@ -157,6 +157,7 @@ + From 8982d87e77a986b8537e997c6469d63959f19226 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 16 Sep 2016 14:17:49 +0200 Subject: [PATCH 61/71] Add missing paint functions to track_data_old --- src/ride/track_data_old.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ride/track_data_old.c b/src/ride/track_data_old.c index 86d3bfe498..d8530f1aa6 100644 --- a/src/ride/track_data_old.c +++ b/src/ride/track_data_old.c @@ -3204,8 +3204,8 @@ static const uint32 _OldLaunchedFreefallTrackPaintFunctions[256] = { 0, 0, 0, - 0, - 0, + 0x006FD1F8, // TRACK_ELEM_TOWER_BASE + 0x006FD208, // TRACK_ELEM_TOWER_SECTION 0, 0, 0, From f2f99d7bb1071f70f8e0c1e5d665ab63cd9ada1d Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 16 Sep 2016 14:22:53 +0200 Subject: [PATCH 62/71] Improve environment simulation --- test/testpaint/intercept.c | 1 + test/testpaint/intercept_2.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index c3f4cb1c0f..1f1035b84f 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -535,6 +535,7 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) RCT2_GLOBAL(0x009DE56E, sint16) = 64; // y gDidPassSurface = true; // Above surface gSurfaceElement = &surfaceElement; + g141E9DB = G141E9DB_FLAG_1 | G141E9DB_FLAG_2; callCount = 0; memset(&calls, 0, sizeof(calls)); diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 92eff337df..76e51bad81 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -344,6 +344,7 @@ namespace Intercept2 gSupport.height = 0; gSupport.slope = 0xFF; + g141E9DB = G141E9DB_FLAG_1 | G141E9DB_FLAG_2; uint32 *trackDirectionList = (uint32 *)RideTypeTrackPaintFunctionsOld[rideType][trackType]; From 987bfa409a738f4ab6cd2f1a4e379ca3fa1fd5cd Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 16 Sep 2016 14:30:20 +0200 Subject: [PATCH 63/71] Improve track type support check --- test/testpaint/intercept.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index 1f1035b84f..d40824116a 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -465,16 +465,23 @@ int getTrackSequenceCount(uint8 rideType, uint8 trackType) { return sequenceCount; } -bool rideSupportsTrackType(int rideType, int trackType) { +bool rideSupportsTrackType(int rideType, int trackType) +{ TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; if (newPaintGetter == NULL) { return false; } - bool supportsTrackType = (newPaintGetter(trackType, 0) != NULL); + if (newPaintGetter(trackType, 0) == NULL) { + return false; + } - return supportsTrackType; + if (RideTypeTrackPaintFunctionsOld[rideType][trackType] == 0) { + return false; + } + + return true; } From 1c585e45e3d37942035fd9943215fc5b7138c186 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 16 Sep 2016 14:32:52 +0200 Subject: [PATCH 64/71] Improve Visual Studio compatibility --- test/testpaint/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/testpaint/main.cpp b/test/testpaint/main.cpp index 735676eec0..06191c9d3e 100644 --- a/test/testpaint/main.cpp +++ b/test/testpaint/main.cpp @@ -119,8 +119,6 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta _dllModule = GetModuleHandleA(OPENRCT2_DLL_MODULE_NAME); } - RCT2_GLOBAL(RCT2_ADDRESS_HINSTANCE, HINSTANCE) = hInstance; - int gExitCode = main(0, NULL); exit(gExitCode); From 5524bd0e14ad60a83b66f02feff9eb7e1697cba6 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 16 Sep 2016 14:51:51 +0200 Subject: [PATCH 65/71] Print address of failed function --- test/testpaint/intercept.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index d40824116a..c4b447e2cf 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -531,6 +531,8 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) int height = 48; + sprintf(*error, "rct2: 0x%08X\n", RideTypeTrackPaintFunctionsOld[rideType][trackType]); + TRACK_PAINT_FUNCTION_GETTER newPaintGetter = RideTypeTrackPaintFunctions[rideType]; int sequenceCount = getTrackSequenceCount(rideType, trackType); for (int currentRotation = 0; currentRotation < 4; currentRotation++) { @@ -585,9 +587,9 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) sprintf(diff + strlen(diff), ">>> ACTUAL\n"); if (oldCallCount != newCallCount) { - sprintf(*error, "Call counts don't match (was %d, expected %d) [direction:%d trackSequence:%d]", newCallCount, oldCallCount, direction, trackSequence); + sprintf(*error + strlen(*error), "Call counts don't match (was %d, expected %d) [direction:%d trackSequence:%d]", newCallCount, oldCallCount, direction, trackSequence); } else { - sprintf(*error, "Calls don't match [direction:%d trackSequence:%d]", direction, trackSequence); + sprintf(*error + strlen(*error), "Calls don't match [direction:%d trackSequence:%d]", direction, trackSequence); } sprintf(*error + strlen(*error), "\n%s", diff); @@ -601,7 +603,7 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) } } - sprintf(*error, ""); + sprintf(*error + strlen(*error), ""); bool segmentSuccess = testSupportSegments(rideType, trackType); if (!segmentSuccess) { From c526d0da3fd41125b6f55ad610b1be089f58c295 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 16 Sep 2016 15:05:19 +0200 Subject: [PATCH 66/71] Rename default palette options --- test/testpaint/intercept.c | 24 ++++++++++++------------ test/testpaint/intercept_2.cpp | 32 ++++++++++++++++---------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index c4b447e2cf..58b4cfc50f 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -22,10 +22,10 @@ #include "../../src/hook.h" -static const uint32 PALETTE_98 = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; -static const uint32 PALETTE_9C = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; -static const uint32 PALETTE_A0 = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000; -static const uint32 PALETTE_A4 = COLOUR_BRIGHT_PURPLE << 19 | COLOUR_DARK_BLUE << 24 | 0xA0000000; +static const uint32 DEFAULT_SCHEME_TRACK = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; +static const uint32 DEFAULT_SCHEME_SUPPORTS = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; +static const uint32 DEFAULT_SCHEME_MISC = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000; +static const uint32 DEFAULT_SCHEME_3 = COLOUR_BRIGHT_PURPLE << 19 | COLOUR_DARK_BLUE << 24 | 0xA0000000; extern const utf8string RideNames[91]; extern const utf8string TrackNames[256]; @@ -359,10 +359,10 @@ static void printImageId(uint32 input, utf8string *out) { bool allocated = false; utf8string paletteName; - if (palette == PALETTE_98)paletteName = "SCHEME_TRACK"; - else if (palette == PALETTE_9C)paletteName = "SCHEME_SUPPORTS"; - else if (palette == PALETTE_A0)paletteName = "SCHEME_MISC"; - else if (palette == PALETTE_A4)paletteName = "SCHEME_3"; + if (palette == DEFAULT_SCHEME_TRACK)paletteName = "SCHEME_TRACK"; + else if (palette == DEFAULT_SCHEME_SUPPORTS)paletteName = "SCHEME_SUPPORTS"; + else if (palette == DEFAULT_SCHEME_MISC)paletteName = "SCHEME_MISC"; + else if (palette == DEFAULT_SCHEME_3)paletteName = "SCHEME_3"; else { paletteName = malloc(16); sprintf(paletteName, "0x%08X", palette); @@ -510,10 +510,10 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) surfaceElement.base_height = 2; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; - gTrackColours[SCHEME_TRACK] = PALETTE_98; - gTrackColours[SCHEME_SUPPORTS] = PALETTE_A0; - gTrackColours[SCHEME_MISC] = PALETTE_A4; - gTrackColours[SCHEME_3] = PALETTE_9C; + gTrackColours[SCHEME_TRACK] = DEFAULT_SCHEME_TRACK; + gTrackColours[SCHEME_SUPPORTS] = DEFAULT_SCHEME_SUPPORTS; + gTrackColours[SCHEME_MISC] = DEFAULT_SCHEME_MISC; + gTrackColours[SCHEME_3] = DEFAULT_SCHEME_3; rct_drawpixelinfo dpi = {.zoom_level = 1}; unk_140E9A8 = &dpi; diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 76e51bad81..41685b05de 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -29,10 +29,10 @@ extern "C" { namespace Intercept2 { - static const uint32 PALETTE_98 = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; - static const uint32 PALETTE_9C = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; - static const uint32 PALETTE_A0 = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000; - static const uint32 PALETTE_A4 = COLOUR_BRIGHT_PURPLE << 19 | COLOUR_DARK_BLUE << 24 | 0xA0000000; + static const uint32 DEFAULT_SCHEME_TRACK = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000; + static const uint32 DEFAULT_SCHEME_SUPPORTS = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000; + static const uint32 DEFAULT_SCHEME_MISC = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000; + static const uint32 DEFAULT_SCHEME_3 = COLOUR_BRIGHT_PURPLE << 19 | COLOUR_DARK_BLUE << 24 | 0xA0000000; struct SegmentSupportCall { @@ -305,10 +305,10 @@ namespace Intercept2 surfaceElement.base_height = 2; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; - gTrackColours[SCHEME_TRACK] = PALETTE_98; - gTrackColours[SCHEME_SUPPORTS] = PALETTE_A0; - gTrackColours[SCHEME_MISC] = PALETTE_A4; - gTrackColours[SCHEME_3] = PALETTE_9C; + gTrackColours[SCHEME_TRACK] = DEFAULT_SCHEME_TRACK; + gTrackColours[SCHEME_SUPPORTS] = DEFAULT_SCHEME_SUPPORTS; + gTrackColours[SCHEME_MISC] = DEFAULT_SCHEME_MISC; + gTrackColours[SCHEME_3] = DEFAULT_SCHEME_3; rct_drawpixelinfo dpi = { 0 }; dpi.zoom_level = 1; @@ -472,10 +472,10 @@ namespace Intercept2 surfaceElement.base_height = 2; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; - gTrackColours[SCHEME_TRACK] = PALETTE_98; - gTrackColours[SCHEME_SUPPORTS] = PALETTE_A0; - gTrackColours[SCHEME_MISC] = PALETTE_A4; - gTrackColours[SCHEME_3] = PALETTE_9C; + gTrackColours[SCHEME_TRACK] = DEFAULT_SCHEME_TRACK; + gTrackColours[SCHEME_SUPPORTS] = DEFAULT_SCHEME_SUPPORTS; + gTrackColours[SCHEME_MISC] = DEFAULT_SCHEME_MISC; + gTrackColours[SCHEME_3] = DEFAULT_SCHEME_3; rct_drawpixelinfo dpi { 0 }; dpi.zoom_level = 1; @@ -662,10 +662,10 @@ namespace Intercept2 surfaceElement.base_height = 2; gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE; - gTrackColours[SCHEME_TRACK] = PALETTE_98; - gTrackColours[SCHEME_SUPPORTS] = PALETTE_A0; - gTrackColours[SCHEME_MISC] = PALETTE_A4; - gTrackColours[SCHEME_3] = PALETTE_9C; + gTrackColours[SCHEME_TRACK] = DEFAULT_SCHEME_TRACK; + gTrackColours[SCHEME_SUPPORTS] = DEFAULT_SCHEME_SUPPORTS; + gTrackColours[SCHEME_MISC] = DEFAULT_SCHEME_MISC; + gTrackColours[SCHEME_3] = DEFAULT_SCHEME_3; rct_drawpixelinfo dpi = { 0 }; dpi.zoom_level = 1; From 9ca2f898316650894e57c0898c386abfb22891d5 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 16 Sep 2016 15:47:04 +0200 Subject: [PATCH 67/71] Improve test output --- test/testpaint/intercept.c | 5 +++++ test/testpaint/intercept_2.cpp | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index 58b4cfc50f..d57f1524df 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -249,6 +249,7 @@ bool metal_b_supports_paint_setup(int supportType, uint8 segment, int special, i enum { SPRITEGROUP_NONE, + SPRITEGROUP_FENCE_METAL_A, // 14568 SPRITEGROUP_FENCE_METAL_B, // 14990 SPRITEGROUP_FLOOR_CORK, // 22134 SPRITEGROUP_FENCE_ROPE, // 22138 @@ -256,6 +257,10 @@ enum { }; static int getSpriteGroup(uint16 spriteIndex) { + if (spriteIndex >= 14568 && spriteIndex <= 14571) { + return SPRITEGROUP_FENCE_METAL_A; + } + if (spriteIndex >= 14990 && spriteIndex <= 14993) { return SPRITEGROUP_FENCE_METAL_B; } diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 41685b05de..e4beb20bc4 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -587,17 +587,17 @@ namespace Intercept2 } } - if (!tunnelCallsLineUp(newTileTunnelCalls)) { - printf("Decompiled tunnel calls don\'t line up. [trackSequence:%d].\n", trackSequence); - printTunnelCalls(newTileTunnelCalls); - return false; - } - if (!tunnelCallsLineUp(tileTunnelCalls)) { printf("Original tunnel calls don\'t line up. Skipping tunnel validation [trackSequence:%d].\n", trackSequence); printTunnelCalls(tileTunnelCalls); + + if (!tunnelCallsLineUp(newTileTunnelCalls)) { + printf("Decompiled tunnel calls don\'t line up. [trackSequence:%d].\n", trackSequence); + printTunnelCalls(newTileTunnelCalls); + return false; + } continue; } From 52282e399bd17a5f973810a978924f009f4655e4 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 16 Sep 2016 18:11:14 +0200 Subject: [PATCH 68/71] Use named addresses for bound box catching --- test/testpaint/intercept.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index d57f1524df..6a44c3423e 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -669,7 +669,11 @@ static int intercept_draw_7c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uin log_error("Ebp is different from current rotation"); } - rct_xyz16 boundOffset = {RCT2_GLOBAL(0x009DEA52, sint16), RCT2_GLOBAL(0x009DEA54, sint16), RCT2_GLOBAL(0x009DEA56, sint16)}; + rct_xyz16 boundOffset = { + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_X, sint16), + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Y, sint16), + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Z, sint16) + }; return (int) sub_98197C(ebx, regs.al, regs.cl, regs.di, regs.si, regs.ah, regs.dx, boundOffset.x, boundOffset.y, boundOffset.z, regs.ebp & 0x03); } @@ -681,7 +685,11 @@ static int intercept_draw_9c(uint32 eax, uint32 ebx, uint32 ecx, uint32 edx, uin log_error("Ebp is different from current rotation"); } - rct_xyz16 boundOffset = {RCT2_GLOBAL(0x009DEA52, sint16), RCT2_GLOBAL(0x009DEA54, sint16), RCT2_GLOBAL(0x009DEA56, sint16)}; + rct_xyz16 boundOffset = { + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_X, sint16), + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Y, sint16), + RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Z, sint16) + }; return (int) sub_98199C(ebx, regs.al, regs.cl, regs.di, regs.si, regs.ah, regs.dx, boundOffset.x, boundOffset.y, boundOffset.z, regs.ebp & 0x03); } From c233e0491aa03c8a8a54c1dc6afb838fecfc150e Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 16 Sep 2016 18:48:35 +0200 Subject: [PATCH 69/71] Improve tunnel offset detection --- test/testpaint/intercept_2.cpp | 83 ++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 25 deletions(-) diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index e4beb20bc4..44d30e70e2 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -55,7 +55,7 @@ namespace Intercept2 struct TunnelCall { uint8 call; - uint8 height; + sint16 offset; uint8 type; }; @@ -204,7 +204,7 @@ namespace Intercept2 if (referenceCall->call == TUNNELCALL_CALL) { if (referenceCall->type != tunnelCalls[direction][side].type) return false; - if (referenceCall->height != tunnelCalls[direction][side].height) return false; + if (referenceCall->offset != tunnelCalls[direction][side].offset) return false; } } } @@ -222,7 +222,7 @@ namespace Intercept2 (*out)[side].call = tunnelCalls[direction][side].call; (*out)[side].type = tunnelCalls[direction][side].type; - (*out)[side].height = tunnelCalls[direction][side].height; + (*out)[side].offset = tunnelCalls[direction][side].offset; } } } @@ -241,7 +241,20 @@ namespace Intercept2 break; case TUNNELCALL_CALL: - sprintf(out, " %d,%X ", edge.height, edge.type); + if (edge.offset == 0) { + sprintf(out, " 0/%X ", edge.type); + } else { + utf8string offset = new utf8[3]; + if (edge.offset < 0) { + sprintf(offset, "%d", edge.offset); + } else { + sprintf(offset, "+%d", edge.offset); + } + + sprintf(out, "%3s/%X ", offset, edge.type); + + delete[] offset; + } break; } @@ -450,13 +463,27 @@ namespace Intercept2 if (expected[side].call == TUNNELCALL_CALL) { if (expected[side].type != actual[side].type) return false; - if (expected[side].height != actual[side].height) return false; + if (expected[side].offset != actual[side].offset) return false; } } return true; } + static sint16 getTunnelOffset(uint baseHeight, tunnel_entry calls[3]) + { + for (sint16 offset = -56; offset <= 56; offset += 8) { + if (calls[0].height != (baseHeight - 8 + offset) / 16) continue; + if (calls[1].height != (baseHeight + 0 + offset) / 16) continue; + if (calls[2].height != (baseHeight + 8 + offset) / 16) continue; + + return offset; + } + + log_error("Unknown tunnel height. (%d, %d, %d)", calls[0].height, calls[1].height, calls[2].height); + return 0; + } + static bool testTunnels(uint8 rideType, uint8 trackType) { uint8 rideIndex = 0; @@ -508,17 +535,19 @@ namespace Intercept2 uint32 *trackDirectionList = (uint32 *)RideTypeTrackPaintFunctionsOld[rideType][trackType]; - // Have to call from this point as it pushes esi and expects callee to pop it - RCT2_CALLPROC_X( - 0x006C4934, - rideType, - (int) trackDirectionList, - direction, - height, - (int) &mapElement, - rideIndex * sizeof(rct_ride), - trackSequence - ); + for (int offset = -8; offset <= 8; offset += 8) { + // Have to call from this point as it pushes esi and expects callee to pop it + RCT2_CALLPROC_X( + 0x006C4934, + rideType, + (int) trackDirectionList, + direction, + height + offset, + (int) &mapElement, + rideIndex * sizeof(rct_ride), + trackSequence + ); + } uint8 rightIndex = (4 - direction) % 4; uint8 leftIndex = (rightIndex + 1) % 4; @@ -528,9 +557,9 @@ namespace Intercept2 } if (gRightTunnelCount == 0) { tileTunnelCalls[direction][rightIndex].call = TUNNELCALL_NONE; - } else if (gRightTunnelCount == 1) { + } else if (gRightTunnelCount == 3) { tileTunnelCalls[direction][rightIndex].call = TUNNELCALL_CALL; - tileTunnelCalls[direction][rightIndex].height = gRightTunnels[0].height; + tileTunnelCalls[direction][rightIndex].offset = getTunnelOffset(height, gRightTunnels); tileTunnelCalls[direction][rightIndex].type = gRightTunnels[0].type; } else { printf("Multiple tunnels on one side aren't supported.\n"); @@ -539,9 +568,9 @@ namespace Intercept2 if (gLeftTunnelCount == 0) { tileTunnelCalls[direction][leftIndex].call = TUNNELCALL_NONE; - } else if (gLeftTunnelCount == 1) { + } else if (gLeftTunnelCount == 3) { tileTunnelCalls[direction][leftIndex].call = TUNNELCALL_CALL; - tileTunnelCalls[direction][leftIndex].height = gLeftTunnels[0].height; + tileTunnelCalls[direction][leftIndex].offset = getTunnelOffset(height, gLeftTunnels); tileTunnelCalls[direction][leftIndex].type = gLeftTunnels[0].type; } else { printf("Multiple tunnels on one side aren't supported.\n"); @@ -555,7 +584,11 @@ namespace Intercept2 gRightTunnelCount = 0; TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); - newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + + for (int offset = -8; offset <= 8; offset += 8) { + // TODO: move tunnel pushing to interface so we don't have to check the output 3 times + newPaintFunction(rideIndex, trackSequence, direction, height + offset, &mapElement); + } uint8 rightIndex = (4 - direction) % 4; uint8 leftIndex = (rightIndex + 1) % 4; @@ -566,9 +599,9 @@ namespace Intercept2 if (gRightTunnelCount == 0) { newTileTunnelCalls[direction][rightIndex].call = TUNNELCALL_NONE; - } else if (gRightTunnelCount == 1) { + } else if (gRightTunnelCount == 3) { newTileTunnelCalls[direction][rightIndex].call = TUNNELCALL_CALL; - newTileTunnelCalls[direction][rightIndex].height = gRightTunnels[0].height; + newTileTunnelCalls[direction][rightIndex].offset = getTunnelOffset(height, gRightTunnels); newTileTunnelCalls[direction][rightIndex].type = gRightTunnels[0].type; } else { printf("Multiple tunnels on one side aren't supported.\n"); @@ -577,9 +610,9 @@ namespace Intercept2 if (gLeftTunnelCount == 0) { newTileTunnelCalls[direction][leftIndex].call = TUNNELCALL_NONE; - } else if (gLeftTunnelCount == 1) { + } else if (gLeftTunnelCount == 3) { newTileTunnelCalls[direction][leftIndex].call = TUNNELCALL_CALL; - newTileTunnelCalls[direction][leftIndex].height = gLeftTunnels[0].height; + newTileTunnelCalls[direction][leftIndex].offset = getTunnelOffset(height, gLeftTunnels); newTileTunnelCalls[direction][leftIndex].type = gLeftTunnels[0].type; } else { printf("Multiple tunnels on one side aren't supported.\n"); From dbb822ad35498969ed918518ada33106df663ffd Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 16 Sep 2016 18:20:17 +0100 Subject: [PATCH 70/71] Ignore zero sized array warning to fix VS builds --- test/testpaint/intercept_2.cpp | 2 +- test/testpaint/testpaint.vcxproj | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index 44d30e70e2..47db93ee5d 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -470,7 +470,7 @@ namespace Intercept2 return true; } - static sint16 getTunnelOffset(uint baseHeight, tunnel_entry calls[3]) + static sint16 getTunnelOffset(uint32 baseHeight, tunnel_entry calls[3]) { for (sint16 offset = -56; offset <= 56; offset += 8) { if (calls[0].height != (baseHeight - 8 + offset) / 16) continue; diff --git a/test/testpaint/testpaint.vcxproj b/test/testpaint/testpaint.vcxproj index e3350e01d9..94cf7fbaf2 100644 --- a/test/testpaint/testpaint.vcxproj +++ b/test/testpaint/testpaint.vcxproj @@ -62,6 +62,7 @@ true $(OpenRCT2_DEFINES);DEBUG;NO_VEHICLES;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) true + 4200 @@ -73,6 +74,7 @@ true $(OpenRCT2_DEFINES);NO_VEHICLES;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) true + 4200 true From 18a6d4246badf0519cabbb83e73ced0fb4149326 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 16 Sep 2016 19:49:16 +0200 Subject: [PATCH 71/71] Update scheme to Xcode 8 --- .../xcshareddata/xcschemes/PaintTest.xcscheme | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenRCT2.xcodeproj/xcshareddata/xcschemes/PaintTest.xcscheme b/OpenRCT2.xcodeproj/xcshareddata/xcschemes/PaintTest.xcscheme index bd9963e139..4262704c01 100644 --- a/OpenRCT2.xcodeproj/xcshareddata/xcschemes/PaintTest.xcscheme +++ b/OpenRCT2.xcodeproj/xcshareddata/xcschemes/PaintTest.xcscheme @@ -1,6 +1,6 @@ @@ -32,7 +32,7 @@ @@ -55,7 +55,7 @@ runnableDebuggingMode = "0"> @@ -74,7 +74,7 @@ runnableDebuggingMode = "0">