Commit Graph

100 Commits (31c7805f1045a6759d27f1e747039df37b6b2f59)

Author SHA1 Message Date
Nicolas Hake 31c7805f10 C4Set: Replace elements with zero-initialized ones on clear
C4Set used to set its removed elements to nullptr. This requires
some special handling from non-pointer entries like C4Property.
Overwriting the element with a zero-initialized one removes this
requirement, leading to improved type safety on the part of
C4Property.
2019-01-01 21:35:08 +01:00
Tushar Maheshwari a661eab867 Automatic fixes using clang-tidy for header files
A follow-up on a previous PR GH-41. The discussion in the forum can be
viewed at http://forum.openclonk.org/topic_show.pl?pid=33086.
Run clang-tidy (without auto, pass-by-value and using checks) to fix the
header files not modified in the previous PR.

Summary of the changes:

 - C++11 member initialization.
 - nullptr instead of 0 for pointers.
 - override for functions declared virtual in base class.
 - default trivial special member functions
2017-05-15 13:46:46 +02:00
Tushar Maheshwari 3a4f49ad90 Revisit #includes
Consolidate the include statements scattered across the code in accordance
with the comment in C4Include.h. The advantages are listed in the same
comment.
Furthermore, it follows llvm-include-order which is the logical
extrapolation of the project's style guideline wherever possible
(C4Include.h being the most-frequent exception).
2017-05-15 13:24:59 +02:00
Sven Eberhardt 83af5ad794 Fix a script reload bug
Thawing needs to catch some of the deeper nested proplists because they are modified in the EditorProp initialization Definition()-callbacks.
2017-03-26 13:31:55 -04:00
Lukas Werling ee0b1c2599 Implement JSON serialization for C4Value 2017-02-17 23:29:01 +01:00
Sven Eberhardt ebda8193ef Replace NULL by nullptr in C++ sources
We don't support pre-C++0x any more, so nullptr should be fine everywhere (except in the plain C source files)
2016-11-02 19:58:02 -04:00
Armin Burgmeier 836927d93c Don't leak static proplists with cyclic references
If a local variable in a definition was set to a proplist inside the
Definition() callback, and that proplist contained cyclic references
then those references were leaked. Typically cyclic references for
script-created proplists are broken in
C4PropListScript::ClearScriptPropLists, however definition proplists
are changed to be static proplists in
C4PropList::FreezeAndMakeStaticRecursively.

To fix this, each script host maintains a list of proplists made static
by FreezeAndMakeStaticRecursively, and explicitly deletes all of these
proplists on Clear().

This leak also leads to an assertion failure inside
C4PropListScript::ClearScriptPropLists in debug mode, and can also be
observed by C4PropList::PropLists not being empty after game clear.

The definition in Objects.ocd/Helpers.ocd/UserAction.ocd constructs
cyclic proplists in its Definition() call. A simpler, more minimal way
to provoke the leak is the following (it provokes the leak but not the
assertion failure):

    local bla;

    func Definition(def)
    {
        bla = {};
        bla.test = { Name="Test222" , Options = { Name="Test333" } };
        bla.test.Options.Link = { Name="Test444", Blub=bla.test };
    }
2016-09-30 17:50:41 -10:00
Sven Eberhardt e4b4246500 Fix freezing and assignment of static names to child proplists created in Definition()-callbacks (#1798)
Also adjust editor props for the change:
1. enum needs to create a copy, not a reference for the default value of an option if it is defined inline
2. Always use proper GetName() resolution on property group names even if a static name would be available
2016-08-27 02:04:03 -04:00
Sven Eberhardt 24a5dc33db Qt editor: Sort properties in property list by localized name and priority 2016-08-02 01:12:08 -04:00
Sven Eberhardt 28d2172b78 Qt Editor: Move editor props from EditorProp_* to an EditorProp proplist 2016-07-13 17:18:08 -04:00
Sven Eberhardt a7aa89f168 Merge branch 'master' into qteditor
Conflicts:
	planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/Script.c
	src/platform/C4WindowSDL.cpp
	src/script/C4AulParse.cpp
	src/script/C4Effect.cpp
2016-06-20 22:27:03 -04:00
Sven Eberhardt 34289fa18a Qt Editor: Add EditorActions.
Replacing the old EditCursorCommands (which nobody knew). Objects now publish their commands directly on the property viewer.
2016-06-19 00:08:09 -04:00
Sven Eberhardt b10da0629d Qt Editor: More EditorProps types (string, array) and attributes (EditOnSelection, DefaultEditorProp) 2016-06-03 01:20:43 -04:00
Nicolas Hake 3fd1187833 Don't overload CompileNewFunc with rvalue reference parameters
We don't need to pass the C4ValueNumbers* as a rvalue reference, and
doing so needs const qualifiers on MSVC.
2016-05-21 12:56:57 +02:00
Günther Brammer d23ffde361 Merge script branch 2016-05-15 19:21:26 +02:00
Günther Brammer 9e8d644a26 StdAdaptors: Make mkParAdapt(mkPtrAdaptNoNull(), Par1, Par2) work
Employ variadic template arguments and more rvalue references for this.
Sadly, StdParameterAdapt itself is even more complicated, since it has to
store the parameters instead of just forwarding them, so the limit is still
two parameters. But that's twice as much as before in many cases.
2016-05-14 22:59:59 +02:00
Nicolas Hake 78e5f8528d C4PropList::GetParent: make const 2016-05-12 18:47:53 +02:00
Günther Brammer b00b8554ab Merge branch script 2016-04-28 03:25:44 +02:00
Sven Eberhardt 881534bee0 Qt Editor: Shape properties 2016-04-25 16:17:10 -04:00
Günther Brammer e5cfb1858f Script: GetName() can return the property a proplist was defined in
This means that the ActMaps do not need to repeat their name anymore,
provided that all Scripts use GetName() instead of directly accessing .Name.
2016-04-24 19:40:29 +02:00
Günther Brammer 42a15e3be9 Convert C4Effect parameters that do not need to be C4Object* to C4PropList* 2016-04-24 19:40:28 +02:00
Sven Eberhardt c0228be4e7 Qt Editor: More editor property types and functionality 2016-04-16 22:05:35 -04:00
Sven Eberhardt 2a2fc68e3f Qt Editor: Add user properties 2016-04-09 14:29:02 -04:00
Sven Eberhardt 879d501592 Merge remote-tracking branch 'remotes/origin/qteditor' into qteditor
Conflicts:
	src/editor/C4ConsoleQtPropListViewer.cpp
	src/editor/C4ConsoleQtPropListViewer.h
	src/script/C4ValueArray.cpp
2016-04-04 19:34:02 -04:00
Sven Eberhardt 98c36e5955 Qt Editor: Implement setting of properties 2016-04-03 23:46:58 -04:00
Nicolas Hake 9dddf289db Merge branch 'master' into qteditor 2016-04-03 21:06:32 +02:00
Nicolas Hake eabca223f5 Update all copyright notices for 2016 2016-04-03 20:24:42 +02:00
Nicolas Hake 493c276126 Rewrite header inclusions to #include "path/to/file.h" style 2016-04-03 20:24:42 +02:00
Sven Eberhardt 2af22ee824 New editor (Qt-based)
Work in progress. So far only for Windows.
2016-02-15 08:38:06 -05: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 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 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 84fbff95a8 Add Find_Property. 2015-09-02 23:55:45 -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
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
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
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
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
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
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
Nicolas Hake 58a39e972f Improve C4Object const correctness 2013-08-31 23:23:35 +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
Sven Eberhardt 671a815223 Fix MapLayer functions on derived prop lists (#935) 2013-03-24 13:29:04 +01:00
Sven Eberhardt 57e63a5275 Added support for scripted maps (Map.c) and documentation. 2013-03-19 00:36:06 +01:00
Günther Brammer df3fcd2b2b Document C4PropList internals a bit 2013-02-11 22:23:05 +01:00
Günther Brammer 864c5c7ea8 copyright notices update 2012 2013-01-12 16:31:40 +01: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