summaryrefslogtreecommitdiff
path: root/src/map/chrif.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/chrif.c')
-rw-r--r--src/map/chrif.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index ee2e252c1..8a70b4931 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -53,11 +53,11 @@ static const int packet_len_table[0x3d] = { // U - used, F - free
//2af9: Incoming, chrif_connectack -> 'answer of the 2af8 login(ok / fail)'
//2afa: Outgoing, chrif_sendmap -> 'sending our maps'
//2afb: Incoming, chrif_sendmapack -> 'Maps received successfully / or not ..'
-//2afc: Outgoing, chrif_scdata_request -> request sc_data for pc_authok'ed char. <- new command reuses previous one.
+//2afc: Outgoing, chrif_scdata_request -> request sc_data for iPc->authok'ed char. <- new command reuses previous one.
//2afd: Incoming, chrif_authok -> 'client authentication ok'
//2afe: Outgoing, send_usercount_tochar -> 'sends player count of this map server to charserver'
//2aff: Outgoing, send_users_tochar -> 'sends all actual connected character ids to charserver'
-//2b00: Incoming, map_setusers -> 'set the actual usercount? PACKET.2B COUNT.L.. ?' (not sure)
+//2b00: Incoming, iMap->setusers -> 'set the actual usercount? PACKET.2B COUNT.L.. ?' (not sure)
//2b01: Outgoing, chrif_save -> 'charsave of char XY account XY (complete struct)'
//2b02: Outgoing, chrif_charselectreq -> 'player returns from ingame to charserver to select another char.., this packets includes sessid etc' ? (not 100% sure)
//2b03: Incoming, clif_charselectok -> '' (i think its the packet after enterworld?) (not sure)
@@ -185,7 +185,7 @@ static bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) {
node->sex = sd->status.sex;
node->fd = sd->fd;
node->sd = sd; //Data from logged on char.
- node->node_created = gettick(); //timestamp for node timeouts
+ node->node_created = iTimer->gettick(); //timestamp for node timeouts
node->state = state;
sd->state.active = 0;
@@ -272,7 +272,7 @@ int chrif_isconnected(void) {
int chrif_save(struct map_session_data *sd, int flag) {
nullpo_retr(-1, sd);
- pc_makesavestatus(sd);
+ iPc->makesavestatus(sd);
if (flag && sd->state.active) { //Store player data which is quitting
//FIXME: SC are lost if there's no connection at save-time because of the way its related data is cleared immediately after this function. [Skotlex]
@@ -361,7 +361,7 @@ int chrif_recvmap(int fd) {
uint16 port = ntohs(RFIFOW(fd,8));
for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) {
- map_setipport(RFIFOW(fd,i), ip, port);
+ iMap->setipport(RFIFOW(fd,i), ip, port);
}
if (battle_config.etc_log)
@@ -379,7 +379,7 @@ int chrif_removemap(int fd) {
uint16 port = RFIFOW(fd,8);
for(i = 10, j = 0; i < RFIFOW(fd, 2); i += 4, j++)
- map_eraseipport(RFIFOW(fd, i), ip, port);
+ iMap->eraseipport(RFIFOW(fd, i), ip, port);
other_mapserver_count--;
@@ -479,12 +479,12 @@ int chrif_connectack(int fd) {
* @see DBApply
*/
static int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
- struct auth_node *node = DB->data2ptr(data);
+ struct auth_node *node = iDB->data2ptr(data);
switch (node->state) {
case ST_LOGIN:
if ( node->sd && node->char_dat == NULL ) {//Since there is no way to request the char auth, make it fail.
- pc_authfail(node->sd);
+ iPc->authfail(node->sd);
chrif_char_offline(node->sd);
chrif_auth_delete(node->account_id, node->char_id, ST_LOGIN);
}
@@ -498,7 +498,7 @@ static int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
uint32 ip;
uint16 port;
- if( map_mapname2ipport(sd->mapindex,&ip,&port) == 0 )
+ if( iMap->mapname2ipport(sd->mapindex,&ip,&port) == 0 )
chrif_changemapserver(sd, ip, port);
else //too much lag/timeout is the closest explanation for this error.
clif->authfail_fd(sd->fd, 3);
@@ -543,7 +543,7 @@ int chrif_sendmapack(int fd) {
exit(EXIT_FAILURE);
}
- memcpy(wisp_server_name, RFIFOP(fd,3), NAME_LENGTH);
+ memcpy(iMap->wisp_server_name, RFIFOP(fd,3), NAME_LENGTH);
chrif_on_ready();
@@ -619,7 +619,7 @@ void chrif_authok(int fd) {
//Check if we don't already have player data in our server
//Causes problems if the currently connected player tries to quit or this data belongs to an already connected player which is trying to re-auth.
- if ( ( sd = map_id2sd(account_id) ) != NULL )
+ if ( ( sd = iMap->id2sd(account_id) ) != NULL )
return;
if ( ( node = chrif_search(account_id) ) == NULL )
@@ -645,10 +645,10 @@ void chrif_authok(int fd) {
node->char_id == char_id &&
node->login_id1 == login_id1 )
{ //Auth Ok
- if (pc_authok(sd, login_id2, expiration_time, group_id, status, changing_mapservers))
+ if (iPc->authok(sd, login_id2, expiration_time, group_id, status, changing_mapservers))
return;
} else { //Auth Failed
- pc_authfail(sd);
+ iPc->authfail(sd);
}
chrif_char_offline(sd); //Set him offline, the char server likely has it set as online already.
@@ -687,14 +687,14 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
* @see DBApply
*/
int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
- struct auth_node *node = DB->data2ptr(data);
+ struct auth_node *node = iDB->data2ptr(data);
const char* states[] = { "Login", "Logout", "Map change" };
- if(DIFF_TICK(gettick(),node->node_created)>60000) {
+ if(DIFF_TICK(iTimer->gettick(),node->node_created)>60000) {
switch (node->state) {
case ST_LOGOUT:
//Re-save attempt (->sd should never be null here).
- node->node_created = gettick(); //Refresh tick (avoid char-server load if connection is really bad)
+ node->node_created = iTimer->gettick(); //Refresh tick (avoid char-server load if connection is really bad)
chrif_save(node->sd, 1);
break;
default:
@@ -819,7 +819,7 @@ int chrif_changesex(struct map_session_data *sd) {
if (sd->fd)
clif->authfail_fd(sd->fd, 15);
else
- map_quit(sd);
+ iMap->quit(sd);
return 0;
}
@@ -839,7 +839,7 @@ static void chrif_char_ask_name_answer(int acc, const char* player_name, uint16
char action[25];
char output[256];
- sd = map_id2sd(acc);
+ sd = iMap->id2sd(acc);
if( acc < 0 || sd == NULL ) {
ShowError("chrif_char_ask_name_answer failed - player not online.\n");
@@ -875,7 +875,7 @@ int chrif_changedsex(int fd) {
if ( battle_config.etc_log )
ShowNotice("chrif_changedsex %d.\n", acc);
- sd = map_id2sd(acc);
+ sd = iMap->id2sd(acc);
if ( sd ) { //Normally there should not be a char logged on right now!
if ( sd->status.sex == sex )
return 0; //Do nothing? Likely safe.
@@ -915,7 +915,7 @@ int chrif_changedsex(int fd) {
// do same modify in login-server for the account, but no in char-server (it ask again login_id1 to login, and don't remember it)
clif->message(sd->fd, msg_txt(409)); //"Your sex has been changed (need disconnection by the server)..."
set_eof(sd->fd); // forced to disconnect for the change
- map_quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
+ iMap->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
}
return 0;
}
@@ -945,18 +945,18 @@ int chrif_divorceack(int char_id, int partner_id) {
if( !char_id || !partner_id )
return 0;
- if( ( sd = map_charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) {
+ if( ( sd = iMap->charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) {
sd->status.partner_id = 0;
for(i = 0; i < MAX_INVENTORY; i++)
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
- pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
+ iPc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
}
- if( ( sd = map_charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) {
+ if( ( sd = iMap->charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) {
sd->status.partner_id = 0;
for(i = 0; i < MAX_INVENTORY; i++)
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
- pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
+ iPc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
}
return 0;
@@ -968,7 +968,7 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) {
struct map_session_data* sd;
int idx = skill->get_index(WE_CALLBABY);
- if( father_id && ( sd = map_charid2sd(father_id) ) != NULL && sd->status.child == child_id ) {
+ if( father_id && ( sd = iMap->charid2sd(father_id) ) != NULL && sd->status.child == child_id ) {
sd->status.child = 0;
sd->status.skill[idx].id = 0;
sd->status.skill[idx].lv = 0;
@@ -976,7 +976,7 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) {
clif->deleteskill(sd,WE_CALLBABY);
}
- if( mother_id && ( sd = map_charid2sd(mother_id) ) != NULL && sd->status.child == child_id ) {
+ if( mother_id && ( sd = iMap->charid2sd(mother_id) ) != NULL && sd->status.child == child_id ) {
sd->status.child = 0;
sd->status.skill[idx].id = 0;
sd->status.skill[idx].lv = 0;
@@ -999,7 +999,7 @@ int chrif_accountban(int fd) {
if ( battle_config.etc_log )
ShowNotice("chrif_accountban %d.\n", acc);
- sd = map_id2sd(acc);
+ sd = iMap->id2sd(acc);
if ( acc < 0 || sd == NULL ) {
ShowError("chrif_accountban failed - player not online.\n");
@@ -1025,7 +1025,7 @@ int chrif_accountban(int fd) {
}
set_eof(sd->fd); // forced to disconnect for the change
- map_quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
+ iMap->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
return 0;
}
@@ -1035,7 +1035,7 @@ int chrif_disconnectplayer(int fd) {
struct map_session_data* sd;
int account_id = RFIFOL(fd, 2);
- sd = map_id2sd(account_id);
+ sd = iMap->id2sd(account_id);
if( sd == NULL ) {
struct auth_node* auth = chrif_search(account_id);
@@ -1047,7 +1047,7 @@ int chrif_disconnectplayer(int fd) {
if (!sd->fd) { //No connection
if (sd->state.autotrade)
- map_quit(sd); //Remove it.
+ iMap->quit(sd); //Remove it.
//Else we don't remove it because the char should have a timer to remove the player because it force-quit before,
//and we don't want them kicking their previous instance before the 10 secs penalty time passes. [Skotlex]
return 0;
@@ -1172,7 +1172,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the
const struct TimerData *timer;
chrif_check(-1);
- tick = gettick();
+ tick = iTimer->gettick();
WFIFOHEAD(char_fd, 14 + SC_MAX*sizeof(struct status_change_data));
WFIFOW(char_fd,0) = 0x2b1c;
@@ -1183,7 +1183,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the
if (!sc->data[i])
continue;
if (sc->data[i]->timer != INVALID_TIMER) {
- timer = get_timer(sc->data[i]->timer);
+ timer = iTimer->get_timer(sc->data[i]->timer);
if (timer == NULL || timer->func != status_change_timer || DIFF_TICK(timer->tick,tick) < 0)
continue;
data.tick = DIFF_TICK(timer->tick,tick); //Duration that is left before ending.
@@ -1221,7 +1221,7 @@ int chrif_load_scdata(int fd) {
aid = RFIFOL(fd,4); //Player Account ID
cid = RFIFOL(fd,8); //Player Char ID
- sd = map_id2sd(aid);
+ sd = iMap->id2sd(aid);
if ( !sd ) {
ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid);
@@ -1338,10 +1338,10 @@ void chrif_on_disconnect(void) {
chrif_connected = 0;
other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect.
- map_eraseallipport();
+ iMap->eraseallipport();
//Attempt to reconnect in a second. [Skotlex]
- add_timer(gettick() + 1000, check_connect_char_server, 0, 0);
+ iTimer->add_timer(iTimer->gettick() + 1000, check_connect_char_server, 0, 0);
}
@@ -1448,11 +1448,11 @@ int chrif_parse(int fd) {
case 0x2af9: chrif_connectack(fd); break;
case 0x2afb: chrif_sendmapack(fd); break;
case 0x2afd: chrif_authok(fd); break;
- case 0x2b00: map_setusers(RFIFOL(fd,2)); chrif_keepalive(fd); break;
+ case 0x2b00: iMap->setusers(RFIFOL(fd,2)); chrif_keepalive(fd); break;
case 0x2b03: clif->charselectok(RFIFOL(fd,2), RFIFOB(fd,6)); break;
case 0x2b04: chrif_recvmap(fd); break;
case 0x2b06: chrif_changemapserverack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOW(fd,18), RFIFOW(fd,20), RFIFOW(fd,22), RFIFOL(fd,24), RFIFOW(fd,28)); break;
- case 0x2b09: map_addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break;
+ case 0x2b09: iMap->addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break;
case 0x2b0a: socket_datasync(fd, false); break;
case 0x2b0d: chrif_changedsex(fd); break;
case 0x2b0f: chrif_char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break;
@@ -1486,7 +1486,7 @@ int send_usercount_tochar(int tid, unsigned int tick, int id, intptr_t data) {
WFIFOHEAD(char_fd,4);
WFIFOW(char_fd,0) = 0x2afe;
- WFIFOW(char_fd,2) = map_usercount();
+ WFIFOW(char_fd,2) = iMap->usercount();
WFIFOSET(char_fd,4);
return 0;
}
@@ -1502,7 +1502,7 @@ int send_users_tochar(void) {
chrif_check(-1);
- users = map_usercount();
+ users = iMap->usercount();
WFIFOHEAD(char_fd, 6+8*users);
WFIFOW(char_fd,0) = 0x2aff;
@@ -1595,7 +1595,7 @@ void chrif_send_report(char* buf, int len) {
* @see DBApply
*/
int auth_db_final(DBKey key, DBData *data, va_list ap) {
- struct auth_node *node = DB->data2ptr(data);
+ struct auth_node *node = iDB->data2ptr(data);
if (node->char_dat)
aFree(node->char_dat);
@@ -1633,17 +1633,17 @@ int do_init_chrif(void) {
auth_db = idb_alloc(DB_OPT_BASE);
auth_db_ers = ers_new(sizeof(struct auth_node),"chrif.c::auth_db_ers",ERS_OPT_NONE);
- add_timer_func_list(check_connect_char_server, "check_connect_char_server");
- add_timer_func_list(auth_db_cleanup, "auth_db_cleanup");
+ iTimer->add_timer_func_list(check_connect_char_server, "check_connect_char_server");
+ iTimer->add_timer_func_list(auth_db_cleanup, "auth_db_cleanup");
// establish map-char connection if not present
- add_timer_interval(gettick() + 1000, check_connect_char_server, 0, 0, 10 * 1000);
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, check_connect_char_server, 0, 0, 10 * 1000);
// wipe stale data for timed-out client connection requests
- add_timer_interval(gettick() + 1000, auth_db_cleanup, 0, 0, 30 * 1000);
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, auth_db_cleanup, 0, 0, 30 * 1000);
// send the user count every 10 seconds, to hide the charserver's online counting problem
- add_timer_interval(gettick() + 1000, send_usercount_tochar, 0, 0, UPDATE_INTERVAL);
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, send_usercount_tochar, 0, 0, UPDATE_INTERVAL);
return 0;
}