Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] YSI Daily Tips

Thread Closed 
 
  • 1 Vote(s) - 5 Average
Pawn YSI Daily Tips
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#41
2021-11-17, 09:12 PM (This post was last modified: 2021-11-18, 12:27 AM by Y_Less.)
2021-11-17: Unsafe YSI.

YSI does a lot of checks and work at mode start to ensure many things, including:
  • All callbacks work.
  • The correct mode type is determined (FS/GM).
  • JIT and crashdetect plugins are handled well.
  • Mode information is available when asking for help in forums/discord.
  • Run-time generated code can be debugged.
  • Client types are determined.
  • Latest versions are checked.
  • Reasons for slow startup (the things just mentioned) are well documented.
  • And more...

This produces a slower startup (with good reason) and a lot of output (also with good reason, it
helps immensely with helping people).  However, some people do not like these steps and frequently
complain about them.  Previously different steps could be disabled with commands like
#define YSI_NO_OBNOXIOUS_HEADER or
#define YSI_NO_OPTIMISATION_MESSAGE, but these were poorly documented,
often missing new features that people wanted to remove, and just plastered across the top of a mode
with no thought or understanding as to why they were there in the first place (the obnoxious header
was just for fun).

So instead, I've added a new way to disable these checks and features; which involves signing a mini
"contract" in defines to state that you accept full responsibility for all errors/bugs/crashes
arising from disabling these checks.  This contract is only for people who actually know what
they're doing, and I'm not even going to put it here as a "just use this magic code" solution.  I'll
also probably randomly change it in subtle ways periodically so you need to keep it updated with YSI
changes.  Including it in a mode and releasing that will only go badly for anyone using that mode.

The change is called ENABLE_YSI_UNSAFE_STARTUP, and defining it along with its contract makes the following changes:
  • All startup messages are disabled, except for one single line to say this mode is in
  • callbackfix.amx is not loaded as a filterscript, so you need to manually ensure that OnRconCommand and OnClientCheckResponse work for your mode.
  • OnScriptInit is simplified, #define FILTERSCRIPT is again required for filterscripts.
  • y_master cloud mode is removed, you must specify one of the single-behaviour y_master modes.
  • Disable scriptfiles YSI folder checks, just assumes they are correct.
  • Ignores old (default) compiler compatibility. It might work, it might not...
  • Slow function crashdetect messages are re-enabled on startup.
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#42
2021-11-19, 12:21 AM
2021-11-19: What Is YSI_SetTimerEx?

YSI redefines several SA:MP natives internally. For example:

Quote:
native YSI_HTTP(index, type, const url[], const data[], const callback[]) = HTTP;
native YSI_Format(dest[], size = sizeof (dest), const format[], GLOBAL_TAG_TYPES:...) = format;

native YSI_SendRconCommand(const str[]) = SendRconCommand;

Why? What's wrong with the originals? Simple - they're sometimes wrong. The updated (community) compiler is const-correct, which means that passing a constant such as a string literal to a parameter that might be modified is a compile-time warning. This is a very good thing that should be enabled, but does cause some issues with people using the default includes (because they are not const-correct). One solution to this is fixes.inc, which correctly redefines the natives to be const-correct; another solution is the samp-stdlib updated includes which do the same thing (amongst other updates).

However, YSI can work with the old or new compiler, and with or without fixes.inc and samp-stdlib, so it needs to always work regardless of the combination of other includes involved. Code that is not const-correct might give warnings on the new compiler (for obvious reasons), but code that is not const-correct might (counter-intuitively) give errors on the old compiler. For example:

Quote:
stock MyFunction(const function[])
{
____return SetTimer(function, 1000, false);
}

Will give an error on the old compiler as function is const, but shouldn't be for SetTimer.

Hence, YSI bypasses this problem entirely and declares its own const-correct versions of a few select functions that it needs. Doing so happens only sparingly as required, because the downside is that this also bypasses hooks; and it breaks if hooks aren't declared with ( as they should be:

Quote:
#define SetTimer( Hooked_SetTimer(
« Next Oldest | Next Newest »

Pages (2): « Previous 1 2


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode