.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Problem with the sounds in AMX (http://forums.bots-united.com/showthread.php?t=4020)

The Storm 26-05-2005 19:40

Problem with the sounds in AMX
 
Ok since many people have reported that after they install E[POD]bot the AMX sounds and some menues are disabled, I start to looking for a way to fix that. So I try the old version of RACC that too load metamod and there is no problem with it, all sounds and menues are in place but when E[POD]bot load metamod the sounds and some menues are gone. So I start to think that is from the GiveFnptrsToDll() function but I can't understand where I wrong. If you can help me? Here the function :

Code:

void WINAPI GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
{

  // get the engine functions from the engine...
  memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
  gpGlobals = pGlobals;

#ifndef __linux__
        // This is the new metamod support.
        // metamod.dll will be loaded instead of mp.dll if it exists.
        // Metamod then will run and load mp.dll, the normal CS-Game-DLL
 
        // It has to be in "default" folder "addons/metamod/dlls/metamod.dll"
       
        // see if metamod exists

  if (FileExists (METAMOD_DLL)) //if it exists, load metamod as game DLL (it will load the cs game dll for us)
          h_Library = LoadLibrary (METAMOD_DLL);// if so, load the metamod DLL
  else //else load normal CS-DLL
          h_Library = LoadLibrary (CS_DLL); // else, load the official game DLL
#else
  h_Library = dlopen("cstrike/dlls/cs_i386.so", RTLD_NOW);
#endif

  if (!h_Library)
  {
        // Directory error or Unsupported MOD!
                ALERT( at_error, "E[POD]bot couldn't find the CounterStrike DLL!" );
                fp=fopen("PODERROR.txt","a"); fprintf(fp, "E[POD]bot couldn't find the CounterStrike DLL!\n"); fclose(fp);
  }


#ifndef __linux__
  h_global_argv = GlobalAlloc(GMEM_SHARE, 1024);
  g_argv = (char *)GlobalLock(h_global_argv);
#else
  g_argv = (char *)h_global_argv;
#endif

  other_GetEntityAPI = (GETENTITYAPI)GetProcAddress(h_Library, "GetEntityAPI");
  other_GetNewDLLFunctions = (GETNEWDLLFUNCTIONS)GetProcAddress(h_Library, "GetNewDLLFunctions");
  other_GiveFnptrsToDll = (GIVEFNPTRSTODLL)GetProcAddress(h_Library, "GiveFnptrsToDll");

#ifdef _WIN32
  LoadSymbols (CS_DLL);  // Load exported symbol table
  pengfuncsFromEngine->pfnFunctionFromName = pfnFunctionFromName;
  pengfuncsFromEngine->pfnNameForFunction = pfnNameForFunction;
#endif

// for engine testing
  pengfuncsFromEngine->pfnCmd_Args = pfnCmd_Args;
  pengfuncsFromEngine->pfnCmd_Argv = pfnCmd_Argv;
  pengfuncsFromEngine->pfnCmd_Argc = pfnCmd_Argc;
  pengfuncsFromEngine->pfnPrecacheModel = pfnPrecacheModel;
  pengfuncsFromEngine->pfnPrecacheSound = pfnPrecacheSound;
  pengfuncsFromEngine->pfnSetModel = pfnSetModel;
  pengfuncsFromEngine->pfnModelIndex = pfnModelIndex;
  pengfuncsFromEngine->pfnModelFrames = pfnModelFrames;
  pengfuncsFromEngine->pfnSetSize = pfnSetSize;
  pengfuncsFromEngine->pfnChangeLevel = pfnChangeLevel;
  pengfuncsFromEngine->pfnGetSpawnParms = pfnGetSpawnParms;
  pengfuncsFromEngine->pfnSaveSpawnParms = pfnSaveSpawnParms;
  pengfuncsFromEngine->pfnVecToYaw = pfnVecToYaw;
  pengfuncsFromEngine->pfnVecToAngles = pfnVecToAngles;
  pengfuncsFromEngine->pfnMoveToOrigin = pfnMoveToOrigin;
  pengfuncsFromEngine->pfnChangeYaw = pfnChangeYaw;
  pengfuncsFromEngine->pfnChangePitch = pfnChangePitch;
  pengfuncsFromEngine->pfnFindEntityByString = pfnFindEntityByString;
  pengfuncsFromEngine->pfnGetEntityIllum = pfnGetEntityIllum;
  pengfuncsFromEngine->pfnFindEntityInSphere = pfnFindEntityInSphere;
  pengfuncsFromEngine->pfnFindClientInPVS = pfnFindClientInPVS;
  pengfuncsFromEngine->pfnEntitiesInPVS = pfnEntitiesInPVS;
  pengfuncsFromEngine->pfnMakeVectors = pfnMakeVectors;
  pengfuncsFromEngine->pfnAngleVectors = pfnAngleVectors;
  pengfuncsFromEngine->pfnCreateEntity = pfnCreateEntity;
  pengfuncsFromEngine->pfnRemoveEntity = pfnRemoveEntity;
  pengfuncsFromEngine->pfnCreateNamedEntity = pfnCreateNamedEntity;
  pengfuncsFromEngine->pfnMakeStatic = pfnMakeStatic;
  pengfuncsFromEngine->pfnEntIsOnFloor = pfnEntIsOnFloor;
  pengfuncsFromEngine->pfnDropToFloor = pfnDropToFloor;
  pengfuncsFromEngine->pfnWalkMove = pfnWalkMove;
  pengfuncsFromEngine->pfnSetOrigin = pfnSetOrigin;
  pengfuncsFromEngine->pfnEmitSound = pfnEmitSound;
  pengfuncsFromEngine->pfnEmitAmbientSound = pfnEmitAmbientSound;
  pengfuncsFromEngine->pfnTraceLine = pfnTraceLine;
  pengfuncsFromEngine->pfnTraceToss = pfnTraceToss;
  pengfuncsFromEngine->pfnTraceMonsterHull = pfnTraceMonsterHull;
  pengfuncsFromEngine->pfnTraceHull = pfnTraceHull;
  pengfuncsFromEngine->pfnTraceModel = pfnTraceModel;
  pengfuncsFromEngine->pfnTraceTexture = pfnTraceTexture;
  pengfuncsFromEngine->pfnTraceSphere = pfnTraceSphere;
  pengfuncsFromEngine->pfnGetAimVector = pfnGetAimVector;
  pengfuncsFromEngine->pfnServerCommand = pfnServerCommand;
  pengfuncsFromEngine->pfnServerExecute = pfnServerExecute;
  pengfuncsFromEngine->pfnClientCommand = pfnClientCommand;
  pengfuncsFromEngine->pfnParticleEffect = pfnParticleEffect;
  pengfuncsFromEngine->pfnLightStyle = pfnLightStyle;
  pengfuncsFromEngine->pfnDecalIndex = pfnDecalIndex;
  pengfuncsFromEngine->pfnPointContents = pfnPointContents;
  pengfuncsFromEngine->pfnMessageBegin = pfnMessageBegin;
  pengfuncsFromEngine->pfnMessageEnd = pfnMessageEnd;
  pengfuncsFromEngine->pfnWriteByte = pfnWriteByte;
  pengfuncsFromEngine->pfnWriteChar = pfnWriteChar;
  pengfuncsFromEngine->pfnWriteShort = pfnWriteShort;
  pengfuncsFromEngine->pfnWriteLong = pfnWriteLong;
  pengfuncsFromEngine->pfnWriteAngle = pfnWriteAngle;
  pengfuncsFromEngine->pfnWriteCoord = pfnWriteCoord;
  pengfuncsFromEngine->pfnWriteString = pfnWriteString;
  pengfuncsFromEngine->pfnWriteEntity = pfnWriteEntity;
  pengfuncsFromEngine->pfnCVarRegister = pfnCVarRegister;
  pengfuncsFromEngine->pfnCVarGetFloat = pfnCVarGetFloat;
  pengfuncsFromEngine->pfnCVarGetString = pfnCVarGetString;
  pengfuncsFromEngine->pfnCVarSetFloat = pfnCVarSetFloat;
  pengfuncsFromEngine->pfnCVarSetString = pfnCVarSetString;
  pengfuncsFromEngine->pfnPvAllocEntPrivateData = pfnPvAllocEntPrivateData;
  pengfuncsFromEngine->pfnPvEntPrivateData = pfnPvEntPrivateData;
  pengfuncsFromEngine->pfnFreeEntPrivateData = pfnFreeEntPrivateData;
  pengfuncsFromEngine->pfnSzFromIndex = pfnSzFromIndex;
  pengfuncsFromEngine->pfnAllocString = pfnAllocString;
  pengfuncsFromEngine->pfnGetVarsOfEnt = pfnGetVarsOfEnt;
  pengfuncsFromEngine->pfnPEntityOfEntOffset = pfnPEntityOfEntOffset;
  pengfuncsFromEngine->pfnEntOffsetOfPEntity = pfnEntOffsetOfPEntity;
  pengfuncsFromEngine->pfnIndexOfEdict = pfnIndexOfEdict;
  pengfuncsFromEngine->pfnPEntityOfEntIndex = pfnPEntityOfEntIndex;
  pengfuncsFromEngine->pfnFindEntityByVars = pfnFindEntityByVars;
  pengfuncsFromEngine->pfnGetModelPtr = pfnGetModelPtr;
  pengfuncsFromEngine->pfnRegUserMsg = pfnRegUserMsg;
  pengfuncsFromEngine->pfnAnimationAutomove = pfnAnimationAutomove;
  pengfuncsFromEngine->pfnGetBonePosition = pfnGetBonePosition;
  pengfuncsFromEngine->pfnClientPrintf = pfnClientPrintf;
  pengfuncsFromEngine->pfnServerPrint = pfnServerPrint;
  pengfuncsFromEngine->pfnGetAttachment = pfnGetAttachment;
  pengfuncsFromEngine->pfnCRC32_Init = pfnCRC32_Init;
  pengfuncsFromEngine->pfnCRC32_ProcessBuffer = pfnCRC32_ProcessBuffer;
  pengfuncsFromEngine->pfnCRC32_ProcessByte = pfnCRC32_ProcessByte;
  pengfuncsFromEngine->pfnCRC32_Final = pfnCRC32_Final;
  pengfuncsFromEngine->pfnRandomLong = pfnRandomLong;
  pengfuncsFromEngine->pfnRandomFloat = pfnRandomFloat;
  pengfuncsFromEngine->pfnSetView = pfnSetView;
  pengfuncsFromEngine->pfnTime = pfnTime;
  pengfuncsFromEngine->pfnCrosshairAngle = pfnCrosshairAngle;
  pengfuncsFromEngine->pfnLoadFileForMe = pfnLoadFileForMe;
  pengfuncsFromEngine->pfnFreeFile = pfnFreeFile;
  pengfuncsFromEngine->pfnEndSection = pfnEndSection;
  pengfuncsFromEngine->pfnCompareFileTime = pfnCompareFileTime;
  pengfuncsFromEngine->pfnGetGameDir = pfnGetGameDir;
  pengfuncsFromEngine->pfnCvar_RegisterVariable = pfnCvar_RegisterVariable;
  pengfuncsFromEngine->pfnFadeClientVolume = pfnFadeClientVolume;
  pengfuncsFromEngine->pfnSetClientMaxspeed = pfnSetClientMaxspeed;
  pengfuncsFromEngine->pfnCreateFakeClient = pfnCreateFakeClient;
  pengfuncsFromEngine->pfnRunPlayerMove = pfnRunPlayerMove;
  pengfuncsFromEngine->pfnNumberOfEntities = pfnNumberOfEntities;
  pengfuncsFromEngine->pfnGetInfoKeyBuffer = pfnGetInfoKeyBuffer;
  pengfuncsFromEngine->pfnInfoKeyValue = pfnInfoKeyValue;
  pengfuncsFromEngine->pfnSetKeyValue = pfnSetKeyValue;
  pengfuncsFromEngine->pfnSetClientKeyValue = pfnSetClientKeyValue;
  pengfuncsFromEngine->pfnIsMapValid = pfnIsMapValid;
  pengfuncsFromEngine->pfnStaticDecal = pfnStaticDecal;
  pengfuncsFromEngine->pfnPrecacheGeneric = pfnPrecacheGeneric;
  pengfuncsFromEngine->pfnGetPlayerUserId = pfnGetPlayerUserId;
  pengfuncsFromEngine->pfnBuildSoundMsg = pfnBuildSoundMsg;
  pengfuncsFromEngine->pfnIsDedicatedServer = pfnIsDedicatedServer;
  pengfuncsFromEngine->pfnCVarGetPointer = pfnCVarGetPointer;
  pengfuncsFromEngine->pfnGetPlayerWONId = pfnGetPlayerWONId;
// end engine testing

  // give the engine functions to the other DLL...
  (*other_GiveFnptrsToDll)(pengfuncsFromEngine, pGlobals);
}


KWo 26-05-2005 20:22

Re: Problem with the sounds in AMX
 
I guess it's probably corresponding to some known issue with confusing AMX by bots (no stats, no admin rights, player "seen" by AMX as just kicked bot etc).

http://forums.bots-united.com/showpo...5&postcount=16

http://djeyl.net/forum/index.php?showtopic=39787

The people of AMX Dev Team know this and they are still working for the new release of AMX including this fix. sPlOrYgOn helped them in solving this problem, but still there is not any new official release of AMX since 08.2004 (when the problem has been solved).
AMX Mod X team released few version of his mod and this fix has been included since the version 0.20 (currently 1.01).

[EDIT]
I forgot to say - there is already availiable some beta version with this bot fix, but only for linux (0.9.9b).
http://djeyl.net/forum/index.php?showtopic=41122
[/EDIT]

Pierre-Marie Baty 26-05-2005 21:28

Re: Problem with the sounds in AMX
 
No, that's because you don't tie all the functions in pEngFuncsFromEngine :)

