Giter Site home page Giter Site logo

Server API Revamp about terrariaapi-server HOT 11 CLOSED

cheahjs avatar cheahjs commented on July 16, 2024
Server API Revamp

from terrariaapi-server.

Comments (11)

Olink avatar Olink commented on July 16, 2024

How would this affect plugins that already hook and do massive computations on onupdate? Is the extra time for this implementation linear or exponential?

from terrariaapi-server.

Olink avatar Olink commented on July 16, 2024

I guess it should be noted that I am all for a better system, so long as the code is portable between updates (aka we just need to add one-two lines in the new source to invoke the hook etc)

from terrariaapi-server.

hakusaro avatar hakusaro commented on July 16, 2024

I suppose he's got a point though - plugins aren't going to work out of the box anyway.

from terrariaapi-server.

CoderCow avatar CoderCow commented on July 16, 2024

How would this affect plugins that already hook and do massive computations on onupdate? Is the extra time for this implementation linear or exponential?

Wouldn't affect them at all. It's just the call to the handler which takes a very bit more performance than before, the code that is eventually executed by the handler will have no difference in performance. It's basically as with the current implementation, the more handlers register with a hook, the more performance is consumed for each invoke of those, this implementation takes maybe a few nanosecs more processing time for each handler invoke than the current implementation - the overhead is very low and will have no notable effect as long as a hook with maybe 20 handlers is not called 1000 times in one game frame or so.

I guess it should be noted that I am all for a better system, so long as the code is portable between updates (aka we just need to add one-two lines in the new source to invoke the hook etc)

Yes, good point. The Invoke methods should therefore be implemented so that hook invocations are as simple as possible, thus except for a different syntax this design then wouldn't make a difference to the current implementation. In comparison it would be looking like this:

if (NetHooks.OnGetData(ref num2, this, ref index1, ref length))
  return;

vs

if (PluginAPI.Hooks.InvokeNetGetData(ref num2, this, ref index1, ref length))
  return;

So whether a hook is invoked or handlers are registered, it's basically always just one line change. I've also designed it so that adding new hooks is pretty straight forward too.

By the way, another advantage of this system is that it could also deregister all handlers of a plugin automatically when the plugin disposes.

from terrariaapi-server.

hakusaro avatar hakusaro commented on July 16, 2024

πŸ‘

Lucas Nicodemus via Web

On Sat, Aug 3, 2013 at 1:28 AM, CoderCow [email protected] wrote:

How would this affect plugins that already hook and do massive
computations on onupdate? Is the extra time for this implementation linear
or exponential?

Wouldn't affect them at all. It's just the call to the handler which takes
a very bit longer than before, the code that is eventually executed by the
handler will have no difference in performance. It's basically as with the
current implementation, the more handlers register with a hook, the more
performance is consumed for each invoke of those, this implementation takes
maybe a few nanosecs more processing time for each handler invoke than the
current implementation - the overhead is very low and will have no notable
effect as long as a hook with maybe 20 handlers is not called 1000 times in
one game frame or so.

I guess it should be noted that I am all for a better system, so long as
the code is portable between updates (aka we just need to add one-two lines
in the new source to invoke the hook etc)

Yes, good point. The Invoke methods should therefore be implemented so
that hook invocations are as simple as possible, thus except for a
different syntax this design then wouldn't make a difference to the current
implementation. In comparison it would be looking like this:

if (NetHooks.OnGetData(ref num2, this, ref index1, ref length))
return;

vs

if (PluginAPI.Hooks.InvokeNetGetData(ref num2, this, ref index1, ref length))
return;

So whether a hook is invoked or handlers are registered, it's basically
always just one line change. I've also designed it so that adding new hooks
is pretty straight forward too.

By the way, another advantage of this system is that it could also
deregister all handlers of a plugin automatically when the plugin disposes.

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-22051197
.

from terrariaapi-server.

CoderCow avatar CoderCow commented on July 16, 2024

Alright, I'll prepare a PR for this then, guess another branch for this would be wise?

from terrariaapi-server.

hakusaro avatar hakusaro commented on July 16, 2024

Yes, but if we need to we can always use git fetch and pull your changes directly. Just keep the fork updated and public and such.

from terrariaapi-server.

CoderCow avatar CoderCow commented on July 16, 2024

There we go, first implementation done:
https://github.com/CoderCow/TerrariaAPI-Server/tree/1.14

Needs a lot of testing of course, I'll probably port TShock and some other plugins to 1.14 to see how it runs.
Feel free to tell me what you think about the code at all and how I can improve it.

from terrariaapi-server.

CoderCow avatar CoderCow commented on July 16, 2024

TShock on 1.14, runs fine:
https://github.com/CoderCow/TShock/tree/api_1.14

from terrariaapi-server.

hakusaro avatar hakusaro commented on July 16, 2024

Noblesse oblige. I await your pull request.

Lucas Nicodemus via Web

On Tue, Aug 6, 2013 at 1:58 PM, CoderCow [email protected] wrote:

TShock on 1.14, runs fine:
https://github.com/CoderCow/TShock/tree/api_1.14

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-22206534
.

from terrariaapi-server.

hakusaro avatar hakusaro commented on July 16, 2024

This code was added, so I'm closing this pull request.

from terrariaapi-server.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.