.:: 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 ::. > Cyborg Factory > RealBot > The RealBot 'Source'
The RealBot 'Source' Discuss things about the source code. You can here point out bugs, share ideas and code. Assign to become an 'official team member' and so on!

Reply
 
Thread Tools
Re: hey stefan...
Old
  (#11)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: hey stefan... - 15-05-2004

okay, forget about this GPL thing if you don't like it. And that's also not on topic - I started this post to help you with the Realbot. And I'm just saw both you and PM have some misunderstanding with the GPL, I just wanted to make things clear. Sorry.

now back to my first intent:

Here's some suggestions to Realbot:
- Use a switch to toggle on/off that Parabot-like autowaypointing function. IMHO when I have played the map for quite a long time the autowaypointing thing is just unnecessary then and just a waste of CPU power.
- Use malloc() for these things may take less memory:
Code:
private:
    tNode Nodes[MAX_NODES];	// Nodes
  tInfoNode InfoNodes[MAX_NODES];	// Info for Nodes
  tPlayer Players[32];		// Players to keep track off
  tGoal Goals[MAX_GOALS];	// Goals in the game
  tMeredian Meredians[MAX_MEREDIANS][MAX_MEREDIANS];	// Meredian lookup search for Nodes
  int iPath[32][MAX_PATH_NODES];	// 32 bots, with max waypoints paths
  int iMaxUsedNodes;
  //byte        iVisTable[MAX_NODES][MAX_NODES];
  byte iVisChecked[MAX_NODES];
  unsigned char *cVisTable;
  tTrouble Troubles[MAX_TROUBLE];
eg, first malloc() 512 or 1024 slots, and when it's not enough, realloc() to increase it. IMHO using these static array just takes a lot of unnecessary memory.
- Compress the waypoint data to make the file smaller. There is a good compress code in the PODbot code, maybe you can make use of it.

(also sorry for post these things not in organized way - but I don't think I can become a Team member because I can't work on Realbot that much. And I did learnt something in your code so thanks a lot)
  
Reply With Quote
Re: hey stefan...
Old
  (#12)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: hey stefan... - 15-05-2004

at the moment the nodemachine is static, and its on purpose static... Although i understand this eats memory. It also ensures its all memory that its needed. I also don't have to worry about bad allocations yet. I am not good at handling dynamic memory. most stuff is btw only a few K of memory so i don't think this should be considered 'critical'..

what did you learn from the code?


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
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
Re: hey stefan...
Old
  (#14)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: hey stefan... - 30-05-2004

i know the Post function is called AFTER the gamedll functions. And this is on purpose btw. PMB once posted a fix for bots not seeing through all glass/windows. I simply copied the entire function, i did not comment out some parts, this could be done though. Its more like lazyness


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: hey stefan...
Old
  (#15)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: hey stefan... - 02-06-2004

"And this is on purpose btw."
...then IMHO you are doubling the cost of CPU powers, the chance of server crashes and creating some memory leaks "on purpose".
  
Reply With Quote
Re: hey stefan...
Old
  (#16)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: hey stefan... - 04-06-2004

well, the fact that some functions do get called twice is on purpose , to fix a bug as stated before Anyhow, there is no point in causing memory leaks and doubling cpu power on purpose, unless your name is Microsoft (moving this thread to the RealBot "source" forum)


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: hey stefan...
Old
  (#17)
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: hey stefan... - 05-06-2004

My fix for the glass bug was not to call the same function twice! You misunderstood it I see.

You mustn't call the same function twice, you must call 2 DIFFERENT, SUCCESSIVE HOOKS, for the Spawn() function.

The first hook occurs BEFORE the actual Spawn() function from the gameDLL is called: it's the normal hook your code already uses. It tells you that an entity is about to be spawned. This hook is declared in metamod's gFunctionTable.

The SECOND hook, which IS the fix, occurs AFTER the actual Spawn() function from the gameDLL is called, in order to "correct" one parameter in the entity which has just been spawned. And since we want to do this AFTER the entity has spawned, we must then declare it in metamod's gFunctionTable_Post table.

Whistler is completely right, and your GetEntityAPI2_Post function should be just like what he says. There has never been any "purpose" in calling the same functions twice but to produce horrible things like memory leaks, array indices getting out of bounds, and general fuckups everywhere. I'm starting to be more and more convinced that RealBot is driven by magic! o_O



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: hey stefan...
Old
  (#18)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: hey stefan... - 05-06-2004

Lol. Well yeah, i do learn from Harry Potter a lot I will fix this thing asap.


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: hey stefan...
Old
  (#19)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: hey stefan... - 05-06-2004

Hmm, one question though:

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);
}



this code , which is from Whistler in the above post, it has in the last line:
memcpy (pFunctionTable, &gFunctionTable, sizeof (DLL_FUNCTIONS));


shouldnt it be:
memcpy (pFunctionTable, &gFunctionTable_post, sizeof (DLL_FUNCTIONS));

?


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: hey stefan...
Old
  (#20)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: hey stefan... - 06-06-2004

yeah, that's a typo error
  
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 - 2025, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com