Esempio n. 1
0
static void
set_dyntext(struct creature *ch, dynamic_text_file * dyntext, char *argument)
{

    char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
    int lev;

    two_arguments(argument, arg1, arg2);

    if (!*arg1 || !*arg2) {
        send_to_char(ch, "Dynedit set requires more arguments.\r\n");
        show_dynedit_options(ch);
        return;
    }

    if (is_abbrev(arg1, "level")) {

        lev = atoi(arg2);

        if (lev > GET_LEVEL(ch)) {
            send_to_char(ch,
                "Let's not set it above your own level, shall we?\r\n");
            return;
        }

        dyntext->level = lev;
        send_to_char(ch, "Level set.\r\n");
    } else {
        send_to_char(ch, "Dynedit set valid arguments: level.\r\n");
        return;
    }

    if (save_dyntext_control(dyntext))
        send_to_char(ch,
            "An error occurred while saving the control file.\r\n");
    else
        send_to_char(ch, "Control file saved.\r\n");
}
Esempio n. 2
0
/* Display a nicely formatted map with a legend */
void perform_map( struct char_data *ch, char *argument, bool worldmap )
{
  int size = DEFAULT_MAP_SIZE;
  int centre, x, y, min, max;
  char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH], buf1[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH];
  int count = 0;
  int ew_size=0, ns_size=0;
  int mapshape = MAP_CIRCLE;

  two_arguments( argument, arg1 , arg2 );
  if(*arg1)
  {
    size = atoi(arg1);
  }
  if (*arg2)
  {
    if (is_abbrev(arg2, "normal")) worldmap=FALSE;
    else if (is_abbrev(arg2, "world")) worldmap=TRUE;
    else {
      send_to_char(ch, "Usage: \tymap <distance> [ normal | world ]\tn");
      return;
    }
  }

  if(size<0) {
    size = -size;
    mapshape = MAP_RECTANGLE;
  }
  size = URANGE(1,size,MAX_MAP_SIZE);

  centre = MAX_MAP/2;

  if(worldmap) {
    min = centre - 2*size;
    max = centre + 2*size;
  } else {
    min = centre - size;
    max = centre + size;
  }

  /* Blank the map */
  for (x = 0; x < MAX_MAP; ++x)
      for (y = 0; y < MAX_MAP; ++y)
           map[x][y]= (!(y%2) && !worldmap) ? DOOR_NONE : SECT_EMPTY;

  /* starts the mapping with the centre room */
  MapArea(IN_ROOM(ch), ch, centre, centre, min, max, ns_size/2, ew_size/2, worldmap);

  /* marks the center, where ch is */
  map[centre][centre] = SECT_HERE;

  /* Feel free to put your own MUD name or header in here */
  send_to_char(ch, " \tb--\tB= \tCLuminari Map System \tB=\tb--\tn\r\n"
                   "\tD  .-.__--.,--.__.-.\tn\r\n" );

  count += sprintf(buf + count, "\tn\tn\tn%s Up\\\\", door_info[NUM_DOOR_TYPES + DOOR_UP].disp);
  count += sprintf(buf + count, "\tn\tn\tn%s Down\\\\", door_info[NUM_DOOR_TYPES + DOOR_DOWN].disp);
  count += sprintf(buf + count, "\tn%s You\\\\", map_info[SECT_HERE].disp);
  count += sprintf(buf + count, "\tn%s Inside\\\\", map_info[SECT_INSIDE].disp);
  count += sprintf(buf + count, "\tn%s City\\\\", map_info[SECT_CITY].disp);
  count += sprintf(buf + count, "\tn%s Field\\\\", map_info[SECT_FIELD].disp);
  count += sprintf(buf + count, "\tn%s Forest\\\\", map_info[SECT_FOREST].disp);
  count += sprintf(buf + count, "\tn%s Hills\\\\", map_info[SECT_HILLS].disp);
  count += sprintf(buf + count, "\tn%s Mountain\\\\", map_info[SECT_MOUNTAIN].disp);
  count += sprintf(buf + count, "\tn%s Water\\\\", map_info[SECT_WATER_SWIM].disp);
  count += sprintf(buf + count, "\tn%s Deep Water\\\\", map_info[SECT_WATER_NOSWIM].disp);
  count += sprintf(buf + count, "\tn%s Air\\\\", map_info[SECT_FLYING].disp);
  count += sprintf(buf + count, "\tn%s Underwater\\\\", map_info[SECT_UNDERWATER].disp);
  count += sprintf(buf + count, "\tn%s Zone Entry\\\\", map_info[SECT_ZONE_START].disp);
  count += sprintf(buf + count, "\tn%s Road N-S\\\\", map_info[SECT_ROAD_NS].disp);
  count += sprintf(buf + count, "\tn%s Road E-W\\\\", map_info[SECT_ROAD_EW].disp);
  count += sprintf(buf + count, "\tn%s Intersect\\\\", map_info[SECT_ROAD_INT].disp);
  count += sprintf(buf + count, "\tn%s Desert\\\\", map_info[SECT_DESERT].disp);
  count += sprintf(buf + count, "\tn%s Ocean\\\\", map_info[SECT_OCEAN].disp);
  count += sprintf(buf + count, "\tn%s Marsh\\\\", map_info[SECT_MARSHLAND].disp);
  count += sprintf(buf + count, "\tn%s High Mount\\\\", map_info[SECT_HIGH_MOUNTAIN].disp);
  count += sprintf(buf + count, "\tn%s Planes\\\\", map_info[SECT_PLANES].disp);

  strcpy(buf, strfrmt(buf, LEGEND_WIDTH, CANVAS_HEIGHT + 2, FALSE, TRUE, TRUE));

  /* Start with an empty column */
  strcpy(buf1, strfrmt("",0, CANVAS_HEIGHT + 2, FALSE, FALSE, TRUE));

  /* Paste the legend */
  strcpy(buf2, strpaste(buf1, buf, "\tD | \tn"));

  /* Set up the map */
  memset(buf, ' ', CANVAS_WIDTH);
  count = (CANVAS_WIDTH);
  if(worldmap)
    count += sprintf(buf + count , "\r\n%s", WorldMap(centre, size, mapshape, MAP_NORMAL));
  else
    count += sprintf(buf + count , "\r\n%s", StringMap(centre, size));
  memset(buf + count, ' ', CANVAS_WIDTH);
  strcpy(buf + count + CANVAS_WIDTH, "\r\n");
  /* Paste it on */
  strcpy(buf2, strpaste(buf2, buf, "\tD | \tn"));
  /* Paste on the right border */
  strcpy(buf2, strpaste(buf2, buf1, "  "));
  /* Print it all out */
  send_to_char(ch, "%s", buf2);

  send_to_char(ch, "\tD `.-.__--.,-.__.-.-'\tn\r\n");
  return;
}
Esempio n. 3
0
int main(int argc, char ** argv)
{
	SECTREE_MANAGER	sectree_manager;
	DESC_MANAGER desc_manager;
	CHARACTER_MANAGER char_manager;
	quest::CQuestManager quest_manager; // CHARACTER::Intiailize에서 필요함
	CArenaManager arena_manager;
	CPVPManager pvp_manager;
	LZOManager lzo;

	if (!start(argc, argv))
		return 0;

	signal_timer_disable();

	char buf[256];
	char last_cmd[256];
	char * p;

	bool bEnd = false;

	while (!bEnd && fgets(buf, 256, stdin))
	{
		while ((p = strrchr(buf, '\r'))) *p = '\0';
		while ((p = strrchr(buf, '\n'))) *p = '\0';

		if (buf[0] == '!')
			strlcpy(buf, last_cmd, sizeof(buf));

		strlcpy(last_cmd, buf, sizeof(last_cmd));

		char arg1[64], arg2[64];//, arg3[64], arg4[64];
		const char * line = one_argument(buf, arg1, sizeof(arg1));

		switch (arg1[0])
		{
			case 'a':
				{
					two_arguments(line, arg1, sizeof(arg1), arg2, sizeof(arg2));

					if (!*arg1 || !*arg2)
					{
						printf("Syntax: a <collision data filename> <map directory>\n");
						break;
					}

					ConvertAttribute(arg1, arg2);
					puts("build server_attr done");
				}
				break;

			case 'c':
				{
					one_argument(line, arg1, sizeof(arg1));

					if (!*arg1)
					{
						printf("Syntax: c <filename>\n");
						break;
					}

					ConvertAttribute2(arg1);
				}
				//ReadColorMapRecursive(line);
				break;

			case 'b':
				{
					// Buffer overflow test (must use with valgrind or gdb at least)
                    LPCHARACTER ch = CHARACTER_MANAGER::instance().CreateCharacter("test");

					// 스택에 할당하면 valgrind가 제대로 오류를 잡지 못함
					size_t bufsize = 512 + 1;
					size_t linesize = 1024 + 1;

					if (bufsize > 0 && linesize > 0)
					{
						char *buf = (char *) malloc(bufsize);
						char *line = (char *) malloc(linesize);

						memset(buf, 0, bufsize);
						memset(line, 0, linesize);

						for (size_t i = 0; i < bufsize - 1; ++i)
						{
							buf[i] = '$';
							int linelen = snprintf(line, linesize, "pvp %s", buf);

							if (linelen < 0 || linelen >= (int) linesize)
								linelen = linesize - 1;

							printf("%d %s\n", i, line);
							interpret_command(ch, line, linelen);
						}

						free(buf);
						free(line);
					}
					else
					{
						printf("size error!\n");
						abort();
					}

					printf("Buffer overflow test finished\n");
				}
				break;

			case 'q':
				bEnd = true;
				break;
		}
	}

	thecore_destroy();
	event_destroy();
	return 0;
}