Author: sapient
Date: Mon Aug 18 07:18:59 2008
New Revision: 28695
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28695&view=rev
Log:
-fix the XP tracking code in tutorial scenario1
-fix a problem where the "advance" event was ignoring any unit modifications
-add some more logging to variable.cpp
Modified:
trunk/data/campaigns/tutorial/scenarios/1_Tutorial.cfg
trunk/src/actions.cpp
trunk/src/variable.cpp
Modified: trunk/data/campaigns/tutorial/scenarios/1_Tutorial.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/tutorial/scenarios/1_Tutorial.cfg?rev=28695&r1=28694&r2=28695&view=diff
==============================================================================
--- trunk/data/campaigns/tutorial/scenarios/1_Tutorial.cfg (original)
+++ trunk/data/campaigns/tutorial/scenarios/1_Tutorial.cfg Mon Aug 18 07:18:59
2008
@@ -1103,13 +1103,48 @@
name=advance
first_time_only=no
[store_unit]
- x,y=$x1,$y1
+ [filter]
+ x,y=$x1,$y1
+ [/filter]
variable=Unit
[/store_unit]
+# [message]
+# x,y=$x1,$y1
+# message="My previous experience is $Unit.variables.previous_xp
+# but it will soon be increased by $Unit.max_experience"
+# [/message]
{VARIABLE_OP Unit.variables.previous_xp add $Unit.max_experience}
[unstore_unit]
variable=Unit
advance=false
[/unstore_unit]
- [/event]
+# [store_unit]
+# [filter]
+# x,y=$x1,$y1
+# [/filter]
+# variable=Sanity
+# [/store_unit]
+# [message]
+# x,y=$x1,$y1
+# message="SANITY CHECK:
+# My previous experience is now $Sanity.variables.previous_xp"
+# [/message]
+ [/event]
+# [event]
+# name="post_advance"
+# first_time_only="no"
+# [message]
+# x,y=$x1,$y1
+# message="POST_ADVANCE:
+# my previous experience is $unit.variables.previous_xp"
+# [/message]
+# [/event]
+# [event]
+# name="moveto"
+# first_time_only="no"
+# [message]
+# x,y=$x1,$y1
+# message="My previous experience is $unit.variables.previous_xp"
+# [/message]
+# [/event]
[/tutorial]
Modified: trunk/src/actions.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.cpp?rev=28695&r1=28694&r2=28695&view=diff
==============================================================================
--- trunk/src/actions.cpp (original)
+++ trunk/src/actions.cpp Mon Aug 18 07:18:59 2008
@@ -825,7 +825,7 @@
// Fix pointers to weapons
if (a_ != units_.end())
const_cast<battle_context::unit_stats*>(a_stats_)->weapon =
&a_->second.attacks()[attack_with_];
-
+
if (d_ != units_.end())
const_cast<battle_context::unit_stats*>(d_stats_)->weapon =
&d_->second.attacks()[defend_with_];
return;
@@ -1111,7 +1111,7 @@
dat.add_child("second");
(*(dat.child("first")))["weapon"] =
d_stats_->weapon != NULL ? d_stats_->weapon->id() : "none";
(*(dat.child("second")))["weapon"] =
a_stats_->weapon != NULL ? a_stats_->weapon->id() : "none";
-
+
DELAY_END_LEVEL(delayed_exception,
game_events::fire("last breath", death_loc, attacker_loc, dat));
d_ = units_.find(death_loc);
@@ -1362,7 +1362,7 @@
game_events::entity_location defender_loc(d_);
const int attacker_side = a_->second.side();
fire_event("attack_end");
-
+
// get weapon info for last_breath and die
events
config dat;
dat.add_child("first");
@@ -1767,19 +1767,36 @@
void advance_unit(unit_map& units,
gamemap::location loc, const std::string& advance_to)
{
- if(units.count(loc) == 0) {
+ unit_map::unit_iterator u = units.find(loc);
+ if(!u.valid()) {
return;
}
+ LOG_NG << "firing advance event at " << loc <<"\n";
+
+/* config test; // REMOVE ME
+ u->second.write(test);
+ std::cerr << test;*/
+
+ game_events::fire("advance",loc);
+
+ if(!u.valid()) {
+ LOG_NG << "WML has invalidated the advancing unit, abort\n";
+ return;
+ }
+
+/* test.clear(); // REMOVE ME
+ u->second.write(test);
+ std::cerr << test;*/
+
+ loc = u->first;
const unit& new_unit = get_advanced_unit(units,loc,advance_to);
- LOG_NG << "firing advance event\n";
- game_events::fire("advance",loc);
statistics::advance_unit(new_unit);
preferences::encountered_units().insert(new_unit.type_id());
LOG_STREAM(info, config) << "Added '" << new_unit.type_id() << "' to
encountered units\n";
units.replace(new std::pair<gamemap::location,unit>(loc,new_unit));
- LOG_NG << "firing post_advance event\n";
+ LOG_NG << "firing post_advance event at " << loc << "\n";
game_events::fire("post_advance",loc);
}
Modified: trunk/src/variable.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/variable.cpp?rev=28695&r1=28694&r2=28695&view=diff
==============================================================================
--- trunk/src/variable.cpp (original)
+++ trunk/src/variable.cpp Mon Aug 18 07:18:59 2008
@@ -450,7 +450,7 @@
scoped_wml_variable::scoped_wml_variable(const std::string& var_name) :
previous_val_(),
- var_name_(var_name),
+ var_name_(var_name),
activated_(false)
{
repos->scoped_variables.push_back(this);
@@ -464,6 +464,7 @@
}
repos->clear_variable_cfg(var_name_);
repos->add_variable_cfg(var_name_, var_value);
+ LOG_NG << "scoped_wml_variable: var_name \"" << var_name_ << "\" has
been auto-stored.\n";
activated_ = true;
}
@@ -475,6 +476,7 @@
for(config::child_list::iterator j=old_val.begin(); j !=
old_val.end() ; j++){
repos->add_variable_cfg(var_name_,**j);
}
+ LOG_NG << "scoped_wml_variable: var_name \"" << var_name_ <<
"\" has been reverted.\n";
}
assert(repos->scoped_variables.back() == this);
repos->scoped_variables.pop_back();
@@ -488,6 +490,7 @@
itor->second.write(tmp_cfg);
tmp_cfg["x"] = lexical_cast<std::string,int>(x_ + 1);
tmp_cfg["y"] = lexical_cast<std::string,int>(y_ + 1);
+ LOG_NG << "auto-storing $" << name() << " at (" << x_ << ',' <<
y_ << ")\n";
store(tmp_cfg);
} else {
ERR_NG << "failed to auto-store $" << name() << " at (" << x_
<< ',' << y_ << ")\n";
@@ -503,6 +506,8 @@
player->available_units[recall_index_].write(tmp_cfg);
tmp_cfg["x"] = "recall";
tmp_cfg["y"] = "recall";
+ LOG_NG << "auto-storing $" << name() << " for player: "
<< player_
+ << " at recall index: " << recall_index_ <<
'\n';
store(tmp_cfg);
} else {
ERR_NG << "failed to auto-store $" << name() << " for
player: " << player_
@@ -539,13 +544,13 @@
}
} // end anonymous namespace
-variable_info::variable_info(const std::string& varname,
+variable_info::variable_info(const std::string& varname,
bool force_valid, TYPE validation_type) :
- vartype(validation_type),
- is_valid(false),
+ vartype(validation_type),
+ is_valid(false),
key(),
- explicit_index(false),
- index(0),
+ explicit_index(false),
+ index(0),
vars(NULL)
{
assert(repos != NULL);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits