Thread: hey stefan...
View Single Post
Re: hey stefan...
Old
  (#13)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: hey stefan... - 30-05-2004

Code:
C_DLLEXPORT int
GetEntityAPI2 (DLL_FUNCTIONS * pFunctionTable, int *interfaceVersion)
{
  gFunctionTable.pfnGameInit = GameDLLInit;
  gFunctionTable.pfnSpawn = Spawn;
  gFunctionTable.pfnClientConnect = ClientConnect;
  gFunctionTable.pfnClientDisconnect = ClientDisconnect;
  gFunctionTable.pfnClientPutInServer = ClientPutInServer;
  gFunctionTable.pfnClientCommand = ClientCommand;
  gFunctionTable.pfnStartFrame = StartFrame;
  memcpy (pFunctionTable, &gFunctionTable, sizeof (DLL_FUNCTIONS));
  return (TRUE);
}

C_DLLEXPORT int
GetEntityAPI2_Post (DLL_FUNCTIONS * pFunctionTable, int *interfaceVersion)
{
  gFunctionTable.pfnGameInit = GameDLLInit;  
  gFunctionTable.pfnSpawn = Spawn_Post;
  gFunctionTable.pfnClientConnect = ClientConnect;
  gFunctionTable.pfnClientDisconnect = ClientDisconnect;
  gFunctionTable.pfnClientPutInServer = ClientPutInServer;
  gFunctionTable.pfnClientCommand = ClientCommand;
  gFunctionTable.pfnStartFrame = StartFrame;
  memcpy (pFunctionTable, &gFunctionTable, sizeof (DLL_FUNCTIONS));
  return (TRUE);
}
...looks like you don't know what these two functions mean.
The hooks in GetEntityAPI2 are called *BEFORE* the real gamedll funcs get called, and those in GetEntityAPI2_Post are called *AFTER* the real gamedll funcs get called. So in this way all of YOUR functions in the plugin are called _twice_ when one of the gamedll funcs gets called by engine.

So the GetEntityAPI2_Post should be only like this:
Code:
C_DLLEXPORT int
GetEntityAPI2_Post (DLL_FUNCTIONS * pFunctionTable, int *interfaceVersion)
{
  gFunctionTable_post.pfnSpawn = Spawn_Post; // need to declare another gFunctionTable_post in the top of the dll.cpp file
  memcpy (pFunctionTable, &gFunctionTable, sizeof (DLL_FUNCTIONS));
  return (TRUE);
}

Last edited by Whistler; 30-05-2004 at 03:45..
  
Reply With Quote