Example #1
0
void CGuiWidget::ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWidgetParms& parms)
{
    CGuiWidget* parent = frame->FindWidget(parms.x8_parentId);
    bool a = in.readBool();
    if (a)
        xf4_workerId = in.readInt16Big();
    zeus::CVector3f trans;
    trans.readBig(in);
    zeus::CMatrix3f orient;
    orient.readBig(in);
    x80_transform = zeus::CTransform(orient, trans);
    ReapplyXform();
    zeus::CVector3f rotCenter;
    rotCenter.readBig(in);
    SetRotationCenter(rotCenter);
    ParseMessages(in, parms);
    ParseAnimations(in, parms);
    if (a)
        if (!parent->AddWorkerWidget(this))
        {
            Log.report(logvisor::Warning,
            "Warning: Discarding useless worker id. Parent is not a compound widget.");
            xf4_workerId = -1;
        }
    parent->AddChildWidget(this, false, true);
}
Example #2
0
void NetworkThread::Run()
{
	while(ReceiveMessages())
	{
		if(myPacket && !myPacket.endOfPacket())
		{
			ParseMessages();
			myPacket.clear();
		}
		
		CheckConnection();
		
		sf::sleep(sf::milliseconds(100));
	}
}
void SerializedMessageList::LoadMessagesFromFile(const char *filename)
{
#ifdef KNET_USE_TINYXML
	TiXmlDocument doc(filename);
	bool success = doc.LoadFile();
	if (!success)
	{
		KNET_LOG(LogError, "TiXmlDocument open failed on filename %s!", filename);
		return;
	}

	TiXmlElement *xmlRoot = doc.FirstChildElement();

	ParseStructs(xmlRoot);
	ParseMessages(xmlRoot);
#else
	throw NetException("kNet was built without TinyXml support! SerializedMessageList is not available!");
#endif
}
Example #4
0
unsigned int __stdcall MyThreadFunction(void*) {
    EGraphicsApi graphicsApi = EGraphicsApi::D3D11;
    if (!LoadRenderApiImpl(graphicsApi)) {
        s_running.store(false);
        return 1;
    }

    // Init time
    QueryPerformanceFrequency(&s_perfFreq);
    QueryPerformanceCounter(&s_lastTime);

    GameInfo gameInfo;
    ZeroMemory(&gameInfo, sizeof(gameInfo));
    gameInfo.graphicsApi = graphicsApi;
    gameInfo.imguiState = ImGui::GetCurrentContext();
    //heapArea = new HeapArea(512 * 1024 * 1024);
    //memory::SimpleArena arena(heapArea);
    //gameInfo.allocator = &arena;
    gameInfo.CalculateDeltaTime = CalculateDeltaTime;
    gameInfo.gfxFuncs = g_renderApi;
    gameInfo.config = &s_config;
    gameInfo.controls = &s_controls;
    gameInfo.CreateThread = slCreateThread;
    gameInfo.reloadOnSave = true;

    // Hardware info
    {
        SYSTEM_INFO sysinfo;
        GetSystemInfo(&sysinfo);
        s_hardware.numLogicalThreads = (uint32_t) sysinfo.dwNumberOfProcessors;
    }
    
    gameInfo.hardware = &s_hardware;

    // ENet
    if (enet_initialize() != 0)
    {
        s_running.store(false);
        return 1;
    }

    // Main loop
    while (s_running.load())
    {
        // Check if graphics API change was requested
        if (gameInfo.graphicsApi != graphicsApi) {
            if (LoadRenderApiImpl(gameInfo.graphicsApi)) {
                graphicsApi = gameInfo.graphicsApi;
                g_renderApi = gameInfo.gfxFuncs;
            } else {
                gameInfo.graphicsApi = graphicsApi;
                gameInfo.gfxFuncs = g_renderApi;
            }
        }

#ifdef _DEBUG
        {
            // Reload DLL
            FILETIME NewDLLWriteTime = Win32GetLastWriteTime((char*)s_dllName);

            // If the .DLL is being written to, the last write time may change multiple times
            // So we need to add a cooldown
            LARGE_INTEGER currentTime;
            QueryPerformanceCounter(&currentTime);

            if (CompareFileTime(&NewDLLWriteTime, &s_gameFuncs.DLLLastWriteTime) != 0
                && (currentTime.QuadPart - s_lastDLLLoadTime.QuadPart) / s_perfFreq.QuadPart >= 1) {

                if (s_gameFuncs.dll) {
                    FreeLibrary(s_gameFuncs.dll);
                }

                s_gameFuncs = LoadGameFuncs();
                g_LogInfo("Reloaded DLL.");
            } else {
                // Ignore changes
                s_gameFuncs.DLLLastWriteTime = NewDLLWriteTime;
            }
        }
#endif

        // Reload Lua
        if (gameInfo.reloadOnSave) {
            DWORD obj = WaitForSingleObject(hDirectoryChange, 0);
            if (obj == WAIT_OBJECT_0) {
                if (!FindNextChangeNotification(hDirectoryChange)) {
                    g_LogInfo("Error: FindNextChangeNotification failed.");
                }
                
                // TODO: Change only of lua files changed (or make separate lua directory)
                LARGE_INTEGER currentTime;
                static LARGE_INTEGER s_lastLuaLoadTime;
                QueryPerformanceCounter(&currentTime);

                if ((currentTime.QuadPart - s_lastLuaLoadTime.QuadPart) / s_perfFreq.QuadPart >= 1) {
                    s_lastLuaLoadTime = currentTime;
                    gameInfo.reloadLua = true;
                }
            }
        }

        ParseMessages();

        g_renderApi->ImGuiNewFrame();
        s_controls.BeginFrame();

        s_gameFuncs.UpdateGame(&gameInfo);

        s_controls.EndFrame();

        // Rendering
        g_renderApi->Render();
    }

    s_gameFuncs.DestroyGame(&gameInfo);
    g_renderApi->Destroy();
    ImGui::Shutdown();
    g_renderApi = nullptr;

    //delete heapArea;

    enet_deinitialize();

    return 0;
}