summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/HPMchar.c20
-rw-r--r--src/char/HPMchar.h2
-rw-r--r--src/char/char.c98
-rw-r--r--src/char/char.h7
-rw-r--r--src/char/geoip.c2
-rw-r--r--src/char/int_auction.c2
-rw-r--r--src/char/int_elemental.c2
-rw-r--r--src/char/int_guild.c2
-rw-r--r--src/char/int_homun.c2
-rw-r--r--src/char/int_mail.c2
-rw-r--r--src/char/int_mercenary.c2
-rw-r--r--src/char/int_party.c2
-rw-r--r--src/char/int_pet.c2
-rw-r--r--src/char/int_quest.c2
-rw-r--r--src/char/int_storage.c2
-rw-r--r--src/char/inter.c2
-rw-r--r--src/char/loginif.c4
17 files changed, 78 insertions, 77 deletions
diff --git a/src/char/HPMchar.c b/src/char/HPMchar.c
index a67f017c1..99e7c598f 100644
--- a/src/char/HPMchar.c
+++ b/src/char/HPMchar.c
@@ -31,7 +31,7 @@
#include "common/db.h"
#include "common/des.h"
#include "common/ers.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mapindex.h"
#include "common/mmo.h"
#include "common/nullpo.h"
@@ -47,13 +47,19 @@
// HPMDataCheck comes after all the other includes
#include "common/HPMDataCheck.h"
-bool HPM_char_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) {
- /* record address */
- switch( type ) {
+/**
+ * HPM plugin data store validator sub-handler (char-server)
+ *
+ * @see HPM_interface::data_store_validate
+ */
+bool HPM_char_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize)
+{
+ switch (type) {
+ // No supported types at the moment.
default:
- return false;
+ break;
}
- return true;
+ return false;
}
void HPM_char_plugin_load_sub(struct hplugin *plugin) {
@@ -61,6 +67,8 @@ void HPM_char_plugin_load_sub(struct hplugin *plugin) {
}
void HPM_char_do_init(void) {
+ HPM->load_sub = HPM_char_plugin_load_sub;
+ HPM->data_store_validate_sub = HPM_char_data_store_validate;
HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer);
HPM_shared_symbols(SERVER_TYPE_CHAR);
}
diff --git a/src/char/HPMchar.h b/src/char/HPMchar.h
index e3e000ef3..431017b7a 100644
--- a/src/char/HPMchar.h
+++ b/src/char/HPMchar.h
@@ -13,7 +13,7 @@
struct hplugin;
-bool HPM_char_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr);
+bool HPM_char_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize);
void HPM_char_plugin_load_sub(struct hplugin *plugin);
diff --git a/src/char/char.c b/src/char/char.c
index 3cc8853a4..41b13b3db 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -29,7 +29,7 @@
#include "common/console.h"
#include "common/core.h"
#include "common/db.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mapindex.h"
#include "common/mmo.h"
#include "common/nullpo.h"
@@ -94,10 +94,6 @@ int save_log = 1;
char db_path[1024] = "db";
-int db_use_sql_item_db;
-int db_use_sql_mob_db;
-int db_use_sql_mob_skill_db;
-
char wisp_server_name[NAME_LENGTH] = "Server";
char login_ip_str[128];
uint32 login_ip = 0;
@@ -2626,10 +2622,12 @@ int char_parse_fromlogin(int fd) {
while(RFIFOREST(fd) >= 2) {
uint16 command = RFIFOW(fd,0);
- if( HPM->packetsc[hpParse_FromLogin] ) {
- int success = HPM->parse_packets(fd,hpParse_FromLogin);
- if( success == 1 ) continue;
- else if( success == 2 ) return 0;
+ if (VECTOR_LENGTH(HPM->packets[hpParse_FromLogin]) > 0) {
+ int result = HPM->parse_packets(fd,hpParse_FromLogin);
+ if (result == 1)
+ continue;
+ if (result == 2)
+ return 0;
}
switch (command) {
@@ -2965,9 +2963,11 @@ void mapif_server_reset(int id)
WBUFL(buf,4) = htonl(chr->server[id].ip);
WBUFW(buf,8) = htons(chr->server[id].port);
j = 0;
- for(i = 0; i < chr->server[id].maps; i++)
- if (chr->server[id].map[i])
- WBUFW(buf,10+(j++)*4) = chr->server[id].map[i];
+ for (i = 0; i < VECTOR_LENGTH(chr->server[id].maps); i++) {
+ uint16 m = VECTOR_INDEX(chr->server[id].maps, i);
+ if (m != 0)
+ WBUFW(buf,10+(j++)*4) = m;
+ }
if (j > 0) {
WBUFW(buf,2) = j * 4 + 10;
mapif->sendallwos(fd, buf, WBUFW(buf,2));
@@ -3050,14 +3050,16 @@ void char_send_maps(int fd, int id, int j)
// Transmitting the maps of the other map-servers to the new map-server
for(k = 0; k < ARRAYLENGTH(chr->server); k++) {
if (chr->server[k].fd > 0 && k != id) {
- WFIFOHEAD(fd,10 +4*chr->server[k].maps);
+ WFIFOHEAD(fd,10 + 4 * VECTOR_LENGTH(chr->server[k].maps));
WFIFOW(fd,0) = 0x2b04;
WFIFOL(fd,4) = htonl(chr->server[k].ip);
WFIFOW(fd,8) = htons(chr->server[k].port);
j = 0;
- for(i = 0; i < chr->server[k].maps; i++)
- if (chr->server[k].map[i])
- WFIFOW(fd,10+(j++)*4) = chr->server[k].map[i];
+ for(i = 0; i < VECTOR_LENGTH(chr->server[k].maps); i++) {
+ uint16 m = VECTOR_INDEX(chr->server[k].maps, i);
+ if (m != 0)
+ WFIFOW(fd,10+(j++)*4) = m;
+ }
if (j > 0) {
WFIFOW(fd,2) = j * 4 + 10;
WFIFOSET(fd,WFIFOW(fd,2));
@@ -3068,27 +3070,22 @@ void char_send_maps(int fd, int id, int j)
void char_parse_frommap_map_names(int fd, int id)
{
- int i,j = 0;
-
- if( chr->server[id].map != NULL ) { aFree(chr->server[id].map); chr->server[id].map = NULL; }
-
- chr->server[id].maps = ( RFIFOW(fd, 2) - 4 ) / 4;
- CREATE(chr->server[id].map, unsigned short, chr->server[id].maps);
-
+ int i;
- for(i = 4; i < RFIFOW(fd,2); i += 4) {
- chr->server[id].map[j] = RFIFOW(fd,i);
- j++;
+ VECTOR_CLEAR(chr->server[id].maps);
+ VECTOR_ENSURE(chr->server[id].maps, (RFIFOW(fd, 2) - 4) / 4, 1);
+ for (i = 4; i < RFIFOW(fd,2); i += 4) {
+ VECTOR_PUSH(chr->server[id].maps, RFIFOW(fd,i));
}
ShowStatus("Map-Server %d connected: %d maps, from IP %d.%d.%d.%d port %d.\n",
- id, j, CONVIP(chr->server[id].ip), chr->server[id].port);
+ id, (int)VECTOR_LENGTH(chr->server[id].maps), CONVIP(chr->server[id].ip), chr->server[id].port);
ShowStatus("Map-server %d loading complete.\n", id);
// send name for wisp to player
chr->map_received_ok(fd);
chr->send_fame_list(fd); //Send fame list.
- chr->send_maps(fd, id, j);
+ chr->send_maps(fd, id, (int)VECTOR_LENGTH(chr->server[id].maps));
RFIFOSKIP(fd,RFIFOW(fd,2));
}
@@ -3896,7 +3893,6 @@ void char_parse_frommap_scdata_delete(int fd)
int char_parse_frommap(int fd)
{
- int i;
int id;
ARR_FIND( 0, ARRAYLENGTH(chr->server), id, chr->server[id].fd == fd );
@@ -3913,11 +3909,12 @@ int char_parse_frommap(int fd)
}
while(RFIFOREST(fd) >= 2) {
- if( HPM->packetsc[hpParse_FromMap] ) {
- if( (i = HPM->parse_packets(fd,hpParse_FromMap)) ) {
- if( i == 1 ) continue;
- if( i == 2 ) return 0;
- }
+ if (VECTOR_LENGTH(HPM->packets[hpParse_FromMap]) > 0) {
+ int result = HPM->parse_packets(fd,hpParse_FromMap);
+ if (result == 1)
+ continue;
+ if (result == 2)
+ return 0;
}
switch(RFIFOW(fd,0)) {
@@ -4154,11 +4151,11 @@ int char_search_mapserver(unsigned short map, uint32 ip, uint16 port)
{
if (chr->server[i].fd > 0
&& (ip == (uint32)-1 || chr->server[i].ip == ip)
- && (port == (uint16)-1 || chr->server[i].port == port))
- {
- for (j = 0; chr->server[i].map[j]; j++)
- if (chr->server[i].map[j] == map)
- return i;
+ && (port == (uint16)-1 || chr->server[i].port == port)
+ ) {
+ ARR_FIND(0, VECTOR_LENGTH(chr->server[i].maps), j, VECTOR_INDEX(chr->server[i].maps, j) == map);
+ if (j != VECTOR_LENGTH(chr->server[i].maps))
+ return i;
}
}
@@ -4577,7 +4574,7 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
}
#endif
- ARR_FIND( 0, ARRAYLENGTH(chr->server), server_id, chr->server[server_id].fd > 0 && chr->server[server_id].map );
+ ARR_FIND(0, ARRAYLENGTH(chr->server), server_id, chr->server[server_id].fd > 0 && VECTOR_LENGTH(chr->server[server_id].maps) > 0);
/* not available, tell it to wait (client wont close; char select will respawn).
* magic response found by Ind thanks to Yommy <3 */
if( server_id == ARRAYLENGTH(chr->server) ) {
@@ -4638,7 +4635,7 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl)
if (i < 0 || !cd->last_point.map) {
unsigned short j;
//First check that there's actually a map server online.
- ARR_FIND( 0, ARRAYLENGTH(chr->server), j, chr->server[j].fd >= 0 && chr->server[j].map );
+ ARR_FIND(0, ARRAYLENGTH(chr->server), j, chr->server[j].fd >= 0 && VECTOR_LENGTH(chr->server[j].maps) > 0);
if (j == ARRAYLENGTH(chr->server)) {
ShowInfo("Connection Closed. No map servers available.\n");
chr->authfail_fd(fd, 1); // 1 = Server closed
@@ -5095,10 +5092,12 @@ int char_parse_char(int fd)
//For use in packets that depend on an sd being present [Skotlex]
#define FIFOSD_CHECK(rest) do { if(RFIFOREST(fd) < (rest)) return 0; if (sd==NULL || !sd->auth) { RFIFOSKIP(fd,(rest)); return 0; } } while (0)
- if( HPM->packetsc[hpParse_Char] ) {
- int success = HPM->parse_packets(fd,hpParse_Char);
- if( success == 1 ) continue;
- else if( success == 2 ) return 0;
+ if (VECTOR_LENGTH(HPM->packets[hpParse_Char]) > 0) {
+ int result = HPM->parse_packets(fd,hpParse_Char);
+ if (result == 1)
+ continue;
+ if (result == 2)
+ return 0;
}
cmd = RFIFOW(fd,0);
@@ -5785,9 +5784,8 @@ int do_final(void) {
SQL->Free(inter->sql_handle);
mapindex->final();
- for(i = 0; i < MAX_MAP_SERVERS; i++ )
- if( chr->server[i].map )
- aFree(chr->server[i].map);
+ for (i = 0; i < MAX_MAP_SERVERS; i++)
+ VECTOR_CLEAR(chr->server[i].maps);
aFree(chr->CHAR_CONF_NAME);
aFree(chr->NET_CONF_NAME);
@@ -5886,8 +5884,8 @@ int do_init(int argc, char **argv) {
chr->SQL_CONF_NAME = aStrdup("conf/inter-server.conf");
chr->INTER_CONF_NAME = aStrdup("conf/inter-server.conf");
- for(i = 0; i < MAX_MAP_SERVERS; i++ )
- chr->server[i].map = NULL;
+ for (i = 0; i < MAX_MAP_SERVERS; i++)
+ VECTOR_INIT(chr->server[i].maps);
HPM_char_do_init();
cmdline->exec(argc, argv, CMDLINE_OPT_PREINIT);
diff --git a/src/char/char.h b/src/char/char.h
index e79cc1898..7576b00ce 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -49,8 +49,7 @@ struct mmo_map_server {
uint32 ip;
uint16 port;
int users;
- unsigned short *map;
- unsigned short maps;
+ VECTOR_DECL(uint16) maps;
};
#define MAX_MAP_SERVERS 2
@@ -299,10 +298,6 @@ extern char acc_reg_str_db[32];
extern char char_reg_str_db[32];
extern char char_reg_num_db[32];
-extern int db_use_sql_item_db;
-extern int db_use_sql_mob_db;
-extern int db_use_sql_mob_skill_db;
-
extern int guild_exp_rate;
extern int log_inter;
diff --git a/src/char/geoip.c b/src/char/geoip.c
index 65bb2bdd4..924c1cd83 100644
--- a/src/char/geoip.c
+++ b/src/char/geoip.c
@@ -7,7 +7,7 @@
#include "geoip.h"
#include "common/cbasetypes.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/showmsg.h"
#include <errno.h>
diff --git a/src/char/int_auction.c b/src/char/int_auction.c
index 67c83ca22..48bf715f2 100644
--- a/src/char/int_auction.c
+++ b/src/char/int_auction.c
@@ -12,7 +12,7 @@
#include "char/mapif.h"
#include "common/cbasetypes.h"
#include "common/db.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c
index e7708179a..3969e5e43 100644
--- a/src/char/int_elemental.c
+++ b/src/char/int_elemental.c
@@ -9,7 +9,7 @@
#include "char/char.h"
#include "char/inter.h"
#include "char/mapif.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index 54355161d..239e8a296 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -12,7 +12,7 @@
#include "char/mapif.h"
#include "common/cbasetypes.h"
#include "common/db.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index be72ecd58..78b4dbb61 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -9,7 +9,7 @@
#include "char/char.h"
#include "char/inter.h"
#include "char/mapif.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
diff --git a/src/char/int_mail.c b/src/char/int_mail.c
index 854fe31b1..933856b14 100644
--- a/src/char/int_mail.c
+++ b/src/char/int_mail.c
@@ -9,7 +9,7 @@
#include "char/char.h"
#include "char/inter.h"
#include "char/mapif.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c
index dd40a0224..fb98161fe 100644
--- a/src/char/int_mercenary.c
+++ b/src/char/int_mercenary.c
@@ -10,7 +10,7 @@
#include "char/inter.h"
#include "char/mapif.h"
#include "common/cbasetypes.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
diff --git a/src/char/int_party.c b/src/char/int_party.c
index aedcb8535..d4af67eb3 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -11,7 +11,7 @@
#include "char/mapif.h"
#include "common/cbasetypes.h"
#include "common/db.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mapindex.h"
#include "common/mmo.h"
#include "common/nullpo.h"
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index 97b2fb6a4..37e238725 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -9,7 +9,7 @@
#include "char/char.h"
#include "char/inter.h"
#include "char/mapif.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
diff --git a/src/char/int_quest.c b/src/char/int_quest.c
index fcd56230b..e2ee3401a 100644
--- a/src/char/int_quest.c
+++ b/src/char/int_quest.c
@@ -10,7 +10,7 @@
#include "char/inter.h"
#include "char/mapif.h"
#include "common/cbasetypes.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index 3a8a6a169..c0cae5300 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -10,7 +10,7 @@
#include "char/char.h"
#include "char/inter.h"
#include "char/mapif.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
diff --git a/src/char/inter.c b/src/char/inter.c
index 65048a9f9..1ed29719e 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -21,7 +21,7 @@
#include "char/mapif.h"
#include "common/cbasetypes.h"
#include "common/db.h"
-#include "common/malloc.h"
+#include "common/memmgr.h"
#include "common/mmo.h"
#include "common/nullpo.h"
#include "common/showmsg.h"
diff --git a/src/char/loginif.c b/src/char/loginif.c
index 422c7c589..e99e05237 100644
--- a/src/char/loginif.c
+++ b/src/char/loginif.c
@@ -63,8 +63,8 @@ void loginif_on_ready(void)
chr->send_accounts_tologin(INVALID_TIMER, timer->gettick(), 0, 0);
// if no map-server already connected, display a message...
- ARR_FIND( 0, ARRAYLENGTH(chr->server), i, chr->server[i].fd > 0 && chr->server[i].map );
- if( i == ARRAYLENGTH(chr->server) )
+ ARR_FIND(0, ARRAYLENGTH(chr->server), i, chr->server[i].fd > 0 && VECTOR_LENGTH(chr->server[i].maps));
+ if (i == ARRAYLENGTH(chr->server))
ShowStatus("Awaiting maps from map-server.\n");
}