summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
Diffstat (limited to 'src/char')
-rw-r--r--src/char/char.c82
-rw-r--r--src/char/inter.c8
-rw-r--r--src/char/loginif.c7
3 files changed, 48 insertions, 49 deletions
diff --git a/src/char/char.c b/src/char/char.c
index e70a4b762..52c560373 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2208,7 +2208,7 @@ void char_disconnect_player(int account_id)
// disconnect player if online on char-server
ARR_FIND( 0, sockt->fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == account_id );
if( i < sockt->fd_max )
- set_eof(i);
+ sockt->eof(i);
}
void char_authfail_fd(int fd, int type)
@@ -2280,7 +2280,7 @@ int char_parse_fromlogin_connection_state(int fd)
ShowError("The server communication passwords (default s1/p1) are probably invalid.\n");
ShowError("Also, please make sure your login db has the correct communication username/passwords and the gender of the account is S.\n");
ShowError("The communication passwords are set in /conf/map-server.conf and /conf/char-server.conf\n");
- set_eof(fd);
+ sockt->eof(fd);
return 1;
} else {
ShowStatus("Connected to login-server (connection #%d).\n", fd);
@@ -2315,7 +2315,7 @@ void char_parse_fromlogin_auth_state(int fd)
unsigned int expiration_time = RFIFOL(fd, 29);
RFIFOSKIP(fd,33);
- if( session_isActive(request_id) && (sd=(struct char_session_data*)session[request_id]->session_data) &&
+ if (sockt->session_is_active(request_id) && (sd=(struct char_session_data*)session[request_id]->session_data) &&
!sd->auth && sd->account_id == account_id && sd->login_id1 == login_id1 && sd->login_id2 == login_id2 && sd->sex == sex )
{
int client_fd = request_id;
@@ -2536,7 +2536,7 @@ void char_parse_fromlogin_kick(int fd)
if( i < sockt->fd_max )
{
chr->authfail_fd(i, 2);
- set_eof(i);
+ sockt->eof(i);
}
else // still moving to the map-server
chr->set_char_offline(-1, aid);
@@ -2561,11 +2561,11 @@ void char_parse_fromlogin_update_ip(int fd)
WBUFW(buf,0) = 0x2b1e;
mapif->sendall(buf, 2);
- new_ip = host2ip(login_ip_str);
+ new_ip = sockt->host2ip(login_ip_str);
if (new_ip && new_ip != login_ip)
login_ip = new_ip; //Update login ip, too.
- new_ip = host2ip(char_ip_str);
+ new_ip = sockt->host2ip(char_ip_str);
if (new_ip && new_ip != chr->ip) {
//Update ip.
chr->ip = new_ip;
@@ -2596,18 +2596,18 @@ int char_parse_fromlogin(int fd) {
// only process data from the login-server
if( fd != chr->login_fd ) {
ShowDebug("chr->parse_fromlogin: Disconnecting invalid session #%d (is not the login-server)\n", fd);
- do_close(fd);
+ sockt->close(fd);
return 0;
}
if( session[fd]->flag.eof ) {
- do_close(fd);
+ sockt->close(fd);
chr->login_fd = -1;
loginif->on_disconnect();
return 0;
} else if ( session[fd]->flag.ping ) {/* we've reached stall time */
if( DIFF_TICK(sockt->last_tick, session[fd]->rdata_tick) > (sockt->stall_time * 2) ) {/* we can't wait any longer */
- set_eof(fd);
+ sockt->eof(fd);
return 0;
} else if( session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */
chr->ping_login_server(fd);
@@ -2713,7 +2713,7 @@ int char_parse_fromlogin(int fd) {
default:
ShowError("Unknown packet 0x%04x received from login-server, disconnecting.\n", command);
- set_eof(fd);
+ sockt->eof(fd);
return 0;
}
}
@@ -2940,7 +2940,7 @@ void mapif_server_destroy(int id)
{
if( chr->server[id].fd == -1 )
{
- do_close(chr->server[id].fd);
+ sockt->close(chr->server[id].fd);
chr->server[id].fd = -1;
}
}
@@ -3296,7 +3296,7 @@ void char_parse_frommap_change_map_server(int fd)
char_data = (struct mmo_charstatus*)uidb_get(chr->char_db_,RFIFOL(fd,14));
}
- if (runflag == CHARSERVER_ST_RUNNING && session_isActive(map_fd) && char_data) {
+ if (runflag == CHARSERVER_ST_RUNNING && sockt->session_is_active(map_fd) && char_data) {
//Send the map server the auth of this player.
struct online_char_data* data;
struct char_auth_node* node;
@@ -3824,14 +3824,14 @@ void char_parse_frommap_request_stats_report(int fd)
opt.silent = 1;
opt.setTimeo = 1;
- if( (sfd = make_connection(host2ip("stats.herc.ws"),(uint16)25427,&opt) ) == -1 ) {
+ if ((sfd = sockt->make_connection(sockt->host2ip("stats.herc.ws"),(uint16)25427,&opt) ) == -1) {
RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
RFIFOFLUSH(fd);
return;/* connection not possible, we drop the report */
}
session[sfd]->flag.server = 1;/* to ensure we won't drop our own packet */
- realloc_fifo(sfd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ sockt->realloc_fifo(sfd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
WFIFOHEAD(sfd, RFIFOW(fd,2) );
@@ -3840,7 +3840,7 @@ void char_parse_frommap_request_stats_report(int fd)
WFIFOSET(sfd, RFIFOW(fd,2) );
do {
- flush_fifo(sfd);
+ sockt->flush(sfd);
#ifdef WIN32
Sleep(1);
#else
@@ -3848,7 +3848,7 @@ void char_parse_frommap_request_stats_report(int fd)
#endif
} while( !session[sfd]->flag.eof && session[sfd]->wdata_size );
- do_close(sfd);
+ sockt->close(sfd);
RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
RFIFOFLUSH(fd);
@@ -3894,11 +3894,11 @@ int char_parse_frommap(int fd)
ARR_FIND( 0, ARRAYLENGTH(chr->server), id, chr->server[id].fd == fd );
if( id == ARRAYLENGTH(chr->server) ) {// not a map server
ShowDebug("chr->parse_frommap: Disconnecting invalid session #%d (is not a map-server)\n", fd);
- do_close(fd);
+ sockt->close(fd);
return 0;
}
if( session[fd]->flag.eof ) {
- do_close(fd);
+ sockt->close(fd);
chr->server[id].fd = -1;
mapif->on_disconnect(id);
return 0;
@@ -4113,7 +4113,7 @@ int char_parse_frommap(int fd)
// no inter server packet. no char server packet -> disconnect
ShowError("Unknown packet 0x%04x from map server, disconnecting.\n", RFIFOW(fd,0));
- set_eof(fd);
+ sockt->eof(fd);
return 0;
}
} // switch
@@ -4497,7 +4497,7 @@ void char_send_map_info(int fd, int i, uint32 subnet_map_ip, struct mmo_charstat
WFIFOL(fd,2) = cd->char_id;
mapindex->getmapname_ext(mapindex_id2name(cd->last_point.map), (char*)WFIFOP(fd,6));
WFIFOL(fd,22) = htonl((subnet_map_ip) ? subnet_map_ip : chr->server[i].ip);
- WFIFOW(fd,26) = ntows(htons(chr->server[i].port)); // [!] LE byte order here [!]
+ WFIFOW(fd,26) = sockt->ntows(htons(chr->server[i].port)); // [!] LE byte order here [!]
WFIFOSET(fd,28);
}
@@ -4977,7 +4977,7 @@ void char_parse_char_login_map_server(int fd, uint32 ipl)
chr->server[i].users = 0;
session[fd]->func_parse = chr->parse_frommap;
session[fd]->flag.server = 1;
- realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ sockt->realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
chr->mapif_init(fd);
}
sockt->datasync(fd, true);
@@ -5052,8 +5052,8 @@ void char_parse_char_move_character(int fd, struct char_session_data* sd)
int char_parse_char_unknown_packet(int fd, uint32 ipl)
{
- ShowError("chr->parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL));
- set_eof(fd);
+ ShowError("chr->parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), sockt->ip2str(ipl, NULL));
+ sockt->eof(fd);
return 1;
}
@@ -5067,7 +5067,7 @@ int char_parse_char(int fd)
// disconnect any player if no login-server.
if(chr->login_fd < 0)
- set_eof(fd);
+ sockt->eof(fd);
if(session[fd]->flag.eof)
{
@@ -5079,7 +5079,7 @@ int char_parse_char(int fd)
if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
chr->set_char_offline(-1,sd->account_id);
}
- do_close(fd);
+ sockt->close(fd);
return 0;
}
@@ -5393,14 +5393,14 @@ int char_check_connect_login_server(int tid, int64 tick, int id, intptr_t data)
ShowInfo("Attempt to connect to login-server...\n");
- if ( (chr->login_fd = make_connection(login_ip, login_port, NULL)) == -1) { //Try again later. [Skotlex]
+ if ((chr->login_fd = sockt->make_connection(login_ip, login_port, NULL)) == -1) { //Try again later. [Skotlex]
chr->login_fd = 0;
return 0;
}
session[chr->login_fd]->func_parse = chr->parse_fromlogin;
session[chr->login_fd]->flag.server = 1;
- realloc_fifo(chr->login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ sockt->realloc_fifo(chr->login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
loginif->connect_to_server();
@@ -5593,27 +5593,27 @@ int char_config_read(const char* cfgName)
safestrncpy(wisp_server_name, w2, sizeof(wisp_server_name));
}
} else if (strcmpi(w1, "login_ip") == 0) {
- login_ip = host2ip(w2);
+ login_ip = sockt->host2ip(w2);
if (login_ip) {
char ip_str[16];
safestrncpy(login_ip_str, w2, sizeof(login_ip_str));
- ShowStatus("Login server IP address : %s -> %s\n", w2, ip2str(login_ip, ip_str));
+ ShowStatus("Login server IP address : %s -> %s\n", w2, sockt->ip2str(login_ip, ip_str));
}
} else if (strcmpi(w1, "login_port") == 0) {
login_port = atoi(w2);
} else if (strcmpi(w1, "char_ip") == 0) {
- chr->ip = host2ip(w2);
+ chr->ip = sockt->host2ip(w2);
if (chr->ip) {
char ip_str[16];
safestrncpy(char_ip_str, w2, sizeof(char_ip_str));
- ShowStatus("Character server IP address : %s -> %s\n", w2, ip2str(chr->ip, ip_str));
+ ShowStatus("Character server IP address : %s -> %s\n", w2, sockt->ip2str(chr->ip, ip_str));
}
} else if (strcmpi(w1, "bind_ip") == 0) {
- bind_ip = host2ip(w2);
+ bind_ip = sockt->host2ip(w2);
if (bind_ip) {
char ip_str[16];
safestrncpy(bind_ip_str, w2, sizeof(bind_ip_str));
- ShowStatus("Character server binding IP address : %s -> %s\n", w2, ip2str(bind_ip, ip_str));
+ ShowStatus("Character server binding IP address : %s -> %s\n", w2, sockt->ip2str(bind_ip, ip_str));
}
} else if (strcmpi(w1, "char_port") == 0) {
chr->port = atoi(w2);
@@ -5739,7 +5739,7 @@ int do_final(void) {
inter->final();
- flush_fifos();
+ sockt->flush_fifos();
do_final_mapif();
loginif->final();
@@ -5752,7 +5752,7 @@ int do_final(void) {
auth_db->destroy(auth_db, NULL);
if( chr->char_fd != -1 ) {
- do_close(chr->char_fd);
+ sockt->close(chr->char_fd);
chr->char_fd = -1;
}
@@ -5800,7 +5800,7 @@ void do_shutdown(void)
for( id = 0; id < ARRAYLENGTH(chr->server); ++id )
mapif->server_reset(id);
loginif->check_shutdown();
- flush_fifos();
+ sockt->flush_fifos();
runflag = CORE_ST_STOP;
}
}
@@ -5919,7 +5919,7 @@ int do_init(int argc, char **argv) {
if ((sockt->naddr_ != 0) && (!login_ip || !chr->ip)) {
char ip_str[16];
- ip2str(sockt->addr_[0], ip_str);
+ sockt->ip2str(sockt->addr_[0], ip_str);
if (sockt->naddr_ > 1)
ShowStatus("Multiple interfaces detected.. using %s as our IP address\n", ip_str);
@@ -5927,11 +5927,11 @@ int do_init(int argc, char **argv) {
ShowStatus("Defaulting to %s as our IP address\n", ip_str);
if (!login_ip) {
safestrncpy(login_ip_str, ip_str, sizeof(login_ip_str));
- login_ip = str2ip(login_ip_str);
+ login_ip = sockt->str2ip(login_ip_str);
}
if (!chr->ip) {
safestrncpy(char_ip_str, ip_str, sizeof(char_ip_str));
- chr->ip = str2ip(char_ip_str);
+ chr->ip = sockt->str2ip(char_ip_str);
}
}
@@ -5962,9 +5962,9 @@ int do_init(int argc, char **argv) {
if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '0' AND `account_id` = '0' AND `char_id` = '0'", guild_member_db) )
Sql_ShowDebug(inter->sql_handle);
- set_defaultparse(chr->parse_char);
+ sockt->set_defaultparse(chr->parse_char);
- if( (chr->char_fd = make_listen_bind(bind_ip,chr->port)) == -1 ) {
+ if ((chr->char_fd = sockt->make_listen_bind(bind_ip,chr->port)) == -1) {
ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",chr->port);
exit(EXIT_FAILURE);
}
diff --git a/src/char/inter.c b/src/char/inter.c
index dbb782093..eceb649f3 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -492,7 +492,7 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
nullpo_retv(last_ip);
nullpo_retv(lastlogin);
nullpo_retv(birthdate);
- if (map_fd <= 0 || !session_isActive(map_fd))
+ if (map_fd <= 0 || !sockt->session_is_active(map_fd))
return; // check if we have a valid fd
if (!success) {
@@ -511,7 +511,7 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc
}
inter->msg_to_fd(map_fd, u_fd, u_aid, "Account e-mail: %s | Birthdate: %s", email, birthdate);
- inter->msg_to_fd(map_fd, u_fd, u_aid, "Last IP: %s (%s)", last_ip, geoip->getcountry(str2ip(last_ip)));
+ inter->msg_to_fd(map_fd, u_fd, u_aid, "Last IP: %s (%s)", last_ip, geoip->getcountry(sockt->str2ip(last_ip)));
inter->msg_to_fd(map_fd, u_fd, u_aid, "This user has logged %d times, the last time were at %s", logincount, lastlogin);
inter->msg_to_fd(map_fd, u_fd, u_aid, "-- Character Details --");
@@ -557,7 +557,7 @@ void inter_savereg(int account_id, int char_id, const char *key, unsigned int in
nullpo_retv(key);
/* to login server we go! */
if( key[0] == '#' && key[1] == '#' ) {/* global account reg */
- if( session_isValid(chr->login_fd) )
+ if (sockt->session_is_valid(chr->login_fd))
chr->global_accreg_to_login_add(key,index,val,is_string);
else {
ShowError("Login server unavailable, cant perform update on '%s' variable for AID:%d CID:%d\n",key,account_id,char_id);
@@ -1170,7 +1170,7 @@ int mapif_parse_Registry(int fd)
if( count ) {
int cursor = 14, i;
char key[32], sval[254];
- bool isLoginActive = session_isActive(chr->login_fd);
+ bool isLoginActive = sockt->session_is_active(chr->login_fd);
if( isLoginActive )
chr->global_accreg_to_login_start(account_id,char_id);
diff --git a/src/char/loginif.c b/src/char/loginif.c
index 881c8f2ac..4eac78774 100644
--- a/src/char/loginif.c
+++ b/src/char/loginif.c
@@ -28,7 +28,7 @@ void loginif_reset(void)
// TODO kick everyone out and reset everything or wait for connect and try to reacquire locks [FlavioJS]
for( id = 0; id < ARRAYLENGTH(chr->server); ++id )
mapif->server_reset(id);
- flush_fifos();
+ sockt->flush_fifos();
exit(EXIT_FAILURE);
}
@@ -80,9 +80,8 @@ void do_init_loginif(void)
void do_final_loginif(void)
{
- if( chr->login_fd != -1 )
- {
- do_close(chr->login_fd);
+ if (chr->login_fd != -1) {
+ sockt->close(chr->login_fd);
chr->login_fd = -1;
}
}