Browse Source

* Added auto save guild dataevery 5 minutes during WOE

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1333 54d463be-8e91-2dee-dedb-b68131a5f0ec
celest 20 năm trước cách đây
mục cha
commit
a2ca733706
4 tập tin đã thay đổi với 70 bổ sung62 xóa
  1. 3 0
      Changelog-SVN.txt
  2. 0 12
      src/char_sql/int_guild.c
  3. 67 5
      src/map/guild.c
  4. 0 45
      src/map/pc.c

+ 3 - 0
Changelog-SVN.txt

@@ -5,6 +5,9 @@ Date	Added
         * Please make sure to use the stable/sql-files/upgrade_svn1315.sql to
           upgrade your mysql as a result of the new adoption system.  Thank you
              -MouseJstr
+
+	* Added auto save guild data (only guardian HP and owner guild ID for now,
+	  both cached) every 5 minutes during WOE [celest]
 	* Updated damage calculation for Magnum Break [celest]
 	* Fixed #item not working properly, thanks to TripleOxygen
         * Fixed a lot of compile time problems with our mixed C++/C

+ 0 - 12
src/char_sql/int_guild.c

@@ -20,9 +20,6 @@
 
 static struct dbt *guild_db_;
 static struct dbt *castle_db_;
-static struct dbt *guild_expcache_db_;
-static struct dbt *guild_infoevent_db_;
-static struct dbt *guild_castleinfoevent_db_;
 
 static struct guild *guild_pt;
 static struct guild *guild_pt2;
@@ -668,9 +665,6 @@ int inter_guild_sql_init()
 
         guild_db_=numdb_init();
         castle_db_=numdb_init();
-        guild_expcache_db_=numdb_init();
-        guild_infoevent_db_=numdb_init();
-        guild_castleinfoevent_db_=numdb_init();
 
 	printf("interserver guild memory initialize.... (%d byte)\n",sizeof(struct guild));
 	guild_pt = (struct guild*)aCalloc(sizeof(struct guild), 1);
@@ -709,9 +703,6 @@ int inter_guild_sql_init()
 	return 0;
 }
 
-int guild_expcache_db_final (void *k, void *data, va_list ap) { return 0; }
-int guild_infoevent_db_final (void *k, void *data, va_list ap) { return 0; }
-int guild_castleinfoevent_db_final (void *k, void *data, va_list ap) { return 0; }
 int guild_db_final (void *k, void *data, va_list ap)
 {
 	struct guild *g = (struct guild *) data;
@@ -732,9 +723,6 @@ void inter_guild_sql_final()
 	
 	numdb_final(guild_db_, guild_db_final);
 	numdb_final(castle_db_, castle_db_final);
-	numdb_final(guild_expcache_db_, guild_expcache_db_final);
-	numdb_final(guild_infoevent_db_, guild_infoevent_db_final);
-	numdb_final(guild_castleinfoevent_db_, guild_castleinfoevent_db_final);
 
 	return;
 }

+ 67 - 5
src/map/guild.c

@@ -45,6 +45,14 @@ struct guild_expcache {
 	int guild_id, account_id, char_id, exp;
 };
 
+// timer for auto saving guild data during WoE
+#define GUILD_SAVE_INTERVAL 300000
+int guild_save_timer = -1;
+
+int guild_payexp_timer(int tid,unsigned int tick,int id,int data);
+int guild_gvg_eliminate_timer(int tid,unsigned int tick,int id,int data);
+int guild_save_sub(int tid,unsigned int tick,int id,int data);
+
 // ギルドスキルdbのアクセサ(今は直打ちで代用)
 int guild_skill_get_inf(int id) { // Modified for new skills [Sara]
 	if (id==GD_BATTLEORDER) return 4;
@@ -82,11 +90,6 @@ int guild_checkskill(struct guild *g,int id)
 	return g->skill[idx].lv;
 }
 
