Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old March 28, 2020, 14:13   #1
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,299
wobbly is on a distinguished road
Kennels and Other Rooms

This is a dog kennel from fcpb:

Code:
N:Kennel
T:ROOM:NORMAL
W:10:*:4
L:C:MON(HOUND, DEPTH+5)
M:%%%%%%%%%%%%%%%%%%%%%
M:%...................%
M:%.#################.%
M:%.#C#C#C#C#C#C#C#C#.%
M:%.#+#+#+#+#+#+#+#+#.%
M:%.+...............#.%
M:%.#+#+#+#+#+#+#+#+#.%
M:%.#C#C#C#C#C#C#C#C#.%
M:%.#################.%
M:%...................%
M:%%%%%%%%%%%%%%%%%%%%%
and straight away I notice this is easy enough to do with a build_kennel instead. The advantage being that it wouldn't always be 16 dogs, it could be random x dogs, random x serpents or random x basilisks.

These are room stacks, they actually go up to 6:

Code:
N:Room Stack I
T:ROOM:NORMAL
W:20:*:2
L:M:MON(*, DEPTH+5)
L:$:OBJ(*)
M:%%%%%%%%%%%%%%%%%%%%%%%%%
M:%.......................%
M:%.#####################.%
M:%.#......M..#..M......#.%
M:%.+.....M..$#$..M.....+.%
M:%.#......M..#..M......#.%
M:%.#####################.%
M:%.......................%
M:%%%%%%%%%%%%%%%%%%%%%%%%%

N:Room Stack II
T:ROOM:NORMAL
W:20:*:4
L:M:MON(*, DEPTH+5)
L:$:OBJ(*)
M:%%%%%%%%%%%%%%%%%%%%%%%%%
M:%.......................%
M:%.+###################+.%
M:%.#......M..#..M......#.%
M:%.#......M.$#$.M......#.%
M:%.#####################.%
M:%.#......M.$#$.M......#.%
M:%.#......M..#..M......#.%
M:%.+###################+.%
M:%.......................%
M:%%%%%%%%%%%%%%%%%%%%%%%%%
Again these are simple symmetrical building that could be done with a builder. all 6 could be done with 1 builder. The kennel could be done with the same builder, though there it would be 1 builder with 2 parts (which seems to lose more then it gains compared to 2 separate builders).

Anyway I'm curious if anyone has any thoughts on:
  • Which rooms are better done with builders & which with prefabs
  • How many versions to cram into 1 builder
  • anything else

I plan to do the kennel for the reasons above, the rest I'm putting off till I decide whether it's worth it.
wobbly is offline   Reply With Quote
Old April 3, 2020, 01:06   #2
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,299
wobbly is on a distinguished road
Turns out kennels are tricky if you want different layouts & orientations. I'm not sure if this is right:

Code:
/**
 * Build cells on the north wall.
 * \param c the current chunk
 * \param x1 inclusive room boundaries
 * \param x2 inclusive room boundaries
 * \param y1 inclusive room boundaries
 * \param y2 inclusive room boundaries
 * \param flag the SQUARE_* flag we are marking with
 */
static void cells_n(struct chunk *c, int x1, int x2, int y1, int y2, int flag)
{
	fill_xrange(c, y2, x1, x2, FEAT_GRANITE, flag, false);
	fill_yrange(c, x1, y1, y2, FEAT_GRANITE, flag, false);
	fill_yrange(c, x2, y1, y2, FEAT_GRANITE, flag, false);
	int x, y;
	for (y = y1; y <= y2 - 1; y++) {
		for (x = x1 + 2; x <= x2 - 2; x += 2) {
			struct loc grid = loc(x, y);
			square_set_feat(c, grid, FEAT_GRANITE);
			sqinfo_on(square(c, grid).info, SQUARE_WALL_INNER);
		}
	}
	for (x = x1 + 1; x <= x2 - 1; x += 2) {
		struct loc grid = loc(x, y1);
		square_set_feat(c, grid, FEAT_CLOSED);
	}
}
Will it spit the dummy about struct loc grid appearing in both loops? Do I declare it outside & set the y co-ordinate inside?
wobbly is offline   Reply With Quote
Old April 3, 2020, 02:49   #3
backwardsEric
Apprentice
 
Join Date: Aug 2019
Posts: 62
backwardsEric is on a distinguished road
Quote:
Originally Posted by wobbly View Post
Will it spit the dummy about struct loc grid appearing in both loops? Do I declare it outside & set the y co-ordinate inside?
Since those declarations are in separate blocks, they won't clash.

Declarations within the for() statement itself,
Code:
for (int i = ....)
, are a C99 feature and have always been allowed in C++. I don't know the scoping rules for those in C (whether such a declaration is also visible to the block containing the for loop or if it's only visible within the for loop). For C++, they are limited to the for loop, though I vaguely recall a period of time where some common compilers didn't handle that properly.
backwardsEric is offline   Reply With Quote
Old April 4, 2020, 05:30   #4
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,299
wobbly is on a distinguished road
Thanks. A lot of this stuff is still confusing to me. I had to go through a bunch of my code & fix some randint0s because I'd messed up. Apparently Randint0(1) is 0 <= x < 1 rather then 0 - 1. Glad I found that out before getting much further. Anway it's working, at least as far as building the rooms, still need to place the occupants. Currently its handling the different layouts with a bunch of if/else & I notice elsewhere in the code its using switch instead. Is there an advantage to switch? Or is this about readability?

