From 43e7eb86238eb3efed961204edb7dc523b408d1d Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Wed, 11 Oct 2017 18:10:27 +0200 Subject: [PATCH 01/11] Add sprites --- resources/g2/track/railway/gravel_nw_se.png | Bin 0 -> 643 bytes resources/g2/track/railway/gravel_sw_ne.png | Bin 0 -> 681 bytes .../g2/track/railway/grooved_end_ne_trans.png | Bin 0 -> 883 bytes .../g2/track/railway/grooved_end_nw_se_trans.png | Bin 0 -> 877 bytes .../g2/track/railway/grooved_end_nw_trans.png | Bin 0 -> 877 bytes .../g2/track/railway/grooved_end_se_trans.png | Bin 0 -> 885 bytes .../g2/track/railway/grooved_end_sw_ne_trans.png | Bin 0 -> 883 bytes .../g2/track/railway/grooved_end_sw_trans.png | Bin 0 -> 885 bytes resources/g2/track/railway/grooved_nw_se.png | Bin 0 -> 935 bytes .../g2/track/railway/grooved_nw_se_trans.png | Bin 0 -> 885 bytes resources/g2/track/railway/grooved_sw_ne.png | Bin 0 -> 958 bytes .../g2/track/railway/grooved_sw_ne_trans.png | Bin 0 -> 888 bytes .../railway/quarter_turn_3_tiles_sw_se_part_3.png | Bin 0 -> 604 bytes 13 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 resources/g2/track/railway/gravel_nw_se.png create mode 100644 resources/g2/track/railway/gravel_sw_ne.png create mode 100644 resources/g2/track/railway/grooved_end_ne_trans.png create mode 100644 resources/g2/track/railway/grooved_end_nw_se_trans.png create mode 100644 resources/g2/track/railway/grooved_end_nw_trans.png create mode 100644 resources/g2/track/railway/grooved_end_se_trans.png create mode 100644 resources/g2/track/railway/grooved_end_sw_ne_trans.png create mode 100644 resources/g2/track/railway/grooved_end_sw_trans.png create mode 100644 resources/g2/track/railway/grooved_nw_se.png create mode 100644 resources/g2/track/railway/grooved_nw_se_trans.png create mode 100644 resources/g2/track/railway/grooved_sw_ne.png create mode 100644 resources/g2/track/railway/grooved_sw_ne_trans.png create mode 100644 resources/g2/track/railway/quarter_turn_3_tiles_sw_se_part_3.png diff --git a/resources/g2/track/railway/gravel_nw_se.png b/resources/g2/track/railway/gravel_nw_se.png new file mode 100644 index 0000000000000000000000000000000000000000..b0bc386bbb98941d96461661d1c6ed81ecf3b34f GIT binary patch literal 643 zcmV-}0(||6P)>Kb8~NlgKvjVgO`_wpI?ht zJC~bJpRccgkqVtG z%fSg`9@`~qeUShRrNI@nvIuIRJEoMt_(a`f)YUWY_I(*Z6zkp+%PE9sO-QdeTq-9MWZuIOPa@?-x dyPuaX{{m8cDwJi&xrqP(002ovPDHLkV1g`JGA{rC literal 0 HcmV?d00001 diff --git a/resources/g2/track/railway/gravel_sw_ne.png b/resources/g2/track/railway/gravel_sw_ne.png new file mode 100644 index 0000000000000000000000000000000000000000..2c2873ea3c91320337e146b0872f572b416886a6 GIT binary patch literal 681 zcmV;a0#^NrP)wBQHZkFGnLgQ!7I&2TNl&OJieOZ$n#ib8mx#Z--BJM=OJumxrHUmzz(YudkoC zZ>O(cx5LA`zjMErSIe(&%g>9`+uPg6hvTb*=i8(2znAyVtN-J}Exeg>00002bW%=J z004HA%{Tx60rp8mK~y-)oz&fSR51tzU@~Kr&7lx7Ne|7OvG4zuUZ~5~{@9xPZ;=q# zL{#X1&U>of%jeY&L*PyIy4*VCY6AGj)pt!4(;D^X6vK zny8zgW_Ew7N-3ofbs*dq)S%t1HA%7N3JLEM@ckI^m)a5+S!vY(5m^RnZS_oNoe6sw z`^6pum553yg-R&~Tt!y*s0t1^+5*;sqZ)vjdu-8g`dO=#LUaxwcJIGBrfz^@xWH%3 zt>4C;#{+&FDy5WjL>Kk&w50-VHB*!=C1Vjt7L(n|B z=cC0OcJ#Y1PyQ#cgT0!8xmIOZVx_st()smnKZf-q45z1aAR&;OFjsEy5UAWFTeB%S z=MiRo&v<5ti0YP7qXNcauENq7GMnxmwm-yi?Jo=wQ5AP#H3l2Ix5lE<4vTRamh literal 0 HcmV?d00001 diff --git a/resources/g2/track/railway/grooved_end_ne_trans.png b/resources/g2/track/railway/grooved_end_ne_trans.png new file mode 100644 index 0000000000000000000000000000000000000000..e9d3ff6d7347e16879f28e0d9c3380352d84bcd8 GIT binary patch literal 883 zcmeAS@N?(olHy`uVBq!ia0vp^nm{bZ!3-p`Cb{lmU|?nl@Ck7Ravd2MN*EXxFfi<6 zVE7N@kAl$<7%?G`c9cs3=vh5a7sn8d^T`PkiVYJdij?+j32490De+3e{i>nD6amR6 mJzF}Q*pjXqPFU1uz`&4ymcc#q%^EXMFnPNAxvXP?npN4WRh fj#Py>U0z0p%wr6WHOFt?1_h9(tDnm{r-UW|QGX#d literal 0 HcmV?d00001 diff --git a/resources/g2/track/railway/grooved_end_nw_trans.png b/resources/g2/track/railway/grooved_end_nw_trans.png new file mode 100644 index 0000000000000000000000000000000000000000..cc1d6bdc35e8fd96fb2dab196daa4bc31b19ff5f GIT binary patch literal 877 zcmeAS@N?(olHy`uVBq!ia0vp^nm{bZ!3-p`Cb{lmU|?nl@Ck7Ravd2MN*EXxFfi<6 zVE7N@kAl$<7%?G`c9cs3=vfU<7sn8d^T`Pk{~9Jvv`7sJ=MHoT(0#lj>eN*uf%VgN fbv86sY*k@m$c<)jpHPU`y85}Sb4q9e0JUT#HUIzs literal 0 HcmV?d00001 diff --git a/resources/g2/track/railway/grooved_nw_se.png b/resources/g2/track/railway/grooved_nw_se.png new file mode 100644 index 0000000000000000000000000000000000000000..5e34dc2bbc90b14f4af714d08fc73dbefcb042ef GIT binary patch literal 935 zcmV;Y16cftP)6ciK{6%`g178e&67#J8C85tTH8XFrM92^`S9UUGX9v>ecARr(iAt53nA|oRs zBqSsyB_$>%CMPE+C@3f?DJd!{Dl021EG#T7EiEoCE-x=HFfcGNF)=bSGBYzXG&D3d zH8nOiHa9mnI5;>tIXOByIy*Z%JUl!-Jv}}?K0iM{KtMo2K|w-7LPJACL_|bIMMXwN zMn^|SNJvOYNl8jdN=r*iOiWBoO-)WtPESuyP*6}&QBhJ-Qd3h?R8&+|RaI72R##V7 zSXfwDSy@_IT3cINTwGjTU0q&YUSD5dU|?WjVPRroVq;@tWMpJzWo2e&W@l$-XlQ6@ zX=!R|YHMq2Y;0_8ZEbFDZf|dIaBy&OadC2Ta&vQYbaZreb#-=jc6WDoczAeud3kzz zdV70&e0+R;eSLm@et&;|fPjF3fq{a8f`fyDgoK2Jg@uNOhKGlTh=_=ZiHVAeii?Yj zjEszpjg5|uj*pLzkdTm(k&%*;l9Q8@l$4Z}m6ev3mY0{8n3$NEnVFiJnwy)OoSdAU zot>VZo}ZteprD|kp`oIpqNAguq@<*!rKP5(rl+T;sHmu^si~@}s;jH3tgNi9t*x%E zuCK4Ju&}VPv9YqUva_?Zw6wIfwY9dkwzs#pxVX5vxw*Q!y1To(yu7@dCU$jHda$;ryf%FD~k%*@Qq&CSlv&d<-!(9qD) z(b3Y<($mw^)YR0~)z#M4*4Nk9*x1lt)=I7_<=;-L_>FMg~>g((4?Ck9A?d|UF?(gsK@bK{Q@$vHV^7Hfa z^z`)g_4W4l_V@Sq`1ttw`T6?#`uqF){QUg={r&#_{{R2~ajHo!00001bW%=J06^y0 zW&i*HRY^oaR4C82k}(PZAPfUV+W7w;yEw!tiJ{!E)D0Ess1r$)8u6{1-oD!M6ciK{6%`g178e&67#J8C85tTH8XFrM92^`S9UUGX9v>ecARr(iAt53nA|oRs zBqSsyB_$>%CMPE+C@3f?DJd!{Dl021EG#T7EiEoCE-x=HFfcGNF)=bSGBYzXG&D3d zH8nOiHa9mnI5;>tIXOByIy*Z%JUl!-Jv}}?K0iM{KtMo2K|w-7LPJACL_|bIMMXwN zMn^|SNJvOYNl8jdN=r*iOiWBoO-)WtPESuyP*6}&QBhJ-Qd3h?R8&+|RaI72R##V7 zSXfwDSy@_IT3cINTwGjTU0q&YUSD5dU|?WjVPRroVq;@tWMpJzWo2e&W@l$-XlQ6@ zX=!R|YHMq2Y;0_8ZEbFDZf|dIaBy&OadC2Ta&vQYbaZreb#-=jc6WDoczAeud3kzz zdV70&e0+R;eSLm@et&;|fPjF3fq{a8f`fyDgoK2Jg@uNOhKGlTh=_=ZiHVAeii?Yj zjEszpjg5|uj*pLzkdTm(k&%*;l9Q8@l$4Z}m6ev3mY0{8n3$NEnVFiJnwy)OoSdAU zot>VZo}ZteprD|kp`oIpqNAguq@<*!rKP5(rl+T;sHmu^si~@}s;jH3tgNi9t*x%E zuCK4Ju&}VPv9YqUva_?Zw6wIfwY9dkwzs#pxVX5vxw*Q!y1To(yu7@dCU$jHda$;ryf%FD~k%*@Qq&CSlv&d<-!(9qD) z(b3Y<($mw^)YR0~)z#M4*4Nk9*x1lt)=I7_<=;-L_>FMg~>g((4?Ck9A?d|UF?(gsK@bK{Q@$vHV^7Hfa z^z`)g_4W4l_V@Sq`1ttw`T6?#`uqF){QUg={r&#_{{R2~sO3^O00002bW%=J{{ZE; zFiHRb0BcD^K~yNujng|003irPQ6@%U|0}j~RDKUDiW9vQ($_tNfM`#ODtF}NN+~My zN}$~Fe6A+=?j8xcoj{=PPw>+9B{Jv>W!M+Uq|eE;&&Z(=``m~`gS sBb{?AH(Tt#{a}Vwmv``y5|+49h8<@Z5zopr0OY7FLI3~& literal 0 HcmV?d00001 diff --git a/resources/g2/track/railway/quarter_turn_3_tiles_sw_se_part_3.png b/resources/g2/track/railway/quarter_turn_3_tiles_sw_se_part_3.png new file mode 100644 index 0000000000000000000000000000000000000000..8e4d82147fe8f9c112c865991b419c7ad18c4966 GIT binary patch literal 604 zcmaKq!E4iC0L8x{BV%(!2(w_23OPi~pkR<5GRQO?b#yM>GRPrr5dtf?Lxjk3m{MmB zMRLfYN|d1yb0}Ig%D{+K!iX}VupEkZu0p|rIZTOASiv1){Re#T-s5+E?@oR;J34$~ z7yvLjeK9lN@8f+B4jt*|>gk^o01Q0O&n!&!@jpsn7)FvQhM_qwCrN^$$eN~^rsX)U z?>AblsM{q|fTjSO8xaI#WhJSurAj(wZm< z@l3w%$gS;C*s^<(pGAR40F?#?2UTRq)8S?X>DJLWOvPO>J~ZOk#{ggf5Ftp0;UbC} zIBrwaCd+OY3e941-?C!QLrDaq6Dc-HiFj5f_#!D8l(NBS)m*v8*>%xv6_RN*mBlEI z$Vq8IX5rqmJaP_0Eqqw9o+&0ai0z;En>t^QgA*XL(BF!^J5xetre znez)nCl|L~joz9Z8q8lUbL)HG^xgNJyL;n1zaRfP_WIIU ziM{vb*_lTV!PvQ{?&sC}>*iSE)6MbsGjnfM>&5{&@nGo>y7UC@bdbyYA9BdQk4#U^ KW?o#la{DiFwD?5; literal 0 HcmV?d00001 From 95997ae78e0d39dc98be24b61340ac45ebe58cb8 Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Wed, 11 Oct 2017 18:11:48 +0200 Subject: [PATCH 02/11] Update sprites json --- resources/g2/sprites.json | 73 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/resources/g2/sprites.json b/resources/g2/sprites.json index 19db0371c4..2aea91bb1c 100644 --- a/resources/g2/sprites.json +++ b/resources/g2/sprites.json @@ -277,5 +277,78 @@ }, { "path": "track/mini/booster_2.png" + }, + { + "path": "track/railway/quarter_turn_3_tiles_sw_se_part_3.png", + "x_offset": -8, + "y_offset": 1 + }, + { + "path": "track/railway/gravel_sw_ne.png", + "x_offset": -33, + "y_offset": -2 + }, + { + "path": "track/railway/gravel_nw_se.png", + "x_offset": -21, + "y_offset": -2 + }, + { + "path": "track/railway/grooved_sw_ne.png", + "x_offset": -28, + "y_offset": -1 + }, + { + "path": "track/railway/grooved_nw_se.png", + "x_offset": -14, + "y_offset": -2 + }, + { + "path": "track/railway/grooved_sw_ne_trans.png", + "x_offset": -28, + "y_offset": -1, + "palette": "keep" + }, + { + "path": "track/railway/grooved_nw_se_trans.png", + "x_offset": -14, + "y_offset": -2, + "palette": "keep" + }, + { + "path": "track/railway/grooved_end_ne_trans.png", + "x_offset": -28, + "y_offset": -1, + "palette": "keep" + }, + { + "path": "track/railway/grooved_end_se_trans.png", + "x_offset": -14, + "y_offset": -2, + "palette": "keep" + }, + { + "path": "track/railway/grooved_end_nw_trans.png", + "x_offset": -14, + "y_offset": -2, + "palette": "keep" + }, + { + "path": "track/railway/grooved_end_sw_trans.png", + "x_offset": -26, + "y_offset": -2, + "palette": "keep" + }, + { + "path": "track/railway/grooved_end_sw_ne_trans.png", + "x_offset": -28, + "y_offset": -1, + "palette": "keep" + }, + { + "path": "track/railway/grooved_end_nw_se_trans.png", + "x_offset": -14, + "y_offset": -2, + "palette": "keep" } ] From 3410330bb2091ca908f34a61b084a5e8133b4bfa Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Wed, 11 Oct 2017 18:13:01 +0200 Subject: [PATCH 03/11] Add paint session memory for tracks and paths --- src/openrct2/paint/paint.h | 3 +- .../paint/tile_element/tile_element.c | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/openrct2/paint/paint.h b/src/openrct2/paint/paint.h index b83759c4a6..e0110149f7 100644 --- a/src/openrct2/paint/paint.h +++ b/src/openrct2/paint/paint.h @@ -170,7 +170,8 @@ typedef struct paint_session tunnel_entry RightTunnels[TUNNEL_MAX_COUNT]; uint8 RightTunnelCount; uint8 VerticalTunnelHeight; - rct_tile_element * SurfaceElement; + rct_tile_element * PathElementOnSameHeight; + rct_tile_element * TrackElementOnSameHeight; bool DidPassSurface; uint8 Unk141E9DB; uint16 Unk141E9DC; diff --git a/src/openrct2/paint/tile_element/tile_element.c b/src/openrct2/paint/tile_element/tile_element.c index 4f9d53f109..62aefb369d 100644 --- a/src/openrct2/paint/tile_element/tile_element.c +++ b/src/openrct2/paint/tile_element/tile_element.c @@ -234,6 +234,7 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y) session->SpritePosition.x = x; session->SpritePosition.y = y; session->DidPassSurface = false; + sint32 previousHeight = 0; do { // Only paint tile_elements below the clip height. if ((gCurrentViewportFlags & VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT) && (tile_element->base_height > gClipHeight)) break; @@ -241,6 +242,41 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y) sint32 direction = tile_element_get_direction_with_offset(tile_element, rotation); sint32 height = tile_element->base_height * 8; + // If we are on a new height level, look through elements on the + // same height and store any types might be relevant to others + if (height != previousHeight) + { + previousHeight = height; + session->PathElementOnSameHeight = 0; + session->TrackElementOnSameHeight = 0; + rct_tile_element * tile_element_sub_iterator = tile_element; + while (!map_element_is_last_for_tile(tile_element_sub_iterator++)) + { + if (tile_element_sub_iterator->base_height != tile_element->base_height) + { + break; + } + switch (map_element_get_type(tile_element_sub_iterator)) + { + case TILE_ELEMENT_TYPE_PATH: + session->PathElementOnSameHeight = tile_element_sub_iterator; + break; + case TILE_ELEMENT_TYPE_TRACK: + session->TrackElementOnSameHeight = tile_element_sub_iterator; + break; + case TILE_ELEMENT_TYPE_CORRUPT: + // To preserve regular behaviour, make an element hidden by + // corruption also invisible to this method. + if (tile_element_is_last_for_tile(tile_element)) + { + break; + } + tile_element_sub_iterator++; + break; + } + } + } + LocationXY16 dword_9DE574 = session->MapPosition; session->CurrentlyDrawnItem = tile_element; // Setup the painting of for example: the underground, signs, rides, scenery, etc. From afab2bd51ff4936553ebdba7e43d82af7bfb6a0d Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Wed, 11 Oct 2017 18:16:25 +0200 Subject: [PATCH 04/11] Change path bounding box when intersecting with track --- src/openrct2/paint/tile_element/path.c | 38 ++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/openrct2/paint/tile_element/path.c b/src/openrct2/paint/tile_element/path.c index ae0ffd8689..4bc0076155 100644 --- a/src/openrct2/paint/tile_element/path.c +++ b/src/openrct2/paint/tile_element/path.c @@ -827,8 +827,21 @@ void path_paint_pole_support(paint_session * session, rct_tile_element * tileEle boundBoxSize.y = 26; } + // By default, add 1 to the z bounding box to always clip above the surface + uint8 boundingBoxZOffset = 1; + + // If we are on the same tile as a straight track, add the offset 2 so we + // can clip above gravel part of the track sprite + if (session->TrackElementOnSameHeight) + { + if (session->TrackElementOnSameHeight->properties.track.type == TRACK_ELEM_FLAT) + { + boundingBoxZOffset = 2; + } + } + if (!hasFences || !session->DidPassSurface) { - sub_98197C(session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + sub_98197C(session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + boundingBoxZOffset, get_current_rotation()); } else { uint32 image_id; if (footpath_element_is_sloped(tileElement)) { @@ -837,12 +850,12 @@ void path_paint_pole_support(paint_session * session, rct_tile_element * tileEle image_id = byte_98D8A4[edges] + footpathEntry->bridge_image + 49; } - sub_98197C(session, image_id | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + sub_98197C(session, image_id | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + boundingBoxZOffset, get_current_rotation()); if (!footpath_element_is_queue(tileElement) && !(footpathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) { // don't draw } else { - sub_98199C(session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + sub_98199C(session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + boundingBoxZOffset, get_current_rotation()); } } @@ -941,8 +954,21 @@ void path_paint_box_support(paint_session * session, rct_tile_element* tileEleme boundBoxSize.y = 26; } + // By default, add 1 to the z bounding box to always clip above the surface + uint8 boundingBoxZOffset = 1; + + // If we are on the same tile as a straight track, add the offset 2 so we + // can clip above gravel part of the track sprite + if (session->TrackElementOnSameHeight) + { + if (session->TrackElementOnSameHeight->properties.track.type == TRACK_ELEM_FLAT) + { + boundingBoxZOffset = 2; + } + } + if (!hasFences || !session->DidPassSurface) { - sub_98197C(session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + sub_98197C(session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + boundingBoxZOffset, get_current_rotation()); } else { uint32 bridgeImage; @@ -954,10 +980,10 @@ void path_paint_box_support(paint_session * session, rct_tile_element* tileEleme bridgeImage |= imageFlags; } - sub_98197C(session, bridgeImage | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + sub_98197C(session, bridgeImage | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + boundingBoxZOffset, get_current_rotation()); if (footpath_element_is_queue(tileElement) || (footpathEntry->flags & FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE)) { - sub_98199C(session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + 1, get_current_rotation()); + sub_98199C(session, imageId | imageFlags, 0, 0, boundBoxSize.x, boundBoxSize.y, 0, height, boundBoxOffset.x, boundBoxOffset.y, height + boundingBoxZOffset, get_current_rotation()); } } From b207826e56d153497f35b500f7f6428e8a20c2c5 Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Wed, 11 Oct 2017 18:17:08 +0200 Subject: [PATCH 05/11] Increase bounding box z of litter --- src/openrct2/paint/sprite/litter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/openrct2/paint/sprite/litter.c b/src/openrct2/paint/sprite/litter.c index c93d4b30b8..3e4d10424e 100644 --- a/src/openrct2/paint/sprite/litter.c +++ b/src/openrct2/paint/sprite/litter.c @@ -84,6 +84,8 @@ void litter_paint(paint_session * session, rct_litter *litter, sint32 imageDirec imageDirection &= litter_sprites[litter->type].direction_mask; uint32 image_id = imageDirection + litter_sprites[litter->type].base_id; - - sub_98197C(session, image_id, 0, 0, 4, 4, -1, litter->z, -4, -4, litter->z + 2, get_current_rotation()); + + // In the following call to sub_98197C, we add 4 (instead of 2) to the + // bound_box_offset_z to make sure litter is drawn on top of railways + sub_98197C(session, image_id, 0, 0, 4, 4, -1, litter->z, -4, -4, litter->z + 4, get_current_rotation()); } From c6d548cc36d05ec64e7cae33f16da699a1ec3a8e Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Wed, 11 Oct 2017 18:17:40 +0200 Subject: [PATCH 06/11] Increase bouding box z of peeps --- src/openrct2/paint/sprite/peep.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/openrct2/paint/sprite/peep.c b/src/openrct2/paint/sprite/peep.c index 877fd57178..80c4739004 100644 --- a/src/openrct2/paint/sprite/peep.c +++ b/src/openrct2/paint/sprite/peep.c @@ -77,26 +77,28 @@ void peep_paint(paint_session * session, rct_peep * peep, sint32 imageDirection) spriteType = peep->next_action_sprite_type; imageOffset = 0; } - + + // In the following 4 calls to sub_98197C/sub_98199C, we add 5 (instead of 3) to the + // bound_box_offset_z to make sure peeps are drawn on top of railways uint32 baseImageId = (imageDirection >> 3) + sprite.sprite_animation[spriteType].base_image + imageOffset * 4; uint32 imageId = baseImageId | peep->tshirt_colour << 19 | peep->trousers_colour << 24 | IMAGE_TYPE_REMAP | IMAGE_TYPE_REMAP_2_PLUS; - sub_98197C(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 3, get_current_rotation()); + sub_98197C(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 5, get_current_rotation()); if (baseImageId >= 10717 && baseImageId < 10749) { imageId = (baseImageId + 32) | peep->hat_colour << 19 | IMAGE_TYPE_REMAP; - sub_98199C(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 3, get_current_rotation()); + sub_98199C(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 5, get_current_rotation()); return; } if (baseImageId >= 10781 && baseImageId < 10813) { imageId = (baseImageId + 32) | peep->balloon_colour << 19 | IMAGE_TYPE_REMAP; - sub_98199C(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 3, get_current_rotation()); + sub_98199C(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 5, get_current_rotation()); return; } if (baseImageId >= 11197 && baseImageId < 11229) { imageId = (baseImageId + 32) | peep->umbrella_colour << 19 | IMAGE_TYPE_REMAP; - sub_98199C(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 3, get_current_rotation()); + sub_98199C(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 5, get_current_rotation()); return; } } From f8b4ee2602967c49cd29abe029e7b19ff3816de4 Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Wed, 11 Oct 2017 18:25:23 +0200 Subject: [PATCH 07/11] Add gravel / grooved track painting behaviour to miniature railway --- .../ride/transport/MiniatureRailway.cpp | 90 +++++++++++++++++-- 1 file changed, 85 insertions(+), 5 deletions(-) diff --git a/src/openrct2/ride/transport/MiniatureRailway.cpp b/src/openrct2/ride/transport/MiniatureRailway.cpp index 8e52fdd8ae..ec5ef1c760 100644 --- a/src/openrct2/ride/transport/MiniatureRailway.cpp +++ b/src/openrct2/ride/transport/MiniatureRailway.cpp @@ -18,6 +18,7 @@ #include "../../interface/viewport.h" #include "../../paint/paint.h" #include "../../paint/supports.h" +#include "../../sprites.h" #include "../../world/map.h" #include "../ride_data.h" #include "../Track.h" @@ -547,27 +548,106 @@ static const uint32 miniature_railway_track_pieces_diag_25_deg_up[4] = { SPR_MINIATURE_RAILWAY_DIAG_25_DEG_UP_S_N, }; +static uint32 miniature_railway_track_to_gravel(uint32 imageId) +{ + return imageId - SPR_MINIATURE_RAILWAY_FLAT_SW_NE + SPR_G2_MINIATURE_RAILWAY_GRAVEL_SW_NE; +} + +static uint32 miniature_railway_track_to_grooved(uint32 imageId) +{ + return imageId - SPR_MINIATURE_RAILWAY_FLAT_SW_NE + SPR_G2_MINIATURE_RAILWAY_GROOVED_SW_NE; +} + +static uint32 miniature_railway_track_to_grooved_indent(uint32 imageId, rct_map_element *path, uint8 direction) +{ + if (!path) + { + return 0; + } + + uint32 imageIdAlt = SPR_G2_MINIATURE_RAILWAY_GROOVED_SW_NE; + + uint8 correctedEdges = path->properties.path.edges; + correctedEdges |= correctedEdges << 4; + correctedEdges >>= 4 - get_current_rotation(); + correctedEdges &= 0x0F; + + if (direction & 0x1) + { + uint32 imageIds[2][2] = { { SPR_G2_MINIATURE_RAILWAY_INSET_NW_SE, SPR_G2_MINIATURE_RAILWAY_INSET_END_NW }, + { SPR_G2_MINIATURE_RAILWAY_INSET_END_SE, SPR_G2_MINIATURE_RAILWAY_INSET_END_NW_SE } }; + imageIdAlt = imageIds[(correctedEdges & 0x2)? 0 : 1][(correctedEdges & 0x8)? 0 : 1]; + } + else + { + uint32 imageIds[2][2] = { { SPR_G2_MINIATURE_RAILWAY_INSET_SW_NE, SPR_G2_MINIATURE_RAILWAY_INSET_END_SW }, + { SPR_G2_MINIATURE_RAILWAY_INSET_END_NE, SPR_G2_MINIATURE_RAILWAY_INSET_END_SW_NE } }; + imageIdAlt = imageIds[(correctedEdges & 0x1)? 0 : 1][(correctedEdges & 0x4)? 0 : 1]; + } + + return imageIdAlt; +} + /** rct2: 0x008AD0C0 */ static void paint_miniature_railway_track_flat(paint_session * session, uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_tile_element * tileElement) { + bool paintAsGravel = false; + bool paintGrooved = false; - bool isSupported = - wooden_a_supports_paint_setup(session, direction & 1, 0, height, session->TrackColours[SCHEME_SUPPORTS], NULL); - uint32 imageId; + if (session->PathElementOnSameHeight) + { + paintAsGravel = true; + paintGrooved = true; + } + bool isSupported = wooden_a_supports_paint_setup(session, direction & 1, 0, height, session->TrackColours[SCHEME_SUPPORTS], NULL); + uint32 imageId, imageIdAlt; + + // In the following 3 calls to sub_98197C_rotated/sub_98199C_rotated, we add 1 to the + // bound_box_offset_z argument to make straight tracks draw above footpaths if (isSupported) { imageId = miniature_railway_track_floor[direction] | session->TrackColours[SCHEME_SUPPORTS]; sub_98197C_rotated(session, direction, imageId, 0, 0, 32, 20, 2, height, 0, 6, height); imageId = miniature_railway_track_pieces_flat[direction] | session->TrackColours[SCHEME_TRACK]; - sub_98199C_rotated(session, direction, imageId, 0, 6, 32, 20, 2, height, 0, 6, height); + if (!paintAsGravel) + { + sub_98199C_rotated(session, direction, imageId, 0, 6, 32, 20, 2, height, 0, 6, height); + } + else + { + imageIdAlt = miniature_railway_track_to_gravel(imageId); + sub_98199C_rotated(session, direction, imageIdAlt, 0, 6, 32, 20, 2, height, 0, 6, height); + } + if (paintGrooved) + { + imageIdAlt = miniature_railway_track_to_grooved(imageId); + sub_98199C_rotated(session, direction, imageIdAlt, 0, 6, 32, 20, 2, height, 0, 6, height + 2); + imageIdAlt = miniature_railway_track_to_grooved_indent(imageId, session->PathElementOnSameHeight, direction); + sub_98199C_rotated(session, direction, (imageIdAlt & 0x7FFFF) | IMAGE_TYPE_REMAP | IMAGE_TYPE_TRANSPARENT | (PALETTE_DARKEN_2 << 19), 0, 6, 32, 20, 2, height, 0, 6, height + 2); + } } else { imageId = miniature_railway_track_pieces_flat[direction] | session->TrackColours[SCHEME_TRACK]; - sub_98197C_rotated(session, direction, imageId, 0, 6, 32, 20, 2, height, 0, 6, height); + if (!paintAsGravel) + { + sub_98197C_rotated(session, direction, imageId, 0, 6, 32, 20, 2, height, 0, 6, height); + } + else + { + imageIdAlt = miniature_railway_track_to_gravel(imageId); + sub_98197C_rotated(session, direction, imageIdAlt, 0, 6, 32, 20, 2, height, 0, 6, height); + } + if (paintGrooved) + { + imageIdAlt = miniature_railway_track_to_grooved(imageId); + sub_98197C_rotated(session, direction, imageIdAlt, 0, 6, 32, 20, 2, height, 0, 6, height + 2); + imageIdAlt = miniature_railway_track_to_grooved_indent(imageId, session->PathElementOnSameHeight, direction); + sub_98197C_rotated(session, direction, (imageIdAlt & 0x7FFFF) | IMAGE_TYPE_REMAP | IMAGE_TYPE_TRANSPARENT | (PALETTE_DARKEN_2 << 19), 0, 6, 32, 20, 2, height, 0, 6, height + 2); + } } paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_6); From 0c1265aba31853953592749fceccf0c14e73094f Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Wed, 11 Oct 2017 18:25:40 +0200 Subject: [PATCH 08/11] Add sprites to sprite index --- src/openrct2/sprites.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/openrct2/sprites.h b/src/openrct2/sprites.h index 2ae6561726..391112f318 100644 --- a/src/openrct2/sprites.h +++ b/src/openrct2/sprites.h @@ -802,6 +802,23 @@ enum { SPR_G2_MINI_RC_BOOSTER_NE_SW = SPR_G2_BEGIN + 91, SPR_G2_MINI_RC_BOOSTER_NW_SE = SPR_G2_BEGIN + 92, + + SPR_G2_MINIATURE_RAILWAY_QUARTER_TURN_3_TILES_SW_SE_PART_3 = SPR_G2_BEGIN + 93, + + SPR_G2_MINIATURE_RAILWAY_BEGIN = SPR_G2_BEGIN + 94, + SPR_G2_MINIATURE_RAILWAY_GRAVEL_SW_NE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 0, + SPR_G2_MINIATURE_RAILWAY_GRAVEL_NW_SE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 1, + SPR_G2_MINIATURE_RAILWAY_GROOVED_SW_NE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 2, + SPR_G2_MINIATURE_RAILWAY_GROOVED_NW_SE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 3, + SPR_G2_MINIATURE_RAILWAY_INSET_SW_NE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 4, + SPR_G2_MINIATURE_RAILWAY_INSET_NW_SE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 5, + SPR_G2_MINIATURE_RAILWAY_INSET_END_NE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 6, + SPR_G2_MINIATURE_RAILWAY_INSET_END_SE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 7, + SPR_G2_MINIATURE_RAILWAY_INSET_END_NW = SPR_G2_MINIATURE_RAILWAY_BEGIN + 8, + SPR_G2_MINIATURE_RAILWAY_INSET_END_SW = SPR_G2_MINIATURE_RAILWAY_BEGIN + 9, + SPR_G2_MINIATURE_RAILWAY_INSET_END_SW_NE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 10, + SPR_G2_MINIATURE_RAILWAY_INSET_END_NW_SE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 11, + SPR_G2_MINIATURE_RAILWAY_LAST = SPR_G2_BEGIN + 105, // 0x60000, chosen because it's a round hex number // of the last possible range of image ID values that is large enough to fit all csg1 sprites. From deb37a8de80cd87ba33594cc2cf71989e7dff65d Mon Sep 17 00:00:00 2001 From: Jeroen D Stout Date: Wed, 11 Oct 2017 19:24:01 +0200 Subject: [PATCH 09/11] Add missing 3-tile turn piece --- src/openrct2/ride/transport/MiniatureRailway.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/openrct2/ride/transport/MiniatureRailway.cpp b/src/openrct2/ride/transport/MiniatureRailway.cpp index ec5ef1c760..49aee07b9b 100644 --- a/src/openrct2/ride/transport/MiniatureRailway.cpp +++ b/src/openrct2/ride/transport/MiniatureRailway.cpp @@ -1243,6 +1243,13 @@ static void paint_miniature_railway_track_right_quarter_turn_3_tiles(paint_sessi session, 3, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK], miniature_railway_track_pieces_flat_quarter_turn_3_tiles, defaultRightQuarterTurn3TilesOffsets, defaultRightQuarterTurn3TilesBoundLengths, NULL, get_current_rotation()); + + // The following piece was missing in vanilla RCT2 + if (trackSequence == 1 && direction == 0) + { + uint32 imageId = SPR_G2_MINIATURE_RAILWAY_QUARTER_TURN_3_TILES_SW_SE_PART_3 | session->TrackColours[SCHEME_TRACK]; + sub_98197C(session, imageId, 0, 0, 8, 8, 2, height, 0, 0, height, get_current_rotation()); + } } else { From 6b5ad0cf73512a7a2b8bf747901b548a90ae0bed Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 16 Nov 2017 19:06:19 +0000 Subject: [PATCH 10/11] Fix alignment in sprites.h --- src/openrct2/sprites.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openrct2/sprites.h b/src/openrct2/sprites.h index 391112f318..332a0c8f76 100644 --- a/src/openrct2/sprites.h +++ b/src/openrct2/sprites.h @@ -805,7 +805,7 @@ enum { SPR_G2_MINIATURE_RAILWAY_QUARTER_TURN_3_TILES_SW_SE_PART_3 = SPR_G2_BEGIN + 93, - SPR_G2_MINIATURE_RAILWAY_BEGIN = SPR_G2_BEGIN + 94, + SPR_G2_MINIATURE_RAILWAY_BEGIN = SPR_G2_BEGIN + 94, SPR_G2_MINIATURE_RAILWAY_GRAVEL_SW_NE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 0, SPR_G2_MINIATURE_RAILWAY_GRAVEL_NW_SE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 1, SPR_G2_MINIATURE_RAILWAY_GROOVED_SW_NE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 2, @@ -818,7 +818,7 @@ enum { SPR_G2_MINIATURE_RAILWAY_INSET_END_SW = SPR_G2_MINIATURE_RAILWAY_BEGIN + 9, SPR_G2_MINIATURE_RAILWAY_INSET_END_SW_NE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 10, SPR_G2_MINIATURE_RAILWAY_INSET_END_NW_SE = SPR_G2_MINIATURE_RAILWAY_BEGIN + 11, - SPR_G2_MINIATURE_RAILWAY_LAST = SPR_G2_BEGIN + 105, + SPR_G2_MINIATURE_RAILWAY_LAST = SPR_G2_BEGIN + 105, // 0x60000, chosen because it's a round hex number // of the last possible range of image ID values that is large enough to fit all csg1 sprites. From f7c7a5bace77ce82caaa704cf0290db6904ec005 Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 16 Nov 2017 19:11:10 +0000 Subject: [PATCH 11/11] Fix build --- src/openrct2/paint/paint.h | 1 + src/openrct2/paint/tile_element/tile_element.c | 4 ++-- src/openrct2/ride/transport/MiniatureRailway.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/openrct2/paint/paint.h b/src/openrct2/paint/paint.h index e0110149f7..7efe33d29d 100644 --- a/src/openrct2/paint/paint.h +++ b/src/openrct2/paint/paint.h @@ -170,6 +170,7 @@ typedef struct paint_session tunnel_entry RightTunnels[TUNNEL_MAX_COUNT]; uint8 RightTunnelCount; uint8 VerticalTunnelHeight; + rct_tile_element * SurfaceElement; rct_tile_element * PathElementOnSameHeight; rct_tile_element * TrackElementOnSameHeight; bool DidPassSurface; diff --git a/src/openrct2/paint/tile_element/tile_element.c b/src/openrct2/paint/tile_element/tile_element.c index 62aefb369d..bbb700a5f1 100644 --- a/src/openrct2/paint/tile_element/tile_element.c +++ b/src/openrct2/paint/tile_element/tile_element.c @@ -250,13 +250,13 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y) session->PathElementOnSameHeight = 0; session->TrackElementOnSameHeight = 0; rct_tile_element * tile_element_sub_iterator = tile_element; - while (!map_element_is_last_for_tile(tile_element_sub_iterator++)) + while (!tile_element_is_last_for_tile(tile_element_sub_iterator++)) { if (tile_element_sub_iterator->base_height != tile_element->base_height) { break; } - switch (map_element_get_type(tile_element_sub_iterator)) + switch (tile_element_get_type(tile_element_sub_iterator)) { case TILE_ELEMENT_TYPE_PATH: session->PathElementOnSameHeight = tile_element_sub_iterator; diff --git a/src/openrct2/ride/transport/MiniatureRailway.cpp b/src/openrct2/ride/transport/MiniatureRailway.cpp index 49aee07b9b..cea941062b 100644 --- a/src/openrct2/ride/transport/MiniatureRailway.cpp +++ b/src/openrct2/ride/transport/MiniatureRailway.cpp @@ -558,7 +558,7 @@ static uint32 miniature_railway_track_to_grooved(uint32 imageId) return imageId - SPR_MINIATURE_RAILWAY_FLAT_SW_NE + SPR_G2_MINIATURE_RAILWAY_GROOVED_SW_NE; } -static uint32 miniature_railway_track_to_grooved_indent(uint32 imageId, rct_map_element *path, uint8 direction) +static uint32 miniature_railway_track_to_grooved_indent(uint32 imageId, rct_tile_element *path, uint8 direction) { if (!path) {