void CheckNewConnections() { Connection *c; while ((c = nl->getNewConnection()) != NULL) { MakeDirty(); if (next) { next->b = c; StartGame(next); next = NULL; } else { next = new Game(); next->a = c; MakeDirty(); } } if (next != 0) { Packet *p = nl->receivePacketFromConnection(next->a); if (p != 0) { // sending packets before connecting? destroy! nl->destroyPacket(p); goto dumb_client_is_dumb; } else if (!nl->connectionIsAlive(next->a)) { dumb_client_is_dumb: nl->destroyConnection(next->a); delete next; next = NULL; MakeDirty(); } } }
void UpdateGames() { for (std::list<Game *>::iterator ptr(games.begin()), end(games.end()); ptr != end; ++ptr) { // Forward one packet per client per tick, to limit tick rate. // Also limit size of each packet forwarded so that attempts to flood don't work. Game *g = *ptr; if (g->a) { if (!nl->connectionIsAlive(g->a)) { nl->destroyConnection(g->a); g->a = 0; MakeDirty(); if (g->b) { nl->sendPacketToConnection("drop", 4, g->b); } } else { // read packet and forward Packet *p = nl->receivePacketFromConnection(g->a); if (p != 0) { if (nl->packetSize(p) < 64 && g->b != 0) { nl->sendPacketToConnection(nl->packetData(p), nl->packetSize(p), g->b); } else { // guy is bad, drop him! nl->destroyConnection(g->a); g->a = 0; MakeDirty(); } nl->destroyPacket(p); } } } if (g->b) { if (!nl->connectionIsAlive(g->b)) { nl->destroyConnection(g->b); g->b = 0; MakeDirty(); if (g->a) { nl->sendPacketToConnection("drop", 4, g->a); } } else { // read packet and forward Packet *p = nl->receivePacketFromConnection(g->b); if (p != 0) { if (nl->packetSize(p) < 64 && g->a != 0) { nl->sendPacketToConnection(nl->packetData(p), nl->packetSize(p), g->a); } else { // guy is bad, drop him! nl->destroyConnection(g->b); g->b = 0; MakeDirty(); } nl->destroyPacket(p); } } } } }
virtual void HandleMessage(const CMessage& msg, bool UNUSED(global)) { switch (msg.GetType()) { case MT_OwnershipChanged: { const CMessageOwnershipChanged& msgData = static_cast<const CMessageOwnershipChanged&> (msg); MakeDirtyIfRelevantEntity(msgData.entity); break; } case MT_PositionChanged: { const CMessagePositionChanged& msgData = static_cast<const CMessagePositionChanged&> (msg); MakeDirtyIfRelevantEntity(msgData.entity); break; } case MT_ValueModification: { const CMessageValueModification& msgData = static_cast<const CMessageValueModification&> (msg); if (msgData.component == L"TerritoryInfluence") MakeDirty(); break; } case MT_ObstructionMapShapeChanged: case MT_TerrainChanged: case MT_WaterChanged: { // also recalculate the cost grid to support atlas changes SAFE_DELETE(m_CostGrid); MakeDirty(); break; } case MT_Update: { if (m_TriggerEvent) { m_TriggerEvent = false; CMessageTerritoriesChanged msg; GetSimContext().GetComponentManager().BroadcastMessage(msg); } break; } case MT_Interpolate: { const CMessageInterpolate& msgData = static_cast<const CMessageInterpolate&> (msg); Interpolate(msgData.deltaSimTime, msgData.offset); break; } case MT_RenderSubmit: { const CMessageRenderSubmit& msgData = static_cast<const CMessageRenderSubmit&> (msg); RenderSubmit(msgData.collector); break; } } }
// Check whether the entity is either a settlement or territory influence; // ignore any others void MakeDirtyIfRelevantEntity(entity_id_t ent) { CmpPtr<ICmpSettlement> cmpSettlement(GetSimContext(), ent); if (cmpSettlement) MakeDirty(); CmpPtr<ICmpTerritoryInfluence> cmpTerritoryInfluence(GetSimContext(), ent); if (cmpTerritoryInfluence) MakeDirty(); }
virtual void HandleMessage(const CMessage& msg, bool UNUSED(global)) { switch (msg.GetType()) { case MT_OwnershipChanged: { const CMessageOwnershipChanged& msgData = static_cast<const CMessageOwnershipChanged&> (msg); MakeDirtyIfRelevantEntity(msgData.entity); break; } case MT_PositionChanged: { const CMessagePositionChanged& msgData = static_cast<const CMessagePositionChanged&> (msg); MakeDirtyIfRelevantEntity(msgData.entity); break; } case MT_TechnologyModification: { const CMessageTechnologyModification& msgData = static_cast<const CMessageTechnologyModification&> (msg); if (msgData.component == L"TerritoryInfluence") MakeDirty(); break; } case MT_TerrainChanged: { MakeDirty(); break; } case MT_Update: { if (m_TriggerEvent) { m_TriggerEvent = false; CMessageTerritoriesChanged msg; GetSimContext().GetComponentManager().BroadcastMessage(msg); } break; } case MT_Interpolate: { const CMessageInterpolate& msgData = static_cast<const CMessageInterpolate&> (msg); Interpolate(msgData.deltaSimTime, msgData.offset); break; } case MT_RenderSubmit: { const CMessageRenderSubmit& msgData = static_cast<const CMessageRenderSubmit&> (msg); RenderSubmit(msgData.collector); break; } } }
virtual void ReloadTerrain() { // TODO: should refactor this code to be nicer u16 tiles = GetTilesPerSide(); u16 vertices = GetVerticesPerSide(); CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); if (cmpObstructionManager) { cmpObstructionManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(), entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE), entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE)); } CmpPtr<ICmpRangeManager> cmpRangeManager(GetSystemEntity()); if (cmpRangeManager) { cmpRangeManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(), entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE), entity_pos_t::FromInt(tiles*(int)TERRAIN_TILE_SIZE), vertices); } if (CRenderer::IsInitialised()) g_Renderer.GetWaterManager()->SetMapSize(vertices); MakeDirty(0, 0, tiles+1, tiles+1); }
void MemoryCard::ClearAll() { { std::unique_lock<std::mutex> l(m_flush_mutex); memset(&m_memcard_data[0], 0xFF, memory_card_size); } MakeDirty(); }
HRESULT CPkcs10::get_PublicKeyBlob(BLOB* pblob) { HRESULT hr = m_pworld->SubjectPublicKeyInfoToBlob( m_preq->certificationRequestInfo.subjectPublicKeyInfo, pblob ); MakeDirty(); return hr; }
void RemoveEmptyGames() { for (std::list<Game *>::iterator ptr(games.begin()), end(games.begin()), del; ptr != end;) { del = ptr; Game *g = *ptr; ++ptr; if (g->a == 0 && g->b == 0) { MakeDirty(); games.erase(del); delete g; } } }
void MemoryCard::ClearBlock(u32 address) { if (address & (BLOCK_SIZE - 1) || !IsAddressInBounds(address)) { PanicAlertT("MemoryCard: ClearBlock called on invalid address (0x%x)", address); return; } else { std::unique_lock<std::mutex> l(m_flush_mutex); memset(&m_memcard_data[address], 0xFF, BLOCK_SIZE); } MakeDirty(); }
s32 MemoryCard::Write(u32 destaddress, s32 length, const u8* srcaddress) { if (!IsAddressInBounds(destaddress)) { PanicAlertT("MemoryCard: Write called with invalid destination address (0x%x)", destaddress); return -1; } { std::unique_lock<std::mutex> l(m_flush_mutex); memcpy(&m_memcard_data[destaddress], srcaddress, length); } MakeDirty(); return length; }
virtual void ReloadTerrain() { // TODO: should refactor this code to be nicer CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSimContext(), SYSTEM_ENTITY); if (!cmpObstructionManager.null()) { cmpObstructionManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(), entity_pos_t::FromInt(m_Terrain->GetTilesPerSide()*CELL_SIZE), entity_pos_t::FromInt(m_Terrain->GetTilesPerSide()*CELL_SIZE)); } CmpPtr<ICmpRangeManager> cmpRangeManager(GetSimContext(), SYSTEM_ENTITY); if (!cmpRangeManager.null()) { cmpRangeManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(), entity_pos_t::FromInt(m_Terrain->GetTilesPerSide()*CELL_SIZE), entity_pos_t::FromInt(m_Terrain->GetTilesPerSide()*CELL_SIZE), m_Terrain->GetVerticesPerSide()); } MakeDirty(0, 0, m_Terrain->GetTilesPerSide()+1, m_Terrain->GetTilesPerSide()+1); }
HRESULT CPkcs10::put_PublicKey(HCRYPTPROV hprov, DWORD dwKeySpec) // Store the indicated public key in the subjectPublicKeyInfo field // of the CertificationRequest. From PKCS #10: // // subjectPublicKeyInfo contains information about the public // key being certified. The information identifies the entity's // public-key algorithm (and any associated parameters); examples // of public-key algorithms include X.509's rsa and PKCS #1's // rsaEncryption. // // The information also includes a bit-string representation of // the entity's public key. For both public-key algorithms just // mentioned, the bit string contains the BER encoding of a // value of X.509/PKCS #1 type RSAPublicKey // { HRESULT hr = m_pworld->HprovToSubjectPublicKeyInfo( hprov, dwKeySpec, m_preq->certificationRequestInfo.subjectPublicKeyInfo ); #if defined(_DEBUG) // Check to to make sure we can read what we wrote if (hr==S_OK) { HCRYPTKEY hkeyuser; VERIFY(CryptGetUserKey(hprov, dwKeySpec, &hkeyuser)); BYTE rgb1[1024]; DWORD cb1 = 1024; // BYTE rgb2[1024]; DWORD cb2 = 1024; VERIFY(CryptExportKey(hkeyuser, 0, PUBLICKEYBLOB, 0, rgb1, &cb1)); // VERIFY(CryptExportKey(hkeypub, 0, PUBLICKEYBLOB, 0, rgb2, &cb2)); // Would like to do the above, but CAPI won't let us export an imported key // (*(&(*##$^*&. So, having verified we can successfully fully import, we just // go get the raw bits again. BLOB b; m_pworld->Init(b); HCRYPTKEY hkeypub; if (get_PublicKey(hprov, &hkeypub) == S_OK) { VERIFY(CryptDestroyKey(hkeypub)); } else OutputDebugString("DigSig: Public key retrieval failed\n"); VERIFY(m_pworld->PublicKeyBlobFromBitString(m_preq->certificationRequestInfo.subjectPublicKeyInfo, dwKeySpec, &b) == S_OK); DWORD cb2 = b.cbSize; BYTE* rgb2 = b.pBlobData; VERIFY(cb1 == cb2); if (cb1 != cb2) { cb1 = min(cb1,cb2); cb2 = cb1; } ((PUBLICKEYSTRUC*)rgb1)->reserved = 0; ((PUBLICKEYSTRUC*)rgb2)->reserved = 0; VERIFY(memcmp(rgb1, rgb2, cb1) == 0); VERIFY(CryptDestroyKey(hkeyuser)); m_pworld->Free(b); } #endif MakeDirty(); return hr; }
void StartGame(Game *g) { MakeDirty(); games.push_back(g); nl->sendPacketToConnection("start", 5, g->a); nl->sendPacketToConnection("start", 5, g->b); }
INT_PTR CTVTestVideoDecoderProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PROP_DEINTERLACE_ENABLE: case IDC_PROP_DEINTERLACE_DISABLE: if (m_pDecoder) { bool fEnableDeinterlace = ::IsDlgButtonChecked(hwnd, IDC_PROP_DEINTERLACE_ENABLE) == BST_CHECKED; if (fEnableDeinterlace != m_NewSettings.fEnableDeinterlace) { m_NewSettings.fEnableDeinterlace = fEnableDeinterlace; m_pDecoder->SetEnableDeinterlace(fEnableDeinterlace); MakeDirty(); EnableDlgItems(hwnd, IDC_PROP_DEINTERLACE_METHOD_LABEL, IDC_PROP_DEINTERLACE_METHOD, fEnableDeinterlace); EnableDlgItems(m_Dlg, IDC_PROP_ADAPT_PROGRESSIVE, IDC_PROP_ADAPT_TELECINE, fEnableDeinterlace && m_NewSettings.DeinterlaceMethod != TVTVIDEODEC_DEINTERLACE_WEAVE); EnableDlgItems(hwnd, IDC_PROP_SET_INTERLACED_FLAG, IDC_PROP_DEINTERLACE_NOTE, !fEnableDeinterlace); } } return TRUE; case IDC_PROP_DEINTERLACE_METHOD: if (HIWORD(wParam) == CBN_SELCHANGE && m_pDecoder) { TVTVIDEODEC_DeinterlaceMethod DeinterlaceMethod = (TVTVIDEODEC_DeinterlaceMethod)::SendDlgItemMessage( hwnd, IDC_PROP_DEINTERLACE_METHOD, CB_GETCURSEL, 0, 0); if (DeinterlaceMethod >= 0 && DeinterlaceMethod != m_NewSettings.DeinterlaceMethod) { m_NewSettings.DeinterlaceMethod = DeinterlaceMethod; m_pDecoder->SetDeinterlaceMethod(DeinterlaceMethod); MakeDirty(); EnableDlgItems(m_Dlg, IDC_PROP_ADAPT_PROGRESSIVE, IDC_PROP_ADAPT_TELECINE, m_NewSettings.fEnableDeinterlace && DeinterlaceMethod != TVTVIDEODEC_DEINTERLACE_WEAVE); } } return TRUE; case IDC_PROP_ADAPT_PROGRESSIVE: if (m_pDecoder) { bool fAdaptProgressive = ::IsDlgButtonChecked(hwnd, IDC_PROP_ADAPT_PROGRESSIVE) == BST_CHECKED; if (fAdaptProgressive != m_NewSettings.fAdaptProgressive) { m_NewSettings.fAdaptProgressive = fAdaptProgressive; m_pDecoder->SetAdaptProgressive(fAdaptProgressive); MakeDirty(); } } return TRUE; case IDC_PROP_ADAPT_TELECINE: if (m_pDecoder) { bool fAdaptTelecine = ::IsDlgButtonChecked(hwnd, IDC_PROP_ADAPT_TELECINE) == BST_CHECKED; if (fAdaptTelecine != m_NewSettings.fAdaptTelecine) { m_NewSettings.fAdaptTelecine = fAdaptTelecine; m_pDecoder->SetAdaptTelecine(fAdaptTelecine); MakeDirty(); } } return TRUE; case IDC_PROP_SET_INTERLACED_FLAG: if (m_pDecoder) { bool fSetInterlacedFlag = ::IsDlgButtonChecked(hwnd, IDC_PROP_SET_INTERLACED_FLAG) == BST_CHECKED; if (fSetInterlacedFlag != m_NewSettings.fSetInterlacedFlag) { m_NewSettings.fSetInterlacedFlag = fSetInterlacedFlag; m_pDecoder->SetInterlacedFlag(fSetInterlacedFlag); MakeDirty(); } } return TRUE; case IDC_PROP_BRIGHTNESS: if (HIWORD(wParam) == EN_CHANGE && m_pDecoder && m_fInitialized) { BOOL fOK; int Brightness = ::GetDlgItemInt(hwnd, IDC_PROP_BRIGHTNESS, &fOK, TRUE); if (fOK && Brightness != m_NewSettings.Brightness) { ::SendDlgItemMessage(hwnd, IDC_PROP_BRIGHTNESS_SLIDER, TBM_SETPOS, TRUE, Brightness); m_NewSettings.Brightness = Brightness; m_pDecoder->SetBrightness(Brightness); MakeDirty(); } } return TRUE; case IDC_PROP_CONTRAST: if (HIWORD(wParam) == EN_CHANGE && m_pDecoder && m_fInitialized) { BOOL fOK; int Contrast = ::GetDlgItemInt(hwnd, IDC_PROP_CONTRAST, &fOK, TRUE); if (fOK && Contrast != m_NewSettings.Contrast) { ::SendDlgItemMessage(hwnd, IDC_PROP_CONTRAST_SLIDER, TBM_SETPOS, TRUE, Contrast); m_NewSettings.Contrast = Contrast; m_pDecoder->SetContrast(Contrast); MakeDirty(); } } return TRUE; case IDC_PROP_HUE: if (HIWORD(wParam) == EN_CHANGE && m_pDecoder && m_fInitialized) { BOOL fOK; int Hue = ::GetDlgItemInt(hwnd, IDC_PROP_HUE, &fOK, TRUE); if (fOK && Hue != m_NewSettings.Hue) { ::SendDlgItemMessage(hwnd, IDC_PROP_HUE_SLIDER, TBM_SETPOS, TRUE, Hue); m_NewSettings.Hue = Hue; m_pDecoder->SetHue(Hue); MakeDirty(); } } return TRUE; case IDC_PROP_SATURATION: if (HIWORD(wParam) == EN_CHANGE && m_pDecoder && m_fInitialized) { BOOL fOK; int Saturation = ::GetDlgItemInt(hwnd, IDC_PROP_SATURATION, &fOK, TRUE); if (fOK && Saturation != m_NewSettings.Saturation) { ::SendDlgItemMessage(hwnd, IDC_PROP_SATURATION_SLIDER, TBM_SETPOS, TRUE, Saturation); m_NewSettings.Saturation = Saturation; m_pDecoder->SetSaturation(Saturation); MakeDirty(); } } return TRUE; case IDC_PROP_RESET_COLOR_ADJUSTMENT: if (m_NewSettings.Brightness != 0) ::SetDlgItemInt(hwnd, IDC_PROP_BRIGHTNESS, 0, TRUE); if (m_NewSettings.Contrast != 0) ::SetDlgItemInt(hwnd, IDC_PROP_CONTRAST, 0, TRUE); if (m_NewSettings.Hue != 0) ::SetDlgItemInt(hwnd, IDC_PROP_HUE, 0, TRUE); if (m_NewSettings.Saturation != 0) ::SetDlgItemInt(hwnd, IDC_PROP_SATURATION, 0, TRUE); return TRUE; case IDC_PROP_NUM_THREADS: if (HIWORD(wParam) == CBN_SELCHANGE && m_pDecoder) { int NumThreads = (int)::SendDlgItemMessage(hwnd, IDC_PROP_NUM_THREADS, CB_GETCURSEL, 0, 0); if (NumThreads >= 0 && NumThreads != m_NewSettings.NumThreads) { m_NewSettings.NumThreads = NumThreads; m_pDecoder->SetNumThreads(NumThreads); MakeDirty(); } } return TRUE; } break; case WM_HSCROLL: if ((HWND)lParam == ::GetDlgItem(hwnd, IDC_PROP_BRIGHTNESS_SLIDER)) { ::SetDlgItemInt(hwnd, IDC_PROP_BRIGHTNESS, (int)::SendDlgItemMessage(hwnd, IDC_PROP_BRIGHTNESS_SLIDER, TBM_GETPOS, 0, 0), TRUE); } else if ((HWND)lParam == ::GetDlgItem(hwnd, IDC_PROP_CONTRAST_SLIDER)) { ::SetDlgItemInt(hwnd, IDC_PROP_CONTRAST, (int)::SendDlgItemMessage(hwnd, IDC_PROP_CONTRAST_SLIDER, TBM_GETPOS, 0, 0), TRUE); } else if ((HWND)lParam == ::GetDlgItem(hwnd, IDC_PROP_HUE_SLIDER)) { ::SetDlgItemInt(hwnd, IDC_PROP_HUE, (int)::SendDlgItemMessage(hwnd, IDC_PROP_HUE_SLIDER, TBM_GETPOS, 0, 0), TRUE); } else if ((HWND)lParam == ::GetDlgItem(hwnd, IDC_PROP_SATURATION_SLIDER)) { ::SetDlgItemInt(hwnd, IDC_PROP_SATURATION, (int)::SendDlgItemMessage(hwnd, IDC_PROP_SATURATION_SLIDER, TBM_GETPOS, 0, 0), TRUE); } return TRUE; } return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam); }
void FSyntaxHighlighterTextLayoutMarshaller::EnableSyntaxHighlighting(const bool bEnable) { bSyntaxHighlightingEnabled = bEnable; MakeDirty(); }
void Undo() { m_TerrainDelta.Undo(); MakeDirty(); }
void Redo() { m_TerrainDelta.Redo(); MakeDirty(); }