Skip to content

Commit

Permalink
Make tld::motd and tld::rules optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
syzop committed Jun 19, 2022
1 parent 55387a8 commit 1fe6119
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 36 deletions.
12 changes: 0 additions & 12 deletions src/conf.c
Expand Up @@ -4902,18 +4902,6 @@ int _test_tld(ConfigFile *conf, ConfigEntry *ce)
ce->file->filename, ce->line_number, ce->name);
errors++;
}
if (!has_motd)
{
config_error_missing(ce->file->filename, ce->line_number,
"tld::motd");
errors++;
}
if (!has_rules)
{
config_error_missing(ce->file->filename, ce->line_number,
"tld::rules");
errors++;
}
return errors;
}

Expand Down
6 changes: 2 additions & 4 deletions src/modules/botmotd.c
Expand Up @@ -67,11 +67,9 @@ CMD_FUNC(cmd_botmotd)
return;

tld = find_tld(client);

motdline = NULL;
if (tld)
if (tld && tld->botmotd.lines)
motdline = tld->botmotd.lines;
if (!motdline)
else
motdline = botmotd.lines;

if (!motdline)
Expand Down
8 changes: 4 additions & 4 deletions src/modules/motd.c
Expand Up @@ -58,7 +58,7 @@ MOD_UNLOAD()
*/
CMD_FUNC(cmd_motd)
{
ConfigItem_tld *ptr;
ConfigItem_tld *tld;
MOTDFile *themotd;
MOTDLine *motdline;
int svsnofile = 0;
Expand All @@ -73,10 +73,10 @@ CMD_FUNC(cmd_motd)
return;
}

ptr = find_tld(client);
tld = find_tld(client);

if (ptr)
themotd = &ptr->motd;
if (tld && tld->motd.lines)
themotd = &tld->motd;
else
themotd = &motd;

Expand Down
8 changes: 4 additions & 4 deletions src/modules/nick.c
Expand Up @@ -764,7 +764,7 @@ CMD_FUNC(cmd_nick)
void welcome_user(Client *client, TKL *viruschan_tkl)
{
int i;
ConfigItem_tld *tlds;
ConfigItem_tld *tld;
char buf[BUFSIZE];

/* Make creation time the real 'online since' time, excluding registration time.
Expand Down Expand Up @@ -871,11 +871,11 @@ void welcome_user(Client *client, TKL *viruschan_tkl)
}

/* Force the user to join the given chans -- codemastr */
tlds = find_tld(client);
tld = find_tld(client);

if (tlds && !BadPtr(tlds->channel))
if (tld && !BadPtr(tld->channel))
{
char *chans = strdup(tlds->channel);
char *chans = strdup(tld->channel);
const char *args[3] = {
NULL,
chans,
Expand Down
6 changes: 2 additions & 4 deletions src/modules/opermotd.c
Expand Up @@ -67,11 +67,9 @@ CMD_FUNC(cmd_opermotd)
}

tld = find_tld(client);

motdline = NULL;
if (tld)
if (tld && tld->opermotd.lines)
motdline = tld->opermotd.lines;
if (!motdline)
else
motdline = opermotd.lines;

if (!motdline)
Expand Down
13 changes: 5 additions & 8 deletions src/modules/rules.c
Expand Up @@ -58,19 +58,16 @@ MOD_UNLOAD()
*/
CMD_FUNC(cmd_rules)
{
ConfigItem_tld *ptr;
ConfigItem_tld *tld;
MOTDLine *temp;

temp = NULL;

if (hunt_server(client, recv_mtags, "RULES", 1, parc, parv) != HUNTED_ISME)
return;

ptr = find_tld(client);

if (ptr)
temp = ptr->rules.lines;
if (!temp)
tld = find_tld(client);
if (tld && tld->rules.lines)
temp = tld->rules.lines;
else
temp = rules.lines;

if (temp == NULL)
Expand Down

0 comments on commit 1fe6119

Please sign in to comment.