Fixed realloc causing segfault (it wasn't realloc)

This commit is contained in:
Carlos Sanchez 2024-09-18 23:11:15 -04:00
parent c0f1685cbb
commit ff826b1806

View File

@ -43,7 +43,7 @@
#define INIT_MINLIGHT 0.2 #define INIT_MINLIGHT 0.2
#define INIT_PLAYERSPEED \ #define INIT_PLAYERSPEED \
{ .x = 0, .y = 0, .z = -0.5 } { .x = 0, .y = 0, .z = -40.5 }
// Some globals you can mess around with potentially // Some globals you can mess around with potentially
int fps = 60; int fps = 60;
@ -65,7 +65,9 @@ void gen_terrain(struct vec3i pos, haloo3d_obj *model) {
// Don't allow the model to have more than some amount of faces/vertices. // Don't allow the model to have more than some amount of faces/vertices.
haloo3d_obj_resetfixed(model, CHUNKSIZE * CHUNKSIZE * 4, haloo3d_obj_resetfixed(model, CHUNKSIZE * CHUNKSIZE * 4,
CHUNKSIZE * CHUNKSIZE * 4); CHUNKSIZE * CHUNKSIZE * 4);
// Generate the "ocean" floor // Generate the "ocean" floor.
// TODO: You need to change this to be a large plane that follows the player
// so you can use lighting on the islands but not on the water
// haloo3d_gen_paletteuv(0xF26F, model->vtexture[model->numvtextures++].v); // haloo3d_gen_paletteuv(0xF26F, model->vtexture[model->numvtextures++].v);
struct vec3 seacol = haloo3d_gen_paletteuv(0xF000 | (rand() & 0xFFF)); struct vec3 seacol = haloo3d_gen_paletteuv(0xF000 | (rand() & 0xFFF));
int seauv = haloo3d_obj_addvtexture(model, seacol); int seauv = haloo3d_obj_addvtexture(model, seacol);
@ -83,8 +85,7 @@ void gen_terrain(struct vec3i pos, haloo3d_obj *model) {
haloo3d_obj_addface(model, face); haloo3d_obj_addface(model, face);
fastface(face, seauv, br, tr, tl); fastface(face, seauv, br, tr, tl);
haloo3d_obj_addface(model, face); haloo3d_obj_addface(model, face);
model->numfaces += 2; haloo3d_obj_shrinktofit(model);
// haloo3d_obj_shrinktofit(model);
} }
// Generate the entity/components/terrain for the chunk at the given // Generate the entity/components/terrain for the chunk at the given