From 36bc1f816cf2a86bcaa60d251ad07279e858e94f Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Thu, 1 Feb 2018 12:28:50 +0100 Subject: [PATCH] Clean up C bits from Testpaint --- test/testpaint/Addresses.h | 9 +---- test/testpaint/Hook.h | 13 +----- test/testpaint/PaintIntercept.cpp | 4 -- test/testpaint/SegmentSupportHeightCall.hpp | 5 +-- test/testpaint/SideTunnelCall.hpp | 3 -- test/testpaint/TestPaint.cpp | 45 ++++++++++----------- test/testpaint/TestPaint.hpp | 22 +++++----- test/testpaint/TestTrack.cpp | 18 ++++----- test/testpaint/generate.cpp | 16 ++++---- 9 files changed, 49 insertions(+), 86 deletions(-) diff --git a/test/testpaint/Addresses.h b/test/testpaint/Addresses.h index d37e74c5bd..8db58c5fa3 100644 --- a/test/testpaint/Addresses.h +++ b/test/testpaint/Addresses.h @@ -34,11 +34,6 @@ #define RCT2_ADDRESS(address, type) ((type*)(GOOD_PLACE_FOR_DATA_SEGMENT - 0x8a4000 + (address))) #define RCT2_GLOBAL(address, type) (*((type*)(GOOD_PLACE_FOR_DATA_SEGMENT - 0x8a4000 + (address)))) -#ifdef __cplusplus -extern "C" -{ -#endif - /** * Returns the flags register * @@ -53,8 +48,6 @@ extern "C" */ sint32 RCT2_CALLPROC_X(sint32 address, sint32 _eax, sint32 _ebx, sint32 _ecx, sint32 _edx, sint32 _esi, sint32 _edi, sint32 _ebp); -#ifdef __cplusplus -} -#endif + #endif diff --git a/test/testpaint/Hook.h b/test/testpaint/Hook.h index 3b462bd556..cc4ba55838 100644 --- a/test/testpaint/Hook.h +++ b/test/testpaint/Hook.h @@ -14,8 +14,7 @@ *****************************************************************************/ #pragma endregion -#ifndef _HOOK_H_ -#define _HOOK_H_ +#pragma once #ifndef NO_RCT2 @@ -33,16 +32,6 @@ enum { typedef uint8 (hook_function)(registers *regs); -#ifdef __cplusplus -extern "C" { -#endif - void addhook(uintptr_t address, hook_function *function); -#ifdef __cplusplus -} -#endif - -#endif - #endif diff --git a/test/testpaint/PaintIntercept.cpp b/test/testpaint/PaintIntercept.cpp index f5cee15263..c497470460 100644 --- a/test/testpaint/PaintIntercept.cpp +++ b/test/testpaint/PaintIntercept.cpp @@ -305,8 +305,6 @@ namespace PaintIntercept { } }; - -extern "C" { bool wooden_a_supports_paint_setup(paint_session * session, int supportType, int special, int height, uint32 imageColourFlags, bool *underground) { return PaintIntercept::PaintWoodenSupports(SUPPORTS_WOOD_A, supportType, special, height, imageColourFlags, underground, gPaintSession.WoodenSupportsPrependTo); } @@ -390,5 +388,3 @@ paint_struct *sub_98199C( bool paint_attach_to_previous_ps(paint_session * session, uint32 image_id, uint16 x, uint16 y) { return false; } - -} diff --git a/test/testpaint/SegmentSupportHeightCall.hpp b/test/testpaint/SegmentSupportHeightCall.hpp index bd73eab37f..7dc7a2382d 100644 --- a/test/testpaint/SegmentSupportHeightCall.hpp +++ b/test/testpaint/SegmentSupportHeightCall.hpp @@ -19,10 +19,7 @@ #include #include - -extern "C" { - #include -} +#include struct SegmentSupportCall { diff --git a/test/testpaint/SideTunnelCall.hpp b/test/testpaint/SideTunnelCall.hpp index d831dd6485..657c5b4315 100644 --- a/test/testpaint/SideTunnelCall.hpp +++ b/test/testpaint/SideTunnelCall.hpp @@ -17,10 +17,7 @@ #pragma once #include - -extern "C" { #include -} enum { TUNNELCALL_SKIPPED, diff --git a/test/testpaint/TestPaint.cpp b/test/testpaint/TestPaint.cpp index f2dd716572..b386a38675 100644 --- a/test/testpaint/TestPaint.cpp +++ b/test/testpaint/TestPaint.cpp @@ -127,23 +127,23 @@ namespace TestPaint static bool _ignoredAll; static std::vector _ignoredEntries; - static void testClearIgnore() + void testClearIgnore() { _ignoredAll = false; _ignoredEntries.clear(); } - static void testIgnore(uint8 direction, uint8 trackSequence) + void testIgnore(uint8 direction, uint8 trackSequence) { _ignoredEntries.push_back({ direction, trackSequence }); } - static void testIgnoreAll() + void testIgnoreAll() { _ignoredAll = true; } - static bool testIsIgnored(uint8 direction, uint8 trackSequence) + bool testIsIgnored(uint8 direction, uint8 trackSequence) { if (_ignoredAll) return true; for (const IgnoredEntry &entry : _ignoredEntries) @@ -158,25 +158,22 @@ namespace TestPaint } } -extern "C" +void testpaint_clear_ignore() { - void testpaint_clear_ignore() - { - TestPaint::testClearIgnore(); - } - - void testpaint_ignore(uint8 direction, uint8 trackSequence) - { - TestPaint::testIgnore(direction, trackSequence); - } - - void testpaint_ignore_all() - { - TestPaint::testIgnoreAll(); - } - - bool testpaint_is_ignored(uint8 direction, uint8 trackSequence) - { - return TestPaint::testIsIgnored(direction, trackSequence); - } + TestPaint::testClearIgnore(); +} + +void testpaint_ignore(uint8 direction, uint8 trackSequence) +{ + TestPaint::testIgnore(direction, trackSequence); +} + +void testpaint_ignore_all() +{ + TestPaint::testIgnoreAll(); +} + +bool testpaint_is_ignored(uint8 direction, uint8 trackSequence) +{ + return TestPaint::testIsIgnored(direction, trackSequence); } diff --git a/test/testpaint/TestPaint.hpp b/test/testpaint/TestPaint.hpp index 4d642da4c2..ddbc46fe3f 100644 --- a/test/testpaint/TestPaint.hpp +++ b/test/testpaint/TestPaint.hpp @@ -17,17 +17,11 @@ #pragma once #include - #include - -extern "C" -{ - #include - #include - #include - #include -} - +#include +#include +#include +#include #include "Addresses.h" #define gRideEntries RCT2_ADDRESS(0x009ACFA4, rct_ride_entry*) @@ -77,6 +71,11 @@ namespace TestPaint void ResetEnvironment(); void ResetTunnels(); void ResetSupportHeights(); + + void testClearIgnore(); + void testIgnore(uint8 direction, uint8 trackSequence); + void testIgnoreAll(); + bool testIsIgnored(uint8 direction, uint8 trackSequence); } enum Verbosity { @@ -84,7 +83,4 @@ enum Verbosity { NORMAL, }; -extern "C" -{ int generatePaintCode(uint8 rideType); -} diff --git a/test/testpaint/TestTrack.cpp b/test/testpaint/TestTrack.cpp index e161948e1b..4696a9dca9 100644 --- a/test/testpaint/TestTrack.cpp +++ b/test/testpaint/TestTrack.cpp @@ -367,13 +367,13 @@ static uint8 TestTrackElementPaintCalls(uint8 rideType, uint8 trackType, uint8 t oldCalls.insert(oldCalls.begin(), callBuffer, callBuffer + callCount); PaintIntercept::ClearCalls(); - testpaint_clear_ignore(); + TestPaint::testClearIgnore(); TestPaint::ResetSupportHeights(); gPaintSession.WoodenSupportsPrependTo = nullptr; CallNew(rideType, trackType, direction, trackSequence, height, &tileElement); - if (testpaint_is_ignored(direction, trackSequence)) { + if (TestPaint::testIsIgnored(direction, trackSequence)) { *error += String::Format("[ IGNORED ] %s\n", caseName.c_str()); continue; } @@ -464,9 +464,9 @@ static uint8 TestTrackElementSegmentSupportHeight(uint8 rideType, uint8 trackTyp for (int direction = 0; direction < 4; direction++) { TestPaint::ResetSupportHeights(); - testpaint_clear_ignore(); + TestPaint::testClearIgnore(); CallNew(rideType, trackType, direction, trackSequence, height, &tileElement); - if (testpaint_is_ignored(direction, trackSequence)) { + if (TestPaint::testIsIgnored(direction, trackSequence)) { continue; } @@ -548,9 +548,9 @@ static uint8 TestTrackElementGeneralSupportHeight(uint8 rideType, uint8 trackTyp for (int direction = 0; direction < 4; direction++) { TestPaint::ResetSupportHeights(); - testpaint_clear_ignore(); + TestPaint::testClearIgnore(); CallNew(rideType, trackType, direction, trackSequence, height, &tileElement); - if (testpaint_is_ignored(direction, trackSequence)) { + if (TestPaint::testIsIgnored(direction, trackSequence)) { continue; } @@ -641,7 +641,7 @@ static uint8 TestTrackElementSideTunnels(uint8 rideType, uint8 trackType, uint8 for (int direction = 0; direction < 4; direction++) { TestPaint::ResetTunnels(); - testpaint_clear_ignore(); + TestPaint::testClearIgnore(); for (sint8 offset = -8; offset <= 8; offset += 8) { // TODO: move tunnel pushing to interface so we don't have to check the output 3 times @@ -748,12 +748,12 @@ static uint8 TestTrackElementVerticalTunnels(uint8 rideType, uint8 trackType, ui for (int direction = 0; direction < 4; direction++) { - testpaint_clear_ignore(); + TestPaint::testClearIgnore(); testPaintVerticalTunnelHeight = 0; CallNew(rideType, trackType, direction, trackSequence, height, &tileElement); - if (testpaint_is_ignored(direction, trackSequence)) { + if (TestPaint::testIsIgnored(direction, trackSequence)) { continue; } diff --git a/test/testpaint/generate.cpp b/test/testpaint/generate.cpp index 1d1e0dfdd9..2badf94d1f 100644 --- a/test/testpaint/generate.cpp +++ b/test/testpaint/generate.cpp @@ -1098,16 +1098,14 @@ private: } }; -extern "C" +int generatePaintCode(uint8 rideType) { - int generatePaintCode(uint8 rideType) + if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) { - if (ride_type_has_flag(rideType, RIDE_TYPE_FLAG_FLAT_RIDE)) - { - fprintf(stderr, "Flat rides not supported.\n"); - } - - auto pcg = PaintCodeGenerator(); - return pcg.Generate(rideType); + fprintf(stderr, "Flat rides not supported.\n"); } + + auto pcg = PaintCodeGenerator(); + return pcg.Generate(rideType); } +