summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/atcommand.c17
-rw-r--r--src/map/battleground.c15
-rw-r--r--src/map/channel.c4
-rw-r--r--src/map/clif.c93
-rw-r--r--src/map/clif.h21
-rw-r--r--src/map/npc.c4
-rw-r--r--src/map/pc.c26
-rw-r--r--src/map/skill.c4
-rw-r--r--src/plugins/sample.c2
9 files changed, 81 insertions, 105 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 47e874492..f42a6332d 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -664,7 +664,7 @@ ACMD(who) {
break;
}
}
- clif->colormes(fd, COLOR_DEFAULT, StrBuf->Value(&buf));/** for whatever reason clif->message crashes with some patterns, see bugreport:8186 **/
+ clif->messagecolor_self(fd, COLOR_DEFAULT, StrBuf->Value(&buf));/** for whatever reason clif->message crashes with some patterns, see bugreport:8186 **/
StrBuf->Clear(&buf);
count++;
}
@@ -7941,10 +7941,10 @@ ACMD(feelreset)
/*==========================================
* AUCTION SYSTEM
*------------------------------------------*/
-ACMD(auction) {
-
- if( !battle_config.feature_auction ) {
- clif->colormes(sd->fd,COLOR_RED,msg_fd(fd,1484));
+ACMD(auction)
+{
+ if (!battle_config.feature_auction) {
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_fd(fd,1484));
return false;
}
@@ -9953,11 +9953,12 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa
}
for(i = 0; i < map->list[sd->bl.m].zone->disabled_commands_count; i++) {
if( info->func == map->list[sd->bl.m].zone->disabled_commands[i]->cmd ) {
- if( pc_get_group_level(sd) < map->list[sd->bl.m].zone->disabled_commands[i]->group_lv ) {
- clif->colormes(sd->fd,COLOR_RED,"This command is disabled in this area");
+ if (pc_get_group_level(sd) < map->list[sd->bl.m].zone->disabled_commands[i]->group_lv) {
+ clif->messagecolor_self(sd->fd, COLOR_RED, "This command is disabled in this area");
return true;
- } else
+ } else {
break;/* already found the matching command, no need to keep checking -- just go on */
+ }
}
}
}
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 76880a086..3c7c1db43 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -538,11 +538,10 @@ void bg_match_over(struct bg_arena *arena, bool canceled) {
bg->team_leave(sd, 0);
bg->queue_pc_cleanup(sd);
}
- if( canceled )
- clif->colormes(sd->fd,COLOR_RED,"BG Match Canceled: not enough players");
- else {
+ if (canceled)
+ clif->messagecolor_self(sd->fd, COLOR_RED, "BG Match Canceled: not enough players");
+ else
pc_setglobalreg(sd, script->add_str(arena->delay_var), (unsigned int)time(NULL));
- }
}
}
@@ -766,7 +765,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
sprintf(response, "You are a deserter! Wait %d minute(s) before you can apply again",(tick-tsec)/60);
else
sprintf(response, "You are a deserter! Wait %d seconds before you can apply again",(tick-tsec));
- clif->colormes(sd->fd,COLOR_RED,response);
+ clif->messagecolor_self(sd->fd, COLOR_RED, response);
return BGQA_FAIL_DESERTER;
}
@@ -776,7 +775,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
sprintf(response, "You can't reapply to this arena so fast. Apply to the different arena or wait %d minute(s)",(tick-tsec)/60);
else
sprintf(response, "You can't reapply to this arena so fast. Apply to the different arena or wait %d seconds",(tick-tsec));
- clif->colormes(sd->fd,COLOR_RED,response);
+ clif->messagecolor_self(sd->fd, COLOR_RED, response);
return BGQA_FAIL_COOLDOWN;
}
@@ -800,7 +799,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
sprintf(response, "Can't apply: not enough members in your team/guild that have not entered the queue in individual mode, minimum is %d",arena->min_team_players);
else
sprintf(response, "Can't apply: not enough members in your team/guild, minimum is %d",arena->min_team_players);
- clif->colormes(sd->fd,COLOR_RED,response);
+ clif->messagecolor_self(sd->fd, COLOR_RED, response);
return BGQA_FAIL_TEAM_COUNT;
}
}
@@ -832,7 +831,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
sprintf(response, "Can't apply: not enough members in your team/party that have not entered the queue in individual mode, minimum is %d",arena->min_team_players);
else
sprintf(response, "Can't apply: not enough members in your team/party, minimum is %d",arena->min_team_players);
- clif->colormes(sd->fd,COLOR_RED,response);
+ clif->messagecolor_self(sd->fd, COLOR_RED, response);
return BGQA_FAIL_TEAM_COUNT;
}
} else
diff --git a/src/map/channel.c b/src/map/channel.c
index 58ff98c2b..7b9dce4ea 100644
--- a/src/map/channel.c
+++ b/src/map/channel.c
@@ -258,7 +258,7 @@ void channel_send(struct channel_data *chan, struct map_session_data *sd, const
if (sd && chan->msg_delay != 0
&& DIFF_TICK(sd->hchsysch_tick + chan->msg_delay*1000, timer->gettick()) > 0
&& !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
- clif->colormes(sd->fd,COLOR_RED,msg_sd(sd,1455));
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1455));
return;
} else if (sd) {
snprintf(message, 150, "[ #%s ] %s : %s",chan->name,sd->status.name, msg);
@@ -352,7 +352,7 @@ enum channel_operation_status channel_join(struct channel_data *chan, struct map
} else {
sprintf(output, msg_sd(sd,1403), chan->name); // You're now in the '%s' channel
}
- clif->colormes(sd->fd, COLOR_DEFAULT, output);
+ clif->messagecolor_self(sd->fd, COLOR_DEFAULT, output);
}
if (chan->type == HCS_TYPE_ALLY) {
diff --git a/src/map/clif.c b/src/map/clif.c
index 1fc606e7c..ea72acb7f 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -5349,7 +5349,7 @@ void clif_displaymessage(const int fd, const char* mes) {
#if PACKETVER == 20141022
/** for some reason game client crashes depending on message pattern (only for this packet) **/
/** so we redirect to ZC_NPC_CHAT **/
- clif->colormes(fd,COLOR_DEFAULT,mes);
+ clif->messagecolor_self(fd, COLOR_DEFAULT, mes);
#else
size_t len;
@@ -8126,28 +8126,41 @@ void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, sen
clif->send(buf, packet_len(0x284), bl, SELF);
}
}
-// Modification of clif_messagecolor to send colored messages to players to chat log only (doesn't display overhead)
-/// 02c1 <packet len>.W <id>.L <color>.L <message>.?B
-int clif_colormes(int fd, enum clif_colors color, const char* msg) {
+/**
+ * Modification of clif_messagecolor to send colored messages to players to chat log only (doesn't display overhead).
+ *
+ * 02c1 <packet len>.W <id>.L <color>.L <message>.?B
+ *
+ * @param fd Target fd to send the message to
+ * @param color Message color (RGB format: 0xRRGGBB)
+ * @param msg Message text
+ */
+void clif_messagecolor_self(int fd, uint32 color, const char *msg)
+{
size_t msg_len = strlen(msg) + 1;
WFIFOHEAD(fd,msg_len + 12);
WFIFOW(fd,0) = 0x2C1;
WFIFOW(fd,2) = msg_len + 12;
WFIFOL(fd,4) = 0;
- WFIFOL(fd,8) = color_table[color];
+ WFIFOL(fd,8) = RGB2BGR(color);
safestrncpy((char*)WFIFOP(fd,12), msg, msg_len);
WFIFOSET(fd, msg_len + 12);
-
- return 0;
}
-/// Monster/NPC color chat [SnakeDrak] (ZC_NPC_CHAT).
-/// 02c1 <packet len>.W <id>.L <color>.L <message>.?B
-void clif_messagecolor(struct block_list* bl, unsigned int color, const char* msg) {
+/**
+ * Monster/NPC color chat [SnakeDrak] (ZC_NPC_CHAT).
+ *
+ * 02c1 <packet len>.W <id>.L <color>.L <message>.?B
+ *
+ * @param bl Source block list.
+ * @param color Message color (RGB format: 0xRRGGBB)
+ * @param msg Message text
+ */
+void clif_messagecolor(struct block_list* bl, uint32 color, const char *msg)
+{
size_t msg_len = strlen(msg) + 1;
uint8 buf[256];
- color = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16; // RGB to BGR
nullpo_retv(bl);
@@ -8159,32 +8172,12 @@ void clif_messagecolor(struct block_list* bl, unsigned int color, const char* ms
WBUFW(buf,0) = 0x2C1;
WBUFW(buf,2) = msg_len + 12;
WBUFL(buf,4) = bl->id;
- WBUFL(buf,8) = color;
+ WBUFL(buf,8) = RGB2BGR(color);
memcpy(WBUFP(buf,12), msg, msg_len);
clif->send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC);
}
-/// Public chat message [Valaris] (ZC_NOTIFY_CHAT).
-/// 008d <packet len>.W <id>.L <message>.?B
-void clif_message(struct block_list* bl, const char* msg) {
- unsigned short msg_len = strlen(msg) + 1;
- uint8 buf[256];
- nullpo_retv(bl);
-
- if( msg_len > sizeof(buf)-8 ) {
- ShowWarning("clif_message: Truncating too long message '%s' (len=%u).\n", msg, msg_len);
- msg_len = sizeof(buf)-8;
- }
-
- WBUFW(buf,0) = 0x8d;
- WBUFW(buf,2) = msg_len + 8;
- WBUFL(buf,4) = bl->id;
- safestrncpy((char*)WBUFP(buf,8), msg, msg_len);
-
- clif->send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC);
-}
-
/**
* Notifies the client that the storage window is still open
*
@@ -17126,8 +17119,8 @@ void __attribute__ ((unused)) clif_parse_dull(int fd,struct map_session_data *sd
}
void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) {
- if( map->list[sd->bl.m].flag.nocashshop ) {
- clif->colormes(fd,COLOR_RED,msg_fd(fd,1489)); //Cash Shop is disabled in this map
+ if (map->list[sd->bl.m].flag.nocashshop) {
+ clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1489)); //Cash Shop is disabled in this map
return;
}
@@ -17167,8 +17160,8 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
unsigned short limit = RFIFOW(fd, 4), i, j;
unsigned int kafra_pay = RFIFOL(fd, 6);// [Ryuuzaki] - These are free cash points (strangely #CASH = main cash currently for us, confusing)
- if( map->list[sd->bl.m].flag.nocashshop ) {
- clif->colormes(fd,COLOR_RED,msg_fd(fd,1489)); //Cash Shop is disabled in this map
+ if (map->list[sd->bl.m].flag.nocashshop) {
+ clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1489)); //Cash Shop is disabled in this map
return;
}
@@ -17569,8 +17562,8 @@ void clif_parse_BankDeposit(int fd, struct map_session_data* sd) {
struct packet_banking_deposit_req *p = P2PTR(fd);
int money;
- if( !battle_config.feature_banking ) {
- clif->colormes(fd,COLOR_RED,msg_fd(fd,1483));
+ if (!battle_config.feature_banking) {
+ clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1483));
return;
}
@@ -17583,8 +17576,8 @@ void clif_parse_BankWithdraw(int fd, struct map_session_data* sd) {
struct packet_banking_withdraw_req *p = P2PTR(fd);
int money;
- if( !battle_config.feature_banking ) {
- clif->colormes(fd,COLOR_RED,msg_fd(fd,1483));
+ if (!battle_config.feature_banking) {
+ clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1483));
return;
}
@@ -17596,8 +17589,8 @@ void clif_parse_BankWithdraw(int fd, struct map_session_data* sd) {
void clif_parse_BankCheck(int fd, struct map_session_data* sd) {
struct packet_banking_check p;
- if( !battle_config.feature_banking ) {
- clif->colormes(fd,COLOR_RED,msg_fd(fd,1483));
+ if (!battle_config.feature_banking) {
+ clif->messagecolor_self(fd, COLOR_RED, msg_fd(fd,1483));
return;
}
@@ -18377,21 +18370,11 @@ void clif_bc_ready(void) {
/*==========================================
*
*------------------------------------------*/
-int do_init_clif(bool minimal) {
- const char* colors[COLOR_MAX] = { "0xFF0000", "0x00ff00", "0xffffff" };
- int i;
-
+int do_init_clif(bool minimal)
+{
if (minimal)
return 0;
- /**
- * Setup Color Table (saves unnecessary load of strtoul on every call)
- **/
- for(i = 0; i < COLOR_MAX; i++) {
- color_table[i] = (unsigned int)strtoul(colors[i],NULL,0);
- color_table[i] = (color_table[i] & 0x0000FF) << 16 | (color_table[i] & 0x00FF00) | (color_table[i] & 0xFF0000) >> 16;//RGB to BGR
- }
-
packetdb_loaddb();
set_defaultparse(clif->parse);
@@ -18686,6 +18669,7 @@ void clif_defaults(void) {
clif->disp_message = clif_disp_message;
clif->broadcast = clif_broadcast;
clif->broadcast2 = clif_broadcast2;
+ clif->messagecolor_self = clif_messagecolor_self;
clif->messagecolor = clif_messagecolor;
clif->disp_overhead = clif_disp_overhead;
clif->msgtable_skill = clif_msgtable_skill;
@@ -18694,7 +18678,6 @@ void clif_defaults(void) {
clif->message = clif_displaymessage;
clif->messageln = clif_displaymessage2;
clif->messages = clif_displaymessage_sprintf;
- clif->colormes = clif_colormes;
clif->process_message = clif_process_message;
clif->wisexin = clif_wisexin;
clif->wisall = clif_wisall;
diff --git a/src/map/clif.h b/src/map/clif.h
index df45b9ec0..f4402bdf7 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -49,6 +49,12 @@ struct channel_data;
#define clif_disp_onlyself(sd,mes,len) clif->disp_message( &(sd)->bl, (mes), (len), SELF )
#define MAX_ROULETTE_LEVEL 7 /** client-defined value **/
#define MAX_ROULETTE_COLUMNS 9 /** client-defined value **/
+#define RGB2BGR(c) ((c & 0x0000FF) << 16 | (c & 0x00FF00) | (c & 0xFF0000) >> 16)
+
+#define COLOR_RED 0xff0000U
+#define COLOR_GREEN 0x00ff00U
+#define COLOR_WHITE 0xffffffU
+#define COLOR_DEFAULT COLOR_GREEN
/**
* Enumerations
@@ -385,16 +391,6 @@ enum cashshop_error {
ERROR_TYPE_NOT_ALL = 8, ///< Some items could not be purchased. (ERROR_TYPE_NOT_ALL)
};
-/**
- * Color Table
- **/
-enum clif_colors {
- COLOR_RED,
- COLOR_DEFAULT,
- COLOR_WHITE,
- COLOR_MAX
-};
-
enum CASH_SHOP_TABS {
CASHSHOP_TAB_NEW = 0,
CASHSHOP_TAB_POPULAR = 1,
@@ -552,7 +548,6 @@ struct cdelayed_damage {
* Vars
**/
struct s_packet_db packet_db[MAX_PACKET_DB + 1];
-unsigned int color_table[COLOR_MAX];
/**
* Clif.c Interface
@@ -830,7 +825,8 @@ struct clif_interface {
void (*disp_message) (struct block_list* src, const char* mes, size_t len, enum send_target target);
void (*broadcast) (struct block_list* bl, const char* mes, size_t len, int type, enum send_target target);
void (*broadcast2) (struct block_list* bl, const char* mes, size_t len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target);
- void (*messagecolor) (struct block_list* bl, unsigned int color, const char* msg);
+ void (*messagecolor_self) (int fd, uint32 color, const char *msg);
+ void (*messagecolor) (struct block_list* bl, uint32 color, const char* msg);
void (*disp_overhead) (struct block_list *bl, const char* mes);
void (*msgtable) (struct map_session_data* sd, unsigned short msg_id);
void (*msgtable_num) (struct map_session_data *sd, unsigned short msg_id, int value);
@@ -839,7 +835,6 @@ struct clif_interface {
void (*messageln) (const int fd, const char* mes);
/* message+s(printf) */
void (*messages) (const int fd, const char *mes, ...) __attribute__((format(printf, 2, 3)));
- int (*colormes) (int fd, enum clif_colors color, const char* msg);
bool (*process_message) (struct map_session_data *sd, int format, char **name_, size_t *namelen_, char **message_, size_t *messagelen_);
void (*wisexin) (struct map_session_data *sd,int type,int flag);
void (*wisall) (struct map_session_data *sd,int type,int flag);
diff --git a/src/map/npc.c b/src/map/npc.c
index b901a2de0..ef56c7872 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1583,8 +1583,8 @@ bool npc_trader_open(struct map_session_data *sd, struct npc_data *nd) {
}
/* nothing to display, no items available */
- if( i == nd->u.scr.shop->items ) {
- clif->colormes(sd->fd,COLOR_RED, msg_sd(sd,881));
+ if (i == nd->u.scr.shop->items) {
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,881));
return false;
}
diff --git a/src/map/pc.c b/src/map/pc.c
index b2dd11581..d105edfda 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -4325,12 +4325,12 @@ int pc_isUseitem(struct map_session_data *sd,int n)
if ((item->item_usage.flag&INR_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override)) {
clif->msgtable(sd, MSG_ITEM_NEED_STANDING);
- //clif->colormes(sd->fd,COLOR_WHITE,msg_txt(1474));
+ //clif->messagecolor_self(sd->fd, COLOR_WHITE, msg_txt(1474));
return 0; // You cannot use this item while sitting.
}
if (sd->state.storage_flag != STORAGE_FLAG_CLOSED && item->type != IT_CASH) {
- clif->colormes(sd->fd, COLOR_RED, msg_sd(sd,1475));
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1475));
return 0; // You cannot use this item while storage is open.
}
@@ -4433,8 +4433,8 @@ int pc_isUseitem(struct map_session_data *sd,int n)
clif->msgtable(sd, MSG_ITEM_CANT_OBTAIN_WEIGHT);
return 0;
}
- if( !pc->inventoryblank(sd) ) {
- clif->colormes(sd->fd,COLOR_RED,msg_sd(sd,1477));
+ if (!pc->inventoryblank(sd)) {
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1477));
return 0;
}
}
@@ -6642,14 +6642,12 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) {
if (!pc_has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown
clif->skillinfoblock(sd);
} else if( battle_config.skillup_limit ){
- if( sd->sktree.second )
+ if (sd->sktree.second)
clif->msgtable_num(sd, MSG_SKILL_POINTS_LEFT_JOB1, sd->sktree.second);
- else if( sd->sktree.third )
+ else if (sd->sktree.third)
clif->msgtable_num(sd, MSG_SKILL_POINTS_LEFT_JOB2, sd->sktree.third);
- else if( pc->calc_skillpoint(sd) < 9 ) {
- /* TODO: official response? */
- clif->colormes(sd->fd,COLOR_RED,"You need the basic skills");
- }
+ else if (pc->calc_skillpoint(sd) < 9) /* TODO: official response? */
+ clif->messagecolor_self(sd->fd, COLOR_RED, "You need the basic skills");
}
return 0;
}
@@ -10651,15 +10649,15 @@ void pc_bank_deposit(struct map_session_data *sd, int money) {
void pc_bank_withdraw(struct map_session_data *sd, int money) {
unsigned int limit_check = money+sd->status.zeny;
- if( money <= 0 ) {
+ if (money <= 0) {
clif->bank_withdraw(sd,BWA_UNKNOWN_ERROR);
return;
- } else if ( money > sd->status.bank_vault ) {
+ } else if (money > sd->status.bank_vault) {
clif->bank_withdraw(sd,BWA_NO_MONEY);
return;
- } else if ( limit_check > MAX_ZENY ) {
+ } else if (limit_check > MAX_ZENY) {
/* no official response for this scenario exists. */
- clif->colormes(sd->fd,COLOR_RED,msg_sd(sd,1482));
+ clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1482));
return;
}
diff --git a/src/map/skill.c b/src/map/skill.c
index c1b4584d6..0562bcd96 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -13648,7 +13648,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
MOBID_EMPERIUM, MOBID_GUARIDAN_STONE1, MOBID_GUARIDAN_STONE2)) {
char output[128];
sprintf(output, "You're too close to a stone or emperium to do this skill"); /* TODO official response? or message.conf it */
- clif->colormes(sd->fd, COLOR_RED, output);
+ clif->messagecolor_self(sd->fd, COLOR_RED, output);
return 0;
}
}
@@ -14082,7 +14082,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
skill->get_desc(skill_id),
require.ammo_qty,
itemdb_jname(sd->status.inventory[i].nameid));
- clif->colormes(sd->fd,COLOR_RED,e_msg);
+ clif->messagecolor_self(sd->fd, COLOR_RED, e_msg);
return 0;
}
if (!(require.ammo&1<<sd->inventory_data[i]->look)) { //Ammo type check. Send the "wrong weapon type" message
diff --git a/src/plugins/sample.c b/src/plugins/sample.c
index 03d32b1f3..82cb198bd 100644
--- a/src/plugins/sample.c
+++ b/src/plugins/sample.c
@@ -107,7 +107,7 @@ int my_pc_dropitem_post(int retVal, struct map_session_data *sd,int *n,int *amou
if( my_pc_dropitem_storage ) {/* signs whether pre-hook did this */
char output[99];
safesnprintf(output,99,"[ Warning ] you can only drop 1 item at a time, capped from %d to 1",my_pc_dropitem_storage);
- clif->colormes(sd->fd,COLOR_RED,output);
+ clif->messagecolor_self(sd->fd, COLOR_RED, output);
}
return 1;
}