viewing paste Unknown #5810 | Diff

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
Index: src/common/mmo.h
===================================================================
--- src/common/mmo.h    (revision 17313)
+++ src/common/mmo.h    (working copy)
@@ -47,8 +47,8 @@
 // 20120307 - 2012-03-07aRagexeRE+ - 0x970
 
 #ifndef PACKETVER
-   #define PACKETVER 20120410
-   //#define PACKETVER 20130320
+   //#define PACKETVER 20120410
+   #define PACKETVER 20130320
    //#define PACKETVER 20111116
 #endif
 
Index: src/map/channel.c
===================================================================
--- src/map/channel.c   (revision 17313)
+++ src/map/channel.c   (working copy)
@@ -335,13 +335,12 @@
        return -1;
 
    if(!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && channel->msg_delay != 0 && DIFF_TICK(sd->channel_tick + ( channel->msg_delay * 1000 ), gettick()) > 0) {
-       clif_colormes(sd,COLOR_RED,msg_txt(sd,1455)); //You're talking too fast!
+       clif_colormes(sd,color_table[COLOR_RED],msg_txt(sd,1455)); //You're talking too fast!
        return -2;
    }
    else {
        char message[CHAN_MSG_LENGTH], color;
-       if((channel->color && Channel_Config.color_override && sd->fontcolor)
-           || (!channel->color && sd->fontcolor))
+       if((channel->opt)&CHAN_OPT_COLOR_OVERRIDE && sd->fontcolor)
            color = sd->fontcolor;
        else
            color = channel->color;
@@ -461,25 +460,6 @@
 }
 
 /*
- * Replication of clif_colormes but with more avaiable colors
- * return
- *  0 : all cases
- */
-int channel_colormes(struct map_session_data *__restrict sd, uint32 channel_color, const char *__restrict msg){
-   uint16 msg_len = strlen(msg) + 1;
-
-   WFIFOHEAD(sd->fd,msg_len + 12);
-   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];
-   safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);
-   WFIFOSET(sd->fd, msg_len + 12);
-
-   return 0;
-}
-
-/*
  * Display some info to user *sd on channels
  * @options :
  *  colors : display availables colors for chan system
@@ -503,7 +483,7 @@
        clif_displaymessage(sd->fd, msg_txt(sd,1444)); // ---- Available Colors ----
        for( k = 0; k < Channel_Config.colors_count; k++ ) {
            sprintf(msg, msg_txt(sd,1445),Channel_Config.colors_name[k]);// - '%s'
-           channel_colormes(sd, k, msg);
+           clif_colormes(sd,Channel_Config.colors[k],msg);
        }
    }
    else if( options[0] != '\0' && strcmpi(options,"mine") == 0 ) { //display chan I'm into
@@ -921,10 +901,11 @@
    struct Channel *channel;
    char output[128];
    int k, s=0;
-   const char* opt_str[3] = {
+   const char* opt_str[] = {
        "None",
        "JoinAnnounce",
        "MessageDelay",
+       "ColorOverride",
    };
 
    if( channel_chk(chname,NULL,1) ) {
@@ -945,14 +926,14 @@
        return -1;
    }
 
-   if( option == '\0' ) {
+   if(!option || option == '\0' ) {
        clif_displaymessage(sd->fd, msg_txt(sd,1446));// You need to input an option.
        return -1;
    }
 
    s = ARRAYLENGTH(opt_str);
    ARR_FIND(1,s,k,( strncmpi(option,opt_str[k],3) == 0 )); //we only cmp 3 letter atm
-   if( k == 3 ) {
+   if( k >= s ) {
        sprintf(output, msg_txt(sd,1447), option);// Unknown channel option '%s'.
        clif_displaymessage(sd->fd, output);
        clif_displaymessage(sd->fd, msg_txt(sd,1414));// ---- Available options:
@@ -1080,11 +1061,6 @@
        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 );
Index: src/map/channel.h
===================================================================
--- src/map/channel.h   (revision 17313)
+++ src/map/channel.h   (working copy)
@@ -17,6 +17,7 @@
    CHAN_OPT_BASE       = 0,
    CHAN_OPT_ANNOUNCE_JOIN  = 1,    //display message when join or leave
    CHAN_OPT_MSG_DELAY  = 2,
+   CHAN_OPT_COLOR_OVERRIDE = 3,
 };
 
 enum Channel_Type {
Index: src/map/skill.c
===================================================================
--- src/map/skill.c (revision 17313)
+++ src/map/skill.c (working copy)
@@ -9244,7 +9244,7 @@
            int mode = hd->sc.data[SC_STYLE_CHANGE]->val1;
            char output[128];
            safesnprintf(output,sizeof(output),"Eleanor is now in %s mode",(sce->val1==MH_MD_FIGHTING?"fighthing":"grappling"));
-           clif_colormes(hd->master,COLOR_RED,output);
+           clif_colormes(hd->master,color_table[COLOR_RED],output);
        }
        }
        break;
@@ -13263,7 +13263,7 @@
                    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");
-               clif_colormes(sd, COLOR_RED, output);
+               clif_colormes(sd,color_table[COLOR_RED], output);
                return 0;
                }
            }
@@ -13634,7 +13634,7 @@
                        skill_get_desc(skill_id),
                        require.ammo_qty,
                        itemdb_jname(sd->status.inventory[i].nameid));
-           clif_colormes(sd,COLOR_RED,e_msg);
+           clif_colormes(sd,color_table[COLOR_RED],e_msg);
            return 0;
        }
        if (!(require.ammo&1<<sd->inventory_data[i]->look)) { //Ammo type check. Send the "wrong weapon type" message
Index: src/map/clif.c
===================================================================
--- src/map/clif.c  (revision 17313)
+++ src/map/clif.c  (working copy)
@@ -5472,9 +5472,9 @@
 
 /*==========================================
  * Displays a message on a 'bl' to all it's nearby clients
- * Used by npc_globalmessage
+ * 008d <PacketLength>.W <GID> L (ZC_NOTIFY_CHAT)
  *------------------------------------------*/