The engine interface and the game DLL interface have changed A LOT since the date when POD-bot was released.

You should switch to a full metamod plugin this time. Take the step, it's worth it.

The Storm 26-05-2005 21:43

Re: Problem with the sounds in AMX
 
I want to make E[POD]bot a real metamod plugin but LightNinja don't want E[POD]bot to be open source. Before a week I send again a mail to him to ask if I can publish the source but still not reply. :( But maybe there is anoder reason that LightNinja don't allow me to publish the code. When I get this code and after I start to understand it, I actually see that LightNinja is ripped a bit stuff from other bots and maybe he don't want to show that. :(:(:( I don't know but if he don't reply of my mails after 2 week I will make E[POD]bot metamod plugin and open source. ;)

Thanks for the help PMB. :)

Lazy 26-05-2005 23:49

Re: Problem with the sounds in AMX
 
You can support metamod and standalone loading methods in the same dll, its alot of work but can be done...

- Export Meta_Init and set a global variable saying that we are being loaded by metamod
- Modify RETURN_META and RETURN_META_VALUE macros or make your own to handle both metamod and the standalone method at the same time.

Its fairly easy to do and lots of people have done it already, if I remember correctly the NeoTF team, FoxBot, TheFlipside of TFC, and I have done metamod/standalone compatible dlls.

