Fix bug on game's structure declaration

This commit is contained in:
Shadow15510 2022-07-05 16:02:37 +02:00
parent e495ee83e7
commit 0a648cea10
3 changed files with 24 additions and 12 deletions

View File

@ -6,6 +6,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include "core.h"
@ -20,7 +21,7 @@ int callback_tick(volatile int *tick)
void default_values(struct calccity *calccity, struct camera *camera, struct map *map)
{
srand(20211104);
srand(clock());
// Initialisation of struct calccity
memset(calccity, 0, sizeof *calccity);

View File

@ -8,20 +8,31 @@ int main(void)
{
extern font_t font_calccity;
dfont(&font_calccity);
title_screen();
// Game initialisation
struct calccity calccity;
struct camera camera;
struct map map;
gint_world_switch(GINT_CALL(read_save, (void *)&calccity, (void *)&camera, (void *)&map));
struct calccity *calccity;
calccity = (struct calccity*) malloc(sizeof *calccity);
// Game
main_loop(&calccity, &camera, &map);
struct camera *camera;
camera = (struct camera*) malloc(sizeof *camera);
struct map *map;
map = (struct map*) malloc(sizeof *map);
// Loading save
gint_world_switch(GINT_CALL(read_save, (void *)calccity, (void *)camera, (void *)map));
// Launch the game
main_loop(calccity, camera, map);
// Backup data
gint_world_switch(GINT_CALL(write_save, (void *)&calccity, (void *)&camera, (void *)&map));
gint_world_switch(GINT_CALL(write_save, (void *)calccity, (void *)camera, (void *)map));
// Free memory
free(calccity);
free(camera);
free(map);
return 1;
}

View File

@ -9,7 +9,7 @@ uint16_t const *filename_u16 = u"\\\\fls0\\CalcCity.sav";
void read_save(struct calccity *calccity, struct camera *camera, struct map *map)
{
if(gint[HWCALC] == HWCALC_G35PE2)
if (gint[HWCALC] == HWCALC_G35PE2)
{
FILE *fp;
fp = fopen(filename_u8, "rb");
@ -29,7 +29,7 @@ void read_save(struct calccity *calccity, struct camera *camera, struct map *map
else
{
int fd = BFile_Open(filename_u16, BFile_ReadOnly);
if(fd < 0)
if (fd < 0)
default_values(calccity, camera, map);
else
{
@ -44,7 +44,7 @@ void read_save(struct calccity *calccity, struct camera *camera, struct map *map
void write_save(const struct calccity *calccity, const struct camera *camera, const struct map *map)
{
if(gint[HWCALC] == HWCALC_G35PE2)
if (gint[HWCALC] == HWCALC_G35PE2)
{
FILE *fp;
fp = fopen(filename_u8, "wb");