OpenRCT2/test/testpaint/intercept_2.cpp

165 lines
4.3 KiB
C++
Raw Normal View History

#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 <vector>
2016-09-09 21:49:53 +02:00
#include <algorithm>
#include "intercept.h"
2016-10-17 00:13:46 +02:00
#include "GeneralSupportHeightCall.hpp"
#include "Printer.hpp"
#include "SegmentSupportHeightCall.hpp"
2016-10-16 21:41:20 +02:00
#include "Utils.hpp"
extern "C" {
#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
{
2016-10-17 10:21:53 +02:00
void ResetEnvironment() {
2016-10-16 15:49:04 +02:00
gPaintInteractionType = VIEWPORT_INTERACTION_ITEM_RIDE;
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;
unk_140E9A8 = &dpi;
rct_ride ride = {0};
ride.entrance_style = RIDE_ENTRANCE_STYLE_PLAIN;
rct_ride_entry rideEntry = {0};
rct_ride_entry_vehicle vehicleEntry { 0 };
vehicleEntry.base_image_id = 0x70000;
rideEntry.vehicles[0] = vehicleEntry;
gRideList[0] = ride;
gRideEntries[0] = &rideEntry;
2016-10-16 16:06:18 +02:00
g141E9DB = G141E9DB_FLAG_1 | G141E9DB_FLAG_2;
}
2016-10-17 10:21:53 +02:00
void ResetTunnels() {
2016-10-16 16:06:18 +02:00
gLeftTunnelCount = 0;
gRightTunnelCount = 0;
for (int i = 0; i < TUNNEL_MAX_COUNT; i++) {
2016-10-16 19:10:55 +02:00
gLeftTunnels[i].height = 0;
gLeftTunnels[i].type = 0;
gRightTunnels[i].height = 0;
gRightTunnels[i].type = 0;
2016-10-16 16:06:18 +02:00
}
2016-10-16 19:10:55 +02:00
gLeftTunnels[0].height = 0xFF;
gLeftTunnels[0].type = 0xFF;
gRightTunnels[0].height = 0xFF;
gRightTunnels[0].type = 0xFF;
2016-10-16 16:06:18 +02:00
}
2016-10-17 10:21:53 +02:00
void ResetSupportHeights() {
2016-10-16 15:49:04 +02:00
for (int s = 0; s < 9; ++s)
{
gSupportSegments[s].height = 0;
gSupportSegments[s].slope = 0xFF;
}
gSupport.height = 0;
gSupport.slope = 0xFF;
}
2016-09-18 17:46:26 +02:00
struct IgnoredEntry
{
uint8 Direction;
uint8 TrackSequence;
};
static bool _ignoredAll;
static std::vector<IgnoredEntry> _ignoredEntries;
static void testClearIgnore()
{
_ignoredAll = false;
_ignoredEntries.clear();
}
static void testIgnore(uint8 direction, uint8 trackSequence)
{
_ignoredEntries.push_back({ direction, trackSequence });
}
static void testIgnoreAll()
{
_ignoredAll = true;
}
static bool testIsIgnored(uint8 direction, uint8 trackSequence)
{
if (_ignoredAll) return true;
for (const IgnoredEntry &entry : _ignoredEntries)
{
if (entry.Direction == direction &&
entry.TrackSequence == trackSequence)
{
return true;
}
}
return false;
}
2016-09-09 21:37:11 +02:00
}
extern "C"
{
2016-09-18 17:46:26 +02:00
void testpaint_clear_ignore()
{
Intercept2::testClearIgnore();
}
void testpaint_ignore(uint8 direction, uint8 trackSequence)
{
Intercept2::testIgnore(direction, trackSequence);
}
void testpaint_ignore_all()
{
Intercept2::testIgnoreAll();
}
bool testpaint_is_ignored(uint8 direction, uint8 trackSequence)
{
return Intercept2::testIsIgnored(direction, trackSequence);
}
2016-10-16 15:49:04 +02:00
void intercept_reset_environment() {
Intercept2::ResetEnvironment();
}
2016-10-16 16:06:18 +02:00
void intercept_reset_segment_heights() {
2016-10-17 10:21:53 +02:00
Intercept2::ResetSupportHeights();
2016-10-16 16:06:18 +02:00
}
void intercept_reset_tunnels() {
Intercept2::ResetTunnels();
}
}