Whistler 27-05-2005 12:37

Re: Problem with the sounds in AMX
 
Quote:

Originally Posted by Pierre-Marie Baty
No, that's because you don't tie all the functions in pEngFuncsFromEngine :)

The engine interface and the game DLL interface have changed A LOT since the date when POD-bot was released.

that isn't necessary, as if you don't tie one function in pengFuncsFromEngine, the "original" address of a engine function (passed from engine to the bot dll) will just be passed to the game dll.

I only tied 2-3 functions in the Realbot 1.0 fix, and it also works well and doesn't crash.

Pierre-Marie Baty 28-05-2005 03:02

Re: Problem with the sounds in AMX
 
You are wrong. This cannot happen in a hook DLL since it is the Hook DLL that is in charge of doing the interface exchange.

Lazy 28-05-2005 03:27

Re: Problem with the sounds in AMX
 
I think he means is:
Make a enginefuncs_t variable...
memcpy the engine functions into it...
variable.pfnXXX = ourhookedfunc...
mod_givefnptrstodll( &variable, pGlobals );

That way should make it so you don't need to hook __every__ function.
Or maybe I'm wayyyyy off?

Whistler 28-05-2005 06:56

Re: Problem with the sounds in AMX
 
nah...

suppose this is what's passed in the parameter "pengfuncsFromEngine" to the bot dll:

