// fill out all slots with notexture
for (i = 0, tx = loadmodel->data_textures;i < loadmodel->num_textures;i++, tx++)
{
- strcpy(tx->name, "NO TEXTURE FOUND");
+ strlcpy(tx->name, "NO TEXTURE FOUND", sizeof(tx->name));
tx->width = 16;
tx->height = 16;
tx->skin.base = r_texture_notexture;
name[j] += 'a' - 'A';
tx = loadmodel->data_textures + i;
- strcpy(tx->name, name);
+ strlcpy(tx->name, name, sizeof(tx->name));
tx->width = mtwidth;
tx->height = mtheight;
int i, j, k;
if (!data)
return;
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
return; // error
if (com_token[0] != '{')
return; // error
while (1)
{
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
return; // error
if (com_token[0] == '}')
break; // end of worldspawn
if (com_token[0] == '_')
- strcpy(key, com_token + 1);
+ strlcpy(key, com_token + 1, sizeof(key));
else
- strcpy(key, com_token);
+ strlcpy(key, com_token, sizeof(key));
while (key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
return; // error
dpsnprintf(value, sizeof(value), "%s", com_token);
if (!strcmp("wad", key)) // for HalfLife maps
{
k = value[i];
value[i] = 0;
- strcpy(wadname, "textures/");
- strcat(wadname, &value[j]);
+ strlcpy(wadname, "textures/", sizeof(wadname));
+ strlcat(wadname, &value[j], sizeof(wadname));
W_LoadTextureWadFile(wadname, false);
j = i+1;
if (!k)
if (!maptext)
return;
text = maptext;
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
return; // error
submodel = 0;
for (;;)
{
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
break;
if (com_token[0] != '{')
return; // error
brushes = Mem_Alloc(loadmodel->mempool, maxbrushes * sizeof(mbrush_t));
for (;;)
{
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
return; // error
if (com_token[0] == '}')
break; // end of entity
}
for (;;)
{
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
return; // error
if (com_token[0] == '}')
break; // end of brush
// FIXME: support hl .map format
for (pointnum = 0;pointnum < 3;pointnum++)
{
- COM_ParseToken(&data, false);
+ COM_ParseTokenConsole(&data);
for (componentnum = 0;componentnum < 3;componentnum++)
{
- COM_ParseToken(&data, false);
+ COM_ParseTokenConsole(&data);
point[pointnum][componentnum] = atof(com_token);
}
- COM_ParseToken(&data, false);
+ COM_ParseTokenConsole(&data);
}
- COM_ParseToken(&data, false);
+ COM_ParseTokenConsole(&data);
strlcpy(facetexture, com_token, sizeof(facetexture));
- COM_ParseToken(&data, false);
+ COM_ParseTokenConsole(&data);
//scroll_s = atof(com_token);
- COM_ParseToken(&data, false);
+ COM_ParseTokenConsole(&data);
//scroll_t = atof(com_token);
- COM_ParseToken(&data, false);
+ COM_ParseTokenConsole(&data);
//rotate = atof(com_token);
- COM_ParseToken(&data, false);
+ COM_ParseTokenConsole(&data);
//scale_s = atof(com_token);
- COM_ParseToken(&data, false);
+ COM_ParseTokenConsole(&data);
//scale_t = atof(com_token);
TriangleNormal(point[0], point[1], point[2], planenormal);
VectorNormalizeDouble(planenormal);
}
}
+#define PORTAL_DIST_EPSILON (1.0 / 32.0)
static void Mod_Q1BSP_RecursiveNodePortals(mnode_t *node)
{
int i, side;
nodeportal = AllocPortal();
nodeportal->plane = *plane;
+ // TODO: calculate node bounding boxes during recursion and calculate a maximum plane size accordingly to improve precision (as most maps do not need 1 billion unit plane polygons)
PolygonD_QuadForPlane(nodeportal->points, nodeportal->plane.normal[0], nodeportal->plane.normal[1], nodeportal->plane.normal[2], nodeportal->plane.dist, 1024.0*1024.0*1024.0);
nodeportal->numpoints = 4;
side = 0; // shut up compiler warning
for (i = 0;i < nodeportal->numpoints*3;i++)
frontpoints[i] = nodeportal->points[i];
- PolygonD_Divide(nodeportal->numpoints, frontpoints, clipplane.normal[0], clipplane.normal[1], clipplane.normal[2], clipplane.dist, 1.0/32.0, MAX_PORTALPOINTS, nodeportal->points, &nodeportal->numpoints, 0, NULL, NULL, NULL);
+ PolygonD_Divide(nodeportal->numpoints, frontpoints, clipplane.normal[0], clipplane.normal[1], clipplane.normal[2], clipplane.dist, PORTAL_DIST_EPSILON, MAX_PORTALPOINTS, nodeportal->points, &nodeportal->numpoints, 0, NULL, NULL, NULL);
if (nodeportal->numpoints <= 0 || nodeportal->numpoints >= MAX_PORTALPOINTS)
break;
}
RemovePortalFromNodes(portal);
// cut the portal into two portals, one on each side of the node plane
- PolygonD_Divide(portal->numpoints, portal->points, plane->normal[0], plane->normal[1], plane->normal[2], plane->dist, 1.0/32.0, MAX_PORTALPOINTS, frontpoints, &numfrontpoints, MAX_PORTALPOINTS, backpoints, &numbackpoints, NULL);
+ PolygonD_Divide(portal->numpoints, portal->points, plane->normal[0], plane->normal[1], plane->normal[2], plane->dist, PORTAL_DIST_EPSILON, MAX_PORTALPOINTS, frontpoints, &numfrontpoints, MAX_PORTALPOINTS, backpoints, &numbackpoints, NULL);
if (!numfrontpoints)
{
// copy the base model to this one
*mod = *loadmodel;
// rename the clone back to its proper name
- strcpy(mod->name, name);
+ strlcpy(mod->name, name, sizeof(mod->name));
// textures and memory belong to the main model
mod->texturepool = NULL;
mod->mempool = NULL;
memcpy(loadmodel->brush.entities, mod_base + l->fileofs, l->filelen);
data = loadmodel->brush.entities;
// some Q3 maps override the lightgrid_cellsize with a worldspawn key
- if (data && COM_ParseToken(&data, false) && com_token[0] == '{')
+ if (data && COM_ParseTokenConsole(&data) && com_token[0] == '{')
{
while (1)
{
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
break; // error
if (com_token[0] == '}')
break; // end of worldspawn
if (com_token[0] == '_')
- strcpy(key, com_token + 1);
+ strlcpy(key, com_token + 1, sizeof(key));
else
- strcpy(key, com_token);
+ strlcpy(key, com_token, sizeof(key));
while (key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
- if (!COM_ParseToken(&data, false))
+ if (!COM_ParseTokenConsole(&data))
break; // error
- strcpy(value, com_token);
+ strlcpy(value, com_token, sizeof(value));
if (!strcmp("gridsize", key))
{
if (sscanf(value, "%f %f %f", &v[0], &v[1], &v[2]) == 3 && v[0] != 0 && v[1] != 0 && v[2] != 0)
shader->surfaceparms |= Q3SURFACEPARM_ALPHASHADOW;
else if (!strcasecmp(parameter[1], "areaportal"))
shader->surfaceparms |= Q3SURFACEPARM_AREAPORTAL;
+ else if (!strcasecmp(parameter[1], "botclip"))
+ shader->surfaceparms |= Q3SURFACEPARM_BOTCLIP;
else if (!strcasecmp(parameter[1], "clusterportal"))
shader->surfaceparms |= Q3SURFACEPARM_CLUSTERPORTAL;
else if (!strcasecmp(parameter[1], "detail"))
shader->surfaceparms |= Q3SURFACEPARM_DETAIL;
else if (!strcasecmp(parameter[1], "donotenter"))
shader->surfaceparms |= Q3SURFACEPARM_DONOTENTER;
+ else if (!strcasecmp(parameter[1], "dust"))
+ shader->surfaceparms |= Q3SURFACEPARM_DUST;
+ else if (!strcasecmp(parameter[1], "hint"))
+ shader->surfaceparms |= Q3SURFACEPARM_HINT;
else if (!strcasecmp(parameter[1], "fog"))
shader->surfaceparms |= Q3SURFACEPARM_FOG;
else if (!strcasecmp(parameter[1], "lava"))
shader->surfaceparms |= Q3SURFACEPARM_LAVA;
else if (!strcasecmp(parameter[1], "lightfilter"))
shader->surfaceparms |= Q3SURFACEPARM_LIGHTFILTER;
+ else if (!strcasecmp(parameter[1], "lightgrid"))
+ shader->surfaceparms |= Q3SURFACEPARM_LIGHTGRID;
else if (!strcasecmp(parameter[1], "metalsteps"))
shader->surfaceparms |= Q3SURFACEPARM_METALSTEPS;
else if (!strcasecmp(parameter[1], "nodamage"))
sprintf(name, "*%i", i);
mod = Mod_FindName(name);
*mod = *loadmodel;
- strcpy(mod->name, name);
+ strlcpy(mod->name, name, sizeof(mod->name));
// textures and memory belong to the main model
mod->texturepool = NULL;
mod->mempool = NULL;