summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c3
-rw-r--r--src/char/int_elemental.c51
-rw-r--r--src/char/int_elemental.h12
-rw-r--r--src/char/inter.c6
-rw-r--r--src/char/mapif.c20
-rw-r--r--src/char/mapif.h12
6 files changed, 77 insertions, 27 deletions
diff --git a/src/char/char.c b/src/char/char.c
index d789de027..7097725c5 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -1817,7 +1817,7 @@ int char_delete_char_sql(int char_id)
/* remove elemental */
if (elemental_id)
- mapif_elemental_delete(elemental_id);
+ mapif->elemental_delete(elemental_id);
/* remove mercenary data */
inter_mercenary_owner_delete(char_id);
@@ -6006,6 +6006,7 @@ void char_load_defaults(void)
loginif_defaults();
mapif_defaults();
inter_auction_defaults();
+ inter_elemental_defaults();
}
void char_defaults(void)
diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c
index 3a36e75a2..d54a13320 100644
--- a/src/char/int_elemental.c
+++ b/src/char/int_elemental.c
@@ -12,6 +12,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
@@ -20,6 +21,8 @@
#include "../common/strlib.h"
#include "../common/utils.h"
+struct inter_elemental_interface inter_elemental_s;
+
bool mapif_elemental_save(struct s_elemental* ele) {
bool flag = true;
@@ -99,7 +102,7 @@ bool mapif_elemental_delete(int ele_id) {
return true;
}
-static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) {
+void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) {
int size = sizeof(struct s_elemental) + 5;
WFIFOHEAD(fd,size);
@@ -110,44 +113,45 @@ static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char
WFIFOSET(fd,size);
}
-static void mapif_parse_elemental_create(int fd, struct s_elemental* ele) {
- bool result = mapif_elemental_save(ele);
- mapif_elemental_send(fd, ele, result);
+void mapif_parse_elemental_create(int fd, struct s_elemental* ele) {
+ bool result = mapif->elemental_save(ele);
+ mapif->elemental_send(fd, ele, result);
}
-static void mapif_parse_elemental_load(int fd, int ele_id, int char_id) {
+void mapif_parse_elemental_load(int fd, int ele_id, int char_id) {
struct s_elemental ele;
- bool result = mapif_elemental_load(ele_id, char_id, &ele);
- mapif_elemental_send(fd, &ele, result);
+ bool result = mapif->elemental_load(ele_id, char_id, &ele);
+ mapif->elemental_send(fd, &ele, result);
}
-static void mapif_elemental_deleted(int fd, unsigned char flag) {
+void mapif_elemental_deleted(int fd, unsigned char flag) {
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x387d;
WFIFOB(fd,2) = flag;
WFIFOSET(fd,3);
}
-static void mapif_parse_elemental_delete(int fd, int ele_id) {
- bool result = mapif_elemental_delete(ele_id);
- mapif_elemental_deleted(fd, result);
+void mapif_parse_elemental_delete(int fd, int ele_id) {
+ bool result = mapif->elemental_delete(ele_id);
+ mapif->elemental_deleted(fd, result);
}
-static void mapif_elemental_saved(int fd, unsigned char flag) {
+void mapif_elemental_saved(int fd, unsigned char flag) {
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x387e;
WFIFOB(fd,2) = flag;
WFIFOSET(fd,3);
}
-static void mapif_parse_elemental_save(int fd, struct s_elemental* ele) {
- bool result = mapif_elemental_save(ele);
- mapif_elemental_saved(fd, result);
+void mapif_parse_elemental_save(int fd, struct s_elemental* ele) {
+ bool result = mapif->elemental_save(ele);
+ mapif->elemental_saved(fd, result);
}
void inter_elemental_sql_init(void) {
return;
}
+
void inter_elemental_sql_final(void) {
return;
}
@@ -159,12 +163,21 @@ int inter_elemental_parse_frommap(int fd) {
unsigned short cmd = RFIFOW(fd,0);
switch( cmd ) {
- case 0x307c: mapif_parse_elemental_create(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
- case 0x307d: mapif_parse_elemental_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
- case 0x307e: mapif_parse_elemental_delete(fd, (int)RFIFOL(fd,2)); break;
- case 0x307f: mapif_parse_elemental_save(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
+ case 0x307c: mapif->parse_elemental_create(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
+ case 0x307d: mapif->parse_elemental_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
+ case 0x307e: mapif->parse_elemental_delete(fd, (int)RFIFOL(fd,2)); break;
+ case 0x307f: mapif->parse_elemental_save(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
default:
return 0;
}
return 1;
}
+
+void inter_elemental_defaults(void)
+{
+ inter_elemental = &inter_elemental_s;
+
+ inter_elemental->sql_init = inter_elemental_sql_init;
+ inter_elemental->sql_final = inter_elemental_sql_final;
+ inter_elemental->parse_frommap = inter_elemental_parse_frommap;
+}
diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h
index e28cfedea..d9ad6ec29 100644
--- a/src/char/int_elemental.h
+++ b/src/char/int_elemental.h
@@ -6,10 +6,14 @@
#include "../common/cbasetypes.h"
-void inter_elemental_sql_init(void);
-void inter_elemental_sql_final(void);
-int inter_elemental_parse_frommap(int fd);
+void inter_elemental_defaults(void);
-bool mapif_elemental_delete(int ele_id);
+struct inter_elemental_interface {
+ void (*sql_init) (void);
+ void (*sql_final) (void);
+ int (*parse_frommap) (int fd);
+};
+
+struct inter_elemental_interface *inter_elemental;
#endif /* CHAR_INT_ELEMENTAL_H */
diff --git a/src/char/inter.c b/src/char/inter.c
index 2df4d668f..13fdd8830 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -1032,7 +1032,7 @@ int inter_init_sql(const char *file)
inter_pet_sql_init();
inter_homunculus_sql_init();
inter_mercenary_sql_init();
- inter_elemental_sql_init();
+ inter_elemental->sql_init();
inter_mail_sql_init();
inter_auction->sql_init();
@@ -1052,7 +1052,7 @@ void inter_final(void)
inter_pet_sql_final();
inter_homunculus_sql_final();
inter_mercenary_sql_final();
- inter_elemental_sql_final();
+ inter_elemental->sql_final();
inter_mail_sql_final();
inter_auction->sql_final();
@@ -1459,7 +1459,7 @@ int inter_parse_frommap(int fd)
|| inter_pet_parse_frommap(fd)
|| inter_homunculus_parse_frommap(fd)
|| inter_mercenary_parse_frommap(fd)
- || inter_elemental_parse_frommap(fd)
+ || inter_elemental->parse_frommap(fd)
|| inter_mail_parse_frommap(fd)
|| inter_auction->parse_frommap(fd)
|| inter_quest_parse_frommap(fd)
diff --git a/src/char/mapif.c b/src/char/mapif.c
index dfa8f437b..e3cc9f0e3 100644
--- a/src/char/mapif.c
+++ b/src/char/mapif.c
@@ -39,6 +39,16 @@ void mapif_auction_close(int fd, int char_id, unsigned char result);
void mapif_parse_auction_close(int fd);
void mapif_auction_bid(int fd, int char_id, int bid, unsigned char result);
void mapif_parse_auction_bid(int fd);
+bool mapif_elemental_save(struct s_elemental* ele);
+bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele);
+bool mapif_elemental_delete(int ele_id);
+void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag);
+void mapif_parse_elemental_create(int fd, struct s_elemental* ele);
+void mapif_parse_elemental_load(int fd, int ele_id, int char_id);
+void mapif_elemental_deleted(int fd, unsigned char flag);
+void mapif_parse_elemental_delete(int fd, int ele_id);
+void mapif_elemental_saved(int fd, unsigned char flag);
+void mapif_parse_elemental_save(int fd, struct s_elemental* ele);
void mapif_defaults(void) {
mapif = &mapif_s;
@@ -65,4 +75,14 @@ void mapif_defaults(void) {
mapif->parse_auction_close = mapif_parse_auction_close;
mapif->auction_bid = mapif_auction_bid;
mapif->parse_auction_bid = mapif_parse_auction_bid;
+ mapif->elemental_save = mapif_elemental_save;
+ mapif->elemental_load = mapif_elemental_load;
+ mapif->elemental_delete = mapif_elemental_delete;
+ mapif->elemental_send = mapif_elemental_send;
+ mapif->parse_elemental_create = mapif_parse_elemental_create;
+ mapif->parse_elemental_load = mapif_parse_elemental_load;
+ mapif->elemental_deleted = mapif_elemental_deleted;
+ mapif->parse_elemental_delete = mapif_parse_elemental_delete;
+ mapif->elemental_saved = mapif_elemental_saved;
+ mapif->parse_elemental_save = mapif_parse_elemental_save;
}
diff --git a/src/char/mapif.h b/src/char/mapif.h
index 6ba6e5924..16c8627b1 100644
--- a/src/char/mapif.h
+++ b/src/char/mapif.h
@@ -7,6 +7,8 @@
#include "char.h"
+struct s_elemental;
+
/* mapif interface */
struct mapif_interface {
void (*ban) (int id, unsigned int flag, int status);
@@ -31,6 +33,16 @@ struct mapif_interface {
void (*parse_auction_close) (int fd);
void (*auction_bid) (int fd, int char_id, int bid, unsigned char result);
void (*parse_auction_bid) (int fd);
+ bool (*elemental_save) (struct s_elemental* ele);
+ bool (*elemental_load) (int ele_id, int char_id, struct s_elemental *ele);
+ bool (*elemental_delete) (int ele_id);
+ void (*elemental_send) (int fd, struct s_elemental *ele, unsigned char flag);
+ void (*parse_elemental_create) (int fd, struct s_elemental* ele);
+ void (*parse_elemental_load) (int fd, int ele_id, int char_id);
+ void (*elemental_deleted) (int fd, unsigned char flag);
+ void (*parse_elemental_delete) (int fd, int ele_id);
+ void (*elemental_saved) (int fd, unsigned char flag);
+ void (*parse_elemental_save) (int fd, struct s_elemental* ele);
} mapif_s;
struct mapif_interface *mapif;