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;
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:
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())) {
* 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);
}