Commit Graph

517 Commits (bcaa2399eb01fa2405307a8c63dd982699b95880)

Author SHA1 Message Date
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
Günther Brammer 16511790a9 Script: Do not disguise '.' and '=' as unrecognized tokens 2011-02-25 18:12:36 +01:00
Günther Brammer ae38a7d929 Fix "Savegames: Skip Proplists and Objects that have a duplicate number" 2011-02-13 22:07:29 +01:00
Günther Brammer c667de49b5 Script: Crash when parsing a function call with more than ten parameters 2011-02-12 20:24:52 +01:00
Günther Brammer 45fa20617c Load definition stringtable before definition script
This allows for a slight simplification of the ScriptHost API, as only the
definitions made the ScriptHost load the stringtable for them.

This changes the sortorder of definitions, but C4Update should be able
to make the necessary changes to the release groups.
2011-02-07 02:18:24 +01:00
Günther Brammer 7be90977bf Make C4ScriptHost have a C4ComponentHost member instead of inheriting
Previously, C4ScriptHost needlessly derived from two classes.
2011-02-06 21:37:19 +01:00
Günther Brammer 489ae8c5b3 Remove unused C4ComponentHost::Name and LoadAppend 2011-02-06 21:31:33 +01:00
Günther Brammer 561c80fd91 Savegames: Skip Proplists and Objects that have a duplicate number
Such savegames are broken anyway, any possible repair methods just
heuristic.
2011-02-05 23:11:02 +01:00
Günther Brammer e4ef7e3d98 Replace C4VID with C4VPropList
Most callsites use C4Id2Def instead, but for some a def->id->def
indirection could be removed.
2011-02-05 23:09:09 +01:00
Günther Brammer 28be8dbcfd Remove some C4Id2Def(def->id) indirection 2011-02-05 11:34:25 +01:00
Günther Brammer dfa1ad948b Move C4AulDefFunc* templates to a header 2011-01-20 00:19:19 +01:00
Günther Brammer cde66b249f C4Include.h: Do not include C4Gui.h
The two dialogs in headers included in C4Game.h are only used by classes in
those headers, and do not need to be defined in the headers.
2011-01-24 01:15:58 +01:00
Günther Brammer e939795a93 Script: Optionally warn about empty array expression entries 2011-02-02 22:07:46 +01:00
Günther Brammer 73d1d35800 Script: Optionally warn about empty function call parameters 2011-02-02 22:06:53 +01:00
Günther Brammer 5d3eff754b Script: Empty function parameters default to nil instead of 0 2011-02-02 21:45:46 +01:00
Günther Brammer d3ddc171ee editor/win32: Remove Components menu in favour of external editors 2011-01-19 02:14:59 +01:00
Günther Brammer 5acda62b71 Do not initialize ::GameScript from ::Game
In case Game was constructed first, this could crash.
2011-01-19 02:13:51 +01:00
Armin Burgmeier d2b93d96d6 Fix the build with gcc 4.4.3
making the Linux nightly build work again
2011-01-18 01:25:09 +01:00
Günther Brammer ec7e35a25a Script: Optional warnings about deprecated functions and 0->nil conversion 2011-01-16 21:26:18 +01:00
Günther Brammer 5e156a07d1 Script: == works when one side is an object with proplist type label
I don't actually know how to get to that situation in script, but when it
happens, everything else expecting an object would correctly accept it
despite the proplist label.
2011-01-15 23:03:01 +01:00
Günther Brammer a2015e0db1 editor: Move function autocompletion list generation to C4AulScriptEngine
This actually removes some code duplication and makes the ScriptEngine
API smaller.
2011-01-13 01:09:06 +01:00
Günther Brammer 58a257f763 editor: Display object properties well readable 2011-01-13 17:55:58 +01:00
Günther Brammer 94335b6a49 editor: Move object debug information into C4Object(List) 2011-01-12 23:43:05 +01:00
Günther Brammer b1cc96d6ce Fix a mismatched malloc/delete resulting from StdStdBuf::GrabPointer usage 2011-01-12 19:58:33 +01:00
Günther Brammer 6d3feabe69 Reduce #includes so that C4Include.h doesn't include C4Value.h
This should avoid many complete rebuilds.
2011-01-08 17:04:20 +01:00
Günther Brammer 4e75f2a134 Merge Plane branch
Conflicts:
	src/C4Game.cpp
	src/C4Game.h
2011-01-08 17:39:59 +01:00
Günther Brammer 241869b1e6 objects: Replace the sorting functionality of Categories with a Plane property
This makes changing the drawing order a lot easier.
2010-12-27 20:15:55 +01:00
Günther Brammer 96fa57eb6b objects: Replace Grab defcore value with Touchable property 2011-01-02 23:55:48 +01:00
Günther Brammer 846e707134 objects: Remove OCF_Living in favor of OCF_Alive 2011-01-02 19:40:48 +01:00
Günther Brammer 877dfee49e objects: Remove Chop command, OCF_Chop, CHOP procedure, Chop defcore val, FX_Call_DmgChop 2011-01-02 01:18:45 +01:00
Günther Brammer 4984cd6b99 objects: Remove DFA_BUILD procedure 2011-01-04 00:55:42 +01:00
Günther Brammer a89667f3d7 Merge C4ValueList and C4ValueArray into one class
Now that the last usage of numbered variables in effects is gone,
C4ValueList wasn't used except as a base class. If the array and
refcounting aspect should be separated at all, the reference count
should be in the base class.
2010-12-27 17:05:35 +01:00
Günther Brammer 884572bbb3 Script: Reflect C++ effect variables as properties
With references gone, the engine can sanely run code upon modification of
properties, or throw exceptions on read-only ones. This obsoletes one use
case of GetEffect, simplifying the function a lot.
2010-12-24 15:10:39 +01:00
Günther Brammer be342d4a51 copyright notices update 2010
This time with more manual checking and using git blame -M -C, so that
a few cases of copied code get a copyright notice corresponding to
their initial introduction.
2010-12-23 01:01:24 +01:00
Günther Brammer 6025602038 Script: Correctly backtrace exceptions
Global functions conspire with appendto/include to make this all horribly
fragile.
2010-12-22 04:26:37 +01:00
Günther Brammer 40c24961dd Correctly map bytecode to linenumber for global/appended/included functions
The method to get the C4AulScript instance that stores the bytecode of a
function is ridiculous, but at least it's now capsuled in a function. While
at it, this also always stores the bytecode index instead of a bytecode
pointer in the function.
2010-12-22 02:10:58 +01:00
Günther Brammer b562acb32c Script: Remove EffectVar, update effect documentation 2010-12-21 21:57:40 +01:00
Maikel de Vries 53e507d2c5 Engine: Removed Power system including all components
Removed power lines, power connects, energy rule, power OCFs, Energy command, C4Script CheckEnergyNeedChain and EnergyCheck, Action EnergyUsage and documentation.
2010-12-15 21:02:50 +01:00
Günther Brammer 6140c73e81 Script: Change effect functions to use the effect instead of the number
This doesn't require any script changes because the effect callbacks don't
heed the parameter type information.
2010-12-20 00:19:24 +01:00
Günther Brammer e2c6a5fd17 Script: Effects are now proplists, too
This doesn't yet affect any script interfaces,
2010-12-20 00:13:56 +01:00
Günther Brammer f801ab61f5 Clear out interned strings instead of them deregistering themselves
This probably prevents a crash when the strings are destructed after the
set.

Also show all C4Strings that are still in the stringtable at the end for
debugging purposes.
2010-12-17 00:31:51 +01:00
Nicolas Hake dbb75f98cb win64: Fix crash when a C4String gets allocated at >4GB 2010-12-16 17:26:52 +01:00
Günther Brammer fccd5597bc Physical: Replace Throw with a ThrowSpeed property 2010-12-13 02:17:21 +01:00
Günther Brammer b9c1790c48 Physical: Replace Breath with a MaxBreath property 2010-12-12 23:01:08 +01:00
Günther Brammer b591ee0dc2 Physical: Replace Energy with a MaxEnergy property 2010-12-12 22:38:15 +01:00
Günther Brammer 1760c8851d Physical: Make BreatheWater and CorrosionResist simple properties 2010-12-12 21:49:47 +01:00
Günther Brammer 07025c2613 Physical: Walk speed and acceleration is now an Action property 2010-12-11 21:10:05 +01:00
Günther Brammer 00a07a1d24 Script: Add ResetProperty to reset properties to reflect the prototype 2010-12-12 01:49:05 +01:00
Günther Brammer f02580df14 Script: Inline C4String::IncRef/DecRef
No measurement whether this helps, but these functions are very simple.
2010-12-08 23:27:02 +01:00
Günther Brammer 0fdd134728 Action: Procedure is specified by a String
Also moves the Action Procedure names to the central stringtable.
2010-12-08 23:17:00 +01:00
Günther Brammer c16102ec9b Shrink StdBuf from 24 to 16 bytes and C4PropList from 56 to 48 on amd64
There's no need for Buffers which exceed 4 GB size in Clonk. C4PropList
just had some padding for alignment.
2010-12-06 19:04:32 +01:00
Günther Brammer 4e4d32f86b Create preallocated C4Strings statically instead of allocating each one
This makes it easy to convert a C4String* to a C4PropertyName, which will
be useful for reflection of internal properties.
2010-12-06 16:24:41 +01:00
Günther Brammer 26c670b29d Improve internal C4PropList interface for predefined property names
SetProperty now also has a wrapper, and the common case of
GetPropertyVal(P_Foo) is now GetProperty(P_Foo).
2010-12-06 16:19:15 +01:00
Sven Eberhardt 7e971d7405 fix error when accessing &Code[0] on empty code during script parsing
caused by 4d1af7ffee78, when code was changed from a C style array into a std::vector
2010-12-07 19:27:59 +01:00
Günther Brammer 8bd9179606 Script: Inline C4Value::Set and the C4Value functions it calls
Apart from these functions just being small enough to reasonably
inline, the compiler might be able to optimize parts of them away based on
knowledge of the type of the new or old content of the C4Value.
On at least one artificial benchmark, this does help significantly.
2010-10-26 03:05:20 +02:00
Günther Brammer d02c424dab Script: Split SPos out of the bytecode into an extra vector for speed
SPos is only needed to display debug messages. Not having that data in the
cache for normal execution speeds up script execution by ten percent on at
least one artificial benchmark.
2010-10-25 23:48:08 +02:00
Günther Brammer 7f899cc1b0 Make AssignRemoval a C4Object-only-feature, C4PropLists don't need it 2010-10-30 00:05:36 +02:00
Günther Brammer 4a256d1953 Script: Every identifier is allowed after a dot
Previously, the tokenizer would emit special tokens for a few keywords. Now
every keyword is handled by the parser. This allows one to use keywords as
identifiers everywhere it is unambiguous.
2010-10-20 00:37:31 +02:00
Günther Brammer 4876db8f2d Remove unused C4PropList::HasProperty
There might be a usecase for finding out from script whether a property is
on an object instead of a prototype of the object, but so far that feature
has not been missed.
2010-10-17 22:15:32 +02:00
Günther Brammer 01eed03487 Make C4PropList::Properties private instead of protected 2010-10-17 22:13:12 +02:00
Günther Brammer 4438986167 Script: don't crash on 0[n]
The typecheck relied on the fact that nullpointers were always C4V_Any,
which is not true anymore. Instead, directly check that the array that will
be used is not a nullpointer, which aligns the check with the usage instead
of C4Value implementation details.
2010-10-25 03:40:57 +02:00
Günther Brammer fe9a13f071 Script: proplist access via foo.bar returns nil for nonexistent properties
Previously, it returned the proplist, which was neither helpful nor
intended.
2010-10-18 01:45:49 +02:00
Nicolas Hake 4a1a9cc2b0 msvc: Avoid a stupid warning 2010-09-29 23:19:43 +02:00
Günther Brammer 93d3bc7d2f Script: Thaw and clean definition proplists for reload (#405) 2010-09-22 03:33:57 +02:00
Günther Brammer 7d3811fc76 Script: Arrays do not autoextend when accessed
Done by constifying the C4ValueList interface. To avoid rewriting some code that
uses that interface, also constify some C4Value functions. While at it,
replace the dynamic function call for C4Value conversion with a switch.

This makes C4Value conversion not actually convert anything, but the only
case left is conversion to bool, which already occurs when the value is
read.
2010-09-20 19:49:00 +02:00
Armin Burgmeier 479362b87c Fix a crash bug on 64 bit 2010-09-22 02:14:16 +02:00
Armin Burgmeier ba3308d1c6 Fix initialization order in C4Value constructors 2010-09-15 21:23:02 +02:00
Günther Brammer f1e27ca7db Script: a[0:GetLength(a)-1] returns a copy of the array
Previously, returning the same array was an optimization that could not be
noticed from script, because arrays were copied on write.
After noref, this caused a big difference between a[0:] and a[1:], which is
bad.
2010-09-12 18:27:09 +02:00
Günther Brammer cf92ceae2d Merge branch 'norefs'
Conflicts:
	planet/Melees.c4f/Ruins.c4s/ObjectFade.c4d/Script.c
	planet/Objects.c4d/Goals.c4d/KingOfTheHill.c4d/Script.c
	planet/Objects.c4d/Goals.c4d/LastManStanding.c4d/Relaunch.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/BlackPowder.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Coal.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Earth.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Firestone.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Gold.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Ice.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Loam.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Metal.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Ore.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Rock.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Snow.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Sulphur.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Resources.c4d/Wood.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Axe.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Balloon.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Barrel.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Boompack.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/CableReel.c4d/PowerLine.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/CableReel.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Dynamite.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/DynamiteBox.c4d/Fuse.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/DynamiteBox.c4d/Igniter.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/DynamiteBox.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/GrappleBow.c4d/Hook.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/GrappleBow.c4d/Rope.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/GrappleBow.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Hammer.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/JarOfWinds.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/OrbOfTelekinesis.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Pickaxe.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/PowderKeg.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Ropeladder.c4d/LadderGrabber.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Ropeladder.c4d/LadderSegment.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Ropeladder.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Tools.c4d/Shovel.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Weapons.c4d/Bow.c4d/Arrow.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Weapons.c4d/Bow.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Weapons.c4d/Club.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Weapons.c4d/Javelin.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Weapons.c4d/Musket.c4d/Ammo.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Weapons.c4d/Musket.c4d/Script.c
	planet/Objects.c4d/Items.c4d/Weapons.c4d/Shield.c4d/Script.c
	planet/Objects.c4d/Vehicles.c4d/Cannon.c4d/Script.c
	planet/Objects.c4d/Vehicles.c4d/Lorry.c4d/Script.c
	planet/Tutorial.c4f/Tutorial.c4d/FlagGoal.c4d/Flag.c4d/Script.c
	planet/Tutorial.c4f/Tutorial.c4d/FlagGoal.c4d/Script.c
	planet/Tutorial.c4f/Tutorial.c4d/MenuDeco.c4d/Script.c
	planet/Tutorial.c4f/Tutorial.c4d/ObjectRestorer.c4d/Script.c
	planet/Tutorial.c4f/Tutorial.c4d/TutGuide.c4d/Script.c
	planet/Tutorial.c4f/Tutorial.c4d/TutorialGoal.c4d/Script.c
	planet/Tutorial.c4f/Tutorial03.c4s/ShootTheTargets.c4d/Script.c
	src/game/object/C4Def.h
2010-09-11 19:30:45 +02:00
Günther Brammer efad172ec6 Script: Compare readonly proplists by their contents
This way, breaking the identity relationship on savegame load will not be
noticable by script.
2010-09-10 23:01:30 +02:00
Günther Brammer 64f424cc51 Script: Add | operator to constants
This is the only operator that is necessary for the ActMaps. Ideally, every
operator would work, but I don't know how to achieve that without massive
code duplication. So just duplicate a little to make it work.
2010-09-09 22:41:41 +02:00
Günther Brammer 153646b3d7 Script: Move Action initialization to script, make it static const
Finally. :-)
2010-09-09 22:38:25 +02:00
Günther Brammer b55c88d486 Script: Add initialization to local named variables (properties) 2010-09-09 22:36:00 +02:00
Günther Brammer ef76b26c4a Script: Save readonly proplists inline so that they do not need a number 2010-09-08 20:09:27 +02:00
Günther Brammer 6d3fc6032b Remove the last traces of the Strings.txt 2010-09-08 20:08:13 +02:00
Günther Brammer bf9137149c Script: Initial proplists are readonly at runtime
That way, recreating them from game data during savegame load won't
suddenly revert changes, because there aren't any changes.
2010-09-08 14:54:39 +02:00
Günther Brammer 1a3f8fe80b Script: Make a[-n]=foo work
Before, negative indices would alias to 0, which is not helpful.
2010-09-08 00:41:59 +02:00
Günther Brammer 984c3430ac Script: constants can contain proplists and arrays
Only supporting the literal syntax for them, with the same
constraints for the contents as for toplevel constants.
2010-09-09 02:18:19 +02:00
Günther Brammer 275e9dfd7d Script: Revise error messages for uniformity
All messages end with a . now, don't quote c4value types and call the i in
a[i] "index".
2010-09-08 00:46:01 +02:00
Günther Brammer e342dc9b35 Script: Remove last, already dead, traces of C4ID constants 2010-08-19 19:05:48 +02:00
Günther Brammer 09218cbdf1 Fix merge mistakes 2010-09-11 19:20:52 +02:00
Günther Brammer b34efab246 Script: Add foo.bar syntactic sugar for foo["bar"] 2010-08-15 01:53:18 +02:00
Günther Brammer 713531bb91 Script: Remove obsolete '&' token (always an operator now) 2010-08-14 23:02:07 +02:00
Peter Wortmann 9c9a898911 Fixed a few scripts to work without references, to the best of my knowledge. 2010-08-03 22:33:03 +01:00
Peter Wortmann 24cfd14f1c Support for setting array slices 2010-08-03 21:47:45 +01:00
Günther Brammer 40e2406a03 stringtable: Destroy strings before the set containing them
So that they can remove themselves from the set,
2011-01-07 00:52:53 +01:00
Peter Wortmann cc3795ef4f Removed ObjectsInt and FindInternal, it has been a NOP for long enough. If we really want to find rules faster, we should consider having (bounded?) per-definition object lists. That way, FindObjects() & co would benefit as well. 2010-08-05 19:48:22 +01:00
Peter Wortmann cf4e83c151 Merge with default, including some small Script cleanups 2010-08-01 16:23:36 +01:00
Günther Brammer 696520dfb4 Script: Avoid conversion warning false positives (#246) 2010-07-31 19:29:31 +02:00
Sven Eberhardt e3a69d50fa Kill some outdated CON_* constants registered by engine
Update GetPlayerControlName to use GetConstantNameByValue
2010-07-30 20:50:35 +02:00
Günther Brammer dfc4070498 Script: Don't crash on obj[nil] 2010-07-15 20:26:53 +02:00
Günther Brammer 9bae376055 Remove old style Cursor and other dead code 2010-07-06 02:10:54 +02:00
Günther Brammer 06c62b31bd Script: Only warn about missing functions in the Parser
Non-failsafe calls will abort at runtime, but they might
only be used in a never taken branch, so unconditionally
aborting the function is wrong.
2010-06-27 02:03:23 +02:00
Armin Burgmeier 9f65838ae8 Fix a couple of compiler warnings 2010-04-28 23:43:25 +02:00
Peter Wortmann edb4a4a0b2 Completely removed references from the engine, changed array semantics to not copy automatically, implemented postfix ++/-- correctly 2010-04-08 02:47:45 +02:00
Peter Wortmann efb5925129 Modified parser to use setter bytecode in place of references.
Currently kills:
* a[...] = ... -> Currently a copy is changed and then discarded, need to rework array semantics.
* bla->EffectVar(...) = ... -> Normal EffectVar is rewritten to SetEffectVar - but this won't work for calls. We need a better solution anyway.
* All scripts that use references, obviously. Just have a look at the parser warnings.
2010-04-07 15:04:19 +02:00
Benjamin Herr adc278dc57 Add array slicing syntax ary[begin:end]
... which evaluates to a copy of the elements with indices in the range
[begin,end), where either index might be omitted, defaulting to 0 or the
length of the string respectively
2010-04-05 17:41:36 +02:00
Günther Brammer abdf54b01b Script: a["foo"] overwrote a
C4AulExec::Exec passed the element on the stack to
C4PropList::GetPropertyVal which contained the reference to the variable
"a". C4Value::operator= follows this reference, so use Set() instead.
2010-04-04 01:53:53 +02:00
Armin Burgmeier c2924041c9 Fix seperate->separate everywhere 2010-04-01 23:08:06 +02:00
Benjamin Herr 4378de147c Rerun astyle with missing \ added 2010-03-28 20:58:01 +02:00
Benjamin Herr 27287b981f Reformat everything according to style guidelines
as per http://forum.openclonk.org/topic_show.pl?tid=208
and http://wiki.openclonk.org/w/Style_Guidelines
via astyle
  --brackets=break
  --indent=tab=2
  --keep-one-line-statements
  --keep-one-line-blocks
  --indent-namespaces
  --convert-tabs
  --recursive
  --exclude=zlib
  --exclude=tinyxml
  src/\*.h src/*.cpp
2010-03-28 19:58:21 +02:00
Günther Brammer 5a44edb613 Store objectlocal named variables as properties
One still has to declare them in before usage, but LocalN can create new
variables now.
2010-03-27 18:52:32 +01:00
Günther Brammer 2e379712fb Add C4PropList::GetPropertyVal to get a property directly
This should theoretically be more efficient than first creating a reference
and then dereferencing that. But mostly it's for more interface clarity.
2010-03-27 19:16:48 +01:00
Günther Brammer 452ee57d04 Small C4Value cleanup 2010-03-25 21:42:47 +01:00
Günther Brammer b4e37b070b Change all indentation with spaces to use tabs instead
This is a whitespace-only patch. Hopefully, it'll only affect rarely-changed
parts of the engine, since all regularly maintained pieces should already
use tabs.
2010-03-27 17:05:02 +01:00
Benjamin Herr 6cb483bc4b C4Value::DenumeratePointer(): Print int with %d
not intptr_t
2010-03-22 22:27:00 +01:00
Benjamin Herr 5aec29c8a1 Remove spurious , at the end of enum list 2010-03-22 15:38:43 +01:00
Günther Brammer 32ec6abace Script: Add a new reference type to C4Value storing proplist and key
This way, a mere reference does not need to add an entry to a proplist. This
can be deferred to the point when the reference is used to change the value.
2010-03-23 23:56:59 +01:00
Günther Brammer 99040a3dd1 Script: Remove ne, eq and S= 2010-03-22 22:26:41 +01:00
Günther Brammer 1446f585d7 Rename C4V_pC4Value to C4V_Ref 2010-03-22 22:16:46 +01:00
Günther Brammer 79e78e3a10 Script: Prepare for C4Value::GetRefVal to create a new entry in a proplist 2010-03-22 19:32:10 +01:00
Günther Brammer 608fadce6b Script: ++ and -- throw when applied to nonintegers 2010-03-22 19:00:29 +01:00
Günther Brammer 5d2c3d4c2b Savegames: (De)serialize PropLists
Because PropLists have an identity, they need to be saved in a central
place and have C4Values reference them, the same as objects. Objects.txt
can be used for that.

This doesn't save PropLists which are definitions. These are reloaded from
the c4ds at game start and identified by their C4ID, not their number.
2010-03-22 00:40:03 +01:00
Benjamin Herr 5ccb193928 override both Close() overrides in C4AulDebug
If we only override the Close() function with no parameters, the
overload taking an addr_t gets hidden. So we specifically override that
as well, preventing a gcc warning.
2010-03-21 19:18:27 +01:00
Günther Brammer 538af1eef7 Merge 2010-03-21 00:45:22 +01:00
Armin Burgmeier 4db22e4a1b Fix Prototype refcounting
This patch produces a measurable slowdown on my computer, but it's not
directly related to the change but probably rather to hashtable collisions
in C4StringTable.h. The performance drop vanishes when increasing the
initial size of the hashtable.

I am not changing that right now because a) it's rather unrelated to
this change and b) would require some more profiling to find a good value.
Maybe changing the hash function or increasing the hash table size before
it's half full would be better things to do.
2010-03-19 01:21:54 +01:00
Armin Burgmeier 56e33cc626 Make an object's current action a property
This fixes a crash on reload since the Action.pActionDef pointer becomes
invalid otherwise
2010-03-19 00:04:29 +01:00
Günther Brammer 8c13465ef3 Script: += and friends result in integers, and check for them
Before, var a = nil; a+=25; would result in any/25, violating a constraint.
The operators also didn't check that the input was an integer.

/= and / now raise an exception on division-by-zero.
2010-03-18 23:59:50 +01:00