Ejemplo n.º 1
0
// static
ClientState
ClientState::FromIPC(const IPCClientState& aData)
{
  switch(aData.type()) {
    case IPCClientState::TIPCClientWindowState:
      return ClientState(aData.get_IPCClientWindowState());
    case IPCClientState::TIPCClientWorkerState:
      return ClientState(aData.get_IPCClientWorkerState());
    default:
      MOZ_CRASH("unexpected IPCClientState type");
  }
}
void UnitFactory::addMissileBuffer( NetBuffer &netbuf, const Missile *mis )
{
    addMissileBuffer( netbuf, mis->getFilename().c_str(), mis->name, mis->getFullname(), mis->faction,
                     "" /* modifications */, ClientState(
                         static_cast< const Unit* > (mis) ), mis->damage, mis->phasedamage, mis->time,
                     mis->radial_effect, mis->radial_multiplier, mis->detonation_radius, mis->GetSerial() );
}
void UnitFactory::addUnitBuffer( NetBuffer &netbuf, const Unit *un, string *netxml )
{
    addUnitBuffer( netbuf, un->getFilename(), un->name.get(), un->fullname, un->isSubUnit(), un->faction,
                  "" /* Not sure... maybe netxml will take care of this? */, ClientState( un ),
                  un->getFlightgroup(),
                  un->getFgSubnumber(), netxml /*For ENTERCLIENT, will generate a saved game netxml*/, un->GetSerial() );
}
Ejemplo n.º 4
0
bool InitHooks(void)
{
	int i = 0;
	while(!Vars.bActive)
	{
		if(i >= 300)
		{
			MessageBox(0, "Failed to set hooks, exiting!", "D2BS", 0);
			return false;
		}

		if(D2GFX_GetHwnd() && (ClientState() == ClientStateMenu || ClientState() == ClientStateInGame))
		{
			if(!Vars.oldWNDPROC)
				Vars.oldWNDPROC = (WNDPROC)SetWindowLong(D2GFX_GetHwnd(), GWL_WNDPROC, (LONG)GameEventHandler);
			if(!Vars.oldWNDPROC)
				continue;

			Vars.uTimer = SetTimer(D2GFX_GetHwnd(), 1, 0, TimerProc);

			DWORD mainThread = GetWindowThreadProcessId(D2GFX_GetHwnd(),0);
			if(mainThread)
			{
				if(!Vars.hKeybHook)
					Vars.hKeybHook = SetWindowsHookEx(WH_KEYBOARD, KeyPress, NULL, mainThread);
				if(!Vars.hMouseHook)
					Vars.hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseMove, NULL, mainThread);
			}
		}
		else
			continue;

		if(Vars.hKeybHook && Vars.hMouseHook)
		{
			if(!ScriptEngine::Startup())
				return false;

			Vars.bActive = TRUE;

			if(ClientState() == ClientStateMenu && Vars.bStartAtMenu)
				clickControl(*p_D2WIN_FirstControl);
		}
		Sleep(50);
		i++;
	}
	return true;
}
Ejemplo n.º 5
0
BOOL OOG_SelectCharacter(char* szCharacter)
{
	if(ClientState() != ClientStateMenu)
		return NULL;

	// Select the first control on the character selection screen.
	Control* pControl = findControl(CONTROL_TEXTBOX, (char *)NULL, -1, 237, 178, 72, 93);
	ControlText* cText;

	 while (pControl != NULL)
    {
        if(pControl->dwType == CONTROL_TEXTBOX && pControl->pFirstText != NULL && pControl->pFirstText->pNext != NULL)
            cText = pControl->pFirstText->pNext;
        else
            cText = NULL;

        if(cText != NULL)
        {
			char * szLine = UnicodeToAnsi(cText->wText[0]);
            if(!szLine)
                return FALSE;

            char* cLine = strdup(szLine);
            char* cCharacter = strdup(szCharacter);
            StringToLower(cLine);
            StringToLower(cCharacter);

            if(strlen(szLine) == strlen(szCharacter) && strstr(cLine,cCharacter) != NULL)
            {
                delete[] szLine;
                delete[] cLine;
                delete[] cCharacter;
                if(!clickControl(pControl))
                    return FALSE;

                // OK Button
                pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 627, 572, 128, 35);
                if(pControl)
                {
                    if(!clickControl(pControl))
                        return FALSE;

                    return TRUE;
                }
                else
                    return FALSE;

            }
            else
            {
                delete[] szLine;
                delete[] cLine;
                delete[] cCharacter;
            }
        }
        pControl = pControl->pNext;
    }
    return FALSE;
}
Ejemplo n.º 6
0
// OnConnected
//------------------------------------------------------------------------------
/*virtual*/ void Server::OnConnected( const ConnectionInfo * connection )
{
    ClientState * cs = FNEW( ClientState( connection ) );
    connection->SetUserData( cs );

    MutexHolder mh( m_ClientListMutex );
    m_ClientList.Append( cs );
}
Ejemplo n.º 7
0
void SetControlText(Control* pControl, const wchar_t* Text) {
    if (ClientState() != ClientStateMenu)
        return;

    if (pControl && Text) {
        D2WIN_SetControlText(pControl, Text);
    }
}
Ejemplo n.º 8
0
BOOL OOG_SelectCharacter(const wchar_t* szCharacter) {
    if (ClientState() != ClientStateMenu)
        return NULL;

    // Select the first control on the character selection screen.

    Control* pControl = findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 237, 178, 72, 93);
    ControlText* cText;

    while (pControl != NULL) {
        if (pControl->dwType == CONTROL_TEXTBOX && pControl->pFirstText != NULL && pControl->pFirstText->pNext != NULL)
            cText = pControl->pFirstText->pNext;
        else
            cText = NULL;

        if (cText != NULL) {
            if (!cText->wText[0])
                return FALSE;

            wchar_t* cLine = _wcsdup(cText->wText[0]);
            wchar_t* cCharacter = _wcsdup(szCharacter);
            StringToLower(cLine);
            StringToLower(cCharacter);

            if (wcslen(cLine) == wcslen(cCharacter) && wcsstr(cLine, cCharacter) != NULL) {
                free(cLine);
                free(cCharacter);
                if (!clickControl(pControl))
                    return FALSE;

                // OK Button
                // Bobode Sleep(7000);
                pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 627, 572, 128, 35);
                if (pControl) {
                    if (!clickControl(pControl))
                        return FALSE;

                    return TRUE;
                } else
                    return FALSE;

            } else {
                free(cLine);
                free(cCharacter);
            }
        }
        pControl = pControl->pNext;
    }
    return FALSE;
}
Ejemplo n.º 9
0
void SetControlText(Control* pControl, const char* Text)
{
	if(ClientState() != ClientStateMenu)
		return;

	if(pControl && Text)
	{
		wchar_t* szwText = AnsiToUnicode(Text);
		if(!szwText)
			return;
		D2WIN_SetControlText(pControl, szwText);
		delete[] szwText;
	}
}
Ejemplo n.º 10
0
Control* findControl(int Type, int LocaleID, int Disabled, int PosX, int PosY, int SizeX, int SizeY) {
    if (ClientState() != ClientStateMenu)
        return NULL;

    wchar_t* localeStr = NULL;
    if (LocaleID >= 0) {
        localeStr = _wcsdup(D2LANG_GetLocaleText((WORD)LocaleID));
        if (!localeStr)
            return NULL;
        Control* res = findControl(Type, localeStr, Disabled, PosX, PosY, SizeX, SizeY);
        free(localeStr);
        return res;
    }

    return NULL;
}
Ejemplo n.º 11
0
Control* findControl(int Type, int LocaleID, int Disabled, int PosX, int PosY, int SizeX, int SizeY)
{
	if(ClientState() != ClientStateMenu)
		return NULL;

	char* localeStr = NULL; 
	if(LocaleID >= 0)
	{
		localeStr = UnicodeToAnsi(D2LANG_GetLocaleText((WORD)LocaleID));
		if(!localeStr)
			return NULL;
		Control* res = findControl(Type, localeStr, Disabled, PosX, PosY, SizeX, SizeY);
		delete[] localeStr;
		return res;
	}

	return NULL;
}
Ejemplo n.º 12
0
bool OOG_JoinGame(const char* name, const char* pass)
{		
	if(ClientState() != ClientStateMenu)
		return FALSE;

	// reject name/password combinations over 15 characters
	if(strlen(name) > 15 || strlen(pass) > 15)
		return FALSE;

	Control* pControl = NULL;

	// Battle.net/open lobby/chat area
	if(!(OOG_GetLocation() == OOG_LOBBY || OOG_GetLocation() == OOG_CHAT || OOG_GetLocation() == OOG_JOIN))
		return FALSE;

	// JOIN button
	if (OOG_GetLocation() != OOG_JOIN)
	{
		pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 652,469,120,20);
		if(!pControl || !clickControl(pControl))
			return FALSE;
		Sleep(100);
	}
	if(OOG_GetLocation() == OOG_JOIN)
	{
		// Game name edit box
		if(name)
			SetControlText(findControl(1, (char *)NULL, -1, 432,148,155,20), name);
		else
			return FALSE;
		// Password edit box
		if(pass)
			SetControlText(findControl(1, (char *)NULL, -1, 606,148,155,20), pass);
		else
			return FALSE;

		// Join Game Button
		pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 594,433,172,32);
		if(!pControl || !clickControl(pControl))
			return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 13
0
bool clickControl(Control* pControl, int x, int y) {
    if (ClientState() != ClientStateMenu)
        return false;

    if (pControl) {
        if (x == -1)
            x = pControl->dwPosX + (pControl->dwSizeX / 2);
        if (y == -1)
            y = pControl->dwPosY - (pControl->dwSizeY / 2);

        Sleep(100);
        SendMouseClick(x, y, 0);
        Sleep(100);
        SendMouseClick(x, y, 1);
        Sleep(100);

        return true;
    }
    return false;
}
Ejemplo n.º 14
0
DWORD Profile::login(char** error)
{
	bool loginComplete = FALSE,	skippedToBnet = TRUE;
	int location = 0;
	char* errorMsg = "";
	Control* pControl = NULL;
	unsigned int timeout = 0;

	/*
		clickedOnce is needed because, when in OOG_OTHER_MULTIPLAYER
		the clickControl () is done twice and the second time it is
		failing because the button is not there anymore.
	*/
	int clickedOnce = false;

	Vars.bBlockKeys = Vars.bBlockMouse = TRUE;

	while(!loginComplete)
	{
		location = OOG_GetLocation();
		switch(location)
		{
			case OOG_D2SPLASH:
				clickControl(*p_D2WIN_FirstControl);
				break;
			case OOG_CHAR_SELECT:
				if (!OOG_SelectCharacter(charname))
					 errorMsg = "Invalid character name";
				break;
			case OOG_MAIN_MENU:
				if(type == PROFILETYPE_SINGLEPLAYER)
					if(!clickControl(findControl(6, (char *)NULL, -1, 264,324,272,35)))
						 errorMsg = "Failed to click the Single button?";
				if(type == PROFILETYPE_BATTLENET)
				{
					OOG_SelectGateway(gateway, 256);
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 366, 272, 35)))
						 errorMsg = "Failed to click the 'Battle.net' button?";
				}
				if(isOtherMP(type))
				{
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 433, 272, 35)))
						errorMsg =  "Failed to click the 'Other Multiplayer' button?";
					else
						skippedToBnet = FALSE;
				}
				break;
			case OOG_LOGIN:
				if((type == PROFILETYPE_SINGLEPLAYER || isOtherMP(type)) && skippedToBnet)
				{
					if(!clickControl(findControl(6, "EXIT", -1,33,572,128,35)))
						errorMsg =  "Failed to click the exit button?";
					break;
				}
				pControl = findControl(1, (char *)NULL, -1, 322, 342, 162, 19);
				if(pControl)
					SetControlText(pControl, username);
				else
					errorMsg = "Failed to set the 'Username' text-edit box.";
				// Password text-edit box
				pControl = findControl(1, (char *)NULL, -1, 322, 396, 162, 19);
				if(pControl)
					SetControlText(pControl, password);
				else
					errorMsg = "Failed to set the 'Password' text-edit box.";

				pControl = findControl(6, (char *)NULL, -1, 264, 484, 272, 35);
				if(pControl)
					if(!clickControl(pControl))
						errorMsg ="Failed to click the 'Log in' button?";
				timeout++;
				break;
			case OOG_DIFFICULTY:
				switch(diff)
				{
				case 0:
					// normal button
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 297, 272, 35)))
						errorMsg ="Failed to click the 'Normal Difficulty' button?";
					break;
				case 1:
					// nightmare button
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 340, 272, 35)))
						errorMsg =  "Failed to click the 'Nightmare Difficulty' button?";
					break;
				case 2:
					// hell button
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 383, 272, 35)))
						errorMsg =  "Failed to click the 'Hell Difficulty' button?";
					break;
				default:
					errorMsg =  "Invalid single player difficulty level specified!";
					break;
				}
			case OOG_OTHER_MULTIPLAYER:
				// Open Battle.net
				if (type == PROFILETYPE_OPEN_BATTLENET)
					if(!clickControl(findControl(6, (char *)NULL, -1, 264, 310, 272, 35)))
						errorMsg = "Failed to click the 'Open Battle.net' button?";
				// TCP/IP Game
				if (isTcpIp(type))
					if(!clickControl(findControl(6, (char *)NULL, -1, 264,350,272,35)) && !clickedOnce)
						errorMsg = "Failed to click the 'TCP/IP Game' button?";
					else
						clickedOnce = true;

				break;
			case OOG_TCP_IP:
				if (type == PROFILETYPE_TCPIP_HOST)
					if(!clickControl(findControl(6, (char *)NULL, -1,265,206,272,35)))
						errorMsg = "Failed to click the 'Host Game' button?";
				if (type == PROFILETYPE_TCPIP_JOIN)
					if(!clickControl(findControl(6, (char *)NULL, -1,265,264,272,35)))
						errorMsg = "Failed to click the 'Join Game' button?";
				break;
			case OOG_ENTER_IP_ADDRESS:
				if (_strcmpi(ip, "")) {
					pControl = findControl(1, (char *)NULL, -1, 300, 268, -1, -1);
					if(pControl) {
						SetControlText(pControl, ip);

						// Click the OK button
						if(!clickControl(findControl(6, (char *)NULL, -1, 421, 337, 96, 32))) {
							errorMsg = "Failed to click the OK button";
						}
					} else
						errorMsg = "Failed to find the 'Host IP Address' text-edit box.";
				} else
					errorMsg = "Could not get the IP address from the profile in the d2bs.ini file.";

				break;
			case OOG_MAIN_MENU_CONNECTING: 
			case OOG_CHARACTER_SELECT_PLEASE_WAIT:
			case OOG_PLEASE_WAIT: 
			case OOG_GATEWAY:
			case OOG_CHARACTER_SELECT_NO_CHARS: 
			case OOG_CONNECTING:
			case OOG_NONE:
				timeout++;
				break;
			case OOG_LOBBY: 
			case OOG_INLINE: 
			case OOG_CHAT: 
			case OOG_CREATE:
			case OOG_JOIN: 
			case OOG_LADDER: 
			case OOG_CHANNEL: 
			case OOG_GAME_EXIST: 
			case OOG_GAME_DOES_NOT_EXIST:	
				loginComplete=TRUE;
				break;
			case OOG_UNABLE_TO_CONNECT:
				errorMsg = "Unable to connect";
				break;
			case OOG_CDKEY_IN_USE:
				errorMsg = "CD-Key in use";
				break;
			case OOG_LOGIN_ERROR:
				errorMsg = "Bad account or password";
				break;
			case OOG_REALM_DOWN:
				errorMsg = "Realm Down";
				break;
			default:
				errorMsg = "Unhandled login location";
				break;				
		}

		if(_strcmpi(errorMsg, ""))
		{
			Vars.bBlockKeys = Vars.bBlockMouse = FALSE;
			*error = errorMsg;
			return 2;
		}

		if((timeout*100) > maxLoginTime)
		{
			Vars.bBlockKeys = Vars.bBlockMouse = FALSE;
			*error = "login time out";
			return 1;
		}

		if(ClientState() == ClientStateInGame)
			loginComplete = TRUE;
		
		Sleep(100);
	}

	Vars.bBlockKeys = Vars.bBlockMouse = FALSE;

	return 0;
}
Ejemplo n.º 15
0
bool OOG_CreateGame(const wchar_t* name, const wchar_t* pass, int difficulty) {
    if (ClientState() != ClientStateMenu)
        return FALSE;

    // reject name/password combinations over 15 characters
    if (!name || !pass || wcslen(name) > 15 || wcslen(pass) > 15)
        return FALSE;

    Control* pControl = NULL;

    // Battle.net/open game creation
    OOG_Location loc = OOG_GetLocation();
    if (!(loc == OOG_LOBBY || loc == OOG_CHAT || loc == OOG_DIFFICULTY || loc == OOG_CREATE))
        return FALSE;

    if (loc == OOG_DIFFICULTY) {
        // just click the difficulty button
        Control *normal = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 297, 272, 35),
                *nightmare = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 340, 272, 35),
                *hell = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 383, 272, 35);

        switch (difficulty) {
        case 0: // normal button
            if (normal->dwDisabled != 0x0d || !clickControl(normal))
                return FALSE;
            break;
        case 1: // nightmare button
            if (nightmare->dwDisabled != 0x0d || !clickControl(nightmare))
                return FALSE;
            break;
        case 2: // hell button
            if (hell->dwDisabled != 0x0d || !clickControl(hell))
                return FALSE;
            break;
        case 3: // hardest difficulty available
            if (hell->dwDisabled != 0x0d) {
                if (!clickControl(hell))
                    return FALSE;
            } else if (nightmare->dwDisabled != 0x0d) {
                if (!clickControl(nightmare))
                    return FALSE;
            } else if (normal->dwDisabled != 0x0d) {
                if (!clickControl(normal))
                    return FALSE;
            }
            break;
        default:
            return FALSE;
        }
    } else {
        // Create button
        if (loc != OOG_CREATE) {
            pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 533, 469, 120, 20);
            if (!pControl || !clickControl(pControl))
                return FALSE;
            Sleep(100);
        }
        if (OOG_GetLocation() == OOG_CREATE) {
            // Game name edit box
            if (name)
                SetControlText(findControl(1, (const wchar_t*)NULL, -1, 432, 162, 158, 20), name);
            else
                return FALSE;
            Sleep(100);

            // Password edit box
            if (pass)
                SetControlText(findControl(1, (const wchar_t*)NULL, -1, 432, 217, 158, 20), pass);
            else
                return FALSE;
            Sleep(100);
            Control *normal = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 430, 381, 16, 16),
                    *nightmare = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 555, 381, 16, 16),
                    *hell = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 698, 381, 16, 16);

            switch (difficulty) {
            case 0: // normal button
                if (normal->dwDisabled == 0x4 || !clickControl(normal))
                    return FALSE;
                break;
            case 1: // nightmare button
                if (nightmare->dwDisabled == 0x4 || !clickControl(nightmare))
                    return FALSE;
                break;
            case 2: // hell button
                if (hell->dwDisabled == 0x4 || !clickControl(hell))
                    return FALSE;
                break;
            case 3: // hardest difficulty available
                if (hell->dwDisabled != 0x4) {
                    if (!clickControl(hell))
                        return FALSE;
                } else if (nightmare->dwDisabled != 0x4) {
                    if (!clickControl(nightmare))
                        return FALSE;
                } else if (normal->dwDisabled != 0x4) {
                    if (!clickControl(normal))
                        return FALSE;
                }
                break;
            default:
                return FALSE;
            }

            // Create Game Button
            pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 594, 433, 172, 32);
            if (!pControl || !clickControl(pControl))
                return FALSE;
        }
    }

    return TRUE;
}
Ejemplo n.º 16
0
OOG_Location OOG_GetLocation(void) {
    if (ClientState() != ClientStateMenu)
        return OOG_NONE;

    if (findControl(CONTROL_BUTTON, 5103, -1, 330, 416, 128, 35))
        return OOG_MAIN_MENU_CONNECTING; // 21 Connecting to Battle.net
    else if (findControl(CONTROL_BUTTON, 5102, -1, 335, 412, 128, 35))
        return OOG_LOGIN_ERROR;                                       // 10 Login Error
    else if (findControl(CONTROL_BUTTON, 5102, -1, 351, 337, 96, 32)) // 5102 =OK
    {
        if (findControl(CONTROL_TEXTBOX, 5351, -1, 268, 320, 264, 120))
            return OOG_LOST_CONNECTION; // 17 lost connection
        else if (findControl(CONTROL_TEXTBOX, 5347, -1, 268, 320, 264, 120))
            return OOG_DISCONNECTED; // 14  Disconnected
        else if (findControl(6, (const wchar_t*)NULL, -1, 265, 206, 272, 35))
            return OOG_UNABLE_TO_CONNECT_TCPIP;
        else
            return OOG_CHARACTER_CREATE_ALREADY_EXISTS;                 // 30 Character Create - Dupe Name
    } else if (findControl(CONTROL_BUTTON, 5103, -1, 351, 337, 96, 32)) // 5103 = CANCEL
    {
        if (findControl(CONTROL_TEXTBOX, 5243, -1, 268, 300, 264, 100))
            return OOG_CHARACTER_SELECT_PLEASE_WAIT; // 16 char select please wait...
        if (findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 268, 320, 264, 120))
            return OOG_PLEASE_WAIT; // 25 "Please Wait..."single player already exists also
    } else if (findControl(CONTROL_BUTTON, 5103, -1, 433, 433, 96, 32)) {
        if (findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 427, 234, 300, 100))
            return OOG_INLINE; // 2 waiting in line
        else if (findControl(CONTROL_TEXTBOX, 10018, -1, 459, 380, 150, 12))
            return OOG_CREATE; // 4 Create game
        else if (findControl(CONTROL_BUTTON, 5119, -1, 594, 433, 172, 32))
            return OOG_JOIN; // 5 Join Game
        else if (findControl(CONTROL_BUTTON, 5102, -1, 671, 433, 96, 32))
            return OOG_CHANNEL; // 7 "Channel List"
        else
            return OOG_LADDER;                                          // 6 "Ladder"
    } else if (findControl(CONTROL_BUTTON, 5101, -1, 33, 572, 128, 35)) // 5101 = EXIT
    {
        if (findControl(CONTROL_BUTTON, 5288, -1, 264, 484, 272, 35))
            return OOG_LOGIN; // 9 Login
        if (findControl(CONTROL_BUTTON, 5102, -1, 495, 438, 96, 32))
            return OOG_CHARACTER_SELECT_CHANGE_REALM;                                                                             // 43 char select change realm
        if (findControl(CONTROL_BUTTON, 5102, -1, 627, 572, 128, 35) && findControl(CONTROL_BUTTON, 10832, -1, 33, 528, 168, 60)) // 10832=create new
        {
            if (findControl(CONTROL_BUTTON, 10018, -1, 264, 297, 272, 35)) // NORMAL
                return OOG_DIFFICULTY;                                     // 20 single char Difficulty
            Control* pControl = findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 37, 178, 200, 92);
            if (pControl && pControl->pFirstText && pControl->pFirstText->pNext)
                return OOG_CHAR_SELECT; // 12 char select
            else {
                if (findControl(CONTROL_TEXTBOX, 11162, -1, 45, 318, 531, 140) || findControl(CONTROL_TEXTBOX, 11066, -1, 45, 318, 531, 140))
                    return OOG_REALM_DOWN;
                // Look for CONNECTING... string
                else if (findControl(CONTROL_TEXTBOX, 11065, -1, 0x2D, 0x13E, 0x213, 0x8C))
                    return OOG_CONNECTING;
                else
                    return OOG_CHARACTER_SELECT_NO_CHARS; // 42 char info not loaded
            }
        }
        if (findControl(CONTROL_BUTTON, 5101, -1, 33, 572, 128, 35)) // 5101=Exit
        {
            if (findControl(CONTROL_BUTTON, 5102, 0, 627, 572, 128, 35)) // 5102=ok
                return OOG_CHARACTER_CREATE;                             // 29 char create screen with char selected
            else {
                if (findControl(CONTROL_TEXTBOX, 5226, -1, 321, 448, 300, 32))
                    return OOG_NEW_ACCOUNT; // 32 create new bnet account
                else
                    return OOG_NEW_CHARACTER; // 15 char create screen no char selected
            }
        }
    }
    if (findControl(CONTROL_BUTTON, 5102, -1, 335, 450, 128, 35)) {
        if (findControl(CONTROL_TEXTBOX, 5200, -1, 162, 270, 477, 50))
            return OOG_CDKEY_IN_USE;                                         // 19 CD-KEY in use
        else if (findControl(CONTROL_TEXTBOX, 5190, -1, 162, 420, 477, 100)) // 5190="If using a modem"
            return OOG_UNABLE_TO_CONNECT;                                    // 11 unable to connect
        else
            return OOG_INVALID_CDKEY; // 22 invalid CD-KEY
    } else if (findControl(CONTROL_TEXTBOX, 5159, -1, 438, 300, 326, 150))
        return OOG_GAME_DOES_NOT_EXIST; // 28 game doesn't exist
    else if (findControl(CONTROL_TEXTBOX, 5161, -1, 438, 300, 326, 150))
        return OOG_GAME_IS_FULL; // 38 Game is full
    else if (findControl(CONTROL_TEXTBOX, 5138, -1, 438, 300, 326, 150))
        return OOG_GAME_EXIST; // 26 Game already exists
    else if (findControl(CONTROL_TEXTBOX, 5139, -1, 438, 300, 326, 150))
        return OOG_SERVER_DOWN;                                        // 24 server down
    else if (findControl(CONTROL_BUTTON, 5106, -1, 264, 324, 272, 35)) // 5106="SINGLE PLAYER"
        return OOG_MAIN_MENU;                                          // 8 Main Menu
    else if (findControl(CONTROL_BUTTON, 11126, -1, 27, 480, 120, 20)) // 11126=ENTER CHAT
        return OOG_LOBBY;                                              // 1 base bnet
    else if (findControl(CONTROL_BUTTON, 5308, -1, 187, 470, 80, 20))  // 5308="HELP"
        return OOG_CHAT;                                               // 3 chat bnet
    else if (findControl(CONTROL_TEXTBOX, 21882, -1, 100, 580, 600, 80))
        return OOG_D2SPLASH; // 18 Spash
    else if (findControl(CONTROL_BUTTON, 5102, -1, 281, 538, 96, 32))
        return OOG_GATEWAY; // 27 select gateway
    else if (findControl(CONTROL_BUTTON, 5181, -1, 525, 513, 128, 35))
        return OOG_AGREE_TO_TERMS; // 31 agree to terms
    else if (findControl(CONTROL_BUTTON, 5102, -1, 525, 513, 128, 35))
        return OOG_PLEASE_READ; // 33 please read
    else if (findControl(CONTROL_BUTTON, 11097, -1, 265, 527, 272, 35))
        return OOG_REGISTER_EMAIL; // 34 register email
    else if (findControl(CONTROL_BUTTON, 5101, -1, 33, 578, 128, 35))
        return OOG_CREDITS; // 35 Credits
    else if (findControl(CONTROL_BUTTON, 5103, -1, 334, 488, 128, 35))
        return OOG_CINEMATICS; // 36 Cinematics
    else if (findControl(CONTROL_BUTTON, 5116, -1, 264, 350, 272, 35))
        return OOG_OTHER_MULTIPLAYER; // 39 other multi player
    else if (findControl(CONTROL_BUTTON, 5103, -1, 281, 337, 96, 32))
        return OOG_ENTER_IP_ADDRESS; // 41 enter ip
    else if (findControl(CONTROL_BUTTON, 5118, -1, 265, 206, 272, 35))
        return OOG_TCP_IP; // 40 tcp-ip

    return OOG_NONE;
}
Ejemplo n.º 17
0
BOOL OOG_SelectGateway(const wchar_t* szGateway, size_t strSize) {
    if (ClientState() != ClientStateMenu)
        return FALSE;

    if (wcsstr(szGateway, L"ERROR"))
        return FALSE;
    // Select the gateway control.
    Control* pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 264, 391, 272, 25);

    // if the control exists and has the text label, check if it matches the selected gateway
    if (pControl && pControl->wText2) {
        wchar_t* wzLine = _wcsdup(pControl->wText2);
        wchar_t* wzGate = _wcsdup(szGateway);
        StringToLower(wzLine);
        StringToLower(wzGate);

        if (wcsstr(wzLine, wzGate)) {
            // gateway is correct, do nothing and return true
            free(wzLine);
            free(wzGate);
            return TRUE;
        } else {
            free(wzLine);
            // gateway is NOT correct, change gateway to selected gateway if it exists
            // open the gateway select screen
            if (!clickControl(pControl))
                return FALSE;

            int index = 0;
            bool gatefound = false;

            // loop here till we find the right gateway if we can
            pControl = findControl(CONTROL_TEXTBOX, (const wchar_t*)NULL, -1, 257, 500, 292, 160);
            ControlText* cText;
            if (pControl && pControl->pFirstText) {
                cText = pControl->pFirstText;
                while (cText) {
                    wchar_t* wzGatelist = _wcsdup(cText->wText[0]);
                    if (!wzGatelist) {
                        free(wzGate);
                        return FALSE;
                    }

                    StringToLower(wzGatelist);
                    if (wcsstr(wzGatelist, wzGate)) {
                        // chosen gateway IS in the list and matches, cleanup and break the loop
                        free(wzGatelist);
                        free(wzGate);
                        gatefound = true;
                        break;
                    }
                    free(wzGatelist);
                    index++;
                    cText = cText->pNext;
                }
                if (gatefound) {
                    // click the correct gateway using the control plus a default x and a y based on (index*24)+12
                    if (!clickControl(pControl, -1, 344 + ((index * 24) + 12))) {
                        free(wzGate);
                        return FALSE;
                    }
                }
            }

            free(wzGate);

            // OK Button, gateway select screen
            pControl = findControl(CONTROL_BUTTON, (const wchar_t*)NULL, -1, 281, 538, 96, 32);
            if (pControl) {
                if (!clickControl(pControl))
                    return FALSE;
            } else
                return FALSE;

            return TRUE;
        }
    }
    return FALSE;
}
Ejemplo n.º 18
0
Control* findControl(int Type, const wchar_t* Text, int Disabled, int PosX, int PosY, int SizeX, int SizeY) {
    if (ClientState() != ClientStateMenu)
        return NULL;

    if (Type == -1 && Text == NULL && Disabled == -1 && PosX == -1 && PosY == -1 && SizeX == -1 && SizeY == -1)
        return *p_D2WIN_FirstControl;

    BOOL bFound = FALSE;

    for (Control* pControl = *p_D2WIN_FirstControl; pControl; pControl = pControl->pNext) {
        if (Type >= 0 && static_cast<int>(pControl->dwType) == Type)
            bFound = TRUE;
        else if (Type >= 0 && static_cast<int>(pControl->dwType) != Type) {
            bFound = FALSE;
            continue;
        }

        if (Disabled >= 0 && static_cast<int>(pControl->dwDisabled) == Disabled) {
            if (pControl->dwType == CONTROL_BUTTON && pControl->unkState == 1) {
                bFound = FALSE;
                continue;
            }
            bFound = TRUE;
        } else if (Disabled >= 0 && static_cast<int>(pControl->dwDisabled) != Disabled) {
            bFound = FALSE;
            continue;
        }

        if (PosX >= 0 && static_cast<int>(pControl->dwPosX) == PosX)
            bFound = TRUE;
        else if (PosX >= 0 && static_cast<int>(pControl->dwPosX) != PosX) {
            bFound = FALSE;
            continue;
        }

        if (PosY >= 0 && static_cast<int>(pControl->dwPosY) == PosY)
            bFound = TRUE;
        else if (PosY >= 0 && static_cast<int>(pControl->dwPosY) != PosY) {
            bFound = FALSE;
            continue;
        }

        if (SizeX >= 0 && static_cast<int>(pControl->dwSizeX) == SizeX)
            bFound = TRUE;
        else if (SizeX >= 0 && static_cast<int>(pControl->dwSizeX) != SizeX) {
            bFound = FALSE;
            continue;
        }

        if (SizeY >= 0 && static_cast<int>(pControl->dwSizeY) == SizeY)
            bFound = TRUE;
        else if (SizeY >= 0 && static_cast<int>(pControl->dwSizeY) != SizeY) {
            bFound = FALSE;
            continue;
        }

        if (Text && pControl->dwType == CONTROL_BUTTON) {
            if (!pControl->wText2)
                return NULL;
            if (wcscmp(pControl->wText2, Text) == 0) {
                bFound = TRUE;
            } else {
                bFound = FALSE;
                continue;
            }
        }

        if (Text && pControl->dwType == CONTROL_TEXTBOX) {
            if (pControl->pFirstText != NULL && pControl->pFirstText->wText[0] != NULL) {
                if (!pControl->pFirstText->wText[0])
                    return NULL;
                if (wcsstr(Text, pControl->pFirstText->wText[0]) != 0) {
                    bFound = TRUE;
                } else {
                    bFound = FALSE;
                    continue;
                }
            } else {
                bFound = FALSE;
                continue;
            }
        }
        if (bFound)
            return pControl;
    }

    return NULL;
}
Ejemplo n.º 19
0
BOOL OOG_SelectGateway(char * szGateway, size_t strSize)
{
	if(ClientState() != ClientStateMenu)
		return FALSE;

	if(strstr(szGateway,"ERROR"))
		return FALSE;
	// Select the gateway control.
	Control* pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 264, 391, 272, 25);

	// if the control exists and has the text label, check if it matches the selected gateway
	if(pControl && pControl->wText2)
	{
		char* szLine = UnicodeToAnsi(pControl->wText2);
		if(!szLine)
			return FALSE;

		_strlwr_s(szLine, strlen(szLine)+1);
		_strlwr_s(szGateway, strSize);
		if(strstr(szLine, szGateway))
		{
			// gateway is correct, do nothing and return true
			delete[] szLine;
			return TRUE;
		}
		else
		{
			delete[] szLine;
			// gateway is NOT correct, change gateway to selected gateway if it exists
			// open the gateway select screen
			if(!clickControl(pControl))
				return FALSE;

			int index = 0;
			bool gatefound = false;

			// loop here till we find the right gateway if we can
			pControl = findControl(CONTROL_TEXTBOX, (char *)NULL, -1, 257, 500, 292, 160);
			ControlText* cText;
			if(pControl && pControl->pFirstText)
			{
				cText = pControl->pFirstText;
				while(cText)
				{
					char * szGatelist = UnicodeToAnsi(cText->wText[0]);
					if(!szGatelist)
						return FALSE;

					_strlwr_s(szGatelist, strlen(szGatelist)+1);
					if(strstr(szGatelist, szGateway))
					{
						// chosen gateway IS in the list and matches, cleanup and break the loop
						gatefound = true;
						delete[] szGatelist;
						break;
					}
					delete[] szGatelist;
					index++;
					cText = cText->pNext;
				}
				if(gatefound)
				{
				// click the correct gateway using the control plus a default x and a y based on (index*24)+12
					if(!clickControl(pControl, -1, 344+((index*24)+12)))
						return FALSE;
				}
			}

			// OK Button, gateway select screen
			pControl = findControl(CONTROL_BUTTON, (char *)NULL, -1, 281, 538, 96, 32);
			if(pControl)
			{
				if(!clickControl(pControl))
					return FALSE;
			}
			else
				return FALSE;

			return TRUE;
		}
	}
	return FALSE;
}
Ejemplo n.º 20
0
INT unit_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{	
	CDebug cDbg("unit getProperty");

	BnetData* pData = *p_D2LAUNCH_BnData;
	GameStructInfo* pInfo = *p_D2CLIENT_GameInfo;

	switch(JSVAL_TO_INT(id))
	{
		case ME_ACCOUNT:
			if(!pData)
				return JS_TRUE;
			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, pData->szAccountName));
			break;
		case ME_CHARNAME:
			if(!pInfo)
				return JS_TRUE;
			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, pInfo->szCharName));
			break;
		case ME_CHICKENHP:
			*vp = INT_TO_JSVAL(Vars.nChickenHP);
			break;
		case ME_CHICKENMP:
			*vp = INT_TO_JSVAL(Vars.nChickenMP);
			break;
		case ME_DIFF:
			*vp = INT_TO_JSVAL(D2CLIENT_GetDifficulty());
			break;
		case ME_GAMENAME:
			if(!pInfo)
				return JS_TRUE;
			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, pInfo->szGameName));
			break;
		case ME_GAMEPASSWORD:
			if(!pInfo)
				return JS_TRUE;
			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, pInfo->szGamePassword));
			break;
		case ME_GAMESERVERIP:
			if(!pInfo)
				return JS_TRUE;
			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, pInfo->szGameServerIp));
			break;
		case ME_GAMESTARTTIME:
			*vp = INT_TO_JSVAL(Vars.dwGameTime);
			break;
		case ME_GAMETYPE:
			*vp = INT_TO_JSVAL(*p_D2CLIENT_ExpCharFlag);
			break;
		case ME_ITEMONCURSOR:
			*vp = BOOLEAN_TO_JSVAL(!!D2CLIENT_GetCursorItem());
			break;
		case ME_LADDER:
			if(pData)
				*vp = BOOLEAN_TO_JSVAL(((pData->nCharFlags & PLAYER_TYPE_LADDER) == TRUE));
			break;
		case ME_QUITONHOSTILE:
			*vp = BOOLEAN_TO_JSVAL(Vars.bQuitOnHostile);
			break;
		case ME_REALM:
			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, pData->szRealmName));
			break;
		case ME_REALMSHORT:
			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, pData->szRealmName2));
			break;
		case OOG_SCREENSIZE:
			*vp = INT_TO_JSVAL(D2GFX_GetScreenSize());
			break;
		case OOG_WINDOWTITLE:
			CHAR szTitle[128];
			GetWindowText(D2WIN_GetHwnd(), szTitle, 128);
			*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, szTitle));
			break;
		case ME_PING:
			*vp = INT_TO_JSVAL(*p_D2CLIENT_Ping);
			break;
		case OOG_INGAME:
			*vp = BOOLEAN_TO_JSVAL(ClientState() == ClientStateMenu ? FALSE : TRUE);
			break;
		case OOG_QUITONERROR:
			*vp = BOOLEAN_TO_JSVAL(Vars.bQuitOnError);
			break;
		case OOG_MAXGAMETIME:
			*vp = INT_TO_JSVAL(Vars.dwMaxGameTime);
			break;
		case OOG_DEBUG:
			*vp = BOOLEAN_TO_JSVAL(Vars.bDebug);
			break;
		case ME_MERCREVIVECOST:
			*vp = INT_TO_JSVAL((*p_D2CLIENT_MercReviveCost));
			break;
		case ME_BLOCKKEYS:
			*vp = BOOLEAN_TO_JSVAL(Vars.bBlockKeys);
			break;
		case ME_BLOCKMOUSE:
			*vp = BOOLEAN_TO_JSVAL(Vars.bBlockMouse);
			break;
		default:
			break;
	}

/*
	// TODO: Properly fix this...
	if ((JSVAL_TO_INT(id) < OOG_WINDOWTITLE) && !GameReady())
			return JS_TRUE;
*/
	if(!GameReady())
		return JS_TRUE;

	myUnit* lpUnit = (myUnit*)JS_GetPrivate(cx, obj);

	if(!lpUnit || IsBadReadPtr(lpUnit, sizeof(myUnit)) || lpUnit->_dwPrivateType != PRIVATE_UNIT)
		return JS_TRUE;

	UnitAny* pUnit = D2CLIENT_FindUnit(lpUnit->dwUnitId, lpUnit->dwType);

	if(!pUnit)
		return JS_TRUE;

	char* tmp = NULL;
	Room1* pRoom = NULL;

	switch(JSVAL_TO_INT(id))
	{
		case UNIT_TYPE:
			*vp = INT_TO_JSVAL(pUnit->dwType);
			break;
		case UNIT_CLASSID:
			*vp = INT_TO_JSVAL(pUnit->dwTxtFileNo);
			break;
		case UNIT_MODE:
			*vp = INT_TO_JSVAL(pUnit->dwMode);
			break;
		case UNIT_NAME:
			tmp = new char[8192];
			GetUnitName(pUnit, tmp, 8192);
			*vp = STRING_TO_JSVAL(JS_InternString(cx, tmp));
			delete[] tmp;
			break;
		case UNIT_ACT:
			*vp = INT_TO_JSVAL(pUnit->dwAct + 1);
			break;
		case UNIT_AREA:
			pRoom = D2COMMON_GetRoomFromUnit(pUnit);
			if(pRoom && pRoom->pRoom2 && pRoom->pRoom2->pLevel)
				*vp = INT_TO_JSVAL(pRoom->pRoom2->pLevel->dwLevelNo);			
			break;
		case UNIT_ID:
			*vp = INT_TO_JSVAL(pUnit->dwUnitId);
			break;
		case UNIT_XPOS:
			*vp = INT_TO_JSVAL(GetUnitX(pUnit));
			break;
		case UNIT_YPOS:
			*vp = INT_TO_JSVAL(GetUnitY(pUnit));
			break;
		case UNIT_HP:
			*vp = INT_TO_JSVAL(D2COMMON_GetUnitStat(pUnit, 6, 0) >> 8);
			break;
		case UNIT_HPMAX:
			*vp = INT_TO_JSVAL(D2COMMON_GetUnitStat(pUnit, 7, 0) >> 8);
			break;
		case UNIT_MP:
			*vp = INT_TO_JSVAL(D2COMMON_GetUnitStat(pUnit, 8, 0) >> 8);
			break;
		case UNIT_MPMAX:
			*vp = INT_TO_JSVAL(D2COMMON_GetUnitStat(pUnit, 9, 0) >> 8);
			break;
		case UNIT_STAMINA:
			*vp = INT_TO_JSVAL(D2COMMON_GetUnitStat(pUnit, 10, 0) >> 8);
			break;
		case UNIT_STAMINAMAX:
			*vp = INT_TO_JSVAL(D2COMMON_GetUnitStat(pUnit, 11, 0) >> 8);
			break;
		case UNIT_CHARLVL:
			*vp = INT_TO_JSVAL(D2COMMON_GetUnitStat(pUnit, 12, 0));
			break;
		case ME_RUNWALK:
			*vp = INT_TO_JSVAL(*p_D2CLIENT_AlwaysRun);
			break;
		case UNIT_ADDRESS:
			*vp = INT_TO_JSVAL(pUnit);
			break;
		case UNIT_SPECTYPE:
			DWORD SpecType;
			SpecType = NULL;
			if(pUnit->dwType == UNIT_MONSTER && pUnit->pMonsterData)
			{
				if(pUnit->pMonsterData->fMinion & 1)
					SpecType |= 0x08;
				if(pUnit->pMonsterData->fBoss & 1)
					SpecType |= 0x04;
				if(pUnit->pMonsterData->fChamp & 1)
					SpecType |= 0x02;
				if((pUnit->pMonsterData->fBoss & 1)&& (pUnit->pMonsterData->fNormal & 1))
					SpecType |= 0x01;
				if(pUnit->pMonsterData->fNormal & 1)
					SpecType |= 0x00;
				*vp = INT_TO_JSVAL(SpecType);
				return JS_TRUE;
			}
			break;
		case UNIT_UNIQUEID:
			if(pUnit->dwType == UNIT_MONSTER && pUnit->pMonsterData->fBoss && pUnit->pMonsterData->fNormal)
				*vp = INT_TO_JSVAL(pUnit->pMonsterData->wUniqueNo);
			else
				*vp = INT_TO_JSVAL(-1);
			break;
		case ITEM_CODE: // replace with better method if found
			if(!(pUnit->dwType == UNIT_ITEM) && pUnit->pItemData)
				break;
			ItemTxt* pTxt;
			pTxt = D2COMMON_GetItemText(pUnit->dwTxtFileNo);
			if(!pTxt) {
				*vp = STRING_TO_JSVAL(JS_InternString(cx, "Unknown"));
				return JS_TRUE;
			}
			CHAR szCode[4];
			memcpy(szCode, pTxt->szCode, 3);
			szCode[3] = 0x00;
			*vp = STRING_TO_JSVAL(JS_InternString(cx, szCode));
			break;
		case ITEM_PREFIX:
			if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData)
				if (D2COMMON_GetItemMagicalMods(pUnit->pItemData->wPrefix))
					*vp = STRING_TO_JSVAL(JS_InternString(cx, D2COMMON_GetItemMagicalMods(pUnit->pItemData->wPrefix)));
			break;
			
		case ITEM_SUFFIX:
			if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData)
				if (D2COMMON_GetItemMagicalMods(pUnit->pItemData->wSuffix))
					*vp = STRING_TO_JSVAL(JS_InternString(cx, D2COMMON_GetItemMagicalMods(pUnit->pItemData->wSuffix)));
			break;
		case ITEM_PREFIXNUM:
				if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData)
					*vp = INT_TO_JSVAL(pUnit->pItemData->wPrefix);
			break;
		case ITEM_SUFFIXNUM:
				if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData)
					*vp = INT_TO_JSVAL(pUnit->pItemData->wSuffix);
			break;
		case ITEM_FNAME:
			if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData) {
				wchar_t wszfname[256] = L"";
				D2CLIENT_GetItemName(pUnit, wszfname, sizeof(wszfname));
				if(wszfname) {
					char* tmp = UnicodeToAnsi(wszfname);
					*vp = STRING_TO_JSVAL(JS_InternString(cx, tmp));
					delete[] tmp;
				}
			}
			break;
		case ITEM_QUALITY:
			if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData)
				*vp = INT_TO_JSVAL(pUnit->pItemData->dwQuality);
			break;
		case ITEM_NODE:
			if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData)
				*vp = INT_TO_JSVAL(pUnit->pItemData->NodePage);
			break;
		case ITEM_LOC:
			if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData)
				*vp = INT_TO_JSVAL(pUnit->pItemData->ItemLocation);
			break;
		case ITEM_SIZEX:
			if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData) {
				if(!D2COMMON_GetItemText(pUnit->dwTxtFileNo))
					break;
				*vp = INT_TO_JSVAL(D2COMMON_GetItemText(pUnit->dwTxtFileNo)->xSize);
			}
			break;
		case ITEM_SIZEY:
			if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData) {
				if(!D2COMMON_GetItemText(pUnit->dwTxtFileNo))
					break;
				*vp = INT_TO_JSVAL(D2COMMON_GetItemText(pUnit->dwTxtFileNo)->ySize);
			}
			break;
		case ITEM_Type:
			if(pUnit->dwType == UNIT_ITEM && pUnit->pItemData) {
				if(!D2COMMON_GetItemText(pUnit->dwTxtFileNo))
					break;
				*vp = INT_TO_JSVAL(D2COMMON_GetItemText(pUnit->dwTxtFileNo)->nType);
			}
			break;
		case ITEM_DESC:
			{
			if(pUnit->dwType != UNIT_ITEM)
				break;

				wchar_t wBuffer[8192] = L"";
				D2CLIENT_GetItemDesc(pUnit, wBuffer);
				tmp = UnicodeToAnsi(wBuffer);
				*vp = STRING_TO_JSVAL(JS_InternString(cx, tmp));
				delete[] tmp;
			}
			break;
		case UNIT_ITEMCOUNT:
			if(pUnit->pInventory)
				*vp = INT_TO_JSVAL(pUnit->pInventory->dwItemCount);
			break;
		case ITEM_BODYLOCATION:
			if(pUnit->dwType != UNIT_ITEM)
				break;
			if(pUnit->pItemData)
				*vp = INT_TO_JSVAL(pUnit->pItemData->BodyLocation);
			break;
		case UNIT_OWNER:
			*vp = INT_TO_JSVAL(pUnit->dwOwnerId);
			break;
		case UNIT_OWNERTYPE:
			*vp = INT_TO_JSVAL(pUnit->dwOwnerType);
			break;
		case ITEM_LEVEL:
			if(pUnit->dwType != UNIT_ITEM)
				break;
			if(pUnit->pItemData)
				*vp = INT_TO_JSVAL(pUnit->pItemData->dwItemLevel);
			break;
		case ITEM_LEVELREQ:
			if(pUnit->dwType != UNIT_ITEM)
				break;
			*vp = INT_TO_JSVAL(D2COMMON_GetItemLevelRequirement(pUnit, D2CLIENT_GetPlayerUnit()));
			break;
		case UNIT_DIRECTION:
			if(pUnit->pPath)
				*vp = INT_TO_JSVAL(pUnit->pPath->bDirection);
			break;
		case OBJECT_TYPE:
			if(pUnit->dwType == UNIT_OBJECT)
				if(pUnit->pObjectData)
				{
					pRoom = D2COMMON_GetRoomFromUnit(pUnit);
					if(pRoom && pRoom->pRoom2 && pRoom->pRoom2->pLevel && IsTownLevel(pRoom->pRoom2->pLevel->dwLevelNo))
						*vp = INT_TO_JSVAL(pUnit->pObjectData->Type & 255);
					else
						*vp = INT_TO_JSVAL(pUnit->pObjectData->Type);
				}
			break;
		case ME_WSWITCH:
			*vp = INT_TO_JSVAL(*p_D2CLIENT_bWeapSwitch);
			break;
		default:
			break;
	}

	return JS_TRUE;
}
Ejemplo n.º 21
0
BOOL GameReady(void)
{
	return (ClientState() == ClientStateInGame ? true : false);
}
Ejemplo n.º 22
0
const char* GetStarterScriptName(void)
{
	return (ClientState() == ClientStateInGame ? Vars.szDefault : ClientState() == ClientStateMenu ? Vars.szStarter : NULL);
}
Ejemplo n.º 23
0
ScriptState GetStarterScriptState(void)
{
	// the default return is InGame because that's the least harmful of the options
	return (ClientState() == ClientStateInGame ? InGame : ClientState() == ClientStateMenu ? OutOfGame : InGame);
}