David Dormagen
d3dba14323
added support for custom menus and dialogs
2013-02-12 20:39:20 +01:00
Günther Brammer
1cf1be1c6d
Hold a reference to the temporary proplist used in case of script errors
...
The parser does not know whether the constant proplist it is about to fill
is missing because it was overwritten by a later local/constant, or because
the preparser was interrupted by a script error and didn't store its
proplist. Thus, the parser cannot simply give up at that point, and in
order to keep things simple it creates a throwaway proplist. This proplist
was thrown away too soon, though.
Thanks to Zapper for the testcase.
2013-02-12 01:11:31 +01:00
Günther Brammer
df3fcd2b2b
Document C4PropList internals a bit
2013-02-11 22:23:05 +01:00
Sven Eberhardt
bf8655ab1d
Fix Call() in global context (required for ScheduleCall)
2013-01-31 22:38:16 +01:00
Günther Brammer
a62e556b63
Script: Reimplement GameCall in C4Script
2013-01-23 21:36:21 +01:00
Günther Brammer
f38670abc3
Script: Functions can shadow global variables
...
Previously, declaring a global variable could break another script that had
a function with the same name.
2013-01-23 21:36:21 +01:00
Günther Brammer
42608c5209
Remove C4DirectExecScript, use an existing scripthost for the eval function
...
Since the scripthost isn't used to store the bytecode anymore,
Parse_Expression doesn't modify it anymore. So there is no need for a
temporary one.
2013-01-23 21:36:21 +01:00
Günther Brammer
57c01ac537
Rename C4AulParse::a to C4AulParse::Host and add C4AulParse::Engine
...
C4AulParse::Host is now only used for local variables and named functions.
Global directexec functions have neither, so they won't need a scripthost
at all anymore.
2013-01-23 21:36:21 +01:00
Günther Brammer
ce87faaf9e
Fix #including a definition that has local variables with proplists
...
The missing break meant that the freshly created copy of the proplist would
get overwritten by the original, which was thankfully caught and announced
with "internal error: constant proplist has the wrong parent".
Thanks to Zapper for the testcase.
2013-01-18 01:45:06 +01:00
Günther Brammer
864c5c7ea8
copyright notices update 2012
2013-01-12 16:31:40 +01:00
Günther Brammer
08f86c2038
Script: continue in a do-while loop jumps to test instead of start of loop
...
This matches C and other languages.
2013-01-08 21:21:11 +01:00
Günther Brammer
6e4b5bd0ca
Don't crash on Call()
2012-12-31 22:03:12 +01:00
Günther Brammer
6a6190564f
Remove some forward declarations that are already in C4Prototypes.h
2012-12-31 22:03:12 +01:00
Sven Eberhardt
16d4258b09
Added some array sorting functions to C4Script
2012-12-17 16:41:39 +01:00
Sven Eberhardt
86b20be644
Fix C4Command::Jump, i.e. jumping as part of pathfinder.
2012-12-09 18:44:22 +01:00
Günther Brammer
af62ab7931
Move script bytecode from C4ScriptHost into C4AulScriptFunc
...
This makes functions independent of their "Code Owner"s, which removes the
necessity to maintain that connection and carefully reset functions when
their scripthost is cleared.
2012-10-21 18:14:32 +02:00
Peter Wortmann
95ad163c29
Fixed warning
2012-11-05 17:17:51 +00:00
Günther Brammer
cd147525eb
Script: Warn when redefining a global constant
2012-10-23 02:05:33 +02:00
Günther Brammer
e0aa23c8ba
Rename C4PropList::NewAnon to C4PropList::NewStatic
...
"Anon" referred to the fact that these proplists have neither a number,
like simple proplists, objects and effects, nor an ID like Definitions.
However, they now store the names of the global constant or property they
are in, so "Anon" is no longer appropriate.
There are now three classes of proplists:
- ordinary proplists (C4PropListScript) have a number only in the savegame
- objects and effects (C4PropListNumbered) always have a number
- proplists created during initialization (C4PropListStatic) have a path
So the function could be called NewNamed, but the source of the proplist
has been far more stable than the method used for serialization, and Static
somewhat describes the source.
2012-08-15 19:43:02 +02:00
Günther Brammer
153ecf47a5
Script: GameCall doesn't catch script errors
...
FnGameCall is the only one that calls C4GameScriptHost::Call with
fPassError=true.
2012-08-19 21:29:43 +02:00
Günther Brammer
8cf2b6adf1
Script: Call can execute functions directly
...
Call(this["foo"],...) is now the same as Call("foo",...).
2012-08-19 17:34:53 +02:00
Günther Brammer
fb9309ec2c
Use a pointer to the operator definition instead of an array index
...
"op->" is a lot shorter than "C4ScriptOpMap[OpID]." Local variables. Use
them.
2012-10-21 16:13:53 +02:00
Günther Brammer
a5ac8b341d
Remove some superfluous {} from switch-case-constructs
...
To reduce and unify the indentation levels and reduce the number of lines.
2012-09-04 02:11:16 +02:00
Günther Brammer
dc4f3766fe
Script: Par(n) needs exactly one parameter, this() exactly zero
...
Mostly so that Parse_Params doesn't get used for things that are not
functions.
2012-08-13 19:07:56 +02:00
Günther Brammer
791484eb5a
Bytecode debug output uses GetDataString for array and proplist constants
2012-10-21 15:51:34 +02:00
Philipp Kern
4f67f73df2
Fix format string use
...
C4Aul's Warn uses the format attribute to check for format string correctness.
Passing a dynamic string buffer from FormatString to it will break the build
with -Werror=format-string. Given that Warn already does the formatting itself,
just drop the use of FormatString
2012-10-21 11:21:49 +02:00
Armin Burgmeier
b4aafdd874
Remove build number aka C4XVER4
2012-10-18 23:54:50 +02:00
Sven Eberhardt
140dc97b24
Rewrote PropList output string sorting to get rid of C4Set<T>::Sort()
...
C4Set<T>::Sort() breaks the internals of the class which Guenther doesn't like. Now the sorted list is returned as a list of pointers into the original set.
2012-10-16 15:47:56 +02:00
Günther Brammer
a912d98a29
Don't crash when a function is deleted after its Owner
...
Functions are refcounted now and might outlive their script. Fortunately,
the function destructor didn't really need the Owner. This further damages
the pretense of multiple scriptengines, but that could be repaired by
storing a pointer to the engine in the functions.
2012-10-14 20:45:35 +02:00
Sven Eberhardt
219dd68fd1
Some DebugRec on PropLists
2012-10-14 19:06:39 +02:00
Armin Burgmeier
b851f4b3fa
Fix the build
2012-10-14 15:18:28 +02:00
Sven Eberhardt
ec22028640
Some DebugRec fixes
2012-10-14 14:39:22 +02:00
Armin Burgmeier
5274f61bf5
Fix c4script build
2012-10-13 16:32:09 +02:00
Sven Eberhardt
4890015537
! Fix crash on shutdown due to object deinitialization order
2012-10-12 19:00:23 +02:00
Günther Brammer
f9afe30d74
Make C4StringTable leak detector not complain about "Global"
...
Simply put it into the list of internal strings. Its always used anyway.
2012-08-19 22:43:32 +02:00
Günther Brammer
91a6c309a9
Reduce the copies C4Set makes
...
Mostly by changing functions to take a const reference, but also by using
move constructors. This helps with C4String leak debugging by reducing the
reference count changes.
2012-07-26 01:21:15 +02:00
Günther Brammer
576edc1e23
Fix crash when including a script that nests proplists in a local variable
...
Previously, only the outer proplist would be copied, but the parser expects
the inner proplists to also be present. Copy proplists deeply instead, as
is already done for functions, and in the linking step.
2012-08-09 01:21:54 +02:00
Günther Brammer
bfdc02900c
Change C4AulScript::GetPropList() return type to C4PropListStatic*
...
This doesn't actually change the type of any object, but shifts some casts
around.
2012-08-09 01:17:26 +02:00
Günther Brammer
3aaa37ad41
Store global proplist in a C4Value like the Scenario proplist
...
Since the script engine doesn't have an appropriate function to create the
proplist in, simply create it in the constructor and arrange for the
string table to be constructed first.
2012-07-26 01:27:52 +02:00
Günther Brammer
4405ce0798
Clear Scenario local variables during script engine cleanup
...
Other script hosts are simply deleted completely, and the parser would
also clean these up, but this avoids a complaint from the string table at
exit.
2012-07-26 01:24:04 +02:00
Günther Brammer
7f9ab9ac19
Script: this returns nil after RemoveObject instead of throwing
...
Because the interpreter throws for every function that is called with a
this parameter that has been removed, this() isn't a function anymore.
The function could stay around so that Call("this") or foo->this()
would still work, but I doubt any script ever did that.
2012-06-18 04:07:36 +02:00
Günther Brammer
23d1246be1
Script: Add === and !== operators
...
These operators have a stricter definition of equality than the == and !=
operators. Those are already stricter than in some other languages, so the
new ones are probably not needed very often. But if the need does arise,
there's no workaround short of modifying the data structures and checking
whether they are still the same.
2012-06-11 00:47:28 +02:00
Günther Brammer
a528b0d76e
Silence some g++ warnings
2012-06-15 18:16:49 +02:00
Günther Brammer
bd371e38c1
Make the child pointers of the scriptengine C4AulScript*s again
...
The rope will create a C4AulScript for the rope engine functions instead of
putting them into the global scope, and we might want to put C4Object-only
functions into a separate C4AulScript some day, too.
2012-06-07 21:07:31 +02:00
Günther Brammer
4b2ea86726
Script: compare proplists by their contents instead of their identity
...
Objects, effects and definitions each have unique numbers/ids, so are
compared by identity as a shortcut.
2012-06-02 15:56:20 +02:00
Günther Brammer
cdeabedf77
Simplify C4AulFuncMap a bit
...
The map is currently only used in the parser for some warning heuristics.
Since it uses a hash table with separate chaining and the amount of
functions is fairly predictable, the hash table doesn't have to be
resizable.
2012-05-28 00:53:41 +02:00
Günther Brammer
c6fe23729b
Replace function list from C4AulScript with proplist enumeration
...
This finally makes the function list in C4AulScript unnecessary.
2012-05-28 00:50:13 +02:00
Günther Brammer
487a0ea38f
Store a copy of the proplist the preparser created for include/appendto
...
The parser now copies the contents of the proplists in the order of their
source scripts into the final proplist. This way, local variable contents
get properly included, and the list of functions has one user less.
2012-05-28 00:31:55 +02:00
Günther Brammer
e26bc8e33a
Move some parser implementation details to C4ScriptHost
2012-05-27 23:47:07 +02:00
Günther Brammer
7e00f3b5ad
Use printf format instead of two strings for script warnings and errors
2012-05-26 00:22:22 +02:00
Günther Brammer
ba1b896ebc
Move C4AulFunc implementation to a separate file from C4Aul.cpp
2012-05-14 22:07:33 +02:00
Günther Brammer
9d30869e87
Remove unused C4ScriptFnDef::FunctionC4V
...
Also move C4AulDefFunc and C4ScriptFnDef to the same header the template
helper classes are in. Like them, these classes are a mostly invisible
implementation detail of the engine script functions.
2012-05-20 02:39:57 +02:00
Günther Brammer
09a5247e9c
Convert the remaining classic FunctionC4V engine functions
...
The Call functions use the FunctionC4V2 style, the others the templates.
2012-05-20 02:04:46 +02:00
Günther Brammer
abbfe41632
Use FunctionC4V2 registration style for the various Format()-like functions
...
The majority of their arguments is essentially a list, so treating
the arguments as an array fits.
2012-05-19 18:34:17 +02:00
Günther Brammer
0ca1c16205
Remove helper macro, types and functions for FunctionC4V2 style functions
...
The remaining users are variable-argument-count functions not needing them.
2012-05-18 20:02:25 +02:00
Günther Brammer
68c2083f49
Convert most functions in C4Script.cpp to the template registration style
...
The only exceptions are the logging functions which will use the
single-C4Value-pointer style.
2012-05-18 19:44:53 +02:00
Günther Brammer
eb63110e4b
Use a macro to shorten the call to register engine functions
2012-05-18 19:41:38 +02:00
Günther Brammer
2fded23a1b
Editor: Get function autocomplete names from proplists instead of scripts
2012-05-18 17:49:38 +02:00
Günther Brammer
4e71af5489
Script: Add GetProperties function to get the keys of a proplist
2012-05-26 01:32:43 +02:00
Günther Brammer
62bc721a65
Make the child pointers of the scriptengine C4ScriptHost*s
...
This only tightens up the types a bit.
2012-05-15 19:32:58 +02:00
Günther Brammer
a10ebdfabe
Remove unused C4AulContext
...
The C4AulScriptContext is now an implementation detail of C4AulExec.
Also consolidate the C4Object * Obj and C4PropList * Def members to just
C4PropList * Obj and convert that to C4Object * on demand.
2012-06-04 00:03:49 +02:00
Günther Brammer
6815515a00
Consolidate C4AulFunc::Exec into just one virtual function
...
Deriving classes only need to implement one variant. The second Exec is a
trivial wrapper that doesn't have to be virtual.
2012-05-27 23:35:23 +02:00
Günther Brammer
09d08298bf
Replace C4AulContext* this of C4Script engine functions with C4PropList*
...
This mainly removes some indirection and a superfluous struct.
2012-05-15 03:03:47 +02:00
Günther Brammer
0e6f972de4
Remove unused C4Object* parameter from C4AulExecError
2012-05-15 03:11:23 +02:00
Günther Brammer
c86eadf5eb
Script: Show the this parameter in callstacks before the function with ->
...
Also reuse the display code from C4Value instead of yet another format.
2012-05-15 03:51:20 +02:00
Günther Brammer
034ca7d894
Script: constant expressions can use local variables
...
For example:
local foo = { bar = baz };
local baz = 27;
2012-05-18 17:40:46 +02:00
Günther Brammer
26a470b30f
The preparser creates static proplists, the parser looks them up by name
...
Constant expressions for global constants and for Definition properties are
now treated the same way. The preparser creates the structure that
the parser will fill in. Since the structure will not move, the parser can
refer to it before it is filled in, just like functions can call siblings
defined further down in the script. This will also allow proplists (and later
functions) to refer to each other.
2012-05-27 18:00:45 +02:00
Günther Brammer
c8907f5204
Shorten C4Value::GetDataString for Objects, Definitions and static proplists
...
The new output is also more often an expression that returns the value when
evaluated.
2012-05-08 02:24:43 +02:00
Günther Brammer
3a3ed01c89
Savegames: Save readonly proplists by their name
...
For example, the proplist in Clonk.ActMap.Walk is saved as DClonk.ActMap.Walk.
Should the script defining the proplist change while the savegame is stored,
the proplist will have the new contents instead of the old ones after savegame
load.
Also, save functions as DFlint.Hit instead of fDFlint.Hit. Loading uses the same
code as static proplist loading.
Curiously, this makes g++ 4.4 use the C4RefCntPointer move constructor,
which was broken until now. Fix it to take a mutable rvalue reference.
2012-06-01 17:27:59 +02:00
Günther Brammer
ef3078d1d0
Remove unused C4Value constructor
2012-05-14 16:18:20 +02:00
Günther Brammer
9c3f949142
Point to the beginning of the current token in script error messages
2012-05-16 23:24:40 +02:00
Günther Brammer
065b100dad
Script: eval throws an exception when the script does not end after the expression
2012-05-08 01:03:29 +02:00
Günther Brammer
ceb9c45984
Fix Script runtime reload
...
Just removing the right amount of functions from the proplists is
somewhat tricky, unfortunately.
2012-05-25 17:25:53 +02:00
Günther Brammer
830d6093a9
Fix Call error message
2012-05-07 21:28:43 +02:00
Günther Brammer
93169c7d33
Script: Make Call() throw again if neither function nor ~ is present
...
And skip a ~ in the function name again.
2012-05-07 20:49:08 +02:00
Günther Brammer
752e945b8d
Call C4PropList::Freeze in Link, remove now empty AfterLink functions
...
AfterLink was otherwise only used for the TimerCalls, which are now gone.
2012-05-06 00:06:33 +02:00
Günther Brammer
46fd427224
Simplify Fn_this
...
cthr->Obj is now 0 or == cthr->Def.
2012-04-28 22:02:35 +02:00
Günther Brammer
fb4bac65be
Remove C4AulContext::Caller
2012-04-28 21:32:29 +02:00
Günther Brammer
8a4181a3be
Replace C4AulObjectContext* with a simple C4Object* parameter
2012-04-28 22:04:36 +02:00
Maikel de Vries
6fcc0f6d2e
Removed TimerCall in favour of AddTimer script implementation
2012-05-05 12:09:44 +02:00
Günther Brammer
133e987902
Script: Throw instead of silently using nil for this after RemoveObject
2012-04-29 16:53:29 +02:00
Günther Brammer
2e9ae057ad
Remove obsolete assertion from FnTranslate ( #746 )
...
The rules for ctx->Obj and ctx->Def changed recently. The latter is now the
real this pointer, and Obj is Def->GetObject(). There's no need to check
this in FnTranslate.
2012-04-28 20:25:04 +02:00
Günther Brammer
1a29f8625d
Reorder engine source file organization a bit
...
This mostly consists of flattening the hierarchy, splitting the
graphics stuff out of platform, and a few smaller cleanups.
2012-04-27 19:04:43 +02:00
Maikel de Vries
4a56f8d7c1
Replaced defcore values related to fire with properties
2012-04-28 16:17:38 +02:00
Maikel de Vries
16fa9cf341
Placement is now a property instead of DefCore value
2012-04-16 22:17:05 +02:00
Julius Michaelis
d93384beb6
Add forgotten C4Value::operator== case for C4V_Function
2012-04-15 16:33:39 +02:00
Nicolas Hake
7efd9a9b9a
Aul: Add new nil-coalescing operator ??
...
This short-circuiting operator will evaluate to its first operand if the operand
is not nil, or to its second operand otherwise. Its intended use is to simplify
defaulting expressions that may evaluate to nil to a valid value.
2012-04-15 15:44:01 +02:00
Tobias Zwick
46156e3f1c
show tooltip for C4D_MouseSelect using the property "Tooltip"
...
+ remove references to the old and obsolete "help mode"
2012-04-15 12:09:54 +02:00
Julius Michaelis
57a07a95ab
Add forgotten string for function type values to GetC4VName
2012-04-14 16:53:35 +02:00
Günther Brammer
f89f19b2cb
Script: No #appendto in Defs or global functions in #appendtos ( #734 )
...
So the only thing #appendtos may contain are lokal functions and variables,
which are only reachable via the Definition the script is appended to, and
global constants and variables, which only need to be parsed once. Thus,
#appendto scripts can skip being parsed without a definition, and the
errors that sometimes produces are gone.
2012-04-13 21:43:43 +02:00
Günther Brammer
ac02380b58
Script: this->RemoveObject() changes this to nil ( #722 )
2012-04-13 20:28:30 +02:00
Günther Brammer
fe261ffca0
Script: GetType returns C4V_C4Object for objects again
2012-04-13 18:38:30 +02:00
Günther Brammer
f245af8972
Rename C4AulParseState to C4AulParse
2012-04-12 21:03:14 +02:00
Günther Brammer
05ef63bf64
Script: Make 0==nil false again
...
This was probably broken by the C4V_Any/C4V_Nil separation. Also clean
the function up a bit and add an assert that should catch similar stuff in
the future.
2012-04-11 02:25:24 +02:00
Julius Michaelis
335a6e0598
Fix C4ValueArray
2012-04-09 22:04:03 +02:00
Julius Michaelis
939f4c69ca
Fix array slice setting
2012-04-08 12:44:17 +02:00
Julius Michaelis
dcf59a4d61
Disallow cyclic prototyping
2012-04-08 12:43:19 +02:00
Günther Brammer
40de33ca3c
win32: Make sdl-mainloop option work
...
As it doesn't have the editor, this is only useful for compiling
more of our code on more platforms.
2012-03-23 22:53:56 +01:00
Martin Plicht
30840696c6
C4AulScriptEngine::Clear: Don't create GlobalPropList just to Clear() it
2012-03-22 21:49:55 +01:00
Günther Brammer
6126df616c
Make engine compile with debugrecs again
2012-03-11 17:52:00 +01:00
Armin Burgmeier
86af00a313
Fix the build
2012-03-12 23:41:07 +01:00
Günther Brammer
5c235cc23e
Savegames: Fix loading of global variables ( #726 )
...
The global variables ended up with the temporary name list created during
load that didn't necessarily contain all variables or even in the right
order. As far as I can tell, this happened since 2005, but nobody noticed
because the list of global variables didn't tend to change between save and
load.
2012-03-10 22:45:42 +01:00
Günther Brammer
dfea0914a9
Merge the functions pointer branch
2012-03-09 17:42:48 +01:00
Julius Michaelis
5716bb1e47
C4AulScript::DirectExec: Throw on parsing errors, too, when fPassErrors is set.
2012-03-09 11:45:25 +01:00
Günther Brammer
71e108f16a
Start of a C4Script API third party programs could use
...
This is very experimental, subject to change, and the single function not
at all useful yet.
2012-03-04 21:23:11 +01:00
Günther Brammer
6486ea9e19
Script: Disallow "new Clonk {}" for now
...
Eventually, "new Clonk {}" will create a C4Object. Prevent anyone from
using it before then.
2012-02-25 22:10:03 +01:00
David Dormagen
4169a9232c
swapped parameters of GetIndexOf
2012-02-25 21:57:39 +01:00
Günther Brammer
ce27d42ac7
Remove unused C4AulScript::Owner
...
C4AulScript::Translate referenced it, but used it only when called from
eval, which is not done.
2012-02-17 01:04:05 +01:00
Günther Brammer
464d372034
Make C4GameScriptHost save to call again for (c4script standalone)
2012-02-17 00:30:00 +01:00
Günther Brammer
67d8ac47e9
Keep functions across script reloads
...
For functions that are not appended/included, this is done by reusing them.
Functions that are not in the new script version are left with their code
raising and error. Appended/included functions are handled by a reference count.
2012-02-02 01:16:14 +01:00
Günther Brammer
1e7f32af48
Move C4AulFunc to its own header file
...
This is necessary since C4Value.h will call a function from C4AulFunc.
2012-02-13 18:00:35 +01:00
Günther Brammer
8091dff419
Clean up C4AulScriptFunc API
2012-02-01 03:49:50 +01:00
Günther Brammer
65801a5188
Remove C4AulFunc::LinkedTo
...
The parser doesn't need it to find the functions it has to parse anymore.
And the global proplist can be cleared before removing the functions,
instead of having engine functions deregister themselves and script
functions being deregistered when their linked function is removed.
2012-02-13 22:20:10 +01:00
Günther Brammer
30c843925f
Script: Include each script at most once
...
If a script includes two others which each include the same fourth, the
script only gets one copy. Which one is arbitrary and subject to change.
2012-01-25 03:50:24 +01:00
Günther Brammer
42679e48fb
Script: Inherit local variable initialization from #included scripts
...
This is done by creating their values in the parser. Global constants are
still created in the preparser so that they are available to the parser.
2012-01-25 00:36:11 +01:00
Günther Brammer
378e502c85
C4Script parser goes through the entire script instead of only functions
...
This should not change anything about which functions are created
by include/appendto and what inherited calls.
2012-01-27 00:42:41 +01:00
Günther Brammer
18038f45d3
Implement the function overload tree using the proplists
...
Instead of carefully inserting functions at the start or end of the list,
build the list just before the parser runs, at the same time as filling
the proplist where the functions are looked up.
This way, the overloaded function is simply the one that was previously in
the proplist, is not needed outside of the overloading function, and can thus
be replaced in the proplist.
2012-01-27 00:20:55 +01:00
Günther Brammer
f61ebfc453
Replace C4AulScript tree structure with a list
2012-01-25 04:15:39 +01:00
Günther Brammer
a7008e8a77
Script: Add "new p {}" syntactic sugar for "{ Prototype = p }"
2011-11-07 01:39:43 +01:00
Günther Brammer
4a3e692962
System.ocg scripts have a proplist for parsing purposes
2011-10-24 17:02:27 +02:00
Günther Brammer
24031a94bd
Simplify the C4Script tokenizer a bit
...
This shouldn't change any user-visible behaviour.
2012-01-24 18:35:21 +01:00
Günther Brammer
d07cc0c168
Some slight parser refactoring
2011-12-22 21:57:17 +01:00
Günther Brammer
dc7ca92936
Some parser code cleanups
2011-10-24 01:00:29 +02:00
Günther Brammer
ae11dfd1e4
Remove #strict infrastructure
...
The next incompatible changes to C4Script will probably use something else
anyway.
2012-01-25 04:15:53 +01:00
Günther Brammer
f3854e87f8
Replace C4AulScript::GetFunc with C4PropList::GetFunc/Call
2011-10-15 22:07:45 +02:00
Günther Brammer
497cd5cffc
Script: '->' also works with proplists
2011-10-15 02:30:30 +02:00
Günther Brammer
04e512fe00
Replace C4AulScript::GetFuncRecursive with C4PropList::GetFunc/Call
2011-10-15 02:27:02 +02:00
Günther Brammer
b6fb634bd3
Replace the other C4AulScript::GetSFunc with C4PropList::GetFunc/Call
2011-10-15 02:06:21 +02:00
Günther Brammer
db926e3f53
Replace C4AulScript::GetSFunc with C4PropList::GetFunc/Call
2011-10-15 02:05:10 +02:00
Günther Brammer
f7b3642bc6
Replace C4DefScriptHost::Call with C4PropList::Call
2011-10-15 02:03:04 +02:00
Günther Brammer
a01bb2cf9c
Remove function cache from C4DefScriptHost
2011-10-15 01:59:15 +02:00
Günther Brammer
bb3861d4f1
Replace C4AulScript::GetSFuncWarn with C4PropList::GetFunc
2011-10-15 02:11:57 +02:00
Günther Brammer
406b7c4eca
Savegames: (De)serialize functions in c4values
2012-02-13 18:12:08 +01:00
Günther Brammer
38c1bb3976
Add C4PropList::GetFunc and C4PropList::Call
2011-10-04 23:04:06 +02:00
Günther Brammer
0403bed306
Put functions into their proplists
2011-10-15 01:38:59 +02:00
Günther Brammer
a684ab4aba
Script: Infrastructure for functions as a value type
2011-09-25 01:20:18 +02:00
Günther Brammer
35a16421f1
Always compare C4Set entries with C4Set::Equals
2011-10-18 21:57:52 +02:00
Günther Brammer
34b8d2c8e7
Add C4Set::C4Set(const C4Set&) and C4Set::C4Set& operator=(const C4Set&)
2011-10-18 21:56:10 +02:00
Günther Brammer
f52b0d248f
Hash properties to c4string pointer, not the contents of the string
...
this might even make a difference, as the strings shouldn't have to be
dereferenced anymore.
2011-10-05 21:38:42 +02:00
Günther Brammer
bf86e81aa7
Clean category code up a tiny bit
2011-12-29 15:56:51 +01:00
Günther Brammer
b3aff643f3
Script reloading does not clear local variable defaults
...
The defaults are filled in by the preparser, which is only invoked for
changed scripts.
2011-10-04 22:16:27 +02:00
Günther Brammer
8185d318bf
Script: Add a proplist representing the global scope, named "Global"
2011-10-04 22:12:45 +02:00
Günther Brammer
f166fdaed7
Move Parser from C4AulScript to C4ScriptHost
2011-10-13 18:01:02 +02:00
Günther Brammer
843642271d
Script: local variables work for the Scenario and definition calls
...
This requires replacing C4AulScript::Def with C4AulScript::GetPropList() and
C4DefScriptHost::Def, and making C4GameScriptHost::GetPropList return the
scenario proplist prototype.
Definition calls won't be able to change the local variables, of course.
Other proplists will be able to use local variables once they can have
functions.
2011-09-29 03:49:21 +02:00
Günther Brammer
769c1083b6
Store C4AulFunc::Name in a C4String
2011-09-25 21:09:16 +02:00
Günther Brammer
ca4da88137
Script: Scenario functions get the Scenario proplist in "this"
2011-09-25 23:25:13 +02:00
Günther Brammer
a24ebc4936
Script: Add a proplist representing the scenario, named "Scenario"
...
The proplist is accessible from script via a global constant.
2011-09-25 23:24:29 +02:00
Günther Brammer
9f180dffee
Script: Remove ScriptGo, ScriptCounter, goto and the ScriptN callbacks
...
No scenario uses them, and ScheduleCall provides an alternative.
2011-09-19 21:33:05 +02:00
Günther Brammer
6f1057c69f
Script: this returns the definition in a definition call
2011-09-25 23:48:06 +02:00
Günther Brammer
b4021015f7
Make C4AulFunc::Exec take a proplist instead of an object
2011-09-25 23:49:17 +02:00
Günther Brammer
d723d43d92
Make C4AulContext::Def a proplist
2011-10-13 23:39:35 +02:00
Günther Brammer
2afeb25df6
Script: remove redundant check for 0 in object call
...
0 is neither object nor definition, so the ordinary typecheck suffices.
Also change the error message to use '->' instead of object or definition
call.
2011-09-26 20:29:32 +02:00
Günther Brammer
c63b66e909
Script: Add def and effect parameter types
2011-09-24 18:37:28 +02:00
Günther Brammer
dbaa638166
Clean up C4Value::CompileFunc
2011-09-26 21:57:25 +02:00
Günther Brammer
32e7eb2904
Only use C4V_C4Object as typecheck target, tag the values with C4V_Proplist
...
This simplifies a few places which had to check for both tags before.
2011-09-26 20:22:31 +02:00
Günther Brammer
0fa37ef35d
Optimize if(!...) from two bytecodes to one
2011-10-14 00:28:32 +02:00
Armin Burgmeier
6afadc6397
Allow mesh graphics images in messages
2012-01-10 22:40:46 +01:00
Armin Burgmeier
cc62b169c8
Add "MouseDrag" property for finer control of script-implemented drag+drop
2011-12-28 19:33:19 +01:00
Günther Brammer
ccbf4d1d45
Consolidate duplicated simple Log functions
...
The various small utilities do not use the engine Log implementation but
one that simply prints to stdout. Instead of duplicating that one, link a
common one into the utilities.
2011-11-02 21:36:39 +01:00
Günther Brammer
283876696d
Optimize away STACK 0 bytecodes
...
They got created for this without parentheses.
2011-05-07 00:18:00 +02:00
Günther Brammer
0c2ea0b6b5
C4AulParseState::AddBCC returns the position of the added chunk
2011-10-14 00:28:29 +02:00
Günther Brammer
c1d1424a56
Annotate Bytecode debug output with jump target labels
2011-05-07 00:19:01 +02:00
Günther Brammer
0cd46a2ebc
Wrap C4AulFunc::Name in C4AulFunc::GetName()
2011-10-14 00:40:55 +02:00
Günther Brammer
725f0e0f5a
Remove GuessType from a comment
2011-08-21 17:10:45 +02:00
Günther Brammer
8758e35255
Remove redundant C4Value::GetTypeInfo
2011-08-21 14:40:29 +02:00
Günther Brammer
39ba48ee54
Rename C4Value::ConvertTo(NoNil) to C4Value::Check(Par)Conversion
...
The NoNil variant thus has the shorter name, because most code should
use it. Conversion checks mostly secure code that uses the value and would
crash with a nullpointer. The exception are function parameters, which all
also accept nil and 0 and check for nullpointers in the function itself.
2011-08-21 01:47:38 +02:00
Günther Brammer
c82debf5f1
Remove almost unused C4AulScript::GetSFunc(int)
...
This also transforms a O(n^2) loop into a O(n) one. Though the n were small
and the loop seldomly called.
2011-09-30 01:39:12 +02:00
Günther Brammer
65a11ef1c3
Script: Remove unused function "descs"
2011-09-29 02:46:26 +02:00
Günther Brammer
3c41310fa3
Remove C4ConfigShareware to reduce OpenSSL dependency
2011-11-02 00:07:29 +01:00
Günther Brammer
5f2f995852
Unify the #include blocks a little bit
...
One line for C4Include.h, one for the .h corresponding to the .cpp, one
empty line, the other C4* includes, another empty line, external headers.
2011-11-01 23:17:41 +01:00
Günther Brammer
6700bff4de
Replace CFacet with C4Facet
...
The latter is almost a superset of the former.
2011-08-27 17:47:49 +02:00
Günther Brammer
562816cfe5
Clean up some unused variables and obsolete FIXMEs
2011-09-28 01:09:56 +02:00
Günther Brammer
1ebc11c213
Savegames: Rename some fields in the Game.txt
...
Effects/GlobalEffects is now Script/Effects, and Script/GlobalNamed is now
Script/StaticVariables
2011-09-19 21:48:14 +02:00
Günther Brammer
4a32e63c46
Savegames: Correctly Denumerate the first enumerated value ( #657 )
...
When that value was copied it went from Enum 0 to nil. While this could
be fixed by making C4V_Enum a NullableType, counting from 1 is a tiny bit
less code overall.
2011-09-19 23:02:18 +02:00
Günther Brammer
9bc61db360
copyright notices update 2011
2011-09-01 16:58:52 +02:00
Nicolas Hake
fe747db554
Clean up copyright notices
...
Use real names for copyright attribution wherever they are known,
drop duplicates
2011-09-01 12:47:54 +02:00
Armin Burgmeier
333f562721
Some compiler warning fixes
2011-08-17 23:55:24 +02:00
Günther Brammer
d0010ecb0f
Fix c4script standalone with debugrec
2011-07-17 15:56:53 +02:00
Tobias Zwick
92069bb2f8
removed undocumented ~GetCustomComponents callback and the involved hackery
2011-07-31 02:22:29 +02:00
Tobias Zwick
481a59835c
docs: talk about nil for defaults. enclose nil, false and true in <code> tags
2011-07-31 01:32:02 +02:00
Maikel de Vries
248f85c2eb
Removed Defcore:Edible and OCF_Edible
...
Had no use in the engine, should therefore be defined in C4Script if deemed necessary.
2011-07-05 13:10:56 +02:00
Günther Brammer
a533b93f10
Do not print a deleted-object-warning while warning about that object
2011-05-25 20:09:12 +02:00
Günther Brammer
37242503df
Read old nil C4Values from player files for compatibility with 5.1
2011-05-21 23:13:49 +02:00
Günther Brammer
e0f49b4cca
Handle unknown C4Value type tags in player files or save games
2011-05-21 23:12:43 +02:00
Günther Brammer
b1e3eeb32d
Savegames: Do not assert() that all C4Values are unenumerated
...
Only C4V_Any never makes it into the Type field of a C4Value.
2011-05-15 19:30:53 +02:00
Günther Brammer
2d9d0d8596
Reduce verbosity of backtraces with object parameters
2011-05-09 23:19:31 +02:00
Günther Brammer
f2d2cd098b
Correct is-current-code-in-function assertions
2011-05-08 19:28:48 +02:00
Günther Brammer
f97cde74c3
Split C4V_Any into C4V_Nil for the data type and C4V_Any for the typecheck
2011-05-09 14:37:28 +02:00
Günther Brammer
fed6d6a0de
Script: Debug output for proplist contains all properties
2011-05-05 22:27:22 +02:00
Günther Brammer
af52109912
Small parser cleanups
2011-05-02 23:52:41 +02:00
Günther Brammer
9c4dabc810
Maintain a pointer to the last added bcc, instead of one after that
2011-04-13 02:16:55 +02:00
Günther Brammer
e3bcd14db0
Simplify Parse_FuncHead
2011-04-18 01:50:33 +02:00
Günther Brammer
baeffbc67f
Let script functions have less than 10 parameters
...
Script functions using ... or Par() still take all 10
parameters, but those are the exceptions now. This makes
calling functions with few parameters faster.
2011-04-18 01:48:37 +02:00
Günther Brammer
63a3b546d5
Use bytecode to push variables onto the stack
2011-04-17 23:52:55 +02:00
Günther Brammer
50b6fcf47a
Use AB_DUP instead of AB_PARN
2011-05-02 21:39:52 +02:00
Günther Brammer
0b8c2bba37
Use AB_DUP instead of AB_VARN
2011-05-02 21:53:58 +02:00
Günther Brammer
76376ee7bb
Remove unused C4AulFunc::GetLocalSFunc
...
ResortObjects was the only user, and that's gone now.
2011-05-03 00:56:49 +02:00
Günther Brammer
fadacd3bb4
Move StrToI32 to lib/
2011-05-01 18:55:02 +02:00
Günther Brammer
117cbe2b81
Script: Add warnings against wrong operator parameter types
2011-05-01 18:53:50 +02:00
Günther Brammer
7b640daedb
Script: Add "\t" escape for tabulator
2011-04-13 23:51:35 +02:00
Günther Brammer
82f6b180e1
Split C4Value typecheck into two variants, one not permitting nil
...
Previously, the typecheck callers often separately checked for
null pointers. This is superfluous since C4Value already checks
for null pointers.
2011-04-11 23:33:11 +02:00
Günther Brammer
51d75e891b
Move script operator parameter types from a table into the code
...
This makes the target type visible to the compiler.
2011-05-01 17:16:02 +02:00
Günther Brammer
7eedece257
Replace C4Value typecheck table with switch statements
...
This has the advantage that the compiler can simplify the check when the
target type is known at compile time.
2011-04-10 03:46:59 +02:00
Günther Brammer
c21248d322
Decrease the initial size of hash tables
...
At the moment, the majority of hash tables has at most one element, so
allocating more is wasteful. There needs to be at least one unused bucket
in the table, so the initial size is 2.
Also, increase the maximum load factor to 3/4.
2011-04-14 16:16:59 +02:00
Günther Brammer
b1a76adb62
Fix debug build
2011-04-14 15:36:31 +02:00
Günther Brammer
1e28504cde
Optimize the script interpreter a bit
...
Integer and boolean constants aren't wrapped in a temporary C4Value. The
overflow check is reduced to one subtractions and comparison to a compile
time constant. C4Value::Set(const C4Value&) doesn't duplicate the check for
the setting to the same value in C4Value::Set(C4V_Data, C4V_Type).
2011-04-10 02:00:27 +02:00
Günther Brammer
5596a57d83
Do not check for stack underflow in release builds
...
Unlike overflows, underflows can only occur when the parser is faulty. In
release builds they just slow the interpreter down.
2011-04-10 17:52:20 +02:00
Günther Brammer
dbe7c37db0
Script: Only debug if the debugger was present before compilation
...
This saves a lot of AB_DEBUG bytecodes in the normal case.
2011-04-10 03:40:55 +02:00
Günther Brammer
435ed78cd9
Script: Remove unimplemented Par(n)=foo
2011-04-10 02:05:11 +02:00
Günther Brammer
a3fab0234e
Create PropLists with one bytecode instead of one per property
2011-04-09 21:35:16 +02:00
Günther Brammer
71f42d7d8f
Correct assert checking that the bytecodepointer is still in the function
...
Previously, if the first byte code of the function was an AB_FUNC, the
assert would erroneously fail.
2011-04-12 00:10:51 +02:00
Günther Brammer
4575f28605
Log call stack when using a deleted object
2011-04-13 15:38:49 +02:00
Günther Brammer
4ae204e2fb
Remove unnecessary includes pulling C4GUI into the script engine
2011-04-13 15:37:12 +02:00
Günther Brammer
21e28a4689
Script: Use Unicode instead of Byte strings
...
Internally, strings are UTF-8 as before, but GetChar returns an
Unicode code point instead of a byte from the UTF-8 encoded string,
and Format("%c") takes an Unicode code point as well.
2011-03-10 00:26:31 +01:00
Günther Brammer
6768614feb
Silence various warnings
2011-03-28 20:58:42 +02:00
Günther Brammer
24fe22faff
Remove redundant check for AB_FUNC bytecode having a function
...
AB_FUNC always has a function.
2011-03-28 20:57:51 +02:00
Günther Brammer
b403fc61c1
Reduce code duplication a bit
2011-04-01 00:03:02 +02:00
Günther Brammer
e6e5b801d6
Check proplist reference lists in debug builds
...
This should help find the next added-to-list-twice bug.
2011-03-31 22:53:07 +02:00
Günther Brammer
38e9926c12
Do not add a C4Value to a proplist reference list it already is on
...
This could happen when nType was PropList or Object and Type was the other.
2011-03-31 22:26:07 +02:00
Günther Brammer
f3365ab73b
Arrays with multiple references are stored just once
...
This is done with the new C4ValueNumbers class. Every array and proplist
with the exception of objects, definitions and effects gets a number
when the game is saved and is restored via that number on load.
2011-03-27 18:14:41 +02:00
Günther Brammer
f582a97998
Add C4ValueNumbers helper class and pass it through to C4Value::CompileFunc
...
In preparation of using that class to enumerate and denumerate various
pointers.
2011-03-26 23:59:35 +01:00
Günther Brammer
b5dea20dae
Remove some dead code
2011-03-27 18:15:10 +02:00
Julius Michaelis
61d93c39cf
Fixed some files which didn't include C4Include properly (all except C4Globals.cpp caused by 17d0ceb9ef2f)
2011-03-14 16:32:01 +01:00
Günther Brammer
6c2a89eaf8
Replace timeGetTime with a platformneutral GetTime wrapper
2011-03-13 17:25:35 +01:00
Armin Burgmeier
41a1b5867d
Change .c4g extension to .ocg
2011-03-13 16:16:45 +01:00
Günther Brammer
c009851ce2
Script: Remove unused category parameter from GetDefinition
...
While at it, also remove it from the internal function and a bunch of dead
code from C4IDList.
2011-03-07 21:26:56 +01:00
Günther Brammer
8323f6c01d
Add a standalone C4Script interpreter
2011-03-05 17:40:22 +01:00
Günther Brammer
89413fcd6e
Move some code out of C4ScriptHost.cpp
2011-03-05 17:36:16 +01:00
Günther Brammer
de626b18aa
Script: Only show error messages in the Log
2011-03-05 16:50:22 +01:00
Günther Brammer
39276c6fd1
Check all pointers to PropLists in c4values in debug engines
...
This can find some refcounting errors by verifying that the proplist did
not get deleted before it is used.
2011-02-06 22:30:31 +01:00
Günther Brammer
75dc49e746
Replace Objects.ObjectNumber with C4PropListNumbered::CheckPropList
...
There's no need to go through the entire object list to get an object
number, so convert most usages of ObjectNumber(obj) with obj->Number. Add a
new method to check proplist pointers for debugging purposes to
C4PropListNumbered.
2011-02-06 01:59:49 +01:00
Günther Brammer
a7615ddced
Make C4PropListNumbered global data static members of the class
...
Previously, this was in ::Game and ::Objects. Both classes still work on
that data, but not as much as before.
2011-03-05 03:32:51 +01:00
Günther Brammer
f4ee636072
Remove some redundant Default methods
...
Using the same method for the constructing and clearing an instance just
leads to leaks and subtle bugs.
2011-03-05 03:24:11 +01:00
Günther Brammer
28a154dcdf
Drop unused third C4LangStringTable::ReplaceStrings parameter
2011-03-05 01:05:36 +01:00
Günther Brammer
609b9bbe93
Fold C4ComponentHost::Default() into C4ComponentHost::C4ComponentHost()
2011-03-05 01:03:09 +01:00
Günther Brammer
6eebaeaac8
Fold C4AulScript::Default() into C4AulScript::C4AulScript()
2011-03-04 15:20:21 +01:00
Julius Michaelis
98717a4051
C4Script: Remove obsolete function GetSystemTime
2011-03-05 14:25:37 +01:00
Günther Brammer
111df0392c
Split C4Script.cpp into game functions and C4Script support functions
2011-03-04 13:49:41 +01:00
Günther Brammer
264009060c
Script: Remove Method from function descs
2011-03-03 02:25:01 +01:00
Günther Brammer
45620c2b85
Move some C4AulDebug code into C4AulDebug
2011-03-03 00:58:43 +01:00
Günther Brammer
8749395a18
Use Nillable<void>() instead of C4VNull as the always-nil return value
2011-03-03 00:57:38 +01:00
Günther Brammer
bdbe3beabf
Optimize the template engine script function wrappers slightly
2011-03-02 23:42:34 +01:00
Günther Brammer
e250312c26
Move C4DefList class into from C4Def.cpp/h to new C4DefList.cpp/h
2011-03-03 17:10:22 +01:00
Günther Brammer
ed86af5f29
Script: Proplists with Object prototypes are also Objects
2011-03-02 14:12:06 +01:00
Günther Brammer
7ce65373a3
Replace C4AList with some std::lists
2011-02-26 00:48:19 +01:00
Günther Brammer
5c18c7aa33
Reduce the time a C4String pointer sits in an integer variable
2011-02-22 00:07:08 +01:00
Günther Brammer
a13309d752
Separate builtin C4Strings from dynamic ones in the leaked-strings-list
2011-02-25 18:11:54 +01:00
Günther Brammer
3a3434fc95
Script: Remove some unnecessary inspections of callers of builtin functions
2011-02-23 21:06:14 +01:00
Günther Brammer
0bad4b7f59
Script: Parse negative numbers in nested constant expressions
...
Previously, local foo = [-1]; would complain about an unexpected '-'
operator.
2011-02-19 22:37:42 +01:00
Günther Brammer
b9cf00d824
Script: obj->~foo() cannot have whitespace between -> and ~ anymore
...
This slightly simplifies the parser, as ->~ is now one token and ~ does not
double as binary not and call failsafety indicator.
2011-02-19 22:18:27 +01:00