![]() |
code to get the illumination at any point on the map
Here a code which will help to receive value of illumination of any point on the map.
Also you will open for yourselves some changes in such structures as 'texture_t', 'mleaf_t', 'msurface_t' and 'mnode_t' which Valve hasn't found time to update in HLSDK.... NOTE: The code is working, but in that kind in which it is placed here wasn't checked. NOTE2: Engine functions (GiveFnptrsToDll, StartFrame, LightStyle and PM_Move) in a code are placed simply for descriptive reasons. Code:
#undef texture_t |
Re: code to get the illumination at any point on the map
Thank you again for your time in discovering/reversing what Valve should give us by default.
I didn't look at the code very deeply, so sorry if my question is obvious. Is it PM_Move requred? Because actually this is only valid in Listen server mode. |
Re: code to get the illumination at any point on the map
Quote:
IMPORTANT NOTE that I forgot to write in the first post: The code will work if at least one client will be present on the server!!! P.S. Why I have made reception 'sv.worldmodel' of structure 'playermove_t'? Because this is probably the only way without the use of wild hooks..... |
Re: code to get the illumination at any point on the map
Ok, but I think there is anoder fall. It is bad ides to save illumination in waypoits, because of the many mods that exists( like AMXX ) that depending on some condition can change the light level in some area. Then if the waypoits are holding such data it will become invalid.
|
Re: code to get the illumination at any point on the map
It was a simple example.
And now about the actual fall :) Now I have understood, why the Valve haven't changed structure which I posted. The reason is that the structures which are currently in HLSDK intended for a dedicated server (swds.dll), and those structures that I have posted are used in the listen server (hw.dll) to work with openGL. Well now that in this situation will have to take into account the type of server (listen/dedicated) and on the basis of it to choose structure.... :( So modified code is here (The prefix "GL_" for names of structures is added, has replaced 'GL_texture_t::UNKNOWN[2u]' to original members, fixed offset for 'GL_mnode_t::numsurfaces', function RecursiveLightPoint() now a template, added function ActualRecursiveLightPoint(), the call in function 'R_LightPoint' of function 'RecursiveLightPoint' has been changed to a call 'ActualRecursiveLightPoint') Code:
struct GL_texture_t // NOT USED BY LIGHTING CODE, BUT STILL AS BONUS |
Re: code to get the illumination at any point on the map
Hi,
I think that looking at the modified common/com_model.h file in the hlsdk23_msvc2008.zip downloadable from http://www.moddb.com/games/half-life/downloads/half-life-sdk-v23-for-visual-studio-2008 will provide you with useful information on data structure you addressed. regards. |
Re: code to get the illumination at any point on the map
It seems that Mr. "Gary_McTaggart" has already made it long before me. :) I on the computer had this archive, however I have missed these changes. Thanks!
|
Re: code to get the illumination at any point on the map
After very fast look at Your code (of course without understanding it) I haven't seen the call for this function:
#define GETENTITYILLUM (*g_engfuncs.pfnGetEntityIllum) I don't know it this is no longer needed or what. But I had troubles with that function - it works perfectly on a windows server, but it always gives 0 as a return value on a linux server. So - did You check if Your code is working on both - linux and windows server? |
Re: code to get the illumination at any point on the map
Hello KWo!
Quote:
Code:
//----- (01D82AE0) -------------------------------------------------------- Quote:
Code:
assert (sv_worldmodel != NULL); Code:
if (sv_worldmodel == NULL) And one more: it is necessary to replace in function "ActualRecursiveLightPoint()" call "IsSoftwareDrawingMode()" instead of a call of function "IS_DEDICATED_SERVER()" and to define this function so: Code:
inline const bool IsSoftwareDrawingMode (void) |
Re: code to get the illumination at any point on the map
OK - I'm getting confused after reading that. What should I do in HLSDK files, and what in bot code files? I mean which changes should be applied to HLSDK files and which should be applied to bot cpp/h files?
|
Re: code to get the illumination at any point on the map
You should add or in HLSDK, or somewhere in the header file of the bot of structures with a prefix "GL_".
Generally, for your bot it is necessary to add simply all code, from my fifth post and if it is concrete: Code:
// "bot_globals.h" |
Re: code to get the illumination at any point on the map
Quote:
[EDIT] If You want to see my code - send me a pm with Your email address, I can send it You that way. I wanted to upload it at the mirror of the filebase (CFE server), but it looks like Ancient has changed some access rights and nobody can browse my files there. :( [/EDIT] |
Re: code to get the illumination at any point on the map
Quote:
So KWo HERE you can take the project (the source code and DLL), and below I present the corrected code: Code:
#include <com_model.h> 1) add the required headers from HLSDK; 2) added definitions of 'SURF_*' constants; 3) type 'BOOL' is changed to 'qboolean'; 4) type 'Math::Vector3D' is changed to HLSDK 'Vector'; 5) added check "hostPlayerEdict->pvPrivateData == NULL" in a function 'ShowMagic'; 6) in a function 'SetupLightStyles' fixed bug related to 'cl_lightstyle' array. 7) changed the name of the function 'g_engfuncs.ServerPrintf' to 'g_engfuncs.pfnServerPrint' 8) function 'DotProduct' is used instead of the overloaded operator logical OR for calculation of scalar product of vectors. Excuse me. It all is simply a consequence of the porting of code from my bot, and also because of that that I this code up until that time didn't compile/not checked properly.... |
Re: code to get the illumination at any point on the map
Thanks. :)
I have added all things into my current code and I've got it finally compiling correctly (no errors and no warnings). It was calling the function Show_Magic() for me as a Host (on my listenserver) to show me my light level (something about 178 on de_dust2). After that I have commented out the call of that function, because I couldn't use the console. Then I've checked bots light_level and it was still 0. I was using PMTOOLS from the filebase. pEntity->v.light_level = 0 I believe Your code is to make the light_level of bots alive, but - at least on the listenserver CS1.6 steam - it doesn't do the job. Or maybe I misunderstood the point of this code? [EDIT] Just checked - on the dedicated server bots light_level is also still 0. [/EDIT] |
Re: code to get the illumination at any point on the map
Quote:
Because you do not assign a value of illumination received after the call of "Light::R_LightPoint" to variable "bot->v.light_level"!! To get everything working as it should you just have to after each function call "pfnRunPlayerMove" to add the code: Code:
if (!pBot->bDead) as a result the code should look like: Code:
g_engfuncs.pfnRunPlayerMove (pEdict, vecMoveAngles, pBot->f_move_speed, pBot->f_sidemove_speed, 0, pEdict->v.button, 0, (unsigned char) i_msecval); // KWo - 25.09.2006 - thanks to THE_STORM Because this function resets back to zero value of bot light_level and we just restores it to normal.... |
Re: code to get the illumination at any point on the map
Thanks. It works now. I have rewritten the UTIL_IlluminationOf function. I cannot remove the Illumination entity (that one based on mechgibs.mdl) because there might be still other bots on the server (like CZERO bots other podbot clone and so on) and their light_level still would be 0. :)
Or maybe there is a way to run Your function for all users/bots from my dll? [EDIT] I cannot compile it for linux, because of the function GetModuleHandle (coming from WinBase.h - not existing for linux). I need a replacement for linux. Whistler would help with it. :) [/EDIT] |
Re: code to get the illumination at any point on the map
Quote:
Way 1, inaccurate: Code:
///........................ Code:
static void RunPlayerMove_Post (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec) BTW. Taken from Source SDK interface.cpp: Code:
#ifdef _LINUX |
Re: code to get the illumination at any point on the map
I'm having troubles with compiling under cygwin with that function
void *GetModuleHandle(const char *name) After adding it to botglobals.h the compiler says it is defined twice (which really isn't). 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)? About GetModuleHandle ("sw.dll") - what exactly is this check for? Isn't just the same as a check (!FNullEnt (pHostEdict))? Another thing - there is no listenserver for a linux... |
Re: code to get the illumination at any point on the map
First of all, I want to refute my previous post a little.
The second way is incorrect, as metamod doesn't do callbacks for its plug-ins, I have forgotten about it, forgive me again :( So use the first method.... About your last post: Change: Code:
void *GetModuleHandle(const char *name) Code:
inline void *GetModuleHandle(const char *name) Code:
extern inline void *GetModuleHandle(const char *name) |
Re: code to get the illumination at any point on the map
How about that below?
Quote:
|
Re: code to get the illumination at any point on the map
oh, missed it....
Quote:
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:
Quote:
Code:
inline const bool IsSoftwareDrawingMode (void) |
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:
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? |
Re: code to get the illumination at any point on the map
Quote:
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:
|
Re: code to get the illumination at any point on the map
Quote:
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:
Thanks for all Your help so far. :) |
Re: code to get the illumination at any point on the map
Thanks for the lesson :)
I mean advice, F*CKING translator.... Good Luck! |
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() |
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 [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. |
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
|
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? |
Re: code to get the illumination at any point on the map
Quote:
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.... |
Re: code to get the illumination at any point on the map
Quote:
Quote:
Another thing I'm thinking of is - how much Your function consume the CPU power since it is a recursive function, which needs to be called for every 30 bots on the server (if there are 30 bots)? |
Re: code to get the illumination at any point on the map
Quote:
Quote:
Code:
namespace Light Quote:
|
Re: code to get the illumination at any point on the map
Quote:
|
Re: code to get the illumination at any point on the map
Why? You said yourself that the functions that are defined in bot_globals.h, must be declared in the same file - bot_globals.cpp. But instead of it you can declare function "RecursiveLightPoint" in a header file bot_globals.h and ofcourse remove declaration from utils.cpp
|
Re: code to get the illumination at any point on the map
I said - it is so for variables and functions, but I haven't had that case for a const (so I don't know if it needs or not to be done exactly the same way). My doubts are coming from lack of basic C++ knowledge. :)
Anyway I'll try to do something with it today evening. Thanks again for all Your help. Спасибо за совет! :) |
Re: code to get the illumination at any point on the map
OK. Still no luck. One thing I'm sure now. I have commented out in bot_globals.cpp this line:
const char *g_sz_cv_WPT_Folder; and I've got similar error messages about text (0xaaaa), so that really means I do need somehow the declaration of the function RecursiveLightPoint. I have checked and there are also other const (not only variables) - first added in bot_globals.h with "extern" prefix, then - without this prefix - in bot_globals.cpp. The problem for me is that template. I don't know how to correctly declare the function RecursiveLightPoint to pevent i.e. such error messages: bot_globals.cpp|235|error: expected `,' or `...' before '*' token| bot_globals.cpp|235|error: ISO C++ forbids declaration of `nodeType' with no type| bot_globals.cpp|235|error: `const bool Light::RecursiveLightPoint(int)' should have been declared inside `Light'| ||=== Build finished: 3 errors, 0 warnings ===| Currently in my code I've removed the function from util.cpp and in bot_globals.h it looks so: Code:
namespace Light Code:
235: const bool Light::RecursiveLightPoint (const nodeType *const node, const Vector &start, const Vector &end); |
Re: code to get the illumination at any point on the map
try:
in bot_globals.h: Code:
#ifdef _LINUX Code:
static const bool RecursiveLightPoint (const mnode_t *const node, const Vector &start, const Vector &end) Finally in bot_globals.cpp everything should be as so: Code:
/* |
Re: code to get the illumination at any point on the map
Finally I've got it compiling even with such code:
bot_globals.h Code:
#include <com_model.h> Code:
lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES]; Thanks again for the patience for me. :) |
Re: code to get the illumination at any point on the map
Good news :)
just a question: have you tried to compile the function "RecursiveLightPoint" with the keyword "static" instead of "extern"? I'm just wondering whether the code from my last post is working or not. 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) |
Re: code to get the illumination at any point on the map
Quote:
|
All times are GMT +2. The time now is 04:44. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.