Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old December 8, 2016, 23:47   #1
t4nk
Swordsman
 
Join Date: May 2016
Posts: 263
t4nk is on a distinguished road
Angband color rooms

Too much C for main forum! I think it belongs here.

Quote:
Originally Posted by droof View Post
I tried changing the room templates from level 5 to 1 in dungeon_profile.txt, but that change also doesn't trigger the function. So to test this, I need to dive to level 5 and use words of recall?
Yes, they start on level 5 (this is actually in dungeon_profile.txt, see "room:room template:" lines).
Of course, you shoudn't use words of recall Press Ctrl-A, that enables debug commands. Some useful commands: 'A' - get max experience (so your @ becomes level 50); 'j' - jump to some level, 'w' - reveal whole level (like with scroll of magic map).

Quote:
From what little I understand from the code, each terrain type has a terrain index from terrain.txt and a color index from z-color. Terrain bits from build_room_template() are set through square_set_feat(). This sets the appropriate terrain feature to a chunk / cave x y coordinate.
Right (except it's y, x coordinate instead of x, y! good source of bugs ) So you'll need to implement square_set_color(), which should be similar to square_set_feat(), but for colors.

Quote:
And this information somehow ends up in grid_data_as_text() where the color of the feature type is displayed.
When the core wants to update something on the map, it calls square_light_spot(); that tells the ui that a grid shoud be redrawn. The ui then calls map_info(), that fills struct grid_data with all information that a player is allowed to know. grid_data_as_text() then translates grid_data to text (or to tiles).

Quote:
To color room templates, maybe I can pass along the color_map color with the feature index in build_room_template() and store both at the cave square coordinate. Is this what you meant with the additional attribute for cave.h:132, t4nk?
So struct square (in cave.h) looks like this:
Code:
struct square {
	byte feat;
	bitflag *info;
	byte noise;
	byte scent;
	s16b mon;
	struct object *obj;
	struct trap *trap;
};
I suggest to add another field to it:
Code:
struct square {
    byte feat;
    byte color;
   /* and all other stuff... */
And initialize color field much like how feat is initialized (functions in cave-square.c). Roughly:
Code:
void square_set_color(struct chunk *c, int y, int x, byte color)
{
    assert(square_in_bounds(c, y, x));
    c->squares[y][x].color = color;
}
Then just call square_set_color() when appropriate in room builder.

Quote:
But grid_data_as_text() doesn't have current square coordinates or the cave object to look up and overrule the feature color for display.
See ui-map.c:
Code:
    /* Determine what is there */
    map_info(y, x, &g);
    grid_data_as_text(&g, &a, &c, &ta, &tc);
    Term_queue_char(t, vx, vy, a, c, ta, tc);
The Term stuff then passes characters and their colors to a frontend, e.g., to ncurses client.
t4nk is offline   Reply With Quote
 


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 61 December 11, 2016 13:08
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
Color prefs Pete Mack Vanilla 4 January 25, 2010 19:33
3.1.0 beta - minor bug? - green lit floor tiles in prelit rooms vorondil Vanilla 2 January 8, 2009 18:12


All times are GMT +1. The time now is 18:08.


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