Explorar o código

- Changed the default save interval to 5 minutes. Added support for specifying fixed save-intervals by using negative values. EG:
- Save interval set to 300 (5 minutes): all characters will be saved in equal time-slots, so that everyone is saved every 5 minutes regardless of number of players online.
- Save interval set to -1000 (1000 ms): One character will be saved every second, regardless of amount of characters online.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@7657 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex %!s(int64=19) %!d(string=hai) anos
pai
achega
72a2139527
Modificáronse 5 ficheiros con 32 adicións e 6 borrados
  1. 9 0
      Changelog-Trunk.txt
  2. 8 2
      conf-tmpl/map_athena.conf
  3. 6 2
      src/map/map.c
  4. 1 1
      src/map/map.h
  5. 8 1
      src/map/pc.c

+ 9 - 0
Changelog-Trunk.txt

@@ -4,6 +4,15 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/07/13
+	* Changed the default save interval to 5 minutes. Added support for
+	  specifying fixed save-intervals by using negative values. [Skotlex] EG:
+	- Save interval set to 300 (5 minutes): all characters will be saved in
+	  equal time-slots, so that everyone is saved every 5 minutes regardless of
+	  number of players online. 
+	- Save interval set to -1000 (1000 ms): One character will be saved every
+	  second, regardless of amount of characters online.
+	  The new fixed-time-slots method is meant for larger servers, so that they
+	  can control the saving-induced stressed on the char-server.
 	* Fixed @storeall and @charstoreall failing when the target character
 	  already had the storage open. [Skotlex]
 	* Reverted temporarily the Cart Termination equation until it can be

+ 8 - 2
conf-tmpl/map_athena.conf

@@ -92,8 +92,14 @@ enable_spy: no
 // This prevents usage of >& log.file
 console: off
 
-// Database autosave time, in seconds.
-autosave_time: 60
+// Database autosave time
+// When positive, all characters are saved on this time in seconds (example:
+// autosave of 60 secs with 60 characters online -> one char is saved every 
+// second)
+// When negative, the timeslot is constant, in ms (example: if -1000, a
+// character will be saved once a second, regardless of number of players 
+// online).
+autosave_time: 300
 
 // Apart from the autosave_time, players will also get saved when involved
 // in the following (add as needed):

+ 6 - 2
src/map/map.c

@@ -3292,9 +3292,13 @@ int map_config_read(char *cfgName) {
 			} else if (strcmpi(w1, "delnpc") == 0) {
 				npc_delsrcfile(w2);
 			} else if (strcmpi(w1, "autosave_time") == 0) {
-				autosave_interval = atoi(w2) * 1000;
-				if (autosave_interval <= 0)
+				autosave_interval = atoi(w2);
+				if (!autosave_interval) //Revert to default saving.
 					autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
+				else if (autosave_interval > 0) //Pass from MS to seconds
+					autosave_interval *= 1000;
+				else if (autosave_interval > -100) //Use lower cap of 100ms
+					autosave_interval = -100;
 			} else if (strcmpi(w1, "save_settings") == 0) {
 				save_settings = atoi(w2);
 			} else if (strcmpi(w1, "motd_txt") == 0) {

+ 1 - 1
src/map/map.h

@@ -155,7 +155,7 @@ enum {
 //Don't change this, as the client seems to always send/receive 80 characters as it currently is. [Skotlex]
 #define MESSAGE_SIZE 80
 
-#define DEFAULT_AUTOSAVE_INTERVAL 60*1000
+#define DEFAULT_AUTOSAVE_INTERVAL 5*60*1000
 
 //Specifies maps where players may hit each other
 #define map_flag_vs(m) (map[m].flag.pvp || map[m].flag.gvg_dungeon || map[m].flag.gvg || (agit_flag && map[m].flag.gvg_castle))

+ 8 - 1
src/map/pc.c

@@ -7095,6 +7095,9 @@ int pc_autosave(int tid,unsigned int tick,int id,int data)
 	if(save_flag==0)
 		last_save_fd=0;
 
+	if (autosave_interval < 0)
+		return 0; //Fixed interval for saving. [Skotlex]
+
 	interval = autosave_interval/(clif_countusers()+1);
 	if(interval <= 0)
 		interval = 1;
@@ -7510,7 +7513,11 @@ int do_init_pc(void) {
 	add_timer_func_list(pc_follow_timer, "pc_follow_timer");
 	natural_heal_prev_tick = gettick();
 	add_timer_interval(natural_heal_prev_tick + NATURAL_HEAL_INTERVAL, pc_natural_heal, 0, 0, NATURAL_HEAL_INTERVAL);
-	add_timer(gettick() + autosave_interval, pc_autosave, 0, 0);
+
+	if (autosave_interval > 0) //Normal saving.
+		add_timer(gettick() + autosave_interval, pc_autosave, 0, 0);
+	else //Constant save interval.
+		add_timer_interval(gettick() -autosave_interval, pc_autosave, 0, 0, -autosave_interval);
 
 	if (battle_config.day_duration > 0 && battle_config.night_duration > 0) {
 		int day_duration = battle_config.day_duration;