Usually the botlib give a real error before it spams the console with "bot library used before being setup". To see the error I change to a map, press ESC to pause errors, and then look back through the log. In my experience, this error happens with incorrectly formated or missing botfiles in basegame (like baseq3).
Zack "ZTurtleMan" Middleton On Mon, Feb 14, 2011 at 12:06 AM, Yasir I. Al-Dosary - zgzg2020™ < [email protected]> wrote: > Hello again, > Thank you for your reply. I will try to write a better one. > > Environment: > WindowsXP, Visual Studio 2008 professional edition. > > Background: > * Sometime ago, I asked about removing the trap_ functionality from the > program. Some of the people on this list kindly recommended me to bind the > sdk with the engine into one binary. At first, I didn't know how to do that. > But, after further investigation, it meant to mash all the files into one > project (projects are five in ioquake3- cgame, game, ui_q3, quake3, ui) > inside Visual Studio. > * I have started doing this. Now, I have moved the botlib folder (not > windows explorer one, but the visual studio one.) from quake3 to game. This > means that the botlib files (which includes the functions and variables in > those files) used to exist inside ioquake3.exe, and now they exist inside > qagamex86.dll file. > * A function called SV_BotInitBotLib() that exists inside the quake3 folder > (ioquake3.exe). This function calls to a function called GetBotLibAPI(). > GetBotLibAPI() exists inside qagamex86.dll (after my alteration). > ** Therefore, SV_BotInitBotLib() is calling to an external symbol, it is > calling to function outside ioquake.exe. > *** This is the compiling error that I have battled with the past week. > > Trialed solutions: > 1- Using __declspec(dllexport) and __declspec(dllimport): > * I have attempted to export/import this external symbol, GetBotLibAPI() > from qagamex86.dll, SV_BotInitBotLib() to ioquake3.exe. > * This has silenced the compiler. > * This also has allowed the Game to launch without any errors. > ** However, when I go into Single Game, an message in red appears > continuously in the upper part of the screen that reads "bot library used > before being setup". > ** Furthermore, I cannot add any bots to the match. > > 2- Creating a callback function of GetBotLibAPI() - My preferred solution: > * Probably the code could explain this basic concept, here is the code > snippets: > inside sv_bot.c file, inside ioquake3.exe: > func_GetBotLibAPI pGetBotLibAPI; > HMODULE hLib; > void SV_BotInitBotLib(void) { > botlib_import_t botlib_import; > //func_GetBotLibAPI pGetBotLibAPI; > /*HMODULE */hLib = LoadLibrary(TEXT("qagamex86.dll")); > > if (hLib == NULL) { > //Module not found, permission denied, ... > return; //inform caller of error > } > > pGetBotLibAPI = (func_GetBotLibAPI)GetProcAddress(hLib, > TEXT("GetBotLibAPI"));//zgzg2020 for importing a function from an external > library > if ( pGetBotLibAPI == NULL) { > //Function not found: try adding an _ to the start of the name > ErrorExit(TEXT("GetProcessId")); > return; > } > > //unchanged > //lines > //of > //code > > botlib_export = zgCBGetBotLibAPI(pGetBotLibAPI, BOTLIB_API_VERSION, > &botlib_import);//zgzg2020 > //botlib_export = (botlib_export_t *)GetBotLibAPI( BOTLIB_API_VERSION, > &botlib_import ); // the original function > assert(botlib_export); // somehow we end up with a zero import. > } > > //zgzg2020 callback function > //This function has nothing that can change at runtime, hence a call to it > can be placed inline. > //This effectively gets rid of this function and puts its code in the > calling function. (not strictly true, but a simplified explanation) > botlib_export_t *zgCBGetBotLibAPI( func_GetBotLibAPI pzgCBGetBotLibAPI, int > apiVersion, botlib_import_t *import ) { > ////We just use the function variable as we would use any other function. > return pzgCBGetBotLibAPI(apiVersion, import); > } > > //// > inside botlib.h, shared by both ioquake3.exe and qagamex86.dll: > //We need to create a data type that defines the signature of the function > GetBotLibAPI > typedef botlib_export_t *(* func_GetBotLibAPI)(int apiVersion, > botlib_import_t *import); > botlib_export_t *zgCBGetBotLibAPI( func_GetBotLibAPI pzgCBGetBotLibAPI, > int apiVersion, botlib_import_t *import ); > > //// > inside be_interface.c > #define _DLLEXPORT __declspec(dllexport)// we need to export so that this > function can be seen and be accessible from the outside of qagamex86.dll, > where it resides, from ioquake3.exe > _DLLEXPORT botlib_export_t *GetBotLibAPI(int apiVersion, botlib_import_t > *import) {//using define to avoid function name manipulations > //The code is as is, untouched. > } > > * Now that all of this is out of the way, the results. > * The Compilation is successful. > * The Game launches successfully. > * However, when I run Single Game, for example, the same error as before. > The error is: > ** However, when I go into Single Game, a message in red appears > continuously in the upper part of the screen that reads "bot library used > before being setup". > ** Furthermore, I cannot add any bots to the match. > > -This is the current situation that I am in. This is where I need help. > # Why does this message appear? > # I take the reason why I cannot add bots is because it has not been setup > yet. > * However, I have debugged the Game: > ** I ran my version of the Game, with the callback. I followed the flow of > the program up to where SV_BotInitBotLib() ends. > ** I then ran an original version of the Game, without the callback, they > both flows look the same. Furthermore, both versions of the botlib_export > variables look the exactly the same in terms of contents and shape. > (botlib_export is the variable that is retrieved from the callback function) > ** Moreover, I have attempted to perform "step-in" at the location where > callback function is called, and it successfully jumps to its location in > the be_interface.c, from ioquake3.exe to inside qagamex86.dll. > > # This is just the beginning of many changes to the program that I attempt > on doing. > # Callback functions will be the backbone of my near future work. So, I > will need to leave in there. > # The reasons for wanting to do this are very important for me, but too > difficult to explain here. Therefore, I would appreciate it if it would be > taken as such. > # Please help. How can I fix this bot library initialization problem with > the usage of callback functions. > > I hope that this explanation was not over the allowed limit. I hope it was > clear too. > > Best regards, > Yasir > > p.s. I took a look at fedora mailing list rules, I think I over explained > things. I still need practice. > > ------------------------------ > *From:* gabriel <[email protected]> > *To:* Primary ioquake3 Discussion/Development list < > [email protected]> > *Sent:* Fri, February 11, 2011 3:04:46 AM > *Subject:* Re: [ioquake3] bot library used before being setup error > > Hi, > > You don't give enough useful infos i think... sorry but i can't help a lot. > > Give a quick summary of what you wanna do and what you got/observed. > Explain the "initial condition", which version of the code, platform etc... > You can take a look to Fedora's mailing list guidelines as an example. > > And the most important, > give a diff from a baseline release. > > Code speaks for itself. > > I guess you're using a Windows platform with visual studio. > I don't know any of the softwares but if the game compiles and starts (no > segfault), > that means all the files where compiled properly and linked. > So i think, the change of directory shouldn't be incriminated. > > But i can't help more. > > Regards. > > On Thu, Feb 10, 2011 at 7:59 AM, Yasir I. Al-Dosary - zgzg2020™ < > [email protected]> wrote: > >> Hi, >> I have moved some of the files around. I moved the botlib folder from >> quake3 >> solution to game solution. >> Then, using (__declspec(dllexport) / __declspec(dllimport) ) >> exported/imported >> the function GetBotLibAPI( ) so that the exe can still access it. >> The compilation phase went without any errors. >> However, when I run the Game, the hud keeps showing "bot library used >> before >> being setup" message in red, and I cannot add any bots. >> >> I ran two Visual Studios at the same time, and ran two Game instances at >> the >> same time, one with my changes, and one original version, so that I can >> see >> where things become different. Both instances seem identical up to int >> SV_BotLibSetup( void ) function. When I do a "Quick Watch" on the variable >> botlib_export for both instances: >> The original version contains cleanly ordered addresses, and next to those >> addresses are functions, for example: >> BotLibSetup : 0x00485190 Export_BotLibSetup >> BotLibShutdown : 0x004852f0 Export_BotLibShutdown >> >> However, my edited version: >> BotLibSetup : 0x00485190 >> BotLibShutdown : 0x004852f0 >> >> Nothing is shown on the right side of the addresses. I am guessing the >> addresses >> are yet to be populated with function pointers. >> >> 1- Which of my two changes made this error? >> a. Moving botlib from quake3 to game. >> b. exporting/importing the function GetBotLibAPI(), which returns a >> export_botlib variable. >> >> 2- In both cases, any suggestions on how to fix this problem while leaving >> botlib on the game side? >> >> Thanks, >> Yasir >> >> _______________________________________________ >> ioquake3 mailing list >> [email protected] >> http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org >> By sending this message I agree to love ioquake3 and libsdl. >> > > > _______________________________________________ > ioquake3 mailing list > [email protected] > http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org > By sending this message I agree to love ioquake3 and libsdl. >
_______________________________________________ ioquake3 mailing list [email protected] http://lists.ioquake.org/listinfo.cgi/ioquake3-ioquake.org By sending this message I agree to love ioquake3 and libsdl.
