summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/atcommand.c27
-rw-r--r--src/map/clif.c32
-rw-r--r--src/map/clif.h1
-rw-r--r--src/map/pc.c25
-rw-r--r--src/map/pc.h1
-rw-r--r--src/map/script.c2
6 files changed, 58 insertions, 30 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index f36d5b8a6..9c14f3dbd 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -4845,7 +4845,7 @@ ACMD(undisguise)
{
nullpo_retr(-1, sd);
if (sd->disguise) {
- pc_disguise(sd, 0);
+ pc_disguise(sd, -1);
clif->message(fd, msg_txt(124)); // Undisguise applied.
} else {
clif->message(fd, msg_txt(125)); // You're not disguised.
@@ -4858,8 +4858,7 @@ ACMD(undisguise)
/*==========================================
* UndisguiseAll
*------------------------------------------*/
-ACMD(undisguiseall)
-{
+ACMD(undisguiseall) {
struct map_session_data *pl_sd;
struct s_mapiterator* iter;
nullpo_retr(-1, sd);
@@ -4867,7 +4866,7 @@ ACMD(undisguiseall)
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
if( pl_sd->disguise )
- pc_disguise(pl_sd, 0);
+ pc_disguise(pl_sd, -1);
mapit_free(iter);
clif->message(fd, msg_txt(124)); // Undisguise applied.
@@ -4900,7 +4899,7 @@ ACMD(undisguiseguild)
for(i = 0; i < g->max_member; i++)
if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
- pc_disguise(pl_sd, 0);
+ pc_disguise(pl_sd, -1);
clif->message(fd, msg_txt(124)); // Undisguise applied.
@@ -9340,11 +9339,11 @@ ACMD(channel) {
/* debug only, delete after */
ACMD(fontcolor) {
unsigned char k;
-
+ unsigned short msg_len = 1;
+ char mout[40];
+
if( !message || !*message ) {
- char mout[40];
for( k = 0; k < hChSys.colors_count; k++ ) {
- unsigned short msg_len = 1;
msg_len += sprintf(mout, "[ %s ] : %s",command,hChSys.colors_name[k]);
WFIFOHEAD(fd,msg_len + 12);
@@ -9360,7 +9359,6 @@ ACMD(fontcolor) {
if( message[0] == '0' ) {
sd->fontcolor = 0;
- pc_disguise(sd,0);
return true;
}
@@ -9375,8 +9373,15 @@ ACMD(fontcolor) {
}
sd->fontcolor = k + 1;
- pc_disguise(sd,sd->status.class_);
-
+ msg_len += sprintf(mout, "Color changed to '%s'",hChSys.colors_name[k]);
+
+ WFIFOHEAD(fd,msg_len + 12);
+ WFIFOW(fd,0) = 0x2C1;
+ WFIFOW(fd,2) = msg_len + 12;
+ WFIFOL(fd,4) = 0;
+ WFIFOL(fd,8) = hChSys.colors[k];
+ safestrncpy((char*)WFIFOP(fd,12), mout, msg_len);
+ WFIFOSET(fd, msg_len + 12);
return true;
}
ACMD(searchstore){
diff --git a/src/map/clif.c b/src/map/clif.c
index 251dc98c4..9b9780a05 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -150,7 +150,7 @@ static inline void RFIFOPOS2(int fd, unsigned short pos, short* x0, short* y0, s
//To idenfity disguised characters.
static inline bool disguised(struct block_list* bl) {
- return (bool)( bl->type == BL_PC && ((TBL_PC*)bl)->disguise );
+ return (bool)( bl->type == BL_PC && ((TBL_PC*)bl)->disguise != -1 );
}
@@ -5751,7 +5751,7 @@ void clif_resurrection(struct block_list *bl,int type)
unsigned char buf[16];
nullpo_retv(bl);
-
+
WBUFW(buf,0)=0x148;
WBUFL(buf,2)=bl->id;
WBUFW(buf,6)=0;
@@ -8494,7 +8494,7 @@ void clif_refresh(struct map_session_data *sd)
if( disguised(&sd->bl) ) {/* refresh-da */
short disguise = sd->disguise;
- pc_disguise(sd, 0);
+ pc_disguise(sd, -1);
pc_disguise(sd, disguise);
}
@@ -9794,7 +9794,14 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd)
clif->charnameack(fd, bl);
}
-
+int clif_undisguise_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ struct map_session_data * sd;
+ if( (sd = map_id2sd(id)) && sd->fontcolor && sd->disguise == sd->status.class_ ) {
+ pc_disguise(sd,-1);
+ }
+ sd->fontcolor_tid = INVALID_TIMER;
+ return 0;
+}
/// Validates and processes global messages
/// 008c <packet len>.W <text>.?B (<name> : <message>) 00 (CZ_REQUEST_CHAT)
@@ -9831,6 +9838,18 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
} else if ( sd->fontcolor && !sd->chatID ) {
char mout[200];
unsigned char mylen = 1;
+ ShowDebug("Hi1:%d\n",sd->disguise);
+
+ if( sd->disguise == -1 ) {
+ pc_disguise(sd,sd->status.class_);
+ ShowDebug("Hi2:%d\n",sd->disguise);
+ sd->fontcolor_tid = add_timer(gettick()+5000, clif->undisguise_timer, sd->bl.id, 0);
+ } else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) {
+ const struct TimerData *timer;
+ if( (timer = get_timer(sd->fontcolor_tid)) ) {
+ settick_timer(sd->fontcolor_tid, timer->tick+5000);
+ }
+ }
mylen += snprintf(mout, 200, "%s : %s",sd->fakename[0]?sd->fakename:sd->status.name,message);
@@ -9845,7 +9864,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
WFIFOSET(fd, mylen + 12);
return;
}
-
+
/**
* Fake Name Design by FatalEror (bug report #9)
**/
@@ -10341,7 +10360,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
struct guild *g = sd->guild, *sg = NULL;
int k;
for (k = 0; k < MAX_GUILDALLIANCE; k++) {
- if( g->alliance[i].opposition == 0 && g->alliance[i].guild_id && (sg = guild_search(g->alliance[i].guild_id) ) ) {
+ if( g->alliance[k].opposition == 0 && g->alliance[k].guild_id && (sg = guild_search(g->alliance[k].guild_id) ) ) {
if( !(((struct hChSysCh*)sg->channel)->banned && idb_exists(((struct hChSysCh*)sg->channel)->banned, sd->status.account_id)))
clif->chsys_join((struct hChSysCh *)sg->channel,sd);
}
@@ -17553,6 +17572,7 @@ void clif_defaults(void) {
clif->chsys_gleave = clif_hercules_chsys_gleave;
clif->cashshop_load = clif_cashshop_db;
clif->bc_ready = clif_bc_ready;
+ clif->undisguise_timer = clif_undisguise_timer;
/*------------------------
*- Parse Incoming Packet
*------------------------*/
diff --git a/src/map/clif.h b/src/map/clif.h
index 8abbe8a03..8c1147ceb 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -879,6 +879,7 @@ struct clif_interface {
void (*chsys_gjoin) (struct guild *g1,struct guild *g2);
void (*chsys_gleave) (struct guild *g1,struct guild *g2);
void (*bc_ready) (void);
+ int (*undisguise_timer) (int tid, unsigned int tick, int id, intptr_t data);
/*------------------------
*- Parse Incoming Packet
*------------------------*/
diff --git a/src/map/pc.c b/src/map/pc.c
index 191a9a6d7..191c05bcd 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -958,6 +958,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
sd->invincible_timer = INVALID_TIMER;
sd->npc_timer_id = INVALID_TIMER;
sd->pvp_timer = INVALID_TIMER;
+ sd->fontcolor_tid = INVALID_TIMER;
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
**/
@@ -1015,6 +1016,8 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
sd->guild_x = -1;
sd->guild_y = -1;
+ sd->disguise = -1;
+
// Event Timers
for( i = 0; i < MAX_EVENTTIMER; i++ )
sd->eventtimer[i] = INVALID_TIMER;
@@ -1637,15 +1640,13 @@ int pc_updateweightstatus(struct map_session_data *sd)
return 0;
}
-int pc_disguise(struct map_session_data *sd, int class_)
-{
- if (!class_ && !sd->disguise)
+int pc_disguise(struct map_session_data *sd, int class_) {
+ if (class_ == -1 && sd->disguise == -1)
return 0;
- if (class_ && sd->disguise == class_)
+ if (class_ >= 0 && sd->disguise == class_)
return 0;
- if(sd->sc.option&OPTION_INVISIBLE)
- { //Character is invisible. Stealth class-change. [Skotlex]
+ if(sd->sc.option&OPTION_INVISIBLE) { //Character is invisible. Stealth class-change. [Skotlex]
sd->disguise = class_; //viewdata is set on uncloaking.
return 2;
}
@@ -1655,19 +1656,19 @@ int pc_disguise(struct map_session_data *sd, int class_)
clif->clearunit_area(&sd->bl, CLR_OUTSIGHT);
}
- if (!class_) {
- sd->disguise = 0;
+ if (class_ == -1) {
+ sd->disguise = -1;
class_ = sd->status.class_;
} else
- sd->disguise=class_;
+ sd->disguise = class_;
status_set_viewdata(&sd->bl, class_);
clif->changeoption(&sd->bl);
if (sd->bl.prev != NULL) {
clif->spawn(&sd->bl);
- if (class_ == sd->status.class_ && pc_iscarton(sd))
- { //It seems the cart info is lost on undisguise.
+ if (class_ == sd->status.class_ && pc_iscarton(sd)) {
+ //It seems the cart info is lost on undisguise.
clif->cartlist(sd);
clif->updatestatus(sd,SP_CARTINFO);
}
@@ -7453,7 +7454,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
//Change look, if disguised, you need to undisguise
//to correctly calculate new job sprite without
if (sd->disguise)
- pc_disguise(sd, 0);
+ pc_disguise(sd, -1);
status_set_viewdata(&sd->bl, job);
clif->changelook(&sd->bl,LOOK_BASE,sd->vd.class_); // move sprite update to prevent client crashes with incompatible equipment [Valaris]
diff --git a/src/map/pc.h b/src/map/pc.h
index 10891f6b4..5eec607db 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -512,6 +512,7 @@ struct map_session_data {
struct hChSysCh *gcbind;
bool stealth;
unsigned char fontcolor;
+ unsigned int fontcolor_tid;
unsigned int hchsysch_tick;
/* [Ind/Hercules] */
diff --git a/src/map/script.c b/src/map/script.c
index 9d9800a32..2304a9f42 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -11788,7 +11788,7 @@ BUILDIN(undisguise)
if (sd == NULL) return true;
if (sd->disguise) {
- pc_disguise(sd, 0);
+ pc_disguise(sd, -1);
script_pushint(st,0);
} else {
script_pushint(st,1);