Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance, add vote draw plugin, minor fixes #815

Merged
merged 49 commits into from
Apr 15, 2020
Merged

Conversation

Person8880
Copy link
Owner

@Person8880 Person8880 commented Apr 12, 2020

Chatbox

  • Fixed a rare script error when auto-completing chat commands.
  • Fixed chat command completions sometimes being invisible.
  • Fixed the settings scrollbar sometimes being invisible.
  • Fixed the main scrollbar sometimes having the wrong colour when dragging it.

Map Vote

  • Fixed the map vote menu incorrectly stating that only one map may be chosen when multiple choice is enabled and the menu is opened automatically before a client has pressed a key.

Unstuck

  • Improved the algorithm for finding a safe position to reduce the number of times unsticking a player fails.
  • Added the MovementToleranceDistance option which controls the maximum distance a player's position is allowed to move from the location they request to be unstuck from. This can help in cases where a player is stuck jittering around a location.

Vote Draw

The votedraw plugin is a new plugin that provides a vote to end the current round as a draw. Players on both teams can vote after a configurable time has passed since the round started. This can be used as an alternative to conceding when the game reaches a stalemate and neither team wishes to lose.

For more information see the wiki page.

Misc

  • Improved performance of many hotspots in the code (hook calls, SGUI control events etc.) allowing LuaJIT to better compile code.
  • Added a system error notification when a plugin fails to load due to a Lua error.
  • Datatable values are now sent at client connection time, rather than waiting for input.

API

  • Added code generation helpers under shine/lib/codegen.lua to create specialised variations of general-purpose code that LuaJIT can compile.
  • SGUI easing callbacks now pass the SGUI control as the first argument (this is a breaking change for any code that used the GUIItem argument previously).
  • SGUI controls can now more easily track whether the mouse is inside using the OnMouseEnter and OnMouseLeave events, or the Control:HasMouseEntered() method. These changes also mean that OnMouseMove is now only called if the mouse is inside the parent control, or has just left it.
  • SGUI now automatically queues destruction of controls during events until after the event has fired to avoid destroying GUIItems that are used later in the event. Controls will still be removed from their parent control/layout immediately.
  • Hooks added via. the SetupGlobalHook and SetupClassHook functions now take the exact number of arguments the original function does, unless the original function has a var-arg. To pass through additional arguments, use a custom function for the hook mode and declare any extra arguments on it.
  • Timers can now have data attached to them by passing a value after the callback. This data value is available on the timer object's Data field.

* Handle missing GUIChat element gracefully.
* Handle local player classes that have no GetTeamNumber method when
checking commander tag visibility.
The existing require usage depends on a package loader added in
TraceTracker.lua, which doesn't return error messages.

This provides the same behaviour, but with the added benefit of a clear
error message when loading fails.
In places that handle dispatching arbitrary numbers of arguments, use
code generation to provide fixed argument size variations of dispatchers
rather than taking a vararg. This avoids NYI aborts, allowing these code
paths to be compiled.

Additionally, a few other places that caused aborts have been fixed,
such as colour checking (getmetatable on cdata aborts traces) and
extension event insertion (replacing closures with callable tables).

The overall result of this is an order of magnitude performance
improvement in hook calling/broadcasting and SGUI child event
propagation, as well as other minor improvements from LuaJIT being more
free to compile code.
This maintains backwards compatibility, even if it isn't ideal
behaviour.
Use the maximum of a custom handler's argument count, and the original
function's argument count.
This provides a vote to end the current round as a draw. It only
considers votes from players that are playing in the round, and has
a lengthy delay and high vote count requirement by default.
Make the background the only element that eases.
Converts easing functions from the built-in easing library into a form
that can be used with SGUI.
* Fix labels sometimes becoming invisible.
* Fix a rare script error due to modifying the layout elements directly.
* Improve fading to fade out the background segment of an entry along
with the label.
* Add a distance tolerance to account for players that are stuck but
still jittering slightly.
* Use the player's view position as the origin to look for spawn points
from to avoid small objects at the player's feet being considered walls.
Track when the mouse enters and leaves elements, and only call the
OnMouseMove event for child elements when the mouse is inside their
parent or the mouse has just left the parent.

These changes also simplify mouse bounds checks, removing highlight
multipliers and moving custom bounds to their own method.
Automatically queue the destruction to run after the event has been
called to avoid destroying GUIItems that may be used in later parts
of the event.
* Make easing callbacks pass the SGUI control as the first argument.
This makes avoiding closures much easier.
* Allow passing data with timers to avoid needing closures for
callbacks.
* Refactor various places that create functions at runtime to use either
callable tables or pre-defined functions instead.
* Remove some tail calls that fail to compile.
This avoids using Client.GetCursorPosScreen which doens't compile.
When destroying inside an event, detach the control to avoid it showing
up in iterations.
Use it for calls to AddProperty/AddBoundProperty to pre-populate it
with most setter names.
This avoids needing a closure when creating binding sources.
This generates more optimal code that avoids loops and upvalues.
If the bar is clicked during fade-in, make sure the fade is cancelled.
If a map vote starts while the player has yet to trigger the
ClientConfirmConnect event, they would not have the datatable values
that indicate the type of vote.

Datatables will now be sent at client connection time to ensure they are
immediately in sync.
Also fire the property change event.
* Fix map selection state not being set properly when opening the menu.
* Fix error when opening the menu due to highlighting changing before
the tile is setup.
When becoming visible again, or changing parent, the mouse state should
be invalidated.
Server.GetOwner is not compiled.
Now extension hooks are added directly with Hook.Add using a unique key.
This avoids a second level of dispatching which improves performance.
There's no reason for priorities to be integers, and this allows
extension callbacks to keep their -19.5 priority.
ffi.istype returns true for ctypes as well as cdata, which breaks if
the colour or vector ctypes end up in a table that's being printed (e.g.
if they're in a stack trace).
Avoid needing to check every plugin if no plugins have hooked into a
given event or the newly enabled plugin has no method for it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant