Code:
// rendergl.cpp: core opengl rendering stuff
#include "engine.h"
#include "game.h" // added to define most stuff and for the namespaces
bool hasVBO = false, hasDRE = false, hasOQ = false, hasTR = false, hasFBO = false, hasDS = false, hasTF = false, hasBE = false, hasBC = false, hasCM = false, hasNP2 = false, hasTC = false, hasTE = false, hasMT = false, hasD3 = false, hasAF = false, hasVP2 = false, hasVP3 = false, hasPP = false, hasMDA = false, hasTE3 = false, hasTE4 = false, hasVP = false, hasFP = false, hasGLSL = false, hasGM = false, hasNVFB = false, hasSGIDT = false, hasSGISH = false, hasDT = false, hasSH = false, hasNVPCF = false, hasRN = false, hasPBO = false, hasFBB = false, hasUBO = false, hasBUE = false, hasFC = false, hasTEX = false;
int hasstencil = 0;
int lasttarget = -1; //part of the aimbot
float lastdist = 0.0f;//part of the aimbot
VAR(renderpath, 1, 0, 0);
#define MINBORD 2 //mod
#define OUTBORD(x,y) ((x)<MINBORD || (y)<MINBORD || (x)>=ssize-MINBORD || (y)>=ssize-MINBORD) //mod
struct traceresult_s // pulled from AssaultCube
{
vec end;
bool collided;
};
void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult_s *tr, // pulled from AssaultCube, but being modded to fit into Sauerbraten
bool SkipTags) //
{
using entities::ents; // namespace entities in game.h (mod)
int ssize; // declares ssize (mod)
tr->end = from;
tr->collided = false;
static float flNearestDist, flDist;
static vec v;
static bool solid;
flNearestDist = 9999.0f;
if(OUTBORD((int)from.x, (int)from.y)) return;
// Check if the 'line' collides with entities like mapmodels
loopv(ents)
{
entity &e = ents[i]; // CAUSES ERROR
if(e.type!=MAPMODEL) continue; // Only check map models for now
mapmodelinfo &mmi = getmminfo(e.attr2);
if(!&mmi || !mmi.h) continue;
float lo = (float)(S(e.x, e.y)->floor+mmi.zoff+e.attr3);
float hi = lo+mmi.h;
float z = (fabs(from.z-lo) < fabs(from.z-hi)) ? lo : hi;
makevec(&v, e.x, e.y, z);
flDist = GetDistance(from, v);
if ((flDist < flNearestDist) && (intersect(&e, from, to, &tr->end)))
{
flNearestDist = GetDistance(from, tr->end);
tr->collided = true;
}
}
if (CheckPlayers)
{
// Check if the 'line' collides with players
loopv(players)
{
playerent *d = players[i];
if(!d || (d==pTracer) || (d->state != CS_ALIVE)) continue; // Only check valid players
flDist = GetDistance(from, d->o);
if ((flDist < flNearestDist) && (intersect(d, from, to, &tr->end)))
{
flNearestDist = flDist;
tr->collided = true;
}
}
// Check if the 'line' collides with the local player(player1)
playerent *d = player1; // Shortcut
if (d && (d!=pTracer) && !BotManager.m_pBotToView && (d->state == CS_ALIVE))
{
flDist = GetDistance(from, d->o);
if ((flDist < flNearestDist) && (intersect(d, from, to, &tr->end)))
{
flNearestDist = flDist;
tr->collided = true;
}
}
}
float dx = to.x-from.x;
float dy = to.y-from.y;
int steps = (int)(sqrt(dx*dx+dy*dy)/0.9);
if(!steps) // If from and to are on the same cube...
{
if (GetDistance(from, to) < flNearestDist)
{
tr->end = to;
sqr *s = S(int(from.x), int(from.y));
float flr = GetCubeFloor(int(from.x), int(from.y));
solid = ((!SkipTags || !s->tag) && SOLID(s));
if (solid || (to.z < flr) || (to.z > s->ceil))
{
tr->collided = true;
tr->end.z = (fabs(to.z-s->ceil) < fabs(to.z-flr)) ? s->ceil : flr;
}
}
return;
}
float x = from.x;
float y = from.y;
int i = 0;
vec endcube = from;
// Now check if the 'line' is hit by a cube
while(i<steps)
{
if(OUTBORD((int)x, (int)y)) break;
if (GetDistance(from, endcube) >= flNearestDist) break;
sqr *s = S(int(x), int(y));
solid = ((!SkipTags || !s->tag) && SOLID(s));
if(solid) break;
float floor = s->floor;
if(s->type==FHF) floor -= s->vdelta/4.0f;
float ceil = s->ceil;
if(s->type==CHF) ceil += s->vdelta/4.0f;
float rz = from.z-((from.z-to.z)*(i/(float)steps));
if(rz<floor || rz>ceil) break;
endcube.x = x;
endcube.y = y;
endcube.z = rz;
x += dx/(float)steps;
y += dy/(float)steps;
i++;
}
if ((i>=steps) && !tr->collided)
{
tr->end = to;
}
else
{
tr->collided = true;
if (GetDistance(from, endcube) < flNearestDist)
tr->end = endcube;
}
return;
}
However, when I try to compile it, I get this: