[Freeciv-Dev] [Patch] Pad year in savegame names with leading zeros
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Hi,
I thinks it's useful to add leading zeroes to the year in generated savegame
names (autosave and default filename). Always show 4 digits (and perhaps the
sign to indcate BC). So saves can be listed in cronological order using ls
etc. and won't get mixed (there is still a jump between BC and AD). [Patch]
Question: Why is the charset for save_name so limited? I'm missing
underscore and slash (to put all the files from a game into a subdirectory).
But the asterisk is allowed.
Andreas
----cut------------------------------------------------------------
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.50
diff -u -u -r1.50 srv_main.c
--- server/srv_main.c 2001/09/12 08:39:38 1.50
+++ server/srv_main.c 2001/09/18 00:47:02
@@ -464,7 +464,7 @@
sz_strlcpy(filename, orig_filename);
} else { /* If orig_filename is NULL or empty, use "civgame<year>m.sav"
*/
my_snprintf(filename, sizeof(filename),
- "%s%dm.sav", game.save_name, game.year);
+ "%s%.4dm.sav", game.save_name, game.year);
}
timer_cpu = new_timer_start(TIMER_CPU, TIMER_ACTIVE);
@@ -503,7 +503,7 @@
assert(strlen(game.save_name)<256);
my_snprintf(filename, sizeof(filename),
- "%s%d.sav", game.save_name, game.year);
+ "%s%.4d.sav", game.save_name, game.year);
save_game(filename);
gamelog_save(); /* should this be in save_game()? --dwp */
}
----cut------------------------------------------------------------
--
CPU time is a terrible thing to waste!
Join the world's fastest computer - http://www.distributed.net - Team #11292
- [Freeciv-Dev] [Patch] Pad year in savegame names with leading zeros,
Andreas Beckmann <=
|
|