Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. enum channel_operation_status channel_join(struct channel_data *chan, struct map_session_data *sd, const char *password, bool silent)
  2. {
  3. bool stealth = false;
  4.  
  5. nullpo_retr(HCS_STATUS_FAIL, chan);
  6. nullpo_retr(HCS_STATUS_FAIL, sd);
  7.  
  8. if (idb_exists(chan->users, sd->status.char_id)) {
  9. return HCS_STATUS_ALREADY;
  10. }
  11.  
  12. if (chan->password[0] != '\0' && strcmp(chan->password, password) != 0) {
  13. if (pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) {
  14. stealth = true;
  15. } else {
  16. return HCS_STATUS_NOPERM;
  17. }
  18. }
  19.  
  20. if (chan->banned && idb_exists(chan->banned, sd->status.account_id))
  21. {
  22. struct channel_ban_entry *banentry = (struct channel_ban_entry *)idb_get(chan->banned, sd->status.account_id);
  23. time_t i;
  24. if ( banentry == NULL ) // well somehow it's null
  25. return HCS_STATUS_BANNED;
  26.  
  27. i = atoi(banentry->time);
  28.  
  29. if ( i >= time(NULL) )
  30. return HCS_STATUS_BANNED;
  31. }
  32.  
  33. if (!silent && !(chan->options&HCS_OPT_ANNOUNCE_JOIN)) {
  34. char output[CHAT_SIZE_MAX];
  35. if (chan->type == HCS_TYPE_MAP) {
  36. sprintf(output, msg_sd(sd,1435), chan->name, map->list[chan->m].name); // You're now in the '#%s' channel for '%s'
  37. } else {
  38. sprintf(output, msg_sd(sd,1403), chan->name); // You're now in the '%s' channel
  39. }
  40. clif->colormes(sd->fd, COLOR_DEFAULT, output);
  41. }
  42.  
  43. if (chan->type == HCS_TYPE_ALLY) {
  44. struct guild *g = sd->guild;
  45. int i;
  46. for (i = 0; i < MAX_GUILDALLIANCE; i++) {
  47. struct guild *sg = NULL;
  48. if (g->alliance[i].opposition == 0 && g->alliance[i].guild_id && (sg = guild->search(g->alliance[i].guild_id))) {
  49. if (!(sg->channel->banned && idb_exists(sg->channel->banned, sd->status.account_id))) {
  50. channel->join_sub(sg->channel, sd, stealth);
  51. }
  52. }
  53. }
  54. }
  55.  
  56. channel->join_sub(chan, sd, stealth);
  57.  
  58. return HCS_STATUS_OK;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement