div=, div=f
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6876 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+121
-56
@@ -219,6 +219,69 @@
|
|||||||
<return token="N" description="the sum"/>
|
<return token="N" description="the sum"/>
|
||||||
</command>
|
</command>
|
||||||
|
|
||||||
|
<command name="-">
|
||||||
|
<description>Performs a subtraction.</description>
|
||||||
|
<arguments>
|
||||||
|
<argument token="A" description="the minuend"/>
|
||||||
|
<argument token="B" description="the subtrahend"/>
|
||||||
|
</arguments>
|
||||||
|
<return token="N" description="the difference"/>
|
||||||
|
</command>
|
||||||
|
|
||||||
|
<command name="*">
|
||||||
|
<description>Performs a multiplication.</description>
|
||||||
|
<arguments>
|
||||||
|
<argument token="A" description="the multiplicand"/>
|
||||||
|
<argument token="B" description="the multiplier"/>
|
||||||
|
</arguments>
|
||||||
|
<return token="N" description="the product"/>
|
||||||
|
</command>
|
||||||
|
|
||||||
|
<command name="div">
|
||||||
|
<description>Performs an integer division.</description>
|
||||||
|
<arguments>
|
||||||
|
<argument token="A" description="the dividend"/>
|
||||||
|
<argument token="B" description="the divisor"/>
|
||||||
|
</arguments>
|
||||||
|
<return token="N" description="the quotient (integer)"/>
|
||||||
|
</command>
|
||||||
|
|
||||||
|
<command name="-f">
|
||||||
|
<description>Subtracts two floating-point numbers.</description>
|
||||||
|
<arguments>
|
||||||
|
<argument token="A" description="the minuend" valueNotes="float"/>
|
||||||
|
<argument token="B" description="the subtrahend" valueNotes="float"/>
|
||||||
|
</arguments>
|
||||||
|
<return token="F" description="the difference"/>
|
||||||
|
</command>
|
||||||
|
|
||||||
|
<command name="+f">
|
||||||
|
<description>Adds up two floating-point numbers.</description>
|
||||||
|
<arguments>
|
||||||
|
<argument token="A" description="the first summand" valueNotes="float"/>
|
||||||
|
<argument token="B" description="the second summand" valueNotes="float"/>
|
||||||
|
</arguments>
|
||||||
|
<return token="F" description="the sum"/>
|
||||||
|
</command>
|
||||||
|
|
||||||
|
<command name="*f">
|
||||||
|
<description>Performs a floating point multiplication.</description>
|
||||||
|
<arguments>
|
||||||
|
<argument token="A" description="the multiplicand"/>
|
||||||
|
<argument token="B" description="the multiplier"/>
|
||||||
|
</arguments>
|
||||||
|
<return token="N" description="the product"/>
|
||||||
|
</command>
|
||||||
|
|
||||||
|
<command name="divf">
|
||||||
|
<description>Performs a division with floating-point precision.</description>
|
||||||
|
<arguments>
|
||||||
|
<argument token="A" description="" valueNotes="the dividend"/>
|
||||||
|
<argument token="B" description="" valueNotes="the divisor"/>
|
||||||
|
</arguments>
|
||||||
|
<return token="F" description="the quotient (floating-point)"/>
|
||||||
|
</command>
|
||||||
|
|
||||||
<command name="+=">
|
<command name="+=">
|
||||||
<description>Adds a value to an alias.</description>
|
<description>Adds a value to an alias.</description>
|
||||||
<remarks>
|
<remarks>
|
||||||
@@ -246,70 +309,81 @@
|
|||||||
</command>
|
</command>
|
||||||
|
|
||||||
<command name="*=">
|
<command name="*=">
|
||||||
<description>Multiplies a value and an alias.</description>
|
<description>Multiplies an alias by a value.</description>
|
||||||
<remarks>
|
<remarks>
|
||||||
<remark>
|
<remark>
|
||||||
Example: *= foo 1337
|
Example: *= foo 1337
|
||||||
</remark>
|
</remark>
|
||||||
</remarks>
|
</remarks>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument token="A" description="the alias to multiplied"/>
|
<argument token="A" description="the alias to be multiplied"/>
|
||||||
<argument token="B" description="the multiplier"/>
|
<argument token="B" description="the multiplier"/>
|
||||||
</arguments>
|
</arguments>
|
||||||
</command>
|
</command>
|
||||||
|
|
||||||
<command name="-">
|
<command name="div=">
|
||||||
<description>Performs a subtraction.</description>
|
<description>Divides an alias by a value.</description>
|
||||||
|
<remarks>
|
||||||
|
<remark>
|
||||||
|
Example: div= foo 1337
|
||||||
|
</remark>
|
||||||
|
</remarks>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument token="A" description="the minuend"/>
|
<argument token="A" description="the alias to be divided"/>
|
||||||
<argument token="B" description="the subtrahend"/>
|
|
||||||
</arguments>
|
|
||||||
<return token="N" description="the difference"/>
|
|
||||||
</command>
|
|
||||||
|
|
||||||
<command name="-f">
|
|
||||||
<description>Subtracts two floating-point numbers.</description>
|
|
||||||
<arguments>
|
|
||||||
<argument token="A" description="the minuend" valueNotes="float"/>
|
|
||||||
<argument token="B" description="the subtrahend" valueNotes="float"/>
|
|
||||||
</arguments>
|
|
||||||
<return token="F" description="the difference"/>
|
|
||||||
</command>
|
|
||||||
|
|
||||||
<command name="+f">
|
|
||||||
<description>Adds up two floating-point numbers.</description>
|
|
||||||
<arguments>
|
|
||||||
<argument token="A" description="the first summand" valueNotes="float"/>
|
|
||||||
<argument token="B" description="the second summand" valueNotes="float"/>
|
|
||||||
</arguments>
|
|
||||||
<return token="F" description="the sum"/>
|
|
||||||
</command>
|
|
||||||
|
|
||||||
<command name="*">
|
|
||||||
<description>Performs a multiplication.</description>
|
|
||||||
<arguments>
|
|
||||||
<argument token="A" description="the multiplicand"/>
|
|
||||||
<argument token="B" description="the multiplier"/>
|
|
||||||
</arguments>
|
|
||||||
<return token="N" description="the product"/>
|
|
||||||
</command>
|
|
||||||
|
|
||||||
<command name="div">
|
|
||||||
<description>Performs an integer division.</description>
|
|
||||||
<arguments>
|
|
||||||
<argument token="A" description="the dividend"/>
|
|
||||||
<argument token="B" description="the divisor"/>
|
<argument token="B" description="the divisor"/>
|
||||||
</arguments>
|
</arguments>
|
||||||
<return token="N" description="the quotient (integer)"/>
|
|
||||||
</command>
|
</command>
|
||||||
|
|
||||||
<command name="divf">
|
<command name="+=f">
|
||||||
<description>Performs a division with floating-point precision.</description>
|
<description>Adds a floating-point value to an alias.</description>
|
||||||
|
<remarks>
|
||||||
|
<remark>
|
||||||
|
Example: +=f foo 13.37
|
||||||
|
</remark>
|
||||||
|
</remarks>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument token="A" description="" valueNotes="the dividend"/>
|
<argument token="A" description="the alias to add to"/>
|
||||||
<argument token="B" description="" valueNotes="the divisor"/>
|
<argument token="B" description="value to be added"/>
|
||||||
|
</arguments>
|
||||||
|
</command>
|
||||||
|
|
||||||
|
<command name="-=f">
|
||||||
|
<description>Subtracts a floating-point value from an alias.</description>
|
||||||
|
<remarks>
|
||||||
|
<remark>
|
||||||
|
Example: -=f foo 13.37
|
||||||
|
</remark>
|
||||||
|
</remarks>
|
||||||
|
<arguments>
|
||||||
|
<argument token="A" description="the alias to subtract from"/>
|
||||||
|
<argument token="B" description="value to be subtracted"/>
|
||||||
|
</arguments>
|
||||||
|
</command>
|
||||||
|
|
||||||
|
<command name="*=f">
|
||||||
|
<description>Multiplies an alias by a floating-point value.</description>
|
||||||
|
<remarks>
|
||||||
|
<remark>
|
||||||
|
Example: *=f foo 13.37
|
||||||
|
</remark>
|
||||||
|
</remarks>
|
||||||
|
<arguments>
|
||||||
|
<argument token="A" description="the alias to be multiplied"/>
|
||||||
|
<argument token="B" description="the multiplier"/>
|
||||||
|
</arguments>
|
||||||
|
</command>
|
||||||
|
|
||||||
|
<command name="div=f">
|
||||||
|
<description>Divides an alias by a floating-point value.</description>
|
||||||
|
<remarks>
|
||||||
|
<remark>
|
||||||
|
Example: div=f foo 13.37
|
||||||
|
</remark>
|
||||||
|
</remarks>
|
||||||
|
<arguments>
|
||||||
|
<argument token="A" description="the alias to be divided"/>
|
||||||
|
<argument token="B" description="the divisor"/>
|
||||||
</arguments>
|
</arguments>
|
||||||
<return token="F" description="the quotient (floating-point)"/>
|
|
||||||
</command>
|
</command>
|
||||||
|
|
||||||
<command name="mod">
|
<command name="mod">
|
||||||
@@ -428,15 +502,6 @@
|
|||||||
</arguments>
|
</arguments>
|
||||||
</command>
|
</command>
|
||||||
|
|
||||||
<command name="*f">
|
|
||||||
<description>Performs a floating point multiplication.</description>
|
|
||||||
<arguments>
|
|
||||||
<argument token="A" description="the multiplicand"/>
|
|
||||||
<argument token="B" description="the multiplier"/>
|
|
||||||
</arguments>
|
|
||||||
<return token="N" description="the product"/>
|
|
||||||
</command>
|
|
||||||
|
|
||||||
<command name="rnd">
|
<command name="rnd">
|
||||||
<description>Random value</description>
|
<description>Random value</description>
|
||||||
<arguments>
|
<arguments>
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ void modifyvar(const char *name, const char *arg, char op)
|
|||||||
case '+': val += argval; break;
|
case '+': val += argval; break;
|
||||||
case '-': val -= argval; break;
|
case '-': val -= argval; break;
|
||||||
case '*': val *= argval; break;
|
case '*': val *= argval; break;
|
||||||
case '/': val /= argval; break;
|
case '/': val = argval ? val/argval : 0; break;
|
||||||
}
|
}
|
||||||
switch(id->type)
|
switch(id->type)
|
||||||
{
|
{
|
||||||
@@ -303,7 +303,7 @@ void modifyfvar(const char *name, const char *arg, char op)
|
|||||||
case '+': val += argval; break;
|
case '+': val += argval; break;
|
||||||
case '-': val -= argval; break;
|
case '-': val -= argval; break;
|
||||||
case '*': val *= argval; break;
|
case '*': val *= argval; break;
|
||||||
case '/': val /= argval; break;
|
case '/': val = (argval == 0.0f) ? 0 : val/argval; break;
|
||||||
}
|
}
|
||||||
switch(id->type)
|
switch(id->type)
|
||||||
{
|
{
|
||||||
@@ -319,16 +319,20 @@ void modifyfvar(const char *name, const char *arg, char op)
|
|||||||
void addeq(char *name, char *arg) { modifyvar(name, arg, '+'); }
|
void addeq(char *name, char *arg) { modifyvar(name, arg, '+'); }
|
||||||
void subeq(char *name, char *arg) { modifyvar(name, arg, '-'); }
|
void subeq(char *name, char *arg) { modifyvar(name, arg, '-'); }
|
||||||
void muleq(char *name, char *arg) { modifyvar(name, arg, '*'); }
|
void muleq(char *name, char *arg) { modifyvar(name, arg, '*'); }
|
||||||
|
void diveq(char *name, char *arg) { modifyvar(name, arg, '/'); }
|
||||||
void addeqf(char *name, char *arg) { modifyfvar(name, arg, '+'); }
|
void addeqf(char *name, char *arg) { modifyfvar(name, arg, '+'); }
|
||||||
void subeqf(char *name, char *arg) { modifyfvar(name, arg, '-'); }
|
void subeqf(char *name, char *arg) { modifyfvar(name, arg, '-'); }
|
||||||
void muleqf(char *name, char *arg) { modifyfvar(name, arg, '*'); }
|
void muleqf(char *name, char *arg) { modifyfvar(name, arg, '*'); }
|
||||||
|
void diveqf(char *name, char *arg) { modifyfvar(name, arg, '/'); }
|
||||||
|
|
||||||
COMMANDN(+=, addeq, ARG_2STR);
|
COMMANDN(+=, addeq, ARG_2STR);
|
||||||
COMMANDN(-=, subeq, ARG_2STR);
|
COMMANDN(-=, subeq, ARG_2STR);
|
||||||
COMMANDN(*=, muleq, ARG_2STR);
|
COMMANDN(*=, muleq, ARG_2STR);
|
||||||
|
COMMANDN(div=, diveq, ARG_2STR);
|
||||||
COMMANDN(+=f, addeqf, ARG_2STR);
|
COMMANDN(+=f, addeqf, ARG_2STR);
|
||||||
COMMANDN(-=f, subeqf, ARG_2STR);
|
COMMANDN(-=f, subeqf, ARG_2STR);
|
||||||
COMMANDN(*=f, muleqf, ARG_2STR);
|
COMMANDN(*=f, muleqf, ARG_2STR);
|
||||||
|
COMMANDN(div=f, diveqf, ARG_2STR);
|
||||||
|
|
||||||
int getvar(const char *name)
|
int getvar(const char *name)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user