[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src game_events.cpp unit.cpp unit.hpp s...
From: |
Philippe Plantier |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src game_events.cpp unit.cpp unit.hpp s... |
Date: |
Mon, 28 Mar 2005 09:07:32 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Philippe Plantier <address@hidden> 05/03/28 14:07:31
Modified files:
src : game_events.cpp unit.cpp unit.hpp
src/serialization: tokenizer.cpp
Log message:
* Made tokenizer.cpp include gettext.hpp
* Added support for units generated with [unit] tags in [event]s to
have their
names generated automatically.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game_events.cpp.diff?tr1=1.138&tr2=1.139&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit.cpp.diff?tr1=1.134&tr2=1.135&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit.hpp.diff?tr1=1.64&tr2=1.65&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/tokenizer.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: wesnoth/src/game_events.cpp
diff -u wesnoth/src/game_events.cpp:1.138 wesnoth/src/game_events.cpp:1.139
--- wesnoth/src/game_events.cpp:1.138 Sun Mar 27 23:06:16 2005
+++ wesnoth/src/game_events.cpp Mon Mar 28 14:07:30 2005
@@ -1,4 +1,4 @@
-/* $Id: game_events.cpp,v 1.138 2005/03/27 23:06:16 gruikya Exp $ */
+/* $Id: game_events.cpp,v 1.139 2005/03/28 14:07:30 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -926,7 +926,7 @@
//if we should spawn a new unit on the map somewhere
else if(cmd == "unit") {
- unit new_unit(*game_data_ptr, cfg.get_parsed_config());
+ unit new_unit(*game_data_ptr, cfg.get_parsed_config(), true);
preferences::encountered_units().insert(new_unit.type().id());
gamemap::location loc = cfg_to_loc(cfg);
Index: wesnoth/src/serialization/tokenizer.cpp
diff -u wesnoth/src/serialization/tokenizer.cpp:1.3
wesnoth/src/serialization/tokenizer.cpp:1.4
--- wesnoth/src/serialization/tokenizer.cpp:1.3 Mon Mar 28 13:31:20 2005
+++ wesnoth/src/serialization/tokenizer.cpp Mon Mar 28 14:07:31 2005
@@ -1,4 +1,4 @@
-/* $Id: tokenizer.cpp,v 1.3 2005/03/28 13:31:20 gruikya Exp $ */
+/* $Id: tokenizer.cpp,v 1.4 2005/03/28 14:07:31 gruikya Exp $ */
/*
Copyright (C) 2004 by Philippe Plantier <address@hidden>
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -14,6 +14,7 @@
#include "tokenizer.hpp"
#include "string_utils.hpp"
#include "filesystem.hpp"
+#include "gettext.hpp"
#include <iostream>
#include <sstream>
Index: wesnoth/src/unit.cpp
diff -u wesnoth/src/unit.cpp:1.134 wesnoth/src/unit.cpp:1.135
--- wesnoth/src/unit.cpp:1.134 Mon Mar 28 13:31:20 2005
+++ wesnoth/src/unit.cpp Mon Mar 28 14:07:31 2005
@@ -1,4 +1,4 @@
-/* $Id: unit.cpp,v 1.134 2005/03/28 13:31:20 gruikya Exp $ */
+/* $Id: unit.cpp,v 1.135 2005/03/28 14:07:31 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -55,13 +55,14 @@
}
//constructor for reading a unit
-unit::unit(const game_data& data, const config& cfg) : state_(STATE_NORMAL),
- moves_(0), user_end_turn_(false),
facingLeft_(true),
- resting_(false),
- recruit_(false),
- guardian_(false),
upkeep_(UPKEEP_FREE)
+unit::unit(const game_data& data, const config& cfg, bool
generate_description) :
+ state_(STATE_NORMAL),
+ moves_(0), user_end_turn_(false), facingLeft_(true),
+ resting_(false),
+ recruit_(false),
+ guardian_(false), upkeep_(UPKEEP_FREE)
{
- read(data,cfg);
+ read(data,cfg, generate_description);
}
unit_race::GENDER unit::generate_gender(const unit_type& type, bool gen)
@@ -106,28 +107,28 @@
//constructor for advancing a unit from a lower level
unit::unit(const unit_type* t, const unit& u) :
- gender_(u.gender_), variation_(u.variation_),
-
type_(&t->get_gender_unit_type(u.gender_).get_variation(u.variation_)),
- state_(STATE_NORMAL),
- hitpoints_(type_->hitpoints()),
- maxHitpoints_(type_->hitpoints()),
- backupMaxHitpoints_(type_->hitpoints()),
- experience_(0),
- maxExperience_(type_->experience_needed()),
- backupMaxExperience_(type_->experience_needed()),
- side_(u.side()), moves_(u.moves_),
- user_end_turn_(false), facingLeft_(u.facingLeft_),
- maxMovement_(type_->movement()),
- backupMaxMovement_(type_->movement()),
- underlying_description_(u.underlying_description_),
- description_(u.description_), recruit_(u.recruit_),
- role_(u.role_), statusFlags_(u.statusFlags_),
- overlays_(u.overlays_), variables_(u.variables_),
- attacks_(type_->attacks()),
backupAttacks_(type_->attacks()),
- modifications_(u.modifications_),
- traitsDescription_(u.traitsDescription_),
- guardian_(false), upkeep_(u.upkeep_),
- unrenamable_(u.unrenamable_)
+ gender_(u.gender_), variation_(u.variation_),
+ type_(&t->get_gender_unit_type(u.gender_).get_variation(u.variation_)),
+ state_(STATE_NORMAL),
+ hitpoints_(type_->hitpoints()),
+ maxHitpoints_(type_->hitpoints()),
+ backupMaxHitpoints_(type_->hitpoints()),
+ experience_(0),
+ maxExperience_(type_->experience_needed()),
+ backupMaxExperience_(type_->experience_needed()),
+ side_(u.side()), moves_(u.moves_),
+ user_end_turn_(false), facingLeft_(u.facingLeft_),
+ maxMovement_(type_->movement()),
+ backupMaxMovement_(type_->movement()),
+ underlying_description_(u.underlying_description_),
+ description_(u.description_), recruit_(u.recruit_),
+ role_(u.role_), statusFlags_(u.statusFlags_),
+ overlays_(u.overlays_), variables_(u.variables_),
+ attacks_(type_->attacks()), backupAttacks_(type_->attacks()),
+ modifications_(u.modifications_),
+ traitsDescription_(u.traitsDescription_),
+ guardian_(false), upkeep_(u.upkeep_),
+ unrenamable_(u.unrenamable_)
{
validate_side(side_);
@@ -595,7 +596,7 @@
return overlays_;
}
-void unit::read(const game_data& data, const config& cfg)
+void unit::read(const game_data& data, const config& cfg, bool
generate_description)
{
std::map<std::string,unit_type>::const_iterator i =
data.unit_types.find(cfg["type"]);
if(i != data.unit_types.end())
@@ -634,6 +635,9 @@
validate_side(side_);
description_ = cfg["user_description"];
+ if(description_.empty() && generate_description)
+ description_ = type_->generate_description();
+
underlying_description_ = cfg["description"];
if(description_.empty()) {
description_ = underlying_description_;
Index: wesnoth/src/unit.hpp
diff -u wesnoth/src/unit.hpp:1.64 wesnoth/src/unit.hpp:1.65
--- wesnoth/src/unit.hpp:1.64 Sat Mar 19 21:04:46 2005
+++ wesnoth/src/unit.hpp Mon Mar 28 14:07:31 2005
@@ -1,4 +1,4 @@
-/* $Id: unit.hpp,v 1.64 2005/03/19 21:04:46 gruikya Exp $ */
+/* $Id: unit.hpp,v 1.65 2005/03/28 14:07:31 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -32,7 +32,7 @@
public:
friend struct unit_movement_resetter;
- unit(const game_data& data, const config& cfg);
+ unit(const game_data& data, const config& cfg, bool
generate_description=false);
unit(const unit_type* t, int side, bool use_traits=false, bool
dummy_unit=false, unit_race::GENDER gender=unit_race::MALE);
//a constructor used when advancing a unit
@@ -100,7 +100,16 @@
void remove_overlay(const std::string& overlay);
const std::vector<std::string>& overlays() const;
- void read(const game_data& data, const config& cfg);
+ /**
+ * Initializes this unit from a cfg object.
+ *
+ * \param data The global game_data object
+ * \param cfg Configuration object from which to read the unit
+ * \param generate_description If set to true, will try to generate a
+ * name from the unit if the cfg object does not specify
+ * one.
+ */
+ void read(const game_data& data, const config& cfg, bool
generate_description=false);
void write(config& cfg) const;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src game_events.cpp unit.cpp unit.hpp s...,
Philippe Plantier <=