Fix seg faults when loading gameobjects

This commit is contained in:
2022-08-16 04:46:06 +00:00
parent 4f0a59f581
commit 7aef7afc90
5 changed files with 35 additions and 33 deletions

View File

@@ -7,7 +7,7 @@
void save_level(char name[MAXNAME])
{
FILE *lfile = res_open(name, "w+");
FILE *lfile = res_open(name, "wb+");
if (!lfile) return;
@@ -24,7 +24,7 @@ void save_level(char name[MAXNAME])
void load_level(char name[MAXNAME])
{
FILE *lfile = fopen(name, "r");
FILE *lfile = fopen(name, "rb");
if (!lfile) return;
@@ -38,6 +38,7 @@ void load_level(char name[MAXNAME])
for (int i = 0; i < objs; i++) {
struct mGameObject *go = vec_add(gameobjects, NULL);
fread(go, sizeof(struct mGameObject), 1, lfile);
go->components = vec_make(1,1);
gameobject_init(go, lfile);
}