]> Chaos Git - vn/vndc.git/commitdiff
Windows build is cleaned up, saves auto-reload with no parameters, and frankly becaus...
authorchaoskagami <chaos.kagami@gmail.com>
Sun, 24 Aug 2014 05:04:04 +0000 (01:04 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sun, 24 Aug 2014 05:04:04 +0000 (01:04 -0400)
bin/vndc.x86_64 [new file with mode: 0755]
vndc/src/VNDC.cpp
vndc/src/op_gsetvar.cpp

diff --git a/bin/vndc.x86_64 b/bin/vndc.x86_64
new file mode 100755 (executable)
index 0000000..ffa7312
Binary files /dev/null and b/bin/vndc.x86_64 differ
index bb1bd884b6969b0cde683310476f83450f14cf99..932cbfe4e1d87a72f0a4150c5dadb4ef7c06d50c 100644 (file)
@@ -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())) {
index a3326ee60d48d35cb6a54252c7c86055c272871a..ceec62f502e8b939b8da2ae108e2923efd0f729b 100644 (file)
@@ -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);
 }