Replacing Foundations & Road Tunnels

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
User avatar
Fedello
Engineer
Engineer
Posts: 15
Joined: 27 Oct 2021 21:19
Location: Galiza
Contact:

Replacing Foundations & Road Tunnels

Post by Fedello »

Hey there!

I'm trying to make a NewGRF that let's you customize foundations (for example, use temperate rochy one on an arctic climate) and also tunnels. I've been trying so far following how OpenGFX is done. But I've found some bugs that I don't know how they get there.

For example, with foundations, if I replace the sprites of the tropical climate (517 onwards), newspapers get these artifacts (others works fine):
Image
Here is the code I use:

Code: Select all


if (param_foundations == TEMPERATE) {
	replace (990, "src/gfx/temperate/foundations.png") {	foundations_template()	}
	replace (328, "src/gfx/temperate/foundations.png") {	foundations_template()	}
	/* replace (517, "src/gfx/temperate/foundations.png") {	foundations_template()	} */
	replace (543, "src/gfx/temperate/foundations.png") {	foundations_template()	}
	replacenew(FOUNDATIONS_SLOPES_HALFTILES, "") {
		sloped_foundations_template("src/gfx/temperate/sloped_foundations.png")
	}
}else if(param_foundations == ARCTIC) {
	replace (990, "src/gfx/arctic/foundations.png") {	foundations_template()	}
	replace (328, "src/gfx/arctic/foundations.png") {	foundations_template()	}
	/* replace (517, "src/gfx/arctic/foundations.png") {	foundations_template()	} */
	replace (543, "src/gfx/arctic/foundations.png") {	foundations_template()	}
	replacenew(FOUNDATIONS_SLOPES_HALFTILES, "") {
		sloped_foundations_template("src/gfx/arctic/sloped_foundations.png")
	}
}else if(param_foundations == TROPICAL) {
	replace (990, "src/gfx/tropical/foundations.png") {	foundations_template()	}
	replace (328, "src/gfx/tropical/foundations.png") {	foundations_template()	}
	/* replace (517, "src/gfx/tropical/foundations.png") {	foundations_template()	} */
	replace (543, "src/gfx/tropical/foundations.png") {	foundations_template()	}
	replacenew(FOUNDATIONS_SLOPES_HALFTILES, "") {
		sloped_foundations_template("src/gfx/tropical/sloped_foundations.png")
	}
}else if(param_foundations == TOYLAND) {
	replace (990, "src/gfx/toyland/foundations.png") {	foundations_template()	}
	replace (328, "src/gfx/toyland/foundations.png") {	foundations_template()	}
	/* replace (517, "src/gfx/toyland/foundations.png") {	foundations_template()	} */
	replace (543, "src/gfx/toyland/foundations.png") {	foundations_template()	}
	replacenew(FOUNDATIONS_SLOPES_HALFTILES, "") {
		sloped_foundations_template("src/gfx/toyland/sloped_foundations.png")
	}
}
Also trying to replace tunnels (For now I'm trying to do an alterante between original tunnels & openGFX ones), I also got the newspaper issue + this black artifacts when zooming in-out
Image

Code: Select all

if (param_tunnels == TUNNEL_CLASSIC) {
	//temperate 2429-2436 tunnel gui
	/* replace (2429, "sprites/png/gui/road_tunnels_gui.png") { [ 0,  0,  20,  20,   0,   0] } // road tunnel
	alternative_sprites (spr2429, ZOOM_LEVEL_IN_2X, BIT_DEPTH_8BPP, "sprites/png/gui/road_tunnels_gui.png") { tmpl_gui2x_toolbar(72, 0) } */
	
	// temperate road tunnels 2389 - 2396
	replace (2389, "src/gfx/tunnels/classic.png") { road_tunnels_template(27) }
	// snowy road tunnels 2421 - 2428
	replace (2421, "src/gfx/tunnels/classic.png") { road_tunnels_template(249) }
	// arctic road tunnel 238 - 245
	replace (238, "src/gfx/tunnels/classic.png") { road_tunnels_template(101) }
	// tropical road tunnel on desert ground 509 - 516
	replace (509, "src/gfx/tunnels/classic.png") { road_tunnels_template(322) }
	// toyland Road tunnel sprites 1170 - 1177
	replace (1170, "src/gfx/tunnels/classic.png") { road_tunnels_template(396) }
}else if(param_tunnels == TUNNEL_OPENGFX) {
	// temperate road tunnels 2389 - 2396
	replace (2389, "src/gfx/tunnels/opengfx.png") { road_tunnels_template(27) }
	// snowy road tunnels 2421 - 2428
	replace (2421, "src/gfx/tunnels/opengfx.png") { road_tunnels_template(249) }
	// arctic road tunnel 238 - 245
	replace (238, "src/gfx/tunnels/opengfx.png") { road_tunnels_template(101) }
	// tropical road tunnel on desert ground 509 - 516
	replace (509, "src/gfx/tunnels/opengfx.png") { road_tunnels_template(322) }
	// toyland Road tunnel sprites 1170 - 1177
	replace (1170, "src/gfx/tunnels/opengfx.png") { road_tunnels_template(396) }

}
Does anyone have any clue what can be the issue?
User avatar
Fedello
Engineer
Engineer
Posts: 15
Joined: 27 Oct 2021 21:19
Location: Galiza
Contact:

Re: Replacing Foundations & Road Tunnels

Post by Fedello »

Problem solved! I've jsut asked the same question on the Official Discord and MnHebi solved the issue!

For anyone else having this issue or wondering the answer:
517 to 531 is most definitely not foundations...
you are replacing letter sprites hence you get the funsies in the newspaper
I'd imagine Tropical uses the same sprite IDs for the foundations as Temperate, which is 990 to 1003
ah I see, you decoded the tropical grf and assumed the sprite numbers corresponded to the sprite ID
you want to base your IDs on what you see in the _base grf.
I can't remember where in the wiki it actually lists the ID for every tile type...
yep its 990 to 1003 in tropical, same as _base
you can use the sprite aligner to check if you have the right sprite ID
Turns out I was over-overwriting too much sprites, and foundations were only 990-1003, as MnHebi said:

Code: Select all

if (param_foundations == TEMPERATE) {
	replace (990, "src/gfx/temperate/foundations.png") {	foundations_template()	}
	replacenew(FOUNDATIONS_SLOPES_HALFTILES, "") {
		sloped_foundations_template("src/gfx/temperate/sloped_foundations.png")
	}
}else if(param_foundations == ARCTIC) {
	replace (990, "src/gfx/arctic/foundations.png") {	foundations_template()	}
	replacenew(FOUNDATIONS_SLOPES_HALFTILES, "") {
		sloped_foundations_template("src/gfx/arctic/sloped_foundations.png")
	}
}else if(param_foundations == TROPICAL) {
	replace (990, "src/gfx/tropical/foundations.png") {	foundations_template()	}
	replacenew(FOUNDATIONS_SLOPES_HALFTILES, "") {
		sloped_foundations_template("src/gfx/tropical/sloped_foundations.png")
	}
}else if(param_foundations == TOYLAND) {
	replace (990, "src/gfx/toyland/foundations.png") {	foundations_template()	}
	replacenew(FOUNDATIONS_SLOPES_HALFTILES, "") {
		sloped_foundations_template("src/gfx/toyland/sloped_foundations.png")
	}
}
I'm still thinking if put this as a separate release in case anyone wants to customize foundations or tunnels or just as part of a larger NewGRF I'm planning including some objects and other stuff. If anyone wants it as it is know let me know!
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 1 guest