Commit Graph

563 Commits (96fcf1389aa97cbe6d90923e17f83dfc98a31c8b)

Author SHA1 Message Date
David Dormagen 40b66d1c76 added (early demo of) new particle system which should both be faster and more flexible than the old one 2013-10-07 20:56:49 +02:00
Nicolas Hake 7e260aa9de Remove C4ControlScript::fInternal
fInternal basically acted as a reverse "evil bit" as in RFC 3514: when
set, the engine would not do any checks on the script contained in the
control packet, nor log the script (visibly in game; the packet log
would of course contain the packet). A malicious game client thus would
be able to inject arbitrary script without people (immediately) noticing
anything was amiss.

As of this patch, only the host is able to execute arbitrary scripts,
and those will be shown in the message board for all players to see.
This privilege can be irrevocably disabled in network games by any
client by using the "/nodebug" message board command.

Closes #936.
2013-09-04 20:18:06 +02:00
Nicolas Hake 5b25b75370 Script executed on behalf of a script debugger is not engine-internal
While fInternal-flagged script controls may be useful for debuggers to
evaluate watch expressions because they don't get shown ingame, they
also bypass all checks the engine does and as such are a nightmare in
network play.

Part of #936.
2013-09-04 14:55:54 +02:00
Nicolas Hake 58a39e972f Improve C4Object const correctness 2013-08-31 23:23:35 +02:00
Tobias Zwick 9027544c37 Merge branch 'master' into Controls 2013-06-04 20:13:35 +02:00
Martin Plicht eaf93d6a0e Also check for DebugRec flag in #ifdef DEBUGREC_* blocks 2013-05-25 23:01:41 +02:00
Martin Plicht 524fe879aa Make DEBUGREC define a commandline option 2013-05-25 22:51:32 +02:00
David Dormagen d18d8c65c9 Merge branch 'Menus' into Controls 2013-05-24 01:24:57 +02:00
Sven Eberhardt 4557d1638e Added property LineMaxDistance to let a line break when connected objects are too far apart. 2013-05-09 12:02:44 +02:00
David Dormagen 9ad9a67939 Merge branch 'master' into Menus
Conflicts:
	src/script/C4StringTable.cpp
	src/script/C4StringTable.h
2013-04-07 23:02:36 +02:00
David Dormagen 1c05f22d41 added OnClose callback
more tests
minor fixes
2013-04-07 22:52:45 +02:00
David Dormagen c2ba7e65d7 improved menu functionality; added test scenario and helper objects 2013-04-04 18:36:27 +02:00
Günther Brammer a0f328468e Don't change Scenario.Prototype on Game.txt load
C4Value used itself as temporary storage, so when loading Scenario.Prototype
into Scenario.Prototype, bad things happened.
2013-04-01 23:56:22 +02:00
Sven Eberhardt 6250ff1766 Silence a few MSVC warnings 2013-04-01 12:48:02 +02:00
Sven Eberhardt 1e1d4eb78a Fix potential double-free of static Map and MapLayer prop lists (#935) 2013-03-27 21:48:18 +01:00
Nicolas Hake 459fce0758 Replace std::auto_ptr with std::unique_ptr
std::auto_ptr has awkward copy semantics and is deprecated in C++11.
2013-03-26 15:43:01 +01:00
Sven Eberhardt 671a815223 Fix MapLayer functions on derived prop lists (#935) 2013-03-24 13:29:04 +01:00
Günther Brammer 03a045810e Script: Ignore attempts to set Scenario.Prototype
This is mostly for the benefit of savegames, which rely on being able to
save scenario functions as Scenario.Prototype.*, but also removes an
opportunity to break things.
2013-03-22 23:00:12 +01:00
Sven Eberhardt ec38b4d9e4 Fix some C4MapScript dependencies 2013-03-22 22:24:20 +01:00
Sven Eberhardt 57e63a5275 Added support for scripted maps (Map.c) and documentation. 2013-03-19 00:36:06 +01:00
Sven Eberhardt b0a0d2a83c Rework logging of unfreed C4Strings a bit 2013-03-19 00:36:05 +01:00
Günther Brammer 2d86e47c04 Fix use-after-free in C4Value::CompileFunc
C4StringTable::RegString modifies the provided StdStrBuf. Use FindString
instead, since GetPropertyByS reliably returns failure for a
freshly-registered string anyway.
2013-03-10 22:47:17 +01:00
Günther Brammer 16f3fe34e1 Use correct exception when unable to compile a static proplist
excNotFound is used to signal that the end of a list is reached. But these
error conditions in C4Value::CompileFunc signal some logic error, not
finding an end-of-list marker instead of a C4Value.
2013-03-10 22:46:32 +01:00
Günther Brammer dfc4b9e077 Increase exception-safety of C4PropListNumbered::CompileFunc 2013-03-10 21:40:22 +01:00
Günther Brammer deeb6eeba5 Clean up a forgotten C4DirectExecScript
Found by ker.
2013-03-10 17:37:30 +01:00
Günther Brammer 6b097a49c5 Some slight parser cleanups 2013-03-10 17:37:30 +01:00
Günther Brammer a384e1bdbd Make most of C4AulParse private
This finishes the transformation from a struct to share some variables
when the parser was first split into multiple functions to a C++ class.
2013-03-10 17:37:30 +01:00
Günther Brammer 7be81f78e8 C4GameObjects::ObjectPointer does not need to be virtual 2013-03-10 17:37:30 +01:00
Sven Eberhardt cc44b71756 Fix SIGFPE exception on INT_MIN/-1 and INT_MIN%-1 in C4Script 2013-02-26 21:41:27 +01:00
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