Commit Graph

43 Commits (62bc721a65fbb92e88ddb9d9cc69e1b8be8e53f8)

Author SHA1 Message Date
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 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 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 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 9bc61db360 copyright notices update 2011 2011-09-01 16:58:52 +02:00
Günther Brammer 2d9d0d8596 Reduce verbosity of backtraces with object parameters 2011-05-09 23:19:31 +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 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 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
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 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 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 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 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 00a07a1d24 Script: Add ResetProperty to reset properties to reflect the prototype 2010-12-12 01:49:05 +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
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 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 93d3bc7d2f Script: Thaw and clean definition proplists for reload (#405) 2010-09-22 03:33:57 +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 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 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
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
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 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 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 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
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 49e607bab0 Added includes and forward declarations, fixing the build 2009-10-26 00:09:34 +01:00
Günther Brammer 572d00c32e Move all source files
This might make stuff easier to find.
2009-08-10 17:59:18 +02:00