Author: suokko
Date: Fri Sep 12 23:51:35 2008
New Revision: 29426
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29426&view=rev
Log:
* Fix underlying id generation for WML created units
* Raise unit map dublicate id warning to error level
- This might fix bugs with invalid unit map iterators
Modified:
trunk/src/gamestatus.cpp
trunk/src/gamestatus.hpp
trunk/src/play_controller.cpp
trunk/src/play_controller.hpp
trunk/src/playcampaign.cpp
trunk/src/unit.cpp
trunk/src/unit_map.cpp
Modified: trunk/src/gamestatus.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=29426&r1=29425&r2=29426&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Fri Sep 12 23:51:35 2008
@@ -29,6 +29,7 @@
#include "statistics.hpp"
#include "time_of_day.hpp"
#include "wesconfig.h"
+#include "replay.hpp"
#include "serialization/binary_or_text.hpp"
#include "serialization/binary_wml.hpp"
#include "serialization/parser.hpp"
@@ -442,6 +443,33 @@
return res;
}
+
+game_state::game_state() :
+ label(),
+ version(),
+ campaign_type(),
+ campaign_define(),
+ campaign_xtra_defines(),
+ campaign(),
+ history(),
+ abbrev(),
+ scenario(),
+ next_scenario(),
+ completion(),
+ players(),
+ scoped_variables(),
+ wml_menu_items(),
+ difficulty("NORMAL"),
+ replay_data(),
+ starting_pos(),
+ snapshot(),
+ last_selected(gamemap::location::null_location),
+ rng_(),
+ variables(),
+ temporaries(),
+ generator_setter(&recorder)
+ {}
+
game_state::game_state(const config& cfg, bool show_replay) :
label(cfg["label"]),
@@ -465,7 +493,8 @@
last_selected(gamemap::location::null_location),
rng_(cfg),
variables(),
- temporaries()
+ temporaries(),
+ generator_setter(&recorder)
{
log_scope("read_game");
@@ -1194,7 +1223,8 @@
last_selected(),
rng_(),
variables(),
- temporaries()
+ temporaries(),
+ generator_setter(&recorder)
{
*this = state;
}
Modified: trunk/src/gamestatus.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.hpp?rev=29426&r1=29425&r2=29426&view=diff
==============================================================================
--- trunk/src/gamestatus.hpp (original)
+++ trunk/src/gamestatus.hpp Fri Sep 12 23:51:35 2008
@@ -29,6 +29,7 @@
#include <time.h>
#include <string>
#include <vector>
+
class scoped_wml_variable;
@@ -69,37 +70,12 @@
class game_state : public variable_set
{
public:
- game_state() :
- label(),
- version(),
- campaign_type(),
- campaign_define(),
- campaign_xtra_defines(),
- campaign(),
- history(),
- abbrev(),
- scenario(),
- next_scenario(),
- completion(),
- players(),
- scoped_variables(),
- wml_menu_items(),
- difficulty("NORMAL"),
- replay_data(),
- starting_pos(),
- snapshot(),
- last_selected(gamemap::location::null_location),
- rng_(),
- variables(),
- temporaries()
- {}
-
+ game_state();
game_state(const game_state& state);
game_state(const config& cfg, bool show_replay = false);
~game_state();
game_state& operator=(const game_state& state);
-
std::string label; //!< Name of the game
(e.g. name of save file).
std::string version; //!< Version game was
created with.
std::string campaign_type; //!< Type of the game
- campaign, multiplayer etc.
@@ -170,6 +146,7 @@
rand_rng::simple_rng rng_ ;
config variables;
mutable config temporaries; // lengths of arrays, etc.
+ const rand_rng::set_random_generator generator_setter; //! Make sure
that rng is initialized first
friend struct variable_info;
//! Loads the recall list.
Modified: trunk/src/play_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=29426&r1=29425&r2=29426&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Fri Sep 12 23:51:35 2008
@@ -51,7 +51,6 @@
menu_handler_(NULL, units_, teams_, level, map_, game_config, status_,
state_of_game, undo_stack_, redo_stack_),
soundsources_manager_(),
gui_(),
- generator_setter(&recorder),
statistics_context_(level["name"]),
level_(level),
teams_(),
Modified: trunk/src/play_controller.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.hpp?rev=29426&r1=29425&r2=29426&view=diff
==============================================================================
--- trunk/src/play_controller.hpp (original)
+++ trunk/src/play_controller.hpp Fri Sep 12 23:51:35 2008
@@ -132,7 +132,6 @@
//other objects
boost::scoped_ptr<game_display> gui_;
- const rand_rng::set_random_generator generator_setter;
const statistics::scenario_context statistics_context_;
const config& level_;
std::vector<team> teams_;
Modified: trunk/src/playcampaign.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playcampaign.cpp?rev=29426&r1=29425&r2=29426&view=diff
==============================================================================
--- trunk/src/playcampaign.cpp (original)
+++ trunk/src/playcampaign.cpp Fri Sep 12 23:51:35 2008
@@ -325,7 +325,6 @@
bool save_game_after_scenario = true;
- const rand_rng::set_random_generator
generator_setter(&recorder);
LEVEL_RESULT res = LEVEL_CONTINUE;
try {
Modified: trunk/src/unit.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=29426&r1=29425&r2=29426&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Fri Sep 12 23:51:35 2008
@@ -1402,24 +1402,14 @@
variation_ = cfg["variation"];
id_ = cfg["id"];
+ if (id_.empty()) {
+ id_ = cfg["type"].c_str();
+ }
name_ = cfg["name"];
- // FIXME OBSOLETE This will go away in 1.5.3
- if (id_.empty())
- id_ = cfg["description"];
- // FIXME OBSOLETE This will go away in 1.5.3
- if (!cfg["user_description"].empty()) {
- name_ = cfg["user_description"];
- }
std::string custom_unit_desc = cfg["description"];
- // FIXME OBSOLETE This will go away in 1.5.3
- if (custom_unit_desc.empty())
- custom_unit_desc = cfg["unit_description"];
-
- underlying_id_ = id_;
- if(id_.empty()) {
- set_underlying_id();
- id_ = cfg["type"].c_str();
- }
+
+ underlying_id_ = cfg["underlying_id"];
+ set_underlying_id();
role_ = cfg["role"];
ai_special_ = cfg["ai_special"];
@@ -1714,7 +1704,8 @@
cfg["overlays"] = utils::join(overlays_);
cfg["name"] = name_;
- cfg["id"] = underlying_id_;
+ cfg["id"] = id_;
+ cfg["underlying_id"] = underlying_id_;
if(can_recruit())
cfg["canrecruit"] = "yes";
Modified: trunk/src/unit_map.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_map.cpp?rev=29426&r1=29425&r2=29426&view=diff
==============================================================================
--- trunk/src/unit_map.cpp (original)
+++ trunk/src/unit_map.cpp Fri Sep 12 23:51:35 2008
@@ -463,7 +463,7 @@
unit_id = id.str();
map_[unit_id] = std::pair<bool, std::pair<gamemap::location,
unit>*>(true, p);
- WRN_NG << "unit_map::add -- duplicate id in unit map: " <<
p->second.underlying_id()
+ ERR_NG << "unit_map::add -- duplicate id in unit map: " <<
p->second.underlying_id()
<< " added to location: (" << p->first.x+1 << "," <<
p->first.y+1
<< ") but exists already at: (" <<
iter->second.second->first.x+1
<< "," << iter->second.second->first.y+1 << ").\n";
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits