Author: fendrin
Date: Tue Jan 12 15:24:32 2010
New Revision: 40679
URL: http://svn.gna.org/viewcvs/wesnoth?rev=40679&view=rev
Log:
Made the custom teleports working. Possible target hex highlighting and
savegame persistence is still missing.
Modified:
branches/fendrin_pathfind/src/game_events.cpp
branches/fendrin_pathfind/src/map.cpp
branches/fendrin_pathfind/src/map.hpp
branches/fendrin_pathfind/src/pathfind.cpp
Modified: branches/fendrin_pathfind/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/game_events.cpp?rev=40679&r1=40678&r2=40679&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/game_events.cpp (original)
+++ branches/fendrin_pathfind/src/game_events.cpp Tue Jan 12 15:24:32 2010
@@ -836,6 +836,27 @@
}
}
+//TODO move to the right place
+WML_HANDLER_FUNCTION(tunnel, /*event_info*/, cfg)
+{
+ vconfig::child_list source_elements = cfg.get_children("source");
+ std::set<map_location> source;
+ terrain_filter filter_source(source_elements.front(),
*resources::units);
+ filter_source.restrict_size(game_config::max_loop);
+ filter_source.get_locations(source);
+
+ vconfig::child_list dest_elements = cfg.get_children("dest");
+ std::set<map_location> dest;
+ terrain_filter filter_dest(dest_elements.front(), *resources::units);
+ filter_dest.restrict_size(game_config::max_loop);
+ filter_dest.get_locations(dest);
+
+ gamemap *game_map = resources::game_map;
+
+ game_map->set_tunnel(std::make_pair(source, dest));
+ //TODO add recording to the savefile
+}
+
WML_HANDLER_FUNCTION(modify_ai, /*event_info*/, cfg)
{
std::string side = cfg["side"];
@@ -1848,14 +1869,8 @@
return;
}
- int side = 1;
- try {
- side = boost::lexical_cast<int>(parsed_cfg["side"]);
- } catch (boost::bad_lexical_cast) {
- ERR_NG << "wrong side in [unit] tag - not a number"<<std::endl;
- DBG_NG << parsed_cfg.debug();
- return;
- }
+ int side = lexical_cast_default<int>(parsed_cfg["side"],1);
+
if ((side<1)||(side > static_cast<int>(resources::teams->size()))) {
ERR_NG << "wrong side in [unit] tag - no such side: "<<side<<"
( number of teams :"<<resources::teams->size()<<")"<<std::endl;
@@ -2331,8 +2346,8 @@
loc = find_vacant_tile(*resources::game_map,
*resources::units,loc);
}
- resources::units->erase(loc);
- resources::units->add(loc, u);
+ resources::units->erase(loc);
+ resources::units->add(loc, u);
std::string text = cfg["text"];
play_controller *controller = resources::controller;
@@ -2585,7 +2600,8 @@
data.custom_endlevel_music = cfg["music"];
data.carryover_report = utils::string_bool(cfg["carryover_report"],
true);
data.prescenario_save = utils::string_bool(cfg["save"], true);
- data.linger_mode = utils::string_bool(cfg["linger_mode"], true);
+ data.linger_mode = utils::string_bool(cfg["linger_mode"], true)
+ && !resources::teams->empty();
data.gold_bonus = utils::string_bool(cfg["bonus"], true);
data.carryover_percentage = lexical_cast_default<int>
(cfg["carryover_percentage"],
Modified: branches/fendrin_pathfind/src/map.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/map.cpp?rev=40679&r1=40678&r2=40679&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/map.cpp (original)
+++ branches/fendrin_pathfind/src/map.cpp Tue Jan 12 15:24:32 2010
@@ -39,27 +39,6 @@
const std::string gamemap::default_map_header = "usage=map\nborder_size=1\n\n";
const gamemap::tborder gamemap::default_border = gamemap::SINGLE_TILE_BORDER;
-
-
-//TODO cleanup
-//teleport_map::teleport_map(std::vector<teleport_group> teleport_groups) {
-//
-// foreach (const teleport_group &group, teleport_groups) {
-//
-// locations_.insert(group.second);
-//
-// teleport_map_.insert(std::make_pair(map_location,
&(locations_[0])));
-// }
-//
-//}
-//
-//
-//
-//
-
-
-
-
const t_translation::t_list&
gamemap::underlying_mvt_terrain(t_translation::t_terrain terrain) const
{
@@ -508,29 +487,6 @@
}
}
-std::map<map_location, std::set<map_location>* > gamemap::tunnels() {
- std::map<map_location, std::set<map_location>* > res;
-
- std::map<map_location, std::set<map_location> >::iterator it;
- for(it = tunnels_.begin(); it != tunnels_.end(); ++it) {
- std::pair<map_location, std::set<map_location>* > pairthing =
std::make_pair(it->first, &(it->second));
- res.insert(pairthing);
- }
-
-// typedef std::pair<map_location, std::set<map_location> > loc_pair;
-// foreach (loc_pair p, tunnels_) {
-//
-// res.insert(std::make_pair(p.first, &(p.second) ));
-// }
-
- return res;
-}
-
-//TODO move to the right place
-void gamemap::set_tunnel(const map_location& source, std::set<map_location>
destination) {
- tunnels_.insert(std::make_pair(source, destination));
-}
-
const terrain_type& gamemap::get_terrain_info(const t_translation::t_terrain
terrain) const
{
static const terrain_type default_terrain;
Modified: branches/fendrin_pathfind/src/map.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/map.hpp?rev=40679&r1=40678&r2=40679&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/map.hpp (original)
+++ branches/fendrin_pathfind/src/map.hpp Tue Jan 12 15:24:32 2010
@@ -189,16 +189,13 @@
const std::vector<map_location>& villages() const { return villages_; }
//TODO
- /** Return a map of the locations of tunnels on the game_map. */
- std::map<map_location, std::set<map_location>* > tunnels() ; // {
return &tunnels_; }
-
-
-// const map_location& get_tunnel(const map_location& loc) const;
+ /** Return a vector of the locations of tunnels on the game_map. */
+ std::vector<teleport_group> tunnels() { return tunnels_; }
/** Defines a oneway tunnel between the source and the destination
location.
* Units can travel through this tunnel like the hexes would be
adjacent.
*/
- void set_tunnel(const map_location& source, std::set<map_location>
destination);
+ void set_tunnel(const teleport_group group) {
tunnels_.push_back(group); }
/**
* Get the corresponding terrain_type information object
@@ -297,7 +294,7 @@
t_translation::t_list terrainList_;
std::map<t_translation::t_terrain, terrain_type> tcodeToTerrain_;
std::vector<map_location> villages_;
- std::map<map_location, std::set<map_location> > tunnels_;
+ std::vector<teleport_group> tunnels_;
mutable std::map<map_location, t_translation::t_terrain> borderCache_;
mutable std::map<t_translation::t_terrain, size_t>
terrainFrequencyCache_;
Modified: branches/fendrin_pathfind/src/pathfind.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/pathfind.cpp?rev=40679&r1=40678&r2=40679&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/pathfind.cpp (original)
+++ branches/fendrin_pathfind/src/pathfind.cpp Tue Jan 12 15:24:32 2010
@@ -165,7 +165,9 @@
groups.push_back(village_group);
- //TODO add the custom teleports
+ std::vector<teleport_group> custom_groups =
resources::game_map->tunnels();
+
+ groups.insert(groups.end(), custom_groups.begin(), custom_groups.end());
const teleport_map res = teleport_map(groups);
return res;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits