From: chaoskagami Date: Sun, 24 Aug 2014 05:04:04 +0000 (-0400) Subject: Windows build is cleaned up, saves auto-reload with no parameters, and frankly becaus... X-Git-Tag: stable-2~14 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=41f95d4fa962572d941644d324df107e3db5c7fc;p=vn%2Fvndc.git Windows build is cleaned up, saves auto-reload with no parameters, and frankly because of how I save gsetvar is useless - so I replaced it with a setvar chain --- diff --git a/bin/vndc.x86_64 b/bin/vndc.x86_64 new file mode 100755 index 0000000..ffa7312 Binary files /dev/null and b/bin/vndc.x86_64 differ diff --git a/vndc/src/VNDC.cpp b/vndc/src/VNDC.cpp index bb1bd88..932cbfe 100644 --- a/vndc/src/VNDC.cpp +++ b/vndc/src/VNDC.cpp @@ -26,10 +26,14 @@ int main(int argc, char** argv) { int width = 0, height = 0; bool debug_enable = false; bool enable_v = false; + bool newgame = false; char c; - while((c = getopt(argc, argv, "bvx:y:d:m:s:ch")) != -1) { + while((c = getopt(argc, argv, "nbvx:y:d:m:s:ch")) != -1) { switch(c) { + case 'n': + printf("[info] New game, not reloading save.\n"); + newgame = true; case 'v': printf("[info] Script commands will be echoed.\n"); enable_v = true; @@ -62,14 +66,15 @@ int main(int argc, char** argv) { vndc_extensions = false; break; case 'h': - printf("-x size -y size\t\tSet display window to wxh\n"); + printf("-x size -y size\tStretch display window to WxH\n"); + printf("-n\t\tNew Game. Do not reload default save.\n"); printf("-d dir\t\tChange to directory/Run game in directory\n"); printf("-b\t\tDebug Mode. Hit Ctrl+C on console for shell\n"); printf("-v\t\tVerbose. Echo script commands back as they execute\n"); printf("-m .scr\t\tLoad .scr as main script\n"); - printf("-s .scr\t\tLoad save .scr\n"); + printf("-s .scr\t\tLoad save .scr instead of default\n"); printf("-c\t\tCompliant mode; don't use VNDC extensions\n"); - printf("-h\t\tPrint this help message\n"); + printf("-h\t\tPrint this help message\n\n"); return 0; break; default: @@ -102,9 +107,23 @@ int main(int argc, char** argv) { Setup(); - if(!save_file) - op_jump(GetData()->main_scr[0], NULL, true); - else + if(!save_file) { + // Check if a default save exists at save.scr. + if(newgame == false) { + FILE* t = fopen((char*)"save.scr", "r"); + if(t != NULL) { + // File exists. first, close the descriptor. + fclose(t); + // Op_jump to it + op_jump((char*)"save.scr", NULL, true); + } + else // Jump to main, there is no save. + op_jump(GetData()->main_scr[0], NULL, true); + } + else // Otherwise just jump to the main screen. + op_jump(GetData()->main_scr[0], NULL, true); + } + else // Jump to save file specified. op_jump(save_file, NULL, true); while(!(GetData()->ctx->GetQuit())) { diff --git a/vndc/src/op_gsetvar.cpp b/vndc/src/op_gsetvar.cpp index a3326ee..ceec62f 100644 --- a/vndc/src/op_gsetvar.cpp +++ b/vndc/src/op_gsetvar.cpp @@ -6,20 +6,16 @@ * Implements gsetvar vnds function. * gsetvar var mod val * Modifier is '=' '+' or '-' in script, simplify to ('-':-1, '=':0, '+':1). - * MAY need to be UTF8 friendly + * is apparently UTF8 friendly + * Also, for now I simply redirect to setvar. Global values are only set + * by definition on an end-game event for replays, so when the interpreter hits + * 'the end' it loops back to the title. + * So setting local vars is okay, since they'll be reloaded across playthrus. */ void op_gsetvar(char* var, int *modifier, int *value) { if (GetData()->if_fail != 0) return; - if(*modifier == 0) { - GetData()->g_flags[0][std::string(var)] = value[0]; - } - else if (*modifier == -1) { - GetData()->g_flags[0][std::string(var)] -= value[0]; - } - else if (*modifier == 1) { - GetData()->g_flags[0][std::string(var)] += value[0]; - } + op_setvar(var, modifier, value); }