Fixed problem on OBV where alternately loaded plugins (CreateInterface_MMS) could be incorrectly told they were on the OB engine (
bug 4491, r=dvander).
This only happened when there was more than one plugin that loaded this way. And the first plugin to load had to fail on OBV first so that OB could be tried. It was being permanently set to OB for future plugin loads and this caused problems.
2 #include "sourcehook.h"
3 #include "sourcehook_test.h"
4 #include "testevents.h"
6 // This should probably be done the other way round!
7 #if SH_XP == SH_XP_POSIX
8 #define _snprintf snprintf
13 SourceHook::ISourceHook *g_SHPtr;
14 SourceHook::Plugin g_PLID;
16 unsigned int g_callcount[10];
21 VMultiTest(unsigned int index) : m_idx(index)
25 virtual void HookTarget()
30 g_callcount[this->m_idx]++;
38 VMultiTest *pv = META_IFACEPTR(VMultiTest);
42 SH_DECL_HOOK0_void(VMultiTest, HookTarget, SH_NOATTRIB, false);
45 bool TestMulti(std::string &error)
50 VMultiTest **pv = new VMultiTest *[10];
51 for (unsigned int i=0; i<10; i++)
52 pv[i] = new VMultiTest(i);
55 for (unsigned int i=0; i<10; i++)
56 SH_ADD_HOOK(VMultiTest, HookTarget, pv[i], SH_STATIC(HookFunction), false);
60 if (g_callcount[0] != 1)
62 error.assign("g_callcount[0] != 0");
66 for (unsigned int i=1; i<10; i++)
70 error.assign("g_callcount[n] != 0");
75 SH_REMOVE_HOOK(VMultiTest, HookTarget, pv[0], SH_STATIC(HookFunction), false);
77 for (unsigned int i=1; i<10; i++)
80 if (g_callcount[0] != 1)
82 error.assign("g_callcount[0] != 0");
86 for (unsigned int i=1; i<10; i++)
88 if (g_callcount[i] != 1)
91 _snprintf(err, sizeof(err)-1, "g_callcount[%d] != 1", i);
97 for (unsigned int i=0; i<10; i++)
99 SH_REMOVE_HOOK(VMultiTest, HookTarget, pv[1], SH_STATIC(HookFunction), false);