[Plugin] More control over plugin native errors (PoC)
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
What is the performance impact of this? The point of using natives is that they can be very fast, since they are written in a native language, with run-time optimisation to replace each native call with a direct reference to the function in the in-memory p-code. This removes all of that and replaces it with a string lookup, which could be significant overhead for short natives (especially since you appear to be using a linear string search).

Given the relatively tiny (IMHO) problems caused by a missing plugin, this seems like a huge price to pay to "fix" them.

Edit: Re-read and better understood what is going on. I still wonder about the performance hit, but not about the other issues I previously had.

Edit 2: Since you are using "GetGravity" by default, your "IsPluginLoaded" example won't work. If the plugin isn't loaded, then the original will be called and return the current non-zero gravity, which this will interpret as "plugin loaded".
I'm not sure of a performance impact, I have only tested this code on servers with low player counts (<50). I'm sure it could be made more efficient. From my experience it hasn't been necessary to test for a performance impact as I haven't noticed one. You could probably calculate the function addresses once (instead of every plugin call) and store in a hashmap, then you'd have faster lookup time.

The problems are pretty small but can be useful to automatically enable or disable functionality when you want your game mode to run with or without a plugin. Most people now are not doing any verification if a plugin is loaded and that can cause problems if a sa-mp version is updated and a plugin doesn't support a new sa-mp version. You can keep your game mode or filterscript working as you wait for a plugin developer to update.

This should work on new versions of sa-mp released without any modifications.

I'm not sure what you meant by your last paragraph. IsPluginLoaded has to be defined as a comparison function. See here:
pawn Код:
native plugin_gateway_param0(func[]) = GetGravity;

#define IsPluginLoaded() ((_:GetGravity()) != plugin_gateway_param0("IsPluginLoaded"))
If the plugin isn't loaded, these functions will return the same values.

Quote:
Originally Posted by chneubeul
Посмотреть сообщение
Hello

Your some function added with the plugin are pretty cool

On "surface", its include water too ?

What about the onplayerpaused, can we check if player is writing a message ?

See you
That plugin really isn't what this topic is about, but you can find out more about it from the website that's linking it.
Reply


Messages In This Thread
More control over plugin native errors (PoC) - by Whitetiger - 21.12.2017, 05:13
Re: More control over plugin native errors (PoC) - by StrikerZ - 21.12.2017, 08:01
Re: More control over plugin native errors (PoC) - by chneubeul - 21.12.2017, 09:47
Re: More control over plugin native errors (PoC) - by Whitetiger - 21.12.2017, 11:28
Re: More control over plugin native errors (PoC) - by Whitetiger - 21.12.2017, 12:08

Forum Jump:


Users browsing this thread: 1 Guest(s)