From: <geo...@us...> - 2011-09-16 07:20:16
|
Revision: 4276 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4276&view=rev Author: geoffthemedio Date: 2011-09-16 07:20:10 +0000 (Fri, 16 Sep 2011) Log Message: ----------- Added members, getters, and parsing for spawn rate and spawn limit for specials. These aren't yet used for anything. Modified Paths: -------------- trunk/FreeOrion/universe/Parser.h trunk/FreeOrion/universe/Special.cpp trunk/FreeOrion/universe/Special.h trunk/FreeOrion/universe/TopLevelParsers.cpp Modified: trunk/FreeOrion/universe/Parser.h =================================================================== --- trunk/FreeOrion/universe/Parser.h 2011-09-16 07:17:47 UTC (rev 4275) +++ trunk/FreeOrion/universe/Parser.h 2011-09-16 07:20:10 UTC (rev 4276) @@ -119,16 +119,18 @@ }; struct SpecialClosure : boost::spirit::classic::closure<SpecialClosure, Special*, std::string, std::string, - Condition::ConditionBase*, + double, int, Condition::ConditionBase*, std::vector<boost::shared_ptr<const Effect::EffectsGroup> >, std::string> { member1 this_; member2 name; member3 description; - member4 location; - member5 effects_groups; - member6 graphic; + member4 spawn_rate; + member5 spawn_limit; + member6 location; + member7 effects_groups; + member8 graphic; }; struct SpeciesClosure : boost::spirit::classic::closure<SpeciesClosure, Species*, std::string, std::string, Modified: trunk/FreeOrion/universe/Special.cpp =================================================================== --- trunk/FreeOrion/universe/Special.cpp 2011-09-16 07:17:47 UTC (rev 4275) +++ trunk/FreeOrion/universe/Special.cpp 2011-09-16 07:20:10 UTC (rev 4276) @@ -116,11 +116,14 @@ ///////////////////////////////////////////////// Special::Special(const std::string& name, const std::string& description, const std::vector<boost::shared_ptr<const Effect::EffectsGroup> > effects, + double spawn_rate, int spawn_limit, const Condition::ConditionBase* location, const std::string& graphic) : m_name(name), m_description(description), m_effects(effects), + m_spawn_rate(spawn_rate), + m_spawn_limit(spawn_limit), m_location(location), m_graphic(graphic) {} Modified: trunk/FreeOrion/universe/Special.h =================================================================== --- trunk/FreeOrion/universe/Special.h 2011-09-16 07:17:47 UTC (rev 4275) +++ trunk/FreeOrion/universe/Special.h 2011-09-16 07:20:10 UTC (rev 4276) @@ -28,8 +28,9 @@ /** basic ctor */ Special(const std::string& name, const std::string& description, const std::vector<boost::shared_ptr<const Effect::EffectsGroup> > effects, - const Condition::ConditionBase* location, - const std::string& graphic); + double spawn_rate = 1.0, int spawn_limit = 99999, + const Condition::ConditionBase* location = 0, + const std::string& graphic = ""); ~Special(); //@} @@ -40,6 +41,8 @@ std::string Dump() const; ///< returns a data file format representation of this object const std::vector<boost::shared_ptr<const Effect::EffectsGroup> >& Effects() const; ///< returns the EffectsGroups that encapsulate the effects that specials of this type have + double SpawnRate() const; + int SpawnLimit() const; const Condition::ConditionBase* Location() const; ///< returns the condition that determines whether an UniverseObject can have this special applied during universe creation const std::string& Graphic() const; ///< returns the name of the grapic file for this special //@} @@ -49,6 +52,8 @@ std::string m_description; std::vector<boost::shared_ptr<const Effect::EffectsGroup> > m_effects; + double m_spawn_rate; + int m_spawn_limit; const Condition::ConditionBase* m_location; std::string m_graphic; @@ -78,6 +83,8 @@ ar & BOOST_SERIALIZATION_NVP(m_name) & BOOST_SERIALIZATION_NVP(m_description) & BOOST_SERIALIZATION_NVP(m_effects) + & BOOST_SERIALIZATION_NVP(m_spawn_rate) + & BOOST_SERIALIZATION_NVP(m_spawn_limit) & BOOST_SERIALIZATION_NVP(m_location) & BOOST_SERIALIZATION_NVP(m_graphic); } Modified: trunk/FreeOrion/universe/TopLevelParsers.cpp =================================================================== --- trunk/FreeOrion/universe/TopLevelParsers.cpp 2011-09-16 07:17:47 UTC (rev 4275) +++ trunk/FreeOrion/universe/TopLevelParsers.cpp 2011-09-16 07:20:10 UTC (rev 4276) @@ -203,11 +203,16 @@ (str_p("special") >> name_label >> name_p[special_p.name = arg1] >> description_label >> name_p[special_p.description = arg1] + >> ((spawn_rate_label >> real_p[special_p.spawn_rate = arg1]) | + eps_p[special_p.spawn_rate = val(1.0)]) + >> ((spawn_limit_label >> int_p[special_p.spawn_limit = arg1]) | + eps_p[special_p.spawn_limit = val(9999)]) >> (location_label >> condition_p[special_p.location = arg1] | eps_p[special_p.location = val(NULL_COND)]) >> !(effectsgroups_label >> effects_group_vec_p[special_p.effects_groups = arg1]) >> graphic_label >> file_name_p[special_p.graphic = arg1]) [special_p.this_ = new_<Special>(special_p.name, special_p.description, special_p.effects_groups, + special_p.spawn_rate, special_p.spawn_limit, special_p.location, special_p.graphic)]; focus_type_p = |