From: <ka...@us...> - 2010-08-31 04:11:34
|
Revision: 4720 http://paintown.svn.sourceforge.net/paintown/?rev=4720&view=rev Author: kazzmir Date: 2010-08-31 04:11:27 +0000 (Tue, 31 Aug 2010) Log Message: ----------- code maintainence Modified Paths: -------------- trunk/src/mugen/character.cpp trunk/src/mugen/character.h trunk/src/mugen/compiler.cpp trunk/src/mugen/state-controller.cpp Modified: trunk/src/mugen/character.cpp =================================================================== --- trunk/src/mugen/character.cpp 2010-08-31 03:55:27 UTC (rev 4719) +++ trunk/src/mugen/character.cpp 2010-08-31 04:11:27 UTC (rev 4720) @@ -2754,7 +2754,7 @@ delete animation; } -bool Character::isHelper(){ +bool Character::isHelper() const { return false; } Modified: trunk/src/mugen/character.h =================================================================== --- trunk/src/mugen/character.h 2010-08-31 03:55:27 UTC (rev 4719) +++ trunk/src/mugen/character.h 2010-08-31 04:11:27 UTC (rev 4720) @@ -1032,7 +1032,7 @@ virtual void setTemporaryAnimation(MugenAnimation * animation); - virtual bool isHelper(); + virtual bool isHelper() const; /* increase combo count */ virtual void addCombo(int combo); Modified: trunk/src/mugen/compiler.cpp =================================================================== --- trunk/src/mugen/compiler.cpp 2010-08-31 03:55:27 UTC (rev 4719) +++ trunk/src/mugen/compiler.cpp 2010-08-31 04:11:27 UTC (rev 4720) @@ -111,8 +111,14 @@ } if (identifier == "ishelper"){ - /* FIXME */ - return compile(0); + class IsHelper: public Value { + public: + RuntimeValue evaluate(const Environment & environment) const { + return RuntimeValue(environment.getCharacter().isHelper()); + } + }; + + return new IsHelper(); } if (identifier == "numhelper"){ @@ -553,20 +559,12 @@ /* FIXME: deal with distance as well */ return RuntimeValue(out); - } }; return new InGuardDist(); } - /* FIXME: remove this, it should be recognized exclusively in the a - * state controller. - */ - if (identifier == "SAC"){ - return new JustString("SAC"); - } - if (identifier == "animtime"){ class AnimTime: public Value { public: @@ -694,6 +692,9 @@ return new Time(); } + /* TODO: these things might be able to go away. Check if the comparison + * operation can be parsed as a function + */ if (identifier == "A"){ return new JustString("A"); } @@ -714,6 +715,11 @@ return new JustString("SCA"); } + if (identifier == "SAC"){ + return new JustString("SAC"); + } + /* end things that might go away */ + if (identifier == "statetype"){ class StateType: public Value { public: @@ -1582,27 +1588,29 @@ } if (function == "ln"){ - class Ln : public Value { + class Ln: public Value { public: - Ln(Value * exprn): - exprn(exprn){ + Ln(Value * argument): + argument(argument){ } - Value * exprn; + + Value * argument; + virtual ~Ln(){ - delete exprn; + delete argument; } RuntimeValue evaluate(const Environment & environment) const { - const double num = exprn->evaluate(environment).toNumber(); + const double num = argument->evaluate(environment).toNumber(); + if (num <= 0){ - throw MugenException("Argument is negative or equal to 0"); + std::ostringstream out; + out << "Argument to ln must be positive but was " << num; + throw MugenException(out.str()); } + const double value = log(num); - if (value <= 0){ - throw MugenException("Value of logarithm of exprn is negative or equal to 0"); - } - return RuntimeValue(value); } }; @@ -1616,30 +1624,34 @@ arg1(arg1), arg2(arg2){ } + Value * arg1; Value * arg2; + virtual ~Log(){ delete arg1; delete arg2; } RuntimeValue evaluate(const Environment & environment) const { - const double a = arg1->evaluate(environment).toNumber(); - const double b = arg2->evaluate(environment).toNumber(); - if (a <= 0){ - throw MugenException("Argument 1 is negative or equal to 0"); - } else if (b <= 0){ - throw MugenException("Argument 2 is negative or equal to 0"); + const double base = arg1->evaluate(environment).toNumber(); + const double value = arg2->evaluate(environment).toNumber(); + if (base <= 0){ + std::ostringstream out; + out << "Base of log must be positive but was " << base; + throw MugenException(out.str()); + } else if (value <= 0){ + std::ostringstream out; + out << "Value of log must be positive but was " << value; + throw MugenException(out.str()); } - const double value = log(a) / log(b); + + const double result = log(value) / log(base); - if (value <= 0){ - throw MugenException("Value of base-a logarithm of b is negative or equal to 0"); - } - - return RuntimeValue(value); + return RuntimeValue(result); } }; + return new Log(compile(function.getArg1()),compile(function.getArg2())); } Modified: trunk/src/mugen/state-controller.cpp =================================================================== --- trunk/src/mugen/state-controller.cpp 2010-08-31 03:55:27 UTC (rev 4719) +++ trunk/src/mugen/state-controller.cpp 2010-08-31 04:11:27 UTC (rev 4720) @@ -4472,6 +4472,16 @@ } }; +class ControllerReversalDef: public StateController { +public: + ControllerReversalDef(Ast::Section * section, const string & name, int state): + StateController(name, state, section){ + } + + virtual void activate(MugenStage & stage, Character & guy, const vector<string> & commands) const { + } +}; + static string toString(StateController::Type type){ switch (type){ case StateController::ChangeAnim : return "ChangeAnim"; @@ -4637,6 +4647,7 @@ case StateController::AttackMulSet : return new ControllerAttackMulSet(section, name, state); case StateController::HitOverride : return new ControllerHitOverride(section, name, state); case StateController::BindToParent : return new ControllerBindToParent(section, name, state); + case StateController::ReversalDef : return new ControllerReversalDef(section, name, state); case StateController::AllPalFX : case StateController::AppendToClipboard : case StateController::BindToRoot : @@ -4648,7 +4659,6 @@ case StateController::ParentVarAdd : case StateController::PowerSet : case StateController::Projectile : - case StateController::ReversalDef : case StateController::SndPan : case StateController::TargetDrop : case StateController::TargetPowerAdd : This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |