コード例 #1
0
ファイル: texfont.c プロジェクト: luigiScarso/mflua
void
set_tag_code (internal_font_number f, integer c, integer i) {
  integer fixedi;
  charinfo * co;
  if (char_exists(f,c)) {
    /* abs(fix_int(i-7,0)) */
    fixedi = - (i<-7 ? -7 : (i>0 ? 0 : i )) ;
    co = char_info(f,c);
    if (fixedi >= 4) {
      if (char_tag(f,c) == ext_tag) 
	set_charinfo_tag(co,(char_tag(f,c)- ext_tag));
      fixedi = fixedi - 4;
    }
    if (fixedi >= 2) {
      if (char_tag(f,c) == list_tag) 
	set_charinfo_tag(co,(char_tag(f,c)- list_tag));
      fixedi = fixedi - 2;
    };
    if (fixedi >= 1) {
      if (has_lig(f,c)) 
	set_charinfo_ligatures(co,NULL);
      if (has_kern(f,c)) 
	set_charinfo_kerns(co,NULL);
    }
  }
}
コード例 #2
0
ファイル: texfont.c プロジェクト: luigiScarso/mflua
void
dump_font (int f) {
  int i,x;

  set_font_used(f,0);
  font_tables[f]->charinfo_cache = NULL;
  dump_things(*(font_tables[f]), 1);
  dump_string(font_name(f));
  dump_string(font_area(f));
  dump_string(font_filename(f));
  dump_string(font_fullname(f));
  dump_string(font_encodingname(f));
  dump_string(font_cidregistry(f));
  dump_string(font_cidordering(f));

  dump_things(*param_base(f),(font_params(f)+1));

  if (has_left_boundary(f)) {
    dump_int(1);  dump_charinfo(f,left_boundarychar);
  } else {
    dump_int(0);
  }
  if (has_right_boundary(f)) {
    dump_int(1);  dump_charinfo(f,right_boundarychar);
  } else {
    dump_int(0);
  }

  for(i=font_bc(f); i<=font_ec(f); i++) {
    if (char_exists(f,i)) {
      dump_charinfo(f,i);
    }
  }
}
コード例 #3
0
ファイル: texfont.c プロジェクト: luigiScarso/mflua
void 
set_ef_code(internal_font_number f, integer c, integer i) {
  charinfo * co;
  if (char_exists(f,c)) {
    co = char_info(f,c);
	set_charinfo_ef(co,i);
  }
}
コード例 #4
0
ファイル: texfont.c プロジェクト: luigiScarso/mflua
integer
get_tag_code (internal_font_number f, integer c) {
  small_number i;
  if (char_exists(f,c)) {
    i = char_tag(f,c);
    if      (i==lig_tag)   return 1;
    else if (i==list_tag)  return 2;
    else if (i==ext_tag)   return 4;
    else                   return 0;
  }
  return  -1;
}
コード例 #5
0
ファイル: texfont.c プロジェクト: luigiScarso/mflua
void delete_font (integer f) {
  int i;
  charinfo *co;
  assert(f>0);
  if (font_tables[f]!=NULL) {
    set_font_name(f,NULL);
    set_font_filename(f,NULL);
    set_font_fullname(f,NULL);
    set_font_encodingname(f,NULL);
    set_font_area(f,NULL);
    set_font_cidregistry(f,NULL);
    set_font_cidordering(f,NULL);
    set_left_boundary(f,NULL);
    set_right_boundary(f,NULL);
    
    for(i=font_bc(f); i<=font_ec(f); i++) {
      if (char_exists(f,i)) {
		co = char_info(f,i);
		set_charinfo_name(co,NULL);
		set_charinfo_tounicode(co,NULL);
		set_charinfo_packets(co,NULL);
		set_charinfo_ligatures(co,NULL);
		set_charinfo_kerns(co,NULL);
		set_charinfo_extensible(co,0,0,0,0);
      }
    }
	/* free .notdef */
	set_charinfo_name(font_tables[f]->charinfo+0,NULL);
    free(font_tables[f]->charinfo);
    destroy_sa_tree(font_tables[f]->characters);

    free(param_base(f));
    free(font_tables[f]);
    font_tables[f] = NULL;

    if (font_id_maxval==f) {
      font_id_maxval--;
    }
  }
}
コード例 #6
0
ファイル: login.c プロジェクト: sartak/Undertow
void nanny(DESCRIPTOR_DATA *d, char *input)
{
  int i;
  char buf[MAX_STRING_LENGTH];
  DESCRIPTOR_DATA *dt;

  switch(d->state)
  {
    case STATE_GET_NAME:
      if (input[0] == 0)
      {
        sckoutput(d->socket, "Fine, then.\n");
        wipe_descriptor(d);
        return;
      }
      i = check_string(input, 4, 12, 0);
      if (i == 1)
        send_to_descriptor(d, "Your name must have at least 4 letters.\n");
      else if (i == 2)
        send_to_descriptor(d, "Your name can contain at most 12 letters.\n");
      else if (i == 4 || i == 3)
        send_to_descriptor(d, "Your name can contain only letters.\n");
      else
      {
        input[0] = UPPER(input[0]);
        load_account(input, d->acc);
        d->acc->d = d;

        if (d->acc->name[0] == 0)
        {
          check_address(d->ip, d->acc->name);
          if (d->acc->name[0] != 0 && stricmp(input, d->acc->name))
            send_to_descriptor(d, "#RWARNING:#n Your IP is linked to an existing account. It is against the rules to have multiple accounts.\n\n");

          strlcpy(d->acc->name, input, 32);
          snprintf(buf, MAX_STRING_LENGTH, "Are you sure you want the name %s? ", input);
          send_to_descriptor(d, buf);
          d->state = STATE_CONFIRM_NAME;
          return;
        }

        send_to_descriptor(d, "Password? ");
        send_to_descriptor(d, password_on);
        d->state = STATE_GET_PASS;
        return;
      }
      send_to_descriptor(d, "What do you want your account name to be? ");
    break;


    case STATE_GET_PASS:
      send_to_descriptor(d, password_off);

      if (!strcmp(d->acc->password, input))
      {
        /* check to see if someone else is logged in under this account */
        for (dt = dhead; dt; dt = dt->next)
        {
          if (dt == d || dt->acc == NULL)
            continue;

          if (!stricmp(d->acc->name, dt->acc->name))
          {
            /* d = new connection, dt = old */
            if (dt->socket > 0 && dt->state != STATE_LINKDEAD)
            {
              sckoutput(dt->socket, "\n\nYou have been kicked off.\n");
              close(dt->socket);
            }

            dt->socket = d->socket;
            d->socket = -1; /* this is mandatory because wipe_descriptor closes d->socket */
            wipe_descriptor(d);
            d = dt;

            if (d->state != STATE_PLAYING && d->state != STATE_LINKDEAD)
              send_to_descriptor(d, "\nYou have kicked someone off while they were logging in. Sending you to the account menu.\n");
            else
            {
              destroy_all_events(d->acc->ch, EVENT_LINKDEAD);
              setup_char_events(d->acc->ch);
              d->acc->ch->idle = 0;
              syslog("RECONNECT", "%s (on %s@%s) has reconnected.", d->acc->ch->name, d->acc->name, d->ip);
              d->state = STATE_PLAYING;
              send_to_descriptor(d, "\n#RReconnected.#n\n");
              return;
            }
          }
        }

        syslog("LOGIN", "%s@%s has logged in.", d->acc->name, d->ip);
        d->state = STATE_ACCT_MENU;
        d->acc->logins++;
        save_account(d->acc);
        show_account_menu(d, 0);
        snprintf(buf, MAX_STRING_LENGTH, "#1[#2Last connection from #R%s#2 at #R%s#2.#1]\n", d->acc->lasthost, d->acc->lasttime);
        save_address(d);
        send_to_descriptor(d, buf);
        if (d->acc->failed == 1)
          snprintf(buf, MAX_STRING_LENGTH, "#1[#RWARNING:#2 1 failed login attempt since your last connection.#1]\n");
        else if (d->acc->failed > 1)
          snprintf(buf, MAX_STRING_LENGTH, "#1[#RWARNING:#2 %d failed login attempts since your last connection.#1]\n", d->acc->failed);
        if (d->acc->failed > 0)
        {
          send_to_descriptor(d, buf);
          d->acc->failed = 0;
          save_account(d->acc);
        }
        send_to_descriptor(d, "#nWhat is your choice? ");
        return;
      }

      sckoutput(d->socket, "Incorrect password. Logging you off...\n");
      syslog("PASSWORD", "%s@%s -- incorrect password! Logged off.", d->acc->name, d->ip);
      d->acc->failed++;
      save_account(d->acc);
      wipe_descriptor(d);
    break;

    case STATE_CONFIRM_NAME:
      if (input[0] == 'y' || input[0] == 'Y')
      {
        send_to_descriptor(d, "What do you want your password to be? ");
        syslog("NEW", "New account %s is being created.", d->acc->name);
        d->state = STATE_NEW_PASS;
        send_to_descriptor(d, password_on);
        return;
      }

      send_to_descriptor(d, "Okay. What do you want your name to be? ");
      d->state = STATE_GET_NAME;
    break;

    case STATE_NEW_PASS:
      send_to_descriptor(d, password_off);
      if (input[0] == 0)
      {
        send_to_descriptor(d, "\nWhat do you want your password to be? ");
        send_to_descriptor(d, password_on);
        return;
      }
      i = check_string(input, 4, 12, 1);
      if (i == 1)
        send_to_descriptor(d, "\nYour password must have at least 4 characters.\n");
      else if (i == 2)
        send_to_descriptor(d, "\nYour password can contain at most 12 characters.\n");
      else if (i == 4)
        send_to_descriptor(d, "\nYour password can contain only letters and numbers.\n");
      else
      {
        strlcpy(d->acc->password, input, 32);
        send_to_descriptor(d, "\nPlease retype your password for confirmation. ");
        send_to_descriptor(d, password_on);
        d->state = STATE_CONFIRM_PASS;
        return;
      }
      send_to_descriptor(d, "\nWhat do you want your password to be? ");
      send_to_descriptor(d, password_on);
    break;

    case STATE_CONFIRM_PASS:
      send_to_descriptor(d, password_off);
      if (strcmp(d->acc->password, input))
      {
        send_to_descriptor(d, "\nYour passwords must match exactly.\nWhat do you want your password to be? ");
        d->state = STATE_NEW_PASS;
        d->acc->password[0] = 0;
        send_to_descriptor(d, password_on);
        return;
      }

      send_to_descriptor(d, "\nDo you want ANSI color? ");
      d->state = STATE_GET_ANSI;
    break;

    case STATE_GET_ANSI:
      d->acc->aflags = 0;
      if (input[0] == 'y' || input[0] == 'Y')
        SET_BIT(d->acc->aflags, AFLAG_ANSI);
      else if (input[0] == 'n' || input[0] == 'N')
        ;
      else
      {
        send_to_descriptor(d, "Please type yes or no.\nDo you want ANSI color? ");
        return;
      }

      for (dt = dhead; dt; dt = dt->next)
      {
        if (dt == d)
          continue;

        if (!stricmp(d->acc->name, dt->acc->name) && (dt->state > STATE_GET_PASS || dt->state < STATE_CONFIRM_NAME))
        {
          sckoutput(d->socket, "You have been kicked off.\n");
          wipe_descriptor(d);
          return;
        }
      }

      d->acc->logins = 1;
      d->acc->changes = time(NULL);
      strlcpy(d->acc->email, "Unset", 128);
      d->state = STATE_ACCT_MENU;
      log_time(d->acc->firsttime);
      save_address(d);
      show_account_menu(d, 1);
      save_account(d->acc);
    break;

    case STATE_ACCT_MENU:
      switch (input[0])
      {
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
          i = atoi(input);
          if (i > d->acc->charcount)
          {
            send_to_descriptor(d, "Unknown option.\nWhat is your choice? ");
            return;
          }
          if (d->acc->status[i - 1] == CHSTATUS_DELETED)
          {
            send_to_descriptor(d, "You are unable to log onto that player.\nWhat is your choice? ");
            return;
          }

          {
            d->acc->ch = load_character(d->acc, d->acc->character[i - 1]);
            d->acc->ch->acc = d->acc;
            d->acc->ch->d = d;
            setup_char_events(d->acc->ch);
            d->state = STATE_PLAYING;
            d->acc->cur_char = i - 1;
            ++d->acc->chlogins[i - 1];
            destroy_d_events(d, EVENT_LOGINIDLE);

            if (d->acc->ch->level >= LEVEL_IMMORTAL)
              d->acc->status[i - 1] = CHSTATUS_IMMORTAL;

            if (!IS_SET(d->acc->ch->cflags, CFLAG_OLDPLAYER))
            {
              syslog("LOGIN", "%s (on %s@%s) is now playing for the first time!", d->acc->ch->name, d->acc->name, d->ip);
              login_msg_new(d->acc->ch);
              SET_BIT(d->acc->ch->cflags, CFLAG_OLDPLAYER);
              if (IS_SET(d->acc->ch->cflags, CFLAG_HARDCORE))
                d->acc->ch->plane = PLANE_HNEWBIE;
              else
                d->acc->ch->plane = PLANE_NEWBIE;
              d->acc->ch->maxhp = 1000;
              d->acc->ch->maxmove = 1000;
              d->acc->ch->maxmana = 1000;
              d->acc->ch->hp = d->acc->ch->maxhp;
              d->acc->ch->move = d->acc->ch->maxmove;
              d->acc->ch->mana = d->acc->ch->maxmana;
              d->acc->ch->level = LEVEL_MORTAL;
              d->acc->ch->sightradius = 5; /* pwipe: increase this to 50 */
              strlcpy(d->acc->ch->prompt, "#1[#2%pP#1] #1[#2%h#1/#2%HH %m#1/#2%MM %v#1/#2%VV#1]#n> ", 256);
              send_to_char(d->acc->ch, "\nWelcome to Undertow. This is a completely custom MUD. We recommend that you read #RHELP NEWBIE#n.\n");
            }
            else
            {
              syslog("LOGIN", "%s (on %s@%s) is now playing.", d->acc->ch->name, d->acc->name, d->ip);
              login_msg(d->acc->ch);
              do_look(d->acc->ch, "");
            }

            save_account(d->acc);
          }
        break;

        case 'r':
        case 'R':
          if (new_changes(d->acc) == 0)
          {
            send_to_descriptor(d, "There are no new changes.\nWhat is your choice? ");
            return;
          }
          show_changes(d->acc, -1);
          send_to_descriptor(d, "\n#nWhat is your choice? ");
        break;

        case 'c':
        case 'C':
          d->state = STATE_CONFIG_MENU;
          show_account_settings(d);
        break;

        case 's':
        case 'S':
          send_who(d);
          send_to_descriptor(d, "#nWhat is your choice? ");
        break;

        case 'n':
        case 'N':
          if (d->acc->charcount >= MAX_CHARS_PER_ACCOUNT)
          {
            send_to_descriptor(d, "You have met your maximum amount of characters for this account.\nWhat is your choice?");
            return;
          }

          d->state = STATE_NEW_CHAR;
          send_to_descriptor(d, "What do you want your name to be? ");
        break;

        case 'd':
        case 'D':
          if (d->acc->charcount == 0)
          {
            send_to_descriptor(d, "You have no characters to delete.\nWhat is your choice? ");
            return;
          }

          show_delete_menu(d);
          d->state = STATE_DELETE_CHAR;
        break;

        case 'q':
        case 'Q':
          save_account(d->acc);
          syslog("QUIT", "%s@%s quit at the login screen.", d->acc->name, d->ip);
          sckoutput(d->socket, "Goodbye.\n");

          wipe_descriptor(d);
        break;

        case '\0':
          show_account_menu(d, 1);
        break;

        default:
          send_to_descriptor(d, "Unknown option.\nWhat is your choice? ");
        break;
      }
    break;

    case STATE_CONFIG_MENU:
      switch (input[0])
      {
        case 'r':
        case 'R':
          d->state = STATE_ACCT_MENU;
          show_account_menu(d, 1);
        break;

        case 'a':
        case 'A':
          TOGGLE_BIT(d->acc->aflags, AFLAG_ANSI);
          if (IS_SET(d->acc->aflags, AFLAG_ANSI))
          {
            if (IS_SET(d->acc->aflags, AFLAG_ANSI_SPARSE))
              send_to_descriptor(d, "Your prompts will now be colored. If you want full color, turn Full ANSI Color on.\nWhat is your choice? ");
            else
              send_to_descriptor(d, "Welcome to the wonderful world of #Rc#Yo#Gl#Co#Mr#n!\nWhat is your choice? ");
          }
          else
            send_to_descriptor(d, "ANSI color turned off.\nWhat is your choice? ");
        break;

        case 'f':
        case 'F':
          TOGGLE_BIT(d->acc->aflags, AFLAG_ANSI_SPARSE);
          if (!IS_SET(d->acc->aflags, AFLAG_ANSI))
            send_to_descriptor(d, "You would probably notice a subsequent color level change if you had color on.\nWhat is your choice? ");
          else if (IS_SET(d->acc->aflags, AFLAG_ANSI_SPARSE))
            send_to_descriptor(d, "You will now only see colored prompts.\nWhat is your choice? ");
          else
            send_to_descriptor(d, "You will now see full color.\nWhat is your choice? ");
        break;

        case 'l':
        case 'L':
          TOGGLE_BIT(d->acc->aflags, AFLAG_REPLYLOCK);
          if (IS_SET(d->acc->aflags, AFLAG_REPLYLOCK))
            send_to_descriptor(d, "You will now reply only to the last person to whom you sent a tell.\nWhat is your choice? ");
          else
            send_to_descriptor(d, "You will now reply to the person who most recently sent you a tell.\nWhat is your choice? ");
        break;

        case 'p':
        case 'P':
          TOGGLE_BIT(d->acc->aflags, AFLAG_PUBLIC_EMAIL);
          if (IS_SET(d->acc->aflags, AFLAG_PUBLIC_EMAIL))
            send_to_descriptor(d, "Your email address is now public.\nWhat is your choice? ");
          else
            send_to_descriptor(d, "Your email address is now private.\nWhat is your choice? ");
        break;

        case 'c':
        case 'C':
          d->state = STATE_CHANGE_PASS1;
          send_to_descriptor(d, "What is your current password? ");
        send_to_descriptor(d, password_on);
        break;

        case 'e':
        case 'E':
          d->state = STATE_SET_EMAIL;
          send_to_descriptor(d, "What is your email address? ");
        break;

        case '\0':
          show_account_settings(d);
        break;

        case 'd':
        case 'D':
          SET_BIT(d->acc->aflags, AFLAG_ANSI);
          REMOVE_BIT(d->acc->aflags, AFLAG_ANSI_SPARSE);
          REMOVE_BIT(d->acc->aflags, AFLAG_PUBLIC_EMAIL);
          strlcpy(d->acc->email, "Unset", 128);
          send_to_descriptor(d, "Reverted to default settings.\nWhat is your choice?");
        break;

        default:
          send_to_descriptor(d, "Unknown option.\nWhat is your choice? ");
        break;
      }
    break;

    case STATE_CHANGE_PASS1:
      send_to_descriptor(d, password_off);
      if (input[0] == 0)
      {
        d->state = STATE_CONFIG_MENU;
        send_to_descriptor(d, "\nWhat is your choice? ");
        return;
      }

      if (strcmp(d->acc->password, input))
      {
        send_to_descriptor(d, "\nIncorrect password.\nWhat is your choice? ");
        d->state = STATE_CONFIG_MENU;
        return;
      }

      d->state = STATE_CHANGE_PASS2;
      d->acc->temp[0] = 0;
      send_to_descriptor(d, "\nWhat do you want your new password to be? ");
      send_to_descriptor(d, password_on);
    break;

    case STATE_CHANGE_PASS2:
      send_to_descriptor(d, password_off);
      if (input[0] == 0)
      {
        d->state = STATE_CONFIG_MENU;
        send_to_descriptor(d, "\nWhat is your choice? ");
        return;
      }

      i = check_string(input, 4, 12, 1);
      if (i == 1)
        send_to_descriptor(d, "\nYour password must have at least 4 characters.\n");
      else if (i == 2)
        send_to_descriptor(d, "\nYour password can contain at most 12 characters.\n");
      else if (i == 4)
        send_to_descriptor(d, "\nYour password can contain only letters and numbers.\n");
      else
      {
        strlcpy(d->acc->temp, input, 128);
        send_to_descriptor(d, "\nPlease retype your password for confirmation. ");
        d->state = STATE_CHANGE_PASS3;
        send_to_descriptor(d, password_on);
        return;
      }
      send_to_descriptor(d, "\nWhat do you want your password to be? ");
      send_to_descriptor(d, password_on);
    break;

    case STATE_CHANGE_PASS3:
      send_to_descriptor(d, password_off);
      if (input[0] == 0)
      {
        d->state = STATE_CONFIG_MENU;
        send_to_descriptor(d, "\nWhat is your choice? ");
        return;
      }

      if (strcmp(d->acc->temp, input))
      {
        send_to_descriptor(d, "\nPasswords must match exactly.\nWhat is your choice? ");
        d->state = STATE_CONFIG_MENU;
        return;
      }

      strlcpy(d->acc->password, input, 32);
      send_to_descriptor(d, "\nYour password is now changed.\nWhat is your choice? ");
      d->state = STATE_CONFIG_MENU;
      save_account(d->acc);
    break;

    case STATE_SET_EMAIL:
      i = check_string(input, -1, 47, 0);
      if (i == 2)
        send_to_descriptor(d, "Your email can contain at most 47 characters.\n");
      else if (strlen(input) == 0)
      {
        strlcpy(d->acc->email, "Unset", 128);
        d->state = STATE_CONFIG_MENU;
        send_to_descriptor(d, "Your email address is now unset.\nWhat is your choice? ");
      }
      else
      {
        replace(input, buf, "%", "", MAX_STRING_LENGTH);
        replace(buf, input, "~", "-", MAX_STRING_LENGTH);
        strlcpy(d->acc->email, input, 128);
        d->state = STATE_CONFIG_MENU;
        snprintf(buf, MAX_STRING_LENGTH, "Your email address is now %s.\nWhat is your choice? ", input);
        send_to_descriptor(d, buf);
        return;
      }
      send_to_descriptor(d, "What is your email address? ");
    break;

    case STATE_DELETE_CHAR:
      if (input[0] == 'r' || input[0] == 'R')
      {
        d->state = STATE_ACCT_MENU;
        show_account_menu(d, 1);
        return;
      }
      if (input[0] == 0)
      {
        show_delete_menu(d);
        return;
      }

      i = atoi(input);
      if (i < 1 || i > d->acc->charcount)
        send_to_descriptor(d, "Out of bounds.\nWhich character do you want to delete? ");
      else
      {
        d->acc->name[15] = --i;
        snprintf(buf, MAX_STRING_LENGTH, "Are you sure you want to delete %s?", d->acc->character[i]);
        send_to_descriptor(d, buf);
        d->state = STATE_CONFIRM_DEL;
      }
    break;

    case STATE_CONFIRM_DEL:
      if (input[0] == 'y' || input[0] == 'Y')
      {
        i = d->acc->name[15];
        d->acc->name[15] = 0;
        snprintf(buf, MAX_STRING_LENGTH, "%s has been deleted.\nWhat is your choice? ", d->acc->character[i]);
        send_to_descriptor(d, buf);
        syslog("DELETION", "%s (on %s@%s) has selfdeleted.", d->acc->character[i], d->acc->name, d->ip);
        d->state = STATE_ACCT_MENU;
        d->acc->chtime[i] = 0;
        snprintf(buf, MAX_STRING_LENGTH, "rm -f account/%s.chr", d->acc->character[i]);
        to_lower(buf);
        system(buf);

        d->acc->charcount--;
        while (i < d->acc->charcount)
        {
          strlcpy(d->acc->character[i], d->acc->character[i + 1], 32);
          i++;
        }
        save_account(d->acc);
        return;
      }
      d->state = STATE_ACCT_MENU;
      show_account_menu(d, 1);
    break;

    case STATE_NEW_CHAR:
      i = 0;
      if (input[0] == 0)
      {
        d->state = STATE_ACCT_MENU;
        show_account_menu(d, 1);
        return;
      }

      i = check_string(input, 4, 12, 0);
      if (i == 1)
        send_to_descriptor(d, "Your name must have atleast 4 letters.\n");
      else if (i == 2)
        send_to_descriptor(d, "Your name can contain at most 12 letters.\n");
      else if (i == 4 || i == 3)
        send_to_descriptor(d, "Your name can contain only letters.\n");
      else
      {
        input[0] = UPPER(input[0]);
        for (dt = dhead; dt; dt = dt->next)
          if ((d != dt) && !stricmp(input, dt->acc->character[dt->acc->charcount]))
            i = 1;
        if (i == 0 && char_exists(input))
          i = 1;
        if (i)
        {
          snprintf(buf, MAX_STRING_LENGTH, "The name %s is already taken.\nWhat do you want your name to be? ", input);
          send_to_descriptor(d, buf);
          return;
        }
        strlcpy(d->acc->character[d->acc->charcount], input, 32);
        snprintf(buf, MAX_STRING_LENGTH, "Are you sure you want the name %s? ", input);
        send_to_descriptor(d, buf);
        d->state = STATE_CONFIRM_CHAR;
        return;
      }
      send_to_descriptor(d, "What do you want your name to be? ");
    break;

    case STATE_CONFIRM_CHAR:
      if (input[0] == 'y' || input[0] == 'Y')
      {
        if (d->acc->logins == 1)
        {
          d->state = STATE_ACCT_MENU;
          finish_creation(d, 0);
          return;
        }
        d->state = STATE_GET_HARDCORE;
        send_to_descriptor(d, "Do you want this character to be hardcore (death = deletion)? ");
      }
      else
      {
        d->state = STATE_ACCT_MENU;
        show_account_menu(d, 1);
      }
    break;

    case STATE_GET_HARDCORE:
      finish_creation(d, input[0] == 'y' || input[0] == 'Y');
    break;
  }
}
コード例 #7
0
ファイル: vfpacket.c プロジェクト: luigiScarso/mflua
integer *packet_local_fonts(internal_font_number f, integer *num) {
  int c, cmd, cur_packet_byte, lf, k,l, i;
  integer localfonts[256] = {0};
  integer *lfs;
  charinfo *co;
  
  real_eight_bits *vf_packets;
  k = 0;
  for (c = font_bc(f);c <= font_ec(f);c++) {
    if (char_exists(f,c)) {
      co = get_charinfo(f,c);
      vf_packets = get_charinfo_packets(co);
      if (vf_packets == NULL) 
	continue;
      cur_packet_byte = 0;
      while ((cmd = vf_packets[cur_packet_byte]) != packet_end_code) {
	cur_packet_byte++;
	switch (cmd) {
	case packet_font_code:
	  packet_number(lf);
	  for (l=0;l<k;l++) {
	    if (localfonts[l]==lf) {
	      break;
	    }
	  }
	  if (l==k) {
	    localfonts[k++]=lf;
	  }
	  break;
	case packet_push_code: 
	case packet_pop_code:
	case packet_nop_code:
	  break;
	case packet_char_code: 
	case packet_right_code:
	case packet_down_code:
	case packet_node_code:
	  cur_packet_byte+=4;
	  break;
	case packet_rule_code: 
	  cur_packet_byte+=8;
	  break;
	case packet_special_code:
	  packet_number(i);
	  while (i-- > 0) 
	    (void)do_packet_byte();
	  break;
	default: 
	  pdf_error(maketexstring("vf"), maketexstring("invalid DVI command"));     
	}
      }
    }
  }  
  *num = k;
  if (k>0) {
    lfs = xmalloc (k*sizeof(integer));
    memcpy(lfs,localfonts,k*sizeof(integer));
    return lfs;
  }
  return NULL;
}
コード例 #8
0
ファイル: vfpacket.c プロジェクト: luigiScarso/mflua
void 
do_vf_packet (internal_font_number vf_f, integer c) {
  internal_font_number lf;
  charinfo *co;
  scaled save_cur_h, save_cur_v;
  real_eight_bits *vf_packets;
  integer cur_packet_byte;
  integer cmd, fs_f;
  scaled i;
  unsigned k;
  str_number s;

  packet_cur_s++;
  if (packet_cur_s >= packet_max_recursion)
    overflow_string("max level recursion of virtual fonts", packet_max_recursion);
  save_cur_v = cur_v;
  save_cur_h = cur_h;
  
  lf = 0; /* for -Wall */
  co = get_charinfo(vf_f,c);
  vf_packets = get_charinfo_packets(co);
  if (vf_packets == NULL) {
    packet_cur_s--;
    return ;
  }
  cur_packet_byte = 0;
  fs_f = font_size(vf_f);
  while ((cmd = vf_packets[cur_packet_byte]) != packet_end_code) {
    cur_packet_byte++;
    /*
    if (cmd>packet_end_code) {
      fprintf(stdout, "do_vf_packet(%i,%i) command code = illegal \n", vf_f,c);
    } else {
      fprintf(stdout, "do_vf_packet(%i,%i) command code = %s\n",vf_f, c, packet_command_names[cmd]);
    }
    */
    switch (cmd) {
    case packet_font_code:
      packet_number(lf);
      break;
    case packet_push_code: 
      packet_stack[packet_stack_ptr].stack_h = cur_h;
      packet_stack[packet_stack_ptr].stack_v = cur_v;
      packet_stack_ptr++;
      break;
    case packet_pop_code:
      packet_stack_ptr--;
      cur_h = packet_stack[packet_stack_ptr].stack_h;
      cur_v = packet_stack[packet_stack_ptr].stack_v;
      break;
    case packet_char_code: 
      packet_number(k);
      if (!char_exists(lf,k)) {
	char_warning(lf, k);
      } else {
	output_one_char(lf, k);
      }
      cur_h = cur_h + char_width(lf,k);
      break;
    case packet_rule_code: 
      packet_scaled(rule_ht,fs_f);
      packet_scaled(rule_wd,fs_f);
      if ((rule_wd > 0) && (rule_ht > 0)) {
	pdf_set_rule(cur_h, cur_v, rule_wd, rule_ht);
	cur_h = cur_h + rule_wd;
      }
      break;
    case packet_right_code:
      packet_scaled(i,fs_f);
      cur_h = cur_h + i;
      break;
    case packet_down_code:
	  packet_scaled(i,fs_f);
      cur_v = cur_v + i;
      break;
    case packet_special_code:
      packet_number(k);
      string_room(k);
      while (k > 0) {
		k--;
		append_pool_char(do_packet_byte());
      }
      s = make_string();
      literal(s, scan_special, false);
      flush_str(s);
      break;
	case packet_node_code:
	  packet_number(k);
	  temp_ptr = k; 
	  pdf_hlist_out();
	  break;
    case packet_nop_code:
      break;
    default: 
      pdf_error(maketexstring("vf"), maketexstring("invalid DVI command"));     
    }
  };
  cur_h = save_cur_h;
  cur_v = save_cur_v;
  packet_cur_s--;
}
コード例 #9
0
ファイル: eval.c プロジェクト: syntheticpp/cpptex
void tex::main_control()
	{
	if (every_job != null)
		begin_token_list(every_job, EVERY_JOB_TEXT);
	
	big_switch:
	get_x_token();

   reswitch:
	if (tracing_commands > 0)
		show_cur_cmd_chr();
	
	switch(abs(mode) + cur_cmd) {
		hmode(LETTER):
		hmode(OTHER_CHAR):
		hmode(CHAR_GIVEN):
			goto main_loop;
		
		hmode(CHAR_NUM):
			scan_char_num();
		   cur_chr = cur_val;
		   goto main_loop;
		
		hmode(NO_BOUNDARY):
			get_x_token();
		   if (cur_cmd == LETTER || cur_cmd == OTHER_CHAR
				 || cur_cmd == CHAR_GIVEN || cur_cmd == CHAR_NUM) {
				cancel_boundary = TRUE;
				}
			goto reswitch;

		hmode(SPACER):
			if (space_factor == 1000) {
				goto append_normal_space;
				} 
			else {
				app_space();
				}
		   break;
	
	hmode(EX_SPACE):
	mmode(EX_SPACE):
		goto append_normal_space;
	
	any_mode(RELAX):
	vmode(SPACER):
	mmode(SPACER):
	mmode(NO_BOUNDARY):
		break;
	
	any_mode(IGNORE_SPACES):
		get_nbx_token();
		goto reswitch;

	vmode(STOP):
		if (its_all_over())
			return;
		break;

	any_mode(LAST_ITEM):
	any_mode(MAC_PARAM):
	non_math(EQ_NO):
	vmode(VMOVE):
	hmode(HMOVE):
	mmode(HMOVE):
	vmode(VADJUST):
	vmode(ITAL_CORR):
		report_illegal_case();
		break;

	non_math(SUP_MARK):
	non_math(SUB_MARK):
	non_math(MATH_CHAR_NUM):
	non_math(MATH_GIVEN):
	non_math(MATH_COMP):
	non_math(DELIM_NUM):
	non_math(LEFT_RIGHT):
	non_math(ABOVE):
	non_math(RADICAL):
	non_math(MATH_STYLE):
	non_math(MATH_CHOICE):
	non_math(VCENTER):
	non_math(NON_SCRIPT):
	non_math(MKERN):
	non_math(LIMIT_SWITCH):
	non_math(MSKIP):
	non_math(MATH_ACCENT):
	mmode(ENDV):
	mmode(PAR_END):
	mmode(STOP):
	mmode(VSKIP):
	mmode(UN_VBOX):
	mmode(VALIGN):
	mmode(HRULE):
		insert_dollar_sign();
		break;
	
	vmode(HRULE):
	hmode(VRULE):
	mmode(VRULE):
		tail_append(scan_rule_spec());
		if (abs(mode) == VMODE)
			prev_depth = IGNORE_DEPTH;
		else if (abs(mode) == HMODE)
			space_factor = 1000;
		break;
	
	vmode(VSKIP):
	hmode(HSKIP):
	mmode(HSKIP):
	mmode(MSKIP):
		append_glue();
		break;
	
	any_mode(KERN):
	mmode(MKERN):
		append_kern();
		break;
	
	non_math(LEFT_BRACE):
		new_save_level(SIMPLE_GROUP);
		break;

	any_mode(BEGIN_GROUP):
		new_save_level(SEMI_SIMPLE_GROUP);
		break;

	any_mode(END_GROUP):
		if (cur_group == SEMI_SIMPLE_GROUP) {
			unsave();
		} else {
			off_save();
		}
		break;
	
	any_mode(RIGHT_BRACE):
		handle_right_brace();
		break;

	vmode(HMOVE):
	hmode(VMOVE):
	mmode(VMOVE): {
		int	t;

		t = cur_chr;
		scan_normal_dimen();
		if (t == 0) {
			scan_box(cur_val);
		} else {
			scan_box(-cur_val);
		}
		break;
	}
	any_mode(LEADER_SHIP):
		scan_box(LEADER_FLAG + cur_chr - A_LEADERS);
		break;
	
	any_mode(MAKE_BOX):
		begin_box(0);
		break;

	vmode(START_PAR):
		new_graf(cur_chr > 0);
		break;
	
	vmode(LETTER):
	vmode(OTHER_CHAR):
	vmode(CHAR_NUM):
	vmode(CHAR_GIVEN):
	vmode(MATH_SHIFT):
	vmode(UN_HBOX):
	vmode(VRULE):
	vmode(ACCENT):
	vmode(DISCRETIONARY):
	vmode(HSKIP):
	vmode(VALIGN):
	vmode(EX_SPACE):
	vmode(NO_BOUNDARY):
		back_input();
		new_graf(TRUE);
		break;
	
	hmode(START_PAR):
	mmode(START_PAR):
		indent_in_hmode();
		break;
	
	vmode(PAR_END):
		normal_paragraph();
		if (mode > 0)
			build_page();
		break;

	hmode(PAR_END):
		if (align_state < 0)
			off_save();
		end_graf();
		if (mode == VMODE)	
			build_page();
		break;
	
	hmode(STOP):
	hmode(VSKIP):
	hmode(HRULE):
	hmode(UN_VBOX):
	hmode(HALIGN):
		head_for_vmode();
		break;
	
	any_mode(INSERT):
	hmode(VADJUST):
	mmode(VADJUST):
		begin_insert_or_adjust();
		break;
	
	any_mode(MARK):
		make_mark();
		break;
	
	any_mode(BREAK_PENALTY):
		append_penalty();
		break;
	
	any_mode(REMOVE_ITEM):
		delete_last();
		break;
	
	vmode(UN_VBOX):
	hmode(UN_HBOX):
	mmode(UN_HBOX):
		unpackage();
		break;
	
	hmode(ITAL_CORR):
		append_italic_correction();
		break;
	
	mmode(ITAL_CORR):
		tail_append(new_kern(0));
		break;

	hmode(DISCRETIONARY):
	mmode(DISCRETIONARY):
		append_discretionary();
		break;
	
	hmode(ACCENT):
		make_accent();
		break;
	
	any_mode(CAR_RET):
	any_mode(TAB_MARK):
		align_error();
		break;

	any_mode(NO_ALIGN):
		no_align_error();
		break;
	
	any_mode(OMIT):
		omit_error();
		break;

	vmode(HALIGN):
	hmode(VALIGN):
		init_align();
		break;
	
	mmode(HALIGN):
		if (privileged()) {
			if (cur_group == MATH_SHIFT_GROUP) {
				init_align();
			} else {
				off_save();
			}
		}
		break;

	vmode(ENDV):
	hmode(ENDV):
		do_endv();
		break;
	
	any_mode(END_CS_NAME):
		cs_error();
		break;

	hmode(MATH_SHIFT):
		init_math();
		break;
	
	mmode(EQ_NO):
		if (privileged()) {
			if (cur_group == MATH_SHIFT_GROUP) {
				start_eq_no();
			} else {
				off_save();
			}
		}
		break;
	
	mmode(LEFT_BRACE):
		tail_append(new_noad());
		back_input();
		scan_math(nucleus(tail));
		break;

	mmode(LETTER):
	mmode(OTHER_CHAR):
	mmode(CHAR_GIVEN):
		if (cur_chr < 256)
			set_math_char(math_code(cur_chr));
		else set_math_char(cur_chr);
		break;
	
	mmode(CHAR_NUM):
		scan_char_num();
		cur_chr = cur_val;
		if (cur_chr < 256)
			set_math_char(math_code(cur_chr));
		else set_math_char(cur_chr);
		break;
	
	mmode(MATH_CHAR_NUM):
		scan_fifteen_bit_int();
		set_math_char(cur_val);
		break;
	
	mmode(MATH_GIVEN):
		set_math_char(cur_chr);
		break;

	mmode(DELIM_NUM):
		scan_twenty_seven_bit_int();
		set_math_char(cur_val / 010000);
		break;
	
	mmode(MATH_COMP):
		tail_append(new_noad());
		type(tail) = cur_chr;
		scan_math(nucleus(tail));
		break;
	
	mmode(LIMIT_SWITCH):
		math_limit_switch();
		break;

	mmode(RADICAL):
		math_radical();
		break;

	mmode(ACCENT):
	mmode(MATH_ACCENT):
		math_ac();
		break;

	mmode(VCENTER):
		scan_spec(VCENTER_GROUP, FALSE);
		normal_paragraph();
		push_nest();
		mode = -VMODE;
		prev_depth = IGNORE_DEPTH;
		if (every_vbox != null)
			begin_token_list(every_vbox, EVERY_VBOX_TEXT);
		break;
	
	mmode(MATH_STYLE):
		tail_append(new_style(cur_chr));
		break;
	
	mmode(NON_SCRIPT):
		tail_append(new_glue(zero_glue));
		subtype(tail) = COND_MATH_GLUE;
		break;
	
	mmode(MATH_CHOICE):
		append_choices();
		break;

	mmode(SUB_MARK):
	mmode(SUP_MARK):
		sub_sup();
		break;
	
	mmode(ABOVE):
		math_fraction();
		break;
	
	mmode(LEFT_RIGHT):
		math_left_right();
		break;

	mmode(MATH_SHIFT):
		if (cur_group == MATH_SHIFT_GROUP) {
			after_math();
		} else {
			off_save();
		}
		break;

	any_mode(AFTER_ASSIGNMENT):
		get_token();
		after_token = cur_tok;
		break;
	
	any_mode(AFTER_GROUP):
		get_token();
		save_for_after(cur_tok);
		break;

	any_mode(IN_STREAM):
		clopen_stream();
		break;

	any_mode(MESSAGE):
		issue_message();
		break;
	
	any_mode(CASE_SHIFT):
		shift_case();
		break;
	
	any_mode(XRAY):
		show_whatever();
		break;
	
	any_mode(EXTENSION):
		do_extension();
		break;
	
	default:
		prefixed_command();
		break;
	}
	goto big_switch;

#define adjust_space_factor() \
{ \
	main_s = sf_code(cur_chr); \
	if (main_s == 1000) { \
		space_factor = 1000; \
	} else if (main_s < 1000) { \
		if (main_s > 0) { \
			space_factor = main_s; \
		} \
	} else if (space_factor < 1000) { \
		space_factor = 1000; \
	} else { \
		space_factor = main_s; \
	} \
}
		
main_loop:
	adjust_space_factor();
	main_f = cur_font;
	bchar = font_bchar(main_f);
	false_bchar = font_false_bchar(main_f);
	if (mode > 0 && language != clang)
		fix_language();
	fast_new_avail(lig_stack);
	font(lig_stack) = main_f;
	character(lig_stack) = cur_l = cur_chr;
	cur_q = tail;
	if (cancel_boundary) {
		cancel_boundary = FALSE;
		main_k = NON_ADDRESS;
	} else {
		main_k = bchar_label(main_f);
	}
	if (main_k == NON_ADDRESS)
		goto main_loop_move_2;
	cur_r = cur_l;
	cur_l = NON_CHAR;
	goto main_lig_loop_1;

#define pack_lig(RT_HIT) \
{ \
	main_p = new_ligature(main_f, cur_l, link(cur_q)); \
	if (lft_hit) { \
		subtype(main_p) = 2; \
		lft_hit = FALSE; \
	} \
	if (RT_HIT && lig_stack == null) { \
		incr(subtype(main_p)); \
		rt_hit = FALSE; \
	} \
	tail = link(cur_q) = main_p; \
	ligature_present = FALSE; \
}

#define wrapup(RT_HIT) \
{ \
	if (cur_l < NON_CHAR) { \
		if (character(tail) == hyphen_char(main_f) \
		&& link(cur_q) != null) \
			ins_disc = TRUE; \
		if (ligature_present) \
			pack_lig(RT_HIT); \
		if (ins_disc) { \
			ins_disc = FALSE; \
			if (mode > 0) \
				tail_append(new_disc()); \
		} \
	} \
}

main_loop_wrapup:
	wrapup(rt_hit);

main_loop_move:
	if (lig_stack == null)
		goto reswitch;
	cur_q = tail;
	cur_l = cur_r;

main_loop_move_1:
	if (!is_char_node(lig_stack))
		goto main_loop_move_lig;

main_loop_move_2:
	if (cur_chr < font_bc(main_f) || cur_chr > font_ec(main_f)) {
		char_warning(main_f, cur_chr);
		free_avail(lig_stack);
		goto big_switch;
	}
	main_i = char_info(main_f, cur_l);
	if (!char_exists(main_i)) {
		char_warning(main_f, cur_chr);
		free_avail(lig_stack);
		goto big_switch;
	}
	tail_append(lig_stack);

main_loop_lookahead:
	get_next();
	if (cur_cmd == LETTER
	|| cur_cmd == OTHER_CHAR
	|| cur_cmd == CHAR_GIVEN) {
		goto main_loop_lookahead_1;
	}
	x_token();
	if (cur_cmd == LETTER
	|| cur_cmd == OTHER_CHAR
	|| cur_cmd == CHAR_GIVEN) {
		goto main_loop_lookahead_1;
	}
	if (cur_cmd == CHAR_NUM) {
		scan_char_num();
		cur_chr = cur_val;
		goto main_loop_lookahead_1;
	}
	if (cur_cmd == NO_BOUNDARY) {
		bchar = NON_CHAR;
	}
	cur_r = bchar;
	lig_stack = null;
	goto main_lig_loop;

main_loop_lookahead_1:
	adjust_space_factor();
	fast_new_avail(lig_stack);
	font(lig_stack) = main_f;
	character(lig_stack) = cur_r = cur_chr;
	if (cur_r == false_bchar) {
		cur_r = NON_CHAR;
	}

main_lig_loop:
	if (char_tag(main_i) != LIG_TAG) {
		goto main_loop_wrapup;
	}
	main_k = lig_kern_start(main_f, main_i);
	main_j = *main_k;
	if (skip_byte(main_j) <= STOP_FLAG) {
		goto main_lig_loop_2;
	}
	main_k = lig_kern_restart(main_f, main_j);

main_lig_loop_1:
	main_j = *main_k;

main_lig_loop_2:
	if (next_char(main_j) == cur_r
	&& skip_byte(main_j) <= STOP_FLAG) {
		if (op_byte(main_j) >= KERN_FLAG) {
			wrapup(rt_hit);
			tail_append(new_kern(char_kern(main_f, main_j)));
			goto main_loop_move;
		}
		if (cur_l == NON_CHAR) {
			lft_hit = TRUE;
		} else if (lig_stack == null) {
			rt_hit = TRUE;
		}
		if(interrupted) throw std::logic_error("interrupted");
		switch (op_byte(main_j))
		{
		case 1: case 5:
			cur_l = rem_byte(main_j);
			main_i = char_info(main_f, cur_l);
			ligature_present = TRUE;
			break;
			
		case 2: case 6:
			cur_r = rem_byte(main_j);
			if (lig_stack == null) {
				lig_stack = new_lig_item(cur_r);
				bchar = NON_CHAR;
			} else if (is_char_node(lig_stack)) {
				main_p = lig_stack;
				lig_stack = new_lig_item(cur_r);
				lig_ptr(lig_stack) = main_p;
			} else {
				character(lig_stack) = cur_r;
			}
			break;

		case 3:
			cur_r = rem_byte(main_j);
			main_p = lig_stack;
			lig_stack = new_lig_item(cur_r);
			link(lig_stack) = main_p;
			break;

		case 7: case 11:
			wrapup(FALSE);
			cur_q = tail;
			cur_l = rem_byte(main_j);
			main_i = char_info(main_f, cur_l);
			ligature_present = TRUE;
			break;

		default:
			cur_l = rem_byte(main_j);
			ligature_present = TRUE;
			if (lig_stack == null) {
				goto main_loop_wrapup;
			} else {
				goto main_loop_move_1;
			}
			break;
		}
		if (op_byte(main_j) > 4 && op_byte(main_j) != 7)
			goto main_loop_wrapup;
		if (cur_l < NON_CHAR)
			goto main_lig_loop;
		main_k = bchar_label(main_f);
		goto main_lig_loop_1;
	}
	if (skip_byte(main_j) == 0) {
		incr(main_k);
	} else {
		if (skip_byte(main_j) >= STOP_FLAG)
			goto main_loop_wrapup;
		main_k += skip_byte(main_j) + 1;
	}
	goto main_lig_loop_1;

main_loop_move_lig:
	main_p = lig_ptr(lig_stack);
	if (main_p != null) {
		tail_append(main_p);
	}
	main_t = lig_stack;
	lig_stack = link(main_t);
	free_node(main_t, SMALL_NODE_SIZE);
	main_i = char_info(main_f, cur_l);
	ligature_present = TRUE;
	if (lig_stack == null) {
		if (main_p != null) {
			goto main_loop_lookahead;
		} else {
			cur_r = bchar;
		}
	} else {
		cur_r = character(lig_stack);
	}
	goto main_lig_loop;

append_normal_space:
	if (space_skip == zero_glue) {
		main_p = font_glue(cur_font);
		if (main_p == null)
			main_p = find_font_glue(cur_font);
		main_t = new_glue(main_p);
	} else {
		main_t = new_param_glue(SPACE_SKIP_CODE);
	}
	tail_append(main_t);
	goto big_switch;
}