Example #1
0
BOOL DoNextCommand()
{
	if (!ppCharSpawn || !pCharSpawn) return FALSE;
	PSPAWNINFO pCharOrMount = NULL;
	PCHARINFO pCharInfo = GetCharInfo();
	PSPAWNINFO pChar = pCharOrMount = (PSPAWNINFO)pCharSpawn;
	if (pCharInfo && pCharInfo->pSpawn) pChar = pCharInfo->pSpawn;
	if ((!pChar) || (gZoning)/* || (gDelayZoning)*/) return FALSE;
	if (((gFaceAngle != 10000.0f) || (gLookAngle != 10000.0f)) && (TurnNotDone)) return FALSE;
	if (IsMouseWaiting()) return FALSE;
	if (gDelay && gDelayCondition[0])
	{
		CHAR szCond[MAX_STRING];
		strcpy(szCond, gDelayCondition);
		ParseMacroParameter(GetCharInfo()->pSpawn, szCond);
		DOUBLE Result;
		if (!Calculate(szCond, Result))
		{
			FatalError("Failed to parse /delay condition '%s', non-numeric encountered", szCond);
			return false;
		}
		if (Result != 0)
		{
			DebugSpewNoFile("/delay ending early, conditions met");
			gDelay = 0;
		}
	}
	if (!gDelay && !gMacroPause && (!gMQPauseOnChat || *EQADDR_NOTINCHATMODE) &&
		gMacroBlock && gMacroStack) {
		PMACROBLOCK tmpBlock = gMacroBlock;
		gMacroStack->Location = gMacroBlock;
#ifdef MQ2_PROFILING
		LARGE_INTEGER BeforeCommand;
		QueryPerformanceCounter(&BeforeCommand);
		PMACROBLOCK ThisMacroBlock = gMacroBlock;
#endif
		gMacroBlock->MacroCmd = 0;
		DoCommand(pChar, gMacroBlock->Line);
		if (gMacroBlock) {
#ifdef MQ2_PROFILING
			LARGE_INTEGER AfterCommand;
			QueryPerformanceCounter(&AfterCommand);
			ThisMacroBlock->ExecutionCount++;
			ThisMacroBlock->ExecutionTime += AfterCommand.QuadPart - BeforeCommand.QuadPart;
#endif
			if (!gMacroBlock->pNext) {
				FatalError("Reached end of macro.");
			}
			else {
				// if the macro block changed and there was a /macro 
				// command don't bump the line 
				//if (gMacroBlock == tmpBlock || !gMacroBlock->MacroCmd) {
				gMacroBlock = gMacroBlock->pNext;
				//}
			}
		}
		return TRUE;
	}
	return FALSE;
}
Example #2
0
void MQ2NavigationPlugin::StuckCheck()
{
	if (m_isPaused)
		return;

	if (!mq2nav::GetSettings().attempt_unstuck)
		return;

	clock::time_point now = clock::now();

	// check every 100 ms
	if (now > m_stuckTimer + std::chrono::milliseconds(100))
	{
		m_stuckTimer = now;
		if (GetCharInfo())
		{
			if (GetCharInfo()->pSpawn->SpeedMultiplier != -10000
				&& FindSpeed(GetCharInfo()->pSpawn)
				&& (GetDistance(m_stuckX, m_stuckY) < FindSpeed(GetCharInfo()->pSpawn) / 600)
				&& !ClickNearestClosedDoor(25)
				&& !GetCharInfo()->pSpawn->Levitate
				&& !GetCharInfo()->pSpawn->UnderWater
				&& !GetCharInfo()->Stunned
				&& m_isActive)
			{
				int jumpCmd = FindMappableCommand("JUMP");
				MQ2Globals::ExecuteCmd(jumpCmd, 1, 0);
				MQ2Globals::ExecuteCmd(jumpCmd, 0, 0);
			}

			m_stuckX = GetCharInfo()->pSpawn->X;
			m_stuckY = GetCharInfo()->pSpawn->Y;
		}
	}
}
Example #3
0
// ***************************************************************************
// Function:    PickZoneCmd
// Description: '/pickzone' command
//              Adds the ability to do /pickzone #
// Usage:       /pickzone 2 will switch zone to number 2 pickzone 0 will pick main instance
// ***************************************************************************
//VOID PickZoneCmd(PSPAWNINFO pChar, PCHAR szLine)
int CMD_PickZone(int argc, char *argv[])
{
	if (!cmdPickZone) { 
		PCMDLIST pCmdListOrig = (PCMDLIST)EQADDR_CMDLIST; 
		for (int i=0;pCmdListOrig[i].fAddress != 0;i++) { 
			if (!strcmp(pCmdListOrig[i].szName,"/pickzone")) { 
				cmdPickZone = (fEQCommand)pCmdListOrig[i].fAddress; 
			} 
		} 
	} 
	if (!cmdPickZone)
	   return -1; 
	PCHAR szLine = NULL;
    if (argc > 1)
        szLine = argv[1];
	if (!szLine || (szLine && szLine[0]=='\0')) {
		WriteChatColor("Usage: /pickzone # where # is the instance number you want to pick");
		if (PCHARINFO pCharInfo = GetCharInfo()) {
			cmdPickZone(pCharInfo->pSpawn, szLine);
		}
		return 0;
	}
	else {
		DWORD index = atoi(szLine);
		DWORD nThreadID = 0;
		CreateThread(NULL, 0, openpickzonewnd, (PVOID)index, 0, &nThreadID);
	}
	return 0;
}
Example #4
0
CFX_WideString CRF_TextPage::GetPageText(int start, int nCount ) const
{
    if(nCount == -1) {
        nCount = CountChars();
        start = 0;
    } else if(nCount < 1) {
        return L"";
    } else if(start >= CountChars()) {
        return L"";
    }
    int i, index = start + nCount;
    FPDF_CHAR_INFO info;
    CFX_WideString str;
    CFX_FloatRect recttmp;
    FX_BOOL bstart = TRUE;
    for(i = start; i < index; i++) {
        GetCharInfo(i, info);
        if(bstart) {
            recttmp = info.m_CharBox;
            str += info.m_Unicode;
            bstart = FALSE;
        } else if (_IsInsameline(recttmp, info.m_CharBox)) {
            str += info.m_Unicode;
        } else {
            str += L"\r\n";
            recttmp = info.m_CharBox;
            str += info.m_Unicode;
        }
    }
    if(str.IsEmpty()) {
        return L"";
    }
    return str;
}
Example #5
0
void CRF_TextPage::GetRectsArrayByRect(CFX_FloatRect rect, CFX_RectArray& resRectArray) const
{
    int count, i;
    FX_BOOL bstart = TRUE;
    FPDF_CHAR_INFO info;
    CFX_FloatRect recttmp;
    count = CountChars();
    for(i = 0; i < count; i++) {
        GetCharInfo(i, info);
        if(_IsIntersect(rect, info.m_CharBox)) {
            if(bstart) {
                recttmp = info.m_CharBox;
                bstart = FALSE;
            } else if(_IsInsameline(recttmp, info.m_CharBox)) {
                recttmp.right = info.m_CharBox.right;
                if(info.m_CharBox.top > recttmp.top) {
                    recttmp.top = info.m_CharBox.top;
                }
                if(info.m_CharBox.bottom < recttmp.bottom) {
                    recttmp.bottom = info.m_CharBox.bottom;
                }
            } else {
                resRectArray.Add(recttmp);
                recttmp = info.m_CharBox;
            }
        }
    }
    resRectArray.Add(recttmp);
}
Example #6
0
CFX_WideString CRF_TextPage::GetTextByRect(CFX_FloatRect rect) const
{
    int count;
    FPDF_CHAR_INFO info;
    CFX_WideString str;
    CFX_FloatRect  Recttmp;
    FX_BOOL bstart = TRUE;
    count = CountChars();
    if(rect.IsEmpty()) {
        return L"";
    }
    for(int i = 0; i < count; i++) {
        GetCharInfo(i, info);
        if(_IsIntersect(rect, info.m_CharBox)) {
            if(bstart) {
                Recttmp = info.m_CharBox;
                str += info.m_Unicode;
                bstart = FALSE;
            } else if(_IsInsameline(Recttmp, info.m_CharBox)) {
                str += info.m_Unicode;
            } else {
                str += L"\r\n";
                Recttmp = info.m_CharBox;
                str += info.m_Unicode;
            }
        }
    }
    if(str.IsEmpty()) {
        return L"";
    } else {
        return str;
    }
}
Example #7
0
int CRF_TextPage::GetIndexAtPos(CPDF_Point point, FX_FLOAT xTorelance, FX_FLOAT yTorelance) const
{
    int index = -1, i = 0, j = 0;
    FPDF_CHAR_INFO info;
    CFX_FloatRect rectTmp;
    FX_FLOAT MinDistance = 1000, DistanceTmp = 0;
    FX_FLOAT rect_bottom = point.x - xTorelance;
    CFX_FloatRect TorelanceRect(rect_bottom <= 0 ? 0 : rect_bottom, point.y - yTorelance, point.x + xTorelance, point.y + yTorelance);
    int count = CountChars();
    for(i = 0; i < count; i++) {
        GetCharInfo(i, info);
        rectTmp = info.m_CharBox;
        if(rectTmp.Contains(point.x, point.y)) {
            index = i;
            break;
        } else if(_IsIntersect(rectTmp, TorelanceRect)) {
            DistanceTmp = _GetDistance(rectTmp, point);
            if(DistanceTmp < MinDistance) {
                MinDistance = DistanceTmp;
                index = i;
            }
        }
    }
    return index;
}
Example #8
0
void CRF_TextPage::GetRectArray(int start, int nCount, CFX_RectArray& rectArray) const
{
    int indexlen = start + nCount;
    FPDF_CHAR_INFO info;
    FX_BOOL bstart = TRUE;
    CFX_FloatRect recttmp;
    int i;
    for(i = start; i < indexlen; i++) {
        GetCharInfo(i, info);
        if(bstart) {
            recttmp = info.m_CharBox;
            bstart = FALSE;
        } else if(_IsInsameline(recttmp, info.m_CharBox)) {
            recttmp.right = info.m_CharBox.right;
            if(info.m_CharBox.top > recttmp.top) {
                recttmp.top = info.m_CharBox.top;
            }
            if(info.m_CharBox.bottom < recttmp.bottom) {
                recttmp.bottom = info.m_CharBox.bottom;
            }
        } else {
            rectArray.Add(recttmp);
            recttmp = info.m_CharBox;
        }
    }
    rectArray.Add(recttmp);
}
// ***************************************************************************
// Function:    Delay
// Description: Our '/delay' command
// Usage:       /delay <time> [condition to end early]
// ***************************************************************************
VOID Delay(PSPAWNINFO pChar, PCHAR szLine)
{
    CHAR szVal[MAX_STRING] = {0};
    LONG VarValue;

    if (szLine[0]==0) {
        SyntaxError("Usage: /delay <time> [condition to end early]");
        return;
    }
    GetArg(szVal,szLine,1);
    ParseMacroParameter(GetCharInfo()->pSpawn,szVal);
    strcpy(gDelayCondition,GetNextArg(szLine));
    VarValue = atol(szVal);
    switch (szVal[strlen(szVal)-1]) {
        case 'm':
        case 'M':
            VarValue *= 60;
        case 's':
        case 'S':
            VarValue *= 10;
    }
    gDelay = VarValue;
    bRunNextCommand=false;
    //    DebugSpewNoFile("Delay - %d",gDelay);
}
Example #10
0
void MQ2NavigationPlugin::UpdateCurrentZone()
{
	int zoneId = -1;

	if (PCHARINFO pChar = GetCharInfo())
	{
		zoneId = pChar->zoneId;

		zoneId &= 0x7FFF;
		if (zoneId >= MAX_ZONES)
			zoneId = -1;
		if (zoneId == m_zoneId)
			return;
	}

	if (m_zoneId != zoneId)
	{
		m_zoneId = zoneId;

		if (m_zoneId == -1)
			DebugSpewAlways("Resetting Zone");
		else
			DebugSpewAlways("Switching to zone: %d", m_zoneId);

		mq2nav::LoadWaypoints(m_zoneId);

		for (const auto& m : m_modules)
		{
			m.second->SetZoneId(m_zoneId);
		}
	}
}
Example #11
0
bool MQ2NavigationPlugin::ClickNearestClosedDoor(float cDistance)
{
	if (!ppSwitchMgr || !pSwitchMgr) return false;

	PDOORTABLE pDoorTable = (PDOORTABLE)pSwitchMgr;
	PDOOR pDoor = NULL;
	PSPAWNINFO pChar = GetCharInfo()->pSpawn;

	for (DWORD index = 0; index < pDoorTable->NumEntries; index++)
	{
		if (pDoorTable->pDoor[index]->Z <= pChar->Z + gZFilter &&
			pDoorTable->pDoor[index]->Z >= pChar->Z - gZFilter)
		{
			FLOAT Distance = GetDistance(pDoorTable->pDoor[index]->X, pDoorTable->pDoor[index]->Y);
			if (Distance < cDistance) {
				pDoor = pDoorTable->pDoor[index];
				cDistance = Distance;
			}
		}
	}
	if (pDoor) {
		ClickDoor(pDoor);
		return true;
	}
	return false;
}
Example #12
0
void __cdecl EQSpawnService(bool Broadcast, unsigned int MSG, void *lpData)
{
	switch (MSG)
	{
#define pNewSpawn ((PSPAWNINFO)lpData)
	case SPAWNSERVICE_ADDSPAWN:
		if (Update && pNewSpawn->SpawnID != 0 && GetCharInfo()->pSpawn != pNewSpawn)
		{
			DebugSpewAlways("MQ2Map::OnAddSpawn(%s)", pNewSpawn->Name);
			AddSpawn(pNewSpawn);
		}
		break;
	case SPAWNSERVICE_REMOVESPAWN:
		DebugSpewAlways("MQ2Map::OnRemoveSpawn(%s)", pNewSpawn->Name);
		if (Update)
			RemoveSpawn(pNewSpawn);
		break;
#undef pNewSpawn
#define pGroundItem ((PGROUNDITEM)lpData)
	case SPAWNSERVICE_ADDITEM:
		DebugSpewAlways("MQ2Map::OnAddGroundItem(%d)", pGroundItem->DropID);
		if (Update)
			AddGroundItem(pGroundItem);
		break;
	case SPAWNSERVICE_REMOVEITEM:
		DebugSpewAlways("MQ2Map::OnRemoveGroundItem(%d)", pGroundItem->DropID);
		if (Update)
			RemoveGroundItem(pGroundItem);
		break;
#undef pGroundItem
	}
}
Example #13
0
PLUGIN_API VOID SetGameState(DWORD GameState)
{
    if (GameState==GAMESTATE_INGAME)
        sprintf_s(HUDSection,"%s_%s",GetCharInfo()->Name,EQADDR_SERVERNAME);
    else 
        strcpy_s(HUDSection,"MQ2HUD");
    GetPrivateProfileString(HUDSection,"Last","Elements",HUDNames,MAX_STRING,INIFileName);
    HandleINI();
}
Example #14
0
DWORD __stdcall openpickzonewnd(PVOID pData)
{
	if(!cmdPickZone)
		return 0;
	lockit lk(ghLockPickZone);
	int nInst = (int)pData;
	CHAR szInst[32] = { 0 };
	itoa(nInst, szInst, 10);
	if (PCHARINFO pCharInfo = GetCharInfo()) {
		cmdPickZone(pCharInfo->pSpawn, NULL);
		Sleep(2000);//i need to make this hardcoded wait dynamic but im in a hurry ill do it later -eqmule
		if (CXWnd *krwnd = FindMQ2Window("MIZoneSelectWnd")) {
			if (krwnd->dShow) {
				if (CListWnd *clist = (CListWnd*)krwnd->GetChildItem("MIZ_ZoneList")) {
					if (DWORD numitems = ((CSidlScreenWnd*)clist)->Items) {
						if (CButtonWnd *cbutt = (CButtonWnd*)krwnd->GetChildItem("MIZ_SelectButton")) {
							CHAR szOut[255] = { 0 };
							CXStr Str;
							std::string s;
							bool itsmain = false;
							bool clickit = false;
							for (DWORD i = 0; i<numitems; i++) {
								clist->GetItemText(&Str, i, 0);
								GetCXStr(Str.Ptr, szOut, 254);
								if (szOut[0] != '\0') {
									s = szOut;
									if (std::string::npos == s.find_first_of("123456789")) {
										itsmain = true;
									}
									if (itsmain && nInst == 0) {
										clickit = true;
									}
									else if (nInst >= 1) {
										if (std::string::npos != s.find_first_of(szInst)) {
											clickit = true;
										}
									}
									if (clickit) {
										SendListSelect("MIZoneSelectWnd", "MIZ_ZoneList", i);
										Sleep(500);
										SendWndClick2((CXWnd*)cbutt, "leftmouseup");
										WriteChatf("%s selected.", szOut);
										return 0;
									}
								}
							}
							WriteChatf("%s instance %d NOT found in list", GetFullZone(pCharInfo->zoneId), nInst);
						}
					}
				}
			}
		}
	}
	return 0;
}
Example #15
0
PCHAR ParseMacroParameter(PSPAWNINFO pChar, PCHAR szOriginal)
{
    PCHARINFO pCharInfo = GetCharInfo();
    if (!pCharInfo) 
        return szOriginal;
    EnterMQ2Benchmark(bmParseMacroParameter);

    ParseMacroData(szOriginal);
    ExitMQ2Benchmark(bmParseMacroParameter);
    return (szOriginal);
}
Example #16
0
void ChatClient::SendChatEnterRes(sUT_ENTER_CHAT* pData)
{
	memcpy(AuthKey, pData->abyAuthKey, NTL_MAX_SIZE_AUTH_KEY);
	AccountID = pData->accountId;
	GetCharInfo();
	sTU_ENTER_CHAT_RES pRes;
	pRes.wOpCode = TU_ENTER_CHAT_RES;
	pRes.wResultCode = CHAT_SUCCESS;
	Send(&pRes, sizeof(pRes));

	pServer->GetChatManager()->AddClient(this);
}
Example #17
0
//By Luiz45 Shouting the msg to everybody who is connected at channel
void ChatClient::SendChatShout(sUT_CHAT_MESSAGE_SHOUT* pData)
{
	GetCharInfo();
	sTU_CHAT_MESSAGE_SHOUT pShout;
	memset(&pShout, 0, sizeof(pShout));
	pShout.hSubject = CharSerialID;
	pShout.wOpCode = TU_CHAT_MESSAGE_SHOUT;
	pShout.wMessageLengthInUnicode = pData->wMessageLengthInUnicode;
	memcpy(pShout.awchSenderCharName, charName, NTL_MAX_SIZE_CHAR_NAME_UNICODE);
	memcpy(pShout.awchMessage, pData->awchMessage, NTL_MAX_LENGTH_OF_CHAT_MESSAGE_UNICODE);
	Logger::Log("%s Say to everybody in the chat: %s\n", GameString(pShout.awchSenderCharName).c_str(), GameString(pShout.awchMessage).c_str());
	pServer->GetChatManager()->SendAll(&pShout, sizeof(pShout));
}
Example #18
0
void ChatClient::SendChatSay(sUT_CHAT_MESSAGE_SAY* pData)
{
	GetCharInfo();
	sTU_CHAT_MESSAGE_SAY pSay;
	memset(&pSay, 0, sizeof(pSay));
	pSay.wOpCode = TU_CHAT_MESSAGE_SAY;
	pSay.hSubject = CharSerialID;
	memcpy(pSay.awchSenderCharName, charName, NTL_MAX_SIZE_CHAR_NAME_UNICODE);
	memcpy(pSay.awchMessage, pData->awchMessage, NTL_MAX_LENGTH_OF_CHAT_MESSAGE_UNICODE);
	pSay.wMessageLengthInUnicode = pData->wMessageLengthInUnicode;
	Logger::Log("%s says: %s\n", GameString(pSay.awchSenderCharName).c_str(), GameString(pSay.awchMessage).c_str());
	pServer->GetChatManager()->SendAll2(&pSay, sizeof(pSay),this);
}
Example #19
0
//By Luiz45 - WhisperChat(Aka Private Chat) - No log because is private.
void ChatClient::SendChatWhisper(sUT_CHAT_MESSAGE_WHISPER* pData)
{
	GetCharInfo();
	sTU_CHAT_MESSAGE_WHISPER pWhisper;
	memset(&pWhisper, 0, sizeof(pWhisper));
	pWhisper.wOpCode = TU_CHAT_MESSAGE_WHISPER;
	pWhisper.wMessageLengthInUnicode = pData->wMessageLengthInUnicode;
	memcpy(pWhisper.awchSenderCharName, charName, NTL_MAX_SIZE_CHAR_NAME_UNICODE);
	memcpy(pWhisper.awchMessage, pData->awchMessage, NTL_MAX_LENGTH_OF_CHAT_MESSAGE_UNICODE);
	ChatClient* pChatToWhisper = pServer->GetChatManager()->GetChatClient(pData->awchReceiverCharName);
	if (NULL != pChatToWhisper){
		pServer->GetChatManager()->SendTo(&pWhisper, sizeof(pWhisper), pChatToWhisper);
		Send(&pWhisper, sizeof(pWhisper));
	}
}
Example #20
0
//By Luiz45 - Private Shop
void ChatClient::SendChatPrivateShop(sUT_CHAT_MESSAGE_PRIVATESHOP_BUSINESS* pData)
{
	GetCharInfo();
	sTU_CHAT_MESSAGE_PRIVATESHOP_BUSINESS pBusiness;
	memset(&pBusiness, 0, sizeof(pBusiness));
	pBusiness.wOpCode = TU_CHAT_MESSAGE_PRIVATESHOP_BUSINESS;
	pBusiness.wMessageLengthInUnicode = pData->wMessageLengthInUnicode;
	memcpy(pBusiness.awchSenderCharName, charName, NTL_MAX_SIZE_CHAR_NAME_UNICODE);
	memcpy(pBusiness.awchMessage, pData->awchMessage, NTL_MAX_LENGTH_OF_CHAT_MESSAGE_UNICODE);
	ChatClient* pChatToWhisper = pServer->GetChatManager()->GetChatClient(pData->awchReceiverCharName);
	if (NULL != pChatToWhisper){
		pServer->GetChatManager()->SendTo(&pBusiness, sizeof(pBusiness), pChatToWhisper);
		Send(&pBusiness, sizeof(pBusiness));
	}
}
Example #21
0
void CTelnetServer::ProcessIncoming()
{
    EnterCriticalSection(&CommandCS);
    if(Commands) // process only 1 per pulse, no loop.
    {
        PCHARINFO pCharInfo=GetCharInfo();
        PSPAWNINFO pSpawn=(PSPAWNINFO)pLocalPlayer;
        if (pCharInfo) pSpawn=pCharInfo->pSpawn;
        PCHATBUF Next=Commands->pNext;
        DoCommand(pSpawn,Commands->szText);
        free(Commands);
        Commands=Next;
    }

    LeaveCriticalSection(&CommandCS);
}
Example #22
0
int CMD_SellItem(int argc, char *argv[])
{
	if (argc<2)
	{
		WriteChatf("Syntax: %s <quantity>",argv[0]);
		return 0;
	}
	if (!pMerchantWnd) 
		return 0;
	PCHARINFO pCharInfo;
    if (NULL == (pCharInfo = GetCharInfo())) return 0;

    DWORD Qty = (DWORD)atoi(argv[1]);
    if (Qty > 20 || Qty < 1) return 0;
    pMerchantWnd->RequestSellItem(Qty);
    return 0;
}
Example #23
0
bool BaseGuildManager::SetGuild(uint32 charid, uint32 guild_id, uint8 rank) {
	if(rank > GUILD_MAX_RANK && guild_id != GUILD_NONE)
		return(false);

	//lookup their old guild, if they had one.
	uint32 old_guild = GUILD_NONE;
	CharGuildInfo gci;
	if(GetCharInfo(charid, gci)) {
		old_guild = gci.guild_id;
	}

	if(!DBSetGuild(charid, guild_id, rank))
		return(false);

	SendCharRefresh(old_guild, guild_id, charid);

	return(true);
}
Example #24
0
VOID ExecuteCustomBind(PCHAR Name,BOOL Down)
{
    int N=FindCustomBind(Name);
    if (N<0)
        return;
    PCHARINFO pCharInfo=GetCharInfo();
    if (!pCharInfo)
        return;
    if (PCUSTOMBIND pBind=CustomBinds[N])
    {
        if (Down)
        {
            if (pBind->CommandDown[0])
                DoCommand(pCharInfo->pSpawn,pBind->CommandDown);
        }
        else if (pBind->CommandUp[0])
            DoCommand(pCharInfo->pSpawn,pBind->CommandUp);
    }
}
Example #25
0
int CRF_TextPage::CountBoundedSegments(FX_FLOAT left, FX_FLOAT top, FX_FLOAT right, FX_FLOAT bottom, FX_BOOL bContains)
{
    if (!m_CountBSArray) {
        return -1;
    }
    m_CountBSArray->RemoveAll();
    CFX_FloatRect floatrect(left, bottom, right, top);
    int totalcount, i, j = 0, counttmp = 0;
    FX_BOOL bstart = TRUE;
    FPDF_CHAR_INFO info;
    CFX_FloatRect recttmp;
    totalcount = CountChars();
    for(i = 0; i < totalcount; i++) {
        GetCharInfo(i, info);
        if(_IsIntersect(floatrect, info.m_CharBox)) {
            if(bstart) {
                m_CountBSArray->Add(i);
                counttmp = 1;
                recttmp = info.m_CharBox;
                bstart = FALSE;
            } else if(_IsInsameline(recttmp, info.m_CharBox)) {
                recttmp.right = info.m_CharBox.right;
                if(info.m_CharBox.top > recttmp.top) {
                    recttmp.top = info.m_CharBox.top;
                }
                if(info.m_CharBox.bottom < recttmp.bottom) {
                    recttmp.bottom = info.m_CharBox.bottom;
                }
                counttmp ++;
            } else {
                m_CountBSArray->Add(counttmp);
                m_CountBSArray->Add(i);
                counttmp = 1;
                j++;
                recttmp = info.m_CharBox;
            }
        }
    }
    m_CountBSArray->Add(counttmp);
    j++;
    return j;
}
Example #26
0
int CMD_MemSpell(int argc, char *argv[])
{
   if (argc < 3)
   {
      WriteChatf("Syntax: %s <gem #> <spellname>",argv[0]);
      return 0;
   }
   if (!ppSpellBookWnd) return -1;
   DWORD Favorite = (DWORD)&MemSpellFavorite;
   DWORD sp;
   WORD Gem = -1;
   PCHARINFO pCharInfo = NULL;
   if (!pSpellBookWnd) return -1;
   if (NULL == (pCharInfo = GetCharInfo())) return -1;

   Gem = atoi(argv[1]);
   if (Gem<1 || Gem>NUM_SPELL_GEMS) return -1;
   Gem--;

   GetCharInfo2()->SpellBook;
   PSPELL pSpell=0;
   for (DWORD N = 0 ; N < NUM_BOOK_SLOTS ; N++)
   if (PSPELL pTempSpell=GetSpellByID(GetCharInfo2()->SpellBook[N]))
   {
      if (!stricmp(argv[2],pTempSpell->Name))
      {
         pSpell=pTempSpell;
         break;
      }
   }

   if (!pSpell) return -1;
   if (pSpell->ClassLevel[GetCharInfo2()->Class]>GetCharInfo2()->Level) return -1;

   ZeroMemory(&MemSpellFavorite,sizeof(MemSpellFavorite));
   strcpy(MemSpellFavorite.Name,"Mem a Spell");
   MemSpellFavorite.inuse=1;
   for (sp=0;sp<NUM_SPELL_GEMS;sp++) MemSpellFavorite.SpellId[sp]=0xFFFFFFFF; 
   MemSpellFavorite.SpellId[Gem] = pSpell->ID;
   pSpellBookWnd->MemorizeSet((int*)Favorite,NUM_SPELL_GEMS); 
   return 0;
} 
Example #27
0
void ZoneGuildManager::SendRankUpdate(uint32 CharID)
{
	CharGuildInfo gci;

	if(!GetCharInfo(CharID, gci))
		return;

	ServerPacket* pack = new ServerPacket(ServerOP_GuildRankUpdate, sizeof(ServerGuildRankUpdate_Struct));

	ServerGuildRankUpdate_Struct *sgrus = (ServerGuildRankUpdate_Struct*)pack->pBuffer;

	sgrus->GuildID = gci.guild_id;
	strn0cpy(sgrus->MemberName, gci.char_name.c_str(), sizeof(sgrus->MemberName));
	sgrus->Rank = gci.rank;
	sgrus->Banker = gci.banker + (gci.alt * 2);

	worldserver.SendPacket(pack);

	safe_delete(pack);
}
Example #28
0
void ClickDoor(PDOOR pDoor)
{
	EQSwitch *pSwitch = (EQSwitch *)pDoor;
	srand((unsigned int)time(0));
	int randclickY = rand() % 5;
	int randclickX = rand() % 5;
	int randclickZ = rand() % 5;
	
	SWITCHCLICK click;
	click.Y = pDoor->Y + randclickY;
	click.X = pDoor->X + randclickX;
	click.Z = pDoor->Z + randclickZ;
	randclickY = rand() % 5;
	randclickX = rand() % 5;
	randclickZ = rand() % 5;
	click.Y1 = click.Y + randclickY;
	click.X1 = click.X + randclickX;
	click.Z1 = click.Z + randclickZ;
	pSwitch->UseSwitch(GetCharInfo()->pSpawn->SpawnID, 0xFFFFFFFF, 0, (DWORD)&click);
}
Example #29
0
float DoorsDebugUI::GetDistance(PDOOR door)
{
	PCHARINFO charInfo = GetCharInfo();
	if (!charInfo)
		return 0;

	glm::vec3 myPos(charInfo->pSpawn->X, charInfo->pSpawn->Y, charInfo->pSpawn->Z);
	if (myPos != m_lastPos)
		m_distanceCache.clear();
	m_lastPos = myPos;

	auto it = m_distanceCache.find(door->ID);
	if (it != m_distanceCache.end())
		return it->second;

	glm::vec3 doorPos(door->DefaultX, door->DefaultY, door->DefaultZ);
	float distance = glm::distance(myPos, doorPos);

	m_distanceCache[door->ID] = distance;
	return distance;
}
Example #30
0
// ***************************************************************************
// Function:    CMD_Where
// Description: Our '/where' command
//              Displays the direction and distance to the closest spawn
// Usage:       /where <spawn>
// ***************************************************************************
int CMD_Where(int argc, char* argv[])
{
   if (argc<2)
   {
      WriteChatf("Syntax: %s <spawn>",argv[0]);
      return 0;
   }
    if (!ppSpawnManager) return 0;
    if (!pSpawnList) return 0;
   PSPAWNINFO pChar = GetCharInfo()->pSpawn;
    PSPAWNINFO pSpawnClosest = NULL;
    SEARCHSPAWN SearchSpawn;
    ClearSearchSpawn(&SearchSpawn);
    CHAR szMsg[MAX_STRING] = {0};
    CHAR szName[MAX_STRING] = {0};
    CHAR szArg[MAX_STRING] = {0};
   
    bRunNextCommand = TRUE;
   SearchSpawn.SpawnType= PC;

   ParseSearchSpawn(1,argc,argv,SearchSpawn);

    if (!(pSpawnClosest = SearchThroughSpawns(&SearchSpawn,pChar))) {
        sprintf(szMsg,"There were no matches for: %s",FormatSearchSpawn(szArg,&SearchSpawn));
    } else {
        INT Angle = (INT)((atan2f(pChar->X - pSpawnClosest->X, pChar->Y - pSpawnClosest->Y) * 180.0f / PI + 360.0f) / 22.5f + 0.5f) % 16;
        sprintf(szMsg,"The closest '%s' is a level %d %s %s and %1.2f away to the %s, Z difference = %1.2f",
            CleanupName(strcpy(szName,pSpawnClosest->Name),FALSE),
            pSpawnClosest->Level,
            pEverQuest->GetRaceDesc(pSpawnClosest->Race),
            GetClassDesc(pSpawnClosest->Class),
            DistanceToSpawn(pChar,pSpawnClosest),
            szHeading[Angle],
            pSpawnClosest->Z-pChar->Z);
        DebugSpew("Where - %s",szMsg);
    }
    WriteChatColor(szMsg,USERCOLOR_WHO);
   
    return 0;
}