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

Added track_data refactored track_place to use track_data

This commit is contained in:
Duncan Frost
2015-02-07 18:38:48 +00:00
parent 5fb09400e7
commit edfbd80747
5 changed files with 335 additions and 12 deletions

View File

@@ -68,6 +68,7 @@
<ClCompile Include="..\src\ride\ride_ratings.c" />
<ClCompile Include="..\src\ride\station.c" />
<ClCompile Include="..\src\ride\track.c" />
<ClCompile Include="..\src\ride\track_data.c" />
<ClCompile Include="..\src\ride\vehicle.c" />
<ClCompile Include="..\src\scenario.c" />
<ClCompile Include="..\src\scenario_list.c" />
@@ -183,6 +184,7 @@
<ClInclude Include="..\src\ride\ride_ratings.h" />
<ClInclude Include="..\src\ride\station.h" />
<ClInclude Include="..\src\ride\track.h" />
<ClInclude Include="..\src\ride\track_data.h" />
<ClInclude Include="..\src\ride\vehicle.h" />
<ClInclude Include="..\src\scenario.h" />
<ClInclude Include="..\src\sprites.h" />

View File

@@ -332,7 +332,6 @@
</ClCompile>
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\cmdline.c">
<Filter>Source</Filter>
</ClCompile>
@@ -344,7 +343,7 @@
<ClCompile Include="..\src\world\fountain.c">
<Filter>Source\World</Filter>
</ClCompile>
<ClCompile Include="..\lib\libspeex\resample.c;..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\world\banner.c">
<Filter>Source\World</Filter>
</ClCompile>
@@ -423,6 +422,9 @@
<Filter>Source\Windows</Filter>
</ClCompile>
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\ride\track_data.c">
<Filter>Source\Ride</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\management\award.h">
@@ -614,5 +616,8 @@
<ClInclude Include="..\src\rct1.h">
<Filter>Source</Filter>
</ClInclude>
<ClInclude Include="..\src\ride\track_data.h">
<Filter>Source\Ride</Filter>
</ClInclude>
</ItemGroup>
</Project>

280
src/ride/track_data.c Normal file
View File

@@ -0,0 +1,280 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* This file is part of 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "track_data.h"
const rct_track_coordinates TrackCoordinates[256] = {
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 16, 0, 0 },
{ 0, 0, 0, 64, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 32, 0, 0 },
{ 0, 0, 0, 32, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 16, 0, 0, 0 },
{ 0, 0, 64, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 32, 0, 0, 0 },
{ 0, 0, 32, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 3, 0, 0, -64, -64 },
{ 0, 1, 0, 0, -64, 64 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 3, 0, 0, -64, -64 },
{ 0, 1, 0, 0, -64, 64 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 3, 0, 64, -64, -64 },
{ 0, 1, 0, 64, -64, 64 },
{ 0, 3, 64, 0, -64, -64 },
{ 0, 1, 64, 0, -64, 64 },
{ 0, 0, 0, 0, -64, -32 },
{ 0, 0, 0, 0, -64, 32 },
{ 0, 0, 0, 0, -32, -32 },
{ 0, 0, 0, 0, -32, 32 },
{ 0, 3, 0, 0, -32, -32 },
{ 0, 1, 0, 0, -32, 32 },
{ 0, 3, 0, 0, -32, -32 },
{ 0, 1, 0, 0, -32, 32 },
{ 0, 3, 0, 32, -32, -32 },
{ 0, 1, 0, 32, -32, 32 },
{ 0, 3, 32, 0, -32, -32 },
{ 0, 1, 32, 0, -32, 32 },
{ 0, 3, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 0, 0, 16, -64, 0 },
{ 0, 0, 0, 16, -64, 0 },
{ 0, 0, 0, -16, -64, 0 },
{ 0, 0, 0, -16, -64, 0 },
{ 0, 2, 0, 152, -32, 0 },
{ 0, 2, 0, -152, 32, 0 },
{ 0, 3, 0, 80, -32, -32 },
{ 0, 1, 0, 80, -32, 32 },
{ 0, 3, 0, -80, -32, -32 },
{ 0, 1, 0, -80, -32, 32 },
{ 0, 0, 0, 24, 0, 0 },
{ 0, 0, 0, 24, 0, 0 },
{ 0, 0, 24, 0, 0, 0 },
{ 0, 0, 24, 0, 0, 0 },
{ 0, 0, 0, 96, 32, 0 },
{ 0, 0, 0, 32, 32, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 16, 0, 0 },
{ 0, 0, 0, 64, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 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96, 0 },
{ 0, 0, 0, 88, -96, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 88, 0, -96, 0 },
{ 0, 0, 88, 0, -96, 0 },
{ 0, 0, 0, -96, -96, 0 },
{ 0, 0, 0, 240, -160, 0 },
{ 0, 0, 0, 80, 32, 0 },
{ 0, 0, 0, 32, 32, 0 },
{ 0, 0, 32, 0, 32, 0 },
{ 0, 0, 0, 56, 32, 0 },
{ 0, 0, 56, 0, 0, 0 },
{ 0, 0, 0, 56, 0, 0 },
{ 0, 0, 56, 0, 32, 0 },
{ 0, 0, 24, 0, 0, 0 },
{ 0, 7, 0, 0, -64, -32 },
{ 0, 4, 0, 0, -64, 32 },
{ 4, 0, 0, 0, -64, 32 },
{ 4, 1, 0, 0, -32, 64 },
{ 0, 7, 0, 0, -64, -32 },
{ 0, 4, 0, 0, -64, 32 },
{ 4, 0, 0, 0, -64, 32 },
{ 4, 1, 0, 0, -32, 64 },
{ 4, 4, 0, 0, -32, 32 },
{ 4, 4, 0, 16, -32, 32 },
{ 4, 4, 0, 64, -32, 32 },
{ 4, 4, 0, 8, -32, 32 },
{ 4, 4, 0, 32, -32, 32 },
{ 4, 4, 0, 32, -32, 32 },
{ 4, 4, 0, 8, -32, 32 },
{ 4, 4, 16, 0, -32, 32 },
{ 4, 4, 64, 0, -32, 32 },
{ 4, 4, 8, 0, -32, 32 },
{ 4, 4, 32, 0, -32, 32 },
{ 4, 4, 32, 0, -32, 32 },
{ 4, 4, 8, 0, -32, 32 },
{ 4, 4, 0, 24, -32, 32 },
{ 4, 4, 0, 24, -32, 32 },
{ 4, 4, 24, 0, -32, 32 },
{ 4, 4, 24, 0, -32, 32 },
{ 4, 4, 0, 0, -32, 32 },
{ 4, 4, 0, 0, -32, 32 },
{ 4, 4, 0, 0, -32, 32 },
{ 4, 4, 0, 0, -32, 32 },
{ 4, 4, 0, 8, -32, 32 },
{ 4, 4, 0, 8, -32, 32 },
{ 4, 4, 0, 8, -32, 32 },
{ 4, 4, 0, 8, -32, 32 },
{ 4, 4, 8, 0, -32, 32 },
{ 4, 4, 8, 0, -32, 32 },
{ 4, 4, 8, 0, -32, 32 },
{ 4, 4, 8, 0, -32, 32 },
{ 4, 4, 0, 0, -32, 32 },
{ 4, 4, 0, 0, -32, 32 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 32, -64, 0 },
{ 0, 0, 0, 32, -64, 0 },
{ 0, 0, 0, -32, -64, 0 },
{ 0, 0, 0, -32, -64, 0 },
{ 0, 3, 0, 24, -32, -32 },
{ 0, 1, 0, 24, -32, 32 },
{ 0, 3, 24, 0, -32, -32 },
{ 0, 1, 24, 0, -32, 32 },
{ 0, 0, 0, 16, 0, 0 },
{ 0, 2, 0, 280, -64, -32 },
{ 0, 2, 0, 280, -64, 32 },
{ 0, 2, 0, -280, 64, -32 },
{ 0, 2, 0, -280, 64, 32 },
{ 0, 0, 0, -16, -64, 0 },
{ 0, 0, 0, -16, -64, 0 },
{ 0, 0, 0, 16, -64, 0 },
{ 0, 0, 0, 16, -64, 0 },
{ 0, 2, 0, 120, -32, 0 },
{ 0, 2, 0, -120, 32, 0 },
{ 0, 3, 0, 48, -32, -32 },
{ 0, 1, 0, 48, -32, 32 },
{ 0, 3, 0, -48, -32, -32 },
{ 0, 1, 0, -48, -32, 32 },
{ 0, 2, 0, 32, 0, 0 },
{ 0, 2, 0, -32, 0, 0 },
{ 0, 0, 0, 0, -160, 0 },
{ 0, 0, 0, 0, -160, 0 },
{ 0, 0, 0, 0, -32, 0 },
{ 0, 0, 0, 0, -32, 0 },
{ 0, 0, 0, 0, -32, 0 },
{ 0, 1, 0, 0, -32, 32 },
{ 0, 3, 0, 0, -32, -32 },
{ 0, 2, 0, -96, -96, 0 },
{ 0, 2, 0, 128, 64, 0 },
{ 0, 2, 0, -128, -96, 0 },
{ 0, 3, 0, 16, -32, -32 },
{ 0, 1, 0, 16, -32, 32 },
{ 0, 0, 0, 0, -64, 0 },
{ 0, 0, 0, 0, -64, 0 },
{ 0, 0, 0, 0, -32, 0 },
{ 0, 0, 80, 0, 32, 0 },
{ 0, 0, 240, 0, -160, 0 },
{ 0, 0, 0, 0, 0, 0 },
{ 0, 3, 0, 32, -32, -32 },
{ 0, 1, 0, 32, -32, 32 },
{ 0, 3, 32, 0, -32, -32 },
{ 0, 1, 32, 0, -32, 32 },
{ 0, 3, 0, 64, -64, -64 },
{ 0, 1, 0, 64, -64, 64 },
{ 0, 3, 64, 0, -64, -64 },
{ 0, 1, 64, 0, -64, 64 },
{ 0, 0, 0, 16, 0, 0 },
{ 0, 0, 0, 16, 0, 0 },
{ 0, 0, 0, 16, 0, 0 },
{ 0, 0, 0, 16, 0, 0 },
{ 0, 0, 16, 0, 0, 0 },
{ 0, 0, 16, 0, 0, 0 },
{ 0, 0, 16, 0, 0, 0 },
{ 0, 0, 16, 0, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 0, 8, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 0, 8, 0, 0, 0 },
{ 0, 3, 0, 96, 0, 32 },
{ 0, 1, 0, 96, 0, -32 },
{ 0, 3, 96, 0, 0, 32 },
{ 0, 1, 96, 0, 0, -32 },
{ 0, 2, 0, 96, 64, 0 },
{ 0, 2, 0, -128, -96, 0 },
{ 0, 2, 0, 128, 64, 0 }
};

33
src/ride/track_data.h Normal file
View File

@@ -0,0 +1,33 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* This file is part of 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "../common.h"
/* size 0x0A */
typedef struct{
sint8 rotation_negative; // 0x00
sint8 rotation_positive; // 0x01
sint16 z_negative; // 0x02
sint16 z_positive; // 0x04
sint16 x; // 0x06
sint16 y; // 0x08
}rct_track_coordinates;
// 0x009968BB, 0x009968BC, 0x009968BD, 0x009968BF, 0x009968C1, 0x009968C3
extern const rct_track_coordinates TrackCoordinates[256];

View File

@@ -28,6 +28,7 @@
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../ride/track.h"
#include "../ride/track_data.h"
#define TRACK_MINI_PREVIEW_WIDTH 168
#define TRACK_MINI_PREVIEW_HEIGHT 78
@@ -211,28 +212,30 @@ static void window_track_place_draw_mini_preview()
// Change rotation and next position based on track curvature
rotation &= 3;
const rct_track_coordinates* track_coordinate = &TrackCoordinates[trackType];
trackType *= 10;
switch (rotation) {
case 0:
originX += RCT2_GLOBAL(0x009968C1 + trackType, sint16);
originY += RCT2_GLOBAL(0x009968C3 + trackType, sint16);
originX += track_coordinate->x;
originY += track_coordinate->y;
break;
case 1:
originX += RCT2_GLOBAL(0x009968C3 + trackType, sint16);
originY -= RCT2_GLOBAL(0x009968C1 + trackType, sint16);
originX += track_coordinate->y;
originY -= track_coordinate->x;
break;
case 2:
originX -= RCT2_GLOBAL(0x009968C1 + trackType, sint16);
originY -= RCT2_GLOBAL(0x009968C3 + trackType, sint16);
originX -= track_coordinate->x;
originY -= track_coordinate->y;
break;
case 3:
originX -= RCT2_GLOBAL(0x009968C3 + trackType, sint16);
originY += RCT2_GLOBAL(0x009968C1 + trackType, sint16);
originX -= track_coordinate->y;
originY += track_coordinate->x;
break;
}
rotation += RCT2_ADDRESS(0x009968BC, uint8)[trackType] - RCT2_ADDRESS(0x009968BB, uint8)[trackType];
rotation += track_coordinate->rotation_positive - track_coordinate->rotation_negative;
rotation &= 3;
if (RCT2_ADDRESS(0x009968BC, uint8)[trackType] & 4)
if (track_coordinate->rotation_positive & 4)
rotation |= 4;
if (!(rotation & 4)) {
originX += RCT2_GLOBAL(0x00993CCC + (rotation * 4), sint16);