summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c148
-rw-r--r--src/char_sql/char.c149
-rw-r--r--src/common/strlib.c50
-rw-r--r--src/common/strlib.h4
-rw-r--r--src/ladmin/ladmin.c52
-rw-r--r--src/login/login.c163
-rw-r--r--src/login/login.h8
-rw-r--r--src/login_sql/login.c171
-rw-r--r--src/login_sql/login.h8
-rw-r--r--src/map/atcommand.c42
-rw-r--r--src/map/atcommand.h1
-rw-r--r--src/map/battle.c24
-rw-r--r--src/map/battle.h2
-rw-r--r--src/map/map.c18
-rw-r--r--src/map/script.c12
-rw-r--r--src/tool/mapcache.c1
16 files changed, 308 insertions, 545 deletions
diff --git a/src/char/char.c b/src/char/char.c
index a9c9532e1..4cef440bc 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -334,7 +334,7 @@ void set_char_online(int map_id, int char_id, int account_id) {
if (login_fd <= 0 || session[login_fd]->eof)
return;
- WFIFOHEAD(login_fd, 6);
+ WFIFOHEAD(login_fd,6);
WFIFOW(login_fd,0) = 0x272b;
WFIFOL(login_fd,2) = account_id;
WFIFOSET(login_fd,6);
@@ -355,7 +355,7 @@ void set_char_offline(int char_id, int account_id) {
}
if (login_fd <= 0 || session[login_fd]->eof)
return;
- WFIFOHEAD(login_fd, 6);
+ WFIFOHEAD(login_fd,6);
WFIFOW(login_fd,0) = 0x272c;
WFIFOL(login_fd,2) = account_id;
WFIFOSET(login_fd,6);
@@ -404,7 +404,7 @@ void set_all_offline(int id) {
if (id >= 0 || login_fd <= 0 || session[login_fd]->eof)
return;
//Tell login-server to also mark all our characters as offline.
- WFIFOHEAD(login_fd, 2);
+ WFIFOHEAD(login_fd,2);
WFIFOW(login_fd,0) = 0x2737;
WFIFOSET(login_fd,2);
}
@@ -1750,7 +1750,7 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) {
j = 24;// offset
{
- WFIFOHEAD(fd, j + found_num*108);
+ WFIFOHEAD(fd,j + found_num*108);
WFIFOW(fd,0) = 0x6b;
memset(WFIFOP(fd,4), 0, 20);// unknown bytes
@@ -1839,45 +1839,6 @@ void char_clearparty(int party_id)
}
}
-//------------------------------------------------------------
-// E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
-//------------------------------------------------------------
-int e_mail_check(char *email) {
- char ch;
- char* last_arobas;
-
- // athena limits
- if (strlen(email) < 3 || strlen(email) > 39)
- return 0;
-
- // part of RFC limits (official reference of e-mail description)
- if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
- return 0;
-
- if (email[strlen(email)-1] == '.')
- return 0;
-
- last_arobas = strrchr(email, '@');
-
- if (strstr(last_arobas, "@.") != NULL ||
- strstr(last_arobas, "..") != NULL)
- return 0;
-
- for(ch = 1; ch < 32; ch++) {
- if (strchr(last_arobas, ch) != NULL) {
- return 0;
- break;
- }
- }
-
- if (strchr(last_arobas, ' ') != NULL ||
- strchr(last_arobas, ';') != NULL)
- return 0;
-
- // all correct
- return 1;
-}
-
//----------------------------------------------------------------------
// Force disconnection of an online player (with account value) by [Yor]
//----------------------------------------------------------------------
@@ -1972,7 +1933,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
}
if (login_fd > 0) {
// request to login-server to obtain e-mail/time limit
- WFIFOHEAD(login_fd, 6);
+ WFIFOHEAD(login_fd,6);
WFIFOW(login_fd,0) = 0x2716;
WFIFOL(login_fd,2) = sd->account_id;
WFIFOSET(login_fd,6);
@@ -2043,7 +2004,7 @@ int parse_tologin(int fd) {
; i++);
if (i < fd_max) {
if (RFIFOB(fd,6) != 0) {
- WFIFOHEAD(i, 3);
+ WFIFOHEAD(i,3);
WFIFOW(i,0) = 0x6c;
WFIFOB(i,2) = 0x42;
WFIFOSET(i,3);
@@ -2453,7 +2414,7 @@ int parse_tologin(int fd) {
for(i = 0; i < fd_max; i++) {
if (session[i] && (tsd = (struct char_session_data*)session[i]->session_data) && tsd->account_id == aid)
{
- WFIFOHEAD(i, 3);
+ WFIFOHEAD(i,3);
WFIFOW(i,0) = 0x81;
WFIFOB(i,2) = 2;
WFIFOSET(i,3);
@@ -2505,11 +2466,11 @@ int parse_tologin(int fd) {
int request_accreg2(int account_id, int char_id) {
if (login_fd > 0) {
- WFIFOHEAD(login_fd, 10);
- WFIFOW(login_fd, 0) = 0x272e;
- WFIFOL(login_fd, 2) = account_id;
- WFIFOL(login_fd, 6) = char_id;
- WFIFOSET(login_fd, 10);
+ WFIFOHEAD(login_fd,10);
+ WFIFOW(login_fd,0) = 0x272e;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOL(login_fd,6) = char_id;
+ WFIFOSET(login_fd,10);
return 1;
}
return 0;
@@ -2518,7 +2479,7 @@ int request_accreg2(int account_id, int char_id) {
//Send packet forward to login-server for account saving
int save_accreg2(unsigned char* buf, int len) {
if (login_fd > 0) {
- WFIFOHEAD(login_fd, len+4);
+ WFIFOHEAD(login_fd,len+4);
memcpy(WFIFOP(login_fd,4), buf, len);
WFIFOW(login_fd,0) = 0x2728;
WFIFOW(login_fd,2) = len+4;
@@ -2741,9 +2702,9 @@ int parse_frommap(int fd)
case 0x2af7: // request from map-server to reload GM accounts. Transmission to login-server
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 2);
+ WFIFOHEAD(login_fd,2);
WFIFOW(login_fd,0) = 0x2709;
- WFIFOSET(login_fd, 2);
+ WFIFOSET(login_fd,2);
}
RFIFOSKIP(fd,2);
break;
@@ -3007,11 +2968,11 @@ int parse_frommap(int fd)
memcpy(WFIFOP(login_fd,2), RFIFOP(fd,2), RFIFOW(fd,2)-2);
WFIFOSET(login_fd, RFIFOW(fd,2));
} else {
- WFIFOHEAD(fd, 10);
+ WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x2b0b;
WFIFOL(fd,2) = RFIFOL(fd,4);
WFIFOL(fd,6) = 0;
- WFIFOSET(fd, 10);
+ WFIFOSET(fd,10);
}
RFIFOSKIP(fd, RFIFOW(fd,2));
break;
@@ -3020,10 +2981,10 @@ int parse_frommap(int fd)
if (RFIFOREST(fd) < 86)
return 0;
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 86);
+ WFIFOHEAD(login_fd,86);
memcpy(WFIFOP(login_fd,0), RFIFOP(fd,0), 86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
WFIFOW(login_fd,0) = 0x2722;
- WFIFOSET(login_fd, 86);
+ WFIFOSET(login_fd,86);
}
RFIFOSKIP(fd, 86);
break;
@@ -3050,11 +3011,11 @@ int parse_frommap(int fd)
case 1: // block
if (acc == -1 || isGM(acc) >= isGM(char_dat[i].status.account_id)) {
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 10);
+ WFIFOHEAD(login_fd,10);
WFIFOW(login_fd,0) = 0x2724;
WFIFOL(login_fd,2) = char_dat[i].status.account_id; // account value
WFIFOL(login_fd,6) = 5; // status of the account
- WFIFOSET(login_fd, 10);
+ WFIFOSET(login_fd,10);
// printf("char : status -> login: account %d, status: %d \n", char_dat[i].account_id, 5);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
@@ -3084,11 +3045,11 @@ int parse_frommap(int fd)
case 3: // unblock
if (acc == -1 || isGM(acc) >= isGM(char_dat[i].status.account_id)) {
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 10);
+ WFIFOHEAD(login_fd,10);
WFIFOW(login_fd,0) = 0x2724;
WFIFOL(login_fd,2) = char_dat[i].status.account_id; // account value
WFIFOL(login_fd,6) = 0; // status of the account
- WFIFOSET(login_fd, 10);
+ WFIFOSET(login_fd,10);
// printf("char : status -> login: account %d, status: %d \n", char_dat[i].account_id, 0);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
@@ -3098,10 +3059,10 @@ int parse_frommap(int fd)
case 4: // unban
if (acc == -1 || isGM(acc) >= isGM(char_dat[i].status.account_id)) {
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 6);
+ WFIFOHEAD(login_fd,6);
WFIFOW(login_fd, 0) = 0x272a;
WFIFOL(login_fd, 2) = char_dat[i].status.account_id; // account value
- WFIFOSET(login_fd, 6);
+ WFIFOSET(login_fd,6);
// printf("char : status -> login: account %d, unban request\n", char_dat[i].account_id);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
@@ -3111,10 +3072,10 @@ int parse_frommap(int fd)
case 5: // changesex
if (acc == -1 || isGM(acc) >= isGM(char_dat[i].status.account_id)) {
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 6);
+ WFIFOHEAD(login_fd,6);
WFIFOW(login_fd, 0) = 0x2727;
WFIFOL(login_fd, 2) = char_dat[i].status.account_id; // account value
- WFIFOSET(login_fd, 6);
+ WFIFOSET(login_fd,6);
// printf("char : status -> login: account %d, change sex request\n", char_dat[i].account_id);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
@@ -3392,7 +3353,7 @@ int parse_char(int fd)
return 0;
{
int GM_value;
- WFIFOHEAD(fd, 4);
+ WFIFOHEAD(fd,4);
if (sd) {
//Received again auth packet for already authentified account?? Discard it.
@@ -3458,10 +3419,10 @@ int parse_char(int fd)
// if we activated email creation and email is default email
if (email_creation != 0 && strcmp(sd->email, "a@a.com") == 0 && login_fd > 0) { // to modify an e-mail, login-server must be online
- WFIFOHEAD(fd, 3);
- WFIFOW(fd, 0) = 0x70;
- WFIFOB(fd, 2) = 0; // 00 = Incorrect Email address
- WFIFOSET(fd, 3);
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x70;
+ WFIFOB(fd,2) = 0; // 00 = Incorrect Email address
+ WFIFOSET(fd,3);
break;
}
// otherwise, load the character
@@ -3490,7 +3451,7 @@ int parse_char(int fd)
break;
if (j == MAX_MAP_SERVERS) {
ShowInfo("Connection Closed. No map servers available.\n");
- WFIFOHEAD(fd, 3);
+ WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3);
@@ -3516,7 +3477,7 @@ int parse_char(int fd)
cd->last_point.y = 103;
} else {
ShowInfo("Connection Closed. No map server available that has a major city, and unable to find map-server for '%s'.\n", mapindex_id2name(cd->last_point.map));
- WFIFOHEAD(fd, 3);
+ WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3);
@@ -3559,7 +3520,7 @@ int parse_char(int fd)
//Send NEW auth packet [Kevin]
if ((map_fd = server_fd[i]) < 1 || session[map_fd] == NULL)
{
- WFIFOHEAD(fd, 3);
+ WFIFOHEAD(fd,3);
ShowError("parse_char: Attempting to write to invalid session %d! Map Server #%d disconnected.\n", map_fd, i);
server_fd[i] = -1;
memset(&server[i], 0, sizeof(struct mmo_map_server));
@@ -3597,12 +3558,12 @@ int parse_char(int fd)
//'Charname already exists' (-1), 'Char creation denied' (-2) and 'You are underaged' (-3)
if (i < 0)
{
- WFIFOHEAD(fd, 3);
+ WFIFOHEAD(fd,3);
WFIFOW(fd, 0) = 0x6e;
switch (i) {
- case -1: WFIFOB(fd, 2) = 0x00; break;
- case -2: WFIFOB(fd, 2) = 0x02; break;
- case -3: WFIFOB(fd, 2) = 0x01; break;
+ case -1: WFIFOB(fd,2) = 0x00; break;
+ case -2: WFIFOB(fd,2) = 0x02; break;
+ case -3: WFIFOB(fd,2) = 0x01; break;
}
WFIFOSET(fd, 3);
RFIFOSKIP(fd, 37);
@@ -3610,7 +3571,7 @@ int parse_char(int fd)
}
{ //Send to player.
int len;
- WFIFOHEAD(fd, 110);
+ WFIFOHEAD(fd,110);
WFIFOW(fd,0) = 0x6d;
len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status);
WFIFOSET(fd,len);
@@ -3630,7 +3591,7 @@ int parse_char(int fd)
{
int cid = RFIFOL(fd,2);
struct mmo_charstatus *cs = NULL;
- WFIFOHEAD(fd, 46);
+ WFIFOHEAD(fd,46);
WFIFOHEAD(login_fd,46);
ShowInfo(CL_RED" Request Char Deletion:"CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid);
memcpy(email, RFIFOP(fd,6), 40);
@@ -3730,7 +3691,7 @@ int parse_char(int fd)
{
char *l_user = RFIFOP(fd,2);
char *l_pass = RFIFOP(fd,26);
- WFIFOHEAD(fd, 4+5*GM_num);
+ WFIFOHEAD(fd,4+5*GM_num);
l_user[23] = '\0';
l_pass[23] = '\0';
WFIFOW(fd,0) = 0x2af9;
@@ -3779,7 +3740,7 @@ int parse_char(int fd)
case 0x7530: // Athena info get
{
- WFIFOHEAD(fd, 10);
+ WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x7531;
WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
@@ -3858,9 +3819,9 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) {
for(i = 0; i < MAX_MAP_SERVERS; i++) {
int fd;
if ((fd = server_fd[i]) > 0 && fd != sfd) {
- WFIFOHEAD(fd, len);
+ WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd, len);
+ WFIFOSET(fd,len);
c++;
}
}
@@ -3910,7 +3871,7 @@ static int send_accounts_tologin_sub(DBKey key, void* data, va_list ap) {
if ((*i) >= count)
return 0; //This is an error that shouldn't happen....
if(character->server > -1) {
- WFIFOHEAD(login_fd, 8+count*4);
+ WFIFOHEAD(login_fd,8+count*4);
WFIFOL(login_fd, 8+(*i)*4) =character->account_id;
(*i)++;
return 1;
@@ -3923,7 +3884,7 @@ int send_accounts_tologin(int tid, unsigned int tick, int id, int data) {
if (login_fd > 0 && session[login_fd]) {
// send account list to login server
- WFIFOHEAD(login_fd, 8+users*4);
+ WFIFOHEAD(login_fd,8+users*4);
WFIFOW(login_fd,0) = 0x272d;
WFIFOL(login_fd,4) = users;
online_char_db->foreach(online_char_db, send_accounts_tologin_sub, &i);
@@ -3948,7 +3909,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, int data)
session[login_fd]->func_parse = parse_tologin;
realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
{
- WFIFOHEAD(login_fd, 86);
+ WFIFOHEAD(login_fd,86);
WFIFOW(login_fd,0) = 0x2710;
memcpy(WFIFOP(login_fd,2), userid, 24);
memcpy(WFIFOP(login_fd,26), passwd, 24);
@@ -3979,19 +3940,6 @@ static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int dat
return 0;
}
-//----------------------------------------------------------
-// Return numerical value of a switch configuration by [Yor]
-// on/off, english, franais, deutsch, espaol
-//----------------------------------------------------------
-int config_switch(const char *str) {
- if (strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || strcmpi(str, "si") == 0)
- return 1;
- if (strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0)
- return 0;
-
- return atoi(str);
-}
-
//----------------------------------
// Reading Lan Support configuration
// Rewrote: Anvanced subnet check [LuzZza]
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index f7b97bc7a..62607e4e9 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -344,7 +344,7 @@ void set_all_offline(int id) {
if (id >= 0 || login_fd <= 0 || session[login_fd]->eof)
return;
//Tell login-server to also mark all our characters as offline.
- WFIFOHEAD(login_fd, 2);
+ WFIFOHEAD(login_fd,2);
WFIFOW(login_fd,0) = 0x2737;
WFIFOSET(login_fd,2);
}
@@ -1833,7 +1833,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
}
if (login_fd > 0) {
// request to login-server to obtain e-mail/time limit
- WFIFOHEAD(login_fd, 6);
+ WFIFOHEAD(login_fd,6);
WFIFOW(login_fd,0) = 0x2716;
WFIFOL(login_fd,2) = sd->account_id;
WFIFOSET(login_fd,6);
@@ -2273,11 +2273,11 @@ int parse_tologin(int fd) {
int request_accreg2(int account_id, int char_id) {
if (login_fd > 0) {
- WFIFOHEAD(login_fd, 10);
- WFIFOW(login_fd, 0) = 0x272e;
- WFIFOL(login_fd, 2) = account_id;
- WFIFOL(login_fd, 6) = char_id;
- WFIFOSET(login_fd, 10);
+ WFIFOHEAD(login_fd,10);
+ WFIFOW(login_fd,0) = 0x272e;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOL(login_fd,6) = char_id;
+ WFIFOSET(login_fd,10);
return 1;
}
return 0;
@@ -2285,7 +2285,7 @@ int request_accreg2(int account_id, int char_id) {
//Send packet forward to login-server for account saving
int save_accreg2(unsigned char* buf, int len) {
if (login_fd > 0) {
- WFIFOHEAD(login_fd, len+4);
+ WFIFOHEAD(login_fd,len+4);
memcpy(WFIFOP(login_fd,4), buf, len);
WFIFOW(login_fd,0) = 0x2728;
WFIFOW(login_fd,2) = len+4;
@@ -2496,9 +2496,9 @@ int parse_frommap(int fd)
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);
+ WFIFOHEAD(login_fd,2);
WFIFOW(login_fd,0) = 0x2709;
- WFIFOSET(login_fd, 2);
+ WFIFOSET(login_fd,2);
}
break;
@@ -2546,7 +2546,7 @@ int parse_frommap(int fd)
// Transmitting the maps of the other map-servers to the new map-server
for(x = 0; x < MAX_MAP_SERVERS; x++) {
if (server_fd[x] > 0 && x != id) {
- WFIFOHEAD(fd, 10 +4*MAX_MAP_PER_SERVER);
+ WFIFOHEAD(fd,10 +4*MAX_MAP_PER_SERVER);
WFIFOW(fd,0) = 0x2b04;
WFIFOL(fd,4) = htonl(server[x].ip);
WFIFOW(fd,8) = htons(server[x].port);
@@ -2584,10 +2584,10 @@ int parse_frommap(int fd)
if (sql_res) {
struct status_change_data data;
int count = 0;
- WFIFOHEAD(fd, 14+50*sizeof(struct status_change_data));
- WFIFOW(fd, 0) = 0x2b1d;
- WFIFOL(fd, 4) = aid;
- WFIFOL(fd, 8) = cid;
+ WFIFOHEAD(fd,14+50*sizeof(struct status_change_data));
+ WFIFOW(fd,0) = 0x2b1d;
+ WFIFOL(fd,4) = aid;
+ WFIFOL(fd,8) = cid;
while((sql_row = mysql_fetch_row(sql_res)) && count < 50)
{
data.type = atoi(sql_row[0]);
@@ -2604,9 +2604,9 @@ int parse_frommap(int fd)
mysql_free_result(sql_res);
if (count > 0)
{
- WFIFOW(fd, 2) = 14 + count*sizeof(struct status_change_data);
- WFIFOW(fd, 12) = count;
- WFIFOSET(fd, WFIFOW(fd,2));
+ WFIFOW(fd,2) = 14 + count*sizeof(struct status_change_data);
+ WFIFOW(fd,12) = count;
+ WFIFOSET(fd,WFIFOW(fd,2));
//Clear the data once loaded.
sprintf(tmp_sql, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid);
@@ -2744,8 +2744,8 @@ int parse_frommap(int fd)
if (map_fd>=0 && session[map_fd] && char_data)
{ //Send the map server the auth of this player.
//Update the "last map" as this is where the player must be spawned on the new map server.
- WFIFOHEAD(fd, 30);
- WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus));
+ WFIFOHEAD(fd,30);
+ WFIFOHEAD(map_fd,20 + sizeof(struct mmo_charstatus));
char_data->last_point.map = RFIFOW(fd,18);
char_data->last_point.x = RFIFOW(fd,20);
char_data->last_point.y = RFIFOW(fd,22);
@@ -2753,8 +2753,8 @@ int parse_frommap(int fd)
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,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: connect_until_time, how do I figure it out right now?
memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus));
@@ -2764,17 +2764,17 @@ int parse_frommap(int fd)
data->server = map_id; //Update server where char is.
//Reply with an ack.
- WFIFOW(fd, 0) = 0x2b06;
+ WFIFOW(fd,0) = 0x2b06;
memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
- WFIFOSET(fd, 30);
+ WFIFOSET(fd,30);
} else { //Reply with nak
- WFIFOHEAD(fd, 30);
- WFIFOW(fd, 0) = 0x2b06;
+ WFIFOHEAD(fd,30);
+ WFIFOW(fd,0) = 0x2b06;
memcpy(WFIFOP(fd,2), RFIFOP(fd,2), 28);
- WFIFOL(fd, 6) = 0; //Set login1 to 0.
- WFIFOSET(fd, 30);
+ WFIFOL(fd,6) = 0; //Set login1 to 0.
+ WFIFOSET(fd,30);
}
- RFIFOSKIP(fd, 35);
+ RFIFOSKIP(fd,35);
}
break;
@@ -2810,10 +2810,10 @@ int parse_frommap(int fd)
if (RFIFOREST(fd) < 86)
return 0;
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 86);
- memcpy(WFIFOP(login_fd,0), RFIFOP(fd,0), 86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
+ WFIFOHEAD(login_fd,86);
+ memcpy(WFIFOP(login_fd,0), RFIFOP(fd,0),86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B
WFIFOW(login_fd,0) = 0x2722;
- WFIFOSET(login_fd, 86);
+ WFIFOSET(login_fd,86);
}
RFIFOSKIP(fd, 86);
break;
@@ -2824,7 +2824,7 @@ int parse_frommap(int fd)
{
char character_name[NAME_LENGTH], t_name[NAME_LENGTH*2];
int acc = RFIFOL(fd,2); // account_id of who ask (-1 if nobody)
- WFIFOHEAD(fd, 34);
+ WFIFOHEAD(fd,34);
memcpy(character_name, RFIFOP(fd,6), NAME_LENGTH);
character_name[NAME_LENGTH-1] = '\0';
jstrescapecpy(t_name, character_name); //Escape string for sql use... [Skotlex]
@@ -2850,11 +2850,11 @@ int parse_frommap(int fd)
case 1: // block
if (acc == -1 || isGM(acc) >= isGM(atoi(sql_row[0]))) {
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 10);
+ WFIFOHEAD(login_fd,10);
WFIFOW(login_fd,0) = 0x2724;
WFIFOL(login_fd,2) = atoi(sql_row[0]); // account value
WFIFOL(login_fd,6) = 5; // status of the account
- WFIFOSET(login_fd, 10);
+ WFIFOSET(login_fd,10);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
} else
@@ -2863,7 +2863,7 @@ int parse_frommap(int fd)
case 2: // ban
if (acc == -1 || isGM(acc) >= isGM(atoi(sql_row[0]))) {
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 18);
+ WFIFOHEAD(login_fd,18);
WFIFOW(login_fd, 0) = 0x2725;
WFIFOL(login_fd, 2) = atoi(sql_row[0]); // account value
WFIFOW(login_fd, 6) = RFIFOW(fd,32); // year
@@ -2881,11 +2881,11 @@ int parse_frommap(int fd)
case 3: // unblock
if (acc == -1 || isGM(acc) >= isGM(atoi(sql_row[0]))) {
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 10);
+ WFIFOHEAD(login_fd,10);
WFIFOW(login_fd,0) = 0x2724;
WFIFOL(login_fd,2) = atoi(sql_row[0]); // account value
WFIFOL(login_fd,6) = 0; // status of the account
- WFIFOSET(login_fd, 10);
+ WFIFOSET(login_fd,10);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
} else
@@ -2894,10 +2894,10 @@ int parse_frommap(int fd)
case 4: // unban
if (acc == -1 || isGM(acc) >= isGM(atoi(sql_row[0]))) {
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 6);
- WFIFOW(login_fd, 0) = 0x272a;
- WFIFOL(login_fd, 2) = atoi(sql_row[0]); // account value
- WFIFOSET(login_fd, 6);
+ WFIFOHEAD(login_fd,6);
+ WFIFOW(login_fd,0) = 0x272a;
+ WFIFOL(login_fd,2) = atoi(sql_row[0]); // account value
+ WFIFOSET(login_fd,6);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
} else
@@ -2906,10 +2906,10 @@ int parse_frommap(int fd)
case 5: // changesex
if (acc == -1 || isGM(acc) >= isGM(atoi(sql_row[0]))) {
if (login_fd > 0) { // don't send request if no login-server
- WFIFOHEAD(login_fd, 6);
- WFIFOW(login_fd, 0) = 0x2727;
- WFIFOL(login_fd, 2) = atoi(sql_row[0]); // account value
- WFIFOSET(login_fd, 6);
+ WFIFOHEAD(login_fd,6);
+ WFIFOW(login_fd,0) = 0x2727;
+ WFIFOL(login_fd,2) = atoi(sql_row[0]); // account value
+ WFIFOSET(login_fd,6);
} else
WFIFOW(fd,32) = 3; // answer: 0-login-server resquest done, 1-player not found, 2-gm level too low, 3-login-server offline
} else
@@ -3203,7 +3203,7 @@ int parse_char(int fd)
if (RFIFOREST(fd) < 17)
return 0;
{
- WFIFOHEAD(fd, 4);
+ WFIFOHEAD(fd,4);
if (sd) {
//Received again auth packet for already authentified account?? Discard it.
@@ -3302,7 +3302,7 @@ int parse_char(int fd)
break;
if (j == MAX_MAP_SERVERS) {
ShowInfo("Connection Closed. No map servers available.\n");
- WFIFOHEAD(fd, 3);
+ WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3);
@@ -3367,7 +3367,7 @@ int parse_char(int fd)
//Send NEW auth packet [Kevin]
if ((map_fd = server_fd[i]) < 1 || session[map_fd] == NULL)
{
- WFIFOHEAD(fd, 3);
+ WFIFOHEAD(fd,3);
ShowError("parse_char: Attempting to write to invalid session %d! Map Server #%d disconnected.\n", map_fd, i);
server_fd[i] = -1;
memset(&server[i], 0, sizeof(struct mmo_map_server));
@@ -3378,7 +3378,7 @@ int parse_char(int fd)
break;
}
{ //Send auth ok to map server
- WFIFOHEAD(map_fd, 20 + sizeof(struct mmo_charstatus));
+ 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) = auth_fifo[auth_fifo_pos].account_id;
@@ -3404,20 +3404,20 @@ int parse_char(int fd)
//'Charname already exists' (-1), 'Char creation denied' (-2) and 'You are underaged' (-3)
if (i < 0)
{
- WFIFOHEAD(fd, 3);
- WFIFOW(fd, 0) = 0x6e;
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x6e;
switch (i) {
- case -1: WFIFOB(fd, 2) = 0x00; break;
- case -2: WFIFOB(fd, 2) = 0x02; break;
- case -3: WFIFOB(fd, 2) = 0x01; break;
+ case -1: WFIFOB(fd,2) = 0x00; break;
+ case -2: WFIFOB(fd,2) = 0x02; break;
+ case -3: WFIFOB(fd,2) = 0x01; break;
}
- WFIFOSET(fd, 3);
- RFIFOSKIP(fd, 37);
+ WFIFOSET(fd,3);
+ RFIFOSKIP(fd,37);
break;
}
{ //Send to player.
int len;
- WFIFOHEAD(fd, 110);
+ WFIFOHEAD(fd,110);
WFIFOW(fd,0) = 0x6d;
mmo_char_fromsql_short(i, &char_dat); //Only the short data is needed.
len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat);
@@ -3438,10 +3438,10 @@ int parse_char(int fd)
FIFOSD_CHECK(46);
{
int cid = RFIFOL(fd,2);
- WFIFOHEAD(fd, 46);
+ WFIFOHEAD(fd,46);
ShowInfo(CL_RED" Request Char Deletion:"CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, cid);
memcpy(email, RFIFOP(fd,6), 40);
- RFIFOSKIP(fd, 46);
+ RFIFOSKIP(fd,46);
// Check if e-mail is correct
if(strcmpi(email, sd->email) && //email does not matches and
@@ -3518,7 +3518,7 @@ int parse_char(int fd)
{
char *l_user = RFIFOP(fd,2);
char *l_pass = RFIFOP(fd,26);
- WFIFOHEAD(fd, 4+5*GM_num);
+ WFIFOHEAD(fd,4+5*GM_num);
l_user[23] = '\0';
l_pass[23] = '\0';
WFIFOW(fd,0) = 0x2af9;
@@ -3567,7 +3567,7 @@ int parse_char(int fd)
case 0x7530: // Athena info get
{
- WFIFOHEAD(fd, 10);
+ WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x7531;
WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
@@ -3645,9 +3645,9 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) {
for(i = 0; i < MAX_MAP_SERVERS; i++) {
int fd;
if ((fd = server_fd[i]) > 0 && fd != sfd) {
- WFIFOHEAD(fd, len);
+ WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd, len);
+ WFIFOSET(fd,len);
c++;
}
}
@@ -3697,8 +3697,8 @@ static int send_accounts_tologin_sub(DBKey key, void* data, va_list ap) {
if ((*i) >= count)
return 0; //This is an error that shouldn't happen....
if(character->server > -1) {
- WFIFOHEAD(login_fd, 8+count*4);
- WFIFOL(login_fd, 8+(*i)*4) =character->account_id;
+ WFIFOHEAD(login_fd,8+count*4);
+ WFIFOL(login_fd,8+(*i)*4) =character->account_id;
(*i)++;
return 1;
}
@@ -3710,7 +3710,7 @@ int send_accounts_tologin(int tid, unsigned int tick, int id, int data) {
if (login_fd > 0 && session[login_fd]) {
// send account list to login server
- WFIFOHEAD(login_fd, 8+users*4);
+ WFIFOHEAD(login_fd,8+users*4);
WFIFOW(login_fd,0) = 0x272d;
WFIFOL(login_fd,4) = users;
online_char_db->foreach(online_char_db, send_accounts_tologin_sub, &i, users);
@@ -3734,7 +3734,7 @@ int check_connect_login_server(int tid, unsigned int tick, int id, int data) {
session[login_fd]->func_parse = parse_tologin;
realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
{
- WFIFOHEAD(login_fd, 86);
+ WFIFOHEAD(login_fd,86);
WFIFOW(login_fd,0) = 0x2710;
memcpy(WFIFOP(login_fd,2), userid, 24);
memcpy(WFIFOP(login_fd,26), passwd, 24);
@@ -3765,19 +3765,6 @@ static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int dat
return 0;
}
-//----------------------------------------------------------
-// Return numerical value of a switch configuration by [Yor]
-// on/off, english, franais, deutsch, espaol
-//----------------------------------------------------------
-int config_switch(const char *str) {
- if (strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || strcmpi(str, "si") == 0)
- return 1;
- if (strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0)
- return 0;
-
- return atoi(str);
-}
-
//----------------------------------
// Reading Lan Support configuration
// Rewrote: Anvanced subnet check [LuzZza]
diff --git a/src/common/strlib.c b/src/common/strlib.c
index 327b2daf1..0ad0575f7 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -207,3 +207,53 @@ size_t strnlen (const char* string, size_t maxlen)
return end ? (size_t) (end - string) : maxlen;
}
#endif
+
+//----------------------------------------------------
+// E-mail check: return 0 (not correct) or 1 (valid).
+//----------------------------------------------------
+int e_mail_check(char* email)
+{
+ char ch;
+ char* last_arobas;
+ int len = strlen(email);
+
+ // athena limits
+ if (len < 3 || len > 39)
+ return 0;
+
+ // part of RFC limits (official reference of e-mail description)
+ if (strchr(email, '@') == NULL || email[len-1] == '@')
+ return 0;
+
+ if (email[len-1] == '.')
+ return 0;
+
+ last_arobas = strrchr(email, '@');
+
+ if (strstr(last_arobas, "@.") != NULL || strstr(last_arobas, "..") != NULL)
+ return 0;
+
+ for(ch = 1; ch < 32; ch++)
+ if (strchr(last_arobas, ch) != NULL)
+ return 0;
+
+ if (strchr(last_arobas, ' ') != NULL || strchr(last_arobas, ';') != NULL)
+ return 0;
+
+ // all correct
+ return 1;
+}
+
+//--------------------------------------------------
+// Return numerical value of a switch configuration
+// on/off, english, franais, deutsch, espaol
+//--------------------------------------------------
+int config_switch(const char* str)
+{
+ if (strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || strcmpi(str, "si") == 0)
+ return 1;
+ if (strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0)
+ return 0;
+
+ return (int)strtol(str, NULL, 0);
+}
diff --git a/src/common/strlib.h b/src/common/strlib.h
index 332e823b9..baaf244d7 100644
--- a/src/common/strlib.h
+++ b/src/common/strlib.h
@@ -22,4 +22,8 @@ char* _strtok_r(char* s1, const char* s2, char** lasts);
size_t strnlen (const char* string, size_t maxlen);
#endif
+int e_mail_check(char* email);
+int config_switch(const char* str);
+
+
#endif /* _STRLIB_H_ */
diff --git a/src/ladmin/ladmin.c b/src/ladmin/ladmin.c
index 4f4099493..38d7dcefc 100644
--- a/src/ladmin/ladmin.c
+++ b/src/ladmin/ladmin.c
@@ -361,45 +361,6 @@ int verify_accountname(char* account_name) {
return 1;
}
-//---------------------------------------------------
-// E-mail check: return 0 (not correct) or 1 (valid).
-//---------------------------------------------------
-int e_mail_check(char *email) {
- char ch;
- char* last_arobas;
-
- // athena limits
- if (strlen(email) < 3 || strlen(email) > 39)
- return 0;
-
- // part of RFC limits (official reference of e-mail description)
- if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
- return 0;
-
- if (email[strlen(email)-1] == '.')
- return 0;
-
- last_arobas = strrchr(email, '@');
-
- if (strstr(last_arobas, "@.") != NULL ||
- strstr(last_arobas, "..") != NULL)
- return 0;
-
- for(ch = 1; ch < 32; ch++) {
- if (strchr(last_arobas, ch) != NULL) {
- return 0;
- break;
- }
- }
-
- if (strchr(last_arobas, ' ') != NULL ||
- strchr(last_arobas, ';') != NULL)
- return 0;
-
- // all correct
- return 1;
-}
-
//----------------------------------
// Sub-function: Input of a password
//----------------------------------
@@ -4256,19 +4217,6 @@ int Connect_login_server(void) {
return 0;
}
-//-------------------------------------------------
-// Return numerical value of a switch configuration
-// on/off, english, franais, deutsch, espaol
-//-------------------------------------------------
-int config_switch(const char *str) {
- if (strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || strcmpi(str, "si") == 0)
- return 1;
- if (strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0)
- return 0;
-
- return atoi(str);
-}
-
//-----------------------------------
// Reading general configuration file
//-----------------------------------
diff --git a/src/login/login.c b/src/login/login.c
index 4bf36a566..c11bb2e74 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -22,17 +22,17 @@
#include <string.h>
#include <stdarg.h>
+#include "../common/cbasetypes.h"
#include "../common/core.h"
#include "../common/socket.h"
-#include "../common/timer.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/version.h"
#include "../common/db.h"
+#include "../common/timer.h"
#include "../common/lock.h"
#include "../common/malloc.h"
#include "../common/strlib.h"
+#include "../common/mmo.h"
#include "../common/showmsg.h"
+#include "../common/version.h"
#include "../common/md5calc.h"
#include "login.h"
@@ -215,7 +215,8 @@ static int waiting_disconnect_timer(int tid, unsigned int tick, int id, int data
// Online User Database [Wizputer]
//-----------------------------------------------------
-void add_online_user (int char_server, int account_id) {
+void add_online_user(int char_server, int account_id)
+{
struct online_login_data *p;
if (!online_check)
return;
@@ -228,11 +229,12 @@ void add_online_user (int char_server, int account_id) {
}
}
-void remove_online_user (int account_id) {
+void remove_online_user(int account_id)
+{
if(!online_check)
return;
- if (account_id == 99) { // reset all to offline
- online_db->clear(online_db, NULL); // purge db
+ if (account_id == 99) { // reset all to offline
+ online_db->clear(online_db, NULL); // purge db
return;
}
idb_remove(online_db,account_id);
@@ -244,12 +246,13 @@ static int waiting_disconnect_timer(int tid, unsigned int tick, int id, int data
if ((p= idb_get(online_db, id)) != NULL && p->waiting_disconnect == id)
{
p->waiting_disconnect = -1;
- remove_online_user(p->account_id);
+ remove_online_user(id);
}
return 0;
}
-static int sync_ip_addresses(int tid, unsigned int tick, int id, int data){
+static int sync_ip_addresses(int tid, unsigned int tick, int id, int data)
+{
unsigned char buf[2];
ShowInfo("IP Sync in progress...\n");
WBUFW(buf,0) = 0x2735;
@@ -487,43 +490,6 @@ int check_ladminip(uint32 ip)
return 0;
}
-//---------------------------------------------------
-// E-mail check: return 0 (not correct) or 1 (valid).
-//---------------------------------------------------
-int e_mail_check(char *email)
-{
- char ch;
- char* last_arobas;
-
- // athena limits
- if (strlen(email) < 3 || strlen(email) > 39)
- return 0;
-
- // part of RFC limits (official reference of e-mail description)
- if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
- return 0;
-
- if (email[strlen(email)-1] == '.')
- return 0;
-
- last_arobas = strrchr(email, '@');
-
- if (strstr(last_arobas, "@.") != NULL ||
- strstr(last_arobas, "..") != NULL)
- return 0;
-
- for(ch = 1; ch < 32; ch++)
- if (strchr(last_arobas, ch) != NULL)
- return 0;
-
- if (strchr(last_arobas, ' ') != NULL ||
- strchr(last_arobas, ';') != NULL)
- return 0;
-
- // all correct
- return 1;
-}
-
//-----------------------------------------------
// Search an account id
// (return account index or -1 (if not found))
@@ -1005,11 +971,11 @@ int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
for(i = 0, c = 0; i < MAX_SERVERS; i++) {
if ((fd = server_fd[i]) >= 0 && fd != sfd) {
- WFIFOHEAD(fd, len);
+ WFIFOHEAD(fd,len);
if (WFIFOSPACE(fd) < len) //Increase buffer size.
realloc_writefifo(fd, len);
memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd, len);
+ WFIFOSET(fd,len);
c++;
}
}
@@ -1487,7 +1453,7 @@ int parse_fromchar(int fd)
if (i == AUTH_FIFO_SIZE) {
login_log("Char-server '%s': authentification of the account %d REFUSED (ip: %s)." RETCODE,
server[id].name, account_id, ip);
- WFIFOHEAD(fd, 51);
+ WFIFOHEAD(fd,51);
WFIFOW(fd,0) = 0x2713;
WFIFOL(fd,2) = account_id;
WFIFOB(fd,6) = 1;
@@ -1505,7 +1471,7 @@ int parse_fromchar(int fd)
//printf("parse_fromchar: Receiving of the users number of the server '%s': %d\n", server[id].name, RFIFOL(fd,2));
server[id].users = RFIFOL(fd,2);
// send some answer
- WFIFOHEAD(fd, 2);
+ WFIFOHEAD(fd,2);
WFIFOW(fd,0) = 0x2718;
WFIFOSET(fd,2);
@@ -2033,7 +1999,7 @@ int parse_admin(int fd)
switch(RFIFOW(fd,0)) {
case 0x7530: // Request of the server version
login_log("'ladmin': Sending of the server version (ip: %s)" RETCODE, ip);
- WFIFOHEAD(fd, 10);
+ WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x7531;
WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
@@ -2988,7 +2954,7 @@ int lan_subnetcheck(uint32 ip)
}
//----------------------------------------------------------------------------------------
-// Default packet parsing (normal players or administation/char-server connexion requests)
+// Default packet parsing (normal players or administation/char-server connection requests)
//----------------------------------------------------------------------------------------
int parse_login(int fd)
{
@@ -3042,7 +3008,7 @@ int parse_login(int fd)
//Perform ip-ban check
if (!check_ip(ipl)) {
login_log("Connection refused: IP isn't authorised (deny/allow, ip: %s)." RETCODE, ip);
- WFIFOHEAD(fd, 23);
+ WFIFOHEAD(fd,23);
WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = 3; // 3 = Rejected from Server
WFIFOSET(fd,23);
@@ -3050,7 +3016,7 @@ int parse_login(int fd)
break;
}
- switch(RFIFOW(fd, 0)){
+ switch(RFIFOW(fd,0)){
case 0x64:
if(packet_len < 55)
return 0;
@@ -3094,18 +3060,18 @@ int parse_login(int fd)
if (min_level_to_connect > gm_level) {
login_log("Connection refused: the minimum GM level for connection is %d (account: %s, GM level: %d, ip: %s)." RETCODE,
min_level_to_connect, account.userid, gm_level, ip);
- WFIFOHEAD(fd, 3);
+ WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = 1; // 01 = Server closed
WFIFOSET(fd,3);
} else {
if (gm_level)
- ShowInfo("Connection of the GM (level:%d) account '%s' accepted.\n", gm_level, account.userid);
+ ShowStatus("Connection of the GM (level:%d) account '%s' accepted.\n", gm_level, account.userid);
else
- ShowInfo("Connection of the account '%s' accepted.\n", account.userid);
+ ShowStatus("Connection of the account '%s' accepted.\n", account.userid);
server_num = 0;
- WFIFOHEAD(fd, 47+32*MAX_SERVERS);
+ WFIFOHEAD(fd,47+32*MAX_SERVERS);
for(i = 0; i < MAX_SERVERS; i++) {
if (server_fd[i] >= 0) {
// Advanced subnet check [LuzZza]
@@ -3147,7 +3113,7 @@ int parse_login(int fd)
}
}
} else { // auth failed
- WFIFOHEAD(fd, 23);
+ WFIFOHEAD(fd,23);
memset(WFIFOP(fd,0), '\0', 23);
WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = result;
@@ -3187,7 +3153,7 @@ int parse_login(int fd)
ld->md5key[i] = rand() % 255 + 1;
RFIFOSKIP(fd,2);
- WFIFOHEAD(fd, 4 + ld->md5keylen);
+ WFIFOHEAD(fd,4 + ld->md5keylen);
WFIFOW(fd,0) = 0x01dc;
WFIFOW(fd,2) = 4 + ld->md5keylen;
memcpy(WFIFOP(fd,4), ld->md5key, ld->md5keylen);
@@ -3204,7 +3170,7 @@ int parse_login(int fd)
uint32 server_ip;
uint16 server_port;
- WFIFOHEAD(fd, 3);
+ WFIFOHEAD(fd,3);
memcpy(account.userid,RFIFOP(fd,2),NAME_LENGTH); account.userid[23] = '\0'; remove_control_chars((unsigned char *)account.userid);
memcpy(account.passwd, RFIFOP(fd,26), NAME_LENGTH); account.passwd[23] = '\0'; remove_control_chars((unsigned char *)account.passwd);
account.passwdenc = 0;
@@ -3271,8 +3237,9 @@ int parse_login(int fd)
return 0;
case 0x7530: // Server version information request
+ {
login_log("Sending of the server version (ip: %s)" RETCODE, ip);
- WFIFOHEAD(fd, 10);
+ WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x7531;
WFIFOB(fd,2) = ATHENA_MAJOR_VERSION;
WFIFOB(fd,3) = ATHENA_MINOR_VERSION;
@@ -3284,6 +3251,7 @@ int parse_login(int fd)
WFIFOSET(fd,10);
RFIFOSKIP(fd,2);
break;
+ }
case 0x7532: // Request to end connection
login_log("End of connection (ip: %s)" RETCODE, ip);
@@ -3441,20 +3409,6 @@ static int online_data_cleanup(int tid, unsigned int tick, int id, int data)
return 0;
}
-//-------------------------------------------------
-// Return numerical value of a switch configuration
-// 1/0, on/off, english, franais, deutsch
-//-------------------------------------------------
-int config_switch(const char *str)
-{
- if (strcmpi(str, "1") == 0 || strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0)
- return 1;
- if (strcmpi(str, "0") == 0 || strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0)
- return 0;
-
- return atoi(str);
-}
-
//----------------------------------
// Reading Lan Support configuration
//----------------------------------
@@ -3473,14 +3427,14 @@ int login_lan_config_read(const char *lancfgName)
while(fgets(line, sizeof(line)-1, fp)) {
- line_num++;
+ line_num++;
if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n')
continue;
line[sizeof(line)-1] = '\0';
if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) {
-
- ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num);
+
+ ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num);
continue;
}
@@ -3490,7 +3444,7 @@ int login_lan_config_read(const char *lancfgName)
remove_control_chars((unsigned char *)w4);
if(strcmpi(w1, "subnet") == 0) {
-
+
subnet[subnet_count].mask = ntohl(inet_addr(w2));
subnet[subnet_count].char_ip = ntohl(inet_addr(w3));
subnet[subnet_count].map_ip = ntohl(inet_addr(w4));
@@ -3499,7 +3453,7 @@ int login_lan_config_read(const char *lancfgName)
ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4);
continue;
}
-
+
subnet_count++;
}
@@ -3512,7 +3466,7 @@ int login_lan_config_read(const char *lancfgName)
//-----------------------------------
// Reading main configuration file
-//-----------------------------------
+//-----------------------------------
int login_config_read(const char* cfgName)
{
char line[1024], w1[1024], w2[1024];
@@ -3676,35 +3630,35 @@ int login_config_read(const char* cfgName)
access_deny[access_denynum * ACO_STRSIZE - 1] = '\0';
}
}
- } else if (strcmpi(w1, "new_account") == 0) {
+ }
+ else if(!strcmpi(w1, "new_account"))
new_account_flag = config_switch(w2);
- } else if(strcmpi(w1, "check_client_version") == 0) {
+ else if(!strcmpi(w1, "check_client_version"))
check_client_version = config_switch(w2);
- } else if(strcmpi(w1, "client_version_to_connect") == 0) {
+ else if(!strcmpi(w1, "client_version_to_connect"))
client_version_to_connect = atoi(w2);
- } else if (strcmpi(w1, "use_MD5_passwords") == 0) {
+ else if(!strcmpi(w1, "use_MD5_passwords"))
use_md5_passwds = config_switch(w2);
- } else if (strcmpi(w1, "min_level_to_connect") == 0) {
+ else if(!strcmpi(w1, "min_level_to_connect"))
min_level_to_connect = atoi(w2);
- } else if (!strcmpi(w1, "date_format")) {
+ else if(!strcmpi(w1, "date_format"))
strncpy(date_format, w2, sizeof(date_format));
- } else if (strcmpi(w1, "console") == 0) {
+ else if(!strcmpi(w1, "console"))
console = config_switch(w2);
- } else if (strcmpi(w1, "allowed_regs") == 0) { //account flood protection system
+ else if(!strcmpi(w1, "allowed_regs")) //account flood protection system
allowed_regs = atoi(w2);
- } else if (strcmpi(w1, "time_allowed") == 0) {
+ else if(!strcmpi(w1, "time_allowed"))
time_allowed = atoi(w2);
- } else if (strcmpi(w1, "online_check") == 0) {
+ else if(!strcmpi(w1, "online_check"))
online_check = config_switch(w2);
- } else if(strcmpi(w1,"use_dnsbl")==0) {
- use_dnsbl=config_switch(w2);
- } else if(strcmpi(w1,"dnsbl_servers")==0) {
- strcpy(dnsbl_servs,w2);
- } else if(strcmpi(w1,"ip_sync_interval")==0) {
+ else if(!strcmpi(w1, "use_dnsbl"))
+ use_dnsbl = config_switch(w2);
+ else if(!strcmpi(w1, "dnsbl_servers"))
+ strcpy(dnsbl_servs, w2);
+ else if(!strcmpi(w1, "ip_sync_interval"))
ip_sync_interval = 1000*60*atoi(w2); //w2 comes in minutes.
- } else if (strcmpi(w1, "import") == 0) {
+ else if(!strcmpi(w1, "import"))
login_config_read(w2);
- }
}
fclose(fp);
ShowInfo("Finished reading %s.\n", cfgName);
@@ -3996,7 +3950,8 @@ void do_final(void) {
// Function called when the server
// has received a crash signal.
//------------------------------
-void do_abort(void) {
+void do_abort(void)
+{
}
//------------------------------
@@ -4006,7 +3961,9 @@ void set_server_type(void)
{
SERVER_TYPE = ATHENA_SERVER_LOGIN;
}
-int do_init(int argc, char **argv) {
+
+int do_init(int argc, char **argv)
+{
int i, j;
// read login-server configuration
@@ -4056,7 +4013,7 @@ int do_init(int argc, char **argv) {
//##TODO invoke a CONSOLE_START plugin event
}
- new_reg_tick=gettick();
+ new_reg_tick = gettick();
login_log("The login-server is ready (Server is listening on the port %d)." RETCODE, login_port);
ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", login_port);
diff --git a/src/login/login.h b/src/login/login.h
index 441f2bac1..7845d3126 100644
--- a/src/login/login.h
+++ b/src/login/login.h
@@ -15,7 +15,7 @@
extern int login_port;
struct mmo_account {
- int version; //Added for version check [Sirius]
+ int version;
char userid[NAME_LENGTH];
char passwd[NAME_LENGTH];
int passwdenc;
@@ -29,9 +29,9 @@ struct mmo_account {
};
struct mmo_char_server {
- char name[21];
- long ip;
- short port;
+ char name[20];
+ uint32 ip;
+ uint16 port;
int users;
int maintenance;
int new_;
diff --git a/src/login_sql/login.c b/src/login_sql/login.c
index c3c5015b4..eff42ffb8 100644
--- a/src/login_sql/login.c
+++ b/src/login_sql/login.c
@@ -9,7 +9,7 @@
#include <winsock2.h>
#else
#include <sys/socket.h>
- #include <netinet/in.h>
+ #include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
@@ -24,16 +24,16 @@
//add include for DBMS(mysql)
#include <mysql.h>
+#include "../common/cbasetypes.h"
#include "../common/core.h"
#include "../common/socket.h"
-#include "../common/malloc.h"
#include "../common/db.h"
#include "../common/timer.h"
+#include "../common/malloc.h"
#include "../common/strlib.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
#include "../common/version.h"
-#include "../common/cbasetypes.h"
#include "../common/md5calc.h"
#include "login.h"
@@ -117,7 +117,7 @@ char login_db_level[256] = "level";
#define AUTH_FIFO_SIZE 256
struct {
- int account_id,login_id1,login_id2;
+ int account_id, login_id1, login_id2;
uint32 ip;
char sex;
bool delflag;
@@ -263,51 +263,13 @@ void send_GM_accounts(int fd)
charif_sendallwos(-1, buf, len);
else
{
- WFIFOHEAD(fd, len);
+ WFIFOHEAD(fd,len);
memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd, len);
+ WFIFOSET(fd,len);
}
return;
}
-//---------------------------------------------------
-// E-mail check: return 0 (not correct) or 1 (valid).
-//---------------------------------------------------
-int e_mail_check(char* email)
-{
- char ch;
- char* last_arobas;
- int len = strlen(email);
-
- // athena limits
- if (len < 3 || len > 39)
- return 0;
-
- // part of RFC limits (official reference of e-mail description)
- if (strchr(email, '@') == NULL || email[len-1] == '@')
- return 0;
-
- if (email[len-1] == '.')
- return 0;
-
- last_arobas = strrchr(email, '@');
-
- if (strstr(last_arobas, "@.") != NULL ||
- strstr(last_arobas, "..") != NULL)
- return 0;
-
- for(ch = 1; ch < 32; ch++)
- if (strchr(last_arobas, ch) != NULL)
- return 0;
-
- if (strchr(last_arobas, ' ') != NULL ||
- strchr(last_arobas, ';') != NULL)
- return 0;
-
- // all correct
- return 1;
-}
-
/*=============================================
* Does a mysql_ping to all connection handles
*---------------------------------------------*/
@@ -510,11 +472,11 @@ int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
for(i = 0, c = 0; i < MAX_SERVERS; i++) {
if ((fd = server_fd[i]) > 0 && fd != sfd) {
- WFIFOHEAD(fd, len);
+ WFIFOHEAD(fd,len);
if (WFIFOSPACE(fd) < len) //Increase buffer size.
realloc_writefifo(fd, len);
memcpy(WFIFOP(fd,0), buf, len);
- WFIFOSET(fd, len);
+ WFIFOSET(fd,len);
c++;
}
}
@@ -942,11 +904,11 @@ int parse_fromchar(int fd)
RFIFOSKIP(fd, RFIFOW(fd, 2));
{
- WFIFOHEAD(fd, 10);
- WFIFOW(fd, 0) = 0x2721;
- WFIFOL(fd, 2) = RFIFOL(fd,4); // oldacc;
- WFIFOL(fd, 6) = 0; // newacc;
- WFIFOSET(fd, 10);
+ WFIFOHEAD(fd,10);
+ WFIFOW(fd,0) = 0x2721;
+ WFIFOL(fd,2) = RFIFOL(fd,4); // oldacc;
+ WFIFOL(fd,6) = 0; // newacc;
+ WFIFOSET(fd,10);
}
return 0;
@@ -1399,7 +1361,7 @@ int parse_login(int fd)
//Perform ip-ban check
if (login_config.ipban && login_ip_ban_check(ipl))
{
- WFIFOHEAD(fd, 23);
+ WFIFOHEAD(fd,23);
WFIFOW(fd,0) = 0x6a;
WFIFOB(fd,2) = 3; // 3 = Rejected from Server
WFIFOSET(fd,23);
@@ -1408,7 +1370,7 @@ int parse_login(int fd)
break;
}
- switch(RFIFOW(fd, 0)){
+ switch(RFIFOW(fd,0)){
case 0x64:
if(packet_len < 55)
return 0;
@@ -1431,14 +1393,14 @@ int parse_login(int fd)
account.passwd[23] = '\0';
#ifdef PASSWORDENC
- account.passwdenc= (RFIFOW(fd,0)!=0x01dd)?0:PASSWORDENC;
+ account.passwdenc = (RFIFOW(fd,0)!=0x01dd)?0:PASSWORDENC;
#else
- account.passwdenc=0;
+ account.passwdenc = 0;
#endif
- result=mmo_auth(&account, fd);
+ result = mmo_auth(&account, fd);
jstrescapecpy(t_uid,account.userid);
- if(result==-1) { // auth success
+ if(result == -1) { // auth success
if (login_config.min_level_to_connect > account.level) {
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
@@ -1499,7 +1461,7 @@ int parse_login(int fd)
}
}
} else { // auth failed
- WFIFOHEAD(fd, 23);
+ WFIFOHEAD(fd,23);
if (login_config.log_login)
{
const char* error;
@@ -1607,7 +1569,7 @@ int parse_login(int fd)
}
{
RFIFOSKIP(fd,2);
- WFIFOHEAD(fd, 4 + md5keylen);
+ WFIFOHEAD(fd,4 + md5keylen);
WFIFOW(fd,0) = 0x01dc;
WFIFOW(fd,2) = 4 + md5keylen;
memcpy(WFIFOP(fd,4), md5key, md5keylen);
@@ -1623,13 +1585,13 @@ int parse_login(int fd)
uint32 server_ip;
uint16 server_port;
- WFIFOHEAD(fd, 3);
- memcpy(account.userid,RFIFOP(fd, 2),NAME_LENGTH); account.userid[23] = '\0';
- memcpy(account.passwd,RFIFOP(fd, 26),NAME_LENGTH); account.passwd[23] = '\0';
+ WFIFOHEAD(fd,3);
+ memcpy(account.userid,RFIFOP(fd,2),NAME_LENGTH); account.userid[23] = '\0';
+ memcpy(account.passwd,RFIFOP(fd,26),NAME_LENGTH); account.passwd[23] = '\0';
account.passwdenc = 0;
server_name = (char*)RFIFOP(fd,60); server_name[20] = '\0';
- server_ip = ntohl(RFIFOL(fd, 54));
- server_port = ntohs(RFIFOW(fd, 58));
+ server_ip = ntohl(RFIFOL(fd,54));
+ server_port = ntohs(RFIFOW(fd,58));
ShowInfo("Connection request of the char-server '%s' @ %d.%d.%d.%d:%d (ip: %s)\n",
server_name, CONVIP(server_ip), server_port, ip);
jstrescapecpy(t_uid, server_name);
@@ -1688,7 +1650,7 @@ int parse_login(int fd)
RFIFOSKIP(fd,86);
return 0;
- case 0x7530: // request Athena information
+ case 0x7530: // Server version information request
{
ShowInfo ("Athena version check...\n");
WFIFOHEAD(fd,10);
@@ -1704,6 +1666,7 @@ int parse_login(int fd)
RFIFOSKIP(fd,2);
break;
}
+
case 0x7532: // Request to end connection
ShowStatus ("End of connection (ip: %s)" RETCODE, ip);
session[fd]->eof = 1;
@@ -1766,20 +1729,6 @@ static int online_data_cleanup(int tid, unsigned int tick, int id, int data)
return 0;
}
-//-------------------------------------------------
-// Return numerical value of a switch configuration
-// 1/0, on/off, english, franais, deutsch
-//-------------------------------------------------
-int config_switch(const char *str)
-{
- if (strcmpi(str, "1") == 0 || strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0)
- return 1;
- if (strcmpi(str, "0") == 0 || strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0)
- return 0;
-
- return atoi(str);
-}
-
//----------------------------------
// Reading Lan Support configuration
//----------------------------------
@@ -1798,14 +1747,14 @@ int login_lan_config_read(const char *lancfgName)
while(fgets(line, sizeof(line)-1, fp)) {
- line_num++;
+ line_num++;
if ((line[0] == '/' && line[1] == '/') || line[0] == '\n' || line[1] == '\n')
continue;
- line[sizeof(line)-1] = '\0';
+ line[sizeof(line)-1] = '\0';
if(sscanf(line,"%[^:]: %[^:]:%[^:]:%[^\r\n]", w1, w2, w3, w4) != 4) {
- ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num);
+ ShowWarning("Error syntax of configuration file %s in line %d.\n", lancfgName, line_num);
continue;
}
@@ -1891,24 +1840,24 @@ int login_config_read(const char* cfgName)
else if (!strcmpi(w1, "log_login"))
login_config.log_login = config_switch(w2);
- else if (!strcmpi(w1,"ipban"))
+ else if (!strcmpi(w1, "ipban"))
login_config.ipban = config_switch(w2);
- else if (!strcmpi(w1,"dynamic_pass_failure_ban"))
- login_config.dynamic_pass_failure_ban=config_switch(w2);
- else if (!strcmpi(w1,"dynamic_pass_failure_ban_interval"))
- login_config.dynamic_pass_failure_ban_interval=atoi(w2);
- else if (!strcmpi(w1,"dynamic_pass_failure_ban_limit"))
- login_config.dynamic_pass_failure_ban_limit=atoi(w2);
- else if (!strcmpi(w1,"dynamic_pass_failure_ban_duration"))
- login_config.dynamic_pass_failure_ban_duration=atoi(w2);
-
- else if (!strcmpi(w1,"new_account"))
+ else if (!strcmpi(w1, "dynamic_pass_failure_ban"))
+ login_config.dynamic_pass_failure_ban = config_switch(w2);
+ else if (!strcmpi(w1, "dynamic_pass_failure_ban_interval"))
+ login_config.dynamic_pass_failure_ban_interval = atoi(w2);
+ else if (!strcmpi(w1, "dynamic_pass_failure_ban_limit"))
+ login_config.dynamic_pass_failure_ban_limit = atoi(w2);
+ else if (!strcmpi(w1, "dynamic_pass_failure_ban_duration"))
+ login_config.dynamic_pass_failure_ban_duration = atoi(w2);
+
+ else if (!strcmpi(w1, "new_account"))
login_config.new_account_flag=config_switch(w2);
- else if (!strcmpi(w1,"check_client_version"))
+ else if (!strcmpi(w1, "check_client_version"))
login_config.check_client_version=config_switch(w2);
- else if (!strcmpi(w1,"client_version_to_connect"))
+ else if (!strcmpi(w1, "client_version_to_connect"))
login_config.client_version_to_connect=atoi(w2);
- else if (!strcmpi(w1,"use_MD5_passwords"))
+ else if (!strcmpi(w1, "use_MD5_passwords"))
login_config.use_md5_passwds = config_switch(w2);
else if (!strcmpi(w1, "min_level_to_connect"))
login_config.min_level_to_connect = atoi(w2);
@@ -1924,11 +1873,11 @@ int login_config_read(const char* cfgName)
time_allowed = atoi(w2);
else if (!strcmpi(w1, "online_check"))
login_config.online_check = config_switch(w2);
- else if (!strcmpi(w1,"use_dnsbl"))
+ else if (!strcmpi(w1, "use_dnsbl"))
login_config.use_dnsbl = config_switch(w2);
- else if (!strcmpi(w1,"dnsbl_servers"))
- { strncpy(login_config.dnsbl_servs,w2,1023); login_config.dnsbl_servs[1023] = '\0'; }
- else if (!strcmpi(w1,"ip_sync_interval"))
+ else if (!strcmpi(w1, "dnsbl_servers"))
+ { strncpy(login_config.dnsbl_servs, w2, 1023); login_config.dnsbl_servs[1023] = '\0'; }
+ else if (!strcmpi(w1, "ip_sync_interval"))
login_config.ip_sync_interval = 1000*60*atoi(w2); //w2 comes in minutes.
else if (!strcmpi(w1, "import"))
login_config_read(w2);
@@ -1958,31 +1907,31 @@ void sql_config_read(const char* cfgName)
login_config.login_gm_read = (atoi(w2) == 0);
else if (!strcmpi(w1, "login_db"))
strcpy(login_db, w2);
- else if (!strcmpi(w1,"login_server_ip"))
+ else if (!strcmpi(w1, "login_server_ip"))
strcpy(login_server_ip, w2);
- else if (!strcmpi(w1,"login_server_port"))
+ else if (!strcmpi(w1, "login_server_port"))
login_server_port = atoi(w2);
- else if (!strcmpi(w1,"login_server_id"))
+ else if (!strcmpi(w1, "login_server_id"))
strcpy(login_server_id, w2);
- else if (!strcmpi(w1,"login_server_pw"))
+ else if (!strcmpi(w1, "login_server_pw"))
strcpy(login_server_pw, w2);
- else if (!strcmpi(w1,"login_server_db"))
+ else if (!strcmpi(w1, "login_server_db"))
strcpy(login_server_db, w2);
- else if (!strcmpi(w1,"default_codepage"))
+ else if (!strcmpi(w1, "default_codepage"))
strcpy(default_codepage, w2);
- else if (!strcmpi(w1,"login_db_account_id"))
+ else if (!strcmpi(w1, "login_db_account_id"))
strcpy(login_db_account_id, w2);
- else if (!strcmpi(w1,"login_db_userid"))
+ else if (!strcmpi(w1, "login_db_userid"))
strcpy(login_db_userid, w2);
- else if (!strcmpi(w1,"login_db_user_pass"))
+ else if (!strcmpi(w1, "login_db_user_pass"))
strcpy(login_db_user_pass, w2);
- else if (!strcmpi(w1,"login_db_level"))
+ else if (!strcmpi(w1, "login_db_level"))
strcpy(login_db_level, w2);
else if (!strcmpi(w1, "loginlog_db"))
strcpy(loginlog_db, w2);
else if (!strcmpi(w1, "reg_db"))
strcpy(reg_db, w2);
- else if (!strcmpi(w1,"import"))
+ else if (!strcmpi(w1, "import"))
sql_config_read(w2);
}
fclose(fp);
diff --git a/src/login_sql/login.h b/src/login_sql/login.h
index 110c6a876..7afe4b358 100644
--- a/src/login_sql/login.h
+++ b/src/login_sql/login.h
@@ -11,13 +11,9 @@
#define LAN_CONF_NAME "conf/subnet_athena.conf"
#ifndef SQL_DEBUG
-
-#define mysql_query(_x, _y) mysql_query(_x, _y)
-
+ #define mysql_query(_x, _y) mysql_query(_x, _y)
#else
-
-#define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
-
+ #define mysql_query(_x, _y) debug_mysql_query(__FILE__, __LINE__, _x, _y)
#endif
#define PASSWORDENC 3 // A definition is given when making an encryption password correspond.
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 916bf2387..f947c0b3b 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -721,46 +721,6 @@ char * player_title_txt(int level) {
return atcmd_temp;
}
-//------------------------------------------------------------
-// E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
-//------------------------------------------------------------
-int e_mail_check(char *email)
-{
- char ch;
- char* last_arobas;
-
- // athena limits
- if (strlen(email) < 3 || strlen(email) > 39)
- return 0;
-
- // part of RFC limits (official reference of e-mail description)
- if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
- return 0;
-
- if (email[strlen(email)-1] == '.')
- return 0;
-
- last_arobas = strrchr(email, '@');
-
- if (strstr(last_arobas, "@.") != NULL ||
- strstr(last_arobas, "..") != NULL)
- return 0;
-
- for(ch = 1; ch < 32; ch++) {
- if (strchr(last_arobas, ch) != NULL) {
- return 0;
- break;
- }
- }
-
- if (strchr(last_arobas, ' ') != NULL ||
- strchr(last_arobas, ';') != NULL)
- return 0;
-
- // all correct
- return 1;
-}
-
/*==========================================
* Retrieve the atcommand's required gm level
*------------------------------------------
@@ -7675,7 +7635,7 @@ int atcommand_partyoption(const int fd, struct map_session_data* sd, const char*
return -1;
}
w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
- option = (battle_config_switch(w1)?1:0)|(battle_config_switch(w2)?2:0);
+ option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
//Change item share type.
if (option != p->party.item)
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index d18e8e923..19b0e27f4 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -325,7 +325,6 @@ void do_final_msg(void);
char* estr_lower(char* str);
-int e_mail_check(char* email);
extern char atcommand_symbol;
#define MAX_MSG 1000
extern char* msg_table[MAX_MSG];
diff --git a/src/map/battle.c b/src/map/battle.c
index f758c3914..6eda8fa78 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3339,26 +3339,6 @@ int battle_check_range(struct block_list *src,struct block_list *bl,int range)
return path_search_long(NULL,src->m,src->x,src->y,bl->x,bl->y);
}
-/*==========================================
- * Return numerical value of a switch configuration (modified by [Yor])
- * on/off, english, franais, deutsch, espaol
- *------------------------------------------
- */
-int battle_config_switch(const char *str) {
- if(strncmpi(str, "on",2) == 0 ||
- strncmpi(str, "yes",3) == 0 ||
- strncmpi(str, "oui",3) == 0 ||
- strncmpi(str, "ja",2) == 0 ||
- strncmpi(str, "si",2) == 0)
- return 1;
- if(strncmpi(str, "off",3) == 0 ||
- strncmpi(str, "no",2) == 0 ||
- strncmpi(str, "non",3) == 0 ||
- strncmpi(str, "nein",4) == 0)
- return 0;
- return (int)strtol(str,NULL,0);
-}
-
static const struct battle_data_short {
const char *str;
unsigned short *val;
@@ -3730,12 +3710,12 @@ int battle_set_value(const char* w1, const char* w2) {
int i;
for(i = 0; i < sizeof(battle_data_short) / (sizeof(battle_data_short[0])); i++)
if (strcmpi(w1, battle_data_short[i].str) == 0) {
- * battle_data_short[i].val = battle_config_switch(w2);
+ * battle_data_short[i].val = config_switch(w2);
return 1;
}
for(i = 0; i < sizeof(battle_data_int) / (sizeof(battle_data_int[0])); i++)
if (strcmpi(w1, battle_data_int[i].str) == 0) {
- *battle_data_int[i].val = battle_config_switch(w2);
+ *battle_data_int[i].val = config_switch(w2);
return 1;
}
return 0;
diff --git a/src/map/battle.h b/src/map/battle.h
index 90b42444c..e33b811ad 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -87,8 +87,6 @@ int battle_check_range(struct block_list *src,struct block_list *bl,int range);
void battle_consume_ammo(struct map_session_data* sd, int skill, int lv);
// ݒ
-int battle_config_switch(const char *str); // [Valaris]
-
extern struct Battle_Config {
unsigned short warp_point_debug;
unsigned short enable_critical;
diff --git a/src/map/map.c b/src/map/map.c
index b69bd4367..43140677e 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2678,18 +2678,6 @@ int parse_console(char* buf)
return 0;
}
-//-------------------------------------------------
-// Return numerical value of a switch configuration
-// on/off, english, franais, deutsch, espaol
-//-------------------------------------------------
-int config_switch(const char *str) {
- if (strcmpi(str, "on") == 0 || strcmpi(str, "yes") == 0 || strcmpi(str, "oui") == 0 || strcmpi(str, "ja") == 0 || strcmpi(str, "si") == 0)
- return 1;
- if (strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0)
- return 0;
- return atoi(str);
-}
-
/*==========================================
* ݒt@C??
*------------------------------------------
@@ -2812,7 +2800,7 @@ int inter_config_read(char *cfgName)
if(i!=2)
continue;
if(strcmpi(w1,"party_share_level")==0){
- party_share_level = battle_config_switch(w2);
+ party_share_level = config_switch(w2);
} else if(strcmpi(w1,"lowest_gm_level")==0){
lowest_gm_level = atoi(w2);
@@ -2845,7 +2833,7 @@ int inter_config_read(char *cfgName)
} else if(strcmpi(w1,"default_codepage")==0){
strcpy(default_codepage, w2);
} else if(strcmpi(w1,"use_sql_db")==0){
- db_use_sqldbs = battle_config_switch(w2);
+ db_use_sqldbs = config_switch(w2);
ShowStatus ("Using SQL dbs: %s\n",w2);
} else if(strcmpi(w1,"log_db")==0) {
strcpy(log_db, w2);
@@ -2861,7 +2849,7 @@ int inter_config_read(char *cfgName)
log_db_port = atoi(w2);
// Mail Server SQL
} else if(strcmpi(w1,"mail_server_enable")==0){
- mail_server_enable = battle_config_switch(w2);
+ mail_server_enable = config_switch(w2);
ShowStatus ("Using Mail Server: %s\n",w2);
} else if(strcmpi(w1,"mail_server_ip")==0){
strcpy(mail_server_ip, w2);
diff --git a/src/map/script.c b/src/map/script.c
index 602020cf2..c305bf6ec 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3312,22 +3312,22 @@ int script_config_read_sub(char *cfgName)
set_posword(w2);
}
else if(strcmpi(w1,"verbose_mode")==0) {
- script_config.verbose_mode = battle_config_switch(w2);
+ script_config.verbose_mode = config_switch(w2);
}
else if(strcmpi(w1,"warn_func_mismatch_paramnum")==0) {
- script_config.warn_func_mismatch_paramnum = battle_config_switch(w2);
+ script_config.warn_func_mismatch_paramnum = config_switch(w2);
}
else if(strcmpi(w1,"check_cmdcount")==0) {
- script_config.check_cmdcount = battle_config_switch(w2);
+ script_config.check_cmdcount = config_switch(w2);
}
else if(strcmpi(w1,"check_gotocount")==0) {
- script_config.check_gotocount = battle_config_switch(w2);
+ script_config.check_gotocount = config_switch(w2);
}
else if(strcmpi(w1,"event_script_type")==0) {
- script_config.event_script_type = battle_config_switch(w2);
+ script_config.event_script_type = config_switch(w2);
}
else if(strcmpi(w1,"event_requires_trigger")==0) {
- script_config.event_requires_trigger = battle_config_switch(w2);
+ script_config.event_requires_trigger = config_switch(w2);
}
else if(strcmpi(w1,"die_event_name")==0) {
strncpy(script_config.die_event_name, w2, NAME_LENGTH-1);
diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c
index c576a6b6c..32680f917 100644
--- a/src/tool/mapcache.c
+++ b/src/tool/mapcache.c
@@ -4,7 +4,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <malloc.h>
#ifndef _WIN32
#include <unistd.h>