added a hacky way to get NULL references
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40944
This commit is contained in:
parent
6193ed8431
commit
6acaaac769
@ -200,7 +200,8 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late
|
||||
}
|
||||
|
||||
unsigned int api = g_pVM->GetAPIVersion();
|
||||
if (api != SOURCEPAWN_VM_API_VERSION)
|
||||
/* :TODO: clean this up (see amb398) */
|
||||
if (api > SOURCEPAWN_VM_API_VERSION || api < 2)
|
||||
{
|
||||
ShutdownJIT();
|
||||
if (error && maxlength)
|
||||
|
@ -72,6 +72,17 @@ BaseContext::BaseContext(sp_context_t *_ctx)
|
||||
} else {
|
||||
m_pub_funcs = NULL;
|
||||
}
|
||||
|
||||
/* Initialize the null references */
|
||||
uint32_t index;
|
||||
if (FindPubvarByName("NULL_VECTOR", &index) == SP_ERROR_NONE)
|
||||
{
|
||||
sp_pubvar_t *pubvar;
|
||||
GetPubvarByIndex(index, &pubvar);
|
||||
m_pNullVec = pubvar->offs;
|
||||
} else {
|
||||
m_pNullVec = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void BaseContext::FlushFunctionCache()
|
||||
@ -991,4 +1002,14 @@ void BaseContext::SetIdentity(SourceMod::IdentityToken_t *token)
|
||||
{
|
||||
m_pToken = token;
|
||||
}
|
||||
|
||||
cell_t *BaseContext::GetNullRef(SP_NULL_TYPE type)
|
||||
{
|
||||
if (type == SP_NULL_VECTOR)
|
||||
{
|
||||
return m_pNullVec;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -69,6 +69,7 @@ namespace SourcePawn
|
||||
#if defined SOURCEMOD_BUILD
|
||||
SourceMod::IdentityToken_t *GetIdentity();
|
||||
void SetIdentity(SourceMod::IdentityToken_t *token);
|
||||
cell_t *GetNullRef(SP_NULL_TYPE type);
|
||||
#endif
|
||||
public: //IPluginDebugInfo
|
||||
int LookupFile(ucell_t addr, const char **filename);
|
||||
@ -84,6 +85,7 @@ namespace SourcePawn
|
||||
sp_context_t *ctx;
|
||||
#if defined SOURCEMOD_BUILD
|
||||
SourceMod::IdentityToken_t *m_pToken;
|
||||
cell_t *m_pNullVec;
|
||||
#endif
|
||||
char m_MsgCache[1024];
|
||||
bool m_CustomMsg;
|
||||
|
@ -85,11 +85,13 @@ enum PluginInfo
|
||||
*/
|
||||
struct Extension
|
||||
{
|
||||
const String:name[], /* Short name */
|
||||
const String:file[], /* Default file name */
|
||||
bool:autoload, /* Whether or not to auto-load */
|
||||
bool:required, /* Whether or not to require */
|
||||
const String:name[], /**< Short name */
|
||||
const String:file[], /**< Default file name */
|
||||
bool:autoload, /**< Whether or not to auto-load */
|
||||
bool:required, /**< Whether or not to require */
|
||||
};
|
||||
|
||||
public Float:NULL_VECTOR[3]; /**< Pass this into certain functions to act as a C++ NULL */
|
||||
|
||||
#define AUTOLOAD_EXTENSIONS
|
||||
#define REQUIRE_EXTENSIONS
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "sp_vm_types.h"
|
||||
|
||||
/** SourcePawn VM API Version */
|
||||
#define SOURCEPAWN_VM_API_VERSION 2
|
||||
#define SOURCEPAWN_VM_API_VERSION 3
|
||||
|
||||
#if !defined SOURCEMOD_BUILD
|
||||
#define SOURCEMOD_BUILD
|
||||
@ -49,6 +49,16 @@ namespace SourcePawn
|
||||
#define SM_PARAM_STRING_UTF8 (1<<0) /**< String should be UTF-8 handled */
|
||||
#define SM_PARAM_STRING_COPY (1<<1) /**< String should be copied into the plugin */
|
||||
|
||||
#if defined SOURCEMOD_BUILD
|
||||
/**
|
||||
* @brief Pseudo-NULL reference types.
|
||||
*/
|
||||
enum SP_NULL_TYPE
|
||||
{
|
||||
SP_NULL_VECTOR = 0, /**< Float[3] reference */
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Represents what a function needs to implement in order to be callable.
|
||||
*/
|
||||
@ -536,6 +546,15 @@ namespace SourcePawn
|
||||
* @return Identity token.
|
||||
*/
|
||||
virtual SourceMod::IdentityToken_t *GetIdentity() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns a NULL reference based on one of the available NULL
|
||||
* reference types.
|
||||
*
|
||||
* @param type NULL reference type.
|
||||
* @return cell_t address to compare to.
|
||||
*/
|
||||
virtual cell_t *GetNullRef(SP_NULL_TYPE type) =0;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user