void add_buddy (const char *name, int type, int len) { int i, found = 0; char message[35]; add_name_to_tablist(name); // Check if the buddy already exists for (i = 0; i < MAX_BUDDY; i++) { if(strncasecmp(buddy_list[i].name, name, len) == 0){ //this name is already in our list if(buddy_list[i].type != type){ //colour change, not a new entry if(buddy_log_notice == 1){ if(buddy_list[i].type == 0xFE){//logging on safe_snprintf (message, sizeof(message), buddy_logon_str, len, name); LOG_TO_CONSOLE (c_green1, message); flash_icon(tt_buddy, 5); }else if(type == 0xFE){//logging off safe_snprintf (message, sizeof(message), buddy_logoff_str, len, name); LOG_TO_CONSOLE (c_green1, message); flash_icon(tt_buddy, 5); }//else it's just a normal colour change } buddy_list[i].type=type; } found = 1; break; } } if (found != 1) { // find empty space for (i = 0; i < MAX_BUDDY; i++) { if (buddy_list[i].type == 0xff) { // found then add buddy buddy_list[i].type = type; safe_snprintf (buddy_list[i].name, sizeof(buddy_list[i].name), "%.*s", len, name); // write optional online message if ((buddy_log_notice == 1) && (type != 0xFE)) { safe_snprintf (message, sizeof(message), buddy_online_str, len, name); LOG_TO_CONSOLE (c_green1, message); flash_icon(tt_buddy, 5); } break; } } } set_scrollbar_len(); }
// Returns 1 if ignored, 0 if not ignored int pre_check_if_ignored (const char *input_text, int len, Uint8 channel) { int offset; char name[MAX_USERNAME_LENGTH] = {0}; if (channel == CHAT_MODPM) { return 0; // Don't ever ignore MOD PM's } switch(channel) { case CHAT_PERSONAL: offset = strlen(pm_from_str) + 2; get_name_from_text(input_text, len, 0, offset, name); // Type 0 = ":" or " " break; case CHAT_LOCAL: offset = 0; while (is_color (input_text[offset])) { offset++; } offset += get_name_from_text(input_text, len, 1, offset, name); // Type 1 = ":", " " or is_color if (!name_is_valid(name)) { //This can be a lot. Let's separate them based on the color for now. switch (from_color_char (*input_text)) { case c_grey1: //Check for summoning messages //(*) NAME summoned a %s if (strcmp(name, "(*)") == 0) { while (offset < len && isspace(input_text[offset])) { offset++; } get_name_from_text(input_text, len, 2, offset, name); // Type 2 = isspace } break; } } break; case CHAT_GM: for (offset = 0; is_color (input_text[offset]); offset++); // Ignore colours if(strncasecmp(input_text+offset, gm_from_str, strlen(gm_from_str)) == 0) { offset = strlen(gm_from_str)+2; get_name_from_text(input_text, len, 0, offset, name); // Type 0 = ":" or " " } else if(strncasecmp(input_text+offset, ig_from_str, strlen(ig_from_str)) == 0) { offset = strlen(ig_from_str)+1; get_name_from_text(input_text, len, 4, offset, name); // Type 4 = ":", "-" or " " } break; case CHAT_MOD: for (offset = 0; is_color (input_text[offset]); offset++); // Ignore colours if(strncasecmp(input_text+offset, mc_from_str, strlen(mc_from_str)) == 0) { offset = strlen(mc_from_str)+2; get_name_from_text(input_text, len, 0, offset, name); // Type 0 = ":" or " " } break; case CHAT_SERVER: for (offset = 0; is_color (input_text[offset]); offset++); // Ignore colours if(strncasecmp(input_text+offset, "delayed: ", 9) == 0) { offset = 10; if(strncasecmp(input_text+offset, pm_from_str, strlen(pm_from_str)) == 0) { offset += strlen(pm_from_str)+1; get_name_from_text(input_text, len, 0, offset, name); // Type 0 = ":" or " " } } break; } #if defined(OTHER_LIFE) && defined(OTHER_LIFE_EXTENDED_CHAT) if(loadsofchannels == 3) { switch(channel) { case CHAT_CHANNEL1: case CHAT_CHANNEL2: case CHAT_CHANNEL3: for (offset = 0; is_color (input_text[offset]); offset++); // Ignore colours if (input_text[offset] == '[') { offset++; } get_name_from_text(input_text, len, 3, offset, name); // Type 3 = ":", " " or "]" } } else { switch(channel) { case CHAT_CHANNEL1: case CHAT_CHANNEL2: case CHAT_CHANNEL3: case CHAT_CHANNEL4: case CHAT_CHANNEL5: case CHAT_CHANNEL6: case CHAT_CHANNEL7: case CHAT_CHANNEL8: case CHAT_CHANNEL9: case CHAT_CHANNEL10: case CHAT_CHANNEL11: case CHAT_CHANNEL12: case CHAT_CHANNEL13: case CHAT_CHANNEL14: case CHAT_CHANNEL15: case CHAT_CHANNEL16: case CHAT_CHANNEL17: case CHAT_CHANNEL18: case CHAT_CHANNEL19: case CHAT_CHANNEL20: case CHAT_CHANNEL21: case CHAT_CHANNEL22: case CHAT_CHANNEL23: case CHAT_CHANNEL24: case CHAT_CHANNEL25: case CHAT_CHANNEL26: case CHAT_CHANNEL27: case CHAT_CHANNEL28: case CHAT_CHANNEL29: case CHAT_CHANNEL30: case CHAT_CHANNEL31: case CHAT_CHANNEL32: for (offset = 0; is_color (input_text[offset]); offset++); // Ignore colours if (input_text[offset] == '[') { offset++; } get_name_from_text(input_text, len, 3, offset, name); // Type 3 = ":", " " or "]" } } #else switch (channel) { case CHAT_CHANNEL1: case CHAT_CHANNEL2: case CHAT_CHANNEL3: for (offset = 0; is_color (input_text[offset]); offset++); // Ignore colours if (input_text[offset] == '[') { offset++; } get_name_from_text(input_text, len, 3, offset, name); // Type 3 = ":", " " or "]" } #endif // if defined(OTHER_LIFE) && defined(OTHER_LIFE_EXTENDED_CHAT) if (*name && name_is_valid(name)) { add_name_to_tablist(name); } else { for (offset = 0; is_color (input_text[offset]); offset++); // Ignore colours get_name_from_text(input_text, len, 1, offset, name); // Type 1 = ":", " " or is_color } if (!check_if_ignored (name)) { if (channel == CHAT_PERSONAL || channel == CHAT_MODPM) { //memorise the name my_strcp (last_pm_from, name); } return 0; } else { return 1; } }