.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   code to get the illumination at any point on the map (http://forums.bots-united.com/showthread.php?t=9005)

KWo 22-03-2012 21:38

Re: code to get the illumination at any point on the map
 
OK. The podbot_mm_i386.so file loads on my linux virtual PC correctly and bots are using flashlights correctly now (so it means they know where is a dark area and Your code works also on linux)!

Now back to the second problem - about running Your function on other bots (CZERO bots and metamod bots). If the function pfnRunPlayerMove (called i.e. for other bots) function resets their pEdict->v.light_level, I believe - if we are setting their v.light_level in StartFrame function, everything should work. Except one thing. There are some plugins (written in PAWN - C similar language) they are using fake bots to prevent i.e. the round to be ended (if all players and "normal" bots are dead). I'm not sure if AMXMOD X creating such type of bots is adding the flag FAKECLIENT. I'm also not sure if calling that function for such type fake bots doesn't do any side-effects. Another thing - I'm not sure if CZERO bots have the FAKECLIENT flag set. I need to do more tests then.

Immortal_BLG 23-03-2012 05:33

Re: code to get the illumination at any point on the map
 
I'm sorry, I seem to have deceived you, the function "RunPlayerMove" does not change the value of the variable "entvars_t::light_level", moreover, this value seems to be that NEVER changes for the bot!
I set some nonzero value and killed a bot, did round restart - value didn't change. I even kick a bot, and then connect new bot, which occupied entity of kicked bot, and so, the new bot used value of this variable, from the kicked bot!!!

So that method with setting this value in a function "StartFrame" in the loop for all clients, which have flag FL_FAKECLIENT - probably the most correct....

I would also like to recommend to reset the value of this variable when creating a new bot, how you do it, for example for the variable entvars_t::frags.

Quote:

Originally Posted by KWo
I'm not sure if CZERO bots have the FAKECLIENT flag set. I need to do more tests then.

no doubt on account of this - CSBot sets this flag on each spawn....

KWo 23-03-2012 08:12

Re: code to get the illumination at any point on the map
 
Quote:

Originally Posted by Immortal_BLG (Post 64351)
I set some nonzero value and killed a bot, did round restart - value didn't change. I even kick a bot, and then connect new bot, which occupied entity of kicked bot, and so, the new bot used value of this variable, from the kicked bot!!!

Well - I'm not surprised by this at all. Long time ago I had to be in contact with AMX /AMX X developers, because users have had troubles with admin priviliges. After kicking the bot and enetering the user-admin - he couldn't get his access rights because... these mods where thinking he is still a bot! I have to re-search what was the remedy for this. I'm not sure if they haven't had even to do something with FAKECLIENT flag, then we probably had to add it each frame. It will take me some time to check that.

Anyway - that (what You wrote) means I have to reset v.light_level also at Client_Disconnect, but I'm not sure if that function gets called in my dll for other mm bots (metamod is blocking some messages coming from other its plugins - not sure if this one is blocked or not). I'll try to test it somehow with podbot mm and yapb (2.30). Did You check if v.light_level for the real player (human) is cleared (0) after the player gets killed (is dead)? I feel I have to add more code in some places I didn't think of them yet before... But the work is still in progress - so probably during few days the new build of podbot mm will be released. :)

Immortal_BLG 23-03-2012 11:13

Re: code to get the illumination at any point on the map
 
Quote:

Originally Posted by KWo
Did You check if v.light_level for the real player (human) is cleared (0) after the player gets killed (is dead)?

Checked already, and the answer is NO.
When the real client dies and he is not in "First Person" spectating mode - the value of the variable "light_level" does not changes, otherwise, he "takes" the value of player, which he sees.

By the way I'm not exactly sure but I think in general the engine and game DLL (CS) never uses the variable "light_level"....

KWo 24-03-2012 09:49

Re: code to get the illumination at any point on the map
 
Quote:

Originally Posted by Immortal_BLG (Post 64348)
BTW at the expense of function "GetModuleHandle". Once again I was wrong in my last post, because if there is no listen servers for LINUX, then the function "GetModuleHandle" for LINUX does not need, in addition, ".DLL" extension on LINUX, it does not exist, there ".SO".

So you should use: (without GetModuleHandle for LINUX)
Code:

inline const bool IsSoftwareDrawingMode (void)
{
    #ifdef _LINUX
        return true;    // Always software rendering mode....
    #else    // ifdef _LINUX
        static const bool isSoftwareDrawingMode (IS_DEDICATED_SERVER () || GetModuleHandle ("sw.dll") != NULL);

        return isSoftwareDrawingMode;
    #endif    // ifndef _LINUX
}


Actually I don't understand at all how this can work. I mean how the function IsSoftwareDrawingMode (void) can get a call for it-self inside it - isSoftwareDrawingMode (IS_DEDICATED_SERVER () || GetModuleHandle ("sw.dll") != NULL) - to give the right result. Can You re-write it to the way I'm used (I mean - first the declaration, then the usage - without recursion)?

Immortal_BLG 24-03-2012 10:22

Re: code to get the illumination at any point on the map
 
This function is not recursive, since the compiler is case sensitive, so "IsSoftwareDrawingMode" - the name of the function, "isSoftwareDrawingMode" - is a global constant, which is computed only once (at the first call of the function that contains this variable - "IsSoftwareDrawingMode") and serves as the return value. You can rename the variable "isSoftwareDrawingMode" at will and it will not change anything. Why static? Because of speedup. I have already written above that the result will be calculated only once - it's what we want....

KWo 24-03-2012 12:43

Re: code to get the illumination at any point on the map
 
Do You mean this function can be written so:
Code:

inline const bool IsSoftwareDrawingMode (void)
{
    #ifdef _LINUX
        return true;    // Always software rendering mode....
    #else    // ifdef _LINUX
        static const bool KWoMode = (IS_DEDICATED_SERVER () || GetModuleHandle ("sw.dll") != NULL);

        return KWoMode;
    #endif    // ifndef _LINUX
}

and it will work the same? So what was the reason it was named the same inside as the global inline const? Just to confuse a noob in C++ programming? :D

Immortal_BLG 24-03-2012 13:36

Re: code to get the illumination at any point on the map
 
Quote:

Originally Posted by KWo
Do You mean this function can be written so:
Code:

inline const bool IsSoftwareDrawingMode (void)
{
    #ifdef _LINUX
        return true;    // Always software rendering mode....
    #else    // ifdef _LINUX
        static const bool KWoMode = (IS_DEDICATED_SERVER () || GetModuleHandle ("sw.dll") != NULL);

        return KWoMode;
    #endif    // ifndef _LINUX
}

and it will work the same?

YES.
Quote:

Originally Posted by KWo
So what was the reason it was named the same inside as the global inline const? Just to confuse a noob in C++ programming?

because in fact the variable "isSoftwareDrawingMode" also itself a function "IsSoftwareDrawingMode", but the only reason why I have not written just code:
Code:

inline const bool IsSoftwareDrawingMode (void)
{
    #ifdef _LINUX
        return true;    // Always software rendering mode....
    #else    // ifdef _LINUX
        return IS_DEDICATED_SERVER () || GetModuleHandle ("sw.dll") != NULL;
    #endif    // ifndef _LINUX
}

, because as I wrote before that check must be executed only once for the economy of the CPU speed.....

KWo 24-03-2012 18:09

Re: code to get the illumination at any point on the map
 
Quote:

Originally Posted by Immortal_BLG (Post 64358)
YES.
because in fact the variable "isSoftwareDrawingMode" also itself a function "IsSoftwareDrawingMode", ...

For linux it is not... The static part (calling once the function) I understood before. Anyway - thanks for the explanation. :)

KWo 03-04-2012 21:34

Re: code to get the illumination at any point on the map
 
Well, me and some users are experiencing a crash since the last podbot mm update. I'm getting this error:
FATAL ERROR (shutting down): New message started when msg '35' has not been sent yet

I googled a bit and I found this answer:
http://www.mail-archive.com/hlcoders.../msg18419.html

Two situation can cause that error: 1) Calling MESSAGE_BEGIN while another message is being written. 2) Forgetting to call MESSAGE_END and the end of a message you send. It appears you are calling callback functions during MESSAGE_BEGIN, MESSAGE_END, WRITE_BYTE (and many others). If any of these callback functions call a MESSAGE_BEGIN you will get that error (since you would be calling MESSAGE_BEGIN a second time before the first message ended). There is no native queuing mechanism in the SDK, since this is only an issue for plugins trying to intercept events. It is pretty easy to write your own queuing mechanism. You can create an abstract class that can be a int, float, vector, or string. Then use std::vector to hold the instances of the abstract class. (If you plan to port to Linux you can run into library dependency issues using the std library.)

Well - what exactly is the message number 35? If I know this I can narrow down the function calling it. It looks like I still need your help. :)

Immortal_BLG 04-04-2012 15:00

Re: code to get the illumination at any point on the map
 
