From: <geo...@us...> - 2009-10-04 22:43:28
|
Revision: 3192 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3192&view=rev Author: geoffthemedio Date: 2009-10-04 22:43:21 +0000 (Sun, 04 Oct 2009) Log Message: ----------- More FlexibleFormat replacing raw boost::format Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2009-10-04 21:39:40 UTC (rev 3191) +++ trunk/FreeOrion/universe/ValueRef.h 2009-10-04 22:43:21 UTC (rev 3192) @@ -257,7 +257,7 @@ template <class T> std::string ValueRef::Variable<T>::Description() const { - boost::format formatter(UserString("DESC_VALUE_REF_MULTIPART_VARIABLE" + boost::lexical_cast<std::string>(m_property_name.size()))); + boost::format formatter = FlexibleFormat(UserString("DESC_VALUE_REF_MULTIPART_VARIABLE" + boost::lexical_cast<std::string>(m_property_name.size()))); formatter % UserString(m_source_ref ? "DESC_VAR_SOURCE" : "DESC_VAR_TARGET"); for (unsigned int i = 0; i < m_property_name.size(); ++i) { formatter % UserString("DESC_VAR_" + boost::to_upper_copy(m_property_name[i])); |
From: <geo...@us...> - 2010-12-21 12:04:11
|
Revision: 3899 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3899&view=rev Author: geoffthemedio Date: 2010-12-21 12:04:05 +0000 (Tue, 21 Dec 2010) Log Message: ----------- Fixed some typos and a probable compile error in ValueRef.h Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2010-12-20 22:36:28 UTC (rev 3898) +++ trunk/FreeOrion/universe/ValueRef.h 2010-12-21 12:04:05 UTC (rev 3899) @@ -36,8 +36,8 @@ NUMBER, // returns the number of objects matching the condition SUM, // returns the sum of the property values of all objects matching the condition MEAN, // returns the mean of the property values of all objects matching the condition - RMS, // returns the sqrt root of the mean of the squares of the property value sof all objects matching the condition - MODE, // returns the most common property value of objects matching the condition + RMS, // returns the sqrt of the mean of the squares of the property values of all objects matching the condition + MODE, // returns the most common property value of objects matching the condition. supported for non-numeric types such as enums. MAX, // returns the maximum value of the property amongst objects matching the condition MIN, // returns the minimum value of the property amongst objects matching the condition SPREAD, // returns the (positive) difference between the maximum and minimum values of the property amongst objects matching the condition @@ -507,13 +507,13 @@ } template <class T> -virtual T ValueRef::Statistic<T>::Eval(const UniverseObject* source, const UniverseObject* target, +T ValueRef::Statistic<T>::Eval(const UniverseObject* source, const UniverseObject* target, const boost::any& current_value) const { // the only statistic that can be computed on non-number property types // and that is itself of a non-number type is the most common value if (m_stat_type != MODE) - throw std::runtime_error("ValueRef evaluated with an invalid STatisticType for the return type."); + throw std::runtime_error("ValueRef evaluated with an invalid StatisticType for the return type."); Condition::ObjectSet condition_matches; GetConditionMatches(source, condition_matches, m_sampling_condition); |
From: <geo...@us...> - 2010-12-22 19:39:36
|
Revision: 3908 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3908&view=rev Author: geoffthemedio Date: 2010-12-22 19:39:29 +0000 (Wed, 22 Dec 2010) Log Message: ----------- Commented out some ValueRef debug logging. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2010-12-22 18:17:28 UTC (rev 3907) +++ trunk/FreeOrion/universe/ValueRef.h 2010-12-22 19:39:29 UTC (rev 3908) @@ -404,7 +404,7 @@ m_stat_type(stat_type), m_sampling_condition(sampling_condition) { - Logger().debugStream() << "ValueRef::Statistic<T>::Statistic(" << property_name << ", " << stat_type << ", " << sampling_condition->Dump() << ")"; + //Logger().debugStream() << "ValueRef::Statistic<T>::Statistic(" << property_name << ", " << stat_type << ", " << sampling_condition->Dump() << ")"; } template <class T> @@ -415,7 +415,7 @@ m_stat_type(stat_type), m_sampling_condition(sampling_condition) { - Logger().debugStream() << "ValueRef::Statistic<T>::Statistic(??." << property_name.back() << ", " << stat_type << ", " << sampling_condition->Dump() << ")"; + //Logger().debugStream() << "ValueRef::Statistic<T>::Statistic(??." << property_name.back() << ", " << stat_type << ", " << sampling_condition->Dump() << ")"; } template <class T> @@ -458,9 +458,9 @@ { object_property_values.clear(); - Logger().debugStream() << "ValueRef::Statistic<T>::GetObjectPropertyValues source: " << source->Dump() - << " sampling condition: " << m_sampling_condition->Dump() - << " property name final: " << this->PropertyName().back(); + //Logger().debugStream() << "ValueRef::Statistic<T>::GetObjectPropertyValues source: " << source->Dump() + // << " sampling condition: " << m_sampling_condition->Dump() + // << " property name final: " << this->PropertyName().back(); for (Condition::ObjectSet::const_iterator it = objects.begin(); it != objects.end(); ++it) { const UniverseObject* obj = *it; |
From: <geo...@us...> - 2011-11-30 03:24:45
|
Revision: 4509 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4509&view=rev Author: geoffthemedio Date: 2011-11-30 03:24:39 +0000 (Wed, 30 Nov 2011) Log Message: ----------- Untested (by me) but looks-right fix for ValueRef constructor by Vezzra and el torito on forums. This reportedly fixes some issues with meter values being all 0. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2011-11-28 01:44:39 UTC (rev 4508) +++ trunk/FreeOrion/universe/ValueRef.h 2011-11-30 03:24:39 UTC (rev 4509) @@ -413,7 +413,7 @@ m_ref_type = NON_OBJECT_REFERENCE; } else if (ref_type_name == Source_name) { m_ref_type = SOURCE_REFERENCE; - } else if (ref_type_name == Value_name || ref_type_name == Value_name) { + } else if (ref_type_name == Value_name || ref_type_name == Target_name) { m_ref_type = EFFECT_TARGET_REFERENCE; } else if (ref_type_name == LocalCandidate_name) { m_ref_type = CONDITION_LOCAL_CANDIDATE_REFERENCE; |
From: <geo...@us...> - 2012-06-08 04:18:48
|
Revision: 4895 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4895&view=rev Author: geoffthemedio Date: 2012-06-08 04:18:42 +0000 (Fri, 08 Jun 2012) Log Message: ----------- Added a safety check in ValueRef::Operation to prevent divide-by-zero errors. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2012-06-07 01:00:15 UTC (rev 4894) +++ trunk/FreeOrion/universe/ValueRef.h 2012-06-08 04:18:42 UTC (rev 4895) @@ -296,21 +296,21 @@ Operation(OpType op_type, const ValueRefBase<T>* operand); ///< unary operation ctor ~Operation(); ///< dtor - OpType GetOpType() const; - const ValueRefBase<T>* LHS() const; - const ValueRefBase<T>* RHS() const; + OpType GetOpType() const; + const ValueRefBase<T>* LHS() const; + const ValueRefBase<T>* RHS() const; - virtual T Eval(const ScriptingContext& context) const; - virtual bool RootCandidateInvariant() const; - virtual bool LocalCandidateInvariant() const; - virtual bool TargetInvariant() const; - virtual std::string Description() const; - virtual std::string Dump() const; + virtual T Eval(const ScriptingContext& context) const; + virtual bool RootCandidateInvariant() const; + virtual bool LocalCandidateInvariant() const; + virtual bool TargetInvariant() const; + virtual std::string Description() const; + virtual std::string Dump() const; private: - OpType m_op_type; - const ValueRefBase<T>* m_operand1; - const ValueRefBase<T>* m_operand2; + OpType m_op_type; + const ValueRefBase<T>* m_operand1; + const ValueRefBase<T>* m_operand2; friend class boost::serialization::access; template <class Archive> @@ -968,9 +968,14 @@ m_operand2->Eval(context)); break; case DIVIDES: + { + T op2 = m_operand2->Eval(context); + if (op2 == T(0)) + return T(0); return T(m_operand1->Eval(context) / - m_operand2->Eval(context)); + op2); break; + } case NEGATE: return T(-m_operand1->Eval(context)); break; |
From: <geo...@us...> - 2012-06-09 23:39:00
|
Revision: 4902 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4902&view=rev Author: geoffthemedio Date: 2012-06-09 23:38:54 +0000 (Sat, 09 Jun 2012) Log Message: ----------- Fiddled with ValueRef description generation code to fix some issues with target's current value of a meter and multi-part reference name reconstruction which was acting buggy (and probably still is). Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2012-06-09 23:37:33 UTC (rev 4901) +++ trunk/FreeOrion/universe/ValueRef.h 2012-06-09 23:38:54 UTC (rev 4902) @@ -451,7 +451,7 @@ template <class T> std::string ValueRef::Variable<T>::Description() const { - boost::format formatter = FlexibleFormat(UserString("DESC_VALUE_REF_MULTIPART_VARIABLE" + boost::lexical_cast<std::string>(m_property_name.size()))); + boost::format formatter = FlexibleFormat(UserString("DESC_VALUE_REF_MULTIPART_VARIABLE" + boost::lexical_cast<std::string>(m_property_name.size() - 1))); switch (m_ref_type) { case SOURCE_REFERENCE: formatter % UserString("DESC_VAR_SOURCE"); break; case EFFECT_TARGET_REFERENCE: formatter % UserString("DESC_VAR_TARGET"); break; @@ -460,8 +460,12 @@ case NON_OBJECT_REFERENCE: formatter % ""; break; default: formatter % "???"; break; } - for (unsigned int i = 1; i < m_property_name.size(); ++i) - formatter % UserString("DESC_VAR_" + boost::to_upper_copy(std::string(m_property_name[i].c_str()))); + if (m_property_name.size() == 1 && m_property_name[0] == Value_name) { + formatter % UserString("DESC_VAR_VALUE"); + } else { + for (unsigned int i = 1; i < m_property_name.size(); ++i) + formatter % UserString("DESC_VAR_" + boost::to_upper_copy(std::string(m_property_name[i].c_str()))); + } return boost::io::str(formatter); } |
From: <geo...@us...> - 2012-09-16 07:48:14
|
Revision: 5243 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5243&view=rev Author: geoffthemedio Date: 2012-09-16 07:48:08 +0000 (Sun, 16 Sep 2012) Log Message: ----------- Modified ValueRef::Variable<T> constructor to treat any property name that doesn't reference an object as a non-source object reference, rather than only doing so if the property was CurrentTurn. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2012-09-16 00:46:22 UTC (rev 5242) +++ trunk/FreeOrion/universe/ValueRef.h 2012-09-16 07:48:08 UTC (rev 5243) @@ -409,9 +409,7 @@ { assert(!property_name.empty()); adobe::name_t ref_type_name = property_name.front(); - if (ref_type_name == CurrentTurn_name) { - m_ref_type = NON_OBJECT_REFERENCE; - } else if (ref_type_name == Source_name) { + if (ref_type_name == Source_name) { m_ref_type = SOURCE_REFERENCE; } else if (ref_type_name == Value_name || ref_type_name == Target_name) { m_ref_type = EFFECT_TARGET_REFERENCE; @@ -419,6 +417,8 @@ m_ref_type = CONDITION_LOCAL_CANDIDATE_REFERENCE; } else if (ref_type_name == RootCandidate_name) { m_ref_type = CONDITION_ROOT_CANDIDATE_REFERENCE; + } else { + m_ref_type = NON_OBJECT_REFERENCE; } } |
From: <geo...@us...> - 2012-09-24 05:03:11
|
Revision: 5263 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5263&view=rev Author: geoffthemedio Date: 2012-09-24 05:03:05 +0000 (Mon, 24 Sep 2012) Log Message: ----------- ValueRef::Operation::Description and ::Dump functions updating for recent OpType additions Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2012-09-24 03:29:59 UTC (rev 5262) +++ trunk/FreeOrion/universe/ValueRef.h 2012-09-24 05:03:05 UTC (rev 5263) @@ -1017,37 +1017,79 @@ template <class T> std::string ValueRef::Operation<T>::Description() const { - if (m_op_type == NEGATE) - return ("-(" + m_operand1->Description() + ")"); + if (m_op_type == NEGATE) { + if (const ValueRef::Operation<T>* rhs = dynamic_cast<const ValueRef::Operation<T>*>(m_operand1)) { + OpType op_type = rhs->GetOpType(); + if (op_type == PLUS || op_type == MINUS || + op_type == TIMES || op_type == DIVIDE || + op_type == NEGATE || op_type == EXPONENTIATE) + return "-(" + m_operand1->Description() + ")"; + } else { + return "-" + m_operand1->Description(); + } + } + if (m_op_type == LOGARITHM) + return "log(" + m_operand1->Description() + ")"; + if (m_op_type == SINE) + return "sin(" + m_operand1->Description() + ")"; + if (m_op_type == COSINE) + return "cos(" + m_operand1->Description() + ")"; + if (m_op_type == MINIMUM) + return "min(" + m_operand1->Description() + ", " + m_operand1->Description() + ")"; + if (m_op_type == MAXIMUM) + return "max(" + m_operand1->Description() + ", " + m_operand1->Description() + ")"; + if (m_op_type == RANDOM_UNIFORM) + return "random(" + m_operand1->Description() + ", " + m_operand1->Description() + ")"; + + bool parenthesize_lhs = false; bool parenthesize_rhs = false; if (const ValueRef::Operation<T>* lhs = dynamic_cast<const ValueRef::Operation<T>*>(m_operand1)) { - if ((m_op_type == TIMES || m_op_type == DIVIDE) && - (lhs->GetOpType() == PLUS || lhs->GetOpType() == MINUS)) + OpType op_type = lhs->GetOpType(); + if ( + (m_op_type == EXPONENTIATE && + (op_type == EXPONENTIATE || op_type == TIMES || op_type == DIVIDE || + op_type == PLUS || op_type == MINUS || op_type == NEGATE) + ) || + ((m_op_type == TIMES || m_op_type == DIVIDE) && + (op_type == PLUS || op_type == MINUS) || op_type == NEGATE) + ) parenthesize_lhs = true; } if (const ValueRef::Operation<T>* rhs = dynamic_cast<const ValueRef::Operation<T>*>(m_operand2)) { - if ((m_op_type == TIMES || m_op_type == DIVIDE) && - (rhs->GetOpType() == PLUS || rhs->GetOpType() == MINUS)) + OpType op_type = rhs->GetOpType(); + if ( + (m_op_type == EXPONENTIATE && + (op_type == EXPONENTIATE || op_type == TIMES || op_type == DIVIDE || + op_type == PLUS || op_type == MINUS || op_type == NEGATE) + ) || + ((m_op_type == TIMES || m_op_type == DIVIDE) && + (op_type == PLUS || op_type == MINUS) || op_type == NEGATE) + ) parenthesize_rhs = true; } + std::string retval; if (parenthesize_lhs) retval += '(' + m_operand1->Description() + ')'; else retval += m_operand1->Description(); + switch (m_op_type) { - case PLUS: retval += " + "; break; - case MINUS: retval += " - "; break; - case TIMES: retval += " * "; break; - case DIVIDE: retval += " / "; break; - default: retval += " ? "; break; + case PLUS: retval += " + "; break; + case MINUS: retval += " - "; break; + case TIMES: retval += " * "; break; + case DIVIDE: retval += " / "; break; + case EXPONENTIATE: retval += " ^ "; break; + default: retval += " ? "; break; } + if (parenthesize_rhs) retval += '(' + m_operand2->Description() + ')'; else retval += m_operand2->Description(); + return retval; } @@ -1055,22 +1097,55 @@ std::string ValueRef::Operation<T>::Dump() const { if (m_op_type == NEGATE) { - if (dynamic_cast<const ValueRef::Operation<T>*>(m_operand1)) + if (const ValueRef::Operation<T>* rhs = dynamic_cast<const ValueRef::Operation<T>*>(m_operand1)) { + OpType op_type = rhs->GetOpType(); + if (op_type == PLUS || op_type == MINUS || + op_type == TIMES || op_type == DIVIDE || + op_type == NEGATE || op_type == EXPONENTIATE) return "-(" + m_operand1->Dump() + ")"; - else + } else { return "-" + m_operand1->Dump(); + } } + if (m_op_type == LOGARITHM) + return "log(" + m_operand1->Dump() + ")"; + if (m_op_type == SINE) + return "sin(" + m_operand1->Dump() + ")"; + if (m_op_type == COSINE) + return "cos(" + m_operand1->Dump() + ")"; + if (m_op_type == MINIMUM) + return "min(" + m_operand1->Dump() + ", " + m_operand1->Dump() + ")"; + if (m_op_type == MAXIMUM) + return "max(" + m_operand1->Dump() + ", " + m_operand1->Dump() + ")"; + if (m_op_type == RANDOM_UNIFORM) + return "random(" + m_operand1->Dump() + ", " + m_operand1->Dump() + ")"; + + bool parenthesize_lhs = false; bool parenthesize_rhs = false; if (const ValueRef::Operation<T>* lhs = dynamic_cast<const ValueRef::Operation<T>*>(m_operand1)) { - if ((m_op_type == TIMES || m_op_type == DIVIDE) && - (lhs->GetOpType() == PLUS || lhs->GetOpType() == MINUS)) + OpType op_type = lhs->GetOpType(); + if ( + (m_op_type == EXPONENTIATE && + (op_type == EXPONENTIATE || op_type == TIMES || op_type == DIVIDE || + op_type == PLUS || op_type == MINUS || op_type == NEGATE) + ) || + ((m_op_type == TIMES || m_op_type == DIVIDE) && + (op_type == PLUS || op_type == MINUS) || op_type == NEGATE) + ) parenthesize_lhs = true; } if (const ValueRef::Operation<T>* rhs = dynamic_cast<const ValueRef::Operation<T>*>(m_operand2)) { - if ((m_op_type == TIMES || m_op_type == DIVIDE) && - (rhs->GetOpType() == PLUS || rhs->GetOpType() == MINUS)) + OpType op_type = rhs->GetOpType(); + if ( + (m_op_type == EXPONENTIATE && + (op_type == EXPONENTIATE || op_type == TIMES || op_type == DIVIDE || + op_type == PLUS || op_type == MINUS || op_type == NEGATE) + ) || + ((m_op_type == TIMES || m_op_type == DIVIDE) && + (op_type == PLUS || op_type == MINUS) || op_type == NEGATE) + ) parenthesize_rhs = true; } @@ -1081,11 +1156,12 @@ retval += m_operand1->Dump(); switch (m_op_type) { - case PLUS: retval += " + "; break; - case MINUS: retval += " - "; break; - case TIMES: retval += " * "; break; - case DIVIDE: retval += " / "; break; - default: retval += " ? "; break; + case PLUS: retval += " + "; break; + case MINUS: retval += " - "; break; + case TIMES: retval += " * "; break; + case DIVIDE: retval += " / "; break; + case EXPONENTIATE: retval += " ^ "; break; + default: retval += " ? "; break; } if (parenthesize_rhs) |
From: <geo...@us...> - 2012-11-15 08:53:22
|
Revision: 5417 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5417&view=rev Author: geoffthemedio Date: 2012-11-15 08:53:12 +0000 (Thu, 15 Nov 2012) Log Message: ----------- Tweak to Statistic evaluation to temporarily set the reference type to local candidate while getting property values. Even though the overall ValueRef is a non-object reference, it should be considered as a local candidate reference when getting the property value for each condition match. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2012-11-15 08:51:33 UTC (rev 5416) +++ trunk/FreeOrion/universe/ValueRef.h 2012-11-15 08:53:12 UTC (rev 5417) @@ -182,10 +182,10 @@ protected: Variable(ReferenceType ref_type, const std::vector<adobe::name_t>& property_name); + mutable ReferenceType m_ref_type; + std::vector<adobe::name_t> m_property_name; + private: - ReferenceType m_ref_type; - std::vector<adobe::name_t> m_property_name; - friend class boost::serialization::access; template <class Archive> void serialize(Archive& ar, const unsigned int version); @@ -560,10 +560,13 @@ //Logger().debugStream() << "ValueRef::Statistic<T>::GetObjectPropertyValues source: " << source->Dump() // << " sampling condition: " << m_sampling_condition->Dump() // << " property name final: " << this->PropertyName().back(); + ReferenceType original_ref_type = m_ref_type; + m_ref_type = ValueRef::CONDITION_LOCAL_CANDIDATE_REFERENCE; for (Condition::ObjectSet::const_iterator it = objects.begin(); it != objects.end(); ++it) { T property_value = this->Variable<T>::Eval(ScriptingContext(context, *it)); object_property_values[*it] = property_value; } + m_ref_type = original_ref_type; } template <class T> |
From: <geo...@us...> - 2012-11-15 17:47:56
|
Revision: 5418 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5418&view=rev Author: geoffthemedio Date: 2012-11-15 17:47:49 +0000 (Thu, 15 Nov 2012) Log Message: ----------- Fix for compile error on some compilers related to template base class member variables being referenced in derived class code. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2012-11-15 08:53:12 UTC (rev 5417) +++ trunk/FreeOrion/universe/ValueRef.h 2012-11-15 17:47:49 UTC (rev 5418) @@ -560,13 +560,13 @@ //Logger().debugStream() << "ValueRef::Statistic<T>::GetObjectPropertyValues source: " << source->Dump() // << " sampling condition: " << m_sampling_condition->Dump() // << " property name final: " << this->PropertyName().back(); - ReferenceType original_ref_type = m_ref_type; - m_ref_type = ValueRef::CONDITION_LOCAL_CANDIDATE_REFERENCE; + ReferenceType original_ref_type = this->m_ref_type; + this->m_ref_type = ValueRef::CONDITION_LOCAL_CANDIDATE_REFERENCE; for (Condition::ObjectSet::const_iterator it = objects.begin(); it != objects.end(); ++it) { T property_value = this->Variable<T>::Eval(ScriptingContext(context, *it)); object_property_values[*it] = property_value; } - m_ref_type = original_ref_type; + this->m_ref_type = original_ref_type; } template <class T> |
From: <mar...@us...> - 2013-08-31 07:56:04
|
Revision: 6389 http://sourceforge.net/p/freeorion/code/6389 Author: marcel_metz Date: 2013-08-31 07:55:57 +0000 (Sat, 31 Aug 2013) Log Message: ----------- Fixed the selection of the ValueRef multipart variable user string. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2013-08-30 22:54:22 UTC (rev 6388) +++ trunk/FreeOrion/universe/ValueRef.h 2013-08-31 07:55:57 UTC (rev 6389) @@ -454,7 +454,7 @@ template <class T> std::string ValueRef::Variable<T>::Description() const { - boost::format formatter = FlexibleFormat(UserString("DESC_VALUE_REF_MULTIPART_VARIABLE" + boost::lexical_cast<std::string>(m_property_name.size() - 1))); + boost::format formatter = FlexibleFormat(UserString("DESC_VALUE_REF_MULTIPART_VARIABLE" + boost::lexical_cast<std::string>(m_property_name.size()))); switch (m_ref_type) { case SOURCE_REFERENCE: formatter % UserString("DESC_VAR_SOURCE"); break; case EFFECT_TARGET_REFERENCE: formatter % UserString("DESC_VAR_TARGET"); break; |
From: <geo...@us...> - 2013-10-12 22:27:45
|
Revision: 6441 http://sourceforge.net/p/freeorion/code/6441 Author: geoffthemedio Date: 2013-10-12 22:27:36 +0000 (Sat, 12 Oct 2013) Log Message: ----------- Made ValueRef::Operation variant to all reference types when using random number generation. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2013-10-12 21:52:59 UTC (rev 6440) +++ trunk/FreeOrion/universe/ValueRef.h 2013-10-12 22:27:36 UTC (rev 6441) @@ -1088,6 +1088,8 @@ template <class T> bool ValueRef::Operation<T>::RootCandidateInvariant() const { + if (m_op_type == RANDOM_UNIFORM) + return false; if (m_operand1 && !m_operand1->RootCandidateInvariant()) return false; if (m_operand2 && !m_operand2->RootCandidateInvariant()) @@ -1098,6 +1100,8 @@ template <class T> bool ValueRef::Operation<T>::LocalCandidateInvariant() const { + if (m_op_type == RANDOM_UNIFORM) + return false; if (m_operand1 && !m_operand1->LocalCandidateInvariant()) return false; if (m_operand2 && !m_operand2->LocalCandidateInvariant()) @@ -1108,6 +1112,8 @@ template <class T> bool ValueRef::Operation<T>::TargetInvariant() const { + if (m_op_type == RANDOM_UNIFORM) + return false; if (m_operand1 && !m_operand1->TargetInvariant()) return false; if (m_operand2 && !m_operand2->TargetInvariant()) @@ -1118,6 +1124,8 @@ template <class T> bool ValueRef::Operation<T>::SourceInvariant() const { + if (m_op_type == RANDOM_UNIFORM) + return false; if (m_operand1 && !m_operand1->SourceInvariant()) return false; if (m_operand2 && !m_operand2->SourceInvariant()) |
From: <geo...@us...> - 2013-11-10 11:46:36
|
Revision: 6506 http://sourceforge.net/p/freeorion/code/6506 Author: geoffthemedio Date: 2013-11-10 11:46:27 +0000 (Sun, 10 Nov 2013) Log Message: ----------- Added FO_COMMON_API before declaration of FormatedDescriptionPropertyNames. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2013-11-10 11:45:35 UTC (rev 6505) +++ trunk/FreeOrion/universe/ValueRef.h 2013-11-10 11:46:27 UTC (rev 6506) @@ -451,8 +451,8 @@ bool ValueRef::Variable<T>::SourceInvariant() const { return m_ref_type != SOURCE_REFERENCE; } -std::string FormatedDescriptionPropertyNames(ValueRef::ReferenceType ref_type, - const std::vector<std::string>& property_names); +FO_COMMON_API std::string FormatedDescriptionPropertyNames(ValueRef::ReferenceType ref_type, + const std::vector<std::string>& property_names); template <class T> std::string ValueRef::Variable<T>::Description() const |
From: <dil...@us...> - 2014-02-14 16:09:34
|
Revision: 6900 http://sourceforge.net/p/freeorion/code/6900 Author: dilvish-fo Date: 2014-02-14 16:09:30 +0000 (Fri, 14 Feb 2014) Log Message: ----------- in a couple parts of the new ValueRef code, gcc 4.8.1 needed the reference to a base class protect member m_property_name to be written as this->m_property_name Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2014-02-14 07:23:11 UTC (rev 6899) +++ trunk/FreeOrion/universe/ValueRef.h 2014-02-14 16:09:30 UTC (rev 6900) @@ -568,7 +568,7 @@ if (m_stat_type != rhs_.m_stat_type) return false; - if (m_property_name != rhs_.m_property_name) + if (this->m_property_name != rhs_.m_property_name) return false; if (m_sampling_condition == rhs_.m_sampling_condition) { @@ -935,7 +935,7 @@ return false; const ValueRef::ComplexVariable<T>& rhs_ = static_cast<const ValueRef::ComplexVariable<T>&>(rhs); - if (m_property_name != rhs_.m_property_name) + if (this->m_property_name != rhs_.m_property_name) return false; if (m_int_ref1 == rhs_.m_int_ref1) { |
From: <mar...@us...> - 2014-02-18 20:50:05
|
Revision: 6919 http://sourceforge.net/p/freeorion/code/6919 Author: marcel_metz Date: 2014-02-18 20:50:03 +0000 (Tue, 18 Feb 2014) Log Message: ----------- The standard template library only standardizes the std::vector<typename T>(size_t count, T value = T()) constructor, but no std::vector<typename T>(T value, size_t count) constructor. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2014-02-18 18:36:37 UTC (rev 6918) +++ trunk/FreeOrion/universe/ValueRef.h 2014-02-18 20:50:03 UTC (rev 6919) @@ -897,7 +897,7 @@ const ValueRefBase<int>* int_ref2, const ValueRefBase<std::string>* string_ref1, const ValueRefBase<std::string>* string_ref2) : - Variable<T>(ValueRef::NON_OBJECT_REFERENCE, std::vector<std::string>(variable_name, 1u)), + Variable<T>(ValueRef::NON_OBJECT_REFERENCE, std::vector<std::string>(1, variable_name)), m_int_ref1(int_ref1), m_int_ref2(int_ref2), m_string_ref1(string_ref1), @@ -910,7 +910,7 @@ const ValueRefBase<std::string>* string_ref1, const ValueRefBase<int>* int_ref2, const ValueRefBase<std::string>* string_ref2) : - Variable<T>(ValueRef::NON_OBJECT_REFERENCE, std::vector<std::string>(variable_name, 1u)), + Variable<T>(ValueRef::NON_OBJECT_REFERENCE, std::vector<std::string>(1, variable_name)), m_int_ref1(int_ref1), m_int_ref2(int_ref2), m_string_ref1(string_ref1), |
From: <ve...@us...> - 2014-04-22 08:59:20
|
Revision: 7094 http://sourceforge.net/p/freeorion/code/7094 Author: vezzra Date: 2014-04-22 08:59:11 +0000 (Tue, 22 Apr 2014) Log Message: ----------- Fix for compile error on OSX in serialization code in ValueRef.h (suggested by Geoff) Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2014-04-21 14:05:25 UTC (rev 7093) +++ trunk/FreeOrion/universe/ValueRef.h 2014-04-22 08:59:11 UTC (rev 7094) @@ -1247,7 +1247,7 @@ template <class Archive> void ValueRef::UserStringLookup::serialize(Archive& ar, const unsigned int version) { - ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(ValueRefBase) + ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(ValueRefBase<std::string>) & BOOST_SERIALIZATION_NVP(m_value_ref); } |
From: <geo...@us...> - 2014-06-21 10:04:07
|
Revision: 7177 http://sourceforge.net/p/freeorion/code/7177 Author: geoffthemedio Date: 2014-06-21 10:03:59 +0000 (Sat, 21 Jun 2014) Log Message: ----------- Added overloaded ValueRef::Variable constructor taking a single string instead of a vector of strings. Modified Paths: -------------- trunk/FreeOrion/universe/ValueRef.h Modified: trunk/FreeOrion/universe/ValueRef.h =================================================================== --- trunk/FreeOrion/universe/ValueRef.h 2014-06-21 10:01:30 UTC (rev 7176) +++ trunk/FreeOrion/universe/ValueRef.h 2014-06-21 10:03:59 UTC (rev 7177) @@ -151,6 +151,7 @@ struct FO_COMMON_API ValueRef::Variable : public ValueRef::ValueRefBase<T> { Variable(ReferenceType ref_type, const std::vector<std::string>& property_name); + Variable(ReferenceType ref_type, const std::string& property_name); virtual bool operator==(const ValueRef::ValueRefBase<T>& rhs) const; ReferenceType GetReferenceType() const; @@ -483,6 +484,14 @@ {} template <class T> +ValueRef::Variable<T>::Variable(ReferenceType ref_type, const std::string& property_name) : + m_ref_type(ref_type), + m_property_name() +{ + m_property_name.push_back(property_name); +} + +template <class T> bool ValueRef::Variable<T>::operator==(const ValueRef::ValueRefBase<T>& rhs) const { if (&rhs == this) |