Commit Graph

808 Commits (61962fe70abd22a665446cc09fcef163bf0e3862)

Author SHA1 Message Date
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
Günther Brammer 88185a60f9 Script: Sort the result of GetProperties lexically
Also, deal with non-string values in the C4ValueArray properly.
2016-01-25 00:00:59 +01:00
Günther Brammer 5708ba2e72 Remove superfluous wrapper function C4AulStartTrace 2016-01-25 00:00:58 +01:00
Günther Brammer 9dadfba5af Move GlobalNamed.SetNameList call after Link() into Link()
It isn't clear whether that call is necessary since the C4AulScriptEngine
constructor already does this, but it is clear that duplicating the call
all over is a bad idea.
2016-01-25 00:00:58 +01:00
Günther Brammer 5be63d1e96 Use macros to reduce duplication in script engine definitions
While at it, make AddFunc take a C4PropList* instead of a C4AulScript*.
2016-01-25 00:00:58 +01:00
Günther Brammer 5287121d86 Use void instead of C4Void for engine functions that always return nil
This allows the removal of quite a few return C4Void();.

Also stop pretending that Nillable<void> is the same class as Nillable<T>.
Its only function was as an implementation detail for C4Void, which doesn't
need any implementation details anymore.
2016-01-25 00:00:58 +01:00
Günther Brammer f78d7712a5 Replace C4AulDefFuncHelper with template functions
This avoids duplication of code in C4AulObjectFunc and C4AulEngineFunc
at the cost of boilerplate code working around the lack of partial
function template spezializations.

Instead of ThisImpl and ExecImpl, we could have multiple C4AulEngineFunc
spezializations deriving from a common template, but that would require
even longer and duplicated boilerplate.
2016-01-25 00:00:58 +01:00
Günther Brammer 22113fd6fc Convert C4AulDefFunc* templates to variadic templates 2016-01-25 00:00:58 +01:00
Günther Brammer 0a8960f969 Reimplement C4AulParSet constructor as a variadic template
This allows the constructor to accept all types there is a C4Value
constructor for.
2016-01-25 00:00:57 +01:00
Günther Brammer 6b514893f9 Replace C4ValueConv::ToC4V with C4Value constructors
Also don't rely on int32_t != long and drop now unnecessary MSVC workaround.
2016-01-25 00:00:57 +01:00
Günther Brammer b08f51372a Add more overloads of the C4Value constructor
This allows one to use the C4Value constructor instead of
C4ValueConv. To avoid unintended implicit conversions like
const char * to bool, add a private template constructor that
catches everything not in the list of intended constructors.
2016-01-25 00:00:57 +01:00
Günther Brammer 05359179e7 Initialize C4AulParSet from C4Value[] with a function, not constructor
This avoids confusion with a variadic template constructor that could take
the same arguments.
2016-01-24 12:27:23 +01:00
Günther Brammer 234101ddbc Remove C4Script.h from C4Aul.h 2016-01-24 12:27:23 +01:00
Günther Brammer c3c402061b Move struct C4ScriptConstDef to C4AulDefFunc.h 2016-01-24 12:27:23 +01:00
Günther Brammer 20c22582ec Move DirectExec from C4AulScript to C4AulExec
In the long term, there is no reason DirectExec should be concerned with
C4AulScript/C4ScriptHost. In the meantime, the lookup code from Fneval can
be moved into the function.

