summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorMadCamel <madcamel@gmail.com>2009-03-16 19:40:12 +0000
committerJared Adams <jaxad0127@gmail.com>2009-03-16 13:50:30 -0600
commitd450f9fd7b5d4fd71d4f7e244ef9d0786d0f745a (patch)
tree207f03c028ea16500032bde862d9ade38d317d06 /src/map
parent1f073198ce4a175191da2815c00cca11e81735d8 (diff)
downloadtmwa-d450f9fd7b5d4fd71d4f7e244ef9d0786d0f745a.tar.gz
tmwa-d450f9fd7b5d4fd71d4f7e244ef9d0786d0f745a.tar.bz2
tmwa-d450f9fd7b5d4fd71d4f7e244ef9d0786d0f745a.tar.xz
tmwa-d450f9fd7b5d4fd71d4f7e244ef9d0786d0f745a.zip
Now possible to divorce when partner is offline
Diffstat (limited to 'src/map')
-rw-r--r--src/map/chrif.c30
-rw-r--r--src/map/pc.c13
-rw-r--r--src/map/script.c3
3 files changed, 36 insertions, 10 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 4f8edf6..ef681b7 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -676,7 +676,9 @@ int chrif_accountreg2(int fd)
}
/*==========================================
- * 離婚情報同期要求
+ * Divorce request from char server
+ * triggered on account deletion or as an
+ * ack from a map-server divorce request
*------------------------------------------
*/
int chrif_divorce(int char_id, int partner_id)
@@ -686,12 +688,32 @@ int chrif_divorce(int char_id, int partner_id)
if (!char_id || !partner_id)
return 0;
- nullpo_retr(0, sd = map_nick2sd(map_charid2nick(partner_id)));
- if (sd->status.partner_id == char_id) {
- int i;
+
+ sd = map_nick2sd(map_charid2nick(char_id));
+ if (sd && sd->status.partner_id == partner_id) {
sd->status.partner_id = 0;
+ map_scriptcont(sd, sd->npc_id);
}
+ nullpo_retr(0, sd = map_nick2sd(map_charid2nick(partner_id)));
+ if (sd->status.partner_id == char_id)
+ sd->status.partner_id = 0;
+
+ return 0;
+}
+
+/*==========================================
+ * Tell character server someone is divorced
+ * Needed to divorce when partner is not connected to map server
+ *-------------------------------------
+ */
+int chrif_send_divorce(int char_id) {
+ if (char_fd < 0)
+ return -1;
+
+ WFIFOW(char_fd, 0) = 0x2b16;
+ WFIFOL(char_fd, 2) = char_id;
+ WFIFOSET(char_fd,6);
return 0;
}
diff --git a/src/map/pc.c b/src/map/pc.c
index b900bd0..8dfdf47 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -6687,18 +6687,19 @@ int pc_divorce(struct map_session_data *sd)
if(sd == NULL || !pc_ismarried(sd))
return -1;
- if( (p_sd=map_nick2sd(map_charid2nick(sd->status.partner_id))) !=NULL){
+ // If both are on map server we don't need to bother the char server
+ if( (p_sd=map_nick2sd(map_charid2nick(sd->status.partner_id))) !=NULL) {
if(p_sd->status.partner_id != sd->status.char_id || sd->status.partner_id != p_sd->status.char_id){
printf("pc_divorce: Illegal partner_id sd=%d p_sd=%d\n",sd->status.partner_id,p_sd->status.partner_id);
return -1;
}
- sd->status.partner_id=0;
p_sd->status.partner_id=0;
-
- }else{
- printf("pc_divorce: p_sd nullpo\n");
- return -1;
+ sd->status.partner_id=0;
+ map_scriptcont(sd, sd->npc_id);
}
+ else
+ chrif_send_divorce(sd->status.char_id);
+
return 0;
}
diff --git a/src/map/script.c b/src/map/script.c
index c5bcae1..287b4f6 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -5263,6 +5263,9 @@ int buildin_wedding_effect(struct script_state *st)
int buildin_divorce(struct script_state *st)
{
struct map_session_data *sd=script_rid2sd(st);
+
+ st->state=STOP; // rely on pc_divorce to restart
+
if(sd==NULL || pc_divorce(sd) < 0){
push_val(st->stack,C_INT,0);
return 0;