Rework of @fontcolor including new channel config - Fixes bugreport:7638

-> allow_user_color_override in conf/channels.conf
-> font color only currently works with channel system
Added server-wide NPC close on @reloadscript - Fixes bugreport:6818 & bugreport:6167
Fixed clif_equipitemack checks so characters update view in status window (lighta) - Fixes bugreport:7644

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@17313 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
akinari1087 2013-05-04 03:38:36 +00:00
parent 9a2d5a9d25
commit fb9d857456
9 changed files with 52 additions and 37 deletions

View File

@ -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"

View File

@ -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);

View File

@ -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) )

View File

@ -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;
}

View File

@ -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 );

View File

@ -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;

View File

@ -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;
}
/**

View File

@ -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;

View File

@ -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