.:: 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)

Immortal_BLG 19-03-2012 09:05

Re: code to get the illumination at any point on the map
 
oh, missed it....

Quote:

Originally Posted by KWo
About GetModuleHandle ("sw.dll") - what exactly is this check for?

It is associated with specificity of display for different renderers....
I use it to determine which structure to use:
1) swds.DLL - used only for dedicated server - has no render interface (structures withOUT "GL_" prefix)
2) sw.DLL - used in software rendering mode (Options->Video->Renderer->Software) (structures withOUT "GL_" prefix)
3) hw.DLL - used in hardware rendering mode (OpenGL: Options->Video->Renderer->Software, Direct 3D: Options->Video->Renderer->D3D) (structures with "GL_" prefix)
Quote:

Originally Posted by KWo
Isn't just the same as a check (!FNullEnt (pHostEdict))?

NO.
Quote:

Originally Posted by KWo
Another thing - there is no listenserver for a linux...

It turns out that the function "IS_DEDICATED_SERVER" always returns true on LINUX?, if so, try this:
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
}


KWo 19-03-2012 09:58

Re: code to get the illumination at any point on the map
 
Adding "inline" helped for cygwin (so the binary has been finally created and I'll be able to test Your function on a linux server - to see if it works - GETENTITYILLUM wasn't working on linux, so my bots wouldn use i.e. flashlights). But that one seems to be still unsolved:
Quote:

Originally Posted by KWo (Post 64327)
When I'm compiling it under mingw it also says about some problems:
obj.win32/bot.o:bot.cpp (.text+0x1a822): undefined reference to `bool const Light::RecursiveLightPoint<mnode_s, msurface_s>(mnode_s const*, Vector const&, Vector const&)'
obj.win32/bot.o:bot.cpp (.text+0x1b08b): undefined reference to `bool const Light::RecursiveLightPoint<GL_mnode_t, GL_msurface_t>(GL_mnode_t const*, Vector const&, Vector const&)'
collect2: ld returned 1 exit status
make: *** [obj.win32/podbot_mm.dll] Error 1

What does it mean that kind of messages like (.text+0x1a822)?

I don't understand that at all - cygwin and mingw are compiling binaries the same gcc way (I mean with the same rules and the same makefile), so why exactly cygwin cannot see any problem, but mingw still says something stupid?

About linux - from that what I know - there is no client and no listenserver available for CS for linux. VALVE has released only a dedicated server version of CS. So IS_DEDICATED_SERVER () SHOULD return always true (expect the situation VALVE has there a bug in the code).
About that GL thing - what if the user selects D3D instead OpenGL (in Video preferences) on a listenserver? Does that mean Your code wouldn't work then?

Immortal_BLG 19-03-2012 11:51

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

Originally Posted by KWo
GETENTITYILLUM wasn't working on linux, so my bots wouldn use i.e. flashlights).

I don't know in what a problem, try to involve again function ShowMagic and to look at result. If the function "Light::R_LightPoint" returns 0 (or some inappropriate value), it means that an error somewhere in my code, but I do not know how to solve it for LINUX, otherwise an error apparently in function "GETENTITYILLUM".
So, my council: use instead of function "GETENTITYILLUM" directly variable "bot->v.light_level" - for bots and players it is the same.

And about the compilation error, I do not know what help you :(

Quote:

Originally Posted by KWo
About that GL thing - what if the user selects D3D instead OpenGL (in Video preferences) on a listenserver? Does that mean Your code wouldn't work then?

No, it means nothing also nothing will change.

KWo 19-03-2012 12:10

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

Originally Posted by Immortal_BLG (Post 64332)
So, my council: use instead of function "GETENTITYILLUM" directly variable "bot->v.light_level" - for bots and players it is the same.

The council is:
1. a group of people who are elected to govern an area such as a town, city, etc.
2. a group of people chosen to give advice, manage affairs, etc. for a particular organization or activity
In our Slovian languages we have one the same word for "council" and for "advice" (in Polish it's "Rada" - in Russian it may sound similar). :)

That's exacty what I have done. I have to look at Your another advice about other bots (not podbot mm) to run Your function at them, too. Your function doesn't return 0 on bots on a Windows server, but now it's time for me to test it on a linux server, too. I'm going to test it today evening.

Quote:

Originally Posted by Immortal_BLG (Post 64332)
And about the compilation error, I do not know what help you :(

OK - i'll try to ask Whistler or somebody with gcc compilation knowledge.
Thanks for all Your help so far. :)

Immortal_BLG 19-03-2012 12:37

Re: code to get the illumination at any point on the map
 
Thanks for the lesson :)
I mean advice, F*CKING translator....
Good Luck!

Whistler 19-03-2012 16:03

Re: code to get the illumination at any point on the map
 
'hack' way - add something like this to util.cpp (so that the symbols for the 2 types actually exist in the compiled .o file):

Code:

void myhack()
{
 Vector v;
 Light::RecursiveLightPoint<mnode_s, msurface_s>(NULL, v, v);
 Light::RecursiveLightPoint<GL_mnode_t, GL_msurface_t>(NULL, v, v);
}

or move the templated function to .h file instead.

KWo 19-03-2012 20:49

Re: code to get the illumination at any point on the map
 
The templated function is already placed in .h (bot_globals.h):
Code:

namespace Light
{
//extern const mplane_t *lightplane (NULL);
//extern Vector lightspot;
  extern Color g_pointColor;

  template <typename nodeType, typename surfaceType> extern const bool RecursiveLightPoint (const nodeType *const node, const Vector &start, const Vector &end);

  inline const bool IsSoftwareDrawingMode (void)
  {
      static const bool isSoftwareDrawingMode (IS_DEDICATED_SERVER () || GetModuleHandle ("sw.dll") != NULL);

      return isSoftwareDrawingMode;
  }

  inline const bool ActualRecursiveLightPoint (const Vector &start, const Vector &end)
  {
      return IsSoftwareDrawingMode () ?
        RecursiveLightPoint <mnode_t, msurface_t> (sv_worldmodel->nodes, start, end) :
        RecursiveLightPoint <GL_mnode_t, GL_msurface_t> (reinterpret_cast <GL_mnode_t *> (sv_worldmodel->nodes), start, end);
  }

  inline const unsigned char R_LightPoint (const Vector &p)
  {
  // Reliability check.
      if (sv_worldmodel == NULL)
        return 0u;

      if (sv_worldmodel->lightdata == NULL)
        return 255u;

      Vector end (p);

      end.z -= 2048.0f;

      return ActualRecursiveLightPoint (p, end) == false ? 0u : static_cast <unsigned char> (g_pointColor.GetAvg ());
  }
}

I don't understand the hack. Rather I would like to understand somehow the problem (why mingw doesn't see the function) and solve it the way mingw can see it (without workarounds). Can You help again?

[EDIT]
The cygwin file - even if it's compiled - it is not loading on my mandriva 2011 linux test server. :big_crying:
The problem reported by MinGW has to be definitely somehow resolved.

Immortal_BLG 20-03-2012 04:08

Re: code to get the illumination at any point on the map
 
Whistler has in mind that you must put the body of a function "RecursiveLightPoint" in the header file bot_globals.h instead of util.cpp

KWo 20-03-2012 08:15

Re: code to get the illumination at any point on the map
 
From that what I've seen in the code, all extern variables they are placed in bot_gloabals.h, they have to be placed also in bot_globals.cpp. Isn't here the same situation - if extern const bool RecursiveLightPoint exists in bot_globals.h, maybe it shoud be also defined in bot_globals.cpp? The only difference is - in this case it is a const (not a variable). I don't have such case in the rest of code, so I cannot compare it with anything. :(
Another thing - I don't have other clasess in podbot mm code, so I'm completly lost with Your function. :) I have completly no idea how classes variables should be declared to be seen from other *.cpp files and their functions. If i.e. there is a function FVisible in util.cpp, it's just enough to add this decalration below in bot.h:
bool FVisible (const Vector &vecOrigin, edict_t *pEdict);

But how it should be made for functions they are some members of a class?

Immortal_BLG 20-03-2012 09:15

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

Originally Posted by KWo
From that what I've seen in the code, all extern variables they are placed in bot_gloabals.h, they have to be placed also in bot_globals.cpp. Isn't here the same situation - if extern const bool RecursiveLightPoint exists in bot_globals.h, maybe it shoud be also defined in bot_globals.cpp? The only difference is - in this case it is a const (not a variable). I don't have such case in the rest of code, so I cannot compare it with anything.

About it I don't know, try to declare this function in bot_globals.cpp, but why you do not accept the declaration in a header file, how has offered Whistler?

And into the account of classes and namespaces - you are free to make with a code all that you want, so you can simply remove this namespace....


All times are GMT +2. The time now is 12:49.

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