Пример #1
0
BOOL CALLBACK Dlgproc3(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case IDC_BUTTON1:
					IsBotting = !IsBotting;				
					if (IsBotting)
						StartBot();
					else
						StopBot();		
					break;

				case IDC_CHECK1:
					PickItems = !PickItems;
					if (PickItems)
						EnableWindow(GetDlgItem(hWnd, IDC_CHECK2), true);
					else
						EnableWindow(GetDlgItem(hWnd, IDC_CHECK2), false);
					break;

				case IDC_CHECK2:
					DoSellItems = !DoSellItems;
					break;

				case IDC_CHECK3:
					DoRepairEquipment = !DoRepairEquipment;
					break;

				case IDC_CHECK4:
					UseOnlySkills = !UseOnlySkills;
					break;

				case IDC_BUTTON4:
					ClearListBox(GetDlgItem(hWnd, IDC_LIST2));
					char c[100];
					DWORD Count = SendMessage(GetDlgItem(hWnd, IDC_LIST1), LB_GETCOUNT, 0, 0);
					if ((Count != 0) && (Count != LB_ERR))
					{		
						for (BYTE i = 0; i < Count; i++)
						{
							if (SendMessage(GetDlgItem(hWnd, IDC_LIST1), LB_GETSEL, i, 0) > 0)
							{
								SendMessage(GetDlgItem(hWnd, IDC_LIST1), LB_GETTEXT, i, (LPARAM)c);
								SendMessage(GetDlgItem(hWnd, IDC_LIST2), LB_ADDSTRING, i, (LPARAM)c);
								IsUsingSkill(i, true);
							}
							else
								IsUsingSkill(i, false);
						}
					}
					break;

			}
	}
	return FALSE;
}
Пример #2
0
void
cmd_startbot(CORE_DATA *cd)
{
	if (cd->cmd_argc != 3) {
		RmtMessageFmt(cd->cmd_name, "Usage: %s <type> <arena>", cd->cmd_argv[0]);
		return;
	}

	char *err = StartBot(cd->cmd_argv[1], cd->cmd_argv[2], cd->cmd_name);
	if (err) {
		RmtMessageFmt(cd->cmd_name, "Couldn't start bot: %s", err);
	} else {
		RmtMessageFmt(cd->cmd_name, "Started %s in %s", cd->cmd_argv[1], cd->cmd_argv[2]);
	}
}
Пример #3
0
void CatchKeystrokes(HWND hWnd)
{
	bool KeyIsPressed = false;
	bool Key2IsPressed = false;
	while (true)
	{
		if (GetAsyncKeyState(VK_F5) < 0)
		{
			if (!KeyIsPressed)
			{
				KeyIsPressed = true;

				if (IsDialogVisible)
					ShowWindow(FormHandle, SW_HIDE);
				else
					ShowWindow(FormHandle, SW_SHOW);
				IsDialogVisible = !IsDialogVisible;
			}
		}
		else
			KeyIsPressed = false;

		if (GetAsyncKeyState(VK_F6) < 0)
		{
			if ((!Key2IsPressed) && (BotReady))
			{
				Key2IsPressed = true;

				IsBotting = !IsBotting;				
				if (IsBotting)
					StartBot();
				else
					StopBot();
			}
		}
		else
			Key2IsPressed = false;

		Sleep(1);
	}
}
Пример #4
0
/*
 * Spawns the initial bot process and waits for them all to exit.
 */
int
main(int argc, char *argv[])
{
	char *pythonpath = getenv("PYTHONPATH");
	if (pythonpath) {
		char *str = (char*)xzmalloc(strlen(pythonpath) + strlen(":") + strlen("./libs") + 1);
		sprintf(str, "%s:%s", "./libs", pythonpath);
		setenv("PYTHONPATH", str, 1);
		free(str);
	} else {
		setenv("PYTHONPATH", "./libs", 1);
	}
	Py_Initialize();
	init_opencore();
	PyObject *sysPath = PySys_GetObject("path");
	PyObject *libDir = PyString_FromString(".");
	PyList_Append(sysPath, libDir);
	Py_DECREF(libDir);

	if (pthread_key_create(&g_tls_key, NULL) != 0) {
		Log(OP_SMOD, "Error creating thread-specific storage");
		exit(-1);
	}
	pthread_setspecific(g_tls_key, NULL);

	/* make directories */
	mkdir("files", 0700);

	/* setup packet handlers */
	for (int i = 0; i < 256; ++i) {
		g_pkt_core_handlers[i] = null_handler;
		g_pkt_game_handlers[i] = null_handler;
	}

	g_pkt_core_handlers[0x02] = pkt_handle_core_0x02;
	g_pkt_core_handlers[0x03] = pkt_handle_core_0x03;
	g_pkt_core_handlers[0x04] = pkt_handle_core_0x04;
	g_pkt_core_handlers[0x05] = pkt_handle_core_0x05;
	g_pkt_core_handlers[0x06] = pkt_handle_core_0x06;
	g_pkt_core_handlers[0x07] = pkt_handle_core_0x07;
	g_pkt_core_handlers[0x08] = pkt_handle_core_0x08_0x09;
	g_pkt_core_handlers[0x09] = pkt_handle_core_0x08_0x09;
	g_pkt_core_handlers[0x0A] = pkt_handle_core_0x0A;
	g_pkt_core_handlers[0x0E] = pkt_handle_core_0x0E;

	g_pkt_game_handlers[0x02] = pkt_handle_game_0x02;
	g_pkt_game_handlers[0x03] = pkt_handle_game_0x03;
	g_pkt_game_handlers[0x04] = pkt_handle_game_0x04;
	g_pkt_game_handlers[0x07] = pkt_handle_game_0x07;
	g_pkt_game_handlers[0x06] = pkt_handle_game_0x06;
	g_pkt_game_handlers[0x0A] = pkt_handle_game_0x0A;
	g_pkt_game_handlers[0x0D] = pkt_handle_game_0x0D;
	g_pkt_game_handlers[0x0E] = pkt_handle_game_0x0E;
	g_pkt_game_handlers[0x14] = pkt_handle_game_0x14;
	g_pkt_game_handlers[0x19] = pkt_handle_game_0x19;
	g_pkt_game_handlers[0x1C] = pkt_handle_game_0x1C;
	g_pkt_game_handlers[0x1D] = pkt_handle_game_0x1D;
	g_pkt_game_handlers[0x27] = pkt_handle_game_0x27;
	g_pkt_game_handlers[0x28] = pkt_handle_game_0x28;
	g_pkt_game_handlers[0x29] = pkt_handle_game_0x29;
	g_pkt_game_handlers[0x2E] = pkt_handle_game_0x2E;
	g_pkt_game_handlers[0x2F] = pkt_handle_game_0x2F;
	g_pkt_game_handlers[0x31] = pkt_handle_game_0x31;

	struct utsname uts;
	bzero(&uts, sizeof(struct utsname));
	uname(&uts);
	uint64_t hash = hash_buf(&uts, sizeof(struct utsname));
	g_machineid = gen_valid_mid(hash & 0xFFFFFFFF);
	g_permissionid = hash >> 32;

	load_op_file();

	static const char* const masterconfig = "types/master.conf";

	log_init();
	db_init(masterconfig);
	botman_init();

	/* run the master bot */
	char arenaname[32] = { '\0' };
	config_get_string("login.masterarena", arenaname, sizeof(arenaname), "#master", masterconfig);
	LogFmt(OP_MOD, "Starting master into %s", arenaname);
	char *err = StartBot("master", arenaname, NULL);
	if (err) {
		LogFmt(OP_MOD, "Error starting master bot: %s", err);
		return -1;
	}

	/* become the bot management thread and loop */
	botman_mainloop();

	botman_shutdown();
	db_shutdown();
	log_shutdown();

	pthread_key_delete(g_tls_key);

	Py_Finalize();

	return 0;
}