-void clif_GlobalMessage(struct block_list* bl, const char* message) {
+void clif_GlobalMessage(struct block_list* bl, const char* message, enum send_target target) {
    char buf[100];
    int len;
    nullpo_retv(bl);
@@ -5493,7 +5493,7 @@
    WBUFW(buf,2)=len+8;
    WBUFL(buf,4)=bl->id;
    safestrncpy((char *) WBUFP(buf,8),message,len);
-   clif_send((unsigned char *) buf,WBUFW(buf,2),bl,ALL_CLIENT);
+   clif_send((unsigned char *) buf,WBUFW(buf,2),bl,target);
 
 }
 
@@ -5526,12 +5526,7 @@
    struct map_session_data *user;
    unsigned short msg_len = strlen(msg) + 1;
 
-   WFIFOHEAD(sd->fd,msg_len + 12);
-   WFIFOW(sd->fd,0) = 0x2C1;
-   WFIFOW(sd->fd,2) = msg_len + 12;
-   WFIFOL(sd->fd,4) = 0;
-   WFIFOL(sd->fd,8) = Channel_Config.colors[color];
-   safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);
+   clif_colormes(sd,Channel_Config.colors[color],msg);
 
    iter = db_iterator(channel->users);
    for( user = dbi_first(iter); dbi_exists(iter); user = dbi_next(iter) ) {
@@ -8211,14 +8206,14 @@
 }
 // 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(struct map_session_data * sd, enum clif_colors color, const char* msg) {
+int clif_colormes(struct map_session_data * sd, unsigned long color, const char* msg) {
    unsigned short msg_len = strlen(msg) + 1;
 
    WFIFOHEAD(sd->fd,msg_len + 12);
    WFIFOW(sd->fd,0) = 0x2C1;
    WFIFOW(sd->fd,2) = msg_len + 12;
    WFIFOL(sd->fd,4) = 0;
-   WFIFOL(sd->fd,8) = Channel_Config.colors[color];
+   WFIFOL(sd->fd,8) = color; //either color_table or channel_table
    safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len);
    WFIFOSET(sd->fd, msg_len + 12);
 
@@ -9681,13 +9676,7 @@
        textlen = strlen(fakename) + 1;
    }
    // send message to others (using the send buffer for temp. storage)
-   WFIFOHEAD(fd, 8 + textlen);
-   WFIFOW(fd,0) = 0x8d;
-   WFIFOW(fd,2) = 8 + textlen;
-   WFIFOL(fd,4) = sd->bl.id;
-   safestrncpy((char*)WFIFOP(fd,8), is_fake ? fakename : text, textlen);
-   //FIXME: chat has range of 9 only
-   clif_send(WFIFOP(fd,0), WFIFOW(fd,2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC);
+   clif_GlobalMessage(&sd->bl,is_fake ? fakename : text,sd->chatID ? CHAT_WOS : AREA_CHAT_WOC);
 
    // send back message to the speaker
    if( is_fake ) {
Index: src/map/clif.h
===================================================================
--- src/map/clif.h  (revision 17313)
+++ src/map/clif.h  (working copy)
@@ -382,7 +382,7 @@
 void clif_changeoption(struct block_list* bl); // area
 void clif_changeoption2(struct block_list* bl);    // area
 void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok);    // self
-void clif_GlobalMessage(struct block_list* bl, const char* message);
+void clif_GlobalMessage(struct block_list* bl, const char* message,enum send_target target);
 void clif_createchat(struct map_session_data* sd, int flag);   // self
 void clif_dispchat(struct chat_data* cd, int fd);  // area or fd
 void clif_joinchatfail(struct map_session_data *sd,int flag);  // self
@@ -776,7 +776,7 @@
    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, unsigned long color, const char* msg);
 
 void clif_channel_msg(struct Channel *channel, struct map_session_data *sd, char *msg, short color);
 
Index: src/map/pc.c
===================================================================
--- src/map/pc.c    (revision 17313)
+++ src/map/pc.c    (working copy)
@@ -4107,7 +4107,7 @@
        return 0;
    if( !item->script ) //if it has no script, you can't really consume it!
        return 0;
-       
+
    if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override) ) {
        return 0; // You cannot use this item while sitting.
    }
@@ -4326,7 +4326,7 @@
                        sprintf(e_msg,"Item Failed. [%s] is cooling down. wait %d seconds.",
                                        itemdb_jname(sd->status.inventory[n].nameid),
                                        e_tick+1);
-                   clif_colormes(sd,COLOR_RED,e_msg);
+                   clif_colormes(sd,color_table[COLOR_RED],e_msg);
                    return 0; // Delay has not expired yet
                }
            } else {// not yet used item (all slots are initially empty)
@@ -6589,7 +6589,7 @@
            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);
Index: src/map/npc.c
===================================================================
--- src/map/npc.c   (revision 17313)
+++ src/map/npc.c   (working copy)
@@ -1150,7 +1150,7 @@
        return 0;
 
    snprintf(temp, sizeof(temp), "%s : %s", name, mes);
-   clif_GlobalMessage(&nd->bl,temp);
+   clif_GlobalMessage(&nd->bl,temp,ALL_CLIENT);
 
    return 0;
 }
Index: src/map/atcommand.c
===================================================================
--- src/map/atcommand.c (revision 17313)
+++ src/map/atcommand.c (working copy)
@@ -8929,7 +8929,7 @@
        char mout[40];
        for( k = 0; k < Channel_Config.colors_count; k++ ) {
            sprintf(mout, "[ %s ] : %s",command,Channel_Config.colors_name[k]);
-           clif_colormes(sd,k,mout);
+           clif_colormes(sd,Channel_Config.colors[k],mout);
        }
        return -1;
    }
Viewed 1238 times, submitted by lighta.