Exemplo n.º 1
0
//============================================================================
void SetAuthSrvHostname (const char addr[]) {

    strncpy(s_authAddrConsole, addr, arrsize(s_authAddrConsole));
}
Exemplo n.º 2
0
//============================================================================
// File
//============================================================================
unsigned GetFileSrvHostnames (const char*** addrs) {

    *addrs = s_fileAddrs; 
    return arrsize(s_fileAddrs);
}
Exemplo n.º 3
0
//// PrintVersion ///////////////////////////////////////////////////////////////
void PrintVersion()
{
    wchar_t productString[256];
    ProductString(productString, arrsize(productString));
    printf("%S\n\n", productString);
}
Exemplo n.º 4
0
//============================================================================
// Auth
//============================================================================
unsigned GetAuthSrvHostnames (const char*** addrs) {

    *addrs = s_authAddrs; 
    return arrsize(s_authAddrs);
}
Exemplo n.º 5
0
void VaultTextNoteNode::SetVisitInfo (const plAgeInfoStruct & info) {
    
    ARRAY(wchar_t) buf;
    
    for (unsigned i = 0; i < kNumAgeInfoFields; ++i) {
        switch (i) {
            case kAgeFilename: {
                wchar_t src[128];
                StrToUnicode(src, info.GetAgeFilename(), arrsize(src));
                unsigned len = StrLen(src);
                wchar_t * dst = buf.New(len);
                memcpy(dst, src, len * sizeof(src[0]));
            }
            break;
            
            case kAgeInstName: {
                wchar_t src[128];
                StrToUnicode(src, info.GetAgeInstanceName(), arrsize(src));
                unsigned len = StrLen(src);
                wchar_t * dst = buf.New(len);
                memcpy(dst, src, len * sizeof(src[0]));
            }
            break;
            
            case kAgeUserName: {
                wchar_t src[128];
                StrToUnicode(src, info.GetAgeUserDefinedName(), arrsize(src));
                unsigned len = StrLen(src);
                wchar_t * dst = buf.New(len);
                memcpy(dst, src, len * sizeof(src[0]));
            }
            break;
            
            case kAgeDesc: {
                wchar_t src[128];
                StrToUnicode(src, info.GetAgeDescription(), arrsize(src));
                unsigned len = StrLen(src);
                wchar_t * dst = buf.New(len);
                memcpy(dst, src, len * sizeof(src[0]));
            }
            break;
            
            case kAgeInstGuid: {
                plUUID guid = *info.GetAgeInstanceGuid();
                wchar_t src[64];
                wcsncpy(src, guid.AsString().ToWchar(), 64);
                unsigned len = StrLen(src);
                wchar_t * dst = buf.New(len);
                memcpy(dst, src, len * sizeof(src[0]));
            }
            break;
            
            case kAgeLanguage: {
                wchar_t src[32];
                StrPrintf(src, arrsize(src), L"%u", info.GetAgeLanguage());
                unsigned len = StrLen(src);
                wchar_t * dst = buf.New(len);
                memcpy(dst, src, len * sizeof(src[0]));
            }
            break;
            
            case kAgeSequence: {
                wchar_t src[32];
                StrPrintf(src, arrsize(src), L"%u", info.GetAgeSequenceNumber());
                unsigned len = StrLen(src);
                wchar_t * dst = buf.New(len);
                memcpy(dst, src, len * sizeof(src[0]));
            }
            break;

            DEFAULT_FATAL(i);
        }
        
        wchar_t * sep = buf.New(1);
        *sep = L'|';            
    }
    
    wchar_t * term = buf.New(1);
    *term = 0;
    
    SetNoteText(buf.Ptr());
}
Exemplo n.º 6
0
//============================================================================
void plNCAgeJoiner::ExecNextOp () {
    plNetClientMgr *    nc = plNetClientMgr::GetInstance();
    plAvatarMgr *       am = plAvatarMgr::GetInstance();
    plAgeLoader *       al = plAgeLoader::GetInstance();

    NextOp next = nextOp;
    nextOp      = kNoOp;
    switch (next) {
        //====================================================================
        case kNoOp: {
        }
        break;
            
        //====================================================================
        case kLoadAge: {
            LogMsg(kLogPerf, L"AgeJoiner: Exec:kLoadAge");

            // Start progress bar
            char str[256];
        #ifdef PLASMA_EXTERNAL_RELEASE
            StrCopy(str, "Loading age...", arrsize(str));
        #else
            StrPrintf(str, arrsize(str), "Loading age %s...", age.ageDatasetName);
        #endif
            progressBar = plProgressMgr::GetInstance()->RegisterOperation(0, str, plProgressMgr::kNone, false, true);
            plDispatch::SetMsgRecieveCallback(IDispatchMsgReceiveCallback);
            ((plResManager*)hsgResMgr::ResMgr())->SetProgressBarProc(IResMgrProgressBarCallback);

            // Start loading age data
            al->LoadAge(age.ageDatasetName);
        }
        break;

        //====================================================================
        case kLoadPlayer: {
            LogMsg(kLogPerf, L"AgeJoiner: Exec:kLoadPlayer");
            // Start loading local player
            const char * avatarName;
            if (NetCommNeedToLoadAvatar()) {
                if (nc->GetFlagsBit(plNetClientApp::kLinkingToOfflineAge))
                    avatarName = "Male";
                else
                    avatarName = NetCommGetPlayer()->avatarDatasetName;
                plString linkInName = plNetLinkingMgr::GetInstance()->GetAgeLink()->SpawnPoint().GetName();
                am->LoadPlayer( avatarName, nil, linkInName.c_str() );
            }
            else {
                LogMsg(kLogPerf, L"AgeJoiner: Next:kPropagatePlayer");
                nextOp = kPropagatePlayer;
            }
        }
        break;

        //====================================================================
        case kPropagatePlayer: {
            LogMsg(kLogPerf, L"AgeJoiner: Exec:kPropagatePlayer");
            // Add our avatar to the scene
            int spawnPt = am->FindSpawnPoint(age.spawnPtName);
            nc->IPlayerChangeAge(false /*not exiting*/, spawnPt);

            if (!nc->GetFlagsBit(plNetClientApp::kLinkingToOfflineAge))
                // Add our avatar to the game state
                am->PropagateLocalPlayer(spawnPt);
            
            LogMsg(kLogPerf, L"AgeJoiner: Next:kRequestAgeState");
            nextOp = kRequestAgeState;
        }
        break;

        //============================================================================
        case kRequestAgeState: {
            LogMsg(kLogPerf, L"AgeJoiner: Exec:kRequestAgeState");
            if (nc->GetFlagsBit(plNetClientApp::kLinkingToOfflineAge)) {
                LogMsg(kLogPerf, L"AgeJoiner: Next:kSimStateRcvd");
                nextOp = kSimStateRcvd;
            }
            else {
                // Request age player list
                nc->ISendMembersListRequest();

                // Request initial SDL state
                plNetMsgGameStateRequest gsmsg;
                gsmsg.SetNetProtocol(kNetProtocolCli2Game);
                gsmsg.SetBit(plNetMessage::kInitialAgeStateRequest);
                nc->SendMsg(&gsmsg);
                
                // Send our avatar settings
                nc->SendLocalPlayerAvatarCustomizations();
            }
        }
        break;

        //====================================================================
        case kSimStateRcvd: {
            nc->NotifyRcvdAllSDLStates();
        }
        break;

        //============================================================================
        case kDestroyProgressBar: {
            plDispatch::SetMsgRecieveCallback(nil);
            ((plResManager*)hsgResMgr::ResMgr())->SetProgressBarProc(nil);
            delete progressBar;
            progressBar = nil;
            nc->EndTask();

            nextOp = kEnableClickables;
        }
        break;

        //====================================================================
        case kEnableClickables: {
            LogMsg(kLogPerf, L"AgeJoiner: Exec:kEnableClickables");
            // Enable scene clickables
            (void)(new plInputIfaceMgrMsg(plInputIfaceMgrMsg::kEnableClickables))->Send();

            LogMsg(kLogPerf, L"AgeJoiner: Next:kNotifyAgeLoaded");
            nextOp = kNotifyAgeLoaded;
        }
        break;
        
        //====================================================================
        case kNotifyAgeLoaded: {
            LogMsg(kLogPerf, L"AgeJoiner: Exec:kNotifyAgeLoaded");
            nc->SetFlagsBit(plNetClientApp::kPlayingGame);
            nc->SetFlagsBit(plNetClientApp::kNeedToSendInitialAgeStateLoadedMsg);
            plAgeLoader::GetInstance()->NotifyAgeLoaded(true);
            nextOp = kNoOp;
        }
        break;

        DEFAULT_FATAL(nextOp);
    }
}
Exemplo n.º 7
0
//============================================================================
void SetFileSrvHostname (const char addr[]) {

    strncpy(s_fileAddrConsole, addr, arrsize(s_fileAddrConsole));
}
Exemplo n.º 8
0
void KillBlobs( int player )
{
	int x,y;
	const int   position[] = {  0, 15, 27, 39, 51, 63, 72, 81, 90, 99,105,
	                          111,117,123,126,129,131,132,133,134,135,135,
	                          136,136,137,137,138,138,138,139,139,139,139,
	                          140,140,140 },
	            shading [] = {20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
	                          31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
	                          31, 30, 29, 28, 26, 24, 21, 18, 15, 12, 9,
	                           6,  3,  0 },
	            blobGraphic[kZapFrames] = { kDying,   kDying,   kDying,   kDying,   kSquish1,
	                                        kSquish1, kSquish1, kSquish1, kSquish2, kSquish2,
	                                        kSquish2, kSquish2, kSquish3, kSquish3, kSquish3,
	                                        kSquish3, kSquish4, kSquish4, kSquish4, kSquish4 },
	            grayGraphic[kZapFrames] = { kGrayBlink1, kGrayBlink1, kGrayBlink1,
	                                        kGrayBlink1, kGrayBlink1, kGrayBlink1,
	                                        kGrayBlink2, kGrayBlink2, kGrayBlink2,
	                                        kGrayBlink2, kGrayBlink2, kGrayBlink2,
	                                        kGrayBlink3, kGrayBlink3, kGrayBlink3,
	                                        kGrayBlink3, kGrayBlink3, kGrayBlink3,
	                                        kGrayBlink3, kGrayBlink3 };
	SDL_Rect myRect;
	bool busy = false;
	SDLU_Point dPoint, oPoint;
	char *scan;

	if( blobTime[player] > GameTickCount( ) )
		return;

	blobTime[player]++;

	SDLU_AcquireSurface( playerSurface[player] );

	// clear grenade sprite
	if( grenadeFrame[player] <= kBlastFrames )
	{
		CleanSpriteArea( player, &grenadeRect[player] );
		if( grenadeFrame[player] == kBlastFrames ) grenadeFrame[player]++;
	}

	for( x=0; x<kGridAcross; x++ )
	{
		for( y=0; y<kGridDown; y++ )
		{
			if( grid[player][x][y] >= kFirstBlob &&  // if a blob is dying
				grid[player][x][y] <= kLastBlob &&
				suction[player][x][y] == kInDeath )
			{
				death[player][x][y]++;
				busy = true;

				CalcBlobRect( x, y, &myRect );

				if( death[player][x][y] >= 0 && death[player][x][y] <= kZapFrames ) // draw its death
				{
					if( death[player][x][y] == kZapFrames )
					{
						grid[player][x][y] = kEmpty;
						suction[player][x][y] = kNoSuction;
						charred[player][x][y] = kNoCharring;
						SurfaceDrawBlob( player, &myRect, kEmpty, kNoSuction, kNoCharring );
						CleanSpriteArea( player, &myRect );
					}
					else
					{
						SurfaceDrawBlob( player, &myRect,
						                 grid[player][x][y],
						                 blobGraphic[ death[player][x][y] ],
						                 kNoCharring );
						CleanSpriteArea( player, &myRect );
					}

					CleanChunks( player, x, y, death[player][x][y], character[player].zapStyle );
				}
				else
				{
					SurfaceDrawBlob( player, &myRect, grid[player][x][y],
								(blobTime[player] & 2)? kFlashDarkBlob: kNoSuction, kNoCharring );
					CleanSpriteArea( player, &myRect );
				}
			}
			else
			{
				if( grid[player][x][y] == kGray &&					// gray dying
					suction[player][x][y] == kGrayBlink1 )
				{
					CalcBlobRect( x, y, &myRect );

					if( death[player][x][y] >= 0 && death[player][x][y] <= kZapFrames )
					{
						if( death[player][x][y] == kZapFrames )
						{
							grid[player][x][y] = kEmpty;
							suction[player][x][y] = kNoSuction;
							SurfaceDrawBlob( player, &myRect, kEmpty, kNoSuction, kNoCharring );
						}
						else
						{
							SurfaceDrawBoard( player, &myRect );
							SurfaceDrawAlpha( &myRect, kGray, kLight, grayGraphic[ death[player][x][y] ] );
							busy = true;
						}
						CleanSpriteArea( player, &myRect );
					}

					death[player][x][y]++;
				}
			}
		}
	}

	// draw score info above blobs but below chunks and explosions

	if( zapScoreFrame[player] < arrsize(position) )
	{
		myRect.y = zapScorePt[player].y - (position[zapScoreFrame[player]    ]);
		myRect.x = zapScorePt[player].x;
		myRect.h = 15 - (position[zapScoreFrame[player] - 1]);
		myRect.w = zapScoreWidth[player];
		CleanSpriteArea( player, &myRect );

		if( zapScoreFrame[player] < arrsize(position)-1 )
		{
			SDLU_AcquireSurface( playerSpriteSurface[player] );

			dPoint.y = oPoint.y = myRect.y;
			dPoint.x = oPoint.x = myRect.x;
			scan = zapScore[player];
			while( *scan )
			{
				SurfaceBlitWeightedCharacter( zapFont,    *scan, &dPoint, zapScoreR[player], zapScoreG[player], zapScoreB[player], shading[zapScoreFrame[player]] );
				SurfaceBlitWeightedCharacter( zapOutline, *scan, &oPoint, 0,                 0,                 0,                 shading[zapScoreFrame[player]] );
				scan++;
			}

			SDLU_ReleaseSurface( playerSpriteSurface[player] );

			zapScoreFrame[player]++;
			busy = true;
		}
	}

	///////////////////////////////////////////////////////////////

	for( x=0; x<kGridAcross; x++ )
	{
		for( y=0; y<kGridDown; y++ )
		{
			if( grid[player][x][y] >= kFirstBlob &&  // if a blob is dying
				grid[player][x][y] <= kLastBlob &&
				suction[player][x][y] == kInDeath &&
				death[player][x][y] >= 0 && death[player][x][y] < kZapFrames ) // draw chunks (after all that stuff)
			{
				DrawChunks( player, x, y, death[player][x][y], character[player].zapStyle );
			}
		}
	}

	SDLU_ReleaseSurface( playerSurface[player] );

	if( grenadeFrame[player] < kBlastFrames )
	{
		busy = true;

		SDLU_AcquireSurface( playerSpriteSurface[player] );

		myRect.y = grenadeFrame[player] * kBlastHeight;
		myRect.x = 0;
		myRect.h = kBlastHeight;
		myRect.w = kBlastWidth;

		SurfaceBlitAlpha(  playerSpriteSurface[player],  blastSurface,  blastMaskSurface,  playerSpriteSurface[player],
		                  &grenadeRect[player],         &myRect,       &myRect,           &grenadeRect[player]          );

		grenadeFrame[player]++;

		SDLU_ReleaseSurface( playerSpriteSurface[player] );
	}

	if( !busy && role[player] == kKillBlobs )
	{
		blobTime[player] = GameTickCount( );
		halfway[player] = false;
		role[player] = kDropBlobs;
	}
}
Exemplo n.º 9
0
#include "GameSpriteDemo.hpp"
#include "ScratchComponents.h"

static const char * s_spriteFiles[] = {
    "sonic-1-sonic.json",
    "kenney/platformer_redux/spritesheet_players.json",
    "kirby.json",
    "shadow.json",
    //"sonic-1-sonic.json",
};
static const unsigned s_spriteFilesCount = arrsize(s_spriteFiles);

static const char s_levelFile[] = "levels/level0.json";

GameSpriteDemo::GameSpriteDemo(void)
{}


GameSpriteDemo::~GameSpriteDemo(void)
{
  UnloadContent();
}


bool GameSpriteDemo::LoadContent(void)
{

    // Make every GameObject hot-reloadable when 'A' is pressed
    for (unsigned i = 0; i < s_goCount; ++i) {
        m_gameObjects[i].AddComponent(new GocTest());
        m_gameObjects[i].AddComponent(new GocGamepad());
Exemplo n.º 10
0
bool plAgeLoader::ILoadAge(const char ageName[])
{
    plNetClientApp* nc = plNetClientApp::GetInstance();
    ASSERT(!nc->GetFlagsBit(plNetClientApp::kPlayingGame));

    StrCopy(fAgeName, ageName, arrsize(fAgeName));
    
    nc->DebugMsg( "Net: Loading age %s", fAgeName);

    if ((fFlags & kLoadMask) != 0)
        ErrorAssert(__LINE__, __FILE__, "Fatal Error:\nAlready loading or unloading an age.\n%S will now exit.", ProductShortName());
        
    fFlags |= kLoadingAge;
    
    plAgeBeginLoadingMsg* ageBeginLoading = new plAgeBeginLoadingMsg();
    ageBeginLoading->Send();

    ///////////////////////////////////////////////////////


    /// Step 1: Update all of the dat files for this age
    /*
    UpdateAge(fAgeName);
    */

    /// Step 2: Load the keys for this age, so we can find sceneNodes for them
    // exec age .fni file when data is done loading
    char consoleIniName[ 256 ];
    sprintf( consoleIniName, "dat\\%s.fni", fAgeName);
    fPendingAgeFniFiles.push_back( consoleIniName );

    char csvName[256];
    sprintf(csvName, "dat\\%s.csv", fAgeName);
    fPendingAgeCsvFiles.push_back(csvName);
    
    plSynchEnabler p( false );  // turn off dirty tracking while in this function   

    hsStream* stream=GetAgeDescFileStream(fAgeName);
    if (!stream)
    {
        nc->ErrorMsg("Failed loading age.  Age desc file %s has nil stream", fAgeName);
        fFlags &= ~kLoadingAge;
        return false;
    }

    plAgeDescription ad;
    ad.Read(stream);
    ad.SetAgeName(fAgeName);
    stream->Close();
    delete stream;
    ad.SeekFirstPage();
    
    plAgePage *page;
    plKey clientKey = hsgResMgr::ResMgr()->FindKey( kClient_KEY );

    // Copy, exclude pages we want excluded, and collect our scene nodes
    fCurAgeDescription.CopyFrom(ad);
    while( ( page = ad.GetNextPage() ) != nil )
    {
        if( IsPageExcluded( page, fAgeName) )
            continue;

        plKey roomKey = plKeyFinder::Instance().FindSceneNodeKey( fAgeName, page->GetName() );
        if( roomKey != nil )
            AddPendingPageInRoomKey( roomKey );
    }
    ad.SeekFirstPage();


    // Tell the client to load-and-hold all the keys for this age, to make the loading process work better
    plClientMsg *loadAgeKeysMsg = new plClientMsg( plClientMsg::kLoadAgeKeys );
    loadAgeKeysMsg->SetAgeName( fAgeName);
    loadAgeKeysMsg->Send( clientKey );

    //
    // Load the Age's SDL Hook object (and it's python modifier)
    //  
    plUoid oid=nc->GetAgeSDLObjectUoid(fAgeName);
    plKey ageSDLObjectKey = hsgResMgr::ResMgr()->FindKey(oid);
    if (ageSDLObjectKey)
        hsgResMgr::ResMgr()->AddViaNotify(ageSDLObjectKey, new plGenRefMsg(nc->GetKey(), plRefMsg::kOnCreate, -1, 
        plNetClientMgr::kAgeSDLHook), plRefFlags::kActiveRef);
    
    int nPages = 0;

    plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kLoadRoom);
    pMsg1->SetAgeName(fAgeName);

    // Loop and ref!
    while( ( page = ad.GetNextPage() ) != nil )
    {
        if( IsPageExcluded( page, fAgeName) )
        {
            nc->DebugMsg( "\tExcluding page %s\n", page->GetName() );
            continue;
        }

        nPages++;

        pMsg1->AddRoomLoc(ad.CalcPageLocation(page->GetName()));
        nc->DebugMsg("\tPaging in room %s\n", page->GetName());
    }

    pMsg1->Send(clientKey);

    // Send the client a message to let go of the extra keys it was holding on to
    plClientMsg *dumpAgeKeys = new plClientMsg( plClientMsg::kReleaseAgeKeys );
    dumpAgeKeys->SetAgeName( fAgeName);
    dumpAgeKeys->Send( clientKey );

    if ( nPages==0 )
    {
        // age is done loading because it has no pages?
        fFlags &= ~kLoadingAge;
    }

    return true;
}
//==============================================================================
bool CGraphicsMgr::Startup (HINSTANCE hInstance, HWND hwnd) {
    
    m_hInstance = hInstance;
    m_hWnd = hwnd;

    RECT dimensions;
    GetClientRect(hwnd, &dimensions);

    unsigned int width = dimensions.right - dimensions.left;
    unsigned int height = dimensions.bottom - dimensions.top;

    D3D_DRIVER_TYPE driver_types[] = {
        //D3D_DRIVER_TYPE_HARDWARE,
        D3D_DRIVER_TYPE_WARP,
        D3D_DRIVER_TYPE_SOFTWARE
    };

    unsigned int driver_type_count = sizeof(driver_types) / sizeof(driver_types[0]);

    D3D_FEATURE_LEVEL feature_levels[] = {
        D3D_FEATURE_LEVEL_11_0,
        D3D_FEATURE_LEVEL_10_1,
        D3D_FEATURE_LEVEL_10_0
    };

    unsigned int feature_level_count = sizeof(feature_levels) / sizeof(feature_levels[0]);

    DXGI_SWAP_CHAIN_DESC swap_chain_desc;
    SecureZeroMemory(&swap_chain_desc, sizeof(swap_chain_desc));
    swap_chain_desc.BufferCount = 1;
    swap_chain_desc.BufferDesc.Width = width;
    swap_chain_desc.BufferDesc.Height = height;
    swap_chain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    swap_chain_desc.BufferDesc.RefreshRate.Numerator = 60;
    swap_chain_desc.BufferDesc.RefreshRate.Denominator = 1;
    swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    swap_chain_desc.OutputWindow = hwnd;
    swap_chain_desc.Windowed = true;
    swap_chain_desc.SampleDesc.Count = 1;
    swap_chain_desc.SampleDesc.Quality = 0;

    unsigned int creation_flags = 0;

#if defined(_DEBUG)
    creation_flags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

    HRESULT hresult;
    unsigned int driver;

    for (driver = 0;  driver < driver_type_count;  ++driver) {
    
        hresult = D3D11CreateDeviceAndSwapChain(
            0, driver_types[driver], 0,
            creation_flags,
            feature_levels, feature_level_count,
            D3D11_SDK_VERSION,
            &swap_chain_desc, &m_swapChain, &m_d3dDevice, &m_featureLevel, &m_d3dContext
        );
        if (SUCCEEDED(hresult)) {
            m_driverType = driver_types[driver];
            break;
        }
    }
    if (FAILED(hresult)) {
        DXTRACE_MSG(L"Failed to create the Direct3D device!");
        return false;
    }
#if defined(_DEBUG)
    {
        char tempName[] = "GraphicsMgr's SwapChain";
        m_swapChain->SetPrivateData(WKPDID_D3DDebugObjectName, arrsize(tempName), tempName);
    }
#endif

    // Debug layer
    if (SUCCEEDED(m_d3dDevice->QueryInterface(__uuidof(ID3D11Debug), (void**)&m_d3dDebug))) {
        ID3D11InfoQueue * d3dInfoQueue = nullptr;
        if (SUCCEEDED(m_d3dDebug->QueryInterface(__uuidof(ID3D11InfoQueue), (void**)&d3dInfoQueue))) {
#if defined(_DEBUG)
            d3dInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_CORRUPTION, true);
            d3dInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, true);
            //d3dInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_WARNING, true);
            //d3dInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_INFO, true);
#endif

            D3D11_MESSAGE_ID hiddenMessages[] = {
                D3D11_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS,
            };

            D3D11_INFO_QUEUE_FILTER filter;
            memset(&filter, 0, sizeof(filter));
            filter.DenyList.NumIDs  = _countof(hiddenMessages);
            filter.DenyList.pIDList = hiddenMessages;
            d3dInfoQueue->AddStorageFilterEntries(&filter);
            d3dInfoQueue->Release();
        }
    }

    ID3D11Texture2D* back_buffer_texture;
    hresult = m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&back_buffer_texture);

    if (FAILED(hresult)) {
        DXTRACE_MSG(L"Failed to get the swap chain back buffer!");
        return false;
    }

    hresult = m_d3dDevice->CreateRenderTargetView(back_buffer_texture, 0, &m_backBufferTarget);
    if (FAILED(hresult)) {
        DXTRACE_MSG(L"Failed to create the render target view!");
        ASSERT(!FAILED(hresult));
        return false;
    }
#if defined(_DEBUG)
    {
        char tempName[] = "GraphicsMgr's BackBufferTarget";
        m_backBufferTarget->SetPrivateData(WKPDID_D3DDebugObjectName, arrsize(tempName), tempName);
    }
#endif

    if (back_buffer_texture)
        back_buffer_texture->Release();

    m_d3dContext->OMSetRenderTargets(1, &m_backBufferTarget, 0);

    D3D11_VIEWPORT viewport;
    viewport.Width = static_cast<float>(width);
    viewport.Height = static_cast<float>(height);
    viewport.MinDepth = 0.0f;
    viewport.MaxDepth = 1.0f;
    viewport.TopLeftX = 0.0f;
    viewport.TopLeftY = 0.0f;

    m_d3dContext->RSSetViewports(1, &viewport);
    
    // Don't backface cull
    {
        D3D11_RASTERIZER_DESC rasterDesc;
        SecureZeroMemory(&rasterDesc, sizeof(rasterDesc));
        rasterDesc.CullMode        = D3D11_CULL_NONE;
        rasterDesc.DepthClipEnable = true;
        rasterDesc.FillMode        = D3D11_FILL_SOLID;
        //rasterDesc.FillMode        = D3D11_FILL_WIREFRAME;
        
        HRESULT result = m_d3dDevice->CreateRasterizerState(
            &rasterDesc,
            &m_rasterState
        );
        if (FAILED(result)) {
            ASSERT(!FAILED(result));
            return false;
        }
#if defined(_DEBUG)
        {
            char tempName[] = "GraphicsMgr's RasterState";
            m_rasterState->SetPrivateData(WKPDID_D3DDebugObjectName, arrsize(tempName), tempName);
        }
#endif
            
        m_d3dContext->RSSetState(m_rasterState);
    }
    
    D3D11_BUFFER_DESC const_desc;
    SecureZeroMemory(&const_desc, sizeof(const_desc));
    const_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
    const_desc.ByteWidth = sizeof(XMMATRIX);
    const_desc.Usage = D3D11_USAGE_DEFAULT;

    HRESULT d3d_result = g_graphicsMgrInt->GetDevice()->CreateBuffer(&const_desc, 0, &m_projectionFromWorldMtxCb);
    if (FAILED(d3d_result)) {
        ASSERT(!FAILED(d3d_result));
        return false;
    }
#if defined(_DEBUG)
    {
        char tempName[] = "GraphicsMgr's projectionFromWorldMtx ConstantBuffer";
        m_projectionFromWorldMtxCb->SetPrivateData(WKPDID_D3DDebugObjectName, arrsize(tempName), tempName);
    }
#endif
        
#ifdef _DEBUG
    // Hacks!! Hides issues with lost pointers to VertexShaders!
    m_vertexShaders.reserve(16);
    m_pixelShaders.reserve(16);
#endif
    
    ASSERT(!g_keyboardMouse);
    XInputKeyboardMouse * xikm = new XInputKeyboardMouse();
    xikm->Startup(hInstance, hwnd, width, height);
    
    return true;

}
#include "Spritesheet.h"
#include <D3Dcompiler.h>
#include "../input/DirectInputKeyboardMouse.h"

#define REPORT_OBJECT_LEAKS 1

//==============================================================================
static_assert(sizeof(Vec3) == sizeof(XMFLOAT3), "Vec3 and XMFLOAT3 must be identical in memory.");
static_assert(sizeof(Vec2) == sizeof(XMFLOAT2), "Vec2 and XMFLOAT2 must be identical in memory.");

//==============================================================================
const D3D11_INPUT_ELEMENT_DESC s_VertexPos3UvLayout[] = {
    { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0,                0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT,    0, sizeof(XMFLOAT3), D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
const unsigned s_VertexPos3UvLayoutCount = arrsize(s_VertexPos3UvLayout);

//==============================================================================
const D3D11_INPUT_ELEMENT_DESC s_VertexPos3RgbLayout[] = {
    { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0,                0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    { "COLOR",    0, DXGI_FORMAT_R32G32B32_FLOAT, 0, sizeof(XMFLOAT3), D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
const unsigned s_VertexPos3RgbLayoutCount = arrsize(s_VertexPos3RgbLayout);

//==============================================================================
Vec2::Vec2 (const XMFLOAT2 & xmfloat2) {
    memcpy(this, &xmfloat2, min(sizeof(*this), sizeof(xmfloat2)));
}

//==============================================================================
Vec3::Vec3 (const XMFLOAT3 & xmfloat3) {
Exemplo n.º 13
0
//============================================================================
long AsyncPerfGetCounter (EAsyncPerfCounter id) {
    static_assert(arrsize(s_perf) == kNumAsyncPerfCounters, "Max async counters and array size do not match.");
    ASSERT(id < kNumAsyncPerfCounters);
    return s_perf[id];
}
Exemplo n.º 14
0
int main(int argc, char *argv[])
{
    bool generatingKey = false;
    bool useDefault = false;
    plFileName directory;
    plString ext;

    if (argc > 1)
    {
        for (int i = 1; i < argc; i++)
        {
            std::string arg = argv[i];
            if ((arg[0] == '-')||(arg[0] == '/'))
            {
                // this arg is a flag of some kind
                arg = arg.substr(1, arg.length()); // trim the dash or slash
                if ((stricmp(arg.c_str(), "g") == 0) || (stricmp(arg.c_str(), "generate") == 0))
                {
                    if (!generatingKey)
                        generatingKey = true;
                    else
                    {
                        print_help();
                        return 0;
                    }
                }
                else if ((stricmp(arg.c_str(), "d") == 0) || (stricmp(arg.c_str(), "default") == 0))
                {
                    if (!useDefault)
                        useDefault = true;
                    else
                    {
                        print_help();
                        return 0;
                    }
                }
                else
                {
                    print_help();
                    return 0;
                }
            }
            else
            {
                // else it is a directory or extension
                if (!directory.IsValid())
                    directory = argv[i];
                else if (ext.IsEmpty())
                    ext = argv[i];
                else
                {
                    print_help();
                    return 0;
                }
            }
        }

        if (generatingKey && ((directory.IsValid()) || (!ext.IsEmpty())))
        {
            print_help();
            return 0;
        }
    }
    else
    {
        print_help();
        return 0;
    }

    if (generatingKey)
    {
        GenerateKey(useDefault);
        return 0;
    }

    // Make sure ext is a real pattern, or we won't find anything
    if (ext.CharAt(0) == '.')
        ext = "*" + ext;
    else if (ext.CharAt(0) != '*')
        ext = "*." + ext;

    if (useDefault)
        SecureFiles(directory, ext, nil);
    else
    {
        uint32_t key[4];
        plSecureStream::GetSecureEncryptionKey(plSecureStream::kKeyFilename, key, arrsize(key));
        SecureFiles(directory, ext, key);
    }
    return 0;
}
Exemplo n.º 15
0
//============================================================================
// GateKeeper
//============================================================================
unsigned GetGateKeeperSrvHostnames (const char*** addrs) {

    *addrs = s_gateKeeperAddrs; 
    return arrsize(s_gateKeeperAddrs);
}
Exemplo n.º 16
0
bool plWin32StreamingSound::LoadSound( bool is3D )
{
    if( fFailed )
        return false;
    if( !plgAudioSys::Active() || fDSoundBuffer )
        return false;

    if( fPriority > plgAudioSys::GetPriorityCutoff() )
        return false;   // Don't set the failed flag, just return

    // Debug flag #1
    if( is3D && fChannelSelect > 0 && plgAudioSys::IsDebugFlagSet( plgAudioSys::kDisableRightSelect ) )
    {
        // Force a fail
        fFailed = true;
        return false;   
    }
    plSoundBuffer::ELoadReturnVal retVal = IPreLoadBuffer(true);
    if(retVal == plSoundBuffer::kPending)
        return true;

    if( retVal == plSoundBuffer::kError )
    {
        plString str = plString::Format( "Unable to open streaming source %s",
                                         fDataBufferKey->GetName().c_str() );
        IPrintDbgMessage( str.c_str(), true );
        fFailed = true;
        return false;
    }

    SetProperty( kPropIs3DSound, is3D );

    plWAVHeader header = fDataStream->GetHeader();
    uint32_t bufferSize = (uint32_t)(fBufferLengthInSecs * header.fAvgBytesPerSec); 

    // Debug flag #2
    if( is3D && fChannelSelect == 0 && header.fNumChannels > 1 && plgAudioSys::IsDebugFlagSet( plgAudioSys::kDisableLeftSelect ) )
    {
        // Force a fail
        fFailed = true;
        return false;
    }

    if( header.fNumChannels > 1 && is3D )
    {
        // We can only do a single channel of 3D sound. So copy over one (later)
        bufferSize              /= header.fNumChannels;
        header.fBlockAlign      /= header.fNumChannels;
        header.fAvgBytesPerSec  /= header.fNumChannels;
        header.fNumChannels = 1;
    }

    // Actually create the buffer now (always looping)
    fDSoundBuffer = new plDSoundBuffer( bufferSize, header, is3D, IsPropertySet(kPropLooping), false, true );
    if( !fDSoundBuffer->IsValid() )
    {
        fDataStream->Close();
        delete fDataStream;
        fDataStream = nil;

        delete fDSoundBuffer;
        fDSoundBuffer = nil;

        plString str = plString::Format("Can't create sound buffer for %s.wav. This could happen if the wav file is a stereo file."
                                        " Stereo files are not supported on 3D sounds. If the file is not stereo then please report this error.",
                                        GetFileName().AsString().c_str());
        IPrintDbgMessage(str.c_str(), true);
        fFailed = true;
        return false;
    }

    fTotalBytes = (uint32_t)bufferSize;
    plProfile_NewMem(MemSounds, fTotalBytes);

    plSoundBuffer *buffer = (plSoundBuffer *)fDataBufferKey->ObjectIsLoaded();      
    if(!buffer)
        return false;

    bool setupSource = true;
    if(!buffer->GetData() || fStartPos)
    { 
        if(fStartPos && fStartPos <= fDataStream->NumBytesLeft())
        {
            fDataStream->SetPosition(fStartPos);
            plStatusLog::AddLineS("syncaudio.log", "startpos %d", fStartPos);
        }

        // if we get here we are not starting from the beginning of the sound. We still have an audio loaded and need to pick up where we left off
        if(!fDSoundBuffer->SetupStreamingSource(fDataStream))
        {
            setupSource = false;
        }
    }
    else
    {
        // this sound is starting from the beginning. Get the data and start it.
        if(!fDSoundBuffer->SetupStreamingSource(buffer->GetData(), buffer->GetAsyncLoadLength()))
        {
            setupSource = false;
        }
    }
    
    if(!setupSource)
    {
        fDataStream->Close();
        delete fDataStream;
        fDataStream = nil;
        delete fDSoundBuffer;
        fDSoundBuffer = nil;

        plStatusLog::AddLineS("audio.log", "Could not play streaming sound, no voices left %s", GetKeyName().c_str());
        return false;
    }
    FreeSoundData();
    
    IRefreshEAXSettings( true );

    // Debug info
    char str[ 256 ];
    snprintf( str, arrsize(str), "   Streaming %s.", fSrcFilename.AsString().c_str() );
    IPrintDbgMessage( str );

    plStatusLog::AddLineS( "audioTimes.log", 0xffffffff, "Streaming %4.2f secs of %s",
                           fDataStream->GetLengthInSecs(), GetKey()->GetUoid().GetObjectName().c_str() );

    // Get pertinent info
    SetLength( (float)fDataStream->GetLengthInSecs() );

    // Set up our deswizzler, if necessary
    delete fDeswizzler;
    if( fDataStream->GetHeader().fNumChannels != header.fNumChannels )
        fDeswizzler = new plSoundDeswizzler( (uint32_t)(fBufferLengthInSecs * fDataStream->GetHeader().fAvgBytesPerSec), 
                                             (uint8_t)(fDataStream->GetHeader().fNumChannels), 
                                             header.fBitsPerSample / 8 );
    else
        fDeswizzler = nil;

    // LEAVE THE WAV FILE OPEN! (We *are* streaming, after all :)
    return true;
}
Exemplo n.º 17
0
//============================================================================
void SetGateKeeperSrvHostname (const char addr[]) {
    strncpy(s_gateKeeperAddrConsole, addr, arrsize(s_gateKeeperAddrConsole));
}
Exemplo n.º 18
0
bool plStatusLog::IPrintLineToFile( const char *line, uint32_t count )
{
    if( fFlags & kDontWriteFile )
        return true;

#ifdef PLASMA_EXTERNAL_RELEASE
    uint8_t hint = 0;
    if( fFlags & kAppendToLast )
    {
        hint = (uint8_t)fSize;
    }
#endif

    if (!fFileHandle)
        IReOpen();

    bool ret = ( fFileHandle!=nil );

    if( fFileHandle != nil )
    {
        char work[256];
        char buf[2000];
        buf[0] = 0;

        //build line to encrypt

        if( count != 0 )
        {
            if ( fFlags & kTimestamp )
            {
                snprintf(work, arrsize(work), "(%s) ", plUnifiedTime(kNow).Format("%m/%d %H:%M:%S").c_str());
                strncat(buf, work, arrsize(work));
            }
            if ( fFlags & kTimestampGMT )
            {
                snprintf(work, arrsize(work), "(%s) ", plUnifiedTime::GetCurrent().Format("%m/%d %H:%M:%S UTC").c_str());
                strncat(buf, work, arrsize(work));
            }
            if ( fFlags & kTimeInSeconds )
            {
                snprintf(work, arrsize(work), "(%lu) ", (unsigned long)plUnifiedTime(kNow).GetSecs());
                strncat(buf, work, arrsize(work));
            }
            if ( fFlags & kTimeAsDouble )
            {
                snprintf(work, arrsize(work), "(%f) ", plUnifiedTime(kNow).GetSecsDouble());
                strncat(buf, work, arrsize(work));
            }
            if (fFlags & kRawTimeStamp)
            {
                snprintf(work, arrsize(work), "[t=%10f] ", hsTimer::GetSeconds());
                strncat(buf, work, arrsize(work));
            }
            if (fFlags & kThreadID)
            {
                snprintf(work, arrsize(work), "[t=%lu] ", hsThread::GetMyThreadId());
                strncat(buf, work, arrsize(work));
            }

            size_t remaining = arrsize(buf) - strlen(buf) - 1;
            remaining -= 1;
            if (count <= remaining) {
                strncat(buf, line, count);
            } else {
                strncat(buf, line, remaining);
            }

            strncat(buf, "\n", 1);
        }

        unsigned length = strlen(buf);

        {
            int err;
            err = fwrite(buf,1,length,fFileHandle);
            ret = ( ferror( fFileHandle )==0 );

            if ( ret )
            {
                fSize += err;
                if (!(fFlags & kNonFlushedLog))
                    fflush(fFileHandle);
            }
        }

        if ( fSize>=kMaxFileSize )
        {
            plStatusLogMgr::GetInstance().BounceLogs();
        }

    }

    plString out_str = plString::FromUtf8(line, count) + "\n";
    if (fFlags & kDebugOutput)
    {

#if HS_BUILD_FOR_WIN32
#ifndef PLASMA_EXTERNAL_RELEASE
        OutputDebugString(out_str.c_str());
#endif
#else
        fputs(out_str.c_str(), stderr);
#endif
    }

    if (fFlags & kStdout)
    {
        fputs(out_str.c_str(), stdout);
    }

    return ret;
}
Exemplo n.º 19
0
//============================================================================
void SetServerSignupUrl (const char url[]) {
    strncpy(s_serverSignupUrl, url, arrsize(s_serverSignupUrl));
}
Exemplo n.º 20
0
bool VaultTextNoteNode::GetVisitInfo (plAgeInfoStruct * info) {

    wchar_t * mem;
    const wchar_t * str = mem = wcsdup(GetNoteText());
    
    for (unsigned i = 0; i < kNumAgeInfoFields; ++i) {
        
        wchar_t token[1024];
        switch (i) {
            case kAgeFilename: {
                StrTokenize(&str, token, arrsize(token), L"|", 1);
                if (StrLen(token) > 0) {
                    char ansi[1024];
                    StrToAnsi(ansi, token, arrsize(ansi));
                    info->SetAgeFilename(ansi);
                }
            }
            break;
            
            case kAgeInstName: {
                StrTokenize(&str, token, arrsize(token), L"|", 1);
                if (StrLen(token) > 0) {
                    char ansi[1024];
                    StrToAnsi(ansi, token, arrsize(ansi));
                    info->SetAgeInstanceName(ansi);
                }
            }
            break;
            
            case kAgeUserName: {
                StrTokenize(&str, token, arrsize(token), L"|", 1);
                if (StrLen(token) > 0) {
                    char ansi[1024];
                    StrToAnsi(ansi, token, arrsize(ansi));
                    info->SetAgeUserDefinedName(ansi);
                }
            }
            break;
            
            case kAgeDesc: {
                StrTokenize(&str, token, arrsize(token), L"|", 1);
                if (StrLen(token) > 0) {
                    char ansi[1024];
                    StrToAnsi(ansi, token, arrsize(ansi));
                    info->SetAgeDescription(ansi);
                }
            }
            break;
            
            case kAgeInstGuid: {
                StrTokenize(&str, token, arrsize(token), L"|", 1);
                if (StrLen(token) > 0) {
                    plUUID uuid(plString::FromWchar(token));
                    info->SetAgeInstanceGuid(&uuid);
                }
            }
            break;
            
            case kAgeLanguage: {
                StrTokenize(&str, token, arrsize(token), L"|", 1);
                if (StrLen(token) > 0) {
                    info->SetAgeLanguage(StrToUnsigned(token, nil, 10));
                }
            }
            break;
            
            case kAgeSequence: {
                StrTokenize(&str, token, arrsize(token), L"|", 1);
                if (StrLen(token) > 0) {
                    info->SetAgeSequenceNumber(StrToUnsigned(token, nil, 10));
                }
            }
            break;

            DEFAULT_FATAL(i);
        }
    }

    free(mem);
    return true;
}
Exemplo n.º 21
0
//============================================================================
void SetServerDisplayName (const char name[]) {
    strncpy(s_serverName, name, arrsize(s_serverName));
}
Exemplo n.º 22
0
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
    PF_CONSOLE_INIT_ALL()

    // Set global handle
    gHInst = hInst;

    std::vector<plString> args;
    args.reserve(__argc);
    for (size_t i = 0; i < __argc; i++) {
        args.push_back(plString::FromUtf8(__argv[i]));
    }

    plCmdParser cmdParser(s_cmdLineArgs, arrsize(s_cmdLineArgs));
    cmdParser.Parse(args);

    bool doIntroDialogs = true;
#ifndef PLASMA_EXTERNAL_RELEASE
    if (cmdParser.IsSpecified(kArgSkipLoginDialog))
        doIntroDialogs = false;
    if (cmdParser.IsSpecified(kArgLocalData))
    {
        gDataServerLocal = true;
        gSkipPreload = true;
    }
    if (cmdParser.IsSpecified(kArgSkipPreload))
        gSkipPreload = true;
    if (cmdParser.IsSpecified(kArgPlayerId))
        NetCommSetIniPlayerId(cmdParser.GetInt(kArgPlayerId));
    if (cmdParser.IsSpecified(kArgStartUpAgeName))
        NetCommSetIniStartUpAge(cmdParser.GetString(kArgStartUpAgeName));
#endif

    plFileName serverIni = "server.ini";
    if (cmdParser.IsSpecified(kArgServerIni))
        serverIni = cmdParser.GetString(kArgServerIni);

    // check to see if we were launched from the patcher
    bool eventExists = false;
    // we check to see if the event exists that the patcher should have created
    HANDLE hPatcherEvent = CreateEventW(nil, TRUE, FALSE, L"UruPatcherEvent");
    if (hPatcherEvent != NULL)
    {
        // successfully created it, check to see if it was already created
        if (GetLastError() == ERROR_ALREADY_EXISTS)
        {
            // it already existed, so the patcher is waiting, signal it so the patcher can die
            SetEvent(hPatcherEvent);
            eventExists = true;
        }
    }

#ifdef PLASMA_EXTERNAL_RELEASE
    // if the client was started directly, run the patcher, and shutdown
    STARTUPINFOW si;
    PROCESS_INFORMATION pi; 
    memset(&si, 0, sizeof(si));
    memset(&pi, 0, sizeof(pi));
    si.cb = sizeof(si);

    if (!eventExists) // if it is missing, assume patcher wasn't launched
    {
        if(!CreateProcessW(s_patcherExeName, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
        {
            hsMessageBox("Failed to launch patcher", "Error", hsMessageBoxNormal);
        }
        CloseHandle( pi.hThread );
        CloseHandle( pi.hProcess );
        return PARABLE_NORMAL_EXIT;
    }
#endif

    // Load an optional general.ini
    plFileName gipath = plFileName::Join(plFileSystem::GetInitPath(), "general.ini");
    FILE *generalini = plFileSystem::Open(gipath, "rb");
    if (generalini)
    {
        fclose(generalini);
        pfConsoleEngine tempConsole;
        tempConsole.ExecuteFile(gipath);
    }

#ifdef PLASMA_EXTERNAL_RELEASE
    // If another instance is running, exit.  We'll automatically release our
    // lock on the mutex when our process exits
    HANDLE hOneInstance = CreateMutex(nil, FALSE, "UruExplorer");
    if (WaitForSingleObject(hOneInstance,0) != WAIT_OBJECT_0)
    {
        switch (plLocalization::GetLanguage())
        {
            case plLocalization::kFrench:
                hsMessageBox("Une autre copie d'URU est déjà en cours d'exécution", "Erreur", hsMessageBoxNormal);
                break;
            case plLocalization::kGerman:
                hsMessageBox("URU wird bereits in einer anderen Instanz ausgeführt", "Fehler", hsMessageBoxNormal);
                break;
            case plLocalization::kSpanish:
                hsMessageBox("En estos momentos se está ejecutando otra copia de URU", "Error", hsMessageBoxNormal);
                break;
            case plLocalization::kItalian:
                hsMessageBox("Un'altra copia di URU è già aperta", "Errore", hsMessageBoxNormal);
                break;
            // default is English
            default:
                hsMessageBox("Another copy of URU is already running", "Error", hsMessageBoxNormal);
                break;
        }
        return PARABLE_NORMAL_EXIT;
    }
#endif

    FILE *serverIniFile = plFileSystem::Open(serverIni, "rb");
    if (serverIniFile)
    {
        fclose(serverIniFile);
        pfConsoleEngine tempConsole;
        tempConsole.ExecuteFile(serverIni);
    }
    else
    {
        hsMessageBox("No server.ini file found.  Please check your URU installation.", "Error", hsMessageBoxNormal);
        return PARABLE_NORMAL_EXIT;
    }

    NetCliAuthAutoReconnectEnable(false);
    InitNetClientComm();

    curl_global_init(CURL_GLOBAL_ALL);

    bool                needExit = false;
    LoginDialogParam    loginParam;
    memset(&loginParam, 0, sizeof(loginParam));
    LoadUserPass(&loginParam);

    if (!doIntroDialogs && loginParam.remember) {
        ENetError auth;

        NetCommSetAccountUsernamePassword(loginParam.username, loginParam.namePassHash);
        bool cancelled = AuthenticateNetClientComm(&auth, NULL);

        if (IS_NET_ERROR(auth) || cancelled) {
            doIntroDialogs = true;

            loginParam.authError = auth;

            if (cancelled)
            {
                NetCommDisconnect();
            }
        }
    }

    if (doIntroDialogs) {
        needExit = ::DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_URULOGIN_MAIN ), NULL, UruLoginDialogProc, (LPARAM)&loginParam ) <= 0;
    }

    if (doIntroDialogs && !needExit) {
        HINSTANCE hRichEdDll = LoadLibrary("RICHED20.DLL");
        INT_PTR val = ::DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_URULOGIN_EULA ), NULL, UruTOSDialogProc, (LPARAM)hInst);
        FreeLibrary(hRichEdDll);
        if (val <= 0) {
            DWORD error = GetLastError();
            needExit = true;
        }
    }

    curl_global_cleanup();

    if (needExit) {
        DeInitNetClientComm();
        return PARABLE_NORMAL_EXIT;
    }

    NetCliAuthAutoReconnectEnable(true);

    // VERY VERY FIRST--throw up our splash screen
    HWND splashDialog = ::CreateDialog( hInst, MAKEINTRESOURCE( IDD_LOADING ), NULL, SplashDialogProc );

    // Install our unhandled exception filter for trapping all those nasty crashes in release build
#ifndef HS_DEBUGGING
    LPTOP_LEVEL_EXCEPTION_FILTER oldFilter;
    oldFilter = SetUnhandledExceptionFilter( plCustomUnhandledExceptionFilter );
#endif

    //
    // Set up to log errors by using hsDebugMessage
    //
    DebugInit();
    DebugMsgF("Plasma 2.0.%i.%i - %s", PLASMA2_MAJOR_VERSION, PLASMA2_MINOR_VERSION, plProduct::ProductString().c_str());

    for (;;) {
        // Create Window
        if (!WinInit(hInst, nCmdShow) || gClient->GetDone())
            break;

        // Done with our splash now
        ::DestroyWindow( splashDialog );

        if (!gClient)
            break;

        // Show the main window
        ShowWindow(gClient->GetWindowHandle(), SW_SHOW);
            
        // Be really REALLY forceful about being in the front
        BringWindowToTop( gClient->GetWindowHandle() );

        // Update the window
        UpdateWindow(gClient->GetWindowHandle());

        // 
        // Init Application here
        //
        if( !gClient->StartInit() )
            break;
        
        // I want it on top! I mean it!
        BringWindowToTop( gClient->GetWindowHandle() );

        // initialize dinput here:
        if (gClient && gClient->GetInputManager())
            gClient->GetInputManager()->InitDInput(hInst, (HWND)gClient->GetWindowHandle());
        
        // Seriously!
        BringWindowToTop( gClient->GetWindowHandle() );
        
        //
        // Main loop
        //
        MSG msg;
        do
        {   
            gClient->MainLoop();

            if( gClient->GetDone() )
                break;

            // Look for a message
            while (PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ))
            {
                // Handle the message
                TranslateMessage( &msg );
                DispatchMessage( &msg );
            }
        } while (WM_QUIT != msg.message);

        break;
    }

    //
    // Cleanup
    //
    if (gClient)
    {
        gClient->Shutdown(); // shuts down PhysX for us
        gClient = nil;
    }
    hsAssert(hsgResMgr::ResMgr()->RefCnt()==1, "resMgr has too many refs, expect mem leaks");
    hsgResMgr::Shutdown();  // deletes fResMgr
    DeInitNetClientComm();

    // Uninstall our unhandled exception filter, if we installed one
#ifndef HS_DEBUGGING
    SetUnhandledExceptionFilter( oldFilter );
#endif

    // Exit WinMain and terminate the app....
    return PARABLE_NORMAL_EXIT;
}
Exemplo n.º 23
0
plStreamSource::plStreamSource()
{
    memset(fServerKey, 0, arrsize(fServerKey));
}