This allows eval in scenario script to access scenario script locals, but
that seems harmless.
2016-01-24 12:27:23 +01:00
Günther Brammer 7cc1334963 Move C4ValueToMatrix helper functions to the file using them most 2016-01-24 12:27:23 +01:00
Günther Brammer 4f620c1537 Parse array expression with fewer lines of code
Instead of tracking the status with a variable, simply test the loop-end
condition directly, and reduce code duplication between empty and non-empty
array contents.
2016-01-24 12:27:23 +01:00
Günther Brammer b7bd48a73f Unify the various Parse_-Functions to consume the last token they match 2016-01-24 12:27:23 +01:00
Günther Brammer 6a5b571fe3 Drop warning about trailing comma at the end of a parameter list
A trailing comma does not change the behaviour of a function call, so it is
totally harmless.
2016-01-24 12:27:23 +01:00
Günther Brammer 4c01592196 Move C4AulScriptFunc into its own source file 2016-01-24 12:27:23 +01:00
Günther Brammer 514c2b8f34 Combine C4String, C4AulFunc, C4ValueArray reference counting 2016-01-24 12:27:23 +01:00
Günther Brammer ca9d95b25f Replace various C4AulFunc::Exec with C4PropList::Call
In C4Control.cpp, this improves correctness by selecting the right global
function instead of a random function.
2016-01-24 12:27:23 +01:00
Günther Brammer 93bf8f4779 Script: Allow "new Foo {}" in constant expressions 2016-01-24 12:27:23 +01:00
Günther Brammer f6c2906660 Script: Constant proplist expressions can contain function definitions
Most of the changes are for exception safety. The parser references the
function stored in Fn when the function body contains a syntax error, so
the function has to stay around. In order to avoid memory leaks, store the
function and its containing proplist in their destinations before they get
fully parsed.

This doesn't allow functions directly in static constants or arrays.
Future work: Putting the owning proplist in the scope chain.
2016-01-24 12:27:23 +01:00
Günther Brammer 507b63a55a Functions store their containing proplist instead of the C4AulScript
The C4AulScript containing the source of the function was already mostly
used to get the relevant proplist or available from context. This will
allow more than one proplist plus the global one per scripthost to contain
functions.
2016-01-24 12:27:23 +01:00
Günther Brammer 4d1f5d95c2 Script: Prevent usage of deleted objects via this()
Apparently, this wasn't done already because of compatibility concerns. The
beginning of a release cycle is the perfect moment to finally complete the
prevention of using deleted objects from script.
2016-01-24 12:25:15 +01:00
Günther Brammer 7c022085ee Improve script bytecode dump formatting slightly 2016-01-24 02:09:15 +01:00
Günther Brammer e790d2c327 Remove duplicated stubs for the scriptengine from mape 2016-01-24 02:09:14 +01:00
Günther Brammer 5a570b96f1 Remove now unnecessary stubs from C4ScriptStandaloneStubs 2016-01-24 02:09:14 +01:00
Günther Brammer 6b6dd96719 Move GameScript.GRBroadCast to Game.GRBroadCast
This avoids a dependency on ::Objects from C4ScriptHost.
2016-01-24 02:09:14 +01:00
Günther Brammer e1a38ee010 Move references to ::Objects and ::MaterialMap from C4AulLink to C4Game
This changes the order in which the various parts of the engine are updated
after a definition reload, but they should not interfere with each other.
2016-01-24 02:09:14 +01:00
Günther Brammer 9833c1ef2d Remove never used NeedDefinitionContext
Every function that accepts a definition also accepts an object instead, so
NeedNonGlobalContext is the exception to use.
2016-01-24 02:09:13 +01:00
Günther Brammer b7ecc49a02 Remove a bit of dead code from C4Value 2016-01-24 02:09:13 +01:00
Nicolas Hake 4fddda20f9 C4Script: Accept array parameter for Min, Max
Min/Max with array parameter will return the smallest/largest value of
all elements of the array. If any array element is not an integer, nor
convertible to integer, the function will fail.
2016-01-23 13:49:10 +01:00
Nicolas Hake 9a9bcd0568 C4AulError: derive from std::exception 2016-01-23 13:49:08 +01:00
Günther Brammer a5af9089a8 Script: Check parameter types of engine callbacks, too
This prevents a crash when an incompatible engine function is used as an
engine callback function.

Unfortunately, this breaks any scripts that have wrong type information in
engine callbacks and only worked because those were ignored.
2016-01-16 18:26:18 +01:00
Günther Brammer 21d8a2a64a Use 32 bit math for +1, ++, -1, etc. in script (#1389)
The engine has a few more usages of the operators, but they don't look
prone to overflowing. The other operators in Script already used SetInt,
which always truncates to 32 bit.
2016-01-15 20:19:21 +01:00
Günther Brammer 00a4c6c428 Replace BorderBound DefCore value with BorderBound object property 2016-01-01 22:18:41 +01:00
Günther Brammer 16ef28e05f Drop unused C4VERSIONBUILDNAME and C4ENGINEINFO
This was used to name snapshot releases of the Network2 branch, and has
seen almost no use since.

C4ENGINEINFO(LONG) was a duplicate of C4ENGINENAME and C4ENGINECAPTION.
2015-12-29 15:47:55 +01:00
Günther Brammer 8e889479cc Script: Find_Property can also search for engine-defined properties
Previously it used a C4PropList API that only checked the properties
set by script.
2015-12-22 18:07:38 +01:00
Nicolas Hake 1f020542d2 Implement Translate() falling back on missing translations (#1502)
Translate() used to select the script which it checked for translations
before actually looking up the string key. Change it so if the object
the context of which it was called in doesn't have a matching
translation, the string table of the script containing the call is used
instead.
2015-12-17 18:56:05 +01:00
Nicolas Hake 617a0828fb Aul: Throw exceptions by value, not by pointer
Throwing values instead of pointers simplifies memory management at the
catch site.
2015-12-08 13:17:40 +01:00
Nicolas Hake 96fcf1389a Aul: Make engine not automatically log error summary
Getting the error summary written to the log/console automatically may
be useful for general game usage, but when testing Aul we just end up
with thousands of useless messages in the output. Let the caller log the
message if it's really desired.
2015-12-08 13:17:39 +01:00
Sven Eberhardt 310daf8b3f Fix static const arrays (#906) 2015-12-07 23:38:40 -05:00
Sven Eberhardt d758c85028 Add max memory time to music resume feature (#1461) 2015-12-03 19:17:41 -05:00
Nicolas Hake 24b54211c5 Drop Min, Max, Swap for std::min, std::max, std::swap
The C++ standard library comes with perfectly fine implementations of
these functions, so there's no point in reimplementing them just for the
hell of it.
2015-11-15 13:53:01 +01:00
Sven Eberhardt d136dc22c0 Implement landscape inflammation.
It used to create the non-existent FLAM objects from the engine. Use a script callback to a global function that creates Flame objects instead.
2015-10-09 16:24:16 -04:00
Peter Wortmann f0030e33e0 Warning fixes
Actually pretty sure a few of them were bugs. Hopefully no new
ones were introduced here.
2015-10-03 15:32:39 +01:00
Sven Eberhardt 17e0e2f423 Add breaks between music. 2015-09-30 22:50:18 -04:00
Sven Eberhardt d3ee2fac57 Fix sorting of script and engine functions in dropdown menu in editor. 2015-09-26 20:10:55 -04:00
Nicolas Hake 6a11e3e811 Stop checking for rvalue ref support
We already require support for std::unique_ptr, which itself requires
support for rvalue references. As such, we know we can use rvalue
references, and thus don't have to keep carrying dead code around.
2015-09-20 13:27:14 +02:00
Sven Eberhardt b683e47499 Add LightOffset property to allow light sources to origin from locations other than the object center. 2015-09-16 21:14:08 -04:00
David Dormagen cd82b41c06 particles: added CollisionDensity to specify with which kind of material a particle will collide 2015-09-12 10:53:23 +02:00
Maikel de Vries a7480ba0ef fix crash for Translate on strings without translation
Thanks to Isilkor
2015-09-12 00:11:24 +02:00
Nicolas Hake 4ae2d9f70b C4Script: Allow executing strings from cmdline instead of only files 2015-09-04 13:40:27 +02:00
Nicolas Hake 2b876a6cb6 C4Script: Split stubs from script runner 2015-09-04 13:21:06 +02:00
Nicolas Hake 082b3e7360 C4AulParse: Properly escape strings when dumping bytecode
Instead of just writing the raw string to stderr, escape them first so
newlines and other control characters don't result in strangely
formatted output.
2015-09-04 12:57:30 +02:00
Sven Eberhardt 20d3de46cd Fix some unused variables. 2015-09-03 21:26:49 -04:00
Sven Eberhardt 84fbff95a8 Add Find_Property. 2015-09-02 23:55:45 -04:00
David Dormagen ac738735b2 Merge branch 'master' into Controls
Conflicts:
	planet/Objects.ocd/Vehicles.ocd/Airplane.ocd/Script.c
	src/game/C4Game.cpp
	src/game/C4GraphicsSystem.cpp
	src/gamescript/C4GameScript.cpp
2015-09-02 08:19:34 +02:00
Sven Eberhardt 3886f76bf3 Do not hang when a C4Value with prop list pointer is not cleared at game end.
Just cause an assertion in debug mode instead.
2015-08-29 13:22:55 -04:00
Sven Eberhardt 6ab6a1ac3c Add script interface for some EFX sound modifiers. 2015-08-27 21:44:23 -04:00
Sven Eberhardt d7a0d291e2 Fix 64 bit build. 2015-08-21 15:03:13 -04:00
Sven Eberhardt cf940d639b Fix memory leak caused by circular prop list chains.
The shapes library has such pointer chains. The leaks were getting pretty heavy because they included pointers to C4AulFuncs, which kept a lot of parts of the script engine and string tables in memory.
2015-08-20 20:19:38 -04:00
Sven Eberhardt 5ec9999d4c Fix crash on global or scenario script reload.
The string table of System.ocg scripts (except the global System.ocg) pointed to nowhere after the initial load phase, but is still required for reload. Added a ref counting option to keep these string tables alive.
2015-08-20 13:15:11 -04:00
David Dormagen 36544bd56c Merge branch 'master' into Controls
Conflicts:
	planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c
	planet/Objects.ocd/Structures.ocd/Foundry.ocd/Script.c
	planet/Objects.ocd/Vegetation.ocd/Branch.ocd/Script.c
	planet/Objects.ocd/Vegetation.ocd/Trunk.ocd/Script.c
	planet/System.ocg/FindLocation.c
2015-08-02 19:24:04 +02:00
David Dormagen d5f4805f18 fixed desync
The desync was caused by PropList->GetProperties returning the properties in an arbitrary order. They are now sorted first.
The debug logs are left in place, because I assume that I will need them again and they prove to be helpful.
2015-08-02 19:12:09 +02:00
Sven Eberhardt 0d48105b46 Added shape library.
Also fixed some coconut tree reproduction issues.
2015-07-31 00:42:01 -04:00
David Dormagen 196f528201 Merge branch 'master' into Controls
Conflicts:
	planet/Objects.ocd/HUD.ocd/FancyGridMenu.ocd/DefCore.txt
	planet/Objects.ocd/HUD.ocd/GridMenu.ocd/DefCore.txt
	planet/Objects.ocd/Helpers.ocd/Dummy.ocd/Graphics.png
	planet/Objects.ocd/Items.ocd/Tools.ocd/WindBag.ocd/Script.c
	planet/Objects.ocd/Items.ocd/Weapons.ocd/Javelin.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/ClonkControl.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/Constructor.ocd/ConstructionMenu.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/Constructor.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/Flag.ocd/Marker.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c
	planet/Objects.ocd/Structures.ocd/Flagpole.ocd/Script.c
	planet/Objects.ocd/Structures.ocd/Pump.ocd/Script.c
	src/game/C4Game.cpp
	src/gamescript/C4GameScript.cpp
	src/gui/C4GameMessage.cpp
	src/landscape/C4Landscape.cpp
2015-06-03 22:32:36 +02:00
Sven Eberhardt 116a5b4ae6 Add Find_InArray (#1073). 2015-04-28 18:59:50 +02:00
Nicolas Hake be1a148915 Aul: Remove C4AulAccess enum
We're not doing access controls anyway, so tracking information about it
isn't useful.
2015-03-25 22:32:19 +01:00
Nicolas Hake 5562b09dc4 Remove a lot of disabled legacy code, round 2
Maybe at some point we'll be rid of all the commented-out code that
nobody has looked at in years.
2015-03-25 20:02:53 +01:00
David Dormagen dae7f11a70 custom GUIs: added property GraphicsName to specify graphics of Symbol (if Symbol is a definition)
f.e. {Symbol = Icon_Number, GraphicsName = "Inf"}
2015-03-23 15:34:09 +01:00
Nicolas Hake e21a5bdd44 Rename BoundBy to Clamp
"BoundBy" sounds like a predicate. "Clamp" is a common function name for
the operation in graphics processing, so it should be familiar to users.
2015-02-12 23:05:55 +01:00
Nicolas Hake e2a8f6d303 Reorder some declarations and initializations to avoid order mismatch
While none of the mismatches were having a side-effect, this silences a
number of -Wreorder warnings which were drowning out potentially
important diagnostics.
2015-02-04 22:12:42 +01:00
Günther Brammer 5bcedb5bbf Remove some redundant #includes 2015-01-25 18:53:48 +01:00
Günther Brammer a92c22a7b3 Merge various build system fixes and cleanups 2015-01-25 18:50:29 +01:00
David Dormagen bd04722553 Merge branch 'master' into Controls
Conflicts:
	planet/Objects.ocd/HUD.ocd/Controller.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/ClonkControl.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/Constructor.ocd/ConstructionMenu.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/Constructor.ocd/Script.c
	src/game/C4GraphicsSystem.cpp
	src/game/C4GraphicsSystem.h
	src/game/C4Viewport.cpp
	src/gui/C4GameMessage.cpp
2015-01-15 19:57:01 +01:00
Maikel de Vries 4ea0cb0ca6 make ContainBlast a property instead of DefCore entry 2015-01-15 17:46:53 +01:00
Julius Michaelis 8e7001ba0f Fix self-overwrite in C4ValueArray::SetSlice (#1212: Array manipulation goes wrong ) 2015-01-09 15:09:36 +09:00
Sven Eberhardt 42b9ca4577 Add custom EditCursorCommands available in editor context menu.
Example: this.EditCursorCommands = ["Explode(20)"] on an item will offer a menu entry to explode the object. Commands may be either strings or function pointers, but function pointers will always be called by name.
2015-01-03 23:21:36 +01:00
Günther Brammer a0bddb92a3 Use size_t for a loop variable that is compared with a sizeof() result
src/script/C4Script.cpp:159:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (long i = 0; i < sizeof(values) / sizeof(*values); ++i) \
                     ^
2015-01-03 20:58:07 +01:00
David Dormagen f89b8c8319 Merge branch 'master' into Controls
Conflicts:
	planet/Objects.ocd/Environment.ocd/Cloud.ocd/DefCore.txt
	planet/Objects.ocd/Libraries.ocd/ClonkControl.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/Constructor.ocd/ConstructionMenu.ocd/DefCore.txt
	planet/Objects.ocd/Libraries.ocd/PowerConsumer.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/PowerProducer.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c
	planet/System.ocg/ClonkControl.c
	src/gui/C4MouseControl.cpp
	src/landscape/C4PXS.cpp
2014-12-25 15:24:19 +01:00
Tobias Zwick d59b1e5e5b reduce version numbering from x.y.z (x does never changes) to y.z 2014-12-12 21:57:52 +01:00
David Dormagen 952f06b173 Merge branch 'master' into Controls
Conflicts:
	planet/Objects.ocd/Libraries.ocd/ClonkControl.ocd/Script.c
2014-09-29 11:47:09 +02:00
Sven Eberhardt 131cc016cb Fix C4PropList::RemoveCyclicPrototypes() declaration 2014-09-26 22:11:10 +02:00
Sven Eberhardt 44e5c2542f Fix crash when loading proplists with non-static prototypes from saved games.
The code accessed a non-denumerated pointer.
2014-09-26 19:31:26 +02:00
David Dormagen 5722339e83 Merge branch 'master' into Controls
Conflicts:
	planet/Objects.ocd/HUD.ocd/Controller.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/Structure.ocd/Script.c
	src/gamescript/C4GameScript.cpp
	src/gui/C4GameMessage.cpp
	src/gui/C4Gui.h
	src/gui/C4GuiDialogs.cpp
	src/gui/C4GuiWindow.cpp
2014-08-13 11:52:41 +02:00
Armin Burgmeier 92720cf490 Allow C4ScriptHost to load a script from memory
This will allow mape to feed the Map.c that is being edited directly to
the map generator.
2014-08-04 13:04:34 -04:00
Sven Eberhardt 5cd9b915b0 Added some dialogue functions and speaker portraits. UpdatedAddMenuItem and CustomMessage to allow more customization for picture graphics.
I would prefer to render the models for speaker portraits directly. However, it seems like it's not currently possible to clip or render models to offscreen surfaces.
2014-07-05 15:25:30 +02:00
David Dormagen fb1ee2f88f the Trans_* mesh-transformation-functions are now implemented in the Engine instead of System.ocg 2014-06-27 20:36:47 +02:00
Günther Brammer 130a275dea Correct a comment about GetDataString safety 2014-05-25 22:47:56 +02:00
Günther Brammer b7a022852e Revert "Move C4Aul code into separate subdirectory"
The distinction between the "aul" and "non-aul" parts of
the script engine are mostly historical accident, and the
current organization of the source code does not use
sub-subdirectories. I'd like to keep it that way.

This reverts commit 69ba06b8d0.
2014-05-12 02:24:19 +02:00
Nicolas Hake 69ba06b8d0 Move C4Aul code into separate subdirectory 2014-05-11 16:17:48 +02:00
Nicolas Hake 0f48e0c4b9 Aul: ExtraWarn when turning a fn varargs in body
Par() calls and '...' in function calls make functions take varargs
without this being obvious from the header. ExtraWarn about this so people
who care about it can add an ellipsis to the parameter list.
2014-05-04 17:15:43 +02:00
Nicolas Hake 8ab7a83e3b Aul: Allow '...' as final parameter in func decls
Accepting an ellipsis as the final parameter in a function declaration
makes it immediately obvious that the function can take a variable number
of parameters
2014-05-04 17:15:42 +02:00
Sven Eberhardt 91db5d33c2 Added SolidMaskPlane property.
If an object moves and other objects are attached to its SolidMask, only objects in front of this plane are moved along with it. Defaults to Plane if zero.
2014-05-04 14:16:46 +02:00
Nicolas Hake 48c1f387f0 Require semicolon after 'do' loop
This makes C4Script consistent with C-based languages, and current usage
on master shows that in the majority of cases, the author expected to have
to place a semicolon after the loop anyway.
2014-05-03 10:07:41 +02:00
Sven Eberhardt b8cd437fc9 Fix C4ID parameters to engine functions. 2014-04-20 18:43:29 +02:00
Sven Eberhardt 445d759a72 Change == and != to do pointer comparison on arrays and proplists (formerly === and !==). Remove === and !=== and introduce function DeepEqual for contents comparison.
There have been some bugs and crashes related to unwanted deep comparison (e.g. in the maze scenario). Scripters very rarely need deep comparison, so it should not be the default for the most commonly used operator.

This also changes behaviour of GetIndexOf to do pointer comparison.

This change has Guenther's seal of approval.
2014-04-19 22:33:31 +02:00
Günther Brammer 04e1c74c05 Merge Call fix commit 2014-04-19 19:02:27 +02:00
Günther Brammer 69f64ea341 Store Prototype directly in PropLists, not as a normal property
This is mostly to prevent crashes when prototypes are deleted.

Also change proplist savegame format to not include the constant flag - all
constant proplists are not stored in savegames anymore, but recreated from
the game data. Store the prototype at that position instead.
2014-04-19 19:02:22 +02:00
Günther Brammer 22016e075f Replace some usages of C4ID with C4Def*
In particular those that made the c4script shell depend on C4Id.cpp.
2014-04-19 19:02:22 +02:00
Günther Brammer 64e258f814 Use the bytecode parameter for operators as result modifier flag
Previously, the parameter stored the operator number, but that was
only used for the purpose of optimizing unnecessary inc/dec away.
2014-04-19 19:02:22 +02:00
Günther Brammer 082a85228c Script: Constant expressions can access properties of constant proplists 2014-04-19 19:02:22 +02:00
Günther Brammer 4c9f3777c5 Make the script parser a bit more concise
Factor the common if (TokenType != t) UnexpectedToken() into a function.
Write the end-of-list-or-comma as one if and one Match instead of a long
switch-case-statement.
2014-04-19 19:02:22 +02:00
Günther Brammer 3c5152d3ba Allow Call to call 10-parameter-functions like GameCall again
CheckParTypes now requires that the parameter array passed in is long
enough, just like Exec does. Luckily, FnCall has a ParSet, which is always
long enough.
2014-04-19 19:01:57 +02:00
Julius Michaelis f4e93d13bf Add parameter type check for FnCall 2014-04-17 19:24:36 +02:00
Nicolas Hake 8254621b95 c4script-cli: Initialize PRNG 2014-04-16 13:30:41 +02:00
David Dormagen 5c17b48bc2 Merge branch 'master' into Controls 2014-03-26 23:58:24 +01:00
David Dormagen 75e776cb04 custom GUIs: added "Margin" property
The property can be used to give GUI windows a margin. Either the same margin in all directions (Margin = "1em") or different margins (Margin = ["1em", "2em", "10$", "0.5em"] - [left, top, right, bottom]).
2014-02-26 22:37:12 +01:00
Nicolas Hake 7b495cdef4 C4Script: Allow more format flags
In addition to field width and precision, also accept sign flags (+, -,
<space>) and the "alternate output" flag (#).
2014-02-17 23:10:50 +01:00
David Dormagen 350513defa custom Gui: added "Player" property, for standard visibility
This was solved via Target+Visibility before, but is such a main feature (more guis will be for a specific player than for everyone) that it legitimates an own property
2014-02-15 18:48:39 +01:00
David Dormagen 06ac00ace8 Merge branch 'master' into Controls
Conflicts:
	CMakeLists.txt
	Makefile.am
	planet/Objects.ocd/HUD.ocd/Controller.ocd/Script.c
	planet/Objects.ocd/Items.ocd/Weapons.ocd/Club.ocd/Script.c
	planet/Objects.ocd/Libraries.ocd/ClonkControl.ocd/Script.c
	src/control/C4Control.cpp
	src/control/C4Control.h
	src/gamescript/C4GameScript.cpp
2014-02-15 14:44:57 +01:00
Sven Eberhardt dd0438b55d Added helper function LogCallStack.
Useful when you need a stack trace but don't want to break execution flow.
2014-01-04 14:22:41 +01:00
Sven Eberhardt ca941b8e1e Fix "ParentKeyName" assertion when a script error occurs during scenario object initialization. 2014-01-03 18:59:31 +01:00
Sven Eberhardt 5094cc5c1b Reworked "Save as scenario" option in editor to write a script file instead of Game.txt. 2013-12-27 17:10:09 +01:00
Nicolas Hake e0dc30c59a Update copyright notices
As discussed in http://forum.openclonk.org/topic_show.pl?tid=2917, I
have merged all copyright notices into a single file and referenced that
merged file from each source file.

For the updated source files, the timeline has been split into three
parts:
 1. Pre-RWD code (before 2001)
 2. RWD code (2001 through 2009)
 3. OpenClonk code (2009 and later)
All pre-RWD copyright notices have been left intact, as have RWD-era
copyright notices where the file did not have a RedWolf design copyright
notice but only individual author ones. All copyright notices of the
OpenClonk era have been replaced by a single notice ranging from the
first recorded year to the current year (2013). Mape code did not get a
OpenClonk Team copyright notice because it is somewhat separate from the
main OpenClonk codebase and has only been touched by Armin Burgmeier.
2013-12-23 13:03:19 +01:00
Tobias Zwick 325053410f rename script callback UpdateTransferZone to OnSynchronized (#220) 2013-12-17 23:16:11 +07:00
David Dormagen e42450ef5b different optimizations to particle creation
This patch might speed up particle creation by around 25%. See crucible review https://crucible.openclonk.org/cru/ENGINE-15
2013-12-16 17:34:15 +01:00
Sven Eberhardt 25ddb14dca Rework prop list renumbering on section load (again).
Turns out changing prop list numbers while they are still indexed by number in the hash map was a bad idea. Existing prop lists are now de-numbered, pushed to an external shelve and re-numbered when added after section load.
2013-12-15 15:46:18 +01:00
Sven Eberhardt 1cca6fd1ad Rework section load again.
Now clears numbers of all existing proplists and renumbers them after loading. Fixes some assertions and duplicate numbers during loading.
2013-12-15 14:06:21 +01:00
Sven Eberhardt 8d1fbd1401 Fix engine internal smoke.
Smoke() used to create a Smoke particle directly, but the particle definitions changed. Now it just calls the global script function to create smoke.
2013-12-14 12:09:31 +01:00
Tobias Zwick fe2a400c02 replace global function GetTime() with class function C4TimeMilliseconds::Now() 2013-12-07 21:27:01 +07:00
Tobias Zwick 94c618d153 add new type C4TimeMilliseconds for time measurements to solve problems when GetTime() overflows (#251)
The new type C4TimeMilliseconds behaves for the most part like a uint32_t but is overflow-proof in comparisons.
In some places, a 0-value (or uint_max) of the variable storing the time had the special meaning "not set yet". This has been resolved by having it as a pointer to C4TimeMilliseconds with NULL meaning that it has not been set yet.
2013-12-04 19:35:07 +07:00
Tobias Zwick 5bee448745 update documentation around ActMap (2) 2013-11-30 13:11:36 +07:00
Tobias Zwick 932853d1d8 update documentation around ActMap 2013-11-30 11:45:31 +07:00
Tobias Zwick b4732f50c3 document properties of definitions, mark the ones missing yet in the source file 2013-11-30 00:39:29 +07:00
Nicolas Hake 1204d7d2d9 C4Aul: Fix broken reload from incorrect par count
When reloading a function, C4AulParse didn't reset the parameter count.
This resulted in the function's ParCount to eventually increase above
C4AUL_MAX_Par, at which point parameter type checking would access
invalid memory.
2013-11-02 13:40:33 +01:00
Nicolas Hake 003f897cbe C4AulFunc: Improve const correctness 2013-11-02 13:40:33 +01:00
Martin Plicht 608f23ece6 debugger: C4AulDebug: Do not call Execute on each DebugStep call 2013-10-16 13:43:02 +02:00
Martin Plicht 788ffdd93c C4ScriptStandalone: Fix compilation (C4AulDebug changes) 2013-10-14 07:21:34 +02:00
Martin Plicht 0fd9ebc2ed debugger: Ignore active breakpoints when no peer connected 2013-10-14 07:12:44 +02:00
Martin Plicht 91f8d32d69 debugger: Make it work again (some issues remaining, setting breakpoints on included scripts is questionable and listener socket setup sometimes hangs..) 2013-10-13 23:03:25 +02:00
Martin Plicht d164a2d50a C4Value: Implement some crude infinite recursion guard which happens solely inside C4Value::operator== 2013-10-13 11:55:01 +02:00
Sven Eberhardt 8cf8ad00e5 Added MAPALGO_Lines.
This might make life easier for people who transition from Landscape.txt.

For new maps, lines should probably better be drawn using MAPALGO_Poly in a loop. This gives you more control over individual line widths, angles, etc.
2013-10-12 19:28:22 +02:00
David Dormagen 1cb2296a37 dynamic particles: added on collision functions PC_Die and PC_Bounce 2013-10-07 20:56:53 +02:00
David Dormagen 85e0d9788a dynamic particles: added property CollisionVertex 2013-10-07 20:56:52 +02:00
David Dormagen 9753b48f7e dynamic particles: now respect particles' aspect ratio; added PV_Speed, added property Stretch 2013-10-07 20:56:51 +02:00
David Dormagen 2e2c40db07 dynamic particles: added phase property; added parameters to PV_Step; objects now draw their particles correctly; fixed PV_Random 2013-10-07 20:56:51 +02:00
David Dormagen ba41d77e0b dynamic particles: added BlitMode property (supports additive and 0) 2013-10-07 20:56:50 +02:00
David Dormagen e43b9d4fee dynamic particles: added rotation property
added PV_Step and PV_Direction
2013-10-07 20:56:50 +02:00
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