Exemplo n.º 1
0
/*
 * Set the room topic
 */
void
set_topic(UR_OBJECT user, char *inpstr)
{
  RM_OBJECT rm;
  const char *name;

  rm = user->room;
  if (word_count < 2) {
    if (!*rm->topic) {
      write_user(user, "No topic has been set yet.\n");
      return;
    }
    vwrite_user(user, "The current topic is: %s\n", rm->topic);
    return;
  }
  if (strlen(inpstr) > TOPIC_LEN) {
    write_user(user, "Topic too long.\n");
    return;
  }
  switch (amsys->ban_swearing) {
  case SBMAX:
    if (contains_swearing(inpstr)) {
      write_user(user, noswearing);
      return;
    }
    break;
  case SBMIN:
    if (!is_personal_room(user->room)) {
      inpstr = censor_swear_words(inpstr);
    }
    break;
  case SBOFF:
  default:
    /* do nothing as ban_swearing is off */
    break;
  }
  vwrite_user(user, "Topic set to: %s\n", inpstr);
  name = user->vis ? user->recap : invisname;
  vwrite_room_except(rm, user, "%s~RS has set the topic to: %s\n", name,
                     inpstr);
  strcpy(rm->topic, inpstr);
}
Exemplo n.º 2
0
/*
 * put speech in a music notes
 */
