Commit Graph

4349 Commits (master)

Author SHA1 Message Date
Maikel de Vries 0d7c8aacca adjust moveto command to make the clonk move while jumping 2017-03-07 20:20:59 +01:00
Nicolas Hake c8d37a5346 C4DrawT: Remove unused functions, add override specifiers 2017-03-05 12:41:51 +01:00
Lukas Werling 3ebedd0c5f Rank private/UL addresses lower than global ones
Also adds some tests. Yay tests!
2017-02-28 22:15:29 +01:00
Lukas Werling d7e71d8362 Double the maximum address count to accomodate IPv6
With the addition of IPv6, some computers with lots of addresses are
reaching the old address limit of 20 addresses. We'll have to see how
this works out in practise. Maybe we'll have to do the connection in
stages to prevent sending out too many packets at once (like only
connecting to the first five addresses initially, then after a timeout
the next five, and so on).
2017-02-27 22:52:24 +01:00
Lukas Werling aa5f5cd654 Convert IPv4-mapped IPv6 peer addresses to IPv4
This avoids duplicating these addresses when broadcasting them.
2017-02-26 23:36:32 +01:00
Lukas Werling 7d55962208 Sort addresses used for initial host connection
Computers with multiple (possibly virtual) network adapters can have
tons of link-local fe80::/64 IPv6 addresses. Connections to those hosts
would run into a timeout before getting to public addresses behind the
link-local ones.

By sorting the address list, we can prioritize public IPv6 addresses if
supported by the client, then try IPv4 before working through the swamp
of link-local addresses.
2017-02-26 23:36:32 +01:00
Sven Eberhardt c8aa5fff8f Fix missing return value in C4PropertyDelegateFactory::PasteFromClipboard 2017-02-26 11:00:20 -05: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 5ad6012a3f Silence warning on switch over sdl scancodes 2017-02-21 19:37:20 +01:00
Julius Michaelis d81a7f10e3 Silence a lot of inconsistent-missing-override warnings 2017-02-21 19:03:46 +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 9abb0bc200 Fix drawing of editor shape delegate polylines with settings StartFromObject=true and Relative=false 2017-02-20 22:25:28 -05: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 cc0371bdf5 Add PIF_NoScenarioSave option to script players 2017-02-20 13:39:11 -05:00
Sven Eberhardt 6579798907 Add editor enum option to force value serialization on foreign values 2017-02-19 20:36:40 -05:00
Sven Eberhardt 69b0fd4f1a Do not call InitializePlayers after script player join if no human players joined 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
Sven Eberhardt a7bbda4ca1 Fix order of InitializePlayer(s) callbacks in non-network games with teams enabled [Luchs] 2017-02-18 18:26:21 -05:00
Lukas Werling a4492dd828 Fix double escaping of Statistics JSON
As newlines are already escaped in the JSON, this is safe.
2017-02-18 19:08:15 +01:00
Lukas Werling 87ee44964c Send script-defined statistics to the masterserver
After GameOver(), the global function CollectStatistics() is called
which in turn calls CollectStats() on all definitions and the Scenario.
The results are collected into a proplist and sent to the masterserver
as JSON.

The intended purpose is to collect statistics like weapon kill counts
and evaluate them across all online games to improve balancing.
2017-02-17 23:29:16 +01:00
Lukas Werling ee0b1c2599 Implement JSON serialization for C4Value 2017-02-17 23:29:01 +01:00
Nicolas Hake 78bbbc917b Fallback to sane settings when compiling scripts without ScriptHost
Compilation without an associated ScriptHost happens in a call to eval,
in which case we'll fall back to the default warning settings (because
we don't have a location which we could get settings from).

Fixes #1891.
2017-02-16 19:32:42 +01:00
Lukas Werling 181f7ab471 Prefer public/stable IPv6 source addresses
We don't benefit at all from privacy addresses as we're publishing all
local addresses in any case. By preferring stable addresses, we can
avoid reconnection issues after the preferred address changes.

This API is defined in RFC5014, but apparently only implemented in
Linux.
2017-02-14 21:44:05 +01:00
Nicolas Hake 1594acd3ed Aul: Warn if a function parameter shadows a local variable
Yeah. Aul looks up function parameters before local variables when
trying to resolve an identifier. Usually this doesn't matter, but you'll
notice it if you have a local variable and a parameter with the same
name, because the variable should be initialized to nil yet you get the
value of the parameter.
2017-02-13 17:20:03 +01:00
Nicolas Hake 2b5d34f420 Aul: Remove unnecessary virtual dtor from Script node
The dtor (which didn't even do anything) broke testing on g++ and clang,
because they correctly delete some ctors if the dtor is declared.
2017-02-13 15:23:51 +01:00
Nicolas Hake 30c5bb5f8d Aul: Allow the user to selectively enable/disable warnings
This commit introduces a new Aul directive "#warning", which can be used
to enable or disable warnings for a particular piece of code.

"#warning enable" enables all warnings.
"#warning disable" disables all warnings.
"#warning enable empty_parameter_in_call" selectively enables one
specific warning while not affecting any other.

All warnings that used to be controlled by Developer.ExtraWarnings
remain disabled by default.
2017-02-13 15:07:50 +01:00
Nicolas Hake 23bf3c4f0a Aul: Don't explicitly prepend "ERROR" to runtime errors
Since the error handler would itself prepend "ERROR", runtime errors
used to be written as "ERROR: ERROR: <whatever>".
2017-02-13 15:07:50 +01:00
Nicolas Hake a026bda561 Aul: Let error handler count warnings and prepend severity
Instead of explicitly writing to the log, let C4AulParse and
C4ScriptHost warnings go to the error handler to do with as it sees fit.
2017-02-13 15:07:50 +01:00
Nicolas Hake 5f520c6326 C4AulCompiler: Don't double-count compile time warnings 2017-02-13 15:07:50 +01:00
Sven Eberhardt 2b888fd136 Enlarge initial client connection dialogue to accommodate long ipv6 addresses 2017-02-12 11:48:55 -05:00
Sven Eberhardt 22306bd266 Editor: Add templates for new scenarios 2017-02-05 16:08:29 -05:00
Nicolas Hake a33d98ee71 Aul: Warn on empty controlled statement
Aul will now emit a warning if you type something like
    if (...); return true;
(note the semicolon right after the condition). It will also warn on an
empty 'else' branch. If you actually intended to have a no-op there, use
an empty block '{}'.
2017-02-05 14:17:37 +01:00
Nicolas Hake 9a201441d5 Mat insertion: Fix broken conditional 2017-02-05 13:51:04 +01:00
Nicolas Hake 9bddba53df Improve CStdStream const correctness 2017-02-05 13:26:24 +01:00
Nicolas Hake b0898f4e1a C4Group: Pull most the data members out of the header 2017-02-05 13:26:23 +01:00
Nicolas Hake bcbd368ffd C4Group: Rename "Status" enum to "SourceType" 2017-02-05 13:20:18 +01:00
Nicolas Hake 71f8cb0699 C4Application: Remove unused flag IsInGameTick 2017-02-05 13:20:18 +01:00
Lukas Werling 487fcc362d Linux: Read IPv6 addresses from /proc/net/if_inet6
In contrast to getifaddrs(), /proc/net/if_inet6 allows filtering
deprecated privacy addresses. As these addresses generally won't be
useful for new connections, there's no reason to include them and they
only cause unnecessary connection attempts.
2017-02-02 22:23:12 +01:00
Maikel de Vries 4d6be35c32 allow script players to join in network rounds (#1885) 2017-02-02 21:47:56 +01:00
Julius Michaelis 80c07d34e4 Add [Landscape] Secret to Scenario.txt to default-disable black NO_OWNER viewports
Related to: c569036d1d
2017-01-24 18:50:30 +01:00
Lukas Werling 459adbd199 Fix local network discovery on Windows (#1886)
On Windows, we cannot resolve addresses using getaddrinfo() before
initializing Winsock. By storing the address as string, the address
parsed later on.
2017-01-21 16:03:03 +01:00
Lukas Werling ef4f1d9231 Merge branch 'ipv6' 2017-01-18 21:59:16 +01:00
Lukas Werling e3a0f2f8b5 Implement Happy Eyeballs for C4Network2HTTPClient
This should make masterserver requests more reliable for users with a
bad IPv6 connection.

See RFC6555
2017-01-18 21:55:17 +01:00
Lukas Werling 894edfce5b Allow adding connections from other addresses
Forcing a static address does not work for IPv6 where everyone has
multiple addresses that change over time. For example, adding a new
connection would fail if the preferred privacy address changes during
a game.
2017-01-18 21:55:17 +01:00
Lukas Werling 6677295bac Serialize addresses in UDP connection packages
The previous approach of just embedding the raw struct fails miserably
when trying to transfer AF_INET6 across platforms.
2017-01-18 21:55:17 +01:00
Lukas Werling 6af32a7c46 Fix IPv6 sockets on Windows not being dual-stack
On Linux, all IPv6 sockets are dual-stack per default; on Windows, they
are not. It's still a good idea to set the option on Linux as well as
the default value can be changed.

When connecting via TCP, C4NetIO still creates IPv4 sockets, so no dual
stack option is required there.
2017-01-18 21:54:50 +01:00
Lukas Werling a9ee16a287 Change C4NetIOUDP broadcast to IPv6
It's not actually used anywhere, but it's not broken now!

This also moves the low-level and OS-specific GetLocalAddresses code to
C4NetIO where it's fitting better than in C4Network2Client.
2017-01-18 21:54:50 +01:00
Lukas Werling 890deb997d Improve "unexpected address family" asserts 2017-01-18 21:54:50 +01:00
Lukas Werling efe0b134ef Use UDP address from puncher to derive TCP address
This is necessary for dual stack connections where the masterserver will
only an IPv6 address and the netpuncher will only return a UDP address/port.
2017-01-18 21:54:50 +01:00
Lukas Werling 602d62cf52 Implement netpunching for IPv6 2017-01-18 21:54:50 +01:00
Lukas Werling b3ef196935 Remove ResolveAddress()
As setting a default port is a common operation, add a helper function
for this.
2017-01-18 21:54:50 +01:00
Lukas Werling 85f5b3cb75 Fix local network discovery 2017-01-18 21:54:49 +01:00
Lukas Werling 97be97c94c netpuncher: Add runtime error handling
Previously, the netpuncher would just exit silently when encountering an
error.
2017-01-18 21:54:49 +01:00
Lukas Werling 5a09c1d4a5 Convert addresses from puncher to IPv4
Addresses from the puncher would show as [::ffff:1.2.3.4] and be a bit
confusing.
2017-01-18 21:54:49 +01:00
Lukas Werling 68d18bf872 Remove obsolete CompileFunc for in_addr 2017-01-18 21:54:49 +01:00
Lukas Werling ef9be2e24e Change (discovery) multicast to IPv6
We use ff02::1 as discovery multicast address.

This "all nodes" multicast address is good enough for discovery in the
local network as packets there are likely broadcasted over ethernet
anyways.
2017-01-18 21:54:35 +01:00
Lukas Werling 793207ce28 Fix connections to link-local IPv6 addresses
Link-local IPv6 addresses are valid on all interfaces and thus need an
interface specifier / scope id, e.g. fe80::1%eth0.
2017-01-18 21:54:02 +01:00
Sven Eberhardt 771a82d879 Fix direct PXS insertion when multiple PXS are at the same location
When many PXS were at the same location (e.g. because of fast/multiple pumps pumping into a basin), only one PXS per frame could be inserted because insertion of one PXS would postpone insertion of additional PXS in the same frame until they finished their slide movement.

This caused some scenarios like Rapid Refining to become very frustrating, because adding extra pumps didn't actually do anything (unless you tricked the insertion by putting the output into the basin).

Now insert them directly if slide movement led to an insertion position.
2017-01-16 20:32:20 -05:00
Maikel de Vries ba731123a2 allow for script players to enter full teams
This should not break anything because script players are created by scripts and one may expect sane behaviour. This is useful to block entry for normal players into a team.
2017-01-16 18:57:00 +01:00
Lukas Werling 5d803d3be3 Improve "could not find connection" error message 2017-01-09 20:35:04 +01:00
Lukas Werling 1925f47440 Fix C4NETIO_DEBUG option 2017-01-09 20:35:04 +01:00
Lukas Werling 592ef85672 Fix local IPv6 address discovery 2017-01-09 20:35:04 +01:00
Nicolas Hake 102047f537 Implement IPv6 support to C4NetIO 2017-01-09 20:34:43 +01:00
Nicolas Hake c73fed8aa6 C4Group: Make more stuff private
C4Update needs to access some internal data of C4Group and uses a
special derived class (C4GroupEx). Make everything it doesn't want to
tamper with private so it's more obvious what is and isn't accessed from
outside the class.
2017-01-07 13:41:50 +01:00
Nicolas Hake aef2705825 C4Group: Delete some dead code
The pByChild parameter to C4Group::AdvanceFilePtr was never used except
to pass it to itself recursively, and C4Group::ProcessOut was never used
at all.
2017-01-07 13:41:48 +01:00
Nicolas Hake 561e083181 Win32: Fix build with MSVC's Clang-based toolset
Well, somewhat. I can't get Clang/C2 to build Qt so I can't build OC
with Qt support.
2017-01-07 13:41:47 +01:00
Nicolas Hake c2ae62975a Win32: Fix build without Qt 2017-01-07 13:41:46 +01:00
Nicolas Hake b0b0533227 Make c4script binary use our private getopt library if necessary
Systems that don't come with getopt/getopt_long in their runtime library
need to link to our private copy; link that and use the right const-ness
for its prototype.
2017-01-07 13:41:45 +01:00
Nicolas Hake eeea131674 Aul: Enable better for loop generation
Instead of jumping forward and back repeatedly per iteration, we're
moving the incrementor past the body, which is when it's supposed to be
executed anyway.
2017-01-07 13:35:51 +01:00
Sven Eberhardt d46f98fd7b Add EditorCollection callback
To be used to re-route contents created/moved in editor.
2017-01-01 17:00:56 -05:00
Lukas Werling 088fc450d9 Distribute players based on team instead of PrefPosition 2017-01-01 22:52:48 +01:00
Lukas Werling 52626fe021 Fix AulCompiler leaking C4Strings with variable names 2016-12-24 00:13:02 +01:00
Lukas Werling 61962fe70a Add --check/-c parameter to c4script for syntax checking 2016-12-23 17:18:00 +01:00
Lukas Werling f9305a1526 Editor: Fix crash when trying to save scenario into itself 2016-12-19 23:14:49 +01:00
Maikel de Vries ae6cdc6619 fix return value of InsertMaterial when a pixel is created
This is a partial fix for #1865. Also this return value still needs to be fixed for query_only == true, but that requires a bit more work in C4PXS.
2016-12-19 22:49:28 +01:00
Lukas Werling 8d9eedffe4 Reset C4NET2IO_DUMP_LEVEL to 1 (#1869) 2016-12-19 17:30:19 +01:00
Lukas Werling d84c9b174f Add warning for non-UTF-8 files 2016-12-13 22:40:51 +01:00
Lukas Werling 4c51620dcf Fix UPnP/Linux crash when there is no UPnP device 2016-12-10 22:07:37 +01:00
Nicolas Hake 60829ae5e4 Aul: Don't let exceptions escape from constant resolver
Letting the constant resolver throw exceptions prevented us from doing
checking on later initializers anyway, so instead we'll send them to the
error handler. As a special bonus this makes it so we don't crash when
a global variable initializer has errors. Fixes #1850, #1855.
2016-11-30 13:37:33 +01:00
Armin Burgmeier 88361ab606 Use NEAREST texture filtering for material map
The material map is 1D texture that contains information about every
material-texture combination. There is no point in linear filtering,
i.e. trying to interpolate between two materials such as gold and granite
or whichever two materials happen to be adjacent in the material map texture.

This might or might not be relevant to #1841, but should be more correct
behavior in any case.
2016-11-27 11:21:17 -08:00
Armin Burgmeier 0340a28cdd editor: delete viewport widgets immediately
I don't know why the viewports are deleted with deleteLater(), but it leads
to an OpenGL context getting deselected behind our back, and so we don't know
when is a good time to re-select it. This leads to termination of the engine
when selecting File->Close (Ctrl+W) in the editor, because the graphics
re-initialization fails with no GL context active.

Instead, just delete the viewport widget immediately, which works fine at
least on Linux. This is also recommended by the Qt documentation at
http://doc.qt.io/qt-5/qopenglwidget.html.
2016-11-26 15:19:56 -08:00
Armin Burgmeier 75cbba8b7d editor: keep track of viewports properly
When removing a viewport, then also remove it from the internal list of
viewports. Otherwise, we might attempt to delete it again later. Fixes
crash on editor shutdown on Linux.
2016-11-26 15:19:56 -08:00
Armin Burgmeier 648309cf7e Make console destruction more deterministic
This fixes a crash on Linux when exiting the editor. It was caused by
C4Console::~C4Console being called by the C++ runtime after after main()
returned. The C4Console destructor then goes and deletes all the Qt
resources (QApplication and friends), and that caused a segfault, maybe
because some of the static Qt structures have already been deallocated.

Fix this by making the destruction of the Qt components deterministic. Add
a function "DeleteConsoleWindow" which deletes all the Qt components, and
call this function in C4Console::Clear.
2016-11-26 15:19:56 -08:00
Armin Burgmeier 7a8b01f7d5 Change return type of CreateConsoleWindow to bool
All implementations were just returning `this` anyway, and this makes it
easier to add a corresponding cleanup function.
2016-11-26 15:19:51 -08:00
Sven Eberhardt 5ccc932386 Editor: Disable packed export if no game is loaded 2016-11-22 22:28:19 -05:00
Sven Eberhardt 1cde52e060 Editor: Add "Export packed" file menu item 2016-11-20 22:43:44 -05:00
Sven Eberhardt d77206338c Editor: Fix pre-selection of last file and folder in save as dialogue 2016-11-20 22:43:15 -05:00
Sven Eberhardt 27272aea02 Fix mac build 2016-11-20 13:58:25 -05:00
Sven Eberhardt 04b5f82080 Editor: Add "open in network" to file menu and to new scenario dialogue 2016-11-20 13:24:09 -05:00
Sven Eberhardt 5e2c39da28 Editor: Fix shape edge and vertex properties when used within an enum 2016-11-20 13:15:00 -05:00
Sven Eberhardt e0d741079a Editor: Fix shape drag value updates 2016-11-20 13:15:00 -05:00
Sven Eberhardt 6793455119 Add drag_finished parameter to EditCursorMoved callback 2016-11-20 13:14:59 -05:00
Sven Eberhardt c5623aa7a2 Fix crash on script error in DirectExec scripts 2016-11-20 13:14:57 -05:00
Sven Eberhardt a46ecc7b5b Editor: Invalidate selection if EditCursorMoved()-callback returned true
This allows position-induced shape- or property-changes to be reflected immediately.
2016-11-16 01:11:55 -05:00
Nicolas Hake 34bdab6ba5 Aul: Don't force assertions active
Assertions are great for debugging, but in public builds they just kill
apps dead.
2016-11-13 11:07:22 +01:00
Nicolas Hake eda6cc9c7f Aul: Gracefully handle errors in codegen (#1840)
By continuing to generate bytecode even after an error is found, we're
able to find more syntax errors and will also be able to keep the value
stack at the expected height.
2016-11-13 11:07:21 +01:00
Nicolas Hake ff0325dfac Aul: Always reset the current function when a declaration ends (#1839)
When an error occurred during codegen of a function, the current
function pointer would not be reset to 0, leading to spurious warnings
about redeclaration of functions.
2016-11-13 11:07:01 +01:00
Sven Eberhardt 072e1dcde0 Editor graph delegate: Add update callback functionality for graph edits 2016-11-12 22:20:05 -05:00
Sven Eberhardt 83c1d25b84 Fix editor graph delegate vertex hit radius 2016-11-12 22:20:04 -05:00
Sven Eberhardt 1621e984a9 Editor shapes: Update shape if value changed by script 2016-11-12 22:20:04 -05:00
Sven Eberhardt 91af5a95be Editor graph delegate: Add HorizontalFix, VerticalFix and StructureFix constraints 2016-11-12 22:20:03 -05:00
Lukas Werling 3b2909fa95 Use glUniform*iv for setting script uniforms 2016-11-13 00:17:35 +01:00
Lukas Werling d720e648ce Fix compile error with libstdc++ 2016-11-13 00:13:04 +01:00
Lukas Werling 6847e50e79 Implement setting shader uniforms from script (#1206)
Uniform variables are read from the "Uniforms" proplist set on Scenario
or on individual objects. Proplist keys are uniform names. Values can
either be an int or an array of one to four ints in C4Script. In GLSL,
the uniforms then need a matching type (int/ivec2/ivec3/ivec4). There is
no error reporting; uniforms are only set if both name and type match.

The implementation walks the "Uniforms" proplists on each Draw call. We
may need to cache the uniform maps if this turns out to be too slow.
2016-11-12 22:09:23 +01:00
Lukas Werling b3772e6650 Fix assertions in C4ConsoleQtGraph 2016-11-11 18:00:21 +01:00
Sven Eberhardt bf9c940aa6 Editor graph delegate: Add edge and vertex properties. Remove graph storage options.
The different storage options weren't really needed and would not work with edge and vertex delegates.
2016-11-10 21:43:43 -05:00
Sven Eberhardt e13bd62f94 Editor: Keep current shape list separate from property holders
This prevents shapes from being re-created (and temporary state lost) if the holding property moves within the list.
2016-11-10 21:43:42 -05:00
Sven Eberhardt 1e52ed5a74 Remove unused variable ndx in C4AulParse::Parse_Expression 2016-11-10 21:43:41 -05:00
David Dormagen 8a8593e0ba Script GUI: added TightGridLayout style (requirement of #1842)
The TightGridLayout fills spaces more aggressively. This is slower but makes for a tighter layout. Finding the best layout is NP-complete. This here is just O(N^2) or so.
2016-11-05 15:35:15 +01:00
Julius Michaelis 7aeec3279c Fix 75289da and 55b6713 2016-11-03 13:09:54 +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
Sven Eberhardt 54e8c14666 Editor: Add graph, polyline and polygon shape delegates 2016-11-02 09:54:31 -04:00
Julius Michaelis 75289dabb5 Always Log chat message 2016-11-01 19:26:38 +01:00
Lukas Werling 9c98227a03 Fix all -Wformat warnings 2016-10-31 23:39:45 +01:00
Sven Eberhardt f17046e1f0 Fix display of rotated meshes with MeshTransformation
Rotation used the wrong (untransformed) coordinates for the rotation center
2016-10-31 10:10:29 -04:00
Nicolas Hake 194e7d709b Aul codegen: Handle errors at codegen time better (#1837)
If a parse error occurs inside a declaration, the codegen should just go
on and deal with the next declaration instead of completely giving up on
the entire script.
2016-10-31 11:17:43 +01:00
Nicolas Hake f0f50ec402 Aul: Don't prepend "ERROR:" to parser error msgs
Further formatting of the error message should be the error handler's
job.
2016-10-31 11:16:14 +01:00
Nicolas Hake 3c13c88f56 Aul: Count errors and warnings properly
9caaf1e introduced an external error handler for easier testing of
error conditions. The default error handler needs to count errors and
warnings if we want to display them, but didn't.
2016-10-31 11:15:19 +01:00
Sven Eberhardt 5c5e1a5fa3 Fix editor selection after object duplication on remote clients
Also remove some remaining EditCursorSelection/EditCursorDeselection callbacks
2016-10-30 22:26:14 -04:00
Kanibal 97c8104ac8 Fix msvc build. 2016-10-30 21:46:29 -04:00
Sven Eberhardt 15fbb1ea99 Fix editor runtime join to use a file at the temporary path 2016-10-30 20:40:40 -04:00
Julius Michaelis 55b6713185 Dedicated server: stop game when there are less than 2 clients 2016-10-30 21:36:29 +01:00
Julius Michaelis 890669ea0d Silence a warning from getopt when using --config 2016-10-30 21:36:29 +01:00
Julius Michaelis 65940080a7 Remove two unused config options, set music to default off with the dedicated.
I admit that this is just a hack to silence some warnings by default.
2016-10-30 21:36:29 +01:00
Julius Michaelis 64dd72c380 Fix dedicated: Load JPEG surfaces so the texture shape information can be correctly generated 2016-10-30 21:36:29 +01:00
Lukas Werling 63cc42e967 Improve script shader code
- Avoid std::list.

 - Don't pass strings and vectors by value.

 - Don't try to update script shader slices as they never change.
2016-10-30 12:06:01 +01:00
Julius Michaelis 29b5fa5946 Fix include: no "src/" 2016-10-30 01:21:44 +02:00
Lukas Werling 13fa0ab7b1 Implement adding/removing shaders from script
New script functions: AddFragmentShader, RemoveShader.

There is currently no support for adding vertex shaders.
2016-10-29 21:19:08 +02:00
Julius Michaelis 9ab410e47d SDL: Notify C4Application of resolution / window size changes. 2016-10-29 14:15:09 +02:00
Nicolas Hake bce0b45413 Editor: Fix scheduler timer so it doesn't busy wait (#1834)
36/1000 is always 0 and doesn't make a lot of sense anyway. Use 1000/36
(aka 1000ms/36fps) instead so the UI thread has some time to rest.

Also use a Qt::PreciseTimer so Qt doesn't try to coalesce the scheduler
timer with other timers to save energy.
2016-10-28 21:31:14 +02:00
Sven Eberhardt f2231e848e AulCompiler: Fix static parameter type check 2016-10-24 22:00:30 -04:00
Julius Michaelis e61dcbe4c3 Extend the netpuncher: clients can ask hosts for a connection initiation to circumvent port restricted NATs 2016-10-23 22:34:43 +02:00
David Dormagen c2f391e565 editor: don't crash on selecting object when EditorBase doesn't have member EditorProps
This crash happened for me in a custom scenario but with unmodified original objects. No idea why, but it seemed defective anyway.
2016-10-23 18:47:44 +02:00
Julius Michaelis 376ca5a9df Prevent using USE_CONSOLE in lib{misc,c4script} 2016-10-22 17:42:23 +02:00
Lukas Werling e7f4105b97 Replace duplicate BreakMessage() implementations
...with a single one based on std::string in the hope of getting rid of
StdStrBuf some day.
2016-10-22 17:00:20 +02:00
Nicolas Hake cada67c097 Prohibit overriding local vars with functions (#1831)
The old parser threw a standard compile error in this case; the
AST-based parser threw an ICE, which is ultimately the same thing but
made it sound like the parser was at fault. And maybe it is, and we
should allow code like "local a; func a() {}" but that seems like it
should be a conscious design decision.
2016-10-21 22:32:24 +02:00
Julius Michaelis 8d2f2846b5 Fix mac build
Also move some stuff around once again…
2016-10-21 01:25:48 +02:00
Julius Michaelis 5b7c5b48ee Fix mape and mac build
Attempt #1.
2016-10-20 20:36:52 +02:00
Julius Michaelis 34a9a1de8d Twiddle with header organization: lib{misc,c4script} do no longer include GL/glew.h
(Yes, it is just that complicated.)
2016-10-20 18:46:32 +02:00
Nicolas Hake e2fd7095c1 Merge branch 'ast'
# Conflicts:
#	src/C4Include.h
#	src/script/C4AulCompiler.cpp
#	src/script/C4AulParse.cpp
#	src/script/C4AulParse.h
#	src/script/C4ScriptHost.cpp
#	src/script/C4ScriptHost.h
#	tests/CMakeLists.txt
2016-10-20 17:33:02 +02:00
Nicolas Hake 266feeda4d Aul: Add AST generation tests
Just making sure the parser creates the AST the way we expect before we
hand off the code to the codegen.
2016-10-20 17:20:55 +02:00
Nicolas Hake 118961d0b7 Aul: fix octal escape parsing
Bet you didn't know C4Script supported octal escapes inside strings.
Well, it didn't; or at least not correctly.
2016-10-20 16:53:23 +02:00
Nicolas Hake 5915f79960 Don't entirely recreate global vars in second compile pass
This allows people to properly cross-reference two proplists from each
proplist's initializer.
2016-10-19 14:20:48 +02:00
Nicolas Hake 021a6e89f5 Implement direct execution of whole function definitions
This implements the changes made in c6e4bfd on the AST-based parser.
2016-10-19 14:20:47 +02:00
Nicolas Hake 1a8db9e109 Make C4ScriptHost store C4Value refs to owned functions
C4Value already handles refcounting properly for us, so we don't need to
do it manually. It might still be worth manually refcounting them
to avoid the boxing/unboxing overhead, but it's only needed at load and
unload so it's not a priority at the moment.
2016-10-19 14:20:46 +02:00
Nicolas Hake 5f3dbdd417 Reject function expressions inside proplists inside functions
These aren't supported by the codegen on account of not working in
savegames.
2016-10-19 14:20:45 +02:00
Nicolas Hake 9caaf1e298 Aul: Split out error handling into a separate class for easier testing
By using an extern error handler in the script engine, we can mock that
handler and make sure something that should fail actually does, instead
of having to parse log messages.
2016-10-19 14:20:41 +02:00
Nicolas Hake b2d5164a0f Remove re namespace alias
This alias is a legacy from when we were using Boost.Regexp to
workaround a broken implementation in GCC's libstdc++ earlier than 4.9.
2016-10-19 13:46:03 +02:00
Nicolas Hake a188500609 Remove MS CRT memory management debugging
Redefining new breaks perfectly valid code, but only on MSVC and only in
one particular configuration (Debug). This is very annoying because it
means people not using MSVC, or even people doing Release builds, can
write standards-conforming code which then may fail to build for other
people.
2016-10-19 13:46:01 +02:00
Nicolas Hake f7a04624eb Remove references to functions defined in unloading defs (#1776) 2016-10-19 13:45:59 +02:00
Nicolas Hake ab1e6bd5a4 Allow proplist-local funcs to access vars of their owner's prototype
Thanks to JCaesar for providing this test case.
2016-10-19 13:45:35 +02:00
Nicolas Hake 1b32633806 Add C4LangStringTable::system_string_table def'n to standalone stubs 2016-10-16 20:11:13 +02:00
Armin Burgmeier 2362a73e60 FnSetSky: open Graphics.ocg before re-loading sky (#1827)
Needed to load shader slices in C4Sky::Init.
2016-10-16 10:04:54 -07:00
Armin Burgmeier 8f61918219 Initialize graphics when re-loading sky (#1827)
Need this so that C4Sky::Init can read the shaders.
2016-10-16 10:04:54 -07:00
Nicolas Hake 8f47edc1e3 Fix destruction order of system string table vs. editor
Depending on the mood of the linker, the editor may have been
constructed before and destroyed after the system-wide string table
because they weren't defined in the same file. Destruction of the editor
tries to load some strings, which would then access the already
destroyed string table and thus crash.
2016-10-16 18:40:51 +02:00
Sven Eberhardt 24c386c67f Editor: Fix recent scenario display on welcome page if a recent entry was opened via path including Scenario.txt
Always show the name of the enclosing .ocs file.
2016-10-16 09:52:48 -04:00
Sven Eberhardt cd9d6f5c6f Editor: Show full path name in sound delegate display string 2016-10-16 01:15:38 -04:00
Sven Eberhardt 38cf275de7 Editor: Implement saving of editable enum delegates 2016-10-16 01:12:21 -04:00
Sven Eberhardt 386f178568 Editor: Auto-focus enum child editors for int, string, color and any types 2016-10-15 18:26:03 -04:00
Sven Eberhardt 028b576ab3 Editor: Change initial tool to "object edit" 2016-10-15 11:43:55 -04:00
Sven Eberhardt c44a776090 Editor: Fix object list update on object removal 2016-10-15 11:43:12 -04:00
Sven Eberhardt 978afbc4a2 Editor: Focus object script box on double-clicking item in object list 2016-10-15 10:39:33 -04:00
Sven Eberhardt d24afbe835 Editor: Fix display of non-object properties
Fixes property display of definitions, Global and Scenario.
2016-10-15 10:06:44 -04:00
Sven Eberhardt 06a438e05e Editor object list: Remove effects; add Global and Scenario 2016-10-15 10:06:44 -04:00
Sven Eberhardt 4b3f8c0fef Remove EditCursorSelection and EditCursorDeselection callbacks
They never worked properly in network mode because all users would see the changes.

EditorProps, EditorActions and shape delegates now provide the functionality to have custom object editing widgets.

This also fixes a bug with the selection callback causing the object list to act up.
2016-10-15 10:06:43 -04:00
Lukas Werling 59b5525a41 Rework sky definition parsing
This also adds a broken SetSky() script function which was the main
motivation for the rework. See #1827
2016-10-15 13:34:39 +02:00
Sven Eberhardt 15d850e4ec Editor: Add effects to property viewer 2016-10-14 10:50:17 -04:00
Nicolas Hake 66d5ef8b08 Reset codegen target after parsing nested function
Parsing a function expression inside another function failed to reset
the code generator target to the containing function, so all following
bytecode would still be appended to the nested function, leaving the
container broken.
2016-10-12 14:56:54 +02:00
Nicolas Hake d9696d2f88 Reorder game cleanup
The order in which game components were cleaned up seemed rather
arbitrary, so let's change that into blocks of reasonably connected
parts.
2016-10-11 19:44:29 +02:00
Nicolas Hake 14bfd7ea59 Clear console pointers earlier
It doesn't make a lot of sense to keep console pointers around while the
objects and scripts have already been deleted. Clear them earlier so we
don't have any dangling pointers.
2016-10-11 19:44:27 +02:00
Lukas Werling 170a793a44 Windows: Only write to stdout if there is no debugger 2016-10-11 18:07:31 +02:00
Sven Eberhardt 510d91fd00 Editor: Allow movement of HorizontalFix items by holding Shift and on object duplication 2016-10-10 21:46:17 -04:00
Sven Eberhardt 5e4aefddb2 Editor: Fix Ctrl+Click in object creation mode to create contents 2016-10-10 21:35:04 -04:00
Sven Eberhardt 4eae2b28d7 Editor: Fix drop cursor drawing 2016-10-10 21:26:10 -04:00
Sven Eberhardt d670291aba Implement tool tips for EditorActions 2016-10-10 16:45:23 -04:00
Sven Eberhardt 20d234e324 Editor: Replace | by line breaks in descriptions and EditorHelp texts 2016-10-10 16:45:22 -04:00
Nicolas Hake a6b65f0dee Merge pull request GH #28 from aburgm:fix-proplist-leak
Don't leak static proplists with cyclic references
2016-10-10 19:32:30 +02:00
Lukas Werling f5613c350e Windows: Write console output to stdout
This is useful for third-party editor UIs.

See http://forum.openclonk.org/topic_show.pl?tid=3344
2016-10-10 16:03:49 +02:00
Lukas Werling 4d5bb7304c Fix game controllers not working with the editor 2016-10-10 14:16:18 +02:00
Sven Eberhardt 5e3730fc3e Editor: Store+Restore maximized state 2016-10-08 20:53:01 -04:00
Sven Eberhardt 765648877f Editor: Fix window shutdown to correctly save editor geometry even if quitting via Application.Quit (e.g. Ctrl+Q) 2016-10-08 20:52:25 -04:00
Sven Eberhardt cf7134e60e Fix a few warnings / possible divisions by zero 2016-10-08 20:51:51 -04:00
Sven Eberhardt 45718ee44d Change tool hotkeys from <number> to to <Ctrl>+<number>
This allows better combined playing+editing experience [Maikel]
2016-10-08 19:15:28 -04:00
Sven Eberhardt 685513816f Editor: Raise focused viewport dock.
When switching viewports using F10, the selected dock may have been hidden
2016-10-08 19:15:27 -04:00
Sven Eberhardt 9e150f2bfb Viewport zoom towards center and fix scrolling 2016-10-08 19:15:26 -04:00
Lukas Werling eff406a181 Fix plain --lobby not working 2016-10-06 21:19:31 +02:00
Armin Burgmeier 561651b715 Fix issues with resolution switching on Linux
* Engine would always open up in Fullscreen and then switch to Windowed
   instead of just starting up as Windowed.

 * Could not change resolution because bit depth or refresh rate did not match
   * handle RefreshRate==0 as "any", just like windows

   * Remember refresh rate in combo box that enumerates all the modes and
     propagate to video mode setting instead of assuming all modes have the
     same refresh rate.

   * Report bit depth as 32 even if SDL tells us it's 24. Other parts of the
     code require it to be equal to 32, but 24 works just fine.

 * Changing from fullscreen to windowed when "Screen" was selected in
   resolution combo box (i.e. iXRes==-1) makes the window tiny (0x0 pixels).
2016-10-05 21:38:46 -07:00
Armin Burgmeier 25b1a49543 Set last error when setting resolution fails
The last error is displayed in the GUI, so until now there was just a "(null)"
string there.

The whole (SDL) resolution switching code is completely broken as well, but
that's a different story...
2016-10-03 22:39:46 -07:00
Lukas Werling bca0c76331 Lower minimum masterserver update interval to 1s
This interval is critical for the netpuncher. Clients have to wait for
the first masterserver update before they can join.
2016-10-03 00:05:23 +02: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
Armin Burgmeier 732fff3029 Fix possible use of uninitialized variables
For example, creating a C4WindowSDL and deleting it without calling
::Init() on it would lead to use of uninitialized variables.
2016-09-27 21:52:55 -10:00
Lukas Werling 8a09fcc1b1 Increase REPL output depth to 10 (from 1)
This makes working with nested arrays and proplists a lot less annoying.
2016-09-26 16:33:24 +02:00
Maikel de Vries 679eedaf50 GetPathLength: add optional depth parameter
This is also exposed by the PathFinder defcore entry.
2016-09-25 21:48:19 +02:00
Lukas Werling c3cf464a83 Editor: Fix scenario open filter (#1817) 2016-09-18 23:22:39 +02:00
Lukas Werling 880981ad31 Fix build on systems with non-long regex index types 2016-09-18 19:40:32 +02:00
Lukas Werling fbb8ad5d87 Add RegexSplit() 2016-09-18 11:10:19 +02:00
Lukas Werling 219f81f004 Regex: Fix off-by-one error 2016-09-18 10:49:06 +02:00
Lukas Werling 619ad27a91 Regex: Fix infinite loop with zero-length matches 2016-09-18 01:16:06 +02:00
Lukas Werling b614209593 SDL: Use OpenGL 3.1 if 3.2 is not available (like WGL) 2016-09-17 12:32:18 +02:00
Lukas Werling d7cd224a4f Add functions RegexReplace, RegexSearch and RegexMatch 2016-09-16 23:46:03 +02:00
Sven Eberhardt 61b1ab08ad Editor: More shortcuts; show helper shortcuts in tools menu 2016-09-10 01:17:40 -04:00
Lukas Werling 8d9657a800 Change default puncher address to netpuncher.openclonk.org 2016-09-09 18:31:39 +02:00
Sven Eberhardt 2490ef4584 Editor: Add more shortcut keys 2016-09-09 00:56:16 -04:00
Sven Eberhardt e67e429fef Editor: Improve default layout and raise proper dialogues on tool change 2016-09-09 00:56:15 -04:00
Lukas Werling f7376169b9 Fix crash when starting a game in fullscreen mode 2016-09-08 21:26:59 +02:00
Lukas Werling 7177c261b3 Bring back and fix the netpuncher
As carrier-grade NATs are becoming common, many players cannot host
Clonk games at all. The simple STUN-like netpuncher from Clonk Rage
which was removed three years ago is already effective against some
DS-Lite NATs.

With some extensions, we should be able to make it work with more
restrictive NATs as well.

This reverts commit 72002cc366.
2016-09-08 21:10:06 +02:00
Sven Eberhardt 53b365a6d2 Editor: Add shortcuts, menu items, tooltips 2016-09-08 01:56:01 -04:00
Sven Eberhardt 0e02bad837 Editor: Disable reinit scenario button if no scenario is loaded 2016-09-08 00:25:17 -04:00
Sven Eberhardt b95d1387a4 Editor: Add "reset to saved scenario" command 2016-09-07 01:53:54 -04:00
Sven Eberhardt 856730aabd Fix some signed/unsigned warnings 2016-09-07 01:53:54 -04:00
Sven Eberhardt 2c20204021 Add C4SECT_ReinitScenario flag for LoadScenarioSection
This also resets the script engine and does player init callbacks. Useful to restart the scenario in the editor.
2016-09-07 01:53:53 -04:00
Lukas Werling 3d5f2f012a Fix openclonk-server build 2016-09-06 22:12:06 +02:00
Sven Eberhardt a882a6e64b Fix black editor screen due to GL object creation and removal in wrong context 2016-09-06 02:45:17 -04:00
Sven Eberhardt 5523e685fb Fix script engine assertion on game clear 2016-09-06 01:13:53 -04:00
Sven Eberhardt dee6086e1d Fix access violation in proplist-to-static conversion 2016-09-06 01:09:29 -04:00
Sven Eberhardt ba371db0e6 Editor property enum delegate: Improve grouping when an item is also a group 2016-09-05 19:19:33 -04:00
Sven Eberhardt d70506ee2e Improve GetDefinitionGroupPath script function
* Now works on _this instead of parameter
* Now works before editor window opened
2016-09-05 18:30:04 -04:00
Sven Eberhardt 41dde5e7d0 Add script function GetDefinitionGroupPath 2016-09-05 02:00:01 -04:00
Sven Eberhardt 31ead2507a Add Unstick() script function
Also add a position parameter to Stuck() script function.
2016-09-05 01:59:58 -04:00
Sven Eberhardt 3669f28b75 Fix array property delegate default value to write a copy instead of a reference when it's a static prop list 2016-09-04 02:14:30 -04:00
Sven Eberhardt 5a149b3b8a Add alpha mask option to editor property color delegate 2016-09-03 22:07:09 -04:00
Sven Eberhardt 31121d682c Rename option default value function property to DefaultValueFunction
It was "Get" and later "Set", which was always a bit confusing.
2016-09-01 18:32:24 -04:00
Sven Eberhardt 0093555b49 Fix sorting between groups and names in enum editor properties 2016-08-30 19:37:42 -04:00
Sven Eberhardt 30738c760e Fix water splashing particles 2016-08-30 18:56:46 -04:00
Sven Eberhardt 6ac3bde3de Fix possible crash in viewport drawing 2016-08-30 18:56:27 -04:00
Sven Eberhardt f53a4a6597 Fix enum parameter value resolution to nil when proplist value is undefined 2016-08-29 15:18:02 -04:00
Sven Eberhardt 80d5810c3e Another Mac/Linux build fix 2016-08-28 10:23:13 -04:00
Sven Eberhardt 5a2e96e25b Correct a format placeholder type 2016-08-28 10:17:36 -04:00
Sven Eberhardt 0acf8a36f9 Fix Linux/Mac build 2016-08-28 10:16:06 -04:00
Sven Eberhardt b763982f45 Fix scenario saving as network client to not delete saved scenario after game end (#1814) 2016-08-28 00:56:15 -04:00
Sven Eberhardt 3163332def EditorActions: Replace %player% by first local player number 2016-08-27 22:19:25 -04:00
Sven Eberhardt 949ab90fc8 Editor: Fix enum delegate setting a value on cancel undeer certain conditions 2016-08-27 21:33:25 -04:00
Sven Eberhardt aa8289b55b Editor: Always commit string property changes if text has been edited 2016-08-27 21:24:43 -04:00
Sven Eberhardt 528504d72e Editor: Hide grade circle in viewport when using rectangle or picker tool 2016-08-27 20:10:58 -04:00
Sven Eberhardt 4f74d88d51 Editor: Fix selected object property dropdown list 2016-08-27 19:56:46 -04:00
Sven Eberhardt c98f99b427 Editor: Do not reset landscape brush when switching tools 2016-08-27 19:43:34 -04:00
Sven Eberhardt 6070bb4782 Fix editor prop enum option Set function 2016-08-27 19:05:12 -04:00
Sven Eberhardt 64f7a97eb6 Fix hang on startup on negative definition priority 2016-08-27 18:37:56 -04:00
Sven Eberhardt 6b9df3118c Sort UserAction evaluators and groups by name
Also merge effect group into ambience group.
2016-08-27 16:46:59 -04:00
Sven Eberhardt 00bc92e13f Use short names as main editor delegate display in property window.
Simplifies most user action displays by omitting things like "Constant" in the list.
2016-08-27 10:12:17 -04:00
Sven Eberhardt 357eb462bd Fix display of nil enum child delegate value if stored in a proplist and key is not defined.
It would fall back to the outer value instead.
2016-08-27 02:21:35 -04: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
Lukas Werling 2044fc3c06 SDL: Fix wrong keyboad button labels 2016-08-20 23:16:31 +02:00
Sven Eberhardt 568088aedb Editor: Add Copy+Paste functionality for properties 2016-08-19 16:13:28 -04:00
Lukas Werling 26a552473c Add support for two extra mouse buttons (#mantis-is-down-right-now)
This also fixes a missing definition for "MiddleDouble". Only
implemented for SDL and Qt, someone else will have to do Windows.
2016-08-18 22:43:42 +02:00
Sven Eberhardt 5d6ecc8dc8 Fix possible hang on effect execution with timer=1
If a timer=1-effect registered another timer=1-effect into the same object, it could cause an endless loop. This happened if the timer in the sequence object was set to 1.
2016-08-18 00:14:19 -04:00