summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c14
-rw-r--r--src/map/chrif.c2
-rw-r--r--src/map/pc.c34
-rw-r--r--src/map/pc.h3
4 files changed, 38 insertions, 15 deletions
diff --git a/src/char/char.c b/src/char/char.c
index dcdab8d0a..310163e3a 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2849,8 +2849,7 @@ int parse_frommap(int fd)
Sql_ShowDebug(sql_handle);
break;
}
- if( SQL->NumRows(sql_handle) > 0 )
- {
+ if( SQL->NumRows(sql_handle) > 0 ) {
struct status_change_data scdata;
int count;
char* data;
@@ -2871,8 +2870,7 @@ int parse_frommap(int fd)
}
if (count >= 50)
ShowWarning("Too many status changes for %d:%d, some of them were not loaded.\n", aid, cid);
- if (count > 0)
- {
+ if (count > 0) {
WFIFOW(fd,2) = 14 + count*sizeof(struct status_change_data);
WFIFOW(fd,12) = count;
WFIFOSET(fd,WFIFOW(fd,2));
@@ -2881,6 +2879,14 @@ int parse_frommap(int fd)
if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) )
Sql_ShowDebug(sql_handle);
}
+ } else { //no sc (needs a response)
+ WFIFOHEAD(fd,14);
+ WFIFOW(fd,0) = 0x2b1d;
+ WFIFOW(fd,2) = 14;
+ WFIFOL(fd,4) = aid;
+ WFIFOL(fd,8) = cid;
+ WFIFOW(fd,12) = 0;
+ WFIFOSET(fd,WFIFOW(fd,2));
}
SQL->FreeResult(sql_handle);
#endif
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 4efc5bce4..a13217060 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -1212,6 +1212,8 @@ int chrif_load_scdata(int fd) {
data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data));
status->change_start(&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15);
}
+
+ pc->scdata_received(sd);
#endif
return 0;
diff --git a/src/map/pc.c b/src/map/pc.c
index f25dd8911..0244c6c84 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -443,7 +443,20 @@ int pc_inventory_rental_clear(struct map_session_data *sd)
return 1;
}
-
+/* assumes i is valid (from default areas where it is called, it is) */
+void pc_rental_expire(struct map_session_data *sd, int i) {
+ short nameid = sd->status.inventory[i].nameid;
+
+ /* Soon to be dropped, we got plans to integrate it with item db */
+ switch( nameid ) {
+ case ITEMID_REINS_OF_MOUNT:
+ status_change_end(&sd->bl,SC_ALL_RIDING,INVALID_TIMER);
+ break;
+ }
+
+ clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
+}
void pc_inventory_rentals(struct map_session_data *sd)
{
int i, c = 0;
@@ -457,12 +470,7 @@ void pc_inventory_rentals(struct map_session_data *sd)
continue;
if( sd->status.inventory[i].expire_time <= time(NULL) ) {
- if( sd->status.inventory[i].nameid == ITEMID_REINS_OF_MOUNT
- && sd->sc.data[SC_ALL_RIDING] ) {
- status_change_end(&sd->bl,SC_ALL_RIDING,INVALID_TIMER);
- }
- clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
- pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
+ pc->rental_expire(sd,i);
} else {
expire_tick = (int64)(sd->status.inventory[i].expire_time - time(NULL)) * 1000;
clif->rental_time(sd->fd, sd->status.inventory[i].nameid, (int)(expire_tick / 1000));
@@ -1269,8 +1277,6 @@ int pc_reg_received(struct map_session_data *sd)
clif->pLoadEndAck(sd->fd, sd);
}
- pc->inventory_rentals(sd);
-
if( sd->sc.option & OPTION_INVISIBLE ) {
sd->vd.class_ = INVISIBLE_CLASS;
clif->message(sd->fd, msg_txt(11)); // Invisible: On
@@ -3929,8 +3935,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
/* rental item check */
if( item_data->expire_time ) {
if( time(NULL) > item_data->expire_time ) {
- clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
- pc->delitem(sd, i, sd->status.inventory[i].amount, 1, 0, LOG_TYPE_OTHER);
+ pc->rental_expire(sd,i);
} else {
int seconds = (int)( item_data->expire_time - time(NULL) );
clif->rental_time(sd->fd, sd->status.inventory[i].nameid, seconds);
@@ -10132,6 +10137,10 @@ void pc_bank_withdraw(struct map_session_data *sd, int money) {
clif->bank_withdraw(sd,BWA_SUCCESS);
}
}
+/* status change data arrived from char-server */
+void pc_scdata_received(struct map_session_data *sd) {
+ pc->inventory_rentals(sd);
+}
/*==========================================
* pc Init/Terminate
@@ -10459,4 +10468,7 @@ void pc_defaults(void) {
pc->bank_withdraw = pc_bank_withdraw;
pc->bank_deposit = pc_bank_deposit;
+
+ pc->rental_expire = pc_rental_expire;
+ pc->scdata_received = pc_scdata_received;
}
diff --git a/src/map/pc.h b/src/map/pc.h
index fdcf395a7..14e1da5f4 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -978,6 +978,9 @@ struct pc_interface {
void (*bank_deposit) (struct map_session_data *sd, int money);
void (*bank_withdraw) (struct map_session_data *sd, int money);
+
+ void (*rental_expire) (struct map_session_data *sd, int i);
+ void (*scdata_received) (struct map_session_data *sd);
};
struct pc_interface *pc;