Skip to content

Commit

Permalink
Added destructurer
Browse files Browse the repository at this point in the history
  • Loading branch information
firefish111 committed Apr 28, 2022
1 parent 14c3ebc commit fd1a633
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 18 additions & 0 deletions destruct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if (argc > 1 && strcmp(argv[1], "/d") == 0) {
printf("Gone Fishing v%zu.%zu.%zu savefile destructurer. Copyright firefish 2022.\n\n", VER / 100, (VER / 10) % 10, VER % 10);

savefile = fopen("GONEFISH.SAV", "rb");
if (!savefile) {
printf("Savefile does not exist. Cannot destructure.\n");
return 1;
}

tempBuf = calloc(sizeof(size_t), LEN + 4);
fread(tempBuf, sizeof(size_t), LEN + 4, savefile);
printf("Save version %zu.%zu.%zu.\nTier %d (%s), $%d in bank, %d bait.\nFish:\n", tempBuf[0] / 100, (tempBuf[0] / 10) % 10, tempBuf[0] % 10, tempBuf[1], rodname[tempBuf[1]], tempBuf[2], tempBuf[LEN + 3]);

for (i = 0; i < 9; ++i) {
printf("\t%zu %s,\n", tempBuf[i + 3], fish[i < 5 ? i : i + 1]);
}
return 0;
}
9 changes: 6 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "table.h"

// semver version; insert dots after each digit
const size_t VER = 201;
const size_t VER = 202;

unsigned char tier = 0x0;
const int LEN = 9;
Expand All @@ -23,10 +23,13 @@ FILE * savefile;
#include "cast.h"
#include "market.h"

int main(void) {
int main(int argc, char** argv) {
// save destructuror
#include "destruct.h"

srand(time(NULL));

printf("Gone Fishing v%zu.%zu.%zu. Copyright @firefish 2022.\n\n", VER / 100, (VER / 10) % 10, VER % 10);
printf("Gone Fishing v%zu.%zu.%zu. Copyright @firefish 2022.\nRun with /d flag to destructure the save file.\n\n", VER / 100, (VER / 10) % 10, VER % 10);

i = access("GONEFISH.SAV", 0); // F_OK ain't defined, so we use good ol' fashioned 0
start:
Expand Down

0 comments on commit fd1a633

Please sign in to comment.