summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-29 16:32:28 +0000
committercelest <celest@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-03-29 16:32:28 +0000
commit51079611e59264b02fdbb4beb0d3675cc64618e6 (patch)
tree22591fb3e22bd877cf913893437da65bf9122680 /src
parent3f3a0e79643fecf5209128075028e375a4a5bb95 (diff)
downloadhercules-51079611e59264b02fdbb4beb0d3675cc64618e6.tar.gz
hercules-51079611e59264b02fdbb4beb0d3675cc64618e6.tar.bz2
hercules-51079611e59264b02fdbb4beb0d3675cc64618e6.tar.xz
hercules-51079611e59264b02fdbb4beb0d3675cc64618e6.zip
* Added auto save guild dataevery 5 minutes during WOE
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1333 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/char_sql/int_guild.c12
-rw-r--r--src/map/guild.c72
-rw-r--r--src/map/pc.c45
3 files changed, 67 insertions, 62 deletions
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index 5ec700a54..794f2e01f 100644
--- a/src/char_sql/int_guild.c
+++ b/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;
}
diff --git a/src/map/guild.c b/src/map/guild.c
index 431ef5dec..5ce0d5d64 100644
--- a/src/map/guild.c
+++ b/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;
diff --git a/src/map/pc.c b/src/map/pc.c
index 8b3a32c6f..3dcb08f3b 100644
--- a/src/map/pc.c
+++ b/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;
}