1.1 --- a/loader/serverplugin.cpp Thu Jul 22 17:42:01 2010 -0500
1.2 +++ b/loader/serverplugin.cpp Tue Jul 27 04:26:14 2010 -0500
1.3 @@ -101,11 +101,14 @@
1.4 mm_LogFatal("Could not detect engine version");
1.5 return false;
1.6 }
1.7 - else if (mm_backend >= MMBackend_Episode2)
1.8 +
1.9 + void **this_vtable;
1.10 + this_vtable = (void **)*(void **)this;
1.11 +
1.12 + if (mm_backend >= MMBackend_Episode2)
1.13 {
1.14 /* We need to insert the right type of call into this vtable */
1.15 void **vtable_src;
1.16 - void **vtable_dest;
1.17 IRandomThings sample;
1.18 SourceHook::MemFuncInfo mfp_dest, mfp_src;
1.19
1.20 @@ -123,31 +126,36 @@
1.21 assert(mfp_src.vtbloffs == 0);
1.22
1.23 vtable_src = (void **)*(void **)&sample;
1.24 - vtable_dest = (void **)*(void **)this;
1.25 - SourceHook::SetMemAccess(&vtable_dest[mfp_dest.vtblindex],
1.26 + SourceHook::SetMemAccess(&this_vtable[mfp_dest.vtblindex],
1.27 sizeof(void*),
1.28 SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC);
1.29 - vtable_dest[mfp_dest.vtblindex] = vtable_src[mfp_src.vtblindex];
1.30 + this_vtable[mfp_dest.vtblindex] = vtable_src[mfp_src.vtblindex];
1.31 + }
1.32
1.33 - /* AS engine inserted ClientFullyConnect into the vtable, so move entries up on older engines */
1.34 - if (mm_backend != MMBackend_AlienSwarm)
1.35 - {
1.36 - SourceHook::MemFuncInfo mfp_fconnect;
1.37 - mfp_fconnect.isVirtual = false;
1.38 +#ifdef _WIN32
1.39 + /* AS inserted ClientFullyConnect into vtable, so move entries up on older engines */
1.40 + if (mm_backend != MMBackend_AlienSwarm)
1.41 + {
1.42 + SourceHook::MemFuncInfo mfp_fconnect;
1.43 + mfp_fconnect.isVirtual = false;
1.44
1.45 - SourceHook::GetFuncInfo(&ServerPlugin::ClientFullyConnect, mfp_fconnect);
1.46 + SourceHook::GetFuncInfo(&ServerPlugin::ClientFullyConnect, mfp_fconnect);
1.47
1.48 - assert(mfp_fconnect.isVirtual);
1.49 - assert(mfp_fconnect.thisptroffs == 0);
1.50 - assert(mfp_fconnect.vtbloffs == 0);
1.51 + assert(mfp_fconnect.isVirtual);
1.52 + assert(mfp_fconnect.thisptroffs == 0);
1.53 + assert(mfp_fconnect.vtbloffs == 0);
1.54
1.55 - /* Shifting ClientDisconnect through OnQueryCvarValueFinished up into slot for ClientFullyConnect (8 entries) */
1.56 - SourceHook::SetMemAccess(&vtable_dest[mfp_fconnect.vtblindex],
1.57 - sizeof(void *) * 8,
1.58 - SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC);
1.59 - memmove(&vtable_dest[mfp_fconnect.vtblindex], &vtable_dest[mfp_fconnect.vtblindex + 1], sizeof(void *) * 8);
1.60 - }
1.61 + /* Shifting ClientDisconnect through OnQueryCvarValueFinished up into slot for
1.62 + * ClientFullyConnect (8 entries)
1.63 + */
1.64 + SourceHook::SetMemAccess(&this_vtable[mfp_fconnect.vtblindex],
1.65 + sizeof(void *) * 8,
1.66 + SH_MEM_READ|SH_MEM_WRITE|SH_MEM_EXEC);
1.67 + memmove(&this_vtable[mfp_fconnect.vtblindex],
1.68 + &this_vtable[mfp_fconnect.vtblindex + 1],
1.69 + sizeof(void *) * 8);
1.70 }
1.71 +#endif
1.72
1.73 char error[255];
1.74 if (gamedll_bridge == NULL)
1.75 @@ -232,9 +240,11 @@
1.76 virtual void ClientActive(edict_t *pEntity)
1.77 {
1.78 }
1.79 +#ifdef _WIN32
1.80 virtual void ClientFullyConnect(edict_t *pEntity)
1.81 {
1.82 }
1.83 +#endif
1.84 virtual void ClientDisconnect(edict_t *pEntity)
1.85 {
1.86 }