//! 响应联系人删除状态改变 void LinkmanSystem::OnPlayerDelStateChange(CMessage *pMsg) { CGUID PlayerGuid; pMsg->GetGUID(PlayerGuid); BOOL bDeleted = pMsg->GetLong(); LONG lDataSize = pMsg->GetLong(); vector<BYTE> vData(lDataSize + 1); BYTE *pData = &vData[0]; pMsg->GetEx(pData, lDataSize); LONG lPos = 0; for (LONG i = 0; i < lDataSize/(long)sizeof(CGUID); ++i) { CGUID ResponserGuid; _GetBufferFromByteArray(pData, lPos, ResponserGuid); map<CGUID, VecLinkmanGroup>::iterator ite = m_mapPlayerLinkman.find(ResponserGuid); if (m_mapPlayerLinkman.end() == ite) continue; for (LONG j = 0; j < (long)ite->second.size(); ++j) { if (eKW_ServerKeep == m_LGSManage.GetLinkmanGroupSetup_ByOrder(j)->m_uKeepWay) ite->second[j].LinkmanDelStateChange(PlayerGuid, lDataSize); } } }
TEST(store1_8ui,regression) { std::vector<uint8_t,lv::AlignedMemAllocator<uint8_t,16>> vData(16); ASSERT_EQ(((uintptr_t)vData.data()%16),uintptr_t(0)); for(uint8_t v=0; v<255; ++v) { lv::store1_8ui((__m128i*)vData.data(),uint8_t(v)); ASSERT_TRUE(vData[0]==v && std::equal(vData.begin()+1,vData.end(),vData.begin())); } }
TEST(store_8ui,regression) { for(size_t i=0; i<10; ++i) { std::vector<uint8_t,lv::AlignedMemAllocator<uint8_t,16>> vData((1ULL<<i)*size_t(16)); ASSERT_EQ(((uintptr_t)vData.data()%16),uintptr_t(0)); for(uint8_t v=0; v<255; ++v) { lv::store_8ui((__m128i*)vData.data(),vData.size()/16,uint8_t(v)); ASSERT_TRUE(vData[0]==v && std::equal(vData.begin()+1,vData.end(),vData.begin())); } } }
void CalculateChecksumTests::CalculateByteArrayTwoSigns() { CReceiverWrapper vReceiver; QByteArray vData("213"); u_int16_t vResult {vReceiver.ForTestCalculateFileDataChecksum(vData)}; // {150}; // ( (16+16+16)*4 ) + 6 // 6 is (2 + 1 + 3) u_int16_t vExpected {CalculateChecksumHelper::CalculateFileDataChecksum(vData)}; QVERIFY(vExpected == 150); QCOMPARE(vResult, vExpected); }
void CalculateChecksumTests::CalculateByteArrayOneSign() { CReceiverWrapper vReceiver; QByteArray vData("11"); u_int16_t vResult {vReceiver.ForTestCalculateFileDataChecksum(vData)}; // {98}; // ( (16+16+16)*2 ) + 2 // 2 is (1 + 1) u_int16_t vExpected {CalculateChecksumHelper::CalculateFileDataChecksum(vData)}; QVERIFY(vExpected == 98); QCOMPARE(vResult, vExpected); }
TYPED_TEST(aligned_cast_load_fixture,regression) { constexpr size_t nVals = sizeof(__m128i)/sizeof(TypeParam); std::vector<TypeParam,lv::AlignedMemAllocator<TypeParam,16>> vData(nVals); std::iota(vData.begin(),vData.end(),TypeParam(1)); union { TypeParam n[nVals]; __m128i a; } uData = {0}; std::iota(uData.n,uData.n+nVals,TypeParam(1)); ASSERT_EQ(((uintptr_t)vData.data()%16),uintptr_t(0)); ASSERT_TRUE(lv::cmp_eq_128i(_mm_load_si128((__m128i*)vData.data()),uData.a)); ASSERT_TRUE(lv::cmp_eq_128i(*(__m128i*)vData.data(),uData.a)); }
void CEnBrowserCtrl::PrintPreview(LPCTSTR szFile) { if (!szFile || !*szFile) SafeExecWB(OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_DODEFAULT, NULL, NULL); else { COleVariant vFlags(0L), vFrame(_T("")), vData(_T("")), vHeaders(_T("")); // navigate to print file m_nAction = EBC_PRINTPREVIEW; Navigate(szFile, vFlags, vFrame, vData, vHeaders); } }
TEST(hsum_32si,regression) { std::vector<int32_t,lv::AlignedMemAllocator<int32_t,16>> vData(4); ASSERT_EQ(((uintptr_t)vData.data()%16),uintptr_t(0)); ASSERT_EQ(lv::hsum_32i(_mm_load_si128((__m128i*)vData.data())),int32_t(0)); std::iota(vData.begin(),vData.end(),int32_t(1)); ASSERT_EQ(lv::hsum_32i(_mm_load_si128((__m128i*)vData.data())),int32_t((vData.size()*(vData.size()+1))/2)); std::fill(vData.begin(),vData.end(),int32_t(255)); ASSERT_EQ(lv::hsum_32i(_mm_load_si128((__m128i*)vData.data())),int32_t(vData.size()*255)); for(size_t i=0; i<1000; ++i) { for(size_t j=0; j<vData.size(); ++j) vData[j] = rand()%10000 - 5000; ASSERT_EQ(lv::hsum_32i(_mm_load_si128((__m128i*)vData.data())),std::accumulate(vData.begin(),vData.end(),int32_t(0))); } }
void CalculateChecksumTests::CalculateLongByteArray() { CReceiverWrapper vReceiver; QByteArray vData("1211"); u_int16_t vResult {vReceiver.ForTestCalculateFileDataChecksum(vData)}; u_int16_t vExpected {CalculateChecksumHelper::CalculateFileDataChecksum(vData)}; // {197}; // ( (16+16+16)*4 ) + 5 // 5 is (1 + 2 + 1 + 1) QVERIFY(vExpected == 197); QCOMPARE(vResult, vExpected); }
static int lbot_get_all_unit_data(lua_State *L) { std::vector<Funct::UnitData*> vData(g_pDefconInterface->GetAllUnitData()); size_t iSize = vData.size(); switch(lua_type(L, 1)) { case LUA_TNIL: lua_settop(L, 0); // no break case LUA_TNONE: lua_createtable(L, 0, static_cast<int>(iSize)); break; case LUA_TTABLE: lua_settop(L, 1); break; default: luaL_checktype(L, 1, LUA_TTABLE); // never returns } lua_Number fTime = static_cast<lua_Number>(g_pDefconInterface->GetGameTime()); for(size_t i = 0; i < iSize; ++i) { Funct::UnitData *pData = vData[i]; void *pKey = reinterpret_cast<void*>(pData->m_objectId); lua_pushlightuserdata(L, pKey); lua_rawget(L, 1); if(lua_type(L, 2) != LUA_TTABLE) { lua_settop(L, 1); lua_createtable(L, 0, 8); lua_pushlightuserdata(L, pKey); lua_pushvalue(L, 2); lua_rawset(L, 1); } lua_pushvalue(L, lua_upvalueindex(1)); lua_pushnumber(L, fTime); lua_rawset(L, 2); lua_pushvalue(L, lua_upvalueindex(2)); lua_rawgeti(L, LUA_ENVIRONINDEX, TYPE_ENUM_NAMES + pData->m_type); lua_rawset(L, 2); lua_pushvalue(L, lua_upvalueindex(3)); lbot_pushint(L, pData->m_teamId); lua_rawset(L, 2); lua_pushvalue(L, lua_upvalueindex(4)); lua_pushinteger(L, static_cast<lua_Integer>(pData->m_currentState)); lua_rawset(L, 2); lua_pushvalue(L, lua_upvalueindex(5)); lua_pushboolean(L, pData->m_visible ? 1 : 0); lua_rawset(L, 2); lua_pushvalue(L, lua_upvalueindex(6)); lua_pushnumber(L, static_cast<lua_Number>(pData->m_longitude)); lua_rawset(L, 2); lua_pushvalue(L, lua_upvalueindex(7)); lua_pushnumber(L, static_cast<lua_Number>(pData->m_latitude)); lua_rawset(L, 2); lua_settop(L, 1); } return 1; }
/// Reads FLV from stdin and outputs human-readable information to stderr. int main(int argc, char ** argv){ Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION); conf.parseArgs(argc, argv); FLV::Tag FLV_in; // Temporary storage for incoming FLV data. std::ofstream vData("vData"); std::ofstream aData("aData"); while ( !feof(stdin)){ if (FLV_in.FileLoader(stdin)){ std::cout << "Tag: " << FLV_in.tagType() << "\n\tTime: " << FLV_in.tagTime() << std::endl; if (FLV_in.data[0] == 0x08){ //Audio aData.write(FLV_in.data + 13, FLV_in.len - 17); } if (FLV_in.data[0] == 0x09){ //Video vData.write(FLV_in.data + 16, FLV_in.len - 20); } } } vData.close(); aData.close(); return 0; }
void RandAddSeedPerfmon() { RandAddSeed(); #ifdef WIN32 // Don't need this on Linux, OpenSSL automatically uses /dev/urandom // Seed with the entire set of perfmon data // This can take up to 2 seconds, so only do it every 10 minutes static int64_t nLastPerfmon; if (GetTime() < nLastPerfmon + 10 * 60) return; nLastPerfmon = GetTime(); std::vector<unsigned char> vData(250000, 0); long ret = 0; unsigned long nSize = 0; const size_t nMaxSize = 10000000; // Bail out at more than 10MB of performance data while (true) { nSize = vData.size(); ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, begin_ptr(vData), &nSize); if (ret != ERROR_MORE_DATA || vData.size() >= nMaxSize) break; vData.resize(std::max((vData.size() * 3) / 2, nMaxSize)); // Grow size of buffer exponentially } RegCloseKey(HKEY_PERFORMANCE_DATA); if (ret == ERROR_SUCCESS) { RAND_add(begin_ptr(vData), nSize, nSize / 100.0); memory_cleanse(begin_ptr(vData), nSize); LogPrint("rand", "%s: %lu bytes\n", __func__, nSize); } else { static bool warned = false; // Warn only once if (!warned) { LogPrint("INFO", "%s: Warning: RegQueryValueExA(HKEY_PERFORMANCE_DATA) failed with code %i\n", __func__, ret); warned = true; } } #endif }
/* **** This test is designed to test the validity of the three add members of the PolyFit class **** Addition to the PolyFit object is tested with individual datum, gpstk::Vectors of data and **** std::vectors of data. **** These are tested against a least squares polynomial fit that was done by hand **** Please note isSingular, Solution, Degreem N and Solve were tested inderectly **** Please note, I don't know enough about Covariance to test it for the example by hand */ void xPolyFit :: addTest (void) { gpstk::PolyFit<double> AddSingle(2); gpstk::PolyFit<double> AddGVect(2); gpstk::PolyFit<double> AddSVect(2); double data[4] = {0.,2.,4.,-1.}; double time[4] = {3.,3.,4.,2.,}; gpstk::Vector<double> gData(4,0.); gData[0] = 0.; gData[1] = 2.; gData[2] = 4.; gData[3] = -1.; gpstk::Vector<double> gTime(4,0.); gTime[0] = 3.; gTime[1] = 3.; gTime[2] = 4.; gTime[3] = 2.; std::vector<double> vData(4,0.); vData[0] = 0.; vData[1] = 2.; vData[2] = 4.; vData[3] = -1.; std::vector<double> vTime(4,0.); vTime[0] = 3.; vTime[1] = 3.; vTime[2] = 4.; vTime[3] = 2.; //Done by hand gpstk::Vector<double> ExpSolution(2,0.); ExpSolution[0] = 152./59; ExpSolution[1] = 20./59; for (int i =0;i<4;i++) { AddSingle.Add(time[i],data[i]); } gpstk::Vector<double> SingleSolution = AddSingle.Solution(); CPPUNIT_ASSERT_DOUBLES_EQUAL(ExpSolution[0],SingleSolution[0],1e-6); CPPUNIT_ASSERT_DOUBLES_EQUAL(ExpSolution[1],SingleSolution[1],1e-6); CPPUNIT_ASSERT_EQUAL((unsigned) 4, AddSingle.N()); CPPUNIT_ASSERT_EQUAL((unsigned) 2, AddSingle.Degree()); CPPUNIT_ASSERT_EQUAL(false, AddSingle.isSingular()); //Add on an unweighted sample, N should increase but everything else should be the same AddSingle.Add(7.,20.,0); gpstk::Vector<double> SingleSolution2 = AddSingle.Solution(); CPPUNIT_ASSERT_DOUBLES_EQUAL(ExpSolution[0],SingleSolution2[0],1e-6); CPPUNIT_ASSERT_DOUBLES_EQUAL(ExpSolution[1],SingleSolution2[1],1e-6); CPPUNIT_ASSERT_EQUAL((unsigned) 5, AddSingle.N()); CPPUNIT_ASSERT_EQUAL((unsigned) 2, AddSingle.Degree()); CPPUNIT_ASSERT_EQUAL(false, AddSingle.isSingular()); AddGVect.Add(gTime,gData); gpstk::Vector<double> gVectSolution = AddGVect.Solution(); CPPUNIT_ASSERT_DOUBLES_EQUAL(ExpSolution[0],gVectSolution[0],1e-6); CPPUNIT_ASSERT_DOUBLES_EQUAL(ExpSolution[1],gVectSolution[1],1e-6); CPPUNIT_ASSERT_EQUAL((unsigned) 4, AddGVect.N()); CPPUNIT_ASSERT_EQUAL((unsigned) 2, AddGVect.Degree()); CPPUNIT_ASSERT_EQUAL(false, AddGVect.isSingular()); AddSVect.Add(vTime,vData); gpstk::Vector<double> sVectSolution = AddSVect.Solution(); CPPUNIT_ASSERT_DOUBLES_EQUAL(ExpSolution[0],sVectSolution[0],1e-6); CPPUNIT_ASSERT_DOUBLES_EQUAL(ExpSolution[1],sVectSolution[1],1e-6); CPPUNIT_ASSERT_EQUAL((unsigned) 4, AddSVect.N()); CPPUNIT_ASSERT_EQUAL((unsigned) 2, AddSVect.Degree()); CPPUNIT_ASSERT_EQUAL(false, AddSVect.isSingular()); }
void Notify(BYTE * data, size_t length) { std::vector<unsigned char> vData(data, data + length); NotifyVector(vData); }
RevTerrain* RevModelFactory::CreateTerrain( const char* terrainPath ) { RevTerrain* terrain = new RevTerrain(); terrain->SetModelFilePath( terrainPath ); terrain->m_tileSize = 0.25f; terrain->m_terrainHeight = 512.0f; const int GridSize=64; // For 4096 size Heightfield const int stepsPerGrid=4096/GridSize; const int GridSize1=GridSize+1; // For 4096 size Heightfield std::vector<float> heightData; terrain->m_heightData.reserve(4097*4097); FI_File::RevFile file; file.Open( terrainPath ); for(int i=0;i<4097*4097;i++) { unsigned short temp; file.Read( temp ); terrain->m_heightData.push_back((float)temp/65536.0f*terrain->m_terrainHeight ); } file.Close(); const float MinimumSize=terrain->m_tileSize; const float TileSize=stepsPerGrid*MinimumSize; terrain->m_vertexes.reserve( GridSize1 * GridSize1 ); int count2 = 0; RevVertexPosUV vertex; float verts[ GridSize1 * GridSize1 * 3 ]; for(int i=0;i<GridSize1;i++) { for(int j=0;j<GridSize1;j++) { int iStep=i*stepsPerGrid; int jStep=j*stepsPerGrid; vertex.myUV = CU::Vector2f( float(j)/float(GridSize),float(i)/float(GridSize) ); vertex.myPos = CU::Vector3f( (j-GridSize/2)*TileSize, 0.0f, (i-GridSize/2)*TileSize ); terrain->m_vertexes.push_back( vertex ); verts[count2] = vertex.myPos.x; verts[count2+1] = vertex.myPos.y; verts[count2+2] = vertex.myPos.z; count2 += 3; } } int indexes[(GridSize*GridSize*3) * 2]; int count1=0; for(int i=0;i<GridSize;i++) { for(int j=0;j<GridSize;j++) { indexes[count1]=i*GridSize1+j; indexes[count1+1]=i*GridSize1+(j+1); indexes[count1+2]=(i+1)*GridSize1+(j); indexes[count1+3]=(i+1)*GridSize1+(j+1); indexes[count1+4]=(i+1)*GridSize1+(j); indexes[count1+5]=(i)*GridSize1+(j+1); count1+=6; } } // revstuff.Init( &verts[0], GridSize1 * GridSize1 * 3, &indexes[0], count1 ); RevVertexDataNormal vData( GridSize1*GridSize1 ); vData.myStride=sizeof(RevVertexPosUV ); vData.mySize=vData.myNrOfVertexes*vData.myStride; vData.myVertexData= new char [vData.mySize](); memcpy(vData.myVertexData,&terrain->m_vertexes[0],vData.mySize); RevIndexData indexData; indexData.myFormat=DXGI_FORMAT_R32_UINT; indexData.myNrOfIndexes=count1; indexData.mySize=indexData.myNrOfIndexes * sizeof(int); indexData.myIndexData = new char [indexData.mySize](); memcpy(indexData.myIndexData,&indexes[0],indexData.mySize); terrain->InitShader( "Shaders\\EffectTerrain.txt" ); RevModelRenderEssentials renderEssentials( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); renderEssentials.myIndexCount = indexData.myNrOfIndexes; renderEssentials.myIndexStart = 0; renderEssentials.myVertexStart = 0; ID3D11ShaderResourceView* rsv = CreateQuadPatchR16Texture(terrain); terrain->AddTexture( "g_HeightMap", rsv); float pixelPerMeter = static_cast<float>(RevEngineMain::GetWindowWidth()) / (45.0f*2); float factor = pixelPerMeter * 4096; RevEffect* effect = terrain->GetEffect(); /* RevTexture* texOne = new RevTexture(); texOne->LoadTexture( "Terrain\\Snow\\Snow_albedo_01.dds",true ); RevTexture* texTwo = new RevTexture(); texTwo->LoadTexture( "Terrain\\Rock\\Rock_albedo_01.dds",true ); RevTexture* texThree = new RevTexture(); texThree->LoadTexture( "Terrain\\Grass\\Grass_albedo_01.dds",true ); RevTexture* texFour = new RevTexture(); texFour->LoadTexture( "Terrain\\Ice\\Ice_albedo_01.dds",true ); terrain->AddTexture( "g_TexOneDiffuse", texOne->GetSRV() ); terrain->AddTexture( "g_TexTwoDiffuse", texTwo->GetSRV() ); terrain->AddTexture( "g_TexThreeDiffuse", texThree->GetSRV() ); terrain->AddTexture( "g_TexFourDiffuse", texFour->GetSRV() ); RevTexture* blend = new RevTexture(); blend->LoadTexture( "Level_Crosses_Splat.dds",true ); terrain->AddTexture( "g_BlendTex", blend->GetSRV() );*/ /* effect->SetFloatVarible( RevEffect::_TEXTILEZEROAMOUNT, factor / texOne->GetImageSize().x); effect->SetFloatVarible( RevEffect::_TEXTILEONEAMOUNT, factor / texTwo->GetImageSize().x); effect->SetFloatVarible( RevEffect::_TEXTILETWOAMOUNT, factor / texThree->GetImageSize().x); effect->SetFloatVarible( RevEffect::_TEXTILETHREEAMOUNT, factor / texFour->GetImageSize().x); */ RevInputData input; input.myElements.push_back(VertexPosUV[0]); input.myElements.push_back(VertexPosUV[1]); terrain->SetIsNullObjectFlag( false ); terrain->Init( vData, indexData, input, renderEssentials ); terrain->SetModelType( RevModel::_TERRAIN ); m_createdModels.push_back( terrain ); return(terrain); }