Commit Graph

874 Commits (master)

Author SHA1 Message Date
Nicolas Hake a0c9bfd931 Aul: Correctly check for enable/disable keywords in warning pragma
The parser was only checking that the passed setting matched the
beginning of the expected keyword, instead of checking for the full
length. This way, users could write "#warning e" instead of the
expected "#warning enable" and still have it work.
2019-02-17 11:58:03 +01:00
Nicolas Hake c8d22e321b Aul: Throw correct exception on parameter-less warning pragma
When no parameter followed the "#warning" pragma, because the end
iterator would be located before the begin iterator, basic_string's
constructor would throw std::length_error. Check for this case
beforehand so we can throw the expected C4ParseError instead.
2019-02-17 11:58:03 +01:00
Nicolas Hake 486619b653 Script: Test SetLength parameter 0 for nil (GH #79)
SetLength didn't check whether its first parameter was valid, and
attempted to dereference a NULL pointer when passed nil.
2019-01-05 19:25:35 +01:00
Nicolas Hake 5cf852d8ab C4Property: Add missing template<> specifier
MSVC doesn't care, apparently.
2019-01-01 21:55:42 +01:00
Nicolas Hake 0a81206b7e C4Property: Remove raw operator void*
operator void* is a quick and dirty workaround for the lack of
explicit operator bool in old C++ standards. Since we can use
explicit operator bool now, we don't need the operator void*
anymore.

Incidentally, that operator also allowed C4Set to equality compare
C4Property entries, which is unintuitive. Replace it with an
explicit specialization of C4Set::Equals.
2019-01-01 21:35:08 +01:00
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
Nicolas Hake 3a8830af6e C4Effect: Remove obsolete fire effect constants
These constants aren't used anywhere inside the engine anymore and
should therefore be removed.
2019-01-01 20:52:38 +01:00
Lukas Werling 950ad4cf2f Fix C4ScriptLibrary destruction
C4PropListStaticMember must be deleted manually.
2018-09-25 20:02:51 +02:00
Lukas Werling 82feac4ccb Remove broken assert() 2018-09-25 20:02:51 +02:00
Lukas Werling 2fb14b026d Script: Remove effect after error in Timer
As the timer tends to run more than once, you'd also very likely get the
error more than once. The timer also often determines the effect
lifetime, making a broken effect live forever.

This was especially annoying with one-off Schedule() invokations
that wouldn't even stop throwing errors after finishing the
designated number of repeats. Although fixing just that script
function would have been possible, I believe that a more general
solution for all effects is useful.
2018-08-26 23:15:05 +02:00
Nicolas Hake f5988085a7 Figure out whether a warning/error was #include'd or #appendto'd
We already notified the user on warning/error that the mistake
happened in a different script than the one we were currently
compiing. It's not too difficult to figure out whether that other
script was added due to an #include or an #appendto directive, so we
can just show the user which one it is.

We also don't show warnings in #include'd scripts anymore, since
they get compiled individually anyway and all warnings will show up
there. This way we don't duplicate warnings several times.
2018-07-24 14:35:12 +02:00
Nicolas Hake 829bb8cb28 Script functions: remove all BCCs at once instead of individually 2018-07-24 14:24:19 +02:00
Nicolas Hake 4c43ebf58c Warn when using variables outside of their block
When we introduce block scoping, using variables declared in a more
narrow scope from a block with wider scope will fail. Warn about
these so people can avoid it and fix their code.
2018-07-23 12:12:23 +02:00
Nicolas Hake 81dff1b92a Disable suspicious_assigment warning in for conditions
While I do not agree with the idea of using straight assignments in
the condition of a for loop, people are divided on the argument and
lots of old code uses it.
2018-07-23 08:29:46 +02:00
Mark 25d008e99d FatalError: Allow formatting the message directly
FatalError(Format(...)) was necessary previously. Actually it seems not
like a huge thing, but being able to format the string directly in
FatalError is a lot more convenient.
2018-04-12 21:39:06 +02:00
Nicolas Hake 704994f1b9 Remove warning on assignment in while() conditions (for now) 2018-04-04 21:42:24 +02:00
Nicolas Hake c73b8b3ece Warn on assignments where an expression is expected
This introduces a new diagnostic (suspicious_assignment) which
issues when an the compiler finds an assignment either where a
condition is expected or as the parameter to return.
2018-03-27 08:12:21 +02:00
Nicolas Hake e3de9f1003 Add BLAKE2 library and expose its a CS hash algorithm to script
The crypto "library" only consists of a single function at the
moment because that's all that users have asked for so far. It is
also highly experimental. We will make an attempt to keep the public
interface (i.e. the interface provided by Library_Crypto.c) stable,
but it might still change if necessary. The internal interface
(provided via the global _Crypto proplist) is not for public
consumption and will probably change at some point.
2018-02-25 10:23:30 +01:00
Lukas Werling 334c57f296 Disable -Wformat-security in parts of C4AulCompiler (#1992, GH-64) 2018-02-17 12:12:16 +01:00
Lukas Werling cd2b8370da Fix warnings in DirectExec crashing (#1990) 2018-02-04 12:33:58 +01:00
David Dormagen 38d937fa58 GetProperties: fixed returning of duplicated property names & too high repair costs
var a = {B=1}; var b = new a {B=1}; would include "B" twice in the list of properties.
This lead to an actual issue when calculating component value for repairing buildings
2018-01-13 15:02:19 +01:00
Clonkonaut cc163b21b0 New engine recognised property: MaterialIncinerate.
Objects will be incinerated by incendiary material (which before was only possible by using ContactIncinerate).
local MaterialIncinerate = true; - object will burn in lava not from other burning objects.
2017-11-01 00:49:26 +01:00
Julius Michaelis ef1c275227 Better error messages for non-constant expressions in 'static const' declarations
cf. #1922
2017-08-26 10:39:38 +02:00
Maikel de Vries 0d58380dbf unify two implementations of Angle in the engine
There seems to be no reason to have two different implementation and the one in FnAngle seemed the most sane and complete one.
2017-07-19 22:04:43 +02:00
Nicolas Hake e5b15a494c Drop C4AulParSet defaulted ctor
Having the ctor defaulted confuses MSVC 2015 and makes it not use the
templated ctor below even for calls with a parameter list,
thus skipping required initialization.
2017-07-18 02:24:04 +02:00
Sven Eberhardt 856dfc9aa9 Fix duplicate editor action buttons #1884 2017-07-11 21:25:08 -07: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 94669cebe4 Merge branch 'master' of ssh://git.openclonk.org/openclonk
Conflicts:
	src/editor/C4ConsoleQtPropListViewer.cpp
2017-05-07 15:16:01 -04:00
Sven Eberhardt 206451eb6b Add prototype in proplist string and JSON serialization 2017-05-07 14:27:19 -04:00
Sven Eberhardt 4fac960cf4 Editor: Add localized string support 2017-05-07 14:26:30 -04:00
Tushar Maheshwari e58a7884e4 Automatic fixes using clang-tidy
See http://forum.openclonk.org/topic_show.pl?tid=3376 for discussion.

Close GH-41
2017-05-03 20:30:45 +02:00
Nicolas Hake 33a0b41179 Trans_Rotate: disallow rotation around null vector (#1908)
Trans_Rotate will now raise at runtime if the user tries to generate a
rotation matrix around a null vector instead of crashing with #DE.
2017-04-29 14:45:10 +02:00
Nicolas Hake c41bd063bd Stop disabling debugrec code by preprocessor
The optimizer is going to remove dead code anyway, and has the
additional advantage of doing syntax checking, so the code won't
silently break when someone changes something.
2017-04-19 09:47:21 +02:00
Nicolas Hake b87f8e3f47 C4Script: Add ParseInt function
ParseInt() will take a string parameter and try to convert it into an
integer. If the conversion fails, it returns nil.
2017-04-11 14:21:25 +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 9b61ba468d Fix JSON serialization of proplists within arrays 2017-03-18 00:26:58 +01:00
Nicolas Hake c5ed6e7dc8 Move strprintf to Standard
strprintf works like asprintf, except it returns a std::string.
2017-03-16 18:51:16 +01:00
Nicolas Hake ed193a0715 Aul: use %u instead of %zu for parameter indexes
MinGW uses an ancient version of the CRT, which doesn't support the z
modifier for integer types in printf. Use %u instead and cast to
unsigned.
2017-03-14 00:45:27 +01:00
Nicolas Hake dc6804c12d Aul: Fix invalid_escape_sequence warning message
The message used a %s where a %c was correct, and therefore tried to
access invalid memory.
2017-03-14 00:28:41 +01:00
Nicolas Hake 41f4779d74 StdCompiler: Use terms "Serializer" and "Deserializer"
Instead of "Compiler" and "Decompiler", which make me look up what's
even going on each time I see them, use the standard terms "serializer"
and "deserializer".
2017-03-11 15:05:41 +01:00
Sven Eberhardt 5032e61dea Editor: Add OnUpdate to all delegates and EditorPropertyChanged callbacks to selected root object 2017-02-26 10:53:59 -05:00
Sven Eberhardt 750d9dafb9 Remove positional parameters in aul compiler warning strings
Feel free to revert this commit when windows autobuilds are no longer done using mingw
2017-02-24 21:42:25 -05:00
Lukas Werling d8e0b33192 Put scenario parameters in SCENPAR proplist 2017-02-21 21:14:43 +01:00
Julius Michaelis 5f1ad6a5d7 Travis: fancy stuff
- gtest
 - colors
 - container based builds and GCC PCH (for a faster: "you failed")
2017-02-21 17:13:18 +01:00
Sven Eberhardt 198d11427d Fix crash on script error outside function [Knueppel-crash] 2017-02-20 18:45:11 -05:00
Sven Eberhardt e3eec21271 Editor: Add arrow drawing option to polyline delegate 2017-02-20 14:05:24 -05:00
Sven Eberhardt 294b679961 Editor: Add StartFromCenter option to polyline delegate 2017-02-20 13:39:46 -05:00
Sven Eberhardt 6579798907 Add editor enum option to force value serialization on foreign values 2017-02-19 20:36:40 -05:00
Nicolas Hake 168824a603 Win32: Use _vsprintf_p instead of v(a)s(n)printf (#1892)
This makes it possible to use positional parameters in format strings on
all platforms.
2017-02-19 12:57:27 +01:00