[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src game_events.cpp
From: |
Isaac Clerencia |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src game_events.cpp |
Date: |
Wed, 25 Aug 2004 19:56:21 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Isaac Clerencia <address@hidden> 04/08/25 23:51:36
Modified files:
src : game_events.cpp
Log message:
Added "automatic path search" to [move_unit_fake], partially applies
patch 3415, partially includes my own (sometimes buggy) code.
Now [move_unit_fake] supports moving between non adjacent tiles, looking
automatically for the shortest path. It needs a parameter
side=<unit_side>
but it uses side=1 by default so it shouldn't break any of the existing
scenarios using [move_unit_fake]
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game_events.cpp.diff?tr1=1.98&tr2=1.99&r1=text&r2=text
Patches:
Index: wesnoth/src/game_events.cpp
diff -u wesnoth/src/game_events.cpp:1.98 wesnoth/src/game_events.cpp:1.99
--- wesnoth/src/game_events.cpp:1.98 Wed Aug 25 02:59:51 2004
+++ wesnoth/src/game_events.cpp Wed Aug 25 23:51:35 2004
@@ -1,4 +1,4 @@
-/* $Id: game_events.cpp,v 1.98 2004/08/25 02:59:51 Sirp Exp $ */
+/* $Id: game_events.cpp,v 1.99 2004/08/25 23:51:35 isaaccp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -435,6 +435,10 @@
//the visual effect
else if(cmd == "move_unit_fake") {
const std::string& type = cfg["type"];
+ const std::string& side = cfg["side"];
+ int side_num = atoi(side.c_str())-1;
+ if(side_num < 0 || side_num >= teams->size()) side_num = 0;
+
const unit_race::GENDER gender = cfg["gender"] == "female" ?
unit_race::FEMALE : unit_race::MALE;
const game_data::unit_type_map::const_iterator itor =
game_data_ptr->unit_types.find(type);
if(itor != game_data_ptr->unit_types.end()) {
@@ -442,12 +446,30 @@
const std::vector<std::string> xvals =
config::split(cfg["x"]);
const std::vector<std::string> yvals =
config::split(cfg["y"]);
std::vector<gamemap::location> path;
+ gamemap::location src;
+ gamemap::location dst;
for(size_t i = 0; i !=
minimum(xvals.size(),yvals.size()); ++i) {
-
path.push_back(gamemap::location(atoi(xvals[i].c_str())-1,
-
atoi(yvals[i].c_str())-1));
- }
+ if(i==0){
+ src.x = atoi(xvals[i].c_str())-1;
+ src.y = atoi(yvals[i].c_str())-1;
+ continue;
+ }
+ shortest_path_calculator calc(dummy_unit,
+ (*teams)[side_num],
+ *units,
+ *teams,
+ *game_map,
+ *status_ptr);
+
+ dst.x = atoi(xvals[i].c_str())-1;
+ dst.y = atoi(yvals[i].c_str())-1;
+
+ paths::route
route=a_star_search(src,dst,10000,calc,0);
+ unit_display::move_unit(*screen, *game_map,
route.steps,
+
dummy_unit,status_ptr->get_time_of_day(), *units, *teams);
-
unit_display::move_unit(*screen,*game_map,path,dummy_unit,status_ptr->get_time_of_day(),*units,*teams);
+ src = dst;
+ }
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src game_events.cpp,
Isaac Clerencia <=