X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=save.c;fp=save.c;h=76cfb3cdade24194da2dc6583cd0a50c0745ebb5;hb=dbdb031ee290892468d24b6dd576fe62c47e778a;hp=0000000000000000000000000000000000000000;hpb=cb1d2f9fbec8a274aaf7a80c5fb552b928148b1e;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/save.c b/save.c new file mode 100644 index 0000000..76cfb3c --- /dev/null +++ b/save.c @@ -0,0 +1,45 @@ +#ifndef SAVE_C +#define SAVE_C + +struct { + u8 buf[ 1024 ]; + u32 len; +} +static savedata; + +static void skaterift_write_savedata(void){ + vg_msg sav = {0}; + sav.buf = savedata.buf; + sav.max = sizeof(savedata.buf); + + vg_msg_frame( &sav, "player" ); + + if( localplayer.board_view_slot ){ + struct cache_board *cache_ptr = localplayer.board_view_slot; + if( cache_ptr->reg_ptr ){ + if( cache_ptr->reg_ptr->workshop_id ) + vg_msg_wkvu64( &sav, "board", cache_ptr->reg_ptr->workshop_id ); + else + vg_msg_wkvstr( &sav, "board", cache_ptr->reg_ptr->foldername ); + } + } + + vg_msg_end_frame( &sav ); + savedata.len = sav.len; + + FILE *fp = fopen( "save.bkv", "wb" ); + if( fp ){ + fwrite( savedata.buf, sav.len, 1, fp ); + fclose( fp ); + } +} + +static void skaterift_read_savedata(void){ + FILE *fp = fopen( "save.bkv", "rb" ); + if( fp ){ + savedata.len = fread( savedata.buf, 1, sizeof(savedata.buf), fp ); + fclose( fp ); + } +} + +#endif /* SAVE_C */