diff --git a/.gitignore b/.gitignore index 88d050b..14781c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -main \ No newline at end of file +main +ext/ diff --git a/destruct.h b/destruct.h index 6a313b4..2ae949b 100644 --- a/destruct.h +++ b/destruct.h @@ -1,20 +1,20 @@ -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 < LEN; ++i) { - printf("\t%zu %s,\n", tempBuf[i + 3], fish[i < 5 ? i : i + 1]); - } - - printf("\n\nText-based save: %01x$%zu[%zu:%zu:%zu:%zu:%zu][%zu:%zu:%zu:%zu]%zu\n", tempBuf[1], tempBuf[2], tempBuf[3], tempBuf[4], tempBuf[5], tempBuf[6], tempBuf[7], tempBuf[8], tempBuf[9], tempBuf[10], tempBuf[11], tempBuf[LEN + 3]); - return 0; -} \ No newline at end of file +if (argc > 1 && strcmp(argv[1], "/d") == 0) { + printf("Gone Fishing v%zu.%zu.%zu savefile destructurer. Copyright firefish %d.\n\n", VER / 100, (VER / 10) % 10, VER % 10, YEAR); + + 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 < LEN; ++i) { + printf("\t%zu %s,\n", tempBuf[i + 3], fish[i < 5 ? i : i + 1]); + } + + printf("\n\nText-based save: %01x$%zu[%zu:%zu:%zu:%zu:%zu][%zu:%zu:%zu:%zu]%zu\n", tempBuf[1], tempBuf[2], tempBuf[3], tempBuf[4], tempBuf[5], tempBuf[6], tempBuf[7], tempBuf[8], tempBuf[9], tempBuf[10], tempBuf[11], tempBuf[LEN + 3]); + return 0; +} diff --git a/main.c b/main.c index ff64b33..9375788 100644 --- a/main.c +++ b/main.c @@ -7,11 +7,12 @@ #include "table.h" // semver version; insert dots after each digit -const size_t VER = 203; +const size_t VER = 204; unsigned char tier = 0x0; const int LEN = 9; const int COST = 21; +const int YEAR = 2023; int choice; int i; size_t money = 0; @@ -29,7 +30,7 @@ int main(int argc, char** argv) { srand(time(NULL)); - 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); + printf("Gone Fishing v%zu.%zu.%zu. Copyright @firefish %d.\nRun with /d flag to destructure the save file.\n\n", VER / 100, (VER / 10) % 10, VER % 10, YEAR); i = access("GONEFISH.SAV", 0); // F_OK ain't defined, so we use good ol' fashioned 0 start: diff --git a/market.h b/market.h index c6c3b49..4ea8bc8 100644 --- a/market.h +++ b/market.h @@ -1,6 +1,6 @@ double total; int to_buy, to_sell, i; -bool has_some = false; +bool unlocked = false; void market() { for (i = 0; i < 5; ++i) { @@ -24,6 +24,7 @@ void market() { if (to_buy <= total) { money -= to_buy * COST; bait += to_buy; + unlocked = true; } else { printf("Unfortunately, you can't afford that much bait.\n\tEither try buying less, or try selling some of your fish.\n"); } @@ -31,32 +32,32 @@ void market() { printf("You can't afford any bait. Bait costs $21 per piece. You currently have $%zu.\n", money); } - for (i = 5, has_some = false; i < 9; ++i) { + /*for (i = 5, has_some = false; i < 9; ++i) { if (data[i] != 0) { has_some = true; } - } + }*/ - if (has_some) { - printf("\nIt seems as if you have some big fish to sell.\n"); + if (unlocked) { + printf("\nYou can now sell some of your less-valued fish.\n"); printf("What would you like to sell?\n"); - for (i = 7; i < 11; ++i) { - printf("\tPress %d to sell %s,\n", i - 6, fish[i-1]); + for (i = 0; i < 5; ++i) { + printf("\tPress %d to sell %s,\n", i + 1, fish[i]); } printf("Or press 0 to not sell anything.\n> "); scanf("%d", &choice); - if (choice > 0 && choice < 5) { - printf("How much %s would you like to sell? (you currently have %zu) ", fish[choice + 5], data[choice + 4]); + if (choice > 0 && choice <= 5) { + printf("How much %s would you like to sell? (you currently have %zu) ", fish[choice - 1], data[choice - 1]); scanf("%d", &to_sell); - if (to_sell > data[choice + 4]) { - printf("You don't have that much %s!\n", fish[choice + 5]); + if (to_sell > data[choice - 1]) { + printf("You don't have that much %s!\n", fish[choice - 1]); return; } else { - data[choice + 4] -= to_sell; + data[choice - 1] -= to_sell; money += sale[choice - 1] * to_sell; } } else { diff --git a/table.h b/table.h index f1ff01c..9ffbbd6 100644 --- a/table.h +++ b/table.h @@ -37,5 +37,7 @@ const float lv15[12] = {0, 0.06, 0.12, 0.17, 0.25, 0.3, 0.1, 0.25, 0.25, 0.25, 0 const float * clump[16] = {lv0, lv1, lv2, lv3, lv4, lv5, lv6, lv7, lv8, lv9, lv10, lv11, lv12, lv13, lv14, lv15}; -const int sale[4] = {15, 25, 40, 70}; +// for high-value: pre 2.0.4 mechanic +// const int sale[4] = {15, 25, 40, 70}; +const int sale[5] = {15, 12, 10, 8, 8};