light: c++ify remaining files
This commit is contained in:
parent
34bc864616
commit
d225891ef5
|
|
@ -7,10 +7,10 @@ set(LIGHT_INCLUDES
|
|||
${CMAKE_SOURCE_DIR}/include/light/litfile.h)
|
||||
|
||||
set(LIGHT_SOURCES
|
||||
entities.c
|
||||
litfile.c
|
||||
ltface.c
|
||||
trace.c
|
||||
entities.cc
|
||||
litfile.cc
|
||||
ltface.cc
|
||||
trace.cc
|
||||
light.cc
|
||||
${CMAKE_SOURCE_DIR}/common/bspfile.c
|
||||
${CMAKE_SOURCE_DIR}/common/cmdlib.c
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ SetKeyValue(entity_t *ent, const char *key, const char *value)
|
|||
strcpy(ep->value, value);
|
||||
return;
|
||||
}
|
||||
ep = malloc(sizeof(*ep));
|
||||
ep = (epair_t *) malloc(sizeof(*ep));
|
||||
ep->next = ent->epairs;
|
||||
ent->epairs = ep;
|
||||
strcpy(ep->key, key);
|
||||
|
|
@ -306,7 +306,7 @@ Dirt_ResolveFlag(int dirtInt)
|
|||
static void
|
||||
AddSun(vec3_t sunvec, vec_t light, const vec3_t color, int dirtInt)
|
||||
{
|
||||
sun_t *sun = malloc(sizeof(sun_t));
|
||||
sun_t *sun = (sun_t *) malloc(sizeof(sun_t));
|
||||
memset(sun, 0, sizeof(*sun));
|
||||
VectorCopy(sunvec, sun->sunvec);
|
||||
VectorNormalize(sun->sunvec);
|
||||
|
|
@ -938,7 +938,7 @@ LoadEntities(const bsp2_t *bsp)
|
|||
logprint("lightmap_scale should be _lightmap_scale\n");
|
||||
}
|
||||
|
||||
epair = malloc(sizeof(epair_t));
|
||||
epair = (epair_t *) malloc(sizeof(epair_t));
|
||||
memset(epair, 0, sizeof(epair_t));
|
||||
strcpy(epair->key, key);
|
||||
strcpy(epair->value, com_token);
|
||||
|
|
@ -966,7 +966,7 @@ LoadEntities(const bsp2_t *bsp)
|
|||
else if (!strcmp(key, "wait"))
|
||||
entity->atten = atof(com_token);
|
||||
else if (!strcmp(key, "delay"))
|
||||
entity->formula = atoi(com_token);
|
||||
entity->formula = static_cast<light_formula_t>(atoi(com_token));
|
||||
else if (!strcmp(key, "mangle")) {
|
||||
if (!projangleknown)
|
||||
scan_vec3(projangle, com_token, key);
|
||||
|
|
@ -1443,7 +1443,7 @@ WriteEntitiesToString(bsp2_t *bsp)
|
|||
logprint("%i switchable light styles\n", numlighttargets);
|
||||
|
||||
bsp->entdatasize = Get_EntityStringSize(entities);
|
||||
bsp->dentdata = malloc(bsp->entdatasize);
|
||||
bsp->dentdata = (char *) malloc(bsp->entdatasize);
|
||||
if (!bsp->dentdata)
|
||||
Error("%s: allocation of %d bytes failed\n", __func__,
|
||||
bsp->entdatasize);
|
||||
|
|
@ -46,10 +46,10 @@ WriteLitFile(const bsp2_t *bsp, facesup_t *facesup, const char *filename, int ve
|
|||
if (version == 2)
|
||||
{
|
||||
unsigned int i, j;
|
||||
unsigned int *offsets = malloc(bsp->numfaces * sizeof(*offsets));
|
||||
unsigned short *extents = malloc(2*bsp->numfaces * sizeof(*extents));
|
||||
unsigned char *styles = malloc(4*bsp->numfaces * sizeof(*styles));
|
||||
unsigned char *shifts = malloc(bsp->numfaces * sizeof(*shifts));
|
||||
unsigned int *offsets = (unsigned int *) malloc(bsp->numfaces * sizeof(*offsets));
|
||||
unsigned short *extents = (unsigned short *) malloc(2*bsp->numfaces * sizeof(*extents));
|
||||
unsigned char *styles = (unsigned char *) malloc(4*bsp->numfaces * sizeof(*styles));
|
||||
unsigned char *shifts = (unsigned char *) malloc(bsp->numfaces * sizeof(*shifts));
|
||||
for (i = 0; i < bsp->numfaces; i++)
|
||||
{
|
||||
offsets[i] = LittleLong(facesup[i].lightofs);
|
||||
|
|
@ -679,8 +679,8 @@ CalcPoints(const modelinfo_t *modelinfo, const vec3_t offset, lightsurf_t *surf,
|
|||
|
||||
/* Allocate surf->points */
|
||||
surf->numpoints = surf->width * surf->height;
|
||||
surf->points = calloc(surf->numpoints, sizeof(vec3_t));
|
||||
surf->normals = calloc(surf->numpoints, sizeof(vec3_t));
|
||||
surf->points = (vec3_t *) calloc(surf->numpoints, sizeof(vec3_t));
|
||||
surf->normals = (vec3_t *) calloc(surf->numpoints, sizeof(vec3_t));
|
||||
surf->occluded = (bool *)calloc(surf->numpoints, sizeof(bool));
|
||||
|
||||
for (int t = 0; t < surf->height; t++) {
|
||||
|
|
@ -812,8 +812,8 @@ CalcPvs(const bsp2_t *bsp, lightsurf_t *lightsurf)
|
|||
if (!bsp->visdatasize) return;
|
||||
|
||||
// set lightsurf->pvs
|
||||
byte *pointpvs = calloc(pvssize, 1);
|
||||
lightsurf->pvs = calloc(pvssize, 1);
|
||||
byte *pointpvs = (byte *) calloc(pvssize, 1);
|
||||
lightsurf->pvs = (byte *) calloc(pvssize, 1);
|
||||
|
||||
for (int i = 0; i < lightsurf->numpoints; i++) {
|
||||
const bsp2_dleaf_t *leaf = Light_PointInLeaf (bsp, lightsurf->points[i]);
|
||||
|
|
@ -912,7 +912,7 @@ Lightsurf_Init(const modelinfo_t *modelinfo, const bsp2_dface_t *face,
|
|||
VectorAdd(lightsurf->origin, modelinfo->offset, lightsurf->origin);
|
||||
|
||||
/* Allocate occlusion array */
|
||||
lightsurf->occlusion = calloc(lightsurf->numpoints, sizeof(float));
|
||||
lightsurf->occlusion = (float *) calloc(lightsurf->numpoints, sizeof(float));
|
||||
|
||||
/* Setup vis data */
|
||||
CalcPvs(bsp, lightsurf);
|
||||
|
|
@ -955,7 +955,7 @@ Lightmap_ForStyle(lightmap_t *lightmaps, const int style, const lightsurf_t *lig
|
|||
|
||||
if (lightmap->samples == NULL) {
|
||||
/* first use of this lightmap, allocate the storage for it. */
|
||||
lightmap->samples = calloc(lightsurf->numpoints, sizeof(lightsample_t));
|
||||
lightmap->samples = (lightsample_t *) calloc(lightsurf->numpoints, sizeof(lightsample_t));
|
||||
} else {
|
||||
/* clear only the data that is going to be merged to it. there's no point clearing more */
|
||||
memset(lightmap->samples, 0, sizeof(*lightmap->samples)*lightsurf->numpoints);
|
||||
|
|
@ -1015,7 +1015,7 @@ Lightmap_Soften(lightmap_t *lightmap, const lightsurf_t *lightsurf)
|
|||
const int height = (lightsurf->texsize[1] + 1) * oversample;
|
||||
const int fullsamples = (2 * softsamples + 1) * (2 * softsamples + 1);
|
||||
|
||||
softmap = calloc(lightsurf->numpoints, sizeof(lightsample_t));
|
||||
softmap = (lightsample_t *) calloc(lightsurf->numpoints, sizeof(lightsample_t));
|
||||
|
||||
dst = softmap;
|
||||
for (i = 0; i < lightsurf->numpoints; i++, dst++) {
|
||||
|
|
@ -2254,7 +2254,7 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo,
|
|||
for (j = 0; j < lightsurf->numpoints; j++) {
|
||||
int palidx = SampleTexture(face, bsp, lightsurf->points[j]);
|
||||
if (palidx >= 0) {
|
||||
vec3_t texcolor = {thepalette[3*palidx], thepalette[3*palidx + 1], thepalette[3*palidx + 2]};
|
||||
vec3_t texcolor = {static_cast<float>(thepalette[3*palidx]), static_cast<float>(thepalette[3*palidx + 1]), static_cast<float>(thepalette[3*palidx + 2])};
|
||||
VectorAdd(lightsurf->texturecolor, texcolor, lightsurf->texturecolor);
|
||||
}
|
||||
}
|
||||
|
|
@ -248,7 +248,7 @@ void
|
|||
MakeFaceInfo(const bsp2_t *bsp, const bsp2_dface_t *face, faceinfo_t *info)
|
||||
{
|
||||
info->numedges = face->numedges;
|
||||
info->edgeplanes = calloc(face->numedges, sizeof(plane_t));
|
||||
info->edgeplanes = (plane_t *) calloc(face->numedges, sizeof(plane_t));
|
||||
|
||||
GetFaceNormal(bsp, face, &info->plane);
|
||||
|
||||
|
|
@ -319,7 +319,7 @@ Model_HasFence(const bsp2_t *bsp, const dmodel_t *model)
|
|||
static void
|
||||
MakeFenceInfo(const bsp2_t *bsp)
|
||||
{
|
||||
fence_dmodels = calloc(bsp->nummodels, sizeof(bool));
|
||||
fence_dmodels = (bool *) calloc(bsp->nummodels, sizeof(bool));
|
||||
for (int i = 0; i < bsp->nummodels; i++) {
|
||||
fence_dmodels[i] = Model_HasFence(bsp, &bsp->dmodels[i]);
|
||||
}
|
||||
|
|
@ -329,11 +329,11 @@ void
|
|||
BSP_MakeTnodes(const bsp2_t *bsp)
|
||||
{
|
||||
bsp_static = bsp;
|
||||
tnode_p = tnodes = malloc(bsp->numnodes * sizeof(tnode_t));
|
||||
tnode_p = tnodes = (tnode_t *) malloc(bsp->numnodes * sizeof(tnode_t));
|
||||
for (int i = 0; i < bsp->nummodels; i++)
|
||||
MakeTnodes_r(bsp->dmodels[i].headnode[0], bsp);
|
||||
|
||||
faceinfos = malloc(bsp->numfaces * sizeof(faceinfo_t));
|
||||
faceinfos = (faceinfo_t *) malloc(bsp->numfaces * sizeof(faceinfo_t));
|
||||
for (int i = 0; i < bsp->numfaces; i++)
|
||||
MakeFaceInfo(bsp, &bsp->dfaces[i], &faceinfos[i]);
|
||||
|
||||
Loading…
Reference in New Issue