.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   The RealBot 'Source' (http://forums.bots-united.com/forumdisplay.php?f=52)
-   -   hey stefan... (http://forums.bots-united.com/showthread.php?t=1644)

Whistler 11-05-2004 14:17

hey stefan...
 
Just got the realbot code in the CVS server but...

in cNodeMachine::add function (hmmm, maybe that cNodeMachine means more a char variable called NodeMachine, the class name may should be CNodeMachine)
Code:

  // record jumping
  if (pEntity->v.button & IN_JUMP); // what's this ; ?
        Nodes[index].iNodeBits |= BIT_JUMP;


Pierre-Marie Baty 11-05-2004 17:06

Re: hey stefan...
 
IN_JUMP is set in a player's v.button when this player is pressing the JUMP key on its keyboard.
Identically, IN_DUCK is set when this player is pressing the CROUCH key.
v.button is a bitmap of the available keyboard entries that are not client commands, such as movement keys.

sPlOrYgOn 11-05-2004 23:37

Re: hey stefan...
 
what he meant was he found a bug...
theres a semi-colon after the if statement making the other statement always run and the if statement does nothing..

Whistler 12-05-2004 11:28

Re: hey stefan...
 
@PM: the comment I added is "what is this ;(semicolon) ?", not "what is this ?" :)

Code:

  // test file, if found = STEAM Linux/Win32 dedicated server
  fp = fopen ("valve/steam.inf", "rb");
  if (fp != NULL)

    {
      fclose (fp);                // test was successful, close it
      counterstrike = 1;        // its cs 1.6
    }

  // test file, if found = STEAM Win32 listenserver
  fp = fopen ("FileSystem_Steam.dll", "rb");
  if (fp != NULL)

    {
      fclose (fp);                // test was successful, close it
      counterstrike = 1;        // its cs 1.6
    }

...If someone is using old versions like CS 1.3 in Steam this check won't care about it and believe he is using CS 1.6 :)
So I am using a check like this:
Code:

// Check which version of Counter-Strike we're running
void VersionCheck(void)
{
  // see if we are running Counter-Strike v1.6...
  unsigned char *tempbuf;
  int i;

  // only CS v1.6 has this file
  // use HL Engine function so that it would not be affected by Steam...
  tempbuf = LOAD_FILE_FOR_ME("sprites/weapon_famas.txt", &i);

  if (tempbuf)
  {
      g_bIsVersion16 = TRUE;
      FREE_FILE(tempbuf);
  }
}

also why are you doing this ? in this way all the functions will just be called twice:
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);
}

also...
Code:

  * Source code is (c) copyrighted by Stefan Hendriks unless stated otherwise.
  * Source code may never be redistributed without explicit permission of the
  * author.

  * <snipped>

  * This project is open-source, it is protected under the GPL license;
  * By using this source-code you agree that you will ALWAYS release the
  * source-code with your project.

...I'm afraid there's something wrong with the 1st paragraph. The GNU GPL has clause that makes it free to redistribute the software...
Quote:

1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
...so it will automatically give licensee "permission" to redistribute the code. If you don't want others redistribute your software you can't apply the GNU GPL (anyway, all metamod plugins have to be GPL so if you want to do it you'll have to convert the bot back to botman's hook DLL style)

Pierre-Marie Baty 12-05-2004 15:00

Re: hey stefan...
 
hahahahaha :D

GPL rul3z!!!

stefanhendriks 12-05-2004 15:22

Re: hey stefan...
 
there is a bug in the IN_JUMP part, you are correct.

about the copyright, i wrote some parts completely myself (from scratch) like the INI file parser and such (and the nodemachine). Therefor these portions of code are 'copyrighted' , the other source files (as for metamod) are gpl'd, thats how i see it.

edit:
updated source file NodeMachine.cpp

ow, and btw. I don't think there _IS_ a problem with the comments about copyright and such. As by releasing the source, and announcing that on the site there is 'explicitly announced' that its free to use...

Pierre-Marie Baty 12-05-2004 16:09

Re: hey stefan...
 
Quote:

