summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaruna <haru@dotalux.com>2014-12-26 21:10:41 +0100
committerHaruna <haru@dotalux.com>2014-12-26 21:10:41 +0100
commitc564291bf3f2666f709beeecad24de7d95fdf558 (patch)
treebec5166f62872cc0ec07e2615bf730eb966a589f /src
parent0de8d96761e4cc4dd8122c06e8ae0ddf5686a943 (diff)
parent14d0fb868e86c676cdf70dfacaf33d4330d5f011 (diff)
downloadhercules-c564291bf3f2666f709beeecad24de7d95fdf558.tar.gz
hercules-c564291bf3f2666f709beeecad24de7d95fdf558.tar.bz2
hercules-c564291bf3f2666f709beeecad24de7d95fdf558.tar.xz
hercules-c564291bf3f2666f709beeecad24de7d95fdf558.zip
Merge pull request #419 from 4144/charsex
Add script command for change per char gender
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c22
-rw-r--r--src/map/script.c45
2 files changed, 54 insertions, 13 deletions
diff --git a/src/char/char.c b/src/char/char.c
index b18beed60..698832bfb 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -453,16 +453,31 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
(p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) ||
(p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) ||
(p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) ||
- (p->uniqueitem_counter != cp->uniqueitem_counter )
+ (p->uniqueitem_counter != cp->uniqueitem_counter ) || (p->sex != cp->sex)
) {
//Save status
unsigned int opt = 0;
+ char sex;
if( p->allow_party )
opt |= OPT_ALLOW_PARTY;
if( p->show_equip )
opt |= OPT_SHOW_EQUIP;
+ switch (p->sex)
+ {
+ case 0:
+ sex = 'F';
+ break;
+ case 1:
+ sex = 'M';
+ break;
+ case 99:
+ default:
+ sex = 'U';
+ break;
+ }
+
if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d',"
"`base_exp`='%u', `job_exp`='%u', `zeny`='%d',"
"`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d',"
@@ -470,7 +485,8 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
"`option`='%d',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d',`elemental_id`='%d',"
"`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d',"
"`last_map`='%s',`last_x`='%d',`last_y`='%d',`save_map`='%s',`save_x`='%d',`save_y`='%d', `rename`='%d',"
- "`delete_date`='%lu',`robe`='%d',`slotchange`='%d', `char_opt`='%u', `font`='%u', `uniqueitem_counter` ='%u'"
+ "`delete_date`='%lu',`robe`='%d',`slotchange`='%d', `char_opt`='%u', `font`='%u', `uniqueitem_counter` ='%u',"
+ " sex = '%c'"
" WHERE `account_id`='%d' AND `char_id` = '%d'",
char_db, p->base_level, p->job_level,
p->base_exp, p->job_exp, p->zeny,
@@ -481,7 +497,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y,
mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename,
(unsigned long)p->delete_date, // FIXME: platform-dependent size
- p->robe,p->slotchange,opt,p->font,p->uniqueitem_counter,
+ p->robe,p->slotchange,opt,p->font,p->uniqueitem_counter, sex,
p->account_id, p->char_id) )
{
Sql_ShowDebug(inter->sql_handle);
diff --git a/src/map/script.c b/src/map/script.c
index c7b1ae849..031dfc21b 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10639,27 +10639,51 @@ BUILDIN(changebase) {
return true;
}
+static TBL_PC *prepareChangeSex(struct script_state* st)
+{
+ int i;
+ TBL_PC *sd = script->rid2sd(st);
+
+ if (sd == NULL)
+ return NULL;
+
+ pc->resetskill(sd, 4);
+ // to avoid any problem with equipment and invalid sex, equipment is unequiped.
+ for (i=0; i<EQI_MAX; i++)
+ if (sd->equip_index[i] >= 0) pc->unequipitem(sd, sd->equip_index[i], 3);
+ return sd;
+}
+
/*==========================================
* Unequip all item and request for a changesex to char-serv
*------------------------------------------*/
BUILDIN(changesex)
{
- int i;
- TBL_PC *sd = NULL;
- sd = script->rid2sd(st);
-
- if( sd == NULL )
+ TBL_PC *sd = prepareChangeSex(st);
+ if (sd == NULL)
return false;
-
- pc->resetskill(sd,4);
- // to avoid any problem with equipment and invalid sex, equipment is unequiped.
- for( i=0; i<EQI_MAX; i++ )
- if( sd->equip_index[i] >= 0 ) pc->unequipitem(sd, sd->equip_index[i], 3);
chrif->changesex(sd);
return true;
}
/*==========================================
+ * Unequip all items and change character sex [4144]
+ *------------------------------------------*/
+BUILDIN(changecharsex)
+{
+ TBL_PC *sd = prepareChangeSex(st);
+ if (sd == NULL)
+ return false;
+ if (sd->status.sex == 99)
+ sd->status.sex = 0;
+ sd->status.sex = sd->status.sex ? 0 : 1;
+ chrif->save(sd, 0);
+ if (sd->fd)
+ clif->authfail_fd(sd->fd, 15);
+ return true;
+}
+
+/*==========================================
* Works like 'announce' but outputs in the common chat window
*------------------------------------------*/
BUILDIN(globalmes) {
@@ -19302,6 +19326,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(skillpointcount,""),
BUILDIN_DEF(changebase,"i?"),
BUILDIN_DEF(changesex,""),
+ BUILDIN_DEF(changecharsex,""), // [4144]
BUILDIN_DEF(waitingroom,"si?????"),
BUILDIN_DEF(delwaitingroom,"?"),
BUILDIN_DEF2(waitingroomkickall,"kickwaitingroomall","?"),