[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src map.cpp map.hpp multiplayer_connect...
From: |
Philippe Plantier |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src map.cpp map.hpp multiplayer_connect... |
Date: |
Sat, 19 Mar 2005 16:04:46 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Philippe Plantier <address@hidden> 05/03/19 21:04:46
Modified files:
src : map.cpp map.hpp multiplayer_connect.cpp
multiplayer_wait.cpp unit.hpp
Log message:
Fixed bug #11214: changed [terrains] being hidden by a side's starting
position.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/map.cpp.diff?tr1=1.55&tr2=1.56&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/map.hpp.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_connect.cpp.diff?tr1=1.129&tr2=1.130&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_wait.cpp.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit.hpp.diff?tr1=1.63&tr2=1.64&r1=text&r2=text
Patches:
Index: wesnoth/src/map.cpp
diff -u wesnoth/src/map.cpp:1.55 wesnoth/src/map.cpp:1.56
--- wesnoth/src/map.cpp:1.55 Sat Mar 19 04:26:53 2005
+++ wesnoth/src/map.cpp Sat Mar 19 21:04:46 2005
@@ -1,4 +1,4 @@
-/* $Id: map.cpp,v 1.55 2005/03/19 04:26:53 Sirp Exp $ */
+/* $Id: map.cpp,v 1.56 2005/03/19 21:04:46 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -198,12 +198,12 @@
tiles_.clear();
villages_.clear();
std::fill(startingPositions_,startingPositions_+sizeof(startingPositions_)/sizeof(*startingPositions_),location());
-
- //ignore leading newlines
- std::string::const_iterator i = data.begin();
- while(i != data.end() && (*i == '\r' || *i == '\n')) {
- ++i;
- }
+
+ //ignore leading newlines
+ std::string::const_iterator i = data.begin();
+ while(i != data.end() && (*i == '\r' || *i == '\n')) {
+ ++i;
+ }
size_t x = 0, y = 0;
for(; i != data.end(); ++i) {
@@ -256,88 +256,89 @@
for(int j = 0; j != y(); ++j) {
for(int i = 0; i != x(); ++i) {
int n;
- for(n = 0; n != 10; ++n) {
+ for(n = 0; n != STARTING_POSITIONS; ++n) {
if(startingPositions_[n] == location(i,j))
break;
}
- if(n < 10)
+ if(n < STARTING_POSITIONS) {
str << n;
- else
+ } else {
str << tiles_[i][j];
+ }
}
str << "\n";
}
return str.str();
-}
-
-void gamemap::overlay(const gamemap& m, const config& rules_cfg, const int
xpos, const int ypos)
-{
- const config::child_list& rules = rules_cfg.get_children("rule");
-
- const int xend = minimum<int>(xpos+m.x(),x());
- const int yend = minimum<int>(ypos+m.y(),y());
- for(int x = xpos; x < xend; ++x) {
- for(int y = ypos; y < yend; ++y) {
- const TERRAIN t = m[x-xpos][y-ypos];
- const TERRAIN current = (*this)[x][y];
-
- if(t == FOGGED || t == VOID_TERRAIN) {
- continue;
- }
-
- //see if there is a matching rule
- config::child_list::const_iterator rule = rules.begin();
- for( ; rule != rules.end(); ++rule) {
- static const std::string src_key = "old",
src_not_key = "old_not",
- dst_key = "new",
dst_not_key = "new_not";
- const config& cfg = **rule;
- const std::string& src = cfg[src_key];
- if(src != "" &&
std::find(src.begin(),src.end(),current) == src.end()) {
- continue;
- }
-
- const std::string& src_not = cfg[src_not_key];
- if(src_not != "" &&
std::find(src_not.begin(),src_not.end(),current) != src_not.end()) {
- continue;
- }
-
- const std::string& dst = cfg[dst_key];
- if(dst != "" &&
std::find(dst.begin(),dst.end(),t) == dst.end()) {
- continue;
- }
-
- const std::string& dst_not = cfg[dst_not_key];
- if(dst_not != "" &&
std::find(dst_not.begin(),dst_not.end(),t) != dst_not.end()) {
- continue;
- }
-
- break;
- }
-
-
- if(rule != rules.end()) {
- const config& cfg = **rule;
- const std::string& terrain = cfg["terrain"];
- if(terrain != "") {
- set_terrain(location(x,y),terrain[0]);
- } else if(cfg["use_old"] != "yes") {
- set_terrain(location(x,y),t);
- }
- } else {
- set_terrain(location(x,y),t);
- }
- }
- }
-
- for(const location* pos = m.startingPositions_; pos !=
m.startingPositions_ +
sizeof(m.startingPositions_)/sizeof(*m.startingPositions_); ++pos) {
- if(pos->valid()) {
- startingPositions_[pos - m.startingPositions_] = *pos;
- }
- }
-
+}
+
+void gamemap::overlay(const gamemap& m, const config& rules_cfg, const int
xpos, const int ypos)
+{
+ const config::child_list& rules = rules_cfg.get_children("rule");
+
+ const int xend = minimum<int>(xpos+m.x(),x());
+ const int yend = minimum<int>(ypos+m.y(),y());
+ for(int x = xpos; x < xend; ++x) {
+ for(int y = ypos; y < yend; ++y) {
+ const TERRAIN t = m[x-xpos][y-ypos];
+ const TERRAIN current = (*this)[x][y];
+
+ if(t == FOGGED || t == VOID_TERRAIN) {
+ continue;
+ }
+
+ //see if there is a matching rule
+ config::child_list::const_iterator rule = rules.begin();
+ for( ; rule != rules.end(); ++rule) {
+ static const std::string src_key = "old",
src_not_key = "old_not",
+ dst_key = "new",
dst_not_key = "new_not";
+ const config& cfg = **rule;
+ const std::string& src = cfg[src_key];
+ if(src != "" &&
std::find(src.begin(),src.end(),current) == src.end()) {
+ continue;
+ }
+
+ const std::string& src_not = cfg[src_not_key];
+ if(src_not != "" &&
std::find(src_not.begin(),src_not.end(),current) != src_not.end()) {
+ continue;
+ }
+
+ const std::string& dst = cfg[dst_key];
+ if(dst != "" &&
std::find(dst.begin(),dst.end(),t) == dst.end()) {
+ continue;
+ }
+
+ const std::string& dst_not = cfg[dst_not_key];
+ if(dst_not != "" &&
std::find(dst_not.begin(),dst_not.end(),t) != dst_not.end()) {
+ continue;
+ }
+
+ break;
+ }
+
+
+ if(rule != rules.end()) {
+ const config& cfg = **rule;
+ const std::string& terrain = cfg["terrain"];
+ if(terrain != "") {
+ set_terrain(location(x,y),terrain[0]);
+ } else if(cfg["use_old"] != "yes") {
+ set_terrain(location(x,y),t);
+ }
+ } else {
+ set_terrain(location(x,y),t);
+ }
+ }
+ }
+
+ for(const location* pos = m.startingPositions_; pos !=
m.startingPositions_ +
sizeof(m.startingPositions_)/sizeof(*m.startingPositions_); ++pos) {
+ if(pos->valid()) {
+ startingPositions_[pos - m.startingPositions_] = *pos;
+ }
+ }
+
}
int gamemap::x() const { return tiles_.size(); }
@@ -391,7 +392,7 @@
const gamemap::location& gamemap::starting_position(int n) const
{
- if(n < sizeof(startingPositions_)/sizeof(*startingPositions_)) {
+ if(size_t(n) < sizeof(startingPositions_)/sizeof(*startingPositions_)) {
return startingPositions_[n];
} else {
static const gamemap::location null_loc;
@@ -454,15 +455,22 @@
{
if(!on_board(loc))
return;
-
- const bool old_village = is_village(loc);
- const bool new_village = is_village(ter);
-
- if(old_village && !new_village) {
-
villages_.erase(std::remove(villages_.begin(),villages_.end(),loc),villages_.end());
- } else if(!old_village && new_village) {
- villages_.push_back(loc);
- }
+
+ const bool old_village = is_village(loc);
+ const bool new_village = is_village(ter);
+
+ if(old_village && !new_village) {
+
villages_.erase(std::remove(villages_.begin(),villages_.end(),loc),villages_.end());
+ } else if(!old_village && new_village) {
+ villages_.push_back(loc);
+ }
+
+ //If the terrain is set under a starting position, do also erase the
+ //starting position.
+ for(int i = 0; i < STARTING_POSITIONS; ++i) {
+ if(loc == startingPositions_[i])
+ startingPositions_[i] = location();
+ }
tiles_[loc.x][loc.y] = ter;
@@ -506,8 +514,8 @@
const size_t weight_at_edge = 100;
const size_t additional_weight_at_center = 200;
- for(size_t i = 0; i != x(); ++i) {
- for(size_t j = 0; j != y(); ++j) {
+ for(size_t i = 0; i != size_t(x()); ++i) {
+ for(size_t j = 0; j != size_t(y()); ++j) {
const size_t distance =
distance_between(location(i,j),center);
terrainFrequencyCache_[(*this)[i][j]] += weight_at_edge
+ (furthest_distance-distance)*additional_weight_at_center;
}
Index: wesnoth/src/map.hpp
diff -u wesnoth/src/map.hpp:1.34 wesnoth/src/map.hpp:1.35
--- wesnoth/src/map.hpp:1.34 Sat Mar 19 04:26:53 2005
+++ wesnoth/src/map.hpp Sat Mar 19 21:04:46 2005
@@ -1,4 +1,4 @@
-/* $Id: map.hpp,v 1.34 2005/03/19 04:26:53 Sirp Exp $ */
+/* $Id: map.hpp,v 1.35 2005/03/19 21:04:46 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -109,9 +109,9 @@
gamemap(const config& terrain_cfg, const std::string& data);
//throw(incorrect_format_exception)
void read(const std::string& data);
- std::string write() const;
-
- //overlays another map onto this one at the given position.
+ std::string write() const;
+
+ //overlays another map onto this one at the given position.
void overlay(const gamemap& m, const config& rules, int x=0, int y=0);
//dimensions of the map.
@@ -178,7 +178,9 @@
std::vector<std::vector<TERRAIN> > tiles_;
std::vector<location> villages_;
- location startingPositions_[10];
+
+ enum { STARTING_POSITIONS = 10 };
+ location startingPositions_[STARTING_POSITIONS];
mutable std::map<location,TERRAIN> borderCache_;
mutable std::map<TERRAIN,size_t> terrainFrequencyCache_;
Index: wesnoth/src/multiplayer_connect.cpp
diff -u wesnoth/src/multiplayer_connect.cpp:1.129
wesnoth/src/multiplayer_connect.cpp:1.130
--- wesnoth/src/multiplayer_connect.cpp:1.129 Sat Mar 19 17:59:13 2005
+++ wesnoth/src/multiplayer_connect.cpp Sat Mar 19 21:04:46 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_connect.cpp,v 1.129 2005/03/19 17:59:13 gruikya Exp $ */
+/* $Id: multiplayer_connect.cpp,v 1.130 2005/03/19 21:04:46 gruikya Exp $ */
/*
Copyright (C)
Part of the Battle for Wesnoth Project http://www.wesnoth.org
Index: wesnoth/src/multiplayer_wait.cpp
diff -u wesnoth/src/multiplayer_wait.cpp:1.18
wesnoth/src/multiplayer_wait.cpp:1.19
--- wesnoth/src/multiplayer_wait.cpp:1.18 Sat Mar 19 17:59:13 2005
+++ wesnoth/src/multiplayer_wait.cpp Sat Mar 19 21:04:46 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_wait.cpp,v 1.18 2005/03/19 17:59:13 gruikya Exp $ */
+/* $Id: multiplayer_wait.cpp,v 1.19 2005/03/19 21:04:46 gruikya Exp $ */
/*
Copyright (C)
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -290,7 +290,7 @@
state_.campaign_type = "multiplayer";
state_.label = level_["name"];
- state_.scenario = level_["scenario"];
+ state_.scenario = level_["id"];
state_.starting_pos = level_;
state_.snapshot = level_;
state_.players.clear();
Index: wesnoth/src/unit.hpp
diff -u wesnoth/src/unit.hpp:1.63 wesnoth/src/unit.hpp:1.64
--- wesnoth/src/unit.hpp:1.63 Thu Mar 10 22:57:23 2005
+++ wesnoth/src/unit.hpp Sat Mar 19 21:04:46 2005
@@ -1,4 +1,4 @@
-/* $Id: unit.hpp,v 1.63 2005/03/10 22:57:23 ydirson Exp $ */
+/* $Id: unit.hpp,v 1.64 2005/03/19 21:04:46 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -52,9 +52,7 @@
int experience() const;
int max_experience() const;
bool get_experience(int xp);
- //the name of this unit is fixed by scenario, it is impossible to
- //change it.
- bool unrenamable() const;
+ bool unrenamable() const; /** < Set to true for some scenario-specific
units which should not be renamed */
bool advances() const;
int side() const;
unit_race::GENDER gender() const;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src map.cpp map.hpp multiplayer_connect...,
Philippe Plantier <=