summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 782446c42..a06f1c474 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -6668,34 +6668,46 @@ int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd)
}
/*==========================================
- * sd‚ª—£¥(‘ŠŽè‚Ísd->status.partner_id‚Ɉ˂é)(‘ŠŽè‚à“¯ŽbÉ—£¥?Œ‹¥Žw—ÖŽ©“®?’D)
+ * Divorce sd from its partner
*------------------------------------------*/
int pc_divorce(struct map_session_data *sd)
{
struct map_session_data *p_sd;
+ int i;
+
if (sd == NULL || !pc_ismarried(sd))
return -1;
- if ((p_sd = map_charid2sd(sd->status.partner_id)) != NULL) {
- int i;
- if (p_sd->status.partner_id != sd->status.char_id || sd->status.partner_id != p_sd->status.char_id) {
- ShowWarning("pc_divorce: Illegal partner_id sd=%d p_sd=%d\n", sd->status.partner_id, p_sd->status.partner_id);
+ if( !sd->status.partner_id )
+ return -1; // Char is not married
+
+ if( (p_sd = map_charid2sd(sd->status.partner_id)) == NULL )
+ { // Lets char server do the divorce
+#ifndef TXT_ONLY
+ if( chrif_divorce(sd->status.char_id, sd->status.partner_id) )
+ return -1; // No char server connected
+
+ return 0;
+#else
+ ShowError("pc_divorce: p_sd nullpo\n");
return -1;
+#endif
}
+
+ // Both players online, lets do the divorce manually
sd->status.partner_id = 0;
p_sd->status.partner_id = 0;
- for (i = 0; i < MAX_INVENTORY; i++) {
+ 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);
if (p_sd->status.inventory[i].nameid == WEDDING_RING_M || p_sd->status.inventory[i].nameid == WEDDING_RING_F)
pc_delitem(p_sd, i, 1, 0);
}
+
clif_divorced(sd, p_sd->status.name);
clif_divorced(p_sd, sd->status.name);
- } else {
- ShowError("pc_divorce: p_sd nullpo\n");
- return -1;
- }
+
return 0;
}