mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-20 13:54:14 +01:00
vafmt fixes
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40563
This commit is contained in:
parent
4ce4e008cc
commit
92ade58dc2
@ -1014,7 +1014,8 @@ SourceHook::CallClass<T> *SH_GET_CALLCLASS(T *p)
|
||||
char buf[::SourceHook::STRBUF_LEN]; \
|
||||
va_list ap; \
|
||||
va_start(ap, fmt); \
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap); \
|
||||
vsnprintf(buf, sizeof(buf) - 1, fmt, ap); \
|
||||
buf[sizeof(buf) - 1] = 0; \
|
||||
va_end(ap);
|
||||
|
||||
|
||||
|
@ -1014,7 +1014,8 @@ SourceHook::CallClass<T> *SH_GET_CALLCLASS(T *p)
|
||||
char buf[::SourceHook::STRBUF_LEN]; \
|
||||
va_list ap; \
|
||||
va_start(ap, fmt); \
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap); \
|
||||
vsnprintf(buf, sizeof(buf) - 1, fmt, ap); \
|
||||
buf[sizeof(buf) - 1] = 0; \
|
||||
va_end(ap);
|
||||
|
||||
@[$1,0,$a:
|
||||
@ -1131,9 +1132,9 @@ SourceHook::CallClass<T> *SH_GET_CALLCLASS(T *p)
|
||||
|
||||
#define SH_DECL_MANUALEXTERN$1(hookname, rettype@[$2,1,$1:, param$2@]) \
|
||||
int __SourceHook_FHMAdd##hookname(void *iface, ::SourceHook::ISourceHook::AddHookMode mode, bool post, \
|
||||
fastdelegate::FastDelegate$1<@[$2,1,$1|, :param$2@]@[$1!=0:, @]rettype> handler); \
|
||||
fastdelegate::FastDelegate$1<@[$2,1,$1:param$2, @]rettype> handler); \
|
||||
bool __SourceHook_FHMRemove##hookname(void *iface, bool post, \
|
||||
fastdelegate::FastDelegate$1<@[$2,1,$1|, :param$2@]@[$1!=0:, @]rettype> handler); \
|
||||
fastdelegate::FastDelegate$1<@[$2,1,$1:param$2, @]rettype> handler); \
|
||||
rettype(::SourceHook::EmptyClass::* __SoureceHook_FHM_GetRecallMFP##hookname(::SourceHook::EmptyClass *thisptr) )(@[$2,1,$1|, :param$2@]); \
|
||||
SourceHook::ExecutableClass$1<SourceHook::EmptyClass, rettype(::SourceHook::EmptyClass::*)(@[$2,1,$1|, :param$2@]), rettype@[$2,1,$1:, param$2@]> __SoureceHook_FHM_SHCall##hookname(void *ptr); \
|
||||
void __SoureceHook_FHM_SetOverrideResult##hookname(::SourceHook::ISourceHook *shptr, rettype res); \
|
||||
|
@ -1014,7 +1014,8 @@ SourceHook::CallClass<T> *SH_GET_CALLCLASS(T *p)
|
||||
char buf[::SourceHook::STRBUF_LEN]; \
|
||||
va_list ap; \
|
||||
va_start(ap, fmt); \
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap); \
|
||||
vsnprintf(buf, sizeof(buf) - 1, fmt, ap); \
|
||||
buf[sizeof(buf) - 1] = 0; \
|
||||
va_end(ap);
|
||||
|
||||
|
||||
|
@ -33,8 +33,9 @@ namespace
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
char buffer[512];
|
||||
vsprintf(buffer, fmt, ap);
|
||||
char buffer[9999];
|
||||
vsnprintf(buffer, 9998, fmt, ap);
|
||||
buffer[9998] = 0;
|
||||
va_end(ap);
|
||||
ADD_STATE(State_Vafmt_Called(1, std::string(buffer)));
|
||||
}
|
||||
@ -42,8 +43,9 @@ namespace
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
char buffer[512];
|
||||
vsprintf(buffer, fmt, ap);
|
||||
char buffer[9999];
|
||||
vsnprintf(buffer, 9998, fmt, ap);
|
||||
buffer[9998] = 0;
|
||||
va_end(ap);
|
||||
ADD_STATE(State_Vafmt_Called(2, std::string(buffer)));
|
||||
return 0.0f;
|
||||
@ -165,6 +167,29 @@ bool TestVafmtAndOverload(std::string &error)
|
||||
new State_Vafmt_PostHandler_Called(2, std::string("Hello BA1LOPAN")),
|
||||
NULL), "Part 3");
|
||||
|
||||
|
||||
// Check LARGE stuff
|
||||
char tmpbuf[501];
|
||||
for (int i = 0; i < 500; ++i)
|
||||
tmpbuf[i] = (i % 10) + '0';
|
||||
tmpbuf[500] = 0;
|
||||
|
||||
pGab->Vafmt2("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
||||
tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf,
|
||||
tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf, tmpbuf);
|
||||
|
||||
char refbuf[SourceHook::STRBUF_LEN];
|
||||
for (int i = 0; i < (SourceHook::STRBUF_LEN - 1); ++i)
|
||||
refbuf[i] = (i % 10) + '0';
|
||||
refbuf[SourceHook::STRBUF_LEN - 1] = 0;
|
||||
|
||||
CHECK_STATES((&g_States,
|
||||
new State_Vafmt_PreHandler_Called(2, std::string(refbuf)),
|
||||
new State_Vafmt_Called(2, std::string(refbuf)),
|
||||
new State_Vafmt_PostHandler_Called(2, std::string(refbuf)),
|
||||
NULL
|
||||
), "Part 3.1");
|
||||
|
||||
// Part 4
|
||||
SH_REMOVE_HOOK_ID(h1);
|
||||
SH_REMOVE_HOOK_ID(h2);
|
||||
|
@ -86,6 +86,14 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok && g_Verbose)
|
||||
{
|
||||
std::cout << std::endl << "FAIL: Should be:" << std::endl;
|
||||
DumpStates(&requiredstates);
|
||||
std::cout << std::endl << "FAIL: Is:" << std::endl;
|
||||
DumpStates(sl);
|
||||
}
|
||||
|
||||
for (StateList::iterator iter = requiredstates.begin(); iter != requiredstates.end(); ++iter)
|
||||
delete *iter;
|
||||
for (StateList::iterator iter = sl->begin(); iter != sl->end(); ++iter)
|
||||
|
Loading…
x
Reference in New Issue
Block a user