Last edited by wobbly; April 4, 2020 at 05:56.
wobbly is offline   Reply With Quote
Old April 4, 2020, 21:08   #5
backwardsEric
Apprentice
 
Join Date: Aug 2019
Posts: 62
backwardsEric is on a distinguished road
Quote:
Originally Posted by wobbly View Post
Currently its handling the different layouts with a bunch of if/else & I notice elsewhere in the code its using switch instead. Is there an advantage to switch? Or is this about readability?
For me, the primary concern would be readability, and I prefer a switch statement in the cases where it's most applicable: testing a single integer value for whether it falls in one of several categories that don't overlap. It does have the disadvantage that the compiler won't catch the error of leaving out the break statement between cases that are to be treated separately. With the if/else construct, the compiler readily notices the equivalent error of omitting a brace.

Both will be awkward with enough separate cases.
backwardsEric is offline   Reply With Quote
Old April 5, 2020, 15:48   #6
fph
Knight
 
Join Date: Apr 2009
Location: Pisa / DL0
Posts: 877
fph is on a distinguished road
Quote:
Originally Posted by backwardsEric View Post
the compiler won't catch the error of leaving out the break statement between cases that are to be treated separately. With the if/else construct, the compiler readily notices the equivalent error of omitting a brace.
Isn't there a compiler warning that can be enabled to catch this? At least in GCC.
__________________
Dive fast, die young, leave a high-CHA corpse.
--
You read a scroll labeled 'lol gtfo' of Teleport Level.
fph is offline   Reply With Quote
Old April 6, 2020, 15:50   #7
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,299
wobbly is on a distinguished road
Thanks again! Yeah I suspect what ever I do it's going to end up a long list of cases just because it's got a type & an orientation.

Code:
	} else if (t == 3) {
		if (o == 0 ) {
			cells_n(c, x1 - 1, x2 + 1, y2 - 1, y2 + 1, SQUARE_WALL_SOLID);
			cells_s(c, x1 - 1, x2 + 1, y1 - 1, y1 + 1, SQUARE_WALL_SOLID);
			cells_e(c, x1 + 1, x1 + 3, y1 + 3, y2 - 3, SQUARE_WALL_INNER);
			cells_w(c, x2 - 3, x2 - 1, y1 + 3, y2 - 3, SQUARE_WALL_INNER);
			
			cells_monsters_xrange(c, y2, x1, x2, depth, race, zoo);
			cells_monsters_xrange(c, y1, x1, x2, depth, race, zoo);
			cells_monsters_yrange(c, x1 + 2, y1 + 4, y2 - 4, depth, race, zoo);
			cells_monsters_yrange(c, x2 - 2, y1 + 4, y2 - 4, depth, race, zoo);
			
		} else {
			cells_w(c, x1 - 1, x1 + 1, y1 - 1, y2 + 1, SQUARE_WALL_SOLID);
			cells_e(c, x2 - 1, x2 + 1, y1 - 1, y2 + 1, SQUARE_WALL_SOLID);
			cells_n(c, x1 + 3, x2 - 3, y1 + 1, y1 + 3, SQUARE_WALL_INNER);
			cells_s(c, x1 + 3, x2 - 3, y2 - 3, y2 - 1, SQUARE_WALL_INNER);
			
			cells_monsters_yrange(c, x1, y1, y2, depth, race, zoo);
			cells_monsters_yrange(c, x2, y1, y2, depth, race, zoo);
			cells_monsters_xrange(c, y1 + 2, x1 + 4, x2 - 4, depth, race, zoo);
			cells_monsters_xrange(c, y2 - 2, x1 + 4, x2 - 4, depth, race, zoo);			
		}
That shouldn't be too bad though? Place 4 rows of cells, fill 4 rows of cells.
wobbly is offline   Reply With Quote
Old April 6, 2020, 16:06   #8
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,698
Donated: $40
Pete Mack is on a distinguished road
I disagree with this design. You are breaking code/configuration separation for no apparent reason.
Pete Mack is offline   Reply With Quote
Old April 6, 2020, 16:18   #9
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,299
wobbly is on a distinguished road
Well I can potentially rearrange it, but I'm not sure what you actually mean.
wobbly is offline   Reply With Quote
Old April 6, 2020, 17:51   #10
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 9,023
Derakon is on a distinguished road
Quote:
Originally Posted by wobbly View Post
Well I can potentially rearrange it, but I'm not sure what you actually mean.
By baking the design of the rooms into the code, you're making it so nobody can change this bit of game content without having a full development environment set up. Much of Angband development over the long haul has been moving things out of code and into resource files, to make them more accessible and easier to modify.

I can see the appeal of "these rooms are all just variations on each other, we could have a generator that produces the variations", but then you want to be exposing, like, some kind of configuration for the generator so people can still modify its behavior without recompiling. And that all starts to sound like it gets complicated fast...
Derakon is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding color rooms to Angband droof Vanilla 63 April 8, 2020 10:07
Comments on themed level gen part 1 - interesting rooms wobbly Vanilla 9 November 8, 2018 21:30
Angband color rooms t4nk Development 3 December 10, 2016 01:36
Why I love Ironman rooms Therem Harth AAR 0 April 18, 2012 03:02
In what order to explore rooms fph Vanilla 5 December 7, 2010 17:10


All times are GMT +1. The time now is 19:12.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.