Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SourcePawn. #2068

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/logic/PluginSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#include <bridge/include/IVEngineServerBridge.h>
#include <bridge/include/CoreProvider.h>

#define SOURCEMOD_PLUGINAPI_VERSION 7

CPluginManager g_PluginSys;
HandleType_t g_PluginType = 0;
IdentityType_t g_PluginIdent = 0;
Expand Down Expand Up @@ -314,7 +316,7 @@ bool CPlugin::ReadInfo()
base->LocalToString(info->time, (char **)&pTime);
ke::SafeSprintf(m_DateTime, sizeof(m_DateTime), "%s %s", pDate, pTime);
}
if (m_FileVersion > 6) {
if (m_FileVersion > SOURCEMOD_PLUGINAPI_VERSION) {
base->LocalToString(info->filevers, (char **)&pFileVers);
EvictWithError(Plugin_Failed, "Newer SourceMod required (%s or higher)", pFileVers);
return false;
Expand Down
8 changes: 4 additions & 4 deletions core/logic/smn_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1787,10 +1787,10 @@ static cell_t SQL_ExecuteTransaction(IPluginContext *pContext, const cell_t *par

IPluginFunction *onSuccess = NULL;
IPluginFunction *onError = NULL;
if (params[3] != -1 && ((onSuccess = pContext->GetFunctionById(params[3])) == NULL))
return pContext->ThrowNativeError("Function id %x is invalid", params[3]);
if (params[4] != -1 && ((onError = pContext->GetFunctionById(params[4])) == NULL))
return pContext->ThrowNativeError("Function id %x is invalid", params[4]);
if (!pContext->GetFunctionByIdOrNull(params[3], &onSuccess))
return 0;
if (!pContext->GetFunctionByIdOrNull(params[4], &onError))
return 0;

cell_t data = params[5];
PrioQueueLevel priority = PrioQueue_Normal;
Expand Down
2 changes: 1 addition & 1 deletion core/logic/smn_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static cell_t sm_GetFunctionByName(IPluginContext *pContext, const cell_t *param
if (pPlugin->GetBaseContext()->FindPublicByName(name, &idx) == SP_ERROR_NOT_FOUND)
{
/* Return INVALID_FUNCTION if not found */
return -1;
return pContext->GetNullFunctionValue();
}

/* Return function ID */
Expand Down
2 changes: 2 additions & 0 deletions core/logic/smn_handles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,7 @@ REGISTER_NATIVES(handles)
{"CloseHandle", sm_CloseHandle},
{"CloneHandle", sm_CloneHandle},
{"GetMyHandle", sm_GetMyHandle},
{"Handle.Close", sm_CloseHandle},
{"Handle.~Handle", sm_CloseHandle},
{NULL, NULL},
};
14 changes: 5 additions & 9 deletions core/logic/smn_menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1568,15 +1568,11 @@ static cell_t InternalShowMenu(IPluginContext *pContext, const cell_t *params)

IMenuHandler *pHandler;
CPanelHandler *pActualHandler = NULL;
if (params[5] != -1)
{
IPluginFunction *pFunction = pContext->GetFunctionById(params[5]);
if (pFunction == NULL)
{
return pContext->ThrowNativeError("Invalid function index %x", params[5]);
}
pActualHandler = g_MenuHelpers.GetPanelHandler(pFunction);
}
IPluginFunction* func;
if (!pContext->GetFunctionByIdOrNull(params[5], &func))
return 0;
if (func)
pActualHandler = g_MenuHelpers.GetPanelHandler(func);

if (pActualHandler == NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion extensions/clientprefs/natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ cell_t AddSettingsPrefabMenuItem(IPluginContext *pContext, const cell_t *params)


/* User passed a function id for a callback */
if (params[4] != -1)
if (!pContext->IsNullFunctionId(params[4]))
{
pItem->forward = forwards->CreateForwardEx(NULL, ET_Ignore, 5, NULL, Param_Cell, Param_Cell, Param_Cell, Param_String, Param_Cell);
pItem->forward->AddFunction(pContext, static_cast<funcid_t>(params[4]));
Expand Down
2 changes: 1 addition & 1 deletion plugins/include/core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <version>

/** If this gets changed, you need to update Core's check. */
#define SOURCEMOD_PLUGINAPI_VERSION 6
#define SOURCEMOD_PLUGINAPI_VERSION 7

struct PlVers
{
Expand Down
6 changes: 5 additions & 1 deletion plugins/include/handles.inc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ native void CloseHandle(Handle hndl);
*/
native Handle CloneHandle(Handle hndl, Handle plugin=INVALID_HANDLE);

using __intrinsics__.Handle;
methodmap Handle __nullable__ {
public native ~Handle();

public native void Close();
};

/**
* Do not use this function. Returns if a Handle and its contents
Expand Down
2 changes: 1 addition & 1 deletion sourcepawn
Submodule sourcepawn updated 117 files