diff --git a/conf/channels.conf b/conf/channels.conf index e2d35e39de..245edf6448 100644 --- a/conf/channels.conf +++ b/conf/channels.conf @@ -22,13 +22,16 @@ chsys: ( Yellow: "0xffff90" Green: "0x28bf00" Normal: "0x00ff00" - /* Add as many channels as you'd like. */ + /* Add as many colors as you'd like. */ } /* Allow users to create their own (private) channels through @channels command? */ /* (must also allow players to use @channels in groups.conf) */ allow_user_channel_creation: true + /* Allow users to override a Non-Default channel color (@fontcolor) */ + allow_user_color_override: false + /* "map_local_channel" is an instanced channel unique to each map. */ map_local_channel: true map_local_channel_name: "map" diff --git a/src/char/char.c b/src/char/char.c index d1c45721ac..05b087169a 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1673,8 +1673,7 @@ int delete_char_sql(int char_id) Sql_GetData(sql_handle, 6, &data, NULL); partner_id = atoi(data); Sql_GetData(sql_handle, 7, &data, NULL); father_id = atoi(data); Sql_GetData(sql_handle, 8, &data, NULL); mother_id = atoi(data); - Sql_GetData(sql_handle, 9, &data, NULL); - elemental_id = atoi(data); + Sql_GetData(sql_handle, 9, &data, NULL); elemental_id = atoi(data); Sql_EscapeStringLen(sql_handle, esc_name, name, min(len, NAME_LENGTH)); Sql_FreeResult(sql_handle); diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 68b5880877..78852420ef 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -141,7 +141,7 @@ void inter_storage_sql_final(void) return; } -// q?f[^? +// Delete char storage int inter_storage_delete(int account_id) { if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) ) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index c121c3faba..de864caaa2 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -3726,10 +3726,18 @@ ACMD_FUNC(reloadmotd) *------------------------------------------*/ ACMD_FUNC(reloadscript) { + struct s_mapiterator* iter; + struct map_session_data* pl_sd; + nullpo_retr(-1, sd); //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." ); //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" ); + iter = mapit_getallusers(); + for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) + pc_close_npc(pl_sd,2); + mapit_free(iter); + flush_fifos(); map_reloadnpc(true); // reload config files seeking for npcs script_reload(); @@ -8926,22 +8934,18 @@ ACMD_FUNC(fontcolor) return -1; } - if( message[0] == '0' ) { + if( message[0] == '0' ) sd->fontcolor = 0; - pc_disguise(sd,0); - return 0; + else { + ARR_FIND(0,Channel_Config.colors_count,k,( strcmpi(message,Channel_Config.colors_name[k]) == 0 )); + if( k == Channel_Config.colors_count ) { + sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'. + clif_displaymessage(fd, atcmd_output); + return -1; + } + sd->fontcolor = k; } - ARR_FIND(0,Channel_Config.colors_count,k,( strcmpi(message,Channel_Config.colors_name[k]) == 0 )); - if( k == Channel_Config.colors_count ) { - sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'. - clif_displaymessage(fd, atcmd_output); - return -1; - } - - sd->fontcolor = k + 1; - pc_disguise(sd,sd->status.class_); - return 0; } diff --git a/src/map/channel.c b/src/map/channel.c index 51cda78608..133d0652e7 100644 --- a/src/map/channel.c +++ b/src/map/channel.c @@ -135,7 +135,7 @@ int channel_join(struct Channel *channel, struct map_session_data *sd) { } else if( channel->opt & CHAN_OPT_ANNOUNCE_JOIN ) { char message[60]; sprintf(message, "[ #%s ] '%s' has joined.",channel->name,sd->status.name); - clif_channel_msg(channel,sd,message); + clif_channel_msg(channel,sd,message,channel->color); } /* someone is cheating, we kindly disconnect the bastard */ @@ -339,9 +339,14 @@ int channel_send(struct Channel *channel, struct map_session_data *sd, const cha return -2; } else { - char message[CHAN_MSG_LENGTH]; + char message[CHAN_MSG_LENGTH], color; + if((channel->color && Channel_Config.color_override && sd->fontcolor) + || (!channel->color && sd->fontcolor)) + color = sd->fontcolor; + else + color = channel->color; snprintf(message, CHAN_MSG_LENGTH, "[ #%s ] %s : %s",channel->name,sd->status.name, msg); - clif_channel_msg(channel,sd,message); + clif_channel_msg(channel,sd,message,color); sd->channel_tick = gettick(); } return 0; @@ -635,7 +640,7 @@ int channel_pcleave(struct map_session_data *sd, char *chname){ if( !Channel_Config.closing && (channel->opt & CHAN_OPT_ANNOUNCE_JOIN) ) { char message[60]; sprintf(message, "#%s '%s' left",channel->name,sd->status.name); - clif_channel_msg(channel,sd,message); + clif_channel_msg(channel,sd,message,channel->color); } switch(channel->type){ case CHAN_TYPE_ALLY: channel_pcquit(sd,3); break; @@ -1044,7 +1049,7 @@ void channel_read_config(void) { const char *map_chname, *ally_chname,*map_color, *ally_color; int ally_enabled = 0, local_enabled = 0; int local_autojoin = 0, ally_autojoin = 0; - int allow_user_channel_creation = 0; + int allow_user_channel_creation = 0, allow_user_color_override = 0; if( !config_setting_lookup_string(settings, "map_local_channel_name", &map_chname) ) map_chname = "map"; @@ -1075,6 +1080,11 @@ void channel_read_config(void) { if( allow_user_channel_creation ) Channel_Config.user_chenable = true; + config_setting_lookup_bool(settings, "allow_user_color_override", &allow_user_color_override); + + if( allow_user_color_override ) + Channel_Config.color_override = true; + if( (colors = config_setting_get_member(settings, "colors")) != NULL ) { int color_count = config_setting_length(colors); CREATE( Channel_Config.colors, unsigned long, color_count ); diff --git a/src/map/channel.h b/src/map/channel.h index 8d0bc4e152..346c46af94 100644 --- a/src/map/channel.h +++ b/src/map/channel.h @@ -33,6 +33,7 @@ struct { unsigned char map_chcolor, ally_chcolor; //msg color for map, ally bool map_enable, ally_enable, user_chenable; //map, ally, users channels enable ? bool map_autojoin, ally_autojoin; //do user auto join in mapchange, guildjoin ? + bool color_override; //can user override set channel color? char map_chname[CHAN_NAME_LENGTH], ally_chname[CHAN_NAME_LENGTH]; //channel name for map and ally bool closing; //server is closing } Channel_Config; diff --git a/src/map/clif.c b/src/map/clif.c index 0ece819933..4075645463 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -3282,15 +3282,16 @@ void clif_statusupack(struct map_session_data *sd,int type,int ok,int val) /// 2 = failure due to low level void clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok) { - int fd,header,offs=0; + int fd,header,offs=0,success; #if PACKETVER < 20110824 header = 0xaa; + success = (ok==1); #elif PACKETVER < 20120925 header = 0x8d0; - ok = ok ? 0:1; + success = ok ? 0:1; #else header = 0x999; - ok = ok ? 0:1; + success = ok ? 0:1; #endif nullpo_retv(sd); @@ -3305,13 +3306,13 @@ void clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok) WFIFOW(fd,offs+4)=(int)pos; #endif #if PACKETVER < 20100629 - WFIFOB(fd,offs+6)=ok; + WFIFOB(fd,offs+6)=success; #else if (ok && sd->inventory_data[n]->equip&EQP_VISIBLE) WFIFOW(fd,offs+6)=sd->inventory_data[n]->look; else WFIFOW(fd,offs+6)=0; - WFIFOB(fd,offs+8)=ok; + WFIFOB(fd,offs+8)=success; #endif WFIFOSET(fd,packet_len(header)); } @@ -5520,7 +5521,7 @@ void clif_broadcast2(struct block_list* bl, const char* mes, int len, unsigned l /* * Display *msg from *sd to all *users in channel */ -void clif_channel_msg(struct Channel *channel, struct map_session_data *sd, char *msg) { +void clif_channel_msg(struct Channel *channel, struct map_session_data *sd, char *msg, short color) { DBIterator *iter; struct map_session_data *user; unsigned short msg_len = strlen(msg) + 1; @@ -5529,7 +5530,7 @@ void clif_channel_msg(struct Channel *channel, struct map_session_data *sd, char WFIFOW(sd->fd,0) = 0x2C1; WFIFOW(sd->fd,2) = msg_len + 12; WFIFOL(sd->fd,4) = 0; - WFIFOL(sd->fd,8) = Channel_Config.colors[channel->color]; + WFIFOL(sd->fd,8) = Channel_Config.colors[color]; safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len); iter = db_iterator(channel->users); @@ -8217,7 +8218,7 @@ int clif_colormes(struct map_session_data * sd, enum clif_colors color, const ch WFIFOW(sd->fd,0) = 0x2C1; WFIFOW(sd->fd,2) = msg_len + 12; WFIFOL(sd->fd,4) = 0; - WFIFOL(sd->fd,8) = color_table[color]; + WFIFOL(sd->fd,8) = Channel_Config.colors[color]; safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len); WFIFOSET(sd->fd, msg_len + 12); @@ -9667,11 +9668,6 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) if( sd->gcbind ) { channel_send(sd->gcbind,sd,message); return; - } else if ( sd->fontcolor && !sd->chatID ) { - char mout[200]; - snprintf(mout, 200, "%s : %s",sd->fakename[0]?sd->fakename:sd->status.name,message); - clif_colormes(sd,sd->fontcolor-1,mout); - return; } /** diff --git a/src/map/clif.h b/src/map/clif.h index e38486b871..64e4186c57 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -778,7 +778,7 @@ enum clif_colors { unsigned long color_table[COLOR_MAX]; int clif_colormes(struct map_session_data * sd, enum clif_colors color, const char* msg); -void clif_channel_msg(struct Channel *channel, struct map_session_data *sd, char *msg); +void clif_channel_msg(struct Channel *channel, struct map_session_data *sd, char *msg, short color); #define clif_menuskill_clear(sd) (sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0; diff --git a/src/map/pc.c b/src/map/pc.c index 35c44cb8e3..33072fe4ec 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6584,11 +6584,12 @@ void pc_close_npc(struct map_session_data *sd,int flag) { nullpo_retv(sd); - if (sd->npc_id) { + if (sd->npc_id || sd->npc_shopid) { if (sd->state.using_fake_npc) { clif_clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd); sd->state.using_fake_npc = 0; } + if (sd->st) { if(sd->st->state == RUN){ //wait ending code execution add_timer(gettick()+500,pc_close_npc_timer,sd->bl.id,flag); @@ -6599,6 +6600,7 @@ void pc_close_npc(struct map_session_data *sd,int flag) } sd->state.menu_or_input = 0; sd->npc_menu = 0; + sd->npc_shopid = 0; #ifdef SECURE_NPCTIMEOUT sd->npc_idle_timer = INVALID_TIMER; #endif