summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/char/char.c3
-rw-r--r--src/char/int_storage.c50
-rw-r--r--src/char/int_storage.h22
-rw-r--r--src/char/inter.c6
-rw-r--r--src/char/mapif.c14
-rw-r--r--src/char/mapif.h9
6 files changed, 77 insertions, 27 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 6f11768d2..a5525998f 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -1334,7 +1334,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
strcat(t_msg, " cart");
//read storage
- inter_storage_fromsql(p->account_id, &p->storage);
+ inter_storage->fromsql(p->account_id, &p->storage);
strcat(t_msg, " storage");
//read skill
@@ -6017,6 +6017,7 @@ void char_load_defaults(void)
inter_party_defaults();
inter_pet_defaults();
inter_quest_defaults();
+ inter_storage_defaults();
}
void char_defaults(void)
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index e3b09dea0..1f23475ed 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -13,6 +13,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
@@ -22,6 +23,8 @@
#define STORAGE_MEMINC 16
+struct inter_storage_interface inter_storage_s;
+
/// Save storage data to sql
int inter_storage_tosql(int account_id, struct storage_data* p)
{
@@ -164,7 +167,7 @@ int inter_storage_guild_storage_delete(int guild_id)
//---------------------------------------------------------
// packet from map server
-int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag)
+int mapif_load_guild_storage(int fd, int account_id, int guild_id, char flag)
{
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
Sql_ShowDebug(sql_handle);
@@ -176,7 +179,7 @@ int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag)
WFIFOL(fd,4) = account_id;
WFIFOL(fd,8) = guild_id;
WFIFOB(fd,12) = flag; //1 open storage, 0 don't open
- inter_storage_guild_storage_fromsql(guild_id, (struct guild_storage*)WFIFOP(fd,13));
+ inter_storage->guild_storage_fromsql(guild_id, (struct guild_storage*)WFIFOP(fd,13));
WFIFOSET(fd, WFIFOW(fd,2));
return 0;
}
@@ -190,7 +193,7 @@ int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag)
WFIFOSET(fd, 12);
return 0;
}
-int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail)
+int mapif_save_guild_storage_ack(int fd, int account_id, int guild_id, int fail)
{
WFIFOHEAD(fd,11);
WFIFOW(fd,0)=0x3819;
@@ -207,7 +210,7 @@ int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail)
int mapif_parse_LoadGuildStorage(int fd)
{
RFIFOHEAD(fd);
- mapif_load_guild_storage(fd,RFIFOL(fd,2),RFIFOL(fd,6),1);
+ mapif->load_guild_storage(fd,RFIFOL(fd,2),RFIFOL(fd,6),1);
return 0;
}
@@ -228,13 +231,13 @@ int mapif_parse_SaveGuildStorage(int fd)
} else if(SQL->NumRows(sql_handle) > 0) {
// guild exists
SQL->FreeResult(sql_handle);
- inter_storage_guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12));
- mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0);
+ inter_storage->guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12));
+ mapif->save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0);
return 0;
}
SQL->FreeResult(sql_handle);
}
- mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1);
+ mapif->save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1);
return 0;
}
@@ -249,6 +252,7 @@ int mapif_itembound_ack(int fd, int aid, int guild_id)
#endif
return 0;
}
+
//------------------------------------------------
//Guild bound items pull for offline characters [Akinari]
//Revised by [Mhalicot]
@@ -416,29 +420,47 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd)
SQL->StmtFree(stmt);
//Finally reload storage and tell map we're done
- mapif_load_guild_storage(fd,aid,guild_id,0);
+ mapif->load_guild_storage(fd,aid,guild_id,0);
// If character is logged in char, disconnect
chr->disconnect_player(aid);
#endif
return 0;
}
-void mapif_parse_ItemBoundRetrieve(int fd) {
- mapif_parse_ItemBoundRetrieve_sub(fd);
+
+void mapif_parse_ItemBoundRetrieve(int fd)
+{
+ mapif->parse_ItemBoundRetrieve_sub(fd);
/* tell map server the operation is over and it can unlock the storage */
- mapif_itembound_ack(fd,RFIFOL(fd,6),RFIFOW(fd,10));
+ mapif->itembound_ack(fd,RFIFOL(fd,6),RFIFOW(fd,10));
}
+
int inter_storage_parse_frommap(int fd)
{
RFIFOHEAD(fd);
switch(RFIFOW(fd,0)){
- case 0x3018: mapif_parse_LoadGuildStorage(fd); break;
- case 0x3019: mapif_parse_SaveGuildStorage(fd); break;
+ case 0x3018: mapif->parse_LoadGuildStorage(fd); break;
+ case 0x3019: mapif->parse_SaveGuildStorage(fd); break;
#ifdef GP_BOUND_ITEMS
- case 0x3056: mapif_parse_ItemBoundRetrieve(fd); break;
+ case 0x3056: mapif->parse_ItemBoundRetrieve(fd); break;
#endif
default:
return 0;
}
return 1;
}
+
+void inter_storage_defaults(void)
+{
+ inter_storage = &inter_storage_s;
+
+ inter_storage->tosql = inter_storage_tosql;
+ inter_storage->fromsql = inter_storage_fromsql;
+ inter_storage->guild_storage_tosql = inter_storage_guild_storage_tosql;
+ inter_storage->guild_storage_fromsql = inter_storage_guild_storage_fromsql;
+ inter_storage->sql_init = inter_storage_sql_init;
+ inter_storage->sql_final = inter_storage_sql_final;
+ inter_storage->delete_ = inter_storage_delete;
+ inter_storage->guild_storage_delete = inter_storage_guild_storage_delete;
+ inter_storage->parse_frommap = inter_storage_parse_frommap;
+}
diff --git a/src/char/int_storage.h b/src/char/int_storage.h
index abf4703f9..6da60f4a8 100644
--- a/src/char/int_storage.h
+++ b/src/char/int_storage.h
@@ -7,16 +7,20 @@
struct storage_data;
struct guild_storage;
-int inter_storage_sql_init(void);
-void inter_storage_sql_final(void);
-int inter_storage_delete(int account_id);
-int inter_storage_guild_storage_delete(int guild_id);
+void inter_storage_defaults(void);
-int inter_storage_parse_frommap(int fd);
+struct inter_storage_interface {
+ int (*tosql) (int account_id, struct storage_data* p);
+ int (*fromsql) (int account_id, struct storage_data* p);
+ int (*guild_storage_tosql) (int guild_id, struct guild_storage* p);
+ int (*guild_storage_fromsql) (int guild_id, struct guild_storage* p);
+ int (*sql_init) (void);
+ void (*sql_final) (void);
+ int (*delete_) (int account_id);
+ int (*guild_storage_delete) (int guild_id);
+ int (*parse_frommap) (int fd);
+};
-//Exported for use in the TXT-SQL converter.
-int inter_storage_fromsql(int account_id, struct storage_data* p);
-int inter_storage_tosql(int account_id,struct storage_data *p);
-int inter_storage_guild_storage_tosql(int guild_id, struct guild_storage *p);
+struct inter_storage_interface *inter_storage;
#endif /* CHAR_INT_STORAGE_H */
diff --git a/src/char/inter.c b/src/char/inter.c
index db5dc822c..ad624ff73 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -1027,7 +1027,7 @@ int inter_init_sql(const char *file)
wis_db = idb_alloc(DB_OPT_RELEASE_DATA);
inter_guild->sql_init();
- inter_storage_sql_init();
+ inter_storage->sql_init();
inter_party->sql_init();
inter_pet->sql_init();
inter_homunculus->sql_init();
@@ -1047,7 +1047,7 @@ void inter_final(void)
wis_db->destroy(wis_db, NULL);
inter_guild->sql_final();
- inter_storage_sql_final();
+ inter_storage->sql_final();
inter_party->sql_final();
inter_pet->sql_final();
inter_homunculus->sql_final();
@@ -1455,7 +1455,7 @@ int inter_parse_frommap(int fd)
default:
if( inter_party->parse_frommap(fd)
|| inter_guild->parse_frommap(fd)
- || inter_storage_parse_frommap(fd)
+ || inter_storage->parse_frommap(fd)
|| inter_pet->parse_frommap(fd)
|| inter_homunculus->parse_frommap(fd)
|| inter_mercenary->parse_frommap(fd)
diff --git a/src/char/mapif.c b/src/char/mapif.c
index a50f10a38..6b6d41cb9 100644
--- a/src/char/mapif.c
+++ b/src/char/mapif.c
@@ -163,6 +163,13 @@ void mapif_quest_save_ack(int fd, int char_id, bool success);
int mapif_parse_quest_save(int fd);
void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_quests);
int mapif_parse_quest_load(int fd);
+int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag);
+int mapif_save_guild_storage_ack(int fd, int account_id, int guild_id, int fail);
+int mapif_parse_LoadGuildStorage(int fd);
+int mapif_parse_SaveGuildStorage(int fd);
+int mapif_itembound_ack(int fd, int aid, int guild_id);
+int mapif_parse_ItemBoundRetrieve_sub(int fd);
+void mapif_parse_ItemBoundRetrieve(int fd);
void mapif_defaults(void) {
mapif = &mapif_s;
@@ -310,4 +317,11 @@ void mapif_defaults(void) {
mapif->parse_quest_save = mapif_parse_quest_save;
mapif->send_quests = mapif_send_quests;
mapif->parse_quest_load = mapif_parse_quest_load;
+ mapif->load_guild_storage = mapif_load_guild_storage;
+ mapif->save_guild_storage_ack = mapif_save_guild_storage_ack;
+ mapif->parse_LoadGuildStorage = mapif_parse_LoadGuildStorage;
+ mapif->parse_SaveGuildStorage = mapif_parse_SaveGuildStorage;
+ mapif->itembound_ack = mapif_itembound_ack;
+ mapif->parse_ItemBoundRetrieve_sub = mapif_parse_ItemBoundRetrieve_sub;
+ mapif->parse_ItemBoundRetrieve = mapif_parse_ItemBoundRetrieve;
}
diff --git a/src/char/mapif.h b/src/char/mapif.h
index b67d07611..a990ad4b4 100644
--- a/src/char/mapif.h
+++ b/src/char/mapif.h
@@ -11,6 +11,8 @@ struct s_elemental;
struct s_homunculus;
struct s_mercenary;
struct s_pet;
+struct guild_storage;
+struct storage_data;
struct quest;
struct mail_message;
@@ -160,6 +162,13 @@ struct mapif_interface {
int (*parse_quest_save) (int fd);
void (*send_quests) (int fd, int char_id, struct quest *tmp_questlog, int num_quests);
int (*parse_quest_load) (int fd);
+ int (*load_guild_storage) (int fd, int account_id, int guild_id, char flag);
+ int (*save_guild_storage_ack) (int fd, int account_id, int guild_id, int fail);
+ int (*parse_LoadGuildStorage) (int fd);
+ int (*parse_SaveGuildStorage) (int fd);
+ int (*itembound_ack) (int fd, int aid, int guild_id);
+ int (*parse_ItemBoundRetrieve_sub) (int fd);
+ void (*parse_ItemBoundRetrieve) (int fd);
} mapif_s;
struct mapif_interface *mapif;