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 zcmeAS@N?(olHy`uVBq!ia0y~yU@&E1V36TpW?*3WHk*A90|P@^fKP}k0|UeV|NptQ z`Nfr$<;|s)jg9r4o%P+7t%J4ggM+=3&ApS8qw}4ki;MG{oAcZKo2O52pC8{HZasar z|NQmq=WownzCM2Y;lsQ47w?}QetLcW>GR!}Z{NOsy#4X&=I6H;zu!Oo|Kr0iV*M{L zFfcHc1o;IsFqBO`Yr(+4c*@hoF~s8Z)F~H(q78XmGCez`*RLy^c!oE8M%(}YC+!Ss z6;!7DxH!*P&U1BfdHLs`g>N73yzBQ=y8m{sNKgKgh;>5Z8l8OgPp7>;T&`&{WubM$ zmdCBH^a8l|E@iuDyDDpMz+LrIy?bY;Je;w_dBU})-d>YA+AUXZ;`*-kxa`za{_86O zuO>{1Zkfn6SLgIW&J?-Zs#&!Y8F-c+6y36kBWr>6vMC3CxZF*Ca(UZ6fvbB~cNsT5 zFe%=!ahdJHY4@MkJ4PJ~b7#mAuxOMFFstzH&HTpo;o+KfcWpn!Nc$ycY98Eji1Bas zs|(W{t}T~)v_Zr1kj?5fH}0-FlxP>}wX^rkjdRboHcwf9e5GiP0^l`jN^onG2|*V4v1`>C~nqOVxfJ>N~)(fimJG)|q& z^^M`~i?_B*<7Xt+GxXUk)Odey)*9s<)BYZJwsz>}w&a?oVfnS>N8A3g14g&9o&_;l z)m*OL-;g}l&)3ZD?t{~|OHzI1^1i&0E4s7p`R@7C_5L#j)o4vgJ+ZTsfq{X+)78&q Iol`;+04!NDF8}}l 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 zcmeAS@N?(olHy`uVBq!ia0y~yU@&E1V36TpW?*3WHk*A90|P@sfKP}k0|UeV|Nq66 zmGzyS_1%@NgSDNt*}ap^y_1up^PQuMi}RbC^V|K)-L;#iPj8bw->x$ox4L>CTrUQ-#e{0U7qHaZWG*o*JaPDZBt5&MKhXpkH21Z zjw9iqsASRSXK9yat(d(at*m~Pm*!G|QiVI>R~Fn|YwEf285ie!;SYZ$K2EQcLDlQ`%kU3pTr+FFq<$_GP!e|3CE&&3k7x?hH$fNLsq{)TN(a^X%Kc zD)TH~UaX)vVYWed-UopdcT}P`Yg#@ROshR#k=D`iYFf}@rejI#4qcKkn*C00oBff( zxB5JSfuiM!rfkx?w;x+{iLbj*a@yy2Uyfb+H)qQ#^FX)9H`UfBAK<@TP^GS@lAZhD z)mFc-c+S_~!>g|g2-fc2p{c$~;c-=W>D#Jb4pFtAyXM3>yM0N{_?vJl_5GX2+n)dU wes|v0&34znpO;ixwBy%uUcrm@_dhfLovEgJf63W>3=9kmp00i_>zopr0NA!ibN~PV 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!ia0y~yV9;b>U=ZVAW?*2*n&i5Nfq|JJz$e6&fq}u1fuV$f zVF3ffJ_d&W45MH)1V&H@q#fmwU|?X-^K@|x(Kw%+AfebWaiU0R&z6Ap>zop=B;2nW rDohcOeA2U}!-*~Fs^Nr1eFh8+`DYp2GvBN+0|k_)tDnm{r-UW|AU=ZVAW?*2*n&i5Nfq|JJz$e6&fq}u1fuV$f zVF3ffJ_d&W45MH)1V&H@q#fmwU|?X-@N{tu(Kw%+An~tZ;zWzokZ|rmhXCEjE27?H lNp^&L-|a|Mh|}d|WXL?m;8=6~_H9rQdAjU=ZVAW?*2*n&i5Nfq|JJz$e6&fq}u1fuV$f zVF3ffJ_d&W45MH)1V&H@q#fmwU|?X-@N{tu(Kw%+An~tZ;zWzokZ|rmhXCEjE22(a lH4<1qZC7VQW5re#CWhQ-2KNbNsZO9E@^tlcS?83{1OQ|ZAt?X= literal 0 HcmV?d00001 diff --git a/resources/g2/track/railway/grooved_end_se_trans.png b/resources/g2/track/railway/grooved_end_se_trans.png new file mode 100644 index 0000000000000000000000000000000000000000..6ec6f0958e561fce6964411fcb93745d768ce7ac GIT binary patch literal 885 zcmeAS@N?(olHy`uVBq!ia0y~yV9;b>U=ZVAW?*2*n&i5Nfq|JJz$e6&fq}u1fuV$f zVF3ffJ_d&W45MH)1V&H@q#fmwU|?V{@N{tu(Kw%+(7@!zwun)=FiWyC__W8KD7Qyf tjQUo|%4JD*gnPHPoN$U=ZVAW?*2*n&i5Nfq|JJz$e6&fq}u1fuV$f zVF3ffJ_d&W45MH)1V&H@q#fmwU|?X-^K@|x(Kw%+AfebWaiU0R&z6Ap>zop=B-*!I ru_awKoUo{G$%;gUFj;2JS1Z^VvYQwjzwgMp2MQ=pS3j3^P6U=ZVAW?*2*n&i5Nfq|JJz$e6&fq}u1fuV$f zVF3ffJ_d&W45MH)1V&H@q#fmwU|?V{@N{tu(K!G1(n3ZC1%U>K8}*s)A2jPG)(GxU t*}TP~yZDvPx%XzW!S02bhCa=ocQJ2iWQgt%a$y7om8Ywp%Q~loCIGc$B{l#6 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 zcmeAS@N?(olHy`uVBq!ia0y~yV9;b>U=ZVAW?*2*n&i5Nfq|JJz$e7@|NsBy^6d7( z!S4F}-pR?)#l`u}&CS!Nb8v8Qa&mHUadC5V^YHNS^78WW@$vKX3kV1Z3JMAd2?+}e zi-?Gbii(PfiHVDgOGrpaN=iyeNl8mf%gD&c%F4>g$;r#hD<~)^Dk>@|DJd%}tEi}` zs;a7~si~{0YiMX_YHDg}X=!U~>*(m{>gww0>FMk18yFZE8X6iI85tWJo0yoGnwpxK znVFlLTUc0FT3T9JSy@|K+t}FH+S=OL+1cCMJ2*HvIyyQzIXOE!ySTWxy1Kf#xw*T$ zdw6(wdU|?!d3k$#`}p|y`uh6$`T6_%2LuEJ1_lNN1qBBOhlGTLhK7cPg@uQQM?^$K zMn*U3Q#l^?RCnO{!CMG5&B_$^(r=+B$rlzK)rKP8*XJlk#W@ct( zWo2h)=j7z%=H}+*<>lw+7Zel}78Vv26%`j3mz0#0mX?;4m6ey5S5#C~R#sM3RaIA4 z*VNS1*4Eb5)z#P6H#9UfHa0djH8nRkx3sjhwzjslwY9gmcXV`gc6N4kb#-@l_w@Ai z_V)Jm_4W7nPna-a;>3xQCQX_=dGeGgQ>IRxI&Ipt>C>mrm@#AK%$c)h&6+)X_MAC$ z=FXivZ{EE5^XD&EuwdcBg^Ly~TD*Aik|j%)E?v58*|O!!m#aNyvkt0Wr9zA;O*sC-XE?v5O`SO)3SFT>YdhOb^>({T}xN+m=&6~Gw z-MW4I_MJO-?%ut7@7}%p_wPS=@ZjOYhmRgTdi?nDlP6D}K7IP^*|X=*pTBtV;^oVi zuU@@+{rdHrH*em)ef#d+yZ7(kfB5j>@@87@w|Nj@R^3-EsU|=i>@(X5gcy=R=fq@~^)5S4FU=ZVAW?*2*n&i5Nfq|JJz$e6&fq}u1fuV$f zVF3ffJ_d&W45MH)1V&H@q#fmwU|?V{@N{tu(Kw%+(7@!zwun)=FiWyC__W8KD7Qyf tjQUo|R%S_dgnPHToOYOU^hK5@3&V~z42eRg^;1AW<>~6@vd$@?2>@H;Bk=$L literal 0 HcmV?d00001 diff --git a/resources/g2/track/railway/grooved_sw_ne.png b/resources/g2/track/railway/grooved_sw_ne.png new file mode 100644 index 0000000000000000000000000000000000000000..db81fb0082abf82479a2cd52b571d4d4c14681c8 GIT binary patch literal 958 zcmeAS@N?(olHy`uVBq!ia0y~yV9;b>U=ZVAW?*2*n&i5Nfq|JJz$e6&fq~)w|NrLl z?DoOI?)v=R$;r{h#re(6&C{oIa&mHUadC5V^YHNS^78WW@$vKX3kV1Z3JMAd2?+}e zi-?Gbii(PfiHVDgOGrpaN=iyeNl8mf%gD&c%F4>g$;r#hD<~)^Dk>@|DJd%}tEi}` zs;a7~si~{0YiMX_YHDg}X=!U~>*(m{>gww0>FMk18yFZE8X6iI85tWJo0yoGnwpxK znVFlLTUc0FT3T9JSy@|K+t}FH+S=OL+1cCMJ2*HvIyyQzIXOE!ySTWxy1Kf#xw*T$ zdw6(wdU|?!d3k$#`}p|y`uh6$`T6_%2LuEJ1_lNN1qBBOhlGTLhK7cPg@uQQM?^$K zMn*U3Q#l^?RCnO{!CMG5&B_$^(r=+B$rlzK)rKP8*XJlk#W@ct( zWo2h)=j7z%=H}+*<>lw+7Zel}78Vv26%`j3mz0#0mX?;4m6ey5S5#C~R#sM3RaIA4 z*VNS1*4Eb5)z#P6H#9UfHa0djH8nRkx3sjhwzjslwY9gmcXV`gc6N4kb#-@l_w@Ai z_V)Jm_4W7nPna-a;>3xQCQX_=dGeGgQ>IRxI&Ipt>C>mrm@#AK%$c)h&6+)X_MAC$ z=FXivZ{EE5^XD&EuwdcBg^Ly~TD*Aik|j%)E?v58*|O!!m#aNyvkt0Wr9zA;O*sC-XE?v5O`SO)3SFT>YdhOb^>({T}xN+m=&6~Gw z-MW4I_MJO-?%ut7@7}%p_wPS=@ZjOYhmRgTdi?nDlP6D}K7IP^*|X=*pTBtV;^oVi zuU@@+{rdHrH*em)ef#d+yZ7(kfB5j>@@87@w|NpOe8f4DEz`#@zAG!8Lxz8sR{4{sUYc5;y%ya0ShG&;$2&RB zU2`24y!Zcb>8q;I3+~h#;wP4zKe^@niAC=xrruX|ygzZp`x6Ic%gfIH?$PU=ZVAW?*2*n&i5Nfq|JJz$e6&fq}u1fuV$f zVF3ffJ_d&W45MH)1V&H@q#fmwU|?V{_H=O!(K!G1@^A1PspD`nVmh9U98st1=rq2=l7=d#Wzp$P!ws4PMN 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 zcmeAS@N?(olHy`uVBq!ia0y~yU=U+qU|{87W?*0_(|BXUz`(dRz$e6&0WT0&R#rAP z)^~Qc4-WQDPL3`v&TnpRo<4p4`t{onAHID1_WRGDjrAGqtr`5ixuc_nv$N&PtM%Kv zt*6iSU%ozm_x|G3=ezGeUhJ&R9&XK@?=4;*F5jQ5KEK#_bF=gQ>EWl>=iffw{`~gh z@9z)0OEbi4GnCsi^aryq&u8D?&3}El@aNOg|DWss{~Z7ScmMzYhm{!^{23VH+1c~? z`Rk>n`_g@Fi+*Llm j=9{t2%(!3Daf|pLKNgO8eZ*TBluA5Z{an^LB{Ts5akThF 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) {