Skip to content

Commit

Permalink
Honor the -nolog commandline parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
vanfanel committed Sep 28, 2017
1 parent 7259004 commit 7c04e24
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ unsigned int rsb_port = 0; // 0 = LPT1, 1 = LPT2 or address of real scoreboard
unsigned int idleexit; // added by JFA for -idleexit
unsigned char startsilent = 0;

bool log_was_disabled = false; // added by MAC for -nolog

#endif
11 changes: 9 additions & 2 deletions src/hypseus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ int main(int argc, char **argv)

set_cur_dir(argv[0]); // set active directory

reset_logfile(argc, argv);

// initialize SDL without any subsystems but with the no parachute option so
// 1 - we can initialize either audio or video first
// 2 - we can trace segfaults using a debugger
Expand All @@ -177,6 +175,11 @@ int main(int argc, char **argv)
remember_leds(); // memorizes the status of keyboard leds
change_led(false, false, false); // turns all keyboard leds off

// MAC : we also have to wait after the command line is parsed before
// knowing if we want loging or not.
if (!log_was_disabled)
reset_logfile(argc, argv);

// if the display initialized properly
// MAC: init_display() call moved to the sdl_video_run thread: it's now
// called at the begining of the sdl_video_run thread main function.
Expand Down Expand Up @@ -355,3 +358,7 @@ void set_startsilent(unsigned char value) { startsilent = value; }

unsigned char get_startsilent() { return (startsilent); }
// end edit

// added by MAC for -nolog
void set_log_was_disabled (bool value) { log_was_disabled = value; }
// end edit
4 changes: 4 additions & 0 deletions src/hypseus.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ void set_startsilent(unsigned char value);
unsigned char get_startsilent();
// end edit

// added by MAC for -nolog
void set_log_was_disabled(bool value);
// end edit

#endif // DAPHNE_H

19 changes: 1 addition & 18 deletions src/io/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,6 @@ bool parse_cmd_line(int argc, char **argv)
char s[320] = {0}; // in case they pass in a huge directory as part of the
// framefile
int i = 0;
bool log_was_disabled = false; // if we actually get "-nolog" while going
// through arguments

//////////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -688,7 +686,7 @@ bool parse_cmd_line(int argc, char **argv)

// disable log file
else if (strcasecmp(s, "-nolog") == 0) {
log_was_disabled = true;
set_log_was_disabled(true);
}

// by RDG2010
Expand Down Expand Up @@ -894,21 +892,6 @@ bool parse_cmd_line(int argc, char **argv)
result = false;
}

// if we didn't receive "-nolog" while parsing, then it's ok to enable the
// log file now.
if (!log_was_disabled) {
// first we need to delete the old logfile so we can start fresh
// (this is the best place to do it since up until this point we don't
// know where our homedir is)
string logfile = g_homedir.get_homedir();
logfile += "/";
logfile += LOGNAME;
unlink(logfile.c_str()); // delete logfile if possible, because we're
// starting over

set_log_enabled(true);
}

return (result);
}

Expand Down

1 comment on commit 7c04e24

@OzFalcon
Copy link
Contributor

@OzFalcon OzFalcon commented on 7c04e24 Mar 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit causes Hypseus to exit straight back to command line when incorrect options are passed.
No error or info is printed.

Please sign in to comment.