Industries placement / Slopes.

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

Moderator: Graphics Moderators

Post Reply
temporal8
Route Supervisor
Route Supervisor
Posts: 430
Joined: 17 May 2019 14:15

Industries placement / Slopes.

Post by temporal8 »

Hi, I'm fixing bugs before releasing Real Industries beta 2, how can I fix this?

I tried but what I did does not work, my code is wrong.

Code: Select all

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_flat_check4, nearby_tile_slope(0,1) == SLOPE_FLAT) { 1: return CB_RESULT_LOCATION_DISALLOW; return CB_RESULT_LOCATION_ALLOW; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_flat_check3, nearby_tile_slope(0,-1) == SLOPE_FLAT) { 1: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_flat_check4; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_flat_check2, nearby_tile_slope(1, 0) == SLOPE_FLAT) { 1: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_flat_check3; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_flat_check1, nearby_tile_slope(-1, 0) == SLOPE_FLAT) { 1: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_flat_check2; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_road_adjacent_4, nearby_tile_class(-1, 0)) { TILE_CLASS_ROAD: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_flat_check1; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_road_adjacent_3, nearby_tile_class(0, -1)) { TILE_CLASS_ROAD: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_road_adjacent_4; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_road_adjacent_2, nearby_tile_class(1, 0)) { TILE_CLASS_ROAD: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_road_adjacent_3; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_road_adjacent_1, nearby_tile_class(0, 1)) { TILE_CLASS_ROAD: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_road_adjacent_2; }
switch (FEAT_INDUSTRYTILES, PARENT, bistro01_terrain_check, ( (((extra_callback_info2 & 0xFF00) >> 8) == IND_CREATION_FUND) || (((extra_callback_info2 & 0xFF00) >> 8) == IND_CREATION_PROSPECT) ) ) { 1: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_road_adjacent_1; }
Image
Attachments
bistro_overlay.png
(2.1 MiB) Not downloaded yet
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Industries placement / Slopes.

Post by Eddi »

you could either check the nearby tile height and try to add offsets and foundations, or check the tile height/slope situation in the construction callback to prevent these locations from ever appearing
temporal8
Route Supervisor
Route Supervisor
Posts: 430
Joined: 17 May 2019 14:15

Re: Industries placement / Slopes.

Post by temporal8 »

Although the code is not elegant, I don't understand why it doesn't work.

Code: Select all

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_flat_check, nearby_tile_slope(0, 0) == SLOPE_FLAT) { 1: return CB_RESULT_LOCATION_ALLOW; return CB_RESULT_LOCATION_DISALLOW;   }

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check23, nearby_tile_slope(0,1) & bitmask(CORNER_N, CORNER_E)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_flat_check;  }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check22, nearby_tile_slope(1,0) & bitmask(CORNER_N, CORNER_E)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check23; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check21, nearby_tile_slope(0,0) & bitmask(CORNER_N, CORNER_E)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check22;  }

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check20, nearby_tile_slope(0,1) & bitmask(CORNER_S, CORNER_E)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check21;  }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check19, nearby_tile_slope(1,0) & bitmask(CORNER_S, CORNER_E)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check20; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check18, nearby_tile_slope(0,0) & bitmask(CORNER_S, CORNER_E)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check19;  }

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check17, nearby_tile_slope(0,1) & bitmask(CORNER_S, CORNER_W)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check18;  }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check16, nearby_tile_slope(1,0) & bitmask(CORNER_S, CORNER_W)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check17; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check15, nearby_tile_slope(0,0) & bitmask(CORNER_S, CORNER_W)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check16;  }

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check14, nearby_tile_slope(0,1) & bitmask(CORNER_N, CORNER_W)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check15;  }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check13, nearby_tile_slope(1,0) & bitmask(CORNER_N, CORNER_W)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check14; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check12, nearby_tile_slope(0,0) & bitmask(CORNER_N, CORNER_W)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check13;  }

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check11, nearby_tile_slope(0,1) & bitmask(CORNER_N)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check12;  }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check10, nearby_tile_slope(1,0) & bitmask(CORNER_N)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check11; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check9, nearby_tile_slope(0,0) & bitmask(CORNER_N)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check10;  }

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check8, nearby_tile_slope(0,1) & bitmask(CORNER_E)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check9;  }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check7, nearby_tile_slope(1,0) & bitmask(CORNER_E)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check8; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check6, nearby_tile_slope(0,0) & bitmask(CORNER_E)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check7;  }

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check5, nearby_tile_slope(0,1) & bitmask(CORNER_S)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check6;  }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check4, nearby_tile_slope(1,0) & bitmask(CORNER_S)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check5; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check3, nearby_tile_slope(0,0) & bitmask(CORNER_S)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check4;  }

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check2, nearby_tile_slope(0,1) & bitmask(CORNER_W)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check3;  }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check1, nearby_tile_slope(1,0) & bitmask(CORNER_W)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check2; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_slope_check, nearby_tile_slope(0,0) & bitmask(CORNER_W)) { 1: return CB_RESULT_LOCATION_DISALLOW; bistro01_tile_slope_check1;  }

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_road_adjacent_4, nearby_tile_class(-1, 0)) { TILE_CLASS_ROAD: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_slope_check; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_road_adjacent_3, nearby_tile_class(0, -1)) { TILE_CLASS_ROAD: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_road_adjacent_4; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_road_adjacent_2, nearby_tile_class(1, 0)) { TILE_CLASS_ROAD: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_road_adjacent_3; }
switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_road_adjacent_1, nearby_tile_class(0, 1)) { TILE_CLASS_ROAD: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_road_adjacent_2; }
switch (FEAT_INDUSTRYTILES, PARENT, bistro01_terrain_check, ( (((extra_callback_info2 & 0xFF00) >> 8) == IND_CREATION_FUND) || (((extra_callback_info2 & 0xFF00) >> 8) == IND_CREATION_PROSPECT) ) ) { 1: return CB_RESULT_LOCATION_ALLOW; bistro01_tile_road_adjacent_1; }

item(FEAT_INDUSTRYTILES, bistro01_tile, 123) {
 property {
  substitute: 0;
  land_shape_flags: bitmask(LSF_ONLY_ON_FLAT_LAND);
  animation_triggers: bitmask(ANIM_TRIGGER_INDTILE_CONSTRUCTION_STATE);
  special_flags: bitmask(INDTILE_FLAG_ACCEPT_ALL);
 }

 graphics {
  tile_check: bistro01_terrain_check;
  bistro01_tile_fences;
 }
}
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Industries placement / Slopes.

Post by Eddi »

i'd try a simple case, like only flat tiles, and building more complex checks on top of that. checking whether it works each time.
temporal8
Route Supervisor
Route Supervisor
Posts: 430
Joined: 17 May 2019 14:15

Re: Industries placement / Slopes.

Post by temporal8 »

Thanks Eddi, i solved in this way finally:

Code: Select all

switch (FEAT_INDUSTRYTILES, SELF, bistro01_tile_flat_check,
            nearby_tile_slope(0, 0) == SLOPE_FLAT  && 
            nearby_tile_slope(0, 1) == SLOPE_FLAT  && 
            nearby_tile_slope(1, 0) == SLOPE_FLAT  && 
            nearby_tile_slope(0, -1) == SLOPE_FLAT  && 
            nearby_tile_slope(-1, 0) == SLOPE_FLAT  ) { 
            1: return CB_RESULT_LOCATION_ALLOW; 
            return 0;   
            }

It's not ideal, but it does the job, thanks again.
Real Projects 32bpp releases:

Real Semi Trucks 32bpp: viewtopic.php?t=90996
Real Houses Eyecandy Objects 32bp: viewtopic.php?t=90767
Real Ships 32bpp: viewtopic.php?t=90733
Real Industries 32bpp: viewtopic.php?t=90183
Real Houses Townset 32bp: viewtopic.php?p=1254605
Real Stations 32bpp: viewtopic.php?p=1255635
Real Cars 32bpp: viewtopic.php?p=1249244
Real Vehicles 32bpp: viewtopic.php?p=1253581
Real Bus 32bpp: viewtopic.php?p=1249245
Real Trucks 32bpp: viewtopic.php?p=1254468
Real Parks 32bpp: viewtopic.php?p=1250255
Argentina World Cup 2022 Champions Bus 32bpp viewtopic.php?p=1257026
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 18 guests