Skip to content

Commit

Permalink
huge unused code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
computermouth committed Oct 31, 2023
1 parent 748dfa0 commit 8d2259c
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 343 deletions.
2 changes: 1 addition & 1 deletion c1k3-assets
Submodule c1k3-assets updated 1 files
+13 −13 Makefile
169 changes: 0 additions & 169 deletions data.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,172 +75,3 @@ const uint32_t data_map1_len = blend_map1_map_len;

const uint8_t * data_map3 = blend_map3_map;
const uint32_t data_map3_len = blend_map3_map_len;

#include "models.h"

const uint8_t * data_models = models;
const uint32_t data_models_len = models_len;

#include "0.h"
#include "1.h"
#include "2.h"
#include "3.h"
#include "4.h"
#include "5.h"
#include "6.h"
#include "7.h"
#include "8.h"
#include "9.h"
#include "10.h"
#include "11.h"
#include "12.h"
#include "13.h"
#include "14.h"
#include "15.h"
#include "16.h"
#include "17.h"
#include "18.h"
#include "19.h"
#include "20.h"
#include "21.h"
#include "22.h"
#include "23.h"
#include "24.h"
#include "25.h"
#include "26.h"
#include "27.h"
#include "28.h"
#include "29.h"
#include "30.h"

#define TEXLEN 31

const png_bin_t __alltex[TEXLEN] = {
{
.data = img_0_png,
.len = img_0_png_len,
},
{
.data = img_1_png,
.len = img_1_png_len,
},
{
.data = img_2_png,
.len = img_2_png_len,
},
{
.data = img_3_png,
.len = img_3_png_len,
},
{
.data = img_4_png,
.len = img_4_png_len,
},
{
.data = img_5_png,
.len = img_5_png_len,
},
{
.data = img_6_png,
.len = img_6_png_len,
},
{
.data = img_7_png,
.len = img_7_png_len,
},
{
.data = img_8_png,
.len = img_8_png_len,
},
{
.data = img_9_png,
.len = img_9_png_len,
},
{
.data = img_10_png,
.len = img_10_png_len,
},
{
.data = img_11_png,
.len = img_11_png_len,
},
{
.data = img_12_png,
.len = img_12_png_len,
},
{
.data = img_13_png,
.len = img_13_png_len,
},
{
.data = img_14_png,
.len = img_14_png_len,
},
{
.data = img_15_png,
.len = img_15_png_len,
},
{
.data = img_16_png,
.len = img_16_png_len,
},
{
.data = img_17_png,
.len = img_17_png_len,
},
{
.data = img_18_png,
.len = img_18_png_len,
},
{
.data = img_19_png,
.len = img_19_png_len,
},
{
.data = img_20_png,
.len = img_20_png_len,
},
{
.data = img_21_png,
.len = img_21_png_len,
},
{
.data = img_22_png,
.len = img_22_png_len,
},
{
.data = img_23_png,
.len = img_23_png_len,
},
{
.data = img_24_png,
.len = img_24_png_len,
},
{
.data = img_25_png,
.len = img_25_png_len,
},
{
.data = img_26_png,
.len = img_26_png_len,
},
{
.data = img_27_png,
.len = img_27_png_len,
},
{
.data = img_28_png,
.len = img_28_png_len,
},
{
.data = img_29_png,
.len = img_29_png_len,
},
{
.data = img_30_png,
.len = img_30_png_len,
}
};

const png_bin_t * data_textures = __alltex;
const uint32_t data_textures_len = TEXLEN;
11 changes: 0 additions & 11 deletions data.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@

#include <stdint.h>

typedef struct {
uint8_t * data;
uint64_t len;
} png_bin_t;

extern const png_bin_t * data_textures;
extern const uint32_t data_textures_len;

extern const uint8_t * data_models;
extern const uint32_t data_models_len;

extern const uint8_t * data_map1;
extern const uint32_t data_map1_len;

Expand Down
6 changes: 3 additions & 3 deletions entity_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ void entity_player_update(entity_t * e) {
.yaw = e->_yaw + PI / 2.0f,
.pitch = e->_pitch,
.texture = weapon->_texture,
.f1 = weapon->_model->frames[0],
.f2 = weapon->_model->frames[0],
.f1 = weapon->_model.frames[0],
.f2 = weapon->_model.frames[0],
.mix = 0,
.num_verts = weapon->_model->nv
.num_verts = weapon->_model.nv
};

r_draw(d);
Expand Down
4 changes: 0 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ void game_load() {
r_init();
map_init();

for(int i = 0; i < data_textures_len; i++)
r_create_texture(data_textures[i]);

// Load map & model containers
map_parse();
model_parse();

// todo, parse all maps? or parse first map??
// mpack_map_parse((char *)data_map1, data_map1_len);
Expand Down
86 changes: 0 additions & 86 deletions model.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,6 @@
#include "render.h"
#include "vector.h"

vector * model_data = NULL;
// todo, change all these to pointers,
// raise memory management to a higher level
// Q
model_t model_q = { 0 };
// Particles
model_t model_explosion = {0};
model_t model_blood = {0};
model_t model_gib = {0};
vector * model_gib_pieces = NULL;
// Enemies
model_t model_grunt = {0};
model_t model_enforcer = {0};
model_t model_ogre = {0};
model_t model_zombie = {0};
model_t model_hound = {0};
// Map Objects
model_t model_barrel = {0};
model_t model_torch = {0};
// Weapon view models
model_t model_shotgun = {0};
model_t model_nailgun = {0};
model_t model_grenadelauncher = {0};
// Pickups
model_t model_pickup_nailgun = {0};
model_t model_pickup_grenadelauncher = {0};
model_t model_pickup_box = {0};
model_t model_pickup_grenades = {0};
model_t model_pickup_key = {0};
model_t model_door = {0};
// Projectiles
model_t model_grenade = {0};
model_t model_nail = {0}; // aka. nail
model_t model_plasma = {0}; // aka. nail

void model_parse() {

model_data = vector_init(sizeof(model_t));
model_gib_pieces = vector_init(sizeof(model_t));

const uint8_t * data = data_models;

for (uint32_t i = 0; i < data_models_len;) {
// let model_size = num_frames * num_verts * 3 + num_indices * 3
uint32_t model_size = (data[i] * data[i+1] + data[i+2]) * 3;
i += 3;
vector_push(model_data, &(model_t) {
.data = (uint8_t *)(data + (i - 3)),
.data_len = model_size,
});
i += model_size;
}
}

// todo, return different type, like entity_model/parsed_model
model_t model_load(uint8_t * data, vec3_t scale) {
uint32_t j = 0;
Expand Down Expand Up @@ -204,37 +150,5 @@ vector * model_load_ng(void * void_verts, uint32_t frame_len, uint32_t vert_len,
}

void model_quit() {

// todo, do these in map_quit once everything's sorted
if (model_q.frames) free(model_q.frames);
if (model_explosion.frames) free(model_explosion.frames);
if (model_blood.frames) free(model_blood.frames);
if (model_gib.frames) free(model_gib.frames);
// if (model_grunt.frames) free(model_grunt.frames);
if (model_enforcer.frames) free(model_enforcer.frames);
if (model_zombie.frames) free(model_zombie.frames);
if (model_ogre.frames) free(model_ogre.frames);
if (model_hound.frames) free(model_hound.frames);
if (model_barrel.frames) free(model_barrel.frames);
if (model_torch.frames) free(model_torch.frames);
// if (model_shotgun.frames) free(model_shotgun.frames);
// if (model_nailgun.frames) free(model_nailgun.frames);
// if (model_grenadelauncher.frames) free(model_grenadelauncher.frames);
// if (model_pickup_nailgun.frames) free(model_pickup_nailgun.frames);
// if (model_pickup_grenadelauncher.frames) free(model_pickup_grenadelauncher.frames);
if (model_pickup_box.frames) free(model_pickup_box.frames);
if (model_pickup_grenades.frames) free(model_pickup_grenades.frames);
if (model_pickup_key.frames) free(model_pickup_key.frames);
// if (model_door.frames) free(model_door.frames);
if (model_grenade.frames) free(model_grenade.frames);
if (model_nail.frames) free(model_nail.frames);

uint32_t len = vector_size(model_gib_pieces);
for(uint32_t i = 0; i < len; i++) {
model_t * m = vector_at(model_gib_pieces, i);
free(m->frames);
}
vector_free(model_gib_pieces);

vector_free(model_data);
}
33 changes: 0 additions & 33 deletions model.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,6 @@ typedef struct {
uint32_t nv;
} model_ng_t;

extern vector * model_data;
extern model_t model_q;
// Particles
extern model_t model_explosion;
extern model_t model_blood;
extern model_t model_gib;
extern vector * model_gib_pieces;
// Enemies
extern model_t model_grunt;
extern model_t model_enforcer;
extern model_t model_ogre;
extern model_t model_zombie;
extern model_t model_hound;
// Map Objects
extern model_t model_barrel;
extern model_t model_torch;
// Weapon view models
extern model_t model_shotgun;
extern model_t model_nailgun;
extern model_t model_grenadelauncher;
// Pickups
extern model_t model_pickup_nailgun;
extern model_t model_pickup_grenadelauncher;
extern model_t model_pickup_box;
extern model_t model_pickup_grenades;
extern model_t model_pickup_key;
extern model_t model_door;
// Projectiles
extern model_t model_grenade;
extern model_t model_nail; // aka. nail
extern model_t model_plasma; // aka. nail

void model_parse();
model_t model_load(uint8_t * data, vec3_t scale);
vector * model_load_ng(void * void_verts, uint32_t frame_len, uint32_t vert_len, float * u, float * v);
void model_quit();
Expand Down
5 changes: 5 additions & 0 deletions render.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ typedef struct {
uint32_t height;
} meta_tex_t;

typedef struct {
uint8_t * data;
uint64_t len;
} png_bin_t;

// to free on quit
extern vector * r_draw_calls;
extern vector * r_textures;
Expand Down
Loading

0 comments on commit 8d2259c

Please sign in to comment.