Permalink
Browse files

Allow -start-position random to set a random start position.

Fixed bug in 'path' config entry handling.
  • Loading branch information...
1 parent 2f5ae32 commit 91cc73dd5a9bf77bfff28c196e6f2b4bb840680b @acaudwell committed Mar 29, 2010
Showing with 19 additions and 12 deletions.
  1. +2 −1 ChangeLog
  2. +1 −1 README
  3. +1 −1 data/gource.1
  4. +15 −7 src/gource_settings.cpp
  5. +0 −2 src/main.cpp
View
@@ -4,8 +4,9 @@
* Added --logo and --background-image options.
* Added --dont-stop and --stop-at-time options.
* Added --log-command option to use instead of multiple --log-command-VCS options.
- * Allow --file-idle-time 0 (files will never expire).
* Added --hide mouse option.
+ * Allow --file-idle-time 0 (files will never expire).
+ * Allow -start-position random to set a random start position.
* Replaced --disable-progress and --disable-bloom with arguments to --hide.
0.26:
View
2 README
@@ -52,7 +52,7 @@ options:
Windowed.
-p, --start-position POSITION
- Begin at some position in the log (between 0.0 and 1.0).
+ Begin at some position in the log (between 0.0 and 1.0 or 'random').
--stop-position POSITION
Stop (exit) at some position in the log (does not work with STDIN).
View
@@ -26,7 +26,7 @@ Fullscreen
Windowed
.TP
\fB\-p, \-\-start\-position POSITION\fR
-Begin at some position in the log (between 0.0 and 1.0).
+Begin at some position in the log (between 0.0 and 1.0 or 'random').
.TP
\fB \-\-stop\-position POSITION\fR
Stop (exit) at some position in the log (does not work with STDIN).
View
@@ -39,7 +39,7 @@ void GourceSettings::help() {
printf(" --multi-sampling Enable multi-sampling\n");
printf(" --demo Run in demo mode\n\n");
- printf(" -p, --start-position POSITION Begin at some position in the log (0.0-1.0)\n");
+ printf(" -p, --start-position POSITION Begin at some position (0.0-1.0 or 'random')\n");
printf(" --stop-position POSITION Stop at some position\n");
printf(" --stop-at-time SECONDS Stop after a specified number of seconds\n");
printf(" --stop-on-idle Stop on break in activity\n");
@@ -214,6 +214,8 @@ GourceSettings::GourceSettings() {
void GourceSettings::setGourceDefaults() {
+ path = ".";
+
hide_date = false;
hide_users = false;
hide_tree = false;
@@ -632,12 +634,17 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
if((entry = gource_settings->getEntry("start-position")) != 0) {
- if(!entry->hasValue()) conffile.entryException(entry, "specify start-position (float)");
+ if(!entry->hasValue()) conffile.entryException(entry, "specify start-position (float,random)");
- start_position = entry->getFloat();
+ if(entry->getString() == "random") {
+ srand(time(0));
+ start_position = (rand() % 1000) / 1000.0f;
+ } else {
+ start_position = entry->getFloat();
- if(start_position<=0.0 || start_position>=1.0) {
- conffile.entryException(entry, "start-position outside of range 0.0 - 1.0 (non-inclusive)");
+ if(start_position<=0.0 || start_position>=1.0) {
+ conffile.entryException(entry, "start-position outside of range 0.0 - 1.0 (non-inclusive)");
+ }
}
}
@@ -806,8 +813,9 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
//validate path
-
- path = gource_settings->getString("path");
+ if(gource_settings->hasValue("path")) {
+ path = gource_settings->getString("path");
+ }
if(path == "-") {
View
@@ -53,8 +53,6 @@ int main(int argc, char *argv[]) {
} else {
conf.setEntry("gource", "path", path);
}
- } else {
- conf.setEntry("gource", "path", ".");
}
//apply the config / see if its valid

0 comments on commit 91cc73d

Please sign in to comment.