1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Generate set segment support height and other fixes

This commit is contained in:
Ted John
2016-10-07 23:52:01 +01:00
parent a0f041b43a
commit ec082b4ac8
6 changed files with 167 additions and 65 deletions

View File

@@ -38,7 +38,8 @@ enum {
SPR_WILD_MOUSE_ROTATION_CONTROL_TOGGLE_NW_SE = 16909,
SPR_WILD_MOUSE_FLAT_CHAIN_SW_NE = 16910,
SPR_WILD_MOUSE_FLAT_CHAIN_NW_SE = 16911,
SPR_WILD_MOUSE_FLAT_CHAIN_NE_SW = 16912,
SPR_WILD_MOUSE_FLAT_CHAIN_SE_NW = 16913,
SPR_WILD_MOUSE_FLAT_TO_25_DEG_SW_NE = 16914,
SPR_WILD_MOUSE_FLAT_TO_25_DEG_NW_SE = 16915,
SPR_WILD_MOUSE_FLAT_TO_25_DEG_NE_SW = 16916,
@@ -172,8 +173,8 @@ static void wild_mouse_track_flat(uint8 rideIndex, uint8 trackSequence, uint8 di
static const uint32 imageIds[4][2] = {
{ SPR_WILD_MOUSE_FLAT_SW_NE, SPR_WILD_MOUSE_FLAT_CHAIN_SW_NE },
{ SPR_WILD_MOUSE_FLAT_NW_SE, SPR_WILD_MOUSE_FLAT_CHAIN_NW_SE },
{ SPR_WILD_MOUSE_FLAT_SW_NE, SPR_WILD_MOUSE_FLAT_CHAIN_SW_NE },
{ SPR_WILD_MOUSE_FLAT_NW_SE, SPR_WILD_MOUSE_FLAT_CHAIN_NW_SE },
{ SPR_WILD_MOUSE_FLAT_SW_NE, SPR_WILD_MOUSE_FLAT_CHAIN_NE_SW },
{ SPR_WILD_MOUSE_FLAT_NW_SE, SPR_WILD_MOUSE_FLAT_CHAIN_SE_NW },
};

View File

@@ -18,10 +18,11 @@
#include <string>
#include <vector>
#include "intercept.h"
extern "C"
{
#include "data.h"
#include "intercept.h"
#include "../../src/interface/viewport.h"
#include "../../src/rct2.h"
#include "../../src/ride/ride.h"
@@ -77,15 +78,14 @@ private:
void GenerateTrackFunction(int trackType)
{
std::string trackName = TrackNames[trackType];
int numSequences = getTrackSequenceCount(_rideType, trackType);
int height = 48;
WriteLine(0, "static void " + _rideName + "_track_" + trackName + "(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement)");
WriteLine(0, "static void " + GetTrackFunctionName(trackType) + "(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement)");
WriteLine(0, "{");
std::vector<Intercept2::SegmentSupportCall> segmentSupportCalls[4];
support_height generalSupports[4] = { 0 };
for (int direction = 0; direction < 4; direction++) {
int trackSequence = 0;
@@ -97,19 +97,74 @@ private:
CallOriginal(trackType, direction, trackSequence, height, &mapElement);
segmentSupportCalls[direction] = Intercept2::getSegmentCalls(gSupportSegments, direction);
generalSupports[direction] = gSupport;
generalSupports[direction].height -= height;
}
GenerateSegmentSupportCall(segmentSupportCalls);
GenerateGeneralSupportCall(generalSupports);
WriteLine(0, "}");
}
void GenerateSegmentSupportCall(std::vector<Intercept2::SegmentSupportCall> segmentSupportCalls[4])
{
for (size_t i = 0; i < segmentSupportCalls[0].size(); i++)
{
auto ssh = segmentSupportCalls[0][i];
std::string szCall = "paint_util_set_segment_support_height(";
if (ssh.segments == SEGMENTS_ALL)
{
szCall += "SEGMENTS_ALL";
}
else
{
szCall += "paint_util_rotate_segments(";
szCall += GetORedSegments(ssh.segments);
szCall += ", direction)";
}
szCall += ", ";
if (ssh.height == 0xFFFF)
{
szCall += "0xFFFF";
szCall += StringFormat(", 0);", ssh.slope);
}
else
{
szCall += std::to_string(ssh.height);
szCall += StringFormat(", 0x%02X);", ssh.slope);
}
WriteLine(1, szCall);
}
}
void GenerateGeneralSupportCall(support_height generalSupports[4])
{
if (AllMatch(generalSupports, 4))
{
WriteLine(1, "paint_util_set_general_support_height(height + %d, 0x%02X);", generalSupports[0].height - height, generalSupports[0].slope);
WriteLine(1, "paint_util_set_general_support_height(height + %d, 0x%02X);", generalSupports[0].height, generalSupports[0].slope);
}
else
{
WriteLine(1, "#error Unsupported: different directional general supports");
}
}
WriteLine(0, "}");
std::string GetORedSegments(int segments)
{
std::string s;
int segmentsPrinted = 0;
for (int i = 0; i < 9; i++) {
if (segments & segment_offsets[i]) {
if (segmentsPrinted > 0) {
s += " | ";
}
s += StringFormat("SEGMENT_%02X", 0xB4 + 4 * i);
segmentsPrinted++;
}
}
return s;
}
template<typename T>
@@ -127,16 +182,11 @@ private:
void CallOriginal(int trackType, int direction, int trackSequence, int height, rct_map_element *mapElement)
{
constexpr uint32 DEFAULT_SCHEME_TRACK = COLOUR_GREY << 19 | COLOUR_WHITE << 24 | 0xA0000000;
constexpr uint32 DEFAULT_SCHEME_SUPPORTS = COLOUR_LIGHT_BLUE << 19 | COLOUR_ICY_BLUE << 24 | 0xA0000000;
constexpr uint32 DEFAULT_SCHEME_MISC = COLOUR_DARK_PURPLE << 19 | COLOUR_LIGHT_PURPLE << 24 | 0xA0000000;
constexpr uint32 DEFAULT_SCHEME_3 = COLOUR_BRIGHT_PURPLE << 19 | COLOUR_DARK_BLUE << 24 | 0xA0000000;
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;
gTrackColours[SCHEME_TRACK] = Intercept2::DEFAULT_SCHEME_TRACK;
gTrackColours[SCHEME_SUPPORTS] = Intercept2::DEFAULT_SCHEME_SUPPORTS;
gTrackColours[SCHEME_MISC] = Intercept2::DEFAULT_SCHEME_MISC;
gTrackColours[SCHEME_3] = Intercept2::DEFAULT_SCHEME_3;
rct_drawpixelinfo dpi = { 0 };
dpi.zoom_level = 1;
@@ -186,7 +236,7 @@ private:
if (IsTrackTypeSupported(trackType))
{
WriteLine(1, "case " + std::string(TrackElemNames[trackType]) + ":");
WriteLine(2, "return NULL;");
WriteLine(2, "return %s;", GetTrackFunctionName(trackType).c_str());
}
}
WriteLine(1, "}");
@@ -194,6 +244,12 @@ private:
WriteLine(0, "}");
}
std::string GetTrackFunctionName(int trackType)
{
std::string trackName = TrackNames[trackType];
return _rideName + "_track_" + trackName;
}
bool IsTrackTypeSupported(int trackType)
{
if (trackType == TRACK_ELEM_BEGIN_STATION ||
@@ -235,6 +291,18 @@ private:
fprintf(_file, s.c_str());
fprintf(_file, "\n");
}
static std::string StringFormat(const char * format, ...)
{
va_list args;
char buffer[512];
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
return std::string(buffer);
}
};
extern "C"

View File

@@ -19,19 +19,77 @@
#include "../../src/common.h"
#ifdef __cplusplus
extern "C"
{
#endif
#include "../../src/interface/colour.h"
#include "../../src/paint/paint.h"
#ifdef __cplusplus
}
#endif
#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);
bool testSupportSegments(uint8 rideType, uint8 trackType);
bool testTunnels(uint8 rideType, uint8 trackType);
bool testVerticalTunnels(uint8 rideType, uint8 trackType);
#ifdef __cplusplus
extern "C"
{
#endif
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);
bool testSupportSegments(uint8 rideType, uint8 trackType);
bool testTunnels(uint8 rideType, uint8 trackType);
bool testVerticalTunnels(uint8 rideType, uint8 trackType);
int generatePaintCode(uint8 rideType);
int generatePaintCode(uint8 rideType);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
#include <vector>
namespace Intercept2
{
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
{
uint16 segments;
sint32 height;
sint16 slope;
};
struct SupportCall
{
sint32 height;
sint16 slope;
};
enum {
TUNNELCALL_SKIPPED,
TUNNELCALL_NONE,
TUNNELCALL_CALL,
};
struct TunnelCall {
uint8 call;
sint16 offset;
uint8 type;
};
std::vector<SegmentSupportCall> getSegmentCalls(support_height supports[9], uint8 rotation);
}
#endif
#endif // #endif _TEST_PAINT_INTERCEPT_H_

View File

@@ -17,8 +17,9 @@
#include <vector>
#include <algorithm>
#include "intercept.h"
extern "C" {
#include "intercept.h"
#include "../../src/paint/paint.h"
#include "../../src/paint/supports.h"
#include "../../src/ride/track_data.h"
@@ -28,37 +29,6 @@ extern "C" {
namespace Intercept2
{
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
{
uint16 segments;
sint32 height;
sint16 slope;
};
struct SupportCall
{
sint32 height;
sint16 slope;
};
enum {
TUNNELCALL_SKIPPED,
TUNNELCALL_NONE,
TUNNELCALL_CALL,
};
struct TunnelCall {
uint8 call;
sint16 offset;
uint8 type;
};
static bool SortSegmentSupportCalls(SegmentSupportCall lhs, SegmentSupportCall rhs)
{
if (lhs.height != rhs.height) {
@@ -72,7 +42,7 @@ namespace Intercept2
return lhs.segments < rhs.segments;
}
static std::vector<SegmentSupportCall> getSegmentCalls(support_height supports[9], uint8 rotation)
std::vector<SegmentSupportCall> getSegmentCalls(support_height supports[9], uint8 rotation)
{
uint16 positionsRemaining = SEGMENTS_ALL;

View File

@@ -23,9 +23,10 @@
#include <sys/mman.h>
#endif // defined(__unix__)
#include "intercept.h"
extern "C" {
#include "data.h"
#include "intercept.h"
#include "../../src/rct2.h"
#include "../../src/ride/ride.h"
#include "../../src/ride/ride_data.h"
@@ -377,7 +378,11 @@ int main(int argc, char *argv[]) {
if (specificRideType > 90) {
fprintf(stderr, "No ride or invalid ride specified.\n");
return 1;
}
}
openrct2_setup_rct2_segment();
initHooks();
return generatePaintCode(specificRideType);
}

View File

@@ -4,7 +4,7 @@
<LocalDebuggerCommand>$(TargetDir)\openrct2.exe</LocalDebuggerCommand>
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>--ride-type 88 --generate</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>--ride-type 54 --generate</LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup>
<ShowAllFiles>false</ShowAllFiles>