fixed a missing bit of code in the vconfig constructor

added a more advanced [insert_tag] usage to scenario-test.cfg

(right click on the Elvish Avenger to test it)
This commit is contained in:
Patrick Parker 2008-04-22 03:13:28 +00:00
parent caf3ee4a96
commit 73a5b58d18
2 changed files with 90 additions and 2 deletions

View File

@ -191,6 +191,7 @@ Xu ,Xu , Qxu , Qxu , Ql , Ql
[unit]
x,y=4,8
type="Elvish Avenger"
id=statue
generate_description=yes
hitpoints=4
[status]
@ -834,6 +835,87 @@ _s, _s, _s, _s, Aa, Aa, _s, _s, _s, _s
{CLEAR_VARIABLE temp_villages_area}
[/event]
#define DYNAMIC_EVENT_SETUP TYPE VAR
[set_variables]
name={VAR}
[literal]
name={TYPE}
[set_variable]
name={VAR}
add=1
[/set_variable]
[message]
id=statue
message="dynamic " + {TYPE} + " event ${VAR}|!"
[option]
message="Continue!"
[/option]
[option]
message="Stop annoying me..."
[command]
[set_variables]
name={VAR}
mode=replace
[value]
name=moveto
[filter]
side=1
[filter_location]
radius=1
[filter]
id=statue
[/filter]
[/filter_location]
[/filter]
[message]
id=statue
message="No more dynamic events! Sorry..."
[/message]
[/value]
[/set_variables]
{MODIFY_UNIT id=statue status.stoned true}
[/command]
[/option]
[/message]
[insert_tag]
name=event
variable={VAR}
[/insert_tag]
[/literal]
[/set_variables]
#enddef
[event]
name=prestart
[set_menu_item]
id=dynamic_ev
description="Start Dynamic Events!"
[filter_location]
[filter]
id=statue
[/filter]
[/filter_location]
[command]
{DYNAMIC_EVENT_SETUP "new turn" ev}
[insert_tag]
name=event
variable=ev
[/insert_tag]
[set_menu_item]
id=dynamic_ev
[show_if]
[not]
[/not]
[/show_if]
[/set_menu_item]
[unstone]
id=statue
[/unstone]
[/command]
[/set_menu_item]
[/event]
[/test]
# vim: tabstop=4: shiftwidth=4: expandtab: softtabstop=4: autoindent:

View File

@ -135,7 +135,9 @@ static void decrement_config_usage(const config* key) {
if(config_cache.empty()) {
hash_memory.clear();
} else {
if(!hash_to_cache.empty()) {
hash_to_cache.erase(get_hash_of(key));
}
config_hashes.erase(key);
}
delete key;
@ -151,6 +153,10 @@ vconfig::vconfig(const config* cfg, const config * cache_key) :
cfg_(cfg), cache_key_(cache_key)
{
increment_config_usage(cache_key_);
if(cache_key_ != cache_key) {
//location of volatile cfg has moved
cfg_ = cache_key_;
}
}
vconfig::vconfig(const vconfig& v) :