Originally Posted by stefanhendriks
about the copyright, i wrote some parts completely myself (from scratch) like the INI file parser and such (and the nodemachine). Therefor these portions of code are 'copyrighted' , the other source files (as for metamod) are gpl'd, thats how i see it.

ow, and btw. I don't think there _IS_ a problem with the comments about copyright and such. As by releasing the source, and announcing that on the site there is 'explicitly announced' that its free to use...

Actually there IS one, Whistler is right, because the GPL license is contaminative. If you write something that makes use of GPL code, or if parts of your code are already covered by the GPL, then you agree that ALL parts of your code be bound to the GPL too.

Don't know if you're aware of it but just these days in the Netherlands a software firm was put to trial for being in violation of the GNU GPL (the firm was using GPL code in a commercial project but wanted non disclosure for the source code of the project I think)

in other terms:

PWNED :P

Whistler 13-05-2004 11:33

Re: hey stefan...
 
...and the GPL isn't designed to take away your 'copyright', you maybe mis-understood it:
Quote:

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
also most of the GPL software has comments like this to declare the copyright:
Quote:

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@PM: "...or if parts of your code are already covered by the GPL, then you agree that ALL parts of your code be bound to the GPL too."
This isn't correct, since the GPL is the license from the software author to the users. So whatever I'm doing with my OWN code isn't "violating" the GPL (i.e., if I downloaded Stefan's GPL code, then Stefan is limiting my use of the code with the GPL, but his OWN code isn't limited to use - if he hasn't convert the bot to a metamod plugin and become limited by Will Day). In other words, if I created a software 100% myself and not using other's GPL code, I can do WHATEVER with the code as I want.

So the fact for Stefan is: he has to release all the Realbot code under GPL, but whatever using his OWN code in other software which doesn't contain OTHERS' GPL code is OK.

stefanhendriks 13-05-2004 16:14

Re: hey stefan...
 
hehe, you know. When reading all this, i think "hell, i don't care, its open-source now"... hey, its open source or its closed! So its open source. Perhaps i should just remove those 'copyright' things in the comments to prevent some misunderstandig.

Whistler 14-05-2004 10:39

Re: hey stefan...
 
Nope, even if Realbot is under GPL the Realbot code IS (C) Copyright Stefan Hendriks (maybe Christian Authmann as well) and protected under appliable copyright law. So you had better not remove that Copyright notice.

Why you have to release your source code is: You have used code which is (C) Copyright Will Day and you have to obey his license.

What has something wrong is: you are restricting the redistribution as that way. Actually that's also NOT "violating" GPL, but by applying the GPL that clause just turned into nothing. I thought you don't want your software to be redistributed so I pointed that out. (and if you do want others redistribute the software perhaps you should remove that instead of the copyright thing :) )

(btw, has Christian Authmann "offically widdrawn (withdrawn)" now ?)

Whistler 15-05-2004 03:49

Re: hey stefan...
 
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)

stefanhendriks 15-05-2004 18:33

Re: hey stefan...
 
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?

Whistler 30-05-2004 03:42

Re: hey stefan...
 
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);
}


stefanhendriks 30-05-2004 11:46

Re: hey stefan...
 
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 ;)

Whistler 02-06-2004 11:17

Re: hey stefan...
 
"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". ;)

stefanhendriks 04-06-2004 19:33

Re: hey stefan...
 
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 :D (moving this thread to the RealBot "source" forum)

Pierre-Marie Baty 05-06-2004 16:18

Re: hey stefan...
 
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

stefanhendriks 05-06-2004 17:17

Re: hey stefan...
 
Lol. Well yeah, i do learn from Harry Potter a lot ;) I will fix this thing asap.

stefanhendriks 05-06-2004 17:40

Re: hey stefan...
 
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));

?

Whistler 06-06-2004 04:14

Re: hey stefan...
 
yeah, that's a typo error

stefanhendriks 06-06-2004 16:18

Re: hey stefan...
 
roger :)

stefanhendriks 06-06-2004 23:27

Re: hey stefan...
 
Okay, i have re-read the entire thing over. And i now fully understand it, and its applied to the source (updated on CVS, so you can do 'update' now).


All times are GMT +2. The time now is 08:57.

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