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
{
//extern const mplane_t *lightplane (NULL);
//extern Vector lightspot;
extern Color g_pointColor;
// extern const bool RecursiveLightPoint (const nodeType *const node, const Vector &start, const Vector &end);
// Color g_pointColor;
//
template <typename nodeType, typename surfaceType>extern const bool RecursiveLightPoint (const nodeType *const node, const Vector &start, const Vector &end)
{
float front, back, frac;
int side;
mplane_t *plane;
Vector mid;
surfaceType *surf;
int s, t, ds, dt;
int i;
mtexinfo_t *tex;
color24 *lightmap;
unsigned int scale;
unsigned char maps;
// Reliability check.
assert (node != NULL);
if (node->contents < 0)
return false; // didn't hit anything
// Determine which side of the node plane our points are on
// FIXME: optimize for axial
plane = node->plane;
front = DotProduct (start, plane->normal) - plane->dist;
back = DotProduct (end, plane->normal) - plane->dist;
side = front < 0.0f;
// If they're both on the same side of the plane, don't bother to split just check the appropriate child
if ((back < 0.0f) == side)
return RecursiveLightPoint <nodeType, surfaceType> (reinterpret_cast <nodeType *> (node->children[side]), start, end);
// calculate mid point
frac = front / (front - back);
mid = start + (end - start) * frac;
// go down front side
if (RecursiveLightPoint <nodeType, surfaceType> (reinterpret_cast <nodeType *> (node->children[side]), start, mid))
return true; // hit something
// Blow it off if it doesn't split the plane...
if ((back < 0.0f) == side)
return false; // didn't hit anything
// check for impact on this node
// lightspot = mid;
// lightplane = plane;
surf = reinterpret_cast <surfaceType *> (sv_worldmodel->surfaces) + node->firstsurface;
for (i = 0; i < node->numsurfaces; ++i, ++surf)
{
if (surf->flags & SURF_DRAWTILED)
continue; // no lightmaps
tex = surf->texinfo;
// See where in lightmap space our intersection point is
s = static_cast <int> (DotProduct (mid, Vector (tex->vecs[0])) + tex->vecs[0][3]);
t = static_cast <int> (DotProduct (mid, Vector (tex->vecs[1])) + tex->vecs[1][3]);
// Not in the bounds of our lightmap? punt...
if (s < surf->texturemins[0] || t < surf->texturemins[1])
continue;
// assuming a square lightmap (FIXME: which ain't always the case),
// lets see if it lies in that rectangle. If not, punt...
ds = s - surf->texturemins[0];
dt = t - surf->texturemins[1];
if (ds > surf->extents[0] || dt > surf->extents[1])
continue;
if (surf->samples == NULL)
return true;
ds >>= 4;
dt >>= 4;
g_pointColor.Reset (); // Reset point color.
const int smax ((surf->extents[0] >> 4) + 1);
const int tmax ((surf->extents[1] >> 4) + 1);
const int size (smax * tmax);
lightmap = surf->samples + dt * smax + ds;
// Compute the lightmap color at a particular point
for (maps = 0u; maps < MAXLIGHTMAPS && surf->styles[maps] != 255u; ++maps)
{
scale = d_lightstylevalue[surf->styles[maps]];
g_pointColor.red += lightmap->r * scale;
g_pointColor.green += lightmap->g * scale;
g_pointColor.blue += lightmap->b * scale;
lightmap += size; // skip to next lightmap
}
g_pointColor.red >>= 8u;
g_pointColor.green >>= 8u;
g_pointColor.blue >>= 8u;
return true;
}
// go down back side
return RecursiveLightPoint <nodeType, surfaceType> (reinterpret_cast <nodeType *> (node->children[!side]), mid, 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 ());
}
}
#endif
The line 235 from bot_globals.cpp looks so:
Code:
235: const bool Light::RecursiveLightPoint (const nodeType *const node, const Vector &start, const Vector &end);
236: Color Light::g_pointColor;
I need still some help with this.