35 is SVC_WEAPONANIM.

I can't help you, because my code does not send messages (with the exception of the ShowMagic, but it is not involved), but I also don't know what message is sent during the construction of the message SVC_WEAPONANIM.

P.S. in order that I could help - you should give me more information

KWo 04-04-2012 18:03

Re: code to get the illumination at any point on the map
 
I'm not sure if we are talking about the same group of messages. I thouht it would be rather one of those captured i.e. in pfnMessageBegin function - like "BarTime", "ResetHUD", "AmmoPickup" and so on. I mean those I need to know for them MSG_ID (GET_USER_MSG_ID). Actually I cannot reproduce that bug on a windows server (it happened only on a linux server), but I found another one on windows server (not related at all to Your code). It is something with pathfinding, I couldn't believe it could happen.
Code:

hlds.exe caused an Access Violation at location 09c261da in module podbot_mm.dll Reading from location cdcdcdf9.

Registers:
eax=09d65c48 ebx=09bd8478 ecx=cdcdcdcd edx=09ccb934 esi=0012ddfc edi=0012f648
eip=09c261da esp=0012ddfc ebp=0012f648 iopl=0        nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000            efl=00000202

Call stack:
09C261DA  podbot_mm.dll:09C261DA  BotCheckTerrain  bot_navigate.cpp:5517
    ...
                      && (pBot->pWaypointNodes != NULL) && (!g_bRecalcVis) && (pBot->bMoveToGoal))  // KWo - 28.01.2012
                  {
>                      if (pBot->pWaypointNodes->NextNode != NULL)
                      {
                        fDistToCurWP = (pEdict->v.origin - paths[pBot->curr_wpt_index]->origin).Length();
    ...

09BFCF1A  podbot_mm.dll:09BFCF1A  BotThink  bot.cpp:8865
    ...
          && (pBot->f_spawn_time + (((g_fTimeRoundEnd + g_f_cv_FreezeTime > gpGlobals->time) && (g_fTimeRoundEnd < gpGlobals->time)) ? (g_f_cv_FreezeTime + 0.0):(0.2)) < gpGlobals->time)) // KWo - 28.05.2010
      {
>          BotCheckTerrain(pBot);
      }
   
    ...

09C355BC  podbot_mm.dll:09C355BC  StartFrame  dll.cpp:2249
    ...
          {
            g_i_botthink_index = bot_index; // KWo - 02.05.2006
>            BotThink (&bots[bot_index]);
            g_iNum_bots++;
          }
    ...

6B2075F6  metamod.dll:6B2075F6

It looks like is not enought to check if the pointer is null or not to prevent the crash... :(
That ">" shows lines of code execution in last called functions.

KWo 04-04-2012 23:27

Re: code to get the illumination at any point on the map
 
It looks like I have fixed the problem with windows crash (the crash dump above), the windows server is not crashing already more than 2 hours (before I needed to wait about 20 minutes to crash). The problem with linux (FATAL ERROR - msg 35) still exists there, but I had to wait about 2 hours now (after the change of the code concerning to the windows crash - not sure why it didn't crash on linux for the same reason). Yesterday it was a crash about every 10 minutes. Maybe there is some problem with network (linux test server is a virtual machine)? I couldn't reproduce that problem on a windows server. Why the hell does it behave different way, if for bot servers I'm using the same configuration of podbot and AMX X files (CSDM)?

Immortal_BLG 12-04-2012 13:09

Re: code to get the illumination at any point on the map
 
I'm sorry that it is so late wrote.
Don't even know how to help you, try to debug bots on LINUX - this is the only thing I can advise to you.... Sorry

KWo 14-04-2012 09:02

Re: code to get the illumination at any point on the map
 
It looks like on real linux servers it doesn't crash anymore since latest update.
http://forums.bots-united.com/showth...4409#post64409
It might be some problem with my virtual PC and network access...

tschumann 09-08-2019 14:02

Re: code to get the illumination at any point on the map
 
The GoldSource engine is currently getting some love and I raised this as an issue on the GitHub tracker: https://github.com/ValveSoftware/halflife/issues/1774


All times are GMT +2. The time now is 17:42.

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