Lukas Werling
60e9383a42
Improve seeding of UnsyncedRandomRng
2016-05-01 19:21:09 +02:00
Günther Brammer
9741af42fd
Replace all usages of the old local variables list with properties
2016-05-01 00:28:37 +02:00
Günther Brammer
7792acdff0
Script: Check for functions before keywords
...
This unifies the lookup for local variables and functions. Its slightly
awkward that global functions can overload if and Par now, but local
variables already could.
2016-05-01 00:28:37 +02:00
Günther Brammer
30f7457d89
Remove unused macros leftover from removed script features
2016-05-01 00:28:37 +02:00
Günther Brammer
b8f2d0ca87
Script: Repeat the parser error message when executing a broken function
2016-05-01 00:28:37 +02:00
Günther Brammer
17b18da26c
Make bytecode dump work again
...
Dumping the bytecode before adding EOFN while depending on that to signal
the end isn't such a hot idea.
2016-05-01 00:28:37 +02:00
Günther Brammer
904bf78d68
Don't crash when deserializing an effect with object command target ( #1730 )
2016-04-29 00:16:20 +02:00
Günther Brammer
4092911349
Move code generation into its own class
2016-04-28 03:25:47 +02:00
Günther Brammer
b00b8554ab
Merge branch script
2016-04-28 03:25:44 +02:00
Günther Brammer
d45ac946fe
Add C4AulParseError constructor and cease reusing it for warnings
...
The nontrivial code that formats the position is now a function of
C4AulParse used by both warnings and errors.
2016-04-28 02:59:12 +02:00
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
Nicolas Hake
072661239d
GRBroadcast: Don't noisily fail when a callback function does not exist
...
Since GRBroadcast calls all goal and rule objects and the scenario,
there is a high likelyhood that not all of them implement whatever
arbitrary callback is called. Instead of throwing script errors about
calling undefined functions, just swallow that error and continue.
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
Lukas Werling
c349254d8b
Remove C4Particles.h include from C4Object.h
...
This reduces the number of files indirectly including PCG from ~50 to 7.
2016-04-25 21:24:27 +02:00
Lukas Werling
e33066a4f2
Rename SafeRandom() to UnsyncedRandom()
2016-04-25 17:32:23 +02:00
Lukas Werling
e734f15117
Remove RNG implementation from C4Random.h
2016-04-25 17:28:04 +02:00
Lukas Werling
aeabe28d82
Remove AsyncRandom() script function
...
We couldn't think of any reason you'd want to use this over regular
Random() in script.
2016-04-25 17:18:07 +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
Nicolas Hake
19a3d43558
Fix definition of explicitly sized enums
2016-04-24 15:20:28 +02:00
Nicolas Hake
baad3aef3c
C4ScriptHost: add const proplist accessor
...
This accessor does not need to be virtual itself, because we don't want
people to override it; it calls the nonconst accessor anyway, which is
virtual.
2016-04-24 14:01:23 +02:00
Nicolas Hake
96223f154c
C4ValueMapNames: mark GetItemNr const
...
It doesn't change anything, so callers don't need a nonconst object.
2016-04-24 14:01:23 +02:00
Nicolas Hake
caf44e2473
Remove specious space from Aul operator table
2016-04-24 14:01:23 +02:00
Nicolas Hake
770be2dafe
Aul: Allow AB_ERR to carry more detailed error information
2016-04-24 14:01:23 +02:00
Nicolas Hake
367f58b1cc
C4AulParseError: Enable creation from host and source pointer
...
Instead of having a C4AulParseError constructor read the location data
from the parse state, allow explicit construction from a known location.
2016-04-24 14:01:23 +02:00
Nicolas Hake
cfdb1142b8
Move C4AulParse declaration into separate header
2016-04-24 14:01:23 +02:00
Lukas Werling
5471fe6cff
Fix randomness in particles with identical properties
...
Several issues:
- The RNG wasn't copied with the value provider (which is always
copied), resulting in unseeded RNGs.
- Separate PCG streams with the same seed start with identical values.
As particles often draw only a single value, we just always advance
the RNG a bit to make the streams diverge.
- The C++ specification requires a <= b for its distributions, but that
wasn't guaranteed by the particle startValue/endValue.
2016-04-23 23:29:36 +02:00
Sven Eberhardt
bc32456ac1
Fix crash on Random(0)
2016-04-22 16:44:35 -04:00
Lukas Werling
b0c1d819af
Reduce game list refresh limit to 1 second
2016-04-22 10:50:03 +02:00
Lukas Werling
0fefc7abae
Merge branch 'pcg'
2016-04-21 20:47:34 +02:00
Lukas Werling
e6a39392dd
Use PCG for C4Particle
2016-04-21 20:39:40 +02:00
Lukas Werling
febc5f91bd
Replace rand() with SafeRandom()
2016-04-20 22:42:00 +02:00
Lukas Werling
1f9c15e388
Allow MapZoom values smaller than 5
2016-04-20 22:42:00 +02:00