note: for simplification, let's suppose the enginefuncs_t only contains pfnFunc1, pfnFunc2, pfnFunc3:

PHP Code:

pfnFunc1          pfnFunc2          pfnFunc3
ENGINE_func1      ENGINE_func1      ENGINE_func3 

ENGINE_func* means the address of functions in the original engine, so that gamedll can call it

then if you do this...

pengfuncsFromEngine->pfnFunc1 = bot_func1;
pengfuncsFromEngine->pfnFunc2 = bot_func2;
pengfuncsFromEngine->pfnFunc3 = bot_func3;

this will be passed into the original game dll:

PHP Code:

pfnFunc1          pfnFunc2          pfnFunc3
bot_func1         bot_func2         bot_func3 

...and just like what HPB bot does, bot_func1 will call the ENGINE_func1

but if you do this...

pengfuncsFromEngine->pfnFunc1 = bot_func1;

and leave the pfnFunc2, pfnFunc3 untouched. We'll get result like this:

PHP Code:

pfnFunc1          pfnFunc2         pfnFunc3
bot_func1         ENGINE_func2     ENGINE_func3 

...and now, this will be passed into the original gamedll and the gamedll can still call the ENGINE_func2 directly using g_engfuncs.pfnFunc2().

you can just choose not to "hijack" a certain engine function in the game dll, and it will be okay. No need to "hijack" every functions.

Lazy 28-05-2005 07:09

Re: Problem with the sounds in AMX
 
Thats MUCH simpler, thx for pointing that out.


All times are GMT +2. The time now is 12:07.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.