new key store_location_as= to store generated chamber item locations

This commit is contained in:
Patrick Parker 2007-08-10 02:45:35 +00:00
parent acb97a77a8
commit 0d8b1daba8
2 changed files with 23 additions and 9 deletions

View File

@ -67,6 +67,7 @@ Version 1.3.6+svn:
* new extra_defines= key to define in campaigns some other preprocessor
symbol *before* the files are repreprocessed
* fog and shroud tiles are now defined by the TerrainWML (not [game_config])
* new key store_location_as= to store generated chamber item locations
* team color
* allow color ranges to be defined on-the-fly (like color palettes)
* now [side] colour=<string> is valid (previously only int)

View File

@ -228,29 +228,31 @@ void cave_map_generator::place_items(const chamber& c, config::all_children_iter
if(!utils::string_bool(cfg["same_location_as_previous"])) {
index = rand()%c.locs.size();
}
const std::string loc_var = cfg["store_location_as"];
std::set<gamemap::location>::const_iterator loc = c.locs.begin();
std::advance(loc,index);
char buf[50];
snprintf(buf,sizeof(buf),"%d",loc->x+1);
cfg.values["x"] = buf;
char xbuf[50];
snprintf(xbuf,sizeof(xbuf),"%d",loc->x+1);
cfg.values["x"] = xbuf;
if(filter != NULL) {
(*filter)["x"] = buf;
(*filter)["x"] = xbuf;
}
if(object_filter != NULL) {
(*object_filter)["x"] = buf;
(*object_filter)["x"] = xbuf;
}
snprintf(buf,sizeof(buf),"%d",loc->y+1);
cfg.values["y"] = buf;
char ybuf[50];
snprintf(ybuf,sizeof(ybuf),"%d",loc->y+1);
cfg.values["y"] = ybuf;
if(filter != NULL) {
(*filter)["y"] = buf;
(*filter)["y"] = ybuf;
}
if(object_filter != NULL) {
(*object_filter)["y"] = buf;
(*object_filter)["y"] = ybuf;
}
//if this is a side, place a castle for the side
@ -260,6 +262,17 @@ void cave_map_generator::place_items(const chamber& c, config::all_children_iter
res_.add_child(key,cfg);
if(!loc_var.empty()) {
config &temp = res_.add_child("event");
temp["name"] = "prestart";
config &xcfg = temp.add_child("set_variable");
xcfg["name"] = loc_var + "_x";
xcfg["value"] = xbuf;
config &ycfg = temp.add_child("set_variable");
ycfg["name"] = loc_var + "_y";
ycfg["value"] = ybuf;
}
++i1;
}
}