void send_to_all(char *chan,char *txt,int invis, int incog, long flag)
{
DESCRIPTOR_DATA *d;
char buf[MSL];
BN(buf);
if (IS_NULLSTR(txt))
return;
if (IS_NULLSTR(chan))
snprintf(buf,sizeof(buf),"\n\r%s{x\n\r",txt);
else
snprintf(buf,sizeof(buf),"\n\r%s %s{x\n\r",chan,txt);
for (d = descriptor_list; d ; d = d->next)
{
if (incog > 0)
if (d->character->level < incog)
continue;
if (invis > 0)
if (d->character->level < invis)
continue;
if (d->connected == CON_PLAYING)
{
if (flag > 0)
if (IS_SET(d->character->comm,flag))
continue;
send_to_char(buf,d->character);
}
}
return;
}
void load_quotes(void)
{
FILE *fp;
QUOTE_DATA *pQuote;
char buf[MSL];
int number;
fp = fopen(QUOTE_FILE,"r");
for(number=0;!feof(fp); number++)
{
fgets(buf, MAX_STRING_LENGTH, fp);
CREATE(pQuote,QUOTE_DATA,1);
pQuote->number = number;
pQuote->text = str_dup(buf);
top_quotes++;
pQuote->next = quote_list;
quote_list = pQuote;
}
fclose(fp);
return;
}
void random_quote(void)
{
QUOTE_DATA *quote,*quote_next;
int random=0;
random = (1 + (rand() % top_quotes));
for (quote = quote_list; quote; quote = quote_next)
{
quote_next = quote->next;
if (quote->number == random)
{
send_to_all("{R*{YQuote of the Tick{R*{C",quote->text,0,0,COMM_NOHINT);
break;
}
}
}
random = (1 + ( rand() % top_quotes) );
aaron@beast:~/code/tests> cat test.cpp
#include <iostream>
int main()
{ int random;
random = (1+ (rand(time(0)) % 20 ) );
std::cout << random << std::endl;
return -1;
}
aaron@beast:~/code/tests> ./test
4
aaron@beast:~/code/tests> ./test
4
aaron@beast:~/code/tests> ./test
4
aaron@beast:~/code/tests> ./test
4
aaron@beast:~/code/tests> ./test
4
aaron@beast:~/code/tests> ./test
4
$ cat rnd.c
int main() {
#define top_quotes 50
int i;
for (i=0;i<10;i++) {
int random = (1 + ( rand() % top_quotes) );
printf("%d\n", random);
}
}
$ gcc rnd.c ; ./a
1
34
44
13
30
1
9
3
7
7
example
"this is a quotestring\n\randthis newline"
"…"
etc
but it's not doing a linebreak at the \n\r and I cannot figure out so I'm hoping someone else can help me.