Nicolas Hake
a8f4bd3960
C4AulParseError: Avoid the second string parameter
...
While I'm not a big fan of hiding flow control in a function, Error()
handles formatting and saves me from calling FormatString().getData() a
lot.
2016-04-28 02:59:12 +02:00
Günther Brammer
4b43576f83
Script: Complain about some attempts to Call nonexistant function again
...
This code got lost in the function pointer rewrite.
2016-04-28 02:59:12 +02:00
Günther Brammer
3760363a3b
Script: Add GetPrototype and SetPrototype functions
...
This should eventually replace the Prototype property, so that proplists
can be used as a key-value-storage without any hidden gotchas.
The Prototype is such a magical property that any code dealing with all
properties has to special-case it anyway, and isn't even returned by
GetProperties().
2016-04-28 02:59:11 +02:00
Günther Brammer
525cdc11a3
Deduplicate calculation of the relative stack position of local variables
2016-04-28 02:59:11 +02:00
Günther Brammer
071feaa78f
Deduplicate loop control handling in the script parser
2016-04-28 02:59:11 +02:00
Günther Brammer
efd4724084
Script: Add Scenario effects
...
These work just like global effects, except that effects from CreateEffect
get the scenario as target parameter in the callbacks.
2016-04-28 02:53:21 +02:00
Günther Brammer
97406d24d2
Script: Add Construction and Destruction effect callbacks
2016-04-28 01:08:04 +02:00
Günther Brammer
50378ffda0
Script: CreateEffect starts effects that receive callbacks themselves
2016-04-28 01:08:04 +02:00
Günther Brammer
e5cfb1858f
Script: GetName() can return the property a proplist was defined in
...
This means that the ActMaps do not need to repeat their name anymore,
provided that all Scripts use GetName() instead of directly accessing .Name.
2016-04-24 19:40:29 +02:00
Günther Brammer
5a470f51f8
Move Effect functions to C4Script.cpp
2016-04-24 19:40:29 +02:00
Günther Brammer
2cdf553953
Change effect list getting function parameter type to C4PropList*
...
This makes it possible to move the effect functions to C4Script.cpp.
2016-04-24 19:40:29 +02:00
Günther Brammer
e8811a7b21
Move global effects from ::Game to ::ScriptEngine
...
This even enables some simplification in the CompileFuncs, since the global
effects were already put in the same section as the other ScriptEngine
parts. The callback for updates due to relinks also fits nicely.
The reset in C4Game::Default was redundant with C4Game::Clear already.
2016-04-24 19:40:28 +02:00
Günther Brammer
e2c6c2a841
Do not use C4Object in C4Effect
...
Instead, the pointer to the effect list is passed to the functions that
previously used the object to determine it.
2016-04-24 19:40:28 +02:00
Günther Brammer
c89e73608b
Unite getting the effects list from a C4Object pointer into a function
...
This way, that function can be re-implemented in standalone c4script.
2016-04-24 19:40:28 +02:00
Günther Brammer
42a15e3be9
Convert C4Effect parameters that do not need to be C4Object* to C4PropList*
2016-04-24 19:40:28 +02:00
Günther Brammer
bfb9b6b1fd
Drop the roundtrip through C4ID for the effect C4Def command target
...
Unfortunately, this complicates the C4Effect::CompileFunc to stay
compatible.
2016-04-24 19:40:27 +02:00
Günther Brammer
632c5cbd0f
Refactor effect callbacks into helper functions
2016-04-24 19:40:27 +02:00
Günther Brammer
e22ca51f72
Don't leak references to Strings on script errors ( #583 )
2016-04-24 19:40:27 +02:00
Günther Brammer
5fbac346d3
Incompatible type warnings work for parameters with type declarations
2016-04-24 19:40:27 +02:00
Günther Brammer
55572720bc
Make the C4ScriptHost a ComponentHost again
2016-04-24 19:40:27 +02:00
Günther Brammer
fb76308812
Make C4ValueConv::Type a constexpr variable instead of an inline function
2016-04-24 19:40:26 +02:00
Günther Brammer
b54ddc7663
Merge branch script
2016-03-01 03:04:17 +01:00
David Dormagen
4c6d347c4d
C4ValueArraySortStringscomp: silenced string-to-bool-conversion warning
...
VisualStudio gave a "performance warning" about this implicit cast. I actually don't know why, but this change makes the intention clearer anyway (since we are not returning the string contents but just whether they exist). So it's probably not bad regardless of whether the warning is weird.
http://stackoverflow.com/questions/1847860/why-is-there-a-performance-warning-on-cast-pointer-to-bool
2016-02-27 11:42:37 +01:00
Günther Brammer
0c0c64642a
Remove unused #define in C4AulParse
2016-02-12 17:15:46 +01:00
Maikel de Vries
159dbf071f
make ContactCalls a property instead of DefCore entry
...
This allows for useful runtime changes, like disabling contact calls when an animal dies.
2016-02-08 21:25:43 +01:00
Günther Brammer
fdbad8fe83
Simplify the test for loop end in parameter parsing
...
Instead of storing in fDone whether the token is a ')', make that the loop
condition.
2016-02-02 02:57:50 +01:00
Günther Brammer
f1b99aa355
Avoid pushing and popping an unused parameter with ...
2016-02-02 02:57:49 +01:00
Günther Brammer
6a6c0d8b0b
Optionally warn about too many parameters in -> calls, too
...
While at it, only consult the right function for direct calls, not any
other function with the same name.
2016-02-02 02:57:49 +01:00
Günther Brammer
b2c263bd0e
Don't mark the condition of do-while as a jump target without a continue
...
In contrast to the other loops, where the condition is always jumped to.
2016-02-02 02:57:49 +01:00
Günther Brammer
00f013d59e
Optimize accessing the same variable as was just now set
2016-02-02 02:57:49 +01:00
Günther Brammer
b7eff7f55f
Set jump target flag for bytecode added after MakeSetter removed one
...
Also avoid removing the original bytecode if it is DUP, LOCALN or GLOBALN.
This way, setting the jump target flag can be avoided in some cases.
2016-02-02 02:57:49 +01:00
Günther Brammer
532b47ed27
Optimize do; while(!...) from two bytecodes to one
...
This revealed that the code for setting Par.i was wrong before, but didn't
matter because the jump target for all CONDN was set afterwards. But the
jumptarget for COND was set directly, and must be adjusted to account for
the bytecode that gets optimized away.
2016-02-02 02:57:49 +01:00
Günther Brammer
168ac8bb40
Remove pointer to start of variables from function context
...
It pointed always to Pars + Func->GetParCount(). The only users were
VARN_CONTEXT, which can be replaced with PARN_CONTEXT that way, and
FOREACH_NEXT, where the parser can do the math and simply give a number
relative to the current stack position, like regular variable usages do.
2016-02-02 02:57:48 +01:00
Günther Brammer
45003d55fb
Guard against script stack overflow on the first script call, too
...
This can happen when an engine function is made to call a script function
when the stack is almost exhausted. Since there was nothing catching that
exception, it'd mean a program abort. Move the bulk of the exception
handler to the outer Exec function, and only keep the saving of the exact
code position in the inner one.
While at it, simplify the pushing of the parameters to simply push the
right amount of parameters instead of pushing ten and then popping the
excess. Also move the creation of dummy parameters for DirectExec into
DirectExec().
2016-02-02 02:57:48 +01:00
Günther Brammer
5bb3d7cb77
Use a null C4ScriptHost to parse DirectExec code
...
This mostly makes Parse_Expression use the case for functions in proplists
instead of the other for local variable lookup.
2016-02-02 02:57:48 +01:00
Günther Brammer
ac9106d197
Remove some unused and unsound C4Value operators
2016-02-02 02:57:48 +01:00
Günther Brammer
39d04360c4
Add some const (C4StringTable::FindString)
2016-02-02 02:57:48 +01:00
Günther Brammer
87689d9f49
Move the global proplist from a member of ScriptEngine to an ancestor
...
While at it, denumerate the global proplist. Not that it contains anything
to denumerate, but someday it might?
2016-02-02 02:57:48 +01:00
Günther Brammer
6f98fb2e66
Remove C4AulScript class
...
It isn't needed to hold engine functions anymore, because those are just
put into C4PropLists.
2016-02-02 02:57:47 +01:00
Günther Brammer
9dafc6424b
Make the ScriptEngine not a C4AulScript
...
Every script has its own C4ScriptHost, the ScriptEngine doesn't use
anything from C4AulScript.
2016-02-02 02:57:47 +01:00
Günther Brammer
473415bafa
Stop using virtual functions to distinguish profiling all or some functions
2016-02-02 02:57:47 +01:00
Günther Brammer
9742a404ff
Move Script Parser warning function to C4ScriptHost
2016-02-02 02:57:47 +01:00
Günther Brammer
a6020197d7
Move script string table to C4ScriptHost
...
The string table in C4AulScriptEngine was never loaded.
2016-02-02 02:57:47 +01:00
Günther Brammer
d3890f8c99
Remove empty C4AulScript::Clear()
...
The virtual call was only made from ~C4AulScript, and the deriving classes
already called their own Clear() from their own destructors.
2016-02-02 02:57:47 +01:00
Günther Brammer
b21acff0c7
Move Scriptparser State into C4ScriptHost
2016-02-02 02:57:46 +01:00
Günther Brammer
2fe0beebdb
Move contents of src/gamescript into other directories
...
C4Effect will get moved into the ScriptEngine, and just three source files
is a bit too little for one directory.
2016-02-02 02:57:46 +01:00
Günther Brammer
2ebd1a98ad
Script: Functions in constant proplists can access their properties
2016-02-02 02:57:46 +01:00
Günther Brammer
f757706e68
Make the C4Script tokenizer context-independant
2016-02-02 02:57:46 +01:00
Günther Brammer
9193c8938b
Retire the split between Parse_Expression and Parse_Expression2
...
In earlier C4Script versions, there were multiple variants of expressions,
all followed by the same operator options, but nowadays everything is more
uniform.
2016-02-02 02:57:46 +01:00
Günther Brammer
79043c8424
Reset the size of a C4Set in Clear()
...
This bug manifested itself in mysteriously growing PropLists with nil keys.
Some usages of Clear were simply to clean the newly-allocated table, and
need to continue to do so.
2016-01-25 00:54:58 +01:00