void
sing_it(UR_OBJECT user, char *inpstr)
{
#if !!0
    static const char usage[] = "Usage: sing [<text>]\n";
#endif
    const char *name;

    /* FIXME: Use sentinel other JAILED */
    if (user->muzzled != JAILED) {
        write_user(user, "You are muzzled, you cannot sing.\n");
        return;
    }
    switch (amsys->ban_swearing) {
    case SBMAX:
        if (contains_swearing(inpstr)) {
            write_user(user, noswearing);
            return;
        }
        break;
    case SBMIN:
        if (!is_private_room(user->room)) {
            inpstr = censor_swear_words(inpstr);
        }
        break;
    case SBOFF:
    default:
        /* do nothing as ban_swearing is off */
        break;
    }
    if (!user->vis) {
        write_monitor(user, user->room, 0);
    }
    name = user->vis ? user->recap : invisname;
    if (word_count < 2) {
        sprintf(text, "%s~RS sings a tune...BADLY!\n", name);
    } else {
        sprintf(text, "%s~RS sings o/~ %s~RS o/~\n", name, inpstr);
    }
    record(user->room, text);
    write_room(user->room, text);
}
Exemplo n.º 3
0
Arquivo: fonts.c Projeto: Lopo/Lotos
void figlet(UR_OBJECT user, char *inpstr, int typ)
{
	UR_OBJECT u=NULL;
	RM_OBJECT rm=NULL;
	long c;
	int i=0, row, wordbreakmode, char_not_added;
	char *p=inpstr, *name;
	fcharnode *fclsave;
	char fontname[256]="standard";

	set_crash();
	if (user->muzzled) {
		write_user(user, "Si muzzled, nemozes bannerovat\n");
		return;
		}
	if (word_count<2) {
		write_user(user,"Pozri si najprv help ...\n");
		return;
		}
	if (!strcmp(inpstr, "/l")) {
		show_file(user, FONTLIST);
		return;
		}
	if (typ==0) rm=user->room;
	if (typ==1) {
		if (word_count<3) {
			write_usage(user, "tbanner /<user> [-<font>] text");
			return;
			}
		/* Check to see if a username is specified */
		i=0;
		if (*p=='/') {
			/* Get size of font name */
			while (*(p+i)!=' ') {
				i++;
				if (i==100) break;
				}
			strncpy(text, p+1, i);
			*(text+i-1)='\0';
			name=text;
			p=p+i+1;
			}
		else {
			write_usage(user, "tbanner /<user> [-<font>] text");
			return;
			}
		if ((u=get_user_name(user, name))==NULL) {
			write_user(user, notloggedon);
			return;
			}
		if ((check_igusers(u,user))!=-1
		     && (user->level<GOD
			 || user->level<u->level)) {
			vwrite_user(user,"%s~RS is ignoring tells from you.\n",u->recap);
			return;
			}
		if (u->ignore.tells && (user->level<WIZ || u->level>user->level)) {
			vwrite_user(user,"%s~RS is ignoring tells at the moment.\n",u->recap);
			return;
			}
		if (u->ignore.all && (user->level<WIZ || u->level>user->level)) {
			if (u->malloc_start!=NULL) vwrite_user(user,"%s~RS is using the editor at the moment.\n",u->recap);
			else vwrite_user(user,"%s~RS is ignoring everyone at the moment.\n",u->recap);
			return;
			}
#ifdef NETLINKS
		if (u->room==NULL) {
			vwrite_user(user,"%s~RS is offsite and would not be able to reply to you.\n",u->recap);
			return;
			}
#endif
		if (u->afk) {
			if (u->afk_mesg[0]) vwrite_user(user,"%s~RS is ~FRAFK~RS, message is: %s\n",u->recap,u->afk_mesg);
			else vwrite_user(user,"%s~RS is ~FRAFK~RS at the moment.\n",u->recap);
			write_user(user,"Sending message to their afk review buffer.\n");
			}
		if (u->editing) {
			vwrite_user(user,"%s~RS is in ~FTEDIT~RS mode at the moment (using the line editor).\n",u->recap);
			write_user(user,"Sending message to their edit review buffer.\n");
			}
		}

	/* Check to see if a font is specified */
	i=0;
	if (*p=='-') {
		/* Get size of font name */
		while (*(p+i)!=' ') {
			i++;
			if (i==100) break;
			}
		strncpy(fontname, p+1, i);
		*(fontname+i-1)='\0';
		p=p+i+1;

		if ((word_count<3 && typ!=1)
		    || (word_count<4 && typ==1)
		    ) {
			write_user(user,"Co zabannerovat ?\n");
			return;
			}
		}

	if (amsys->ban_swearing && contains_swearing(p) && user->level<MIN_LEV_NOSWR) {
		switch(amsys->ban_swearing) {
			case SBMIN:
				p=censor_swear_words(p);
				break;
			case SBMAX:
				write_user(user,noswearing);
				return;
			default : break; /* do nothing as ban_swearing is off */
			}
		}

	justification = 0;
	right2left = -1;

	outputwidth = 80;

	outlinelenlimit = outputwidth-1;

	if ((i=readfont(fontname))==-1) {
		sprintf(text,"Nemozem nahrat font %s\n",fontname);
		write_user(user,text);
		return;
		}

	name=invisname;
	if ((typ==1 && u->level>=user->level) || user->vis) name=user->name;

	write_text_figlet(user, u, rm, p, name, fontname);

	/* Line alloc... */
	outline = (char**)myalloc(sizeof(char*)*charheight);
	for (row=0;row<charheight;row++) {
		outline[row] = (char*)myalloc(sizeof(char)*(outlinelenlimit+1));
		}
	inchrlinelenlimit = outputwidth*4+100;
	inchrline = (long*)myalloc(sizeof(long)*(inchrlinelenlimit+1));
	fclearline();
	wordbreakmode = 0;

	while (*p) { 
		c=*p;
		p=p+1;
  
		if (isascii(c) && isspace(c)) {
			c = (c=='\t' || c==' ') ? ' ' : '\n';
			}

		if ( (c>'\0' && c<' ' && c!='\n' ) || c==127) continue;

		/*
		Note: The following code is complex and thoroughly tested.
		Be careful when modifying!
		*/

		do {
			char_not_added = 0;

			if (wordbreakmode== -1) {
				if (c==' ') break;
				else if (c=='\n') {
					wordbreakmode = 0;
					break;
					}
				wordbreakmode = 0;
				}

			if (c=='\n') {
				printline(user, u, rm);
				wordbreakmode = 0;
				}
			else if (addchar(c)) {
				if (c!=' ') wordbreakmode = (wordbreakmode>=2)?3:1;
				else wordbreakmode = (wordbreakmode>0)?2:0;
				}
			else if (outlinelen==0) {
				for (i=0;i<charheight;i++) {
					if (right2left && outputwidth>1)
						putstring(user, u, rm, currchar[i]+MYSTRLEN(currchar[i])-outlinelenlimit);
					else
						putstring(user, u, rm, currchar[i]);
					}
				wordbreakmode = -1;
				}
    
			else if (c==' ') {
				if (wordbreakmode==2) splitline(user, u, rm);
				else printline(user, u, rm);
				wordbreakmode = -1;
				}
			else {
				if (wordbreakmode>=2) splitline(user, u, rm);
				else printline(user, u, rm);
				wordbreakmode = (wordbreakmode==3)?1:0;
				char_not_added = 1;
				}
			} while (char_not_added);
		}
	if (outlinelen!=0) printline(user, u, rm);

	/* Free up memory... */
	free(inchrline);
	for (row=0;row<charheight;row++)
		free(outline[row]);
	free(outline);
	/* Free up font memory... */
	do {
		/* Save pointer to next node */
		fclsave=fcharlist->next;
		/* Free memory used by this node */
		for (row=0;row<charheight;row++)
			free(fcharlist->thechar[row]);
		free(fcharlist->thechar);
		free(fcharlist);
		fcharlist=fclsave;
		} while (fclsave!=NULL);
	return;
}