Skip to content

Commit

Permalink
v2.0.3: fix new track elements copy, paste, mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
Sadret committed Jul 5, 2023
1 parent c269e88 commit eb55c22
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 201 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.0.3 (2023-07-05)
------------------------------------------------------------------------
- Fix: [#39] New track elements now copy and mirror properly.
- Fix: Eighth turns now mirror properly.

2.0.2 (2023-06-24)
------------------------------------------------------------------------
- Fix: [#38] Footpath addition object is off by one.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openrct2-scenery-manager",
"version": "2.0.2",
"version": "2.0.3",
"description": "OpenRCT2 Scenery Manager Plug-In",
"author": "Sadret",
"license": "GPL-3.0",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ An OpenRCT2 plug-in to copy and paste scenery, with many more features.
## Installation

1. Make sure that your OpenRCT2 version is up-to-date. You need at least version `0.4.0` or a recent development version.
2. Go to the [releases](#https://github.com/Sadret/openrct2-scenery-manager/releases) page and download the `scenery-manager-2.0.2.js` file from the latest release. Save it in the `plugin` subfolder of your OpenRCT2 user directory.\
2. Go to the [releases](#https://github.com/Sadret/openrct2-scenery-manager/releases) page and download the `scenery-manager-2.0.3.js` file from the latest release. Save it in the `plugin` subfolder of your OpenRCT2 user directory.\
On Windows, this is usually at `C:Users\{User}\Documents\OpenRCT2\plugin`.\
If you had a previous version of the Scenery Manager installed, make sure to delete its file from the `plugin` folder.
3. Start OpenRCT2 and open a scenario. If this is the first time that you use this plug-in, it should show a welcome message.
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import MainWindow from "./window/MainWindow";

registerPlugin({
name: "scenery-manager",
version: "2.0.2",
version: "2.0.3",
authors: ["Sadret"],
type: "local",
licence: "GPL-3.0",
Expand Down
206 changes: 9 additions & 197 deletions src/template/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ export function rotate(element: TrackData, rotation: number): TrackData {
}

export function mirror(element: TrackData): TrackData {
const mirroredTrackType = mirrorMap[element.trackType];
const trackSegment = context.getTrackSegment(element.trackType);
const directionOffset = Number(Boolean(trackSegment ?.beginDirection || 0));
const mirroredTrackType = (trackSegment ?.mirrorSegment) || element.trackType;

return {
...element,
direction: Directions.mirror(element.direction),
direction: Directions.mirror(element.direction + directionOffset),
trackType: mirroredTrackType === undefined ? element.trackType : mirroredTrackType,
}
}
Expand Down Expand Up @@ -65,13 +68,15 @@ export function getPlaceActionData(
): PlaceActionData[] {
if (element.sequence !== 0)
return [];
const offset = heightOffset[element.trackType];

const zOffset = context.getTrackSegment(element.trackType) ?.elements[0].z || 0;

return [{
type: "trackplace",
args: {
...element,
...coords,
z: element.baseZ - (offset === undefined ? 0 : offset),
z: element.baseZ - zOffset,
flags: flags,
brakeSpeed: element.brakeBoosterSpeed || 0,
colour: element.colourScheme || 0,
Expand Down Expand Up @@ -102,196 +107,3 @@ export function getRemoveActionData(
},
}];
}

const mirrorMap: { [key: number]: number } = {
16: 17,
17: 16,
18: 19,
19: 18,
20: 21,
21: 20,
22: 23,
23: 22,
24: 25,
25: 24,
26: 27,
27: 26,
28: 29,
29: 28,
30: 31,
31: 30,
32: 33,
33: 32,
34: 35,
35: 34,
36: 37,
37: 36,
38: 39,
39: 38,
40: 41,
41: 40,
42: 43,
43: 42,
44: 45,
45: 44,
46: 47,
47: 46,
48: 49,
49: 48,
50: 51,
51: 50,
52: 53,
53: 52,
54: 55,
55: 54,
58: 59,
59: 58,
60: 61,
61: 60,
81: 82,
82: 81,
83: 84,
84: 83,
85: 86,
86: 85,
87: 88,
88: 87,
89: 90,
90: 89,
91: 92,
92: 91,
93: 94,
94: 93,
95: 96,
96: 95,
97: 98,
98: 97,
102: 103,
103: 102,
104: 105,
105: 104,
106: 107,
107: 106,
108: 109,
109: 108,
110: 111,
111: 110,
115: 116,
116: 115,
133: 134,
134: 133,
135: 136,
136: 135,
137: 138,
138: 137,
139: 140,
140: 139,
158: 159,
159: 158,
160: 161,
161: 160,
162: 163,
163: 162,
164: 165,
165: 164,
166: 167,
167: 166,
168: 169,
169: 168,
170: 171,
171: 170,
174: 175,
175: 174,
176: 177,
177: 176,
178: 179,
179: 178,
180: 181,
181: 180,
183: 184,
184: 183,
185: 186,
186: 185,
187: 188,
188: 187,
189: 190,
190: 189,
193: 194,
194: 193,
195: 196,
196: 195,
199: 200,
200: 199,
204: 205,
205: 204,
209: 210,
210: 209,
211: 212,
212: 211,
217: 218,
218: 217,
219: 220,
220: 219,
221: 222,
222: 221,
223: 224,
224: 223,
225: 226,
226: 225,
227: 228,
228: 227,
229: 230,
230: 229,
231: 232,
232: 231,
233: 234,
234: 233,
235: 236,
236: 235,
237: 238,
238: 237,
239: 240,
240: 239,
241: 242,
242: 241,
243: 244,
244: 243,
245: 246,
246: 245,
247: 248,
248: 247,
249: 250,
250: 249,
251: 252,
252: 251,
}

// src/ride/TrackData.cpp TrackBlocksXXX[0][3]
const heightOffset: { [key: number]: number } = {
36: 48,
37: 48,
48: 16,
49: 16,
57: -32,
60: -32,
61: -32,
89: 8,
90: 8,
93: 8,
94: 8,
121: 40,
122: 80,
176: -32,
177: -32,
180: 16,
181: 16,
185: -32,
186: -32,
208: -32,
219: 16,
220: 16,
223: 48,
224: 48,
254: -32,
255: 32,
}
3 changes: 2 additions & 1 deletion src/window/tabs/Research.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export default new GUI.Tab({
padding: 8,
margin: GUI.Margin.uniform(8),
}).add(
new GUI.Label({ text: "Version: 2.0.2 (2023-06-24)", }),
new GUI.Label({ text: "Version: 2.0.3 (2023-07-05)", }),
new GUI.GroupBox({ text: "Latest changes" }).add(
new GUI.Label({ text: "- Fix copy & paste for new track elements." }),
new GUI.Label({ text: "- Fix footpath addition place in safe mode." }),
new GUI.Label({ text: "- Tertiary colours for large scenery." }),
new GUI.Space(2),
Expand Down

0 comments on commit eb55c22

Please sign in to comment.