added ability to use NULL_STRING in KeyValues natives

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401006
This commit is contained in:
David Anderson
2007-06-22 14:59:26 +00:00
parent 102fa64a77
commit 3e88c91ad2
6 changed files with 59 additions and 21 deletions
+25
View File
@@ -83,6 +83,15 @@ BaseContext::BaseContext(sp_context_t *_ctx)
} else {
m_pNullVec = NULL;
}
if (FindPubvarByName("NULL_STRING", &index) == SP_ERROR_NONE)
{
sp_pubvar_t *pubvar;
GetPubvarByIndex(index, &pubvar);
m_pNullString = pubvar->offs;
} else {
m_pNullString = NULL;
}
}
void BaseContext::FlushFunctionCache()
@@ -992,6 +1001,22 @@ IPluginFunction *BaseContext::GetFunctionByName(const char *public_name)
return pFunc;
}
int BaseContext::LocalToStringNULL(cell_t local_addr, char **addr)
{
int err;
if ((err = LocalToString(local_addr, addr)) != SP_ERROR_NONE)
{
return err;
}
if ((cell_t *)*addr == m_pNullString)
{
*addr = NULL;
}
return SP_ERROR_NONE;
}
#if defined SOURCEMOD_BUILD
SourceMod::IdentityToken_t *BaseContext::GetIdentity()
{
+2
View File
@@ -70,6 +70,7 @@ namespace SourcePawn
SourceMod::IdentityToken_t *GetIdentity();
void SetIdentity(SourceMod::IdentityToken_t *token);
cell_t *GetNullRef(SP_NULL_TYPE type);
int LocalToStringNULL(cell_t local_addr, char **addr);
#endif
public: //IPluginDebugInfo
int LookupFile(ucell_t addr, const char **filename);
@@ -86,6 +87,7 @@ namespace SourcePawn
#if defined SOURCEMOD_BUILD
SourceMod::IdentityToken_t *m_pToken;
cell_t *m_pNullVec;
cell_t *m_pNullString;
#endif
char m_MsgCache[1024];
bool m_CustomMsg;