Example #1
0
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
    DebugSpewAlways("Initializing MQ2CustomBinds");

    AddCommand("/custombind",CustomBindCmd,0,0,0);
    // Add commands, macro parameters, hooks, etc.
    // AddCommand("/mycommand",MyCommand);
    // AddParm("$myparm(x)",MyParm);
    // AddXMLFile("MQUI_MyXMLFile.xml");
    // bmMyBenchmark=AddMQ2Benchmark("My Benchmark Name");
}
Example #2
0
// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
    DebugSpewAlways("Shutting down MQ2HUD");
    ClearElements();
    RemoveCommand("/loadhud");
    RemoveCommand("/unloadhud");
    RemoveCommand("/defaulthud");
    RemoveCommand("/backgroundhud");
    RemoveCommand("/classhud");
    RemoveCommand("/zonehud");
    RemoveMQ2Data("HUD");
}
Example #3
0
PLUGIN_API VOID InitializePlugin() 
{ 
    DebugSpewAlways("Initializing MQ2ChatWnd"); 
    // Add commands, macro parameters, hooks, etc. 
    AddCommand("/style",Style,0,1,0); 
    AddCommand("/mqfont",MQChatFont); 
    AddCommand("/mqmin",MQChatMin); 
    AddCommand("/mqclear",MQChatClear); 
    AddMQ2KeyBind("MQ2CHAT",DoMQ2ChatBind); 
    bmStripFirstStmlLines=AddMQ2Benchmark("StripFirstStmlLines"); 
    LoadChatSettings(); 
} 
Example #4
0
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
    DebugSpewAlways("Initializing MQ2Labels");

    // Add commands, macro parameters, hooks, etc.
    //EasyClassDetour(CLabel__Draw,CLabelHook,Draw_Detour,VOID,(VOID),Draw_Trampoline);
    EzDetourwName(CLabel__Draw,&CLabelHook::Draw_Detour,&CLabelHook::Draw_Trampoline,"CLabel__Draw");
    EzDetourwName(CSidlManager__CreateLabel,&CSidlManagerHook::CreateLabel_Detour,&CSidlManagerHook::CreateLabel_Trampoline,"CSidlManager__CreateLabel");
	if (gAnonymize) {
		EzDetourwName(CEverQuest__trimName, &CLabelHook::CEverQuest__trimName_Detour, &CLabelHook::CEverQuest__trimName_Trampoline,"CEverQuest__trimName");
		EzDetourwName(__GetGaugeValueFromEQ, GetGaugeValueFromEQ_Detour, GetGaugeValueFromEQ_Trampoline,"__GetGaugeValueFromEQ");
		EzDetourwName(__GetLabelFromEQ, GetLabelFromEQ_Detour, GetLabelFromEQ_Trampoline,"__GetLabelFromEQ");
		bTrimnames = 1;
	}
}
Example #5
0
// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
    DebugSpewAlways("Shutting down MQ2Labels");
	
    // Remove commands, macro parameters, hooks, etc.
	if (bTrimnames) {
		bTrimnames = 0;
		RemoveDetour(CEverQuest__trimName);
		RemoveDetour(__GetGaugeValueFromEQ);
		RemoveDetour(__GetLabelFromEQ);
	}
    RemoveDetour(CSidlManager__CreateLabel);
    RemoveDetour(CLabel__Draw);
    //RemoveDetour(CGaugeWnd__Draw);
    //RemoveDetour(__GetGaugeValueFromEQ);
}
Example #6
0
PLUGIN_API VOID ShutdownPlugin(VOID)
{
    DebugSpewAlways("Shutting down MQ2EQBugFix");
	RemoveDetour(CDisplay__is3dON);
	if (switchbug) {
		//RemoveDetour(switchbug);
	}
	if (__UpdateDisplay) {
		//RemoveDetour(__UpdateDisplay);
	}
	if (__Reset) {
		RemoveDetour(__Reset);
	}
	#ifdef EQMULETESTINGSTUFF
    //RemoveDetour(startworlddisplayexceptionhandler);
	#endif
}
Example #7
0
// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
    DebugSpewAlways("Shutting down MQ2CustomBinds");
    RemoveCommand("/custombind");
    //SaveCustomBinds();

    for (unsigned long N = 0 ; N < CustomBinds.Size ; N++)
        if (PCUSTOMBIND pBind=CustomBinds[N])
        {
            RemoveMQ2KeyBind(pBind->Name);
        }
        CustomBinds.Cleanup();
        // Remove commands, macro parameters, hooks, etc.
        // RemoveMQ2Benchmark(bmMyBenchmark);
        // RemoveParm("$myparm(x)");
        // RemoveCommand("/mycommand");
        // RemoveXMLFile("MQUI_MyXMLFile.xml");
}
Example #8
0
BOOL Detour_ProcessGameEvents(VOID)
{
	CAutoLock Lock(&gPulseCS);
	int ret = Heartbeat();
#ifdef ISXEQ
	if (!pISInterface->ScriptEngineActive())
		pISInterface->LavishScriptPulse();
#endif
	int ret2 =  Trampoline_ProcessGameEvents();
#ifndef ISXEQ
	if(ret==2 && bPluginCS==0) {
		OutputDebugString("I am loading in ProcessGameEvents");
		//we are loading stuff
		DWORD oldscreenmode = ScreenMode;
		ScreenMode = 3;
		InitializeMQ2Commands();
		InitializeMQ2Windows();
		MQ2MouseHooks(1);
		Sleep(100);
		InitializeMQ2KeyBinds();
		#ifndef ISXEQ
		InitializeMQ2Plugins();
		#endif
		ScreenMode = oldscreenmode;
		SetEvent(hLoadComplete);
	} else if(ret==1) {
		OutputDebugString("I am unloading in ProcessGameEvents");
		//we are unloading stuff
		DWORD oldscreenmode = ScreenMode;
		ScreenMode = 3;
		WriteChatColor(UnloadedString,USERCOLOR_DEFAULT);
		DebugSpewAlways("%s", UnloadedString);
		UnloadMQ2Plugins();
		MQ2Shutdown();
		DebugSpew("Shutdown completed");
		g_Loaded = FALSE;
		ScreenMode = oldscreenmode;
		SetEvent(hUnloadComplete);

	}
#endif
	return ret2;
}
Example #9
0
// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
	if (bzsrchhandle) {
		ReleaseMutex(bzsrchhandle);
		CloseHandle(bzsrchhandle);
		bzsrchhandle = 0;
	}
    DebugSpewAlways("Shutting down MQ2Bzsrch");

    // Remove commands, macro parameters, hooks, etc.
    RemoveDetour(CBazaarSearchWnd__HandleBazaarMsg);
    RemoveMQ2Data("Bazaar");
    //RemoveCommand("/pricecheck");
    RemoveCommand("/mq2bzsrch");
    RemoveCommand("/breset");
    RemoveCommand("/bzsrch");
    delete pBazaarType;
    delete pBazaarItemType;
}
Example #10
0
PLUGIN_API VOID ShutdownPlugin() 
{ 
    DebugSpewAlways("Shutting down MQ2ChatWnd"); 
    while(pPendingChat) 
    { 
        ChatBuffer *pNext=pPendingChat->pNext; 
        delete pPendingChat; 
        pPendingChat=pNext; 
    } 
    pPendingChatTail=0; 
    PendingChatLines=0; 
    // Remove commands, macro parameters, hooks, etc. 
    RemoveCommand("/style"); 
    RemoveCommand("/mqfont"); 
    RemoveCommand("/mqmin"); 
    RemoveCommand("/mqclear"); 
    RemoveMQ2KeyBind("MQ2CHAT"); 
    RemoveMQ2Benchmark(bmStripFirstStmlLines); 
    DestroyChatWnd(); 
} 
Example #11
0
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
    CHAR szBuffer[MAX_STRING] = {0};
    // check for eqw running, and steal its function to check the foreground window if available
    if (EQWhMod=GetModuleHandle("eqw.dll"))
    {
        EQW_GetDisplayWindow=(fEQW_GetDisplayWindow)GetProcAddress(EQWhMod,"EQW_GetDisplayWindow");
    }
    DebugSpewAlways("Initializing MQ2HUD");

    GetPrivateProfileString(HUDSection,"Last","Elements",HUDNames,MAX_STRING,INIFileName);
    HandleINI();

    AddCommand("/defaulthud",DefaultHUD);
    AddCommand("/loadhud",LoadHUD);
    AddCommand("/unloadhud",UnLoadHUD);
    AddCommand("/backgroundhud",BackgroundHUD);
    AddCommand("/classhud",ClassHUD);
    AddCommand("/zonehud",ZoneHUD);
    AddMQ2Data("HUD",dataHUD);
}
Example #12
0
PLUGIN_API VOID InitializePlugin(VOID)
{
	//dont mess with this its work in progress, im sick of the crash that happens if you invoke the UAC dialog while eq is loading
	//basically it makes the render device get lost and then we crash
	//the proper handling would be to detect UAC or device lost and then reset it, but its not done
	//and if it is, its in the wrong place or it misses it
	//also, if the device is lost then we cant simply do d3device->Reset because well... d3device is NULL so that would crash us...
	//something to think more on...
	//8B 44 24 04 8B 0D ?? ?? ?? 10 50 E8 ?? E8 FF FF
	/*MessageBox(NULL, "break in", "eqbugfix", MB_SYSTEMMODAL | MB_OK);
	if (HANDLE eqghandle = GetModuleHandle("EQGraphicsDX9.dll")) {
		
		if (DWORD DeviceReady = _FindPattern((DWORD)eqghandle, 0x150000, drPattern, drMask)) {
			g_bDeviceReady = _GetDWordAt(DeviceReady, 2);
		}
		if (switchbug = _FindPattern((DWORD)eqghandle, 0x150000, lcPattern, lcMask))
		{
			p2DPrimitiveManager = _GetDWordAt(switchbug, 6);
			if (g_ppDrawHandler) {
				if (DWORD addr = *(DWORD*)g_ppDrawHandler) {
					if (DWORD addr2 = *(DWORD*)addr) {
						if (__UpdateDisplay = *(DWORD*)(addr2 + 0xb4)) {
							pRender = _GetDWordAt(__UpdateDisplay, 1);
							//EzDetourwName(__UpdateDisplay, &CDisplay_Hook::UpdateDisplay_Detour , &CDisplay_Hook::UpdateDisplay_Tramp, "UpdateDisplay_Detour");
						}
						if (__Reset = *(DWORD*)(addr2 + 0x40)) {
							EzDetourwName(__Reset, &CDisplay_Hook::Reset_Detour , &CDisplay_Hook::Reset_Tramp, "Reset_Detour");
						}
					}
				}
			}
			//EzDetourwName(switchbug, CachedTextBug_Detour, CachedTextBug_Tramp,"CachedTextBug_Detour");
		}
	}*/
    DebugSpewAlways("Initializing MQ2EQBugFix");
    EzDetourwName(CDisplay__is3dON, &CDisplay_Hook::is_3dON_Detour, &CDisplay_Hook::is_3dON_Trampoline,"CDisplay__is3dON");
    #ifdef EQMULETESTINGSTUFF
	//EzDetourwName(startworlddisplayexceptionhandler, startworddisplayexceptionhandler_Detour, startworddisplayexceptionhandler_Trampoline,"startworlddisplayexceptionhandler");
	#endif
}
Example #13
0
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
	bzsrchhandle = CreateMutex(NULL, FALSE, NULL);
    DebugSpewAlways("Initializing MQ2Bzsrch");

    LoadMQ2Plugin("MQ2ItemDisplay");
    if(HMODULE h = GetModuleHandle("MQ2ItemDisplay.dll")) {
		pg_Item = (ITEMINFO *)GetProcAddress(h, "g_Item");
    } else {
        pg_Item = NULL;
    }
    // Add commands, macro parameters, hooks, etc.
	AddCommand("/bzquery",BZQuery);
    AddCommand("/bzsrch",BzSrchMe);
    AddCommand("/breset",BzSrchMe);
    AddCommand("/mq2bzsrch",MQ2BzSrch);
    //AddCommand("/pricecheck",bzpc);
    AddMQ2Data("Bazaar",dataBazaar);              // cc - added, but not using TLO yet

    EzDetourwName(CBazaarSearchWnd__HandleBazaarMsg,&BzSrchHook::BzDetour,&BzSrchHook::BzTrampoline,"CBazaarSearchWnd__HandleBazaarMsg");
    pBazaarType = new MQ2BazaarType;
    pBazaarItemType = new MQ2BazaarItemType;
}
NavMeshLoader::LoadResult NavMeshLoader::LoadZoneMeshData(const std::shared_ptr<char>& data, DWORD length)
{
	ReadCursor cursor{ data.get(), length };

	//------------------------------------------------------------------------
	// Read the header
	NavMeshSetHeader header;
	if (!FillStructure(cursor, header)) {
		DebugSpewAlways("Failed to read header from mesh file!");
		return CORRUPT;
	}

	if (header.magic != NAVMESHSET_MAGIC) {
		DebugSpewAlways("Header Magic value mismatch!");
		return CORRUPT;
	}
	if (header.version != NAVMESHSET_VERSION) {
		DebugSpewAlways("Header version mismatch!");
		return VERSION_MISMATCH;
	}

	std::unique_ptr<dtNavMesh> navMesh(new dtNavMesh);
	if (!navMesh->init(&header.params)) {
		DebugSpewAlways("Header params are bad!");
		return CORRUPT;
	}

	//------------------------------------------------------------------------
	// Read the tiles
	int passtile = 0, failtile = 0;

	for (int i = 0; i < header.numTiles; ++i)
	{
		NavMeshTileHeader tileHeader;
		if (!FillStructure(cursor, tileHeader)) {
			DebugSpewAlways("Failed to read tile header for tile %d!", i);
			return CORRUPT;
		}

		if (!tileHeader.tileRef || !tileHeader.dataSize) {
			continue;
		}

		// validate the size. For sure it should not exceed the remainder of the
		// file size.
		if (tileHeader.dataSize < 0 || tileHeader.dataSize > cursor.length) {
			DebugSpewAlways("tileHeader's dataSize has invalid size %d for tile %d",
				tileHeader.dataSize, i);
			return CORRUPT;
		}

		unsigned char* tileData = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM);
		memcpy(tileData, cursor.data, tileHeader.dataSize);
		cursor.length -= tileHeader.dataSize;
		cursor.data += tileHeader.dataSize;

		if (navMesh->addTile(tileData, tileHeader.dataSize, DT_TILE_FREE_DATA, tileHeader.tileRef, 0))
			passtile++;
		else
		{
			DebugSpewAlways("Failed to load tile %d", i);
			failtile++;
		}
	}

	// these values shouldn't be set until we have a successful load
	m_loadedTiles = passtile;
	m_mesh = std::move(navMesh);
	OnNavMeshChanged(m_mesh.get());

	return SUCCESS;
}
Example #15
0
void NavigationPath::UpdatePath(bool force)
{
	if (m_navMesh == nullptr)
		return;
	if (m_query == nullptr)
	{
		m_query.reset(new dtNavMeshQuery);
		m_query->init(m_navMesh, 10000 /* MAX_NODES */);
	}

	PSPAWNINFO me = GetCharInfo()->pSpawn;
	if (me == nullptr)
		return;

	float startOffset[3] = { me->X, me->Feet, me->Y };
	float endOffset[3] = { m_destination.x, m_destination.z, m_destination.y };
	float spos[3];
	float epos[3];

	glm::vec3 thisPos(startOffset[0], startOffset[1], startOffset[2]);

	if (thisPos == m_lastPos && !force)
		return;
	m_lastPos = thisPos;

	m_currentPathCursor = 0;
	m_currentPathSize = 0;

	dtPolyRef startRef, endRef;
	m_query->findNearestPoly(startOffset, m_extents, &m_filter, &startRef, spos);

	if (!startRef)
	{
		WriteChatf(PLUGIN_MSG "No start reference");
		return;
	}

	dtPolyRef polys[MAX_POLYS];
	int numPolys = 0;

	if (!m_corridor)
	{
		if (m_useCorridor)
		{
			// initialize planning
			m_corridor.reset(new dtPathCorridor);
			m_corridor->init(MAX_PATH_SIZE);

			m_corridor->reset(startRef, startOffset);
		}

		m_query->findNearestPoly(endOffset, m_extents, &m_filter, &endRef, epos);

		if (!endRef)
		{
			WriteChatf(PLUGIN_MSG "No end reference");
			return;
		}

		dtStatus status = m_query->findPath(startRef, endRef, spos, epos, &m_filter, polys, &numPolys, MAX_POLYS);
		if (status & DT_OUT_OF_NODES)
			DebugSpewAlways("findPath from %.2f,%.2f,%.2f to %.2f,%.2f,%.2f failed: out of nodes",
				startOffset[0], startOffset[1], startOffset[2],
				endOffset[0], endOffset[1], endOffset[2]);
		if (status & DT_PARTIAL_RESULT)
			DebugSpewAlways("findPath from %.2f,%.2f,%.2f to %.2f,%.2f,%.2f returned a partial result.",
				startOffset[0], startOffset[1], startOffset[2],
				endOffset[0], endOffset[1], endOffset[2]);

		if (m_corridor)
		{
			m_corridor->setCorridor(endOffset, polys, numPolys);
		}
	}
	else
	{
		// this is an update
		m_corridor->movePosition(startOffset, m_query.get(), &m_filter);
	}

	if (m_corridor)
	{
		m_corridor->optimizePathTopology(m_query.get(), &m_filter);

		m_currentPathSize = m_corridor->findCorners(m_currentPath,
			m_cornerFlags, polys, 10, m_query.get(), &m_filter);
	}

	if (m_debugDrawGrp)
		m_debugDrawGrp->Reset();

	if (numPolys > 0)
	{
		m_query->findStraightPath(spos, epos, polys, numPolys, m_currentPath,
			0, 0, &m_currentPathSize, MAX_POLYS, 0);

		// The 0th index is the starting point. Begin by trying to reach the
		// 2nd point...
		if (m_currentPathSize > 1)
			m_currentPathCursor = 1;

		if (m_debugDrawGrp && mq2nav::GetSettings().debug_render_pathing)
		{
			DebugDrawDX dd(m_debugDrawGrp.get());

			// draw current position
			duDebugDrawCross(&dd, me->X, me->Feet, me->Y, 0.5, DXColor(51, 255, 255), 1);

			// Draw the waypoints. Green is next point
			for (int i = 0; i < m_currentPathSize; ++i)
			{
				int color = DXColor(255, 255, 255);
				if (i < m_currentPathCursor)
					color = DXColor(0, 102, 204);
				if (i == m_currentPathCursor)
					color = DXColor(0, 255, 0);
				if (i == m_currentPathSize - 1)
					color = DXColor(255, 0, 0);

				duDebugDrawCross(&dd, m_currentPath[i * 3],
					m_currentPath[i * 3 + 1],
					m_currentPath[i * 3 + 2],
					0.5, color, 1);
			}
		}
	}

	if (m_line && mq2nav::GetSettings().show_nav_path)
	{
		m_line->Update();
	}
}
Example #16
0
DWORD WINAPI ProcessingThread(LPVOID lpParam)
{
    CTelnetServer *server=(CTelnetServer*)lpParam;
    EnterCriticalSection(&ProcessingCS);
    bThreading=true;
	char Buffer[4096] = { 0 };
    SOCKET incoming;
 	CHAR szAddr[MAX_STRING] = { 0 };
	while(!bKillThread)
    {
        // process new connections
        if (bListening)
        {
            incoming = accept(Listener,NULL,NULL);
            if (incoming != INVALID_SOCKET) {
                int ret=0;
                sockaddr_in addr;
                if (LocalOnly) {
                    int namesize = sizeof(addr);
                    int ret;
                    ret = getpeername(incoming,(sockaddr*)&addr,&namesize);
                }
				inet_ntop(AF_INET, &addr.sin_addr, szAddr, sizeof(szAddr));

				//PCHAR paddr = inet_ntoa(addr.sin_addr);
                if ((bKillThread) || (ret==SOCKET_ERROR) || (LocalOnly && !strcmp("127.0.0.1",szAddr))) {
                    DebugSpewAlways("ListenThread: Closing new connection...");
                    closesocket(incoming);
                    continue;
                }
                EnterCriticalSection(&ListCS);
                _TELNET *NewConn = new _TELNET;
                memset(NewConn,0,sizeof(_TELNET));
                CWinTelnet *telnet = new CWinTelnet;
                telnet->m_Socket=incoming;
                unsigned long nonblocking = 1;
                ioctlsocket(incoming,FIONBIO,&nonblocking);
                NewConn->connection=telnet;
                NewConn->pNext=Connections;
                if (Connections)
                    Connections->pLast=NewConn;
                Connections=NewConn;

                LeaveCriticalSection(&ListCS);
            }
        }

        // process sends
        EnterCriticalSection(&BufferCS);
        _TELNET *Conn=Connections;
		CHAR szText[MAX_STRING * 25] = { 0 };
        PCHATBUF pBuff=Sends;
        while(pBuff)
        {
            PCHATBUF NextChat=pBuff->pNext;
            strcat_s(szText,pBuff->szText);
            strcat_s(szText,"\r\n");
            free(pBuff);
            pBuff=NextChat;
        }
        Sends=0;
        LeaveCriticalSection(&BufferCS);

        EnterCriticalSection(&ListCS);
        while(Conn)
        {
            if (!Conn->connection->isConnected())
            {
                // remove connection...
                _TELNET *Next=Conn->pNext;
                while(Conn->Received)
                {
                    PCHATBUF rNext=Conn->Received->pNext;
                    free(Conn->Received);
                    Conn->Received=rNext;
                }
                if (Conn->pLast)
                    Conn->pLast->pNext=Conn->pNext;
                else
                    Connections=Conn->pNext;
                if (Conn->pNext)
                    Conn->pNext->pLast=Conn->pLast;

                delete Conn->connection;
                delete Conn;
                Conn=Next;
                continue;
            }

            switch(Conn->State)
            {
            case TS_MAININPUT:
                Conn->connection->WriteStr(szText);
                break;
            case TS_SENDLOGIN:
                Conn->connection->WriteStr(TelnetLoginPrompt);
                Conn->State=TS_GETLOGIN;
                break;
            case TS_SENDPASSWORD:
                Conn->connection->WriteStr(TelnetPasswordPrompt);
                Conn->State=TS_GETPASSWORD;
                break;
            }
            Conn=Conn->pNext;
        }

        // process receives
        Conn=Connections;
        while(Conn)
        {
            // update receive buffer for this connection
            int isize=0;
            if (isize=Conn->connection->isData())
            {
                memset(Buffer,0,4096);
                if (isize>2047) isize=2047;
                strcpy_s(Buffer,Conn->Buffer);
                isize=Conn->connection->Read(&Buffer[strlen(Buffer)],isize);
                int begin=0;
                for (int i = 0 ; Buffer[i] ; i++)
                {
                    if (Buffer[i]==0x0a || Buffer[i]==0x0d || (i-begin>250))
                    {
                        // carriage return, see if we have a length
                        if (i-begin)
                        {
                            // we do. make a command out of it.
                            PCHATBUF newcmd = (PCHATBUF)calloc(1,sizeof(CHATBUF));
                            if (newcmd) {
                                DebugSpew("MQ2Telnet processing input");
                                //memset(newcmd,0,sizeof(CHATBUF));
                                memcpy(newcmd->szText,&Buffer[begin],i-begin);
                                DebugSpew("MQ2Telnet: received '%s'",newcmd->szText);
                                newcmd->pNext = NULL;
                                if (!Conn->Received) {
                                    Conn->Received = newcmd;
                                } else {
                                    PCHATBUF pCurrent = 0;
                                    for (pCurrent = Conn->Received;pCurrent->pNext;pCurrent=pCurrent->pNext);
                                    pCurrent->pNext = newcmd;
                                }
                            }
                        }
                        begin=i+1;
                    }
                }
				if (isize) {
					strcpy_s(Conn->Buffer, &Buffer[begin]);
				}
            }


            while(Conn->Received)
            {
                if (Conn->State==TS_MAININPUT)
                {
                    EnterCriticalSection(&CommandCS);
                    // Add command to list

                    PCHATBUF pChat = (PCHATBUF)calloc(1,sizeof(CHATBUF));
                    if (pChat) {
                        strcpy_s(pChat->szText,Conn->Received->szText);
                        pChat->pNext = NULL;
                        if (!Commands) {
                            Commands = pChat;
                        } else {
                            PCHATBUF pCurrent;
                            for (pCurrent = Commands;pCurrent->pNext;pCurrent=pCurrent->pNext);
                            pCurrent->pNext = pChat;
                        }
                    }

                    LeaveCriticalSection(&CommandCS);
                }
                else if (Conn->State==TS_GETLOGIN)
                {
                    // process user name
					char pwd[32] = { 0 };
                    if (server->IsValidUser(Conn->Received->szText,pwd))
                    {
                        Conn->State=TS_SENDPASSWORD; // send password prompt
                        strcpy_s(Conn->Username,Conn->Received->szText);
                        strcpy_s(Conn->Password,pwd);
                    }
                    else
                    {
                        Conn->connection->WriteStr("invalid\r\n");
                        Conn->State=TS_SENDLOGIN;
                    }
                }
                else if (Conn->State==TS_GETPASSWORD)
                {
                    // process password
                    if (!strcmp(Conn->Password,Conn->Received->szText))
                    {
                        Conn->connection->WriteStr(TelnetWelcome);
                        Conn->connection->WriteStr("\r\n");
                        Conn->State=TS_MAININPUT;
                    }
                    else
                    {
                        Conn->connection->WriteStr("invalid\r\n");
                        if (++Conn->PasswordTries>=3)
                        {
                            Conn->connection->WriteStr("3 strikes, you're out. later.\r\n");
                            Conn->connection->Disconnect();
                        }
                        Conn->State=TS_SENDPASSWORD;
                    }
                }
                else
                    break;
                PCHATBUF Next=Conn->Received->pNext;
                free(Conn->Received);
                Conn->Received=Next;
            }

            Conn=Conn->pNext;
        }
        LeaveCriticalSection(&ListCS);

        Sleep(10);
    }
    LeaveCriticalSection(&ProcessingCS);
    DebugSpew("MQ2Telnet processing thread ending");
    bThreading=false;
    return 0;
}
Example #17
0
void MQ2NavigationPlugin::AttemptMovement()
{
	if (m_isActive)
	{
		clock::time_point now = clock::now();

		if (now - m_pathfindTimer > std::chrono::milliseconds(PATHFINDING_DELAY_MS))
		{
			//WriteChatf(PLUGIN_MSG "Recomputing Path...");

			// update path
			m_activePath->UpdatePath();
			m_isActive = m_activePath->GetPathSize() > 0;

			m_pathfindTimer = now;
		}
	}

	// if no active path, then leave
	if (!m_isActive) return;

	//WriteChatf(PLUGIN_MSG "AttemptMovement - cursor = %d, size = %d, isActive = %d",
	//	m_activePath->GetPathIndex() , m_activePath->GetPathSize(), m_isActive ? 1 : 0);
	const glm::vec3& dest = m_activePath->GetDestination();
	float distanceToTarget = GetDistance(dest.x, dest.z);
	//PSPAWNINFO me = GetCharInfo()->pSpawn;
	//WriteChatf(PLUGIN_MSG "Distance from target: %.2f. I am at: %.2f %.2f %.2f", distanceToTarget,
	//	me->X, me->Y, me->Z);

	if (m_activePath->IsAtEnd())
	{
		DebugSpewAlways("[MQ2Nav] Reached destination at: %.2f %.2f %.2f",
			dest.x, dest.z, dest.y);
		WriteChatf(PLUGIN_MSG "\agReached destination at: %.2f %.2f %.2f",
			dest.x, dest.y, dest.z);

		if (PSPAWNINFO me = GetCharInfo()->pSpawn)
		{
			if (distanceToTarget < ENDPOINT_STOP_DISTANCE
				&& !m_bSpamClick)
			{
				LookAt(dest);
			}
		}

		Stop();
	}
	else if (m_activePath->GetPathSize() > 0)
	{
		if (!m_isPaused)
		{
			if (!GetCharInfo()->pSpawn->SpeedRun)
				MQ2Globals::ExecuteCmd(FindMappableCommand("FORWARD"), 1, 0);
		}

		glm::vec3 nextPosition = m_activePath->GetNextPosition();

		float distanceFromNextPosition = GetDistance(nextPosition.x, nextPosition.z);

		if (distanceFromNextPosition < WAYPOINT_PROGRESSION_DISTANCE)
		{
			m_activePath->Increment();

			if (!m_activePath->IsAtEnd())
			{
				m_activePath->UpdatePath();
				nextPosition = m_activePath->GetNextPosition();
			}
		}

		if (m_currentWaypoint != nextPosition)
		{
			m_currentWaypoint = nextPosition;
			DebugSpewAlways("[MQ2Nav] Moving Towards: %.2f %.2f %.2f", nextPosition.x, nextPosition.z, nextPosition.y);
		}

		glm::vec3 eqPoint(nextPosition.x, nextPosition.z, nextPosition.y);
		LookAt(eqPoint);
	}
}
Example #18
0
PLUGIN_API VOID OnReloadUI() 
{ 
    DebugSpewAlways("MQ2ChatWnd::OnReloadUI()"); 
    // redraw window when you load/reload UI 
    DebugTry(CreateChatWindow()); 
} 
Example #19
0
PLUGIN_API VOID OnCleanUI() 
{ 
    DebugSpewAlways("MQ2ChatWnd::OnCleanUI()"); 
    // destroy chatwnd before server select & while reloading UI 
    DestroyChatWnd(); 
}