summaryrefslogtreecommitdiff
path: root/src/char_sql
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-07-26 20:45:57 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-07-26 20:45:57 +0000
commit1624d1d57db3cfde3b4f42a55580f5a1e742f28e (patch)
treeaedd8d2afa77616e61bf8f50249575294b06a528 /src/char_sql
parente3879120d578c07cc6ca2dfeeec577e8461a6c52 (diff)
downloadhercules-1624d1d57db3cfde3b4f42a55580f5a1e742f28e.tar.gz
hercules-1624d1d57db3cfde3b4f42a55580f5a1e742f28e.tar.bz2
hercules-1624d1d57db3cfde3b4f42a55580f5a1e742f28e.tar.xz
hercules-1624d1d57db3cfde3b4f42a55580f5a1e742f28e.zip
Merged the /loginmerge branch (topic:192754)
* the login server storage, ipban and logging systems have been abstracted and now provide a common interface; the rest has been merged into a single login server core (no more login/login_sql duplicity) * storage systems are now added via compiler options (WITH_SQL / WITH_TXT) * multiple storage engines can be compiled in at the same time, and the config option account.engine defines which one will be used. * due to MySQL autoincrement limitations, accounts with id '0' will not be supported; account IDs from this point on should start from '1'. * login_log() functions now again record IP addresses in dotted format, not as 4-byte integers (undo from r6868). * removed config options that defined column names in the login table * removed `memo` and `error message` columns from login db/savefile * moved `loginlog` table to the logs database * added sql files upgrade_svn12975.sql and upgrade_svn12975_log.sql * due to changes to the login table layout, I added an !optional! sql file (upgrade_svn12975_view.sql) that will provide a certain degree of backwards compatibility with existing software; read the instructions inside carefully! * moved third-party includes/libs to a separate directory * updated project files / makefiles Changed the way GM levels are handled * removed conf/gm_account.txt * added the gm level column to the txt savefile (after 'email' column) * gm level information is now transferred along with account data For open problems see bugreport:1889. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13000 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql')
-rw-r--r--src/char_sql/char.c188
-rw-r--r--src/char_sql/char.h8
-rw-r--r--src/char_sql/inter.c177
-rw-r--r--src/char_sql/inter.h15
4 files changed, 46 insertions, 342 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 0ce2aecf6..f11fb7896 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -69,12 +69,6 @@ char db_path[1024] = "db";
int db_use_sqldbs;
-char login_db[256] = "login";
-char login_db_account_id[32] = "account_id";
-char login_db_level[32] = "level";
-
-int lowest_gm_level = 1;
-
struct mmo_map_server {
int fd;
uint32 ip;
@@ -135,6 +129,7 @@ struct char_session_data {
int found_char[MAX_CHARS]; // ids of chars on this account
char email[40]; // e-mail (default: a@a.com) by [Yor]
time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
+ int gmlevel;
};
int char_num, char_max;
@@ -164,10 +159,6 @@ unsigned int save_flag = 0;
// Initial position (it's possible to set it in conf file)
struct point start_point = { 0, 53, 111 };
-bool char_gm_read = false;
-struct gm_account *gm_account = NULL;
-int GM_num = 0;
-
int console = 0;
//-----------------------------------------------------
@@ -183,6 +174,7 @@ struct auth_node {
uint32 ip;
int sex;
time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
+ int gmlevel;
};
static DBMap* auth_db; // int account_id -> struct auth_node*
@@ -394,53 +386,6 @@ void set_all_offline_sql(void)
Sql_ShowDebug(sql_handle);
}
-//----------------------------------------------------------------------
-// Determine if an account (id) is a GM account
-// and returns its level (or 0 if it isn't a GM account or if not found)
-//----------------------------------------------------------------------
-int isGM(int account_id)
-{
- int i;
-
- for(i = 0; i < GM_num; i++)
- if (gm_account[i].account_id == account_id)
- return gm_account[i].level;
- return 0;
-}
-
-void read_gm_account(void)
-{
- if(!char_gm_read)
- return;
-
- if (gm_account != NULL)
- aFree(gm_account);
- GM_num = 0;
-
- if( SQL_ERROR == Sql_Query(lsql_handle, "SELECT `%s`,`%s` FROM `%s` WHERE `%s`>='%d'", login_db_account_id, login_db_level, login_db, login_db_level, lowest_gm_level) )
- Sql_ShowDebug(lsql_handle);
-
- if( Sql_NumRows(lsql_handle) > 0 )
- {
- char* data;
-
- CREATE(gm_account, struct gm_account, (size_t)Sql_NumRows(lsql_handle));
- while( SQL_SUCCESS == Sql_NextRow(lsql_handle) )
- {
- // account_id
- Sql_GetData(lsql_handle, 0, &data, NULL);
- gm_account[GM_num].account_id = atoi(data);
- // account_id
- Sql_GetData(lsql_handle, 1, &data, NULL);
- gm_account[GM_num].level = atoi(data);
- ++GM_num;
- }
- }
- Sql_FreeResult(lsql_handle);
-
- mapif_send_gmaccounts();
-}
-
static void* create_charstatus(DBKey key, va_list args)
{
struct mmo_charstatus *cp;
@@ -1636,7 +1581,7 @@ int char_family(int pl1, int pl2, int pl3)
static void char_auth_ok(int fd, struct char_session_data *sd)
{
struct online_char_data* character;
- if (max_connect_user && count_users() >= max_connect_user && isGM(sd->account_id) < gm_allow_level)
+ if (max_connect_user && count_users() >= max_connect_user && sd->gmlevel < gm_allow_level)
{
// refuse connection (over populated)
WFIFOW(fd,0) = 0x6c;
@@ -1742,7 +1687,7 @@ int parse_fromlogin(int fd)
// acknowledgement of account authentication request
case 0x2713:
- if (RFIFOREST(fd) < 59)
+ if (RFIFOREST(fd) < 60)
return 0;
{
int account_id = RFIFOL(fd,2);
@@ -1751,6 +1696,7 @@ int parse_fromlogin(int fd)
bool result = RFIFOB(fd,14);
const char* email = (const char*)RFIFOP(fd,15);
time_t expiration_time = (time_t)RFIFOL(fd,55);
+ int gmlevel = RFIFOB(fd,59);
// find the session with this account id
ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) &&
@@ -1765,16 +1711,17 @@ int parse_fromlogin(int fd)
} else { // success
memcpy(sd->email, email, 40);
sd->expiration_time = expiration_time;
+ sd->gmlevel = gmlevel;
char_auth_ok(i, sd);
}
}
}
- RFIFOSKIP(fd,59);
+ RFIFOSKIP(fd,60);
break;
// acknowledgement of e-mail/limited time request
case 0x2717:
- if (RFIFOREST(fd) < 50)
+ if (RFIFOREST(fd) < 51)
return 0;
// find the session with this account id
@@ -1783,8 +1730,9 @@ int parse_fromlogin(int fd)
{
memcpy(sd->email, RFIFOP(fd,6), 40);
sd->expiration_time = (time_t)RFIFOL(fd,46);
+ sd->gmlevel = RFIFOB(fd,50);
}
- RFIFOSKIP(fd,50);
+ RFIFOSKIP(fd,51);
break;
// login-server alive packet
@@ -1881,7 +1829,7 @@ int parse_fromlogin(int fd)
return 0;
{ //Receive account_reg2 registry, forward to map servers.
- unsigned char buf[ACCOUNT_REG2_NUM*(256+32+2)+16];
+ unsigned char buf[13+ACCOUNT_REG2_NUM*sizeof(struct global_reg)];
memcpy(buf,RFIFOP(fd,0), RFIFOW(fd,2));
WBUFW(buf,0) = 0x3804; //Map server can now receive all kinds of reg values with the same packet. [Skotlex]
mapif_sendall(buf, WBUFW(buf,2));
@@ -1910,33 +1858,6 @@ int parse_fromlogin(int fd)
RFIFOSKIP(fd,11);
break;
- // gm account information from login server
- case 0x2732:
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
- return 0;
-
- if(!char_gm_read) {
- unsigned char buf[32000]; //FIXME: this will crash
- if (gm_account != NULL)
- aFree(gm_account);
- gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1);
- GM_num = 0;
- for (i = 4; i < RFIFOW(fd,2); i = i + 5) {
- gm_account[GM_num].account_id = RFIFOL(fd,i);
- gm_account[GM_num].level = (int)RFIFOB(fd,i+4);
- //printf("GM account: %d -> level %d\n", gm_account[GM_num].account_id, gm_account[GM_num].level);
- GM_num++;
- }
- ShowStatus("From login-server: receiving information of %d GM accounts.\n", GM_num);
- // send new gm acccounts level to map-servers
- memcpy(buf, RFIFOP(fd,0), RFIFOW(fd,2));
- WBUFW(buf,0) = 0x2b15;
- mapif_sendall(buf, RFIFOW(fd,2));
- }
-
- RFIFOSKIP(fd,RFIFOW(fd,2));
- break;
-
// Login server request to kick a character out. [Skotlex]
case 0x2734:
if (RFIFOREST(fd) < 6)
@@ -2214,18 +2135,6 @@ int parse_frommap(int fd)
switch(RFIFOW(fd, 0))
{
- case 0x2af7: // request from map-server to reload GM accounts. Transmission to login-server
- if(char_gm_read) //Re-read gm accounts.
- read_gm_account();
- //Send to login request to reload gm accounts.
- else if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd,2);
- WFIFOW(login_fd,0) = 0x2709;
- WFIFOSET(login_fd,2);
- }
- RFIFOSKIP(fd,2);
- break;
-
case 0x2afa: // Receiving map names list from the map-server
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
@@ -2434,7 +2343,8 @@ int parse_frommap(int fd)
node->login_id2 = login_id2;
//node->sex = 0;
node->ip = ntohl(ip);
- node->expiration_time = 0; // unlimited/unknown time by default (not display in map-server)
+ //node->expiration_time = 0; // unlimited/unknown time by default (not display in map-server)
+ //node->gmlevel = 0;
idb_put(auth_db, account_id, node);
//Set char to "@ char select" in online db [Kevin]
@@ -2467,7 +2377,7 @@ int parse_frommap(int fd)
mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true);
char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14));
}
- //Tell the new map server about this player using Kevin's new auth packet. [Skotlex]
+
if (map_fd >= 0 && session[map_fd] && char_data)
{ //Send the map server the auth of this player.
struct auth_node* node;
@@ -2478,19 +2388,6 @@ int parse_frommap(int fd)
char_data->last_point.y = RFIFOW(fd,22);
char_data->sex = RFIFOB(fd,30);
-#if 0
- // the map-server must request it [FlavioJS]
- WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus));
- WFIFOW(map_fd,0) = 0x2afd;
- WFIFOW(map_fd,2) = 20 + sizeof(struct mmo_charstatus);
- WFIFOL(map_fd,4) = RFIFOL(fd,2); //Account ID
- WFIFOL(map_fd,8) = RFIFOL(fd,6); //Login1
- WFIFOL(map_fd,16) = RFIFOL(fd,10); //Login2
- WFIFOL(map_fd,12) = (unsigned long)0; //TODO: expiration_time, how do I figure it out right now?
- memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus));
- WFIFOSET(map_fd, WFIFOW(map_fd,2));
-#endif
-
// create temporary auth entry
CREATE(node, struct auth_node, 1);
node->account_id = RFIFOL(fd,2);
@@ -2588,9 +2485,10 @@ int parse_frommap(int fd)
if( login_fd <= 0 )
result = 3; // 3-login-server offline
- else
- if( acc != -1 && isGM(acc) < isGM(account_id) )
- result = 2; // 2-gm level too low
+ //FIXME: need to move this check to login server [ultramage]
+// else
+// if( acc != -1 && isGM(acc) < isGM(account_id) )
+// result = 2; // 2-gm level too low
else
switch( type ) {
case 1: // block
@@ -2838,14 +2736,15 @@ int parse_frommap(int fd)
{// auth ok
cd->sex = sex;
- WFIFOHEAD(fd,20 + sizeof(struct mmo_charstatus));
+ WFIFOHEAD(fd,24 + sizeof(struct mmo_charstatus));
WFIFOW(fd,0) = 0x2afd;
- WFIFOW(fd,2) = 20 + sizeof(struct mmo_charstatus);
+ WFIFOW(fd,2) = 24 + sizeof(struct mmo_charstatus);
WFIFOL(fd,4) = account_id;
- WFIFOL(fd,8) = login_id1;
- WFIFOL(fd,12) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT"
- WFIFOL(fd,16) = node->login_id2;
- memcpy(WFIFOP(fd,20), cd, sizeof(struct mmo_charstatus));
+ WFIFOL(fd,8) = node->login_id1;
+ WFIFOL(fd,12) = node->login_id2;
+ WFIFOL(fd,16) = (uint32)node->expiration_time; // FIXME: will wrap to negative after "19-Jan-2038, 03:14:07 AM GMT"
+ WFIFOL(fd,20) = node->gmlevel;
+ memcpy(WFIFOP(fd,24), cd, sizeof(struct mmo_charstatus));
WFIFOSET(fd, WFIFOW(fd,2));
// only use the auth once and mark user online
@@ -2996,7 +2895,6 @@ int parse_char(int fd)
CREATE(session[fd]->session_data, struct char_session_data, 1);
sd = (struct char_session_data*)session[fd]->session_data;
- sd->expiration_time = 0; // unknown or unlimited (not displaying on map-server)
sd->account_id = account_id;
sd->login_id1 = login_id1;
sd->login_id2 = login_id2;
@@ -3149,8 +3047,6 @@ int parse_char(int fd)
WFIFOW(fd,0) = 0x71;
WFIFOL(fd,2) = cp->char_id;
mapindex_getmapname_ext(mapindex_id2name(cp->last_point.map), (char*)WFIFOP(fd,6));
-
- // Advanced subnet check [LuzZza]
subnet_map_ip = lan_subnetcheck(ipl);
WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : server[i].ip);
WFIFOW(fd,26) = ntows(htons(server[i].port)); // [!] LE byte order here [!]
@@ -3164,6 +3060,7 @@ int parse_char(int fd)
node->login_id2 = sd->login_id2;
node->sex = sd->sex;
node->expiration_time = sd->expiration_time;
+ node->gmlevel = sd->gmlevel;
node->ip = ipl;
idb_put(auth_db, sd->account_id, node);
@@ -3324,15 +3221,6 @@ int parse_char(int fd)
session[fd]->flag.server = 1;
realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
char_mapif_init(fd);
- // send gm acccounts level to map-servers
- WFIFOHEAD(fd,4+5*GM_num);
- WFIFOW(fd,0) = 0x2b15;
- for(i = 0; i < GM_num; i++) {
- WFIFOL(fd,4+5*i) = gm_account[i].account_id;
- WFIFOB(fd,4+5*i+4) = (unsigned char)gm_account[i].level;
- }
- WFIFOW(fd,2) = 4+5*GM_num;
- WFIFOSET(fd,WFIFOW(fd,2));
}
RFIFOSKIP(fd,60);
@@ -3669,21 +3557,6 @@ void sql_config_read(const char* cfgName)
if(!strcmpi(w1,"char_db"))
strcpy(char_db,w2);
-#ifndef TXT_SQL_CONVERT
- else if(!strcmpi(w1,"gm_read_method"))
- char_gm_read = config_switch(w2);
- //custom columns for login database
- else if(!strcmpi(w1,"login_db"))
- strcpy(login_db,w2);
- else if(!strcmpi(w1,"login_db_level"))
- strcpy(login_db_level,w2);
- else if(!strcmpi(w1,"login_db_account_id"))
- strcpy(login_db_account_id,w2);
- else if(!strcmpi(w1,"lowest_gm_level")) {
- lowest_gm_level = atoi(w2);
- ShowStatus("set lowest_gm_level : %s\n", w2);
- }
-#endif
else if(!strcmpi(w1,"scdata_db"))
strcpy(scdata_db,w2);
else if(!strcmpi(w1,"cart_db"))
@@ -3920,11 +3793,6 @@ void do_final(void)
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ragsrvinfo") )
Sql_ShowDebug(sql_handle);
- if(gm_account) {
- aFree(gm_account);
- gm_account = 0;
- }
-
if (login_fd > 0)
do_close(login_fd);
if (char_fd > 0)
@@ -3934,8 +3802,6 @@ void do_final(void)
auth_db->destroy(auth_db, NULL);
Sql_Free(sql_handle);
- if( lsql_handle )
- Sql_Free(lsql_handle);
ShowInfo("ok! all done...\n");
}
@@ -3986,8 +3852,6 @@ int do_init(int argc, char **argv)
online_char_db = idb_alloc(DB_OPT_RELEASE_DATA);
mmo_char_sql_init();
char_read_fame_list(); //Read fame lists.
- if(char_gm_read)
- read_gm_account();
ShowInfo("char server initialized.\n");
set_defaultparse(parse_char);
diff --git a/src/char_sql/char.h b/src/char_sql/char.h
index 19c6fcba5..33c4544b2 100644
--- a/src/char_sql/char.h
+++ b/src/char_sql/char.h
@@ -6,7 +6,6 @@
struct mmo_charstatus;
-#define START_CHAR_NUM 150000
#define MAX_MAP_SERVERS 30
#define DEFAULT_AUTOSAVE_INTERVAL 300*1000
@@ -64,13 +63,6 @@ extern char quest_obj_db[256];
extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris]
-extern char login_db_level[32];
-extern char login_db_account_id[32];
-
-extern int lowest_gm_level;
-extern int GM_num;
-extern struct gm_account *gm_account;
-
extern int guild_exp_rate;
extern int log_inter;
diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c
index 261ed9b0d..58215d5da 100644
--- a/src/char_sql/inter.c
+++ b/src/char_sql/inter.c
@@ -28,7 +28,6 @@
Sql* sql_handle = NULL;
-Sql* lsql_handle = NULL;
int char_server_port = 3306;
char char_server_ip[32] = "127.0.0.1";
@@ -37,12 +36,6 @@ char char_server_pw[32] = "ragnarok";
char char_server_db[32] = "ragnarok";
char default_codepage[32] = ""; //Feature by irmin.
-int login_server_port = 3306;
-char login_server_ip[32] = "127.0.0.1";
-char login_server_id[32] = "ragnarok";
-char login_server_pw[32] = "ragnarok";
-char login_server_db[32] = "ragnarok";
-
#ifndef TXT_SQL_CONVERT
static struct accreg *accreg_pt;
@@ -71,8 +64,6 @@ struct WisData {
static DBMap* wis_db = NULL; // int wis_id -> struct WisData*
static int wis_dellist[WISDELLIST_MAX], wis_delnum;
-int inter_sql_test (void);
-
#endif //TXT_SQL_CONVERT
//--------------------------------------------------------
// Save registry to sql
@@ -237,29 +228,6 @@ static int inter_config_read(const char* cfgName)
strcpy(default_codepage,w2);
ShowStatus ("set default_codepage : %s\n", w2);
}
- //Logins information to be read from the inter_athena.conf
- //for character deletion (checks email in the loginDB)
- else
- if(!strcmpi(w1,"login_server_ip")) {
- strcpy(login_server_ip, w2);
- ShowStatus ("set login_server_ip : %s\n", w2);
- } else
- if(!strcmpi(w1,"login_server_port")) {
- login_server_port = atoi(w2);
- ShowStatus ("set login_server_port : %s\n", w2);
- } else
- if(!strcmpi(w1,"login_server_id")) {
- strcpy(login_server_id, w2);
- ShowStatus ("set login_server_id : %s\n", w2);
- } else
- if(!strcmpi(w1,"login_server_pw")) {
- strcpy(login_server_pw, w2);
- ShowStatus ("set login_server_pw : %s\n", w2);
- } else
- if(!strcmpi(w1,"login_server_db")) {
- strcpy(login_server_db, w2);
- ShowStatus ("set login_server_db : %s\n", w2);
- }
#ifndef TXT_SQL_CONVERT
else if(!strcmpi(w1,"party_share_level"))
party_share_level = atoi(w2);
@@ -297,38 +265,6 @@ int inter_log(char* fmt, ...)
return 0;
}
-/*=============================================
- * Does a mysql_ping to all connection handles
- *---------------------------------------------*/
-int inter_sql_ping(int tid, unsigned int tick, int id, intptr data)
-{
- ShowInfo("Pinging SQL server to keep connection alive...\n");
- Sql_Ping(sql_handle);
- if( char_gm_read )
- Sql_Ping(lsql_handle);
- return 0;
-}
-
-
-int sql_ping_init(void)
-{
- uint32 connection_timeout, connection_ping_interval;
-
- // set a default value first
- connection_timeout = 28800; // 8 hours
-
- // ask the mysql server for the timeout value
- if( SQL_SUCCESS == Sql_GetTimeout(sql_handle, &connection_timeout) && connection_timeout < 60 )
- connection_timeout = 60;
-
- // establish keepalive
- connection_ping_interval = connection_timeout - 30; // 30-second reserve
- add_timer_func_list(inter_sql_ping, "inter_sql_ping");
- add_timer_interval(gettick() + connection_ping_interval*1000, inter_sql_ping, 0, 0, connection_ping_interval*1000);
-
- return 0;
-}
-
#endif //TXT_SQL_CONVERT
// initialize
@@ -348,34 +284,10 @@ int inter_init_sql(const char *file)
Sql_Free(sql_handle);
exit(EXIT_FAILURE);
}
-#ifndef TXT_SQL_CONVERT
- else if (inter_sql_test()) {
- ShowStatus("Connect Success! (Character Server)\n");
- }
- if(char_gm_read) {
- lsql_handle = Sql_Malloc();
- ShowInfo("Connect Character DB server.... (login server)\n");
- if( SQL_ERROR == Sql_Connect(lsql_handle, login_server_id, login_server_pw, login_server_ip, (uint16)login_server_port, login_server_db) )
- {
- Sql_ShowDebug(lsql_handle);
- Sql_Free(lsql_handle);
- Sql_Free(sql_handle);
- exit(EXIT_FAILURE);
- }
- else
- {
- ShowStatus ("Connect Success! (Login Server)\n");
- }
- }
-#endif //TXT_SQL_CONVERT
if( *default_codepage ) {
if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) )
Sql_ShowDebug(sql_handle);
-#ifndef TXT_SQL_CONVERT
- if( char_gm_read && SQL_ERROR == Sql_SetEncoding(lsql_handle, default_codepage) )
- Sql_ShowDebug(lsql_handle);
-#endif //TXT_SQL_CONVERT
}
#ifndef TXT_SQL_CONVERT
@@ -389,46 +301,11 @@ int inter_init_sql(const char *file)
inter_mail_sql_init();
inter_auction_sql_init();
- sql_ping_init();
#endif //TXT_SQL_CONVERT
return 0;
}
#ifndef TXT_SQL_CONVERT
-int inter_sql_test (void)
-{
- const char fields[][24] = {
- "father", // version 1363
- "fame", // version 1491
- };
- char buf[1024] = "";
- char* p;
- size_t len;
- int i;
-
- if( SQL_ERROR == Sql_GetColumnNames(sql_handle, char_db, buf, sizeof(buf), '\n') )
- Sql_ShowDebug(sql_handle);
-
- // check DB strings
- for( i = 0; i < ARRAYLENGTH(fields); ++i )
- {
- len = strlen(fields[i]);
- p = strstr(buf, fields[i]);
- while( p != NULL && p[len] != '\n' )
- p = strstr(p, fields[i]);
- if( p == NULL )
- {
- ShowSQL ("Field `%s` not be found in `%s`. Consider updating your database!\n", fields[i], char_db);
- if( lsql_handle )
- Sql_Free(lsql_handle);
- Sql_Free(sql_handle);
- exit(EXIT_FAILURE);
- }
- }
-
- return 1;
-}
-
// finalize
void inter_final(void)
{
@@ -533,26 +410,6 @@ int mapif_account_reg_reply(int fd,int account_id,int char_id, int type)
return 0;
}
-int mapif_send_gmaccounts()
-{
- int i, len = 4;
- unsigned char buf[32000];
-
- // forward the gm accounts to the map server
- len = 4;
- WBUFW(buf,0) = 0x2b15;
-
- for(i = 0; i < GM_num; i++) {
- WBUFL(buf,len) = gm_account[i].account_id;
- WBUFB(buf,len+4) = (uint8)gm_account[i].level;
- len += 5;
- }
- WBUFW(buf,2) = len;
- mapif_sendall(buf, len);
-
- return 0;
-}
-
//Request to kick char from a certain map server. [Skotlex]
int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason)
{
@@ -815,6 +672,26 @@ int mapif_parse_NameChangeRequest(int fd)
}
//--------------------------------------------------------
+
+/// Returns the length of the next complete packet to process,
+/// or 0 if no complete packet exists in the queue.
+///
+/// @param length The minimum allowed length, or -1 for dynamic lookup
+int inter_check_length(int fd, int length)
+{
+ if( length == -1 )
+ {// variable-length packet
+ if( RFIFOREST(fd) < 4 )
+ return 0;
+ length = RFIFOW(fd,2);
+ }
+
+ if( (int)RFIFOREST(fd) < length )
+ return 0;
+
+ return length;
+}
+
int inter_parse_frommap(int fd)
{
int cmd;
@@ -855,18 +732,4 @@ int inter_parse_frommap(int fd)
return 1;
}
-// RFIFO check
-int inter_check_length(int fd, int length)
-{
- if(length == -1) { // v-len packet
- if(RFIFOREST(fd) < 4) // packet not yet
- return 0;
- length = RFIFOW(fd, 2);
- }
-
- if((int)RFIFOREST(fd) < length) // packet not yet
- return 0;
-
- return length;
-}
#endif //TXT_SQL_CONVERT
diff --git a/src/char_sql/inter.h b/src/char_sql/inter.h
index a44ce77e1..ac2e1785f 100644
--- a/src/char_sql/inter.h
+++ b/src/char_sql/inter.h
@@ -14,30 +14,15 @@ int inter_mapif_init(int fd);
int mapif_send_gmaccounts(void);
int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason);
-int inter_check_length(int fd,int length);
-
int inter_log(char *fmt,...);
#define inter_cfgName "conf/inter_athena.conf"
extern unsigned int party_share_level;
-extern char inter_log_filename[1024];
extern Sql* sql_handle;
extern Sql* lsql_handle;
-extern int char_server_port;
-extern char char_server_ip[32];
-extern char char_server_id[32];
-extern char char_server_pw[32];
-extern char char_server_db[32];
-
-extern int login_db_server_port;
-extern char login_db_server_ip[32];
-extern char login_db_server_id[32];
-extern char login_db_server_pw[32];
-extern char login_db_server_db[32];
-
extern char main_chat_nick[16];
int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type);