2021-11-19, 12:21 AM
2021-11-19: What Is YSI_SetTimerEx?
YSI redefines several SA:MP natives internally. For example:
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:
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:
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(