Revision: 6065
http://planeshift.svn.sourceforge.net/planeshift/?rev=6065&view=rev
Author: rlydontknow
Date: 2010-07-26 15:25:41 +0000 (Mon, 26 Jul 2010)
Log Message:
-----------
skip evaluation time check whether a variable has to be an object for function calls
the user shall ensure a variable he calls a function on is an object
this is required for dynamic objects (e.g. as returned by item:owner)
the check remains intact for properties, if you need a property of a dynamic object, use object:GetProperty('propertyname')
Modified Paths:
--------------
trunk/src/common/util/mathscript.cpp
Modified: trunk/src/common/util/mathscript.cpp
===================================================================
--- trunk/src/common/util/mathscript.cpp 2010-07-24 18:27:40 UTC (rev 6064)
+++ trunk/src/common/util/mathscript.cpp 2010-07-26 15:25:41 UTC (rev 6065)
@@ -509,12 +509,13 @@
return false;
}
- // The previous variable must be an object.
- requiredObjs.Add(tokens[i-1]);
-
// Is it a method call?
if (i+2 < tokens.GetSize() && tokens[i+2] == "(")
{
+ // method calls don't require the variable to be an object at the beginning, they may become one
+ // runtime via properties/other function calls, therefore this check is skipped
+ // the user shall ensure that a variable he calls a function on is an object
+
// Methods start as Target:WeaponAt(Slot) and turn into customCompoundFuncN(X,Target,Slot)
// where N-2 is the number of parameters and X is the index in a global lookup table.
int paramCount = 2; // customCompoundFunc takes two args as boilerplate.
@@ -544,6 +545,9 @@
}
else
{
+ // The previous variable must be an object.
+ requiredObjs.Add(tokens[i-1]);
+
// Found a property reference, i.e. Actor:HP
tokens[i] = "_"; // fparser can't deal with ':', so change it to '_'.
propertyRefs.Add(csString().Format("%s:%s", tokens[i-1].GetData(), tokens[i+1].GetData()));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Revision: 6066
http://planeshift.svn.sourceforge.net/planeshift/?rev=6066&view=rev
Author: rlydontknow
Date: 2010-07-26 15:40:46 +0000 (Mon, 26 Jul 2010)
Log Message:
-----------
at least check whether it *could* be an object (right now very naive - only checks
whether the variable exists at all, if not it *has* to be known evaluation time)
Modified Paths:
--------------
trunk/src/common/util/mathscript.cpp
Modified: trunk/src/common/util/mathscript.cpp
===================================================================
--- trunk/src/common/util/mathscript.cpp 2010-07-26 15:25:41 UTC (rev 6065)
+++ trunk/src/common/util/mathscript.cpp 2010-07-26 15:40:46 UTC (rev 6066)
@@ -514,7 +514,14 @@
{
// method calls don't require the variable to be an object at the beginning, they may become one
// runtime via properties/other function calls, therefore this check is skipped
- // the user shall ensure that a variable he calls a function on is an object
+ // the user shall ensure that a variable he calls a function on is an object at the point
+ // of calling the function
+ if(!requiredVars.Contains(tokens[i-1]))
+ {
+ // as the variable didn't occur prior to calling a function on it, it has
+ // to be an object at the beginning
+ requiredObjs.Add(tokens[i-1]);
+ }
// Methods start as Target:WeaponAt(Slot) and turn into customCompoundFuncN(X,Target,Slot)
// where N-2 is the number of parameters and X is the index in a global lookup table.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.