NML NewObject TileCheck's, how to detect Farm land?

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
Aegir
Tycoon
Tycoon
Posts: 2884
Joined: 09 Feb 2004 10:02
Contact:

NML NewObject TileCheck's, how to detect Farm land?

Post by Aegir »

I think based off my own reading of the NML spec I've already answered my own question as a 'no' but I thought I'd throw it out there.

Currently I'm doing this:

Code: Select all

switch (FEAT_OBJECTS, SELF, switch_object_auto_build_rules,
			(terrain_type == TILETYPE_SNOW) ||
			(terrain_type == TILETYPE_DESERT) ||
			(nearby_tile_is_water( 0 , 0))
		) {
	1: return CB_RESULT_LOCATION_DISALLOW;
	return CB_RESULT_LOCATION_ALLOW;
}
with this:

Code: Select all

tile_check: switch_object_auto_build_rules;
hiding in the graphics{} block of each object to prevent some objects being built on snow, desert, or tiles directly adjacent the ocean. What I'd *really* love is to detect Farm Land and prevent construction on it too. I've already got "OBJ_FLAG_ANYTHING_REMOVE" set so in theory any farms being built after the fact should be able to clear the land easy-peasy, but these objects are all being generated at map gen time and are getting built after industries are already built and the newobjects are making swiss cheese of farms.

How do?

Thnx ❤️
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5602
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: NML NewObject TileCheck's, how to detect Farm land?

Post by PikkaBird »

You're right, you can't.

(Nor, IMO, would it make much sense to - farm fields have gaps of clear land between them, so your object might still end up in the middle of a farm even if it could avoid the actual field tiles. And farms regularly construct new fields, so a field might get built around your object even if there was no field there when the object was placed).
User avatar
2TallTyler
Route Supervisor
Route Supervisor
Posts: 502
Joined: 11 Aug 2019 18:15
Contact:

Re: NML NewObject TileCheck's, how to detect Farm land?

Post by 2TallTyler »

It would probably be relatively easy to add a tiletype for farm land (and perhaps include rough ground and rocks, perhaps as MP_ROUGH) and add the necessary NewGRF spec extensions for objects, houses, industries, etc.
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: NML NewObject TileCheck's, how to detect Farm land?

Post by Eddi »

no, you can't just add tiletypes like that. that's an integral part of the map array.

you need to distinguish rough ground, fields, etc. with the other bits from the map array, as documented in "docs/landscape.html", and check whether those are exposed to newgrfs
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 58 guests