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

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
Re: code to get the illumination at any point on the map
Old
  (#21)
Immortal_BLG
Member
 
Status: Offline
Posts: 170
Join Date: Nov 2007
Location: Russian Federation
Default Re: code to get the illumination at any point on the map - 19-03-2012

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
}
   
Reply With Quote
Re: code to get the illumination at any point on the map
Old
  (#22)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,415
Join Date: Apr 2004
Default Re: code to get the illumination at any point on the map - 19-03-2012

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 View Post
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?
   
Reply With Quote
Re: code to get the illumination at any point on the map
Old
  (#23)
Immortal_BLG
Member
 
Status: Offline
Posts: 170
Join Date: Nov 2007
Location: Russian Federation
Default Re: code to get the illumination at any point on the map - 19-03-2012

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.
   
Reply With Quote
Re: code to get the illumination at any point on the map
Old
  (#24)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,415
Join Date: Apr 2004
Default Re: code to get the illumination at any point on the map - 19-03-2012

Quote:
Originally Posted by Immortal_BLG View Post
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 View Post
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.
   
Reply With Quote
Re: code to get the illumination at any point on the map
Old
  (#25)
Immortal_BLG
Member
 
Status: Offline
Posts: 170
Join Date: Nov 2007
Location: Russian Federation
Default Re: code to get the illumination at any point on the map - 19-03-2012

Thanks for the lesson
I mean advice, F*CKING translator....
Good Luck!
   
Reply With Quote
Re: code to get the illumination at any point on the map
Old
  (#26)
Whistler
Whistler
 
Whistler's Avatar
 
Status: Offline
Posts: 1,478
Join Date: Feb 2004
Location: Beijing, P. R. China
Default Re: code to get the illumination at any point on the map - 19-03-2012

'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.
   
Reply With Quote
Re: code to get the illumination at any point on the map
Old
  (#27)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,415
Join Date: Apr 2004
Default Re: code to get the illumination at any point on the map - 19-03-2012

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.
The problem reported by MinGW has to be definitely somehow resolved.

Last edited by KWo; 19-03-2012 at 20:27..
   
Reply With Quote
Re: code to get the illumination at any point on the map
Old
  (#28)
Immortal_BLG
Member
 
Status: Offline
Posts: 170
Join Date: Nov 2007
Location: Russian Federation
Default Re: code to get the illumination at any point on the map - 20-03-2012

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
   
Reply With Quote
Re: code to get the illumination at any point on the map
Old
  (#29)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,415
Join Date: Apr 2004
Default Re: code to get the illumination at any point on the map - 20-03-2012

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?
   
Reply With Quote
Re: code to get the illumination at any point on the map
Old
  (#30)
Immortal_BLG
Member
 
Status: Offline
Posts: 170
Join Date: Nov 2007
Location: Russian Federation
Default Re: code to get the illumination at any point on the map - 20-03-2012

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....
   
Reply With Quote
Reply


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

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 - 2017, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com