View Single Post
Re: code to get the illumination at any point on the map
Old
  (#9)
Immortal_BLG
Member
 
Status: Offline
Posts: 171
Join Date: Nov 2007
Location: Russian Federation
Default Re: code to get the illumination at any point on the map - 27-02-2012

Hello KWo!

Quote:
Originally Posted by KWo
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.
Fairly I admit - I don't know why on LINUX function GetEntityIllum always returns 0 and also how to solve this problem, all that I can is to show code of function GetEntityIllum to you:
Code:
//----- (01D82AE0) --------------------------------------------------------
int GetEntityIllum (edict_t *const edict)
{
	if (edict == NULL)
		return -1;

	const unsigned int edictIndex (NUM_FOR_EDICT (edict));

	if (edictIndex <= svs.maxclients)
		return edict->v.light_level;	// player has more precision light level that come from client-side

	if (cls.state == 3/*! MAYBE 'ca_connected', BUT NOT SHURE!!! */ || cls.state == 4/*! MAYBE 'ca_active', BUT NOT SHURE!!! */ || cls.state == 5/*! @warning DON'T KNOW!!! */)
	{
		const colorVec &cvFloorColor (cl_entities[edictIndex].cvFloorColor);

		return (cvFloorColor.r + cvFloorColor.g + cvFloorColor.b) / 3u;
	}

	return 128;
}

And 'edict->v.light_level' is assigned approximately so:
edict->v.light_level = R_LightPoint (edict->v.origin);
Quote:
Originally Posted by KWo
did You check if Your code is working on both - linux and windows server?
The answer is no, because I do not have LINUX. However, I think that everything should work. The only thing I want to recommend - is to change line
Code:
assert (sv_worldmodel != NULL);
to
Code:
if (sv_worldmodel == NULL)
	return 0u;
in the beginning of function R_LightPoint() just in case.

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)
{
	static const bool isSoftwareDrawingMode (IS_DEDICATED_SERVER () || GetModuleHandle ("sw.dll") != NULL);

	return isSoftwareDrawingMode;
}
It is made that the client could play without crashing on software mode. Sorry forgot about it....
  
Reply With Quote