.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Guide : Exporting functions in Half-life mods (http://forums.bots-united.com/showthread.php?t=2570)

koraX 30-08-2004 21:30

Guide : Exporting functions in Half-life mods
 
Read it here : Guide : Exporting functions in Half-life mods

This document deals with strange declaration of GiveFnptrsToDll()
and various macros and function keywords used in HL SDK, Metamod and most of todays bots/mods for Half-life.

You have now detailed guide which can teach you :
  • What are all those extern "C", EXPORT, DLLEXPORT, WINAPI, __stdcall and _declspec(dllexport) symbols ?
  • Pesky name-decoration
  • Why do you must have .def file in your bot ?
  • How it is possible to not to use .def file under MSVC and have working bot
Wanna know more ?


I will include here the most important part : How it is possible to not to use .def file under MSVC and have working bot

If you are already using .def file :
  • delete .def file used in MSVC
  • remove all references to your .def file from your project
Change GiveFnptrsToDll()s definition to :
Code:

#if defined _WIN32
#pragma comment(linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
#pragma comment(linker, "/SECTION:.data,RW")
#endif

#ifndef __linux__
extern "C" void __stdcall GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine,globalvars_t *pGlobals)
#else
extern "C" void GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine,globalvars_t *pGlobals)
#endif

{
...
}

Advantages of my approach :
  • whole export procedure is controlled in one file, no need to create special .def file just for one export
  • fully compatible with HL SDKs approach. (Including making GiveFnptrsToDll first on export list and explicitly defining READ and WRITE attribute for .data section)
Note that this solution is for MSVC and linux. You have to include additional code for Borland or MingW32 to export it (But you had to do it also in old approach, hadn't you ?)



And for experienced bot coders, I have Comparing declarations of GiveFnptrsToDll() and Server_GetBlendingInterface() in bots. They may or may not find there something useful. But it should be useful at least for Pierre and Botman, because it seems they have bugs in their bots (Botmans HPB bot template and Pierres templates)


.

Pierre-Marie Baty 30-08-2004 22:45

Re: Guide : Exporting functions in Half-life mods
 
Very interesting stuff here, thanks :)

It looks like you enjoyed it a lot, hehehe

koraX 31-08-2004 11:26

Re: Guide : Exporting functions in Half-life mods
 
mirror is here, 'cause seems like main site is down and I can't find edit button to edit my first message. strange o_O

stefanhendriks 19-12-2004 11:02

Re: Guide : Exporting functions in Half-life mods
 
very interesting and good written piece of tutorial there. You should do more ;) Gonna keep that ;)


All times are GMT +2. The time now is 01:45.

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