Browse Source

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

akinari1087 12 years ago
parent
commit
fb9d857456
9 changed files with 52 additions and 37 deletions
  1. 4 1
      conf/channels.conf
  2. 1 2
      src/char/char.c
  3. 1 1
      src/char/int_storage.c
  4. 17 13
      src/map/atcommand.c
  5. 15 5
      src/map/channel.c
  6. 1 0
      src/map/channel.h
  7. 9 13
      src/map/clif.c
  8. 1 1
      src/map/clif.h
  9. 3 1
      src/map/pc.c

+ 4 - 1
conf/channels.conf

@@ -22,13 +22,16 @@ chsys: (
 		Yellow: "0xffff90"
 		Yellow: "0xffff90"
 		Green: "0x28bf00"
 		Green: "0x28bf00"
 		Normal: "0x00ff00"
 		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? */
 	/* Allow users to create their own (private) channels through @channels command? */
 	/* (must also allow players to use @channels in groups.conf) */
 	/* (must also allow players to use @channels in groups.conf) */
 	allow_user_channel_creation: true
 	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" is an instanced channel unique to each map. */
 	map_local_channel: true
 	map_local_channel: true
 	map_local_channel_name: "map"
 	map_local_channel_name: "map"

+ 1 - 2
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, 6, &data, NULL); partner_id = atoi(data);
 	Sql_GetData(sql_handle, 7, &data, NULL); father_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, 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_EscapeStringLen(sql_handle, esc_name, name, min(len, NAME_LENGTH));
 	Sql_FreeResult(sql_handle);
 	Sql_FreeResult(sql_handle);

+ 1 - 1
src/char/int_storage.c

@@ -141,7 +141,7 @@ void inter_storage_sql_final(void)
 	return;
 	return;
 }
 }
 
 
-// q?f[^?
+// Delete char storage
 int inter_storage_delete(int account_id)
 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) )
 	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) )

+ 17 - 13
src/map/atcommand.c

@@ -3726,10 +3726,18 @@ ACMD_FUNC(reloadmotd)
  *------------------------------------------*/
  *------------------------------------------*/
 ACMD_FUNC(reloadscript)
 ACMD_FUNC(reloadscript)
 {
 {
+	struct s_mapiterator* iter;
+	struct map_session_data* pl_sd;
+
 	nullpo_retr(-1, sd);
 	nullpo_retr(-1, sd);
 	//atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
 	//atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
 	//atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
 	//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();
 	flush_fifos();
 	map_reloadnpc(true); // reload config files seeking for npcs
 	map_reloadnpc(true); // reload config files seeking for npcs
 	script_reload();
 	script_reload();
@@ -8926,22 +8934,18 @@ ACMD_FUNC(fontcolor)
 		return -1;
 		return -1;
 	}
 	}
 
 
-	if( message[0] == '0' ) {
+	if( message[0] == '0' )
 		sd->fontcolor = 0;
 		sd->fontcolor = 0;
-		pc_disguise(sd,0);
-		return 0;
-	}
-
-	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;
+	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;
 	}
 	}
 
 
-	sd->fontcolor = k + 1;
-	pc_disguise(sd,sd->status.class_);
-
 	return 0;
 	return 0;
 }
 }
 
 

+ 15 - 5
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 ) {
 	} else if( channel->opt & CHAN_OPT_ANNOUNCE_JOIN ) {
 		char message[60];
 		char message[60];
 		sprintf(message, "[ #%s ] '%s' has joined.",channel->name,sd->status.name);
 		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 */
 	/* 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;
 		return -2;
 	}
 	}
 	else {
 	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);
 		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();
 		sd->channel_tick = gettick();
 	}
 	}
 	return 0;
 	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) ) {
 	if( !Channel_Config.closing && (channel->opt & CHAN_OPT_ANNOUNCE_JOIN) ) {
 		char message[60];
 		char message[60];
 		sprintf(message, "#%s '%s' left",channel->name,sd->status.name);
 		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){
 	switch(channel->type){
 	case CHAN_TYPE_ALLY: channel_pcquit(sd,3); break;
 	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;
 		const char *map_chname, *ally_chname,*map_color, *ally_color;
 		int ally_enabled = 0, local_enabled = 0;
 		int ally_enabled = 0, local_enabled = 0;
 		int local_autojoin = 0, ally_autojoin = 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) )
 		if( !config_setting_lookup_string(settings, "map_local_channel_name", &map_chname) )
 			map_chname = "map";
 			map_chname = "map";
@@ -1075,6 +1080,11 @@ void channel_read_config(void) {
 		if( allow_user_channel_creation )
 		if( allow_user_channel_creation )
 			Channel_Config.user_chenable = true;
 			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 ) {
 		if( (colors = config_setting_get_member(settings, "colors")) != NULL ) {
 			int color_count = config_setting_length(colors);
 			int color_count = config_setting_length(colors);
 			CREATE( Channel_Config.colors, unsigned long, color_count );
 			CREATE( Channel_Config.colors, unsigned long, color_count );

+ 1 - 0
src/map/channel.h

@@ -33,6 +33,7 @@ struct {
 	unsigned char map_chcolor, ally_chcolor; //msg color for map, ally
 	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_enable, ally_enable, user_chenable; //map, ally, users channels enable ?
 	bool map_autojoin, ally_autojoin;	//do user auto join in mapchange, guildjoin ?
 	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
 	char map_chname[CHAN_NAME_LENGTH], ally_chname[CHAN_NAME_LENGTH]; //channel name for map and ally
 	bool closing;			//server is closing
 	bool closing;			//server is closing
 } Channel_Config;
 } Channel_Config;

+ 9 - 13
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
 ///     2 = failure due to low level
 void clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok)
 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
 #if PACKETVER < 20110824
 	header = 0xaa;
 	header = 0xaa;
+	success = (ok==1);
 #elif PACKETVER < 20120925
 #elif PACKETVER < 20120925
 	header = 0x8d0;
 	header = 0x8d0;
-	ok = ok ? 0:1;
+	success = ok ? 0:1;
 #else
 #else
 	header = 0x999;
 	header = 0x999;
-	ok = ok ? 0:1;
+	success = ok ? 0:1;
 #endif
 #endif
 	nullpo_retv(sd);
 	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;
 	WFIFOW(fd,offs+4)=(int)pos;
 #endif
 #endif
 #if PACKETVER < 20100629
 #if PACKETVER < 20100629
-	WFIFOB(fd,offs+6)=ok;
+	WFIFOB(fd,offs+6)=success;
 #else
 #else
 	if (ok && sd->inventory_data[n]->equip&EQP_VISIBLE)
 	if (ok && sd->inventory_data[n]->equip&EQP_VISIBLE)
 		WFIFOW(fd,offs+6)=sd->inventory_data[n]->look;
 		WFIFOW(fd,offs+6)=sd->inventory_data[n]->look;
 	else
 	else
 		WFIFOW(fd,offs+6)=0;
 		WFIFOW(fd,offs+6)=0;
-	WFIFOB(fd,offs+8)=ok;
+	WFIFOB(fd,offs+8)=success;
 #endif
 #endif
 	WFIFOSET(fd,packet_len(header));
 	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
  * 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;
 	DBIterator *iter;
 	struct map_session_data *user;
 	struct map_session_data *user;
 	unsigned short msg_len = strlen(msg) + 1;
 	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,0) = 0x2C1;
 	WFIFOW(sd->fd,2) = msg_len + 12;
 	WFIFOW(sd->fd,2) = msg_len + 12;
 	WFIFOL(sd->fd,4) = 0;
 	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);
 	safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);
 
 
 	iter = db_iterator(channel->users);
 	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,0) = 0x2C1;
 	WFIFOW(sd->fd,2) = msg_len + 12;
 	WFIFOW(sd->fd,2) = msg_len + 12;
 	WFIFOL(sd->fd,4) = 0;
 	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);
 	safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);
 	WFIFOSET(sd->fd, msg_len + 12);
 	WFIFOSET(sd->fd, msg_len + 12);
 
 
@@ -9667,11 +9668,6 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
 	if( sd->gcbind ) {
 	if( sd->gcbind ) {
 		channel_send(sd->gcbind,sd,message);
 		channel_send(sd->gcbind,sd,message);
 		return;
 		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;
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 1
src/map/clif.h

@@ -778,7 +778,7 @@ enum clif_colors {
 unsigned long color_table[COLOR_MAX];
 unsigned long color_table[COLOR_MAX];
 int clif_colormes(struct map_session_data * sd, enum clif_colors color, const char* msg);
 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;
 #define clif_menuskill_clear(sd) (sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0;
 
 

+ 3 - 1
src/map/pc.c

@@ -6584,11 +6584,12 @@ void pc_close_npc(struct map_session_data *sd,int flag)
 {
 {
 	nullpo_retv(sd);
 	nullpo_retv(sd);
 
 
-	if (sd->npc_id) {
+	if (sd->npc_id || sd->npc_shopid) {
 		if (sd->state.using_fake_npc) {
 		if (sd->state.using_fake_npc) {
 			clif_clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd);
 			clif_clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd);
 			sd->state.using_fake_npc = 0;
 			sd->state.using_fake_npc = 0;
 		}
 		}
+			
 		if (sd->st) {
 		if (sd->st) {
 			if(sd->st->state == RUN){ //wait ending code execution
 			if(sd->st->state == RUN){ //wait ending code execution
 			    add_timer(gettick()+500,pc_close_npc_timer,sd->bl.id,flag);
 			    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->state.menu_or_input = 0;
 		sd->npc_menu = 0;
 		sd->npc_menu = 0;
+		sd->npc_shopid = 0;
 #ifdef SECURE_NPCTIMEOUT
 #ifdef SECURE_NPCTIMEOUT
 		sd->npc_idle_timer = INVALID_TIMER;
 		sd->npc_idle_timer = INVALID_TIMER;
 #endif
 #endif