static void divide(point * p_sorted[], int l, int r, edge ** l_ccw, edge ** r_cw) { int n; edge *l_ccw_l, *r_cw_l, *l_ccw_r, *r_cw_r, *l_tangent; edge *a, *b, *c; n = r - l + 1; if (n == 2) { /* Bottom of the recursion. Make an edge */ *l_ccw = *r_cw = make_edge(p_sorted[l], p_sorted[r]); } else if (n == 3) { /* Bottom of the recursion. Make a triangle or two edges */ double c_p; a = make_edge(p_sorted[l], p_sorted[l + 1]); b = make_edge(p_sorted[l + 1], p_sorted[r]); splice(a, b, p_sorted[l + 1]); c_p = Cross_product_3p(p_sorted[l], p_sorted[l + 1], p_sorted[r]); if (c_p > 0.0) { /* Make a triangle */ c = join(a, p_sorted[l], b, p_sorted[r], side::right); *l_ccw = a; *r_cw = b; } else if (c_p < 0.0) { /* Make a triangle */ c = join(a, p_sorted[l], b, p_sorted[r], side::left); *l_ccw = c; *r_cw = c; } else { /* Points are collinear, no triangle */ *l_ccw = a; *r_cw = b; } } else if (n > 3) { /* Continue to divide */ /* Calculate the split point */ int split = (l + r) / 2; /* Divide */ divide(p_sorted, l, split, &l_ccw_l, &r_cw_l); divide(p_sorted, split + 1, r, &l_ccw_r, &r_cw_r); /* Merge */ merge(r_cw_l, p_sorted[split], l_ccw_r, p_sorted[split + 1], &l_tangent); /* The lower tangent added by merge may have invalidated l_ccw_l or r_cw_r. Update them if necessary. */ if (Org(l_tangent) == p_sorted[l]) l_ccw_l = l_tangent; if (Dest(l_tangent) == p_sorted[r]) r_cw_r = l_tangent; /* Update edge refs to be passed back */ *l_ccw = l_ccw_l; *r_cw = r_cw_r; } }
Dest structure_cast( fcppt::math::box::object< T, N > const &_src ) { static_assert( fcppt::math::box::is_box< Dest >::value, "Dest must be a box" ); return Dest( fcppt::math::vector::structure_cast< typename Dest::vector, Conv >( _src.pos() ), fcppt::math::dim::structure_cast< typename Dest::dim, Conv >( _src.size() ) ); }
/* * Remove an edge. */ static void delete_edge(edge * e) { point *u, *v; /* Cache origin and destination. */ u = Org(e); v = Dest(e); /* Adjust entry points. */ if (u->entry_pt == e) u->entry_pt = e->onext; if (v->entry_pt == e) v->entry_pt = e->dnext; /* Four edge links to change */ if (Org(e->onext) == u) e->onext->oprev = e->oprev; else e->onext->dprev = e->oprev; if (Org(e->oprev) == u) e->oprev->onext = e->onext; else e->oprev->dnext = e->onext; if (Org(e->dnext) == v) e->dnext->oprev = e->dprev; else e->dnext->dprev = e->dprev; if (Org(e->dprev) == v) e->dprev->onext = e->dnext; else e->dprev->dnext = e->dnext; free_edge(e); }
/** Diferentiate data and return the result in a new object. * WARNING: Do not call for recursive functions as it will crash with a stack overflow * \param Var: Variable to differenciate with respect to * \param Trigonometry: Choose to differentiate trigonometric functions as radians or degrees. */ boost::shared_ptr<TFuncData> TFuncData::MakeDif(const TElem &Var, TTrigonometry Trigonometry) const { if(Data.empty()) throw EFuncError(ecNoFunc); if(CheckRecursive()) throw EFuncError(ecRecursiveDif); try { boost::shared_ptr<TFuncData> Temp(new TFuncData); CopyReplaceArgs(Temp->Data, Data.begin(), std::vector<std::vector<TElem> >()); DEBUG_LOG(std::wclog << L"f(x)=" << MakeText(Temp->Data.begin()) << std::endl); boost::shared_ptr<TFuncData> Dest(new TFuncData); Dest->AddDif(Temp->Data.begin(), Var, Trigonometry, 0); //It is sometimes necesarry to optimize. For example d(x^2) needs an ln(x) optimized away DEBUG_LOG(std::wclog << L"Before simplify: f'(x)=" << MakeText(Dest->Data.begin()) << std::endl); Dest->Simplify(); DEBUG_LOG(std::wclog << L"After simplify: f'(x)=" << MakeText(Dest->Data.begin()) << std::endl); Dest->Simplify(); DEBUG_LOG(std::wclog << L"After simplify: f'(x)=" << MakeText(Dest->Data.begin()) << std::endl); return Dest; } catch(boost::bad_any_cast &E) { throw EFuncError(ecInternalError); } }
RetCode IStreamFileImpl::CopyTo(IStream *dest) const { Common::ISyncObject Locker(GetSynObj()); if (!File.Get()) return retFail; Common::RefObjPtr<IFaces::IStream> Dest(dest); if (!Dest.Get()) return retFail; try { unsigned long FileSize = File->GetSize(); if (!FileSize) return retOk; unsigned long CurPos = File->GetPos(); File->SeekToBegin(); const unsigned long MaxBufSize = 32 * 1024 * 1024; unsigned long BufSize = MaxBufSize > FileSize ? FileSize : MaxBufSize; std::vector<char> Buf(BufSize, 0); for (unsigned long i = File->Read(&Buf[0], BufSize) ; i ; i = File->Read(&Buf[0], BufSize)) { if (Dest->Write(&Buf[0], i) != retOk) return retFail; } File->SeekTo(CurPos); } catch (std::exception &) { return retFail; } return retOk; }
inline void move_to(Iterator first, Iterator last, Dest& dest, container_attribute) { if (is_empty(dest)) dest = Dest(first, last); else append(dest, first, last); }
void cToolboxSprites::paintEvent(QPaintEvent*) { mScaleWidth = (static_cast<double>(size().width()) / static_cast<double>(mImage.width())); mScaleHeight = (static_cast<double>(size().height() - 20) / static_cast<double>(mImage.height())); QPainter painter(this); QRectF Dest(0, 0, size().width(), size().height() - 20); QRectF Src(0, 0, mImage.width(), mImage.height()); painter.drawImage(Dest, mImage, Src); }
// ------------------------------------------------------------------------------------------------ int StoreString(int _argNum, int _argc, char* _argv[], Options* _outOptions, size_t _byteOffset) { std::string* dest; Dest(_outOptions, _byteOffset, &dest); if (_argNum + 2 > _argc) { PrintHelp(); console::error("Not enough parameters for argument '%s'", _argv[_argNum]); } (*dest) = std::string(_argv[_argNum + 1]); return 2; }
// ------------------------------------------------------------------------------------------------ int StorePairInt(int _argNum, int _argc, char* _argv[], Options* _outOptions, size_t _byteOffset) { std::pair<int, int>* dest; Dest(_outOptions, _byteOffset, &dest); if (_argNum + 3 > _argc) { PrintHelp(); console::error("Not enough parameters for argument '%s'", _argv[_argNum]); } (*dest).first = atoi(_argv[_argNum + 1]); (*dest).second = atoi(_argv[_argNum + 2]); return 3; }
Dest map( Source const &_source, Function const &_function ) { return Dest( fcppt::algorithm::array_map< typename Dest::storage_type >( _source.storage(), _function ) ); }
//--------------------------------------------------------- void __fastcall CEVision::MergeImage(int nIndex,int nGrabWidth,double m_dAngle) { /* EImageBW8 A(748,484),B(748*2,484),B1(748*2,484),B2(748*2,484); //A.Load("C:\\Documents and Settings\\Administrator\\桌面\\Work\\20130528 C11 Image\\102418_1.bmp"); A.Load("F:\\AAA.TIF"); ImgScaleRotate(&A,324,242,324,242,1.f,1.f,0.0,&B1,0); ImgScaleRotate(&A,324,242,748+324,242,1.f,1.f,0.0,&B2,0); ImgOper(IMG_ADD,&B1,&B2,&B2); theVision.m_ImageTmpBW8.SetSize(748*2,484); ImgCopy(&B2,&theVision.m_ImageTmpBW8); */ int nWidth=nGrabWidth;//400; int nHeight=m_ImageSizeY; int nOrgX=(m_ImageSizeX-nWidth)/2; //124 int nImageCount=4; //if(nIndex==0) ImgOper(IMG_XOR,&m_ImageADD,&m_ImageADD,&m_ImageADD); //Clear Image m_roiADD.Attach(&m_ImageTmpBW8); //m_ImageBW8 m_roiADD.SetPlacement(nOrgX,0,nWidth,nHeight); m_ImageADD.SetSize(nWidth*nImageCount,nHeight); EImageBW8 Dest(nWidth*nImageCount,nHeight); ImgScaleRotate(&m_roiADD,nWidth/2,nHeight/2,nWidth/2+nWidth*nIndex,nHeight/2,1.f,1.f,m_dAngle,&Dest,4); //0.5 degree if(nIndex==0) ImgOper(IMG_XOR,&m_ImageADD,&m_ImageADD,&m_ImageADD); //Clear Image ImgOper(IMG_ADD,&Dest,&m_ImageADD,&m_ImageADD); if(nIndex==3) { //m_ImageTmpBW8.SetSize(nWidth*nImageCount,nHeight); //ImgCopy(&m_ImageADD,&m_ImageTmpBW8); ImgScaleRotate(&m_ImageADD,0,0,0,0, 1.f, 1.f, 0.0, &m_ImageTmpBW8, 0); } m_roiADD.Detach(); //m_ImageADD,clear }
Dest binary_map( Source1 const &_source1, Source2 const &_source2, Function const &_function ) { return Dest( fcppt::algorithm::array_binary_map< typename Dest::storage_type >( _source1.storage(), _source2.storage(), _function ) ); }
BOOL CArtOleDropTarget::SaveDIBToUserArt(BITMAPINFO* pBitmap, LPCTSTR pFilename) { // TODO: create general function in bmp.cpp to do the DIB stuff? // Compute the size of the BMP data. DWORD nByteWidth = (pBitmap->bmiHeader.biWidth*pBitmap->bmiHeader.biBitCount+7)/8; nByteWidth = (nByteWidth + 3) & ~3; DWORD dwSizeImage = (DWORD)nByteWidth * (DWORD)pBitmap->bmiHeader.biHeight; int nColors; if (pBitmap->bmiHeader.biClrUsed != 0) nColors = pBitmap->bmiHeader.biClrUsed; else if (pBitmap->bmiHeader.biBitCount > 8) nColors = 0; else nColors = (1 << pBitmap->bmiHeader.biBitCount); DWORD dwSizeColors = nColors * sizeof(pBitmap->bmiColors[0]); DWORD dwDataSize = pBitmap->bmiHeader.biSize + dwSizeColors + dwSizeImage; // Build the header. BITMAPFILEHEADER Header; Header.bfType = (SHORT)'B' + (((SHORT)'M') << 8); Header.bfSize = sizeof(Header) + dwDataSize; Header.bfReserved1 = 0; Header.bfReserved2 = 0; Header.bfOffBits = sizeof(Header) + pBitmap->bmiHeader.biSize + dwSizeColors; // Write the bitmap file to memory, then save to disk MemoryDevice DataDevice; DataDevice.AddPiece(&Header, sizeof(Header)); DataDevice.AddPiece(pBitmap, dwDataSize); // save BMP to file in user art directory StorageFile Dest(pFilename); if (copy_file(&DataDevice, &Dest) != ERRORCODE_None) { Dest.flush(); Dest.zap(); return FALSE; } return TRUE; }
inline Dest to_different( Source const &_source ) { static_assert( Dest::dim_wrapper::value == Source::dim_wrapper::value, "dim_wrappers must match" ); return Dest( _source.begin(), _source.end() ); }
bool FileUtil::CopyFile(const char* sSrc, const char* sDest) { File Src(sSrc); File Dest(sDest); const unsigned int uBufSize = 4096; char sBuf[uBufSize] = {0}; unsigned int uReadSize = 0; do { if (Src.Read(sBuf, 1, uBufSize, &uReadSize) == false) { return false; } if (uReadSize) { if (Dest.Write(&sBuf, 1, uReadSize) == false) { return false; } } } while(uReadSize); return true; }
bool CActionWander::SelectAction(CActor* pActor) { if (CurrAction.isvalid()) CurrAction->Deactivate(pActor); //!!!can tune all these probabilities and timings! float Rnd = n_rand(); if (Rnd < 0.6f) { // Can also start from current direction & limit angle vector2 Dest(0.f, -1.f); Dest.rotate(n_rand(-PI, PI)); if (Rnd < 0.3f) { // NavSystem automatically clamps a destination to the navmesh Dest *= (n_rand() * 11.5f + 3.5f); pActor->GetNavSystem().SetDestPoint(vector3(Dest.x + InitialPos.x, pActor->Position.y, Dest.y + InitialPos.y)); CurrAction = n_new(CActionGoto); //vector3 Loc; //if (pActor->GetNavSystem().GetRandomValidLocation(15.f, Loc)) //{ // pActor->GetNavSystem().SetDestPoint(Loc); // CurrAction = n_new(CActionGoto); //} } else { pActor->GetMotorSystem().SetFaceDirection(vector3(Dest.x, 0.f, Dest.y)); CurrAction = n_new(CActionFace); } } else { CurrAction = NULL; NextActSelectionTime = (float)GameSrv->GetTime() + n_rand() * 5.f + 5.f; OK; } return CurrAction->Activate(pActor); }
void CCollision::Init(class CLayers *pLayers) { if(m_pLayers) m_pLayers->Dest(); Dest(); m_pLayers = pLayers; m_Width = m_pLayers->GameLayer()->m_Width; m_Height = m_pLayers->GameLayer()->m_Height; m_pTiles = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->GameLayer()->m_Data)); if(m_pLayers->TeleLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->TeleLayer()->m_Tele); if (Size >= m_Width*m_Height*sizeof(CTeleTile)) m_pTele = static_cast<CTeleTile *>(m_pLayers->Map()->GetData(m_pLayers->TeleLayer()->m_Tele)); } if(m_pLayers->SpeedupLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->SpeedupLayer()->m_Speedup); if (Size >= m_Width*m_Height*sizeof(CSpeedupTile)) m_pSpeedup = static_cast<CSpeedupTile *>(m_pLayers->Map()->GetData(m_pLayers->SpeedupLayer()->m_Speedup)); } if(m_pLayers->TuneLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->TuneLayer()->m_Tune); if (Size >= m_Width*m_Height*sizeof(CTuneTile)) m_pTune = static_cast<CTuneTile *>(m_pLayers->Map()->GetData(m_pLayers->TuneLayer()->m_Tune)); } if(m_pLayers->FrontLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->FrontLayer()->m_Front); if (Size >= m_Width*m_Height*sizeof(CTile)) m_pFront = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->FrontLayer()->m_Front)); } for(int i = 0; i < m_Width*m_Height; i++) { int Index; if(m_pFront) { Index = m_pFront[i].m_Index; if(Index <= TILE_SUPER_START) { switch(Index) { case TILE_DEATH: m_pFront[i].m_Index = COLFLAG_DEATH; break; case TILE_SOLID: m_pFront[i].m_Index = 0; break; case TILE_NOHOOK: m_pFront[i].m_Index = 0; break; default: m_pFront[i].m_Index = 0; } // DDRace tiles if((Index >= TILE_WALLJUMP && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_EHOOK && Index <= TILE_ZHOLDPOINT_END)) m_pFront[i].m_Index = Index; } } Index = m_pTiles[i].m_Index; if(Index <= TILE_SUPER_START) { switch(Index) { case TILE_DEATH: m_pTiles[i].m_Index = COLFLAG_DEATH; break; case TILE_SOLID: m_pTiles[i].m_Index = COLFLAG_SOLID; break; case TILE_NOHOOK: m_pTiles[i].m_Index = COLFLAG_SOLID|COLFLAG_NOHOOK; break; default: m_pTiles[i].m_Index = 0; } // DDRace tiles if((Index >= TILE_WALLJUMP && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_EHOOK && Index <= TILE_ZHOLDPOINT_END)) m_pTiles[i].m_Index = Index; } } }
void CCollision::Init(class CLayers *pLayers) { if(m_pLayers) m_pLayers->Dest(); Dest(); m_NumSwitchers = 0; m_pLayers = pLayers; m_Width = m_pLayers->GameLayer()->m_Width; m_Height = m_pLayers->GameLayer()->m_Height; m_pTiles = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->GameLayer()->m_Data)); if(m_pLayers->TeleLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->TeleLayer()->m_Tele); if (Size >= m_Width*m_Height*sizeof(CTeleTile)) m_pTele = static_cast<CTeleTile *>(m_pLayers->Map()->GetData(m_pLayers->TeleLayer()->m_Tele)); } if(m_pLayers->SpeedupLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->SpeedupLayer()->m_Speedup); if (Size >= m_Width*m_Height*sizeof(CSpeedupTile)) m_pSpeedup = static_cast<CSpeedupTile *>(m_pLayers->Map()->GetData(m_pLayers->SpeedupLayer()->m_Speedup)); } if(m_pLayers->SwitchLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->SwitchLayer()->m_Switch); if (Size >= m_Width*m_Height*sizeof(CSwitchTile)) m_pSwitch = static_cast<CSwitchTile *>(m_pLayers->Map()->GetData(m_pLayers->SwitchLayer()->m_Switch)); m_pDoor = new CDoorTile[m_Width*m_Height]; mem_zero(m_pDoor, m_Width * m_Height * sizeof(CDoorTile)); } else { m_pDoor = 0; m_pSwitchers = 0; } if(m_pLayers->TuneLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->TuneLayer()->m_Tune); if (Size >= m_Width*m_Height*sizeof(CTuneTile)) m_pTune = static_cast<CTuneTile *>(m_pLayers->Map()->GetData(m_pLayers->TuneLayer()->m_Tune)); } if(m_pLayers->FrontLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->FrontLayer()->m_Front); if (Size >= m_Width*m_Height*sizeof(CTile)) m_pFront = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->FrontLayer()->m_Front)); } for(int i = 0; i < m_Width*m_Height; i++) { int Index; if(m_pSwitch) { if(m_pSwitch[i].m_Number > m_NumSwitchers) m_NumSwitchers = m_pSwitch[i].m_Number; if(m_pSwitch[i].m_Number) m_pDoor[i].m_Number = m_pSwitch[i].m_Number; else m_pDoor[i].m_Number = 0; Index = m_pSwitch[i].m_Type; if(Index <= TILE_NPH_START) { if(Index >= TILE_JUMP && Index <= TILE_BONUS) m_pSwitch[i].m_Type = Index; else m_pSwitch[i].m_Type = 0; } } } if(m_NumSwitchers) { m_pSwitchers = new SSwitchers[m_NumSwitchers+1]; for (int i = 0; i < m_NumSwitchers+1; ++i) { m_pSwitchers[i].m_Initial = true; for (int j = 0; j < MAX_CLIENTS; ++j) { m_pSwitchers[i].m_Status[j] = true; m_pSwitchers[i].m_EndTick[j] = 0; m_pSwitchers[i].m_Type[j] = 0; } } } }
//---------- void Mesh2DFromGraycode::triangulate() { this->throwIfMissingAnyConnection(); auto dataSet = this->getInput<Scan::Graycode>()->getDataSet(); if (!dataSet.getHasData()) { throw(Exception("No scan data available")); } //get camera coords in projector space map const auto & cameraInProjector = dataSet.getDataInverse(); const auto & active = dataSet.getActive(); const auto projectorWidth = cameraInProjector.getWidth(); const auto projectorHeight = cameraInProjector.getHeight(); const auto cameraWidth = active.getWidth(); auto getCameraPixelPosition = [&cameraInProjector, projectorWidth, cameraWidth](int i, int j) { const auto cameraPixelIndex = cameraInProjector.getData()[i + j * projectorWidth]; return ofVec2f(cameraPixelIndex % cameraWidth, cameraPixelIndex / cameraWidth); }; auto isActive = [& cameraInProjector, &active, projectorWidth](int i, int j) { const auto cameraPixelIndex = cameraInProjector.getData()[i + j * projectorWidth]; const auto isActive = active.getData()[cameraPixelIndex]; return isActive; }; vector<ofPoint> projectorSpaceActivePoints; //find all active pixels for (int j = 0; j < projectorHeight; j++) { for (int i = 0; i < projectorWidth; i++) { if (isActive(i, j)) { projectorSpaceActivePoints.emplace_back(ofVec2f(i, j)); } } } //triangulate ofMesh mesh; { //make vertices and tex coords Delaunay::Point tempP; vector<Delaunay::Point> delauneyPoints; for (const auto & projectorSpaceActivePoint : projectorSpaceActivePoints) { delauneyPoints.emplace_back(projectorSpaceActivePoint.x, projectorSpaceActivePoint.y); mesh.addVertex(projectorSpaceActivePoint); mesh.addTexCoord(getCameraPixelPosition(projectorSpaceActivePoint.x, projectorSpaceActivePoint.y)); } //triangulate auto delauney = make_shared<Delaunay>(delauneyPoints); delauney->Triangulate(); //apply indices for (auto it = delauney->fbegin(); it != delauney->fend(); ++it) { mesh.addIndex(delauney->Org(it)); mesh.addIndex(delauney->Dest(it)); mesh.addIndex(delauney->Apex(it)); } } swap(this->getInput<Data::Mesh>()->getMesh(), mesh); }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ int StoreTrue(int _argNum, int _argc, char* _argv[], Options* _outOptions, size_t _byteOffset) { bool* dest; Dest(_outOptions, _byteOffset, &dest); (*dest) = true; return 1; }
ERRORCODE CreateWMFFromMetaFilePict(LPCSTR pName, PMGDatabase* pDatabase, const METAFILEPICT* pPict, GraphicObject*& pObject) { ERRORCODE error; pObject = NULL; // od("WMF - mm: %d, xExt: %d, yExt: %d, hMF: %u\r\n", // pPict->mm, // pPict->xExt, // pPict->yExt, // pPict->hMF); /* // Build the device image. // This will consist of two pieces: // (1) Our constructed placeable metafile header, and // (2) The actual WMF data. */ MemoryDevice DataDevice; // (1) The header. ALDUS_WMF_HEADER Header; FillOutAldusHeader(Header, pPict); DataDevice.AddPiece(&Header, sizeof(Header)); // (2) The WMF data. error = ERRORCODE_Memory; HMETAFILE hMF; #ifdef WIN32 #ifdef _MAC // TODO:MAC -- GetMetaFileBitsEx not supported hMF = NULL; if (0) { HGLOBAL hMem = NULL; if (0) { LPVOID pMem = NULL; if (0) { #else //_MAC UINT uSizeData; if ((hMF = pPict->hMF) != NULL && (uSizeData = ::GetMetaFileBitsEx(hMF, 0, NULL)) != 0) { HGLOBAL hMem; if ((hMem = GlobalAlloc(GMEM_MOVEABLE, uSizeData)) != NULL) { LPVOID pMem; if ((pMem = ::GlobalLock(hMem)) != NULL) { ::GetMetaFileBitsEx(hMF, uSizeData, pMem); #endif // else _MAC #else // _WIN32 // GetMetaFileBits() will destroy the metafile under Win16. // So we copy it. if ((hMF = ::CopyMetaFile(pPict->hMF, NULL)) != NULL) { HGLOBAL hMem; if ((hMem = ::GetMetaFileBits(hMF)) == NULL) { ::DeleteMetaFile(hMF); } else { LPVOID pMem; if ((pMem = ::GlobalLock(hMem)) != NULL) { #endif DataDevice.AddPiece(pMem, ::GlobalSize(hMem)); /* // Build the graphic creation structure. // We want to embed source so it will use our little memory device. */ GRAPHIC_CREATE_STRUCT gcs; gcs.m_csFileName = pName; gcs.embed_source = TRUE; gcs.pSourceDevice = &DataDevice; /* Create the graphic. */ if ((pObject = pDatabase->create_graphic_object(&gcs)) == NULL) { error = pDatabase->last_creation_error(); } else { /* Success! */ error = ERRORCODE_None; } ::GlobalUnlock(hMem); } ::GlobalFree(hMem); } } return error; } // // Create a WMF file from the passed MetaFilePict. // ERRORCODE CreateWMFFromMetaFilePict(const METAFILEPICT* pPict, LPCSTR pFileName) { ERRORCODE error = ERRORCODE_Memory; MemoryDevice DataDevice; // Save the header. ALDUS_WMF_HEADER Header; FillOutAldusHeader(Header, pPict); DataDevice.AddPiece(&Header, sizeof(Header)); // Save the WMF data. HMETAFILE hMF; UINT uSizeData; if ((hMF = pPict->hMF) != NULL && (uSizeData = ::GetMetaFileBitsEx(hMF, 0, NULL)) != 0) { HGLOBAL hMem; if ((hMem = ::GlobalAlloc(GMEM_MOVEABLE, uSizeData)) != NULL) { LPVOID pMem; if ((pMem = ::GlobalLock(hMem)) != NULL) { ::GetMetaFileBitsEx(hMF, uSizeData, pMem); DataDevice.AddPiece(pMem, uSizeData); StorageFile Dest(pFileName); if ((error = copy_file(&DataDevice, &Dest)) != ERRORCODE_None) { Dest.flush(); Dest.zap(); } ::GlobalUnlock(hMem); } ::GlobalFree(hMem); } } return error; }
// ------------------------------------------------------------------------------------------------ int StoreFloat(int _argNum, int _argc, char* _argv[], Options* _outOptions, size_t _byteOffset) { float* dest; Dest(_outOptions, _byteOffset, &dest); (*dest) = (float)atof(_argv[_argNum + 1]); return 2; }
void CCollision::Init(class CLayers *pLayers) { if(m_pLayers) m_pLayers->Dest(); Dest(); m_NumSwitchers = 0; m_pLayers = pLayers; m_Width = m_pLayers->GameLayer()->m_Width; m_Height = m_pLayers->GameLayer()->m_Height; m_pTiles = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->GameLayer()->m_Data)); if(m_pLayers->TeleLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->TeleLayer()->m_Tele); if (Size >= m_Width*m_Height*sizeof(CTeleTile)) m_pTele = static_cast<CTeleTile *>(m_pLayers->Map()->GetData(m_pLayers->TeleLayer()->m_Tele)); } if(m_pLayers->SpeedupLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->SpeedupLayer()->m_Speedup); if (Size >= m_Width*m_Height*sizeof(CSpeedupTile)) m_pSpeedup = static_cast<CSpeedupTile *>(m_pLayers->Map()->GetData(m_pLayers->SpeedupLayer()->m_Speedup)); } if(m_pLayers->SwitchLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->SwitchLayer()->m_Switch); if (Size >= m_Width*m_Height*sizeof(CSwitchTile)) m_pSwitch = static_cast<CSwitchTile *>(m_pLayers->Map()->GetData(m_pLayers->SwitchLayer()->m_Switch)); m_pDoor = new CDoorTile[m_Width*m_Height]; mem_zero(m_pDoor, m_Width * m_Height * sizeof(CDoorTile)); } else { m_pDoor = 0; m_pSwitchers = 0; } if(m_pLayers->TuneLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->TuneLayer()->m_Tune); if (Size >= m_Width*m_Height*sizeof(CTuneTile)) m_pTune = static_cast<CTuneTile *>(m_pLayers->Map()->GetData(m_pLayers->TuneLayer()->m_Tune)); } if(m_pLayers->FrontLayer()) { unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(m_pLayers->FrontLayer()->m_Front); if (Size >= m_Width*m_Height*sizeof(CTile)) m_pFront = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->FrontLayer()->m_Front)); } for(int i = 0; i < m_Width*m_Height; i++) { int Index; if(m_pSwitch) { if(m_pSwitch[i].m_Number > m_NumSwitchers) m_NumSwitchers = m_pSwitch[i].m_Number; if(m_pSwitch[i].m_Number) m_pDoor[i].m_Number = m_pSwitch[i].m_Number; else m_pDoor[i].m_Number = 0; Index = m_pSwitch[i].m_Type; if(Index <= TILE_NPH_START) { if(Index >= TILE_JUMP && Index <= TILE_BONUS) m_pSwitch[i].m_Type = Index; else m_pSwitch[i].m_Type = 0; } } if(m_pFront) { Index = m_pFront[i].m_Index; if(Index <= TILE_NPH_START) { switch(Index) { case TILE_DEATH: m_pFront[i].m_Index = COLFLAG_DEATH; break; case TILE_SOLID: m_pFront[i].m_Index = 0; break; case TILE_NOHOOK: m_pFront[i].m_Index = 0; break; case TILE_NOLASER: m_pFront[i].m_Index = TILE_NOLASER; break; default: m_pFront[i].m_Index = 0; } // DDRace tiles if(Index == TILE_THROUGH || Index == TILE_FREEZE || (Index >= TILE_UNFREEZE && Index <= TILE_DUNFREEZE) || (Index >= TILE_WALLJUMP && Index <= TILE_SOLO_END) || (Index >= TILE_REFILL_JUMPS && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_OLDLASER && Index <= TILE_NPH) || (Index >= TILE_NPC_END && Index <= TILE_NPH_END) || (Index >= TILE_NPC_START && Index <= TILE_NPH_START) || (Index >=TILE_RAINBOW && Index<= TILE_RMEXTRAS)) m_pFront[i].m_Index = Index; } } Index = m_pTiles[i].m_Index; if(Index <= TILE_NPH_START) { switch(Index) { case TILE_DEATH: m_pTiles[i].m_Index = COLFLAG_DEATH; break; case TILE_SOLID: m_pTiles[i].m_Index = COLFLAG_SOLID; break; case TILE_NOHOOK: m_pTiles[i].m_Index = COLFLAG_SOLID|COLFLAG_NOHOOK; break; case TILE_NOLASER: m_pTiles[i].m_Index = TILE_NOLASER; break; default: m_pTiles[i].m_Index = 0; } // DDRace tiles if(Index == TILE_THROUGH || Index == TILE_FREEZE || (Index >= TILE_UNFREEZE && Index <= TILE_DUNFREEZE) || (Index >= TILE_WALLJUMP && Index <= TILE_SOLO_END) || (Index >= TILE_REFILL_JUMPS && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_OLDLASER && Index <= TILE_NPH) || (Index >= TILE_NPC_END && Index <= TILE_NPH_END) || (Index >= TILE_NPC_START && Index <= TILE_NPH_START) || (Index >=TILE_RAINBOW && Index<= TILE_RMEXTRAS)) m_pTiles[i].m_Index = Index; } } if(m_NumSwitchers) { m_pSwitchers = new SSwitchers[m_NumSwitchers+1]; for (int i = 0; i < m_NumSwitchers+1; ++i) { m_pSwitchers[i].m_Initial = true; for (int j = 0; j < MAX_CLIENTS; ++j) { m_pSwitchers[i].m_Status[j] = true; m_pSwitchers[i].m_EndTick[j] = 0; m_pSwitchers[i].m_Type[j] = 0; } } } }