.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
Is it possible?
Old
  (#1)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Is it possible? - 16-12-2004

Well, i'm busy with a secret project.

The question is, can i have something like:

file a.cpp
Code:
int ReturnSomeIndex()
{
 return bla;
}
in file b.cpp
Code:
int UTIL_ReturnSomeIndex()
{
  if (ReturnSomeIndex)
	return ReturnSomeIndex();
 
 return 0;
}
so in other words.

file B must be in the project all the time, but will work even without file A. So when ReturnSomeIndex() does not exist, it compiles fine. I thought there was something done like this in botmans code before, with the engine functions put in a void *. But i am not sur eif this is possible.

So i want to override the UTIL_ReturnSomeIndex() with resulting a function. But even if that function does not exist (for neatness sake). I know i can 'do this simpler' with a simple boolean value or something like that. Or even provide an empty ReturnSomeIndex() function in file A. But thats the key, file A should NOT be needed and still compile and the program should run...

any idea?


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Is it possible?
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Is it possible? - 16-12-2004

The only way to do this is to set up a table of function pointers (like the g_engfuncs we all know in HL1). Else your linker will complain about undefined identifiers.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: Is it possible?
Old
  (#3)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Is it possible? - 16-12-2004

i was afraid of that


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Is it possible?
Old
  (#4)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: Is it possible? - 16-12-2004

yes, I think the only way would be to use function pointer tables and some sort of loading routines, like .dll / .so loading


  
Reply With Quote
Re: Is it possible?
Old
  (#5)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Is it possible? - 17-12-2004

Yeah I have no idea how to do this. You will most likely need to make a library and use a header file. Like this:

Code:
extern int ReturnSomeIndex();
Or, you can give the function a pointer to the function. I've seen tutorials.

http://www.function-pointer.org/

BTW, pfn stands for pointer to function. That is how you can denote it.


sfx1999.postcount++
  
Reply With Quote
Re: Is it possible?
Old
  (#6)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Is it possible? - 17-12-2004

I thought of this method, but in fact this caused double-trouble. I might go this route again, but i don't think its worth it and can be done easier. Though, i'm still interested in this, its similiar how the Think functions work in HL2... they do a "SetTHink" or something But thats something you guys already knew of course.


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com