Skip to content

Instantly share code, notes, and snippets.

@Y-Less
Created December 14, 2020 03:57
Show Gist options
  • Save Y-Less/505de60f06bd3ef1b7c629c534eafcb7 to your computer and use it in GitHub Desktop.
Save Y-Less/505de60f06bd3ef1b7c629c534eafcb7 to your computer and use it in GitHub Desktop.
YSI_Core/y_core/y_samp_natives.inc | 2 ++
YSI_Core/y_testing/y_testing_entry.inc | 2 --
YSI_Visual/y_dialog/y_dialog_impl.inc | 14 ++++----------
3 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/YSI_Core/y_core/y_samp_natives.inc b/YSI_Core/y_core/y_samp_natives.inc
index f871a819..b74ad0e6 100644
--- a/YSI_Core/y_core/y_samp_natives.inc
+++ b/YSI_Core/y_core/y_samp_natives.inc
@@ -80,3 +80,5 @@ native YSI_PrintF(const format[], GLOBAL_TAG_TYPES:...) = printf;
native YSI_SetTimer(const funcname[], interval, repeating) = SetTimer;
native YSI_SetTimerEx(const funcname[], interval, repeating, const format[], GLOBAL_TAG_TYPES:...) = SetTimerEx;
+native YSI_ShowPlayerDialog(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[]) = ShowPlayerDialog;
+
diff --git a/YSI_Core/y_testing/y_testing_entry.inc b/YSI_Core/y_testing/y_testing_entry.inc
index 758749f3..93ec0a7e 100644
--- a/YSI_Core/y_testing/y_testing_entry.inc
+++ b/YSI_Core/y_testing/y_testing_entry.inc
@@ -311,8 +311,6 @@ stock _Testing_Start(const name[])
* </remarks>
*//*------------------------------------------------------------------------**/
-native YSI_ShowPlayerDialog(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[]) = ShowPlayerDialog;
-
stock Testing_Ask(playerid, const str[] = "", GLOBAL_TAG_TYPES:...)
{
#pragma unused str
diff --git a/YSI_Visual/y_dialog/y_dialog_impl.inc b/YSI_Visual/y_dialog/y_dialog_impl.inc
index 99b32659..e257c95a 100644
--- a/YSI_Visual/y_dialog/y_dialog_impl.inc
+++ b/YSI_Visual/y_dialog/y_dialog_impl.inc
@@ -113,24 +113,18 @@ stock Dialog_ShowCallbackData(playerid, callback[E_CALLBACK_DATA], style, const
return Dialog_ShowCallback(playerid, F@_@iiiis:callback[E_CALLBACK_DATA:0], style, title, caption, button1, button2);
}
-#if defined _ALS_ShowPlayerDialog
- #define Dialog_ShowPlayerNative ShowPlayerDialog
-#else
- native Dialog_ShowPlayerNative(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[]) = ShowPlayerDialog;
-#endif
-
stock Dialog_Show(playerid, style, const string:title[], const string:caption[], const string:button1[], const string:button2[] = "")
{
broadcastfunc Dialog_Set(playerid, YSI_DIALOG_ID);
YSI_g_sPlayerMaster[playerid] = true;
- return Dialog_ShowPlayerNative(playerid, YSI_DIALOG_ID, style, title, caption, button1, button2);
+ return YSI_ShowPlayerDialog(playerid, YSI_DIALOG_ID, style, title, caption, button1, button2);
}
stock Dialog_Hide(playerid)
{
// This almost looks like a Windows API function call!
broadcastfunc Dialog_Set(playerid, -1);
- return Dialog_ShowPlayerNative(playerid, -1, 0, NULL, NULL, NULL, NULL);
+ return YSI_ShowPlayerDialog(playerid, -1, 0, NULL, NULL, NULL, NULL);
}
HOOK__ OnPlayerDisconnect(playerid, reason)
@@ -189,7 +183,7 @@ stock Dialog_ShowPlayerDialog(playerid, dialog, style, const string:title[], con
return 0;
broadcastfunc Dialog_Set(playerid, dialog);
YSI_g_sPlayerMaster[playerid] = true;
- return Dialog_ShowPlayerNative(playerid, dialog, style, title, caption, button1, button2);
+ return YSI_ShowPlayerDialog(playerid, dialog, style, title, caption, button1, button2);
}
#if defined _ALS_ShowPlayerDialog
@@ -197,7 +191,7 @@ stock Dialog_ShowPlayerDialog(playerid, dialog, style, const string:title[], con
#else
#define _ALS_ShowPlayerDialog
#endif
-#define ShowPlayerDialog Dialog_ShowPlayerDialog
+#define ShowPlayerDialog( Dialog_ShowPlayerDialog(
#define _ALS_HidePlayerDialog
#define HidePlayerDialog Dialog_Hide
@Y-Less
Copy link
Author

Y-Less commented Dec 14, 2020

This doesn't make the default ShowPlayerDialog const-correct. If you call that without y_dialog you'll still get the original SA:MP version. This defines another native, YSI_ShowPlayerDialog that is const-correct. While it actually calls the same code in the end, the compiler has different rules to enforce for the two versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment