Author: alink
Date: Thu May 1 22:41:40 2008
New Revision: 26293
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26293&view=rev
Log:
Resolve alias recursively and preserve arguments
This allow construcion like "alias u=unit; alias uhp=u hitpoints" and then
"uhp 100" gives 100 hp to the unit.
This also fix the alias+args broken in previous commit.
Modified:
trunk/src/menu_events.cpp
Modified: trunk/src/menu_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=26293&r1=26292&r2=26293&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Thu May 1 22:41:40 2008
@@ -1957,8 +1957,16 @@
init_map();
}
- std::string actual_cmd = get_actual_cmd(cmd);
- parse_cmd(actual_cmd);
+ // We recursively resolve alias (100 max to
avoid infinite recursion)
+ for (int i=0; i < 100; ++i) {
+ parse_cmd(cmd);
+ std::string actual_cmd =
get_actual_cmd(get_cmd());
+ if (actual_cmd == get_cmd())
+ break;
+ std::string data = get_data(1);
+ // translate the command and add space
+ data if any
+ cmd = actual_cmd + (data.empty() ? "" :
" ") + data;
+ }
if (get_cmd().empty()) {
return;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits