示例#1
0
文件: main.cpp 项目: Rarder44/Server
void destroy()
{
	sys_log(0, "<shutdown> Canceling ReloadSpamEvent...");
	CancelReloadSpamEvent();

	sys_log(0, "<shutdown> regen_free()...");
	regen_free();

	sys_log(0, "<shutdown> Closing sockets...");
	socket_close(tcp_socket);
#ifndef __UDP_BLOCK__
	socket_close(udp_socket);
#endif
	socket_close(p2p_socket);

	sys_log(0, "<shutdown> fdwatch_delete()...");
	fdwatch_delete(main_fdw);

	sys_log(0, "<shutdown> event_destroy()...");
	event_destroy();

	sys_log(0, "<shutdown> CTextFileLoader::DestroySystem()...");
	CTextFileLoader::DestroySystem();

	sys_log(0, "<shutdown> thecore_destroy()...");
	thecore_destroy();
}
示例#2
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;
}