I think since you are working on that part of code already you would be the best one to do it, to merge it with your own build and then it will consequently be merged with the main trunk with all the rest of it.
Here is what I did to make shelters have both the basement and two upper floors. I think it should be fairly easy to generalize the whole thing based on this “template”, expand for other buildings and combine with your own code.
1.) overmap.h
2.) overmap.h
[code]enum oter_id {
.
.
.
ot_sky, ot_shelter_over, ot_shelter_over2,
ot_tutorial,
num_ter_types
};[/code]
- overmap.h
[code]const oter_t oterlist[num_ter_types] = {
.
.
.
- {“evac shelter”, ‘+’, c_white, 2, no_extras, true, false},
- {“evac shelter”, ‘+’, c_white, 2, no_extras, true, true},
.
.
.
{“sky”, ‘8’, c_ltcyan, 2, no_extras, false, false},
{“evac shelter”, ‘+’, c_white, 2, no_extras, true, true}, //shelter z= 1
{“evac shelter”, ‘+’, c_white, 2, no_extras, true, false}, //shelte z= 2
{“tutorial room”, ‘O’, c_cyan, 5, no_extras, false, false}
};
[/code]
4.) overmap.cpp
[code]void overmap::init_layers()
{
layer = new map_layer[OVERMAP_LAYERS];
for(int z = 0; z < OVERMAP_LAYERS; ++z) {
oter_id default_type = (z < OVERMAP_DEPTH) ? ot_rock : ot_field;
if(z > OVERMAP_DEPTH)
default_type= ot_sky;
for(int i = 0; i < OMAPX; ++i) {
for(int j = 0; j < OMAPY; ++j) {
layer[z].terrain[i][j] = default_type;
layer[z].visible[i][j] = false;
}
}
}
}[/code]
- overmap.cpp
[code]bool overmap::generate_sub(int const z)
{
.
.
.
- else if (ter(i, j, z + 1) == ot_shelter)
- else if (ter(i, j, 0) == ot_shelter)
shelter_points.push_back( point(i, j) );
.
.
.
for (int i = 0; i < shelter_points.size(); i++)
{
if(z == -1)
{
ter(shelter_points[i].x, shelter_points[i].y, z) = ot_shelter_under;
requires_sub = true;
}
else
if(z == -2)
{
ter(shelter_points[i].x, shelter_points[i].y, 1) = ot_shelter_over; // z= 1
requires_sub = true;
}
else
if(z == -3)
ter(shelter_points[i].x, shelter_points[i].y, 2) = ot_shelter_over2; // z= 2
}[/code]
- mapdata.h
[code]enum ter_id {
.
.
.
t_air,
num_terrain_types
};
[/code]
- mapdata.h
const ter_t terlist[num_terrain_types] = {
.
.
.
{"bunch of air", '.', c_ltcyan, 2, tr_airhole,
mfb(transparent)}
};
- mapgen.h
[code]void map::draw_map
.
.
.
case ot_sky:
for (int i = 0; i < SEEX * 2; i++) {
for (int j = 0; j < SEEY * 2; j++) {
ter(i, j) = t_air;
}
}
break;
case ot_shelter_over:
{
for (int i = 0; i < SEEX2; i++) {
for (int j = 0; j < SEEY2; j++)
ter(i, j) = t_air;
}
square(this, t_floor_red, 0, 0, 5, 2);
line(this, t_wall_h, 1, 0, 2, 0);
line(this, t_wall_h, 1, 2, 2, 2);
line(this, t_wall_v, 0, 0, 0, 2);
line(this, t_wall_v, 2, 2, 2, 0);
ter(2, 1) = t_door_locked;
ter(1, 1) = t_stairs_up;
square(this, t_floor, 4, 4, SEEX * 2 - 5, SEEY * 2 - 5);
line(this, t_wall_h, 4, 4, SEEX * 2 - 5, 4);
line(this, t_wall_h, 4, SEEY * 2 - 5, SEEX * 2 - 5, SEEY * 2 - 5);
line(this, t_pavement, SEEX+4, 3, SEEX * 2 - 4, 3);
line(this, t_pavement, SEEX * 2 - 4, 4, SEEX * 2 - 4, 11);
line(this, t_pavement, SEEX * 2 - 4, 14, SEEX * 2 - 4, 19);
line(this, t_pavement, SEEX * 2 - 5, SEEY * 2 - 4, SEEX+1, SEEY * 2 - 4);
line(this, t_pavement, SEEX-3, SEEY * 2 - 4, 3, 20);
line(this, t_sidewalk, 3, 19, 3, 15);
line(this, t_sidewalk, 3, 10, 3, 5);
line(this, t_wall_v, 4, 5, 4, SEEY * 2 - 6);
line(this, t_wall_v, 7, 5, 7, SEEY * 2 - 6);
line(this, t_wall_v, SEEX * 2 - 5, 5, SEEX * 2 - 5, SEEY * 2 - 6);
line(this, t_wall_v, SEEX * 2 - 8, 5, SEEX * 2 - 8, SEEY * 2 - 6);
ter(16, 11) = t_door_c;
ter(15, 13) = t_bookcase;
ter(15, 14) = t_rack;
ter(15, 14) = t_locker;
ter(15, 9) = t_table;
ter(15, 5) = t_dresser;
ter(8, 7) = t_dresser;
ter(7, 11) = t_door_c;
ter(8, 10) = t_locker;
ter(8, 11) = t_bookcase;
ter(8, 12) = t_bookcase;
ter(8, 18) = t_chair;
ter(9, 12) = t_crate_c;
ter(11, 18) = t_locker;
ter(12,18) = t_bookcase;
ter(SEEX+2, 4) = t_curtains;
ter(SEEX+3, 4) = t_curtains;
ter(SEEX-4, 4) = t_curtains;
ter(SEEX-3, 4) = t_window_domestic;
ter(5, 17) = t_stairs_up;
ter(15, 18) = t_stairs_down;
add_graffiti(g, 14, 15, "I write this message...\n\
with my own blood...\n\
if you want to jump...\n\
...try pressing SHIFT+X.");
add_item(5, 5, g->itypes[itm_mp3], 0);
add_item(17, 18, g->itypes[itm_crowbar], 0);
}
break;
case ot_shelter_over2:
{
// Init to air;
for (int i = 0; i < SEEX2; i++) {
for (int j = 0; j < SEEY2; j++)
ter(i, j) = t_air;
}
square(this, t_pavement, 0, 0, 2, 2);
ter(0, 1) = t_stairs_down;
square(this, t_pavement, 4, 4, SEEX * 2 - 5, SEEY * 2 - 5);
ter(5, 18) = t_stairs_down;
add_item(14+rng(-2,2), 14+rng(-2,2), g->itypes[itm_law_packed], 0);
for(int i= 0; i < 5; i++)
add_item(14+rng(-2,2), 14+rng(-2,2), g->itypes[itm_66mm_HEAT], 0);
}
break;[/code]
- trap.h
[code]enum trap_id {
.
.
.
tr_airhole,
num_trap_types
};
struct trapfunc {
.
.
.
void airhole (game *g, int x, int y);
};
struct trapfuncm {
.
.
.
void airhole(game *g, monster *z, int x, int y);
};[/code]
- trapdef.cpp
void game::init_traps()
{
.
.
.
TRAP("airhole", '.', c_ltcyan, 0, 99, 99,
&trapfunc::airhole, &trapfuncm::airhole,
itm_null, NULL);
}
- trapfunc.cpp
[code]void trapfunc::airhole(game *g, int x, int y)
{
g->add_msg(“You fall down a level!”);
g->vertical_move(-1, true);
}
void trapfuncm::airhole(game *g, monster *z, int x, int y)
{
g->add_msg(“The %s falls down a level!”, z->name().c_str());
g->kill_mon(g->mon_at(x, y));
}[/code]
There, easy! Let me know if anything is unclear or needs further explanation.