-
-int guild_payexp_timer(int tid,unsigned int tick,int id,int data);
-int guild_gvg_eliminate_timer(int tid,unsigned int tick,int id,int data);
-
-
 static int guild_read_castledb(void)
 {
 	FILE *fp;
@@ -147,6 +150,7 @@ void do_init_guild(void)
 
 	add_timer_func_list(guild_gvg_eliminate_timer,"guild_gvg_eliminate_timer");
 	add_timer_func_list(guild_payexp_timer,"guild_payexp_timer");
+	add_timer_func_list(guild_save_sub, "guild_save_sub");
 	add_timer_interval(gettick()+GUILD_PAYEXP_INVERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INVERVAL);
 }
 
@@ -1514,6 +1518,8 @@ int guild_agit_start(void)
 {	// Run All NPC_Event[OnAgitStart]
 	int c = npc_event_doall("OnAgitStart");
 	printf("NPC_Event:[OnAgitStart] Run (%d) Events by @AgitStart.\n",c);
+	// Start auto saving
+	guild_save_timer = add_timer_interval (gettick() + GUILD_SAVE_INTERVAL, guild_save_sub, 0, 0, GUILD_SAVE_INTERVAL);
 	return 0;
 }
 
@@ -1521,6 +1527,8 @@ int guild_agit_end(void)
 {	// Run All NPC_Event[OnAgitEnd]
 	int c = npc_event_doall("OnAgitEnd");
 	printf("NPC_Event:[OnAgitEnd] Run (%d) Events by @AgitEnd.\n",c);
+	// Stop auto saving
+	delete_timer (guild_save_timer, guild_save_sub);
 	return 0;
 }
 
@@ -1544,6 +1552,60 @@ int guild_gvg_eliminate_timer(int tid,unsigned int tick,int id,int data)
 	return 0;
 }
 
+static int Ghp[MAX_GUILDCASTLE][8];	// so save only if HP are changed // experimental code [Yor]
+static int Gid[MAX_GUILDCASTLE];
+int guild_save_sub(int tid,unsigned int tick,int id,int data)
+{
+	struct guild_castle *gc;
+	int i;
+
+	for(i = 0; i < MAX_GUILDCASTLE; i++) {	// [Yor]
+		gc = guild_castle_search(i);
+		if (!gc) continue;
+		if (gc->guild_id != Gid[i]) {
+			// Re-save guild id if its owner guild has changed
+			// This should already be done in gldfunc_ev_agit.txt,
+			// but since people have complained... Well x3
+			guild_castledatasave(gc->castle_id, 1, gc->guild_id);
+			Gid[i] = gc->guild_id;
+		}
+		if (gc->visibleG0 == 1 && Ghp[i][0] != gc->Ghp0) {
+			guild_castledatasave(gc->castle_id, 18, gc->Ghp0);
+			Ghp[i][0] = gc->Ghp0;
+		}
+		if (gc->visibleG1 == 1 && Ghp[i][1] != gc->Ghp1) {
+			guild_castledatasave(gc->castle_id, 19, gc->Ghp1);
+			Ghp[i][1] = gc->Ghp1;
+		}
+		if (gc->visibleG2 == 1 && Ghp[i][2] != gc->Ghp2) {
+			guild_castledatasave(gc->castle_id, 20, gc->Ghp2);
+			Ghp[i][2] = gc->Ghp2;
+		}
+		if (gc->visibleG3 == 1 && Ghp[i][3] != gc->Ghp3) {
+			guild_castledatasave(gc->castle_id, 21, gc->Ghp3);
+			Ghp[i][3] = gc->Ghp3;
+		}
+		if (gc->visibleG4 == 1 && Ghp[i][4] != gc->Ghp4) {
+			guild_castledatasave(gc->castle_id, 22, gc->Ghp4);
+			Ghp[i][4] = gc->Ghp4;
+		}
+		if (gc->visibleG5 == 1 && Ghp[i][5] != gc->Ghp5) {
+			guild_castledatasave(gc->castle_id, 23, gc->Ghp5);
+			Ghp[i][5] = gc->Ghp5;
+		}
+		if (gc->visibleG6 == 1 && Ghp[i][6] != gc->Ghp6) {
+			guild_castledatasave(gc->castle_id, 24, gc->Ghp6);
+			Ghp[i][6] = gc->Ghp6;
+		}
+		if (gc->visibleG7 == 1 && Ghp[i][7] != gc->Ghp7) {
+			guild_castledatasave(gc->castle_id, 25, gc->Ghp7);
+			Ghp[i][7] = gc->Ghp7;
+		}		
+	}
+
+	return 0;
+}
+
 int guild_agit_break(struct mob_data *md)
 {	// Run One NPC_Event[OnAgitBreak]
 	char *evname;

+ 0 - 45
src/map/pc.c

@@ -6881,9 +6881,6 @@ int pc_setsavepoint(struct map_session_data *sd,char *mapname,int x,int y)
  *------------------------------------------
  */
 static int last_save_fd,save_flag;
-// --- uncomment to reenable guild castle saving ---//
-//static int Ghp[MAX_GUILDCASTLE][8]; // so save only if HP are changed // experimental code [Yor]
-
 static int pc_autosave_sub(struct map_session_data *sd,va_list ap)
 {
 	nullpo_retr(0, sd);
@@ -6891,10 +6888,6 @@ static int pc_autosave_sub(struct map_session_data *sd,va_list ap)
 	Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
 
 	if(save_flag==0 && sd->fd>last_save_fd && !sd->state.waitingdisconnect){
-// --- uncomment to reenable guild castle saving ---//
-//		struct guild_castle *gc=NULL;
-//		int i;
-//
 
 //		if(battle_config.save_log)
 //			printf("autosave %d\n",sd->fd);
@@ -6905,44 +6898,6 @@ static int pc_autosave_sub(struct map_session_data *sd,va_list ap)
 		chrif_save(sd);
 		storage_storage_save(sd);
 
-// --- uncomment to reenable guild castle saving ---//
-/*		for(i = 0; i < MAX_GUILDCASTLE; i++) {	// [Yor]
-			gc = guild_castle_search(i);
-			if (!gc) continue;
-			if (gc->visibleG0 == 1 && Ghp[i][0] != gc->Ghp0) {
-				guild_castledatasave(gc->castle_id, 18, gc->Ghp0);
-				Ghp[i][0] = gc->Ghp0;
-			}
-			if (gc->visibleG1 == 1 && Ghp[i][1] != gc->Ghp1) {
-				guild_castledatasave(gc->castle_id, 19, gc->Ghp1);
-				Ghp[i][1] = gc->Ghp1;
-			}
-			if (gc->visibleG2 == 1 && Ghp[i][2] != gc->Ghp2) {
-				guild_castledatasave(gc->castle_id, 20, gc->Ghp2);
-				Ghp[i][2] = gc->Ghp2;
-			}
-			if (gc->visibleG3 == 1 && Ghp[i][3] != gc->Ghp3) {
-				guild_castledatasave(gc->castle_id, 21, gc->Ghp3);
-				Ghp[i][3] = gc->Ghp3;
-			}
-			if (gc->visibleG4 == 1 && Ghp[i][4] != gc->Ghp4) {
-				guild_castledatasave(gc->castle_id, 22, gc->Ghp4);
-				Ghp[i][4] = gc->Ghp4;
-			}
-			if (gc->visibleG5 == 1 && Ghp[i][5] != gc->Ghp5) {
-				guild_castledatasave(gc->castle_id, 23, gc->Ghp5);
-				Ghp[i][5] = gc->Ghp5;
-			}
-			if (gc->visibleG6 == 1 && Ghp[i][6] != gc->Ghp6) {
-				guild_castledatasave(gc->castle_id, 24, gc->Ghp6);
-				Ghp[i][6] = gc->Ghp6;
-			}
-			if (gc->visibleG7 == 1 && Ghp[i][7] != gc->Ghp7) {
-				guild_castledatasave(gc->castle_id, 25, gc->Ghp7);
-				Ghp[i][7] = gc->Ghp7;
-			}
-		}*/
-
 		save_flag=1;
 		last_save_fd = sd->fd;
 	}