added ThrowError() a la amxmodx's abort()
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40566
This commit is contained in:
parent
9de900d3eb
commit
66b244011e
@ -681,6 +681,10 @@
|
||||
RelativePath="..\smn_console.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_core.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\smn_datapacks.cpp"
|
||||
>
|
||||
|
35
core/smn_core.cpp
Normal file
35
core/smn_core.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* ===============================================================
|
||||
* SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
|
||||
* ===============================================================
|
||||
*
|
||||
* This file is not open source and may not be copied without explicit
|
||||
* written permission of AlliedModders LLC. This file may not be redistributed
|
||||
* in whole or significant part.
|
||||
* For information, see LICENSE.txt or http://www.sourcemod.net/license.php
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "sm_globals.h"
|
||||
#include "sourcemod.h"
|
||||
|
||||
static cell_t ThrowError(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char buffer[512];
|
||||
|
||||
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 1);
|
||||
|
||||
if (pContext->GetContext()->n_err == SP_ERROR_NONE)
|
||||
{
|
||||
pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", buffer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
REGISTER_NATIVES(coreNatives)
|
||||
{
|
||||
{"ThrowError", ThrowError},
|
||||
{NULL, NULL},
|
||||
};
|
@ -31,7 +31,7 @@
|
||||
|
||||
using namespace SourcePawn;
|
||||
|
||||
#define ERROR_MESSAGE_MAX 23
|
||||
#define ERROR_MESSAGE_MAX 25
|
||||
static const char *g_ErrorMsgTable[] =
|
||||
{
|
||||
NULL,
|
||||
@ -59,6 +59,7 @@ static const char *g_ErrorMsgTable[] =
|
||||
"Maximum number of parameters reached",
|
||||
"Native detected error",
|
||||
"Plugin not runnable",
|
||||
"Call was aborted",
|
||||
};
|
||||
|
||||
SourcePawnEngine::SourcePawnEngine()
|
||||
|
@ -37,7 +37,6 @@ struct Plugin
|
||||
#include <bitbuffer>
|
||||
#include <sorting>
|
||||
#include <clients>
|
||||
#include <entity>
|
||||
|
||||
/**
|
||||
* Declare this as a struct in your plugin to expose its information.
|
||||
@ -106,6 +105,18 @@ forward OnGameFrame();
|
||||
*/
|
||||
native Handle:GetMyHandle();
|
||||
|
||||
|
||||
/**
|
||||
* Aborts the current callback and throws an error. This function
|
||||
* does not return in that no code is executed following it.
|
||||
*
|
||||
* @param format String format.
|
||||
* @param ... Format arguments.
|
||||
* @noreturn
|
||||
* @error Always!
|
||||
*/
|
||||
native ThrowError(const String:fmt[], {Handle,Float,String,_}:...);
|
||||
|
||||
/**
|
||||
* Logs a generic message to the HL2 logs.
|
||||
*
|
||||
@ -210,3 +221,4 @@ native GetCurrentMap(String:buffer[], maxlength);
|
||||
|
||||
#include <usermessages>
|
||||
#include <helpers>
|
||||
#include <entity>
|
||||
|
@ -62,6 +62,7 @@ typedef uint32_t funcid_t; /**< Function index code */
|
||||
#define SP_ERROR_PARAMS_MAX 22 /**< Maximum number of parameters reached */
|
||||
#define SP_ERROR_NATIVE 23 /**< Error originates from a native */
|
||||
#define SP_ERROR_NOT_RUNNABLE 24 /**< Function or plugin is not runnable */
|
||||
#define SP_ERROR_ABORTED 25 /**< Function call was aborted */
|
||||
//Hey you! Update the string table if you add to the end of me! */
|
||||
|
||||
/**********************************************
|
||||
|
Loading…
Reference in New Issue
Block a user