/[svn]/ircd-hybrid/branches/8.2.x/modules/m_svsnick.c
ViewVC logotype

Diff of /ircd-hybrid/branches/8.2.x/modules/m_svsnick.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 7853 by michael, Thu Oct 6 16:59:51 2016 UTC revision 7854 by michael, Sun Nov 6 20:57:44 2016 UTC
# Line 50  Line 50 
50   * \note Valid arguments for this command are:   * \note Valid arguments for this command are:
51   *      - parv[0] = command   *      - parv[0] = command
52   *      - parv[1] = old nickname   *      - parv[1] = old nickname
53   *      - parv[2] = new nickname   *      - parv[2] = old timestampt
54   *      - parv[3] = timestamp   *      - parv[3] = new nickname
55     *      - parv[4] = new timestamp
56   */   */
57  static int  static int
58  ms_svsnick(struct Client *source_p, int parc, char *parv[])  ms_svsnick(struct Client *source_p, int parc, char *parv[])
59  {  {
60    struct Client *target_p = NULL, *exists_p = NULL;    struct Client *target_p = NULL, *exists_p = NULL;
61      const char *new_nick = parc == 5 ? parv[3] : parv[2];  /* TBR: compatibility mode */
62      uintmax_t ts = 0, new_ts = 0;
63    
64    if (!HasFlag(source_p, FLAGS_SERVICE))    if (!HasFlag(source_p, FLAGS_SERVICE))
65      return 0;      return 0;
66    
67    if (!valid_nickname(parv[2], 1))    if (!valid_nickname(new_nick, 1))
68      return 0;      return 0;
69    
70    if ((target_p = find_person(source_p, parv[1])) == NULL)    if ((target_p = find_person(source_p, parv[1])) == NULL)
71      return 0;      return 0;
72    
73      if (parc == 5)  /* TBR: compatibility mode */
74      {
75        ts = strtoumax(parv[2], NULL, 10);
76        if (ts && (ts != target_p->tsinfo))
77          return 0;
78      }
79      else  /* parc == 4 */
80        ts = strtoumax(parv[3], NULL, 10);
81    
82      if (parc == 4)  /* TBR: compatibility mode */
83        new_ts = ts;
84      else
85        new_ts = strtoumax(parv[4], NULL, 10);
86    
87    if (!MyConnect(target_p))    if (!MyConnect(target_p))
88    {    {
89      if (target_p->from == source_p->from)      if (target_p->from == source_p->from)
# Line 80  ms_svsnick(struct Client *source_p, int Line 97  ms_svsnick(struct Client *source_p, int
97      }      }
98    
99      sendto_one(target_p, ":%s SVSNICK %s %s %s", source_p->id,      sendto_one(target_p, ":%s SVSNICK %s %s %s", source_p->id,
100                 target_p->id, parv[2], parv[3]);                 target_p->id, new_nick, parv[3]);
101      return 0;      return 0;
102    }    }
103    
104    if ((exists_p = hash_find_client(parv[2])))    if ((exists_p = hash_find_client(new_nick)))
105    {    {
106      if (target_p == exists_p)      if (target_p == exists_p)
107      {      {
108        if (!strcmp(target_p->name, parv[2]))        if (!strcmp(target_p->name, new_nick))
109          return 0;          return 0;
110      }      }
111      else if (IsUnknown(exists_p))      else if (IsUnknown(exists_p))
# Line 100  ms_svsnick(struct Client *source_p, int Line 117  ms_svsnick(struct Client *source_p, int
117      }      }
118    }    }
119    
120    target_p->tsinfo = strtoumax(parv[3], NULL, 10);    target_p->tsinfo = new_ts;
121    clear_ban_cache_list(&target_p->channel);    clear_ban_cache_list(&target_p->channel);
122    watch_check_hash(target_p, RPL_LOGOFF);    watch_check_hash(target_p, RPL_LOGOFF);
123    
# Line 115  ms_svsnick(struct Client *source_p, int Line 132  ms_svsnick(struct Client *source_p, int
132    
133    sendto_common_channels_local(target_p, 1, 0, 0, ":%s!%s@%s NICK :%s",    sendto_common_channels_local(target_p, 1, 0, 0, ":%s!%s@%s NICK :%s",
134                                 target_p->name, target_p->username,                                 target_p->name, target_p->username,
135                                 target_p->host, parv[2]);                                 target_p->host, new_nick);
136    
137    whowas_add_history(target_p, 1);    whowas_add_history(target_p, 1);
138    
139    sendto_server(NULL, 0, 0, ":%s NICK %s :%ju",    sendto_server(NULL, 0, 0, ":%s NICK %s :%ju",
140                  target_p->id, parv[2], target_p->tsinfo);                  target_p->id, new_nick, target_p->tsinfo);
141    hash_del_client(target_p);    hash_del_client(target_p);
142    strlcpy(target_p->name, parv[2], sizeof(target_p->name));    strlcpy(target_p->name, new_nick, sizeof(target_p->name));
143    hash_add_client(target_p);    hash_add_client(target_p);
144    
145    watch_check_hash(target_p, RPL_LOGON);    watch_check_hash(target_p, RPL_LOGON);

Legend:
Removed from v.7853  
changed lines
  Added in v.7854

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28