BOOL CSchemaMember::LoadSchema(const CXMLElement* pRoot, const CXMLElement* pElement) { m_bElement = pElement->GetName().CompareNoCase( L"element" ) == 0; m_sName = pElement->GetAttributeValue( L"name", L"" ); if ( m_sName.IsEmpty() ) return FALSE; m_sTitle = m_sName; m_sTitle.SetAt( 0, TCHAR( toupper( m_sTitle.GetAt( 0 ) ) ) ); m_sType = pElement->GetAttributeValue( L"type", L"" ); ToLower( m_sType ); m_bNumeric = ( m_sType == L"decimal" || m_sType == L"int" || m_sType == L"short" ); m_bBoolean = m_sType == L"boolean"; m_bYear = m_sType == L"year"; m_bGUID = m_sType == L"guidtype"; CString strValue = pElement->GetAttributeValue( L"minOccurs", L"0" ); _stscanf( strValue, L"%i", &m_nMinOccurs ); strValue = pElement->GetAttributeValue( L"maxOccurs", L"65536" ); _stscanf( strValue, L"%i", &m_nMaxOccurs ); if ( pElement->GetElementCount() ) return LoadType( pElement->GetFirstElement() ); if ( ! m_sType.IsEmpty() ) { const CXMLElement* pType = m_pSchema->GetType( pRoot, m_sType ); return pType ? LoadType( pType ) : TRUE; } return FALSE; }
BOOL CSchemaMember::LoadSchema(CXMLElement* pRoot, CXMLElement* pElement) { m_bElement = pElement->GetName().CompareNoCase( _T("element") ) == 0; m_sName = pElement->GetAttributeValue( _T("name"), _T("") ); if ( m_sName.IsEmpty() ) return FALSE; m_sTitle = m_sName; m_sTitle.SetAt( 0, toupper( m_sTitle.GetAt( 0 ) ) ); m_sType = pElement->GetAttributeValue( _T("type"), _T("") ); CharLower( m_sType.GetBuffer() );// Lowercase'd m_sType.ReleaseBuffer(); m_bNumeric = ( m_sType == _T("short") || m_sType == _T("int") || m_sType == _T("decimal") ); CString strValue = pElement->GetAttributeValue( _T("minOccurs"), _T("0") ); _stscanf( strValue, _T("%i"), &m_nMinOccurs ); strValue = pElement->GetAttributeValue( _T("maxOccurs"), _T("65536") ); _stscanf( strValue, _T("%i"), &m_nMaxOccurs ); if ( pElement->GetElementCount() ) { return LoadType( pElement->GetFirstElement() ); } else if ( m_sType.GetLength() ) { CXMLElement* pType = m_pSchema->GetType( pRoot, m_sType ); return pType ? LoadType( pType ) : TRUE; } else { return FALSE; } }
std::list<Particle> CellMesh2D::generateExplosionParticles(const size_t &x, const size_t &y, const size_t &max_value) { std::list<Particle> particles; const LoadType step_x = bounds.width() / getWidth(); const LoadType step_y = bounds.height() / getHeight(); const LoadType rx = bounds.getLeft() + x*step_x; const LoadType ry = bounds.getBottom() + y*step_y; const LoadType cx = bounds.getLeft() + bounds.width() / 2.0; const LoadType cy = bounds.getBottom() + bounds.height() / 2.0; const LoadType val = 0.5 - (rx*rx + ry*ry); const size_t num_of_particles = val > 0 ? val*max_value : 0; for (size_t n = 0; n < num_of_particles; n++) { const LoadType px = rx + step_x*LoadType(rand() % 1000)/1000.0; const LoadType py = ry + step_y*LoadType(rand() % 1000)/1000.0; particles.push_back(Particle(Coord2D<Real>(px, py), Coord2D<Real>(px - cx, py - cy))); } return particles; }
/** * lädt eine LST-File in ein ArchivInfo. * * @param[in] file Dateiname der LST-File * @param[in] palette Grundpalette der LST-File * @param[out] items ArchivInfo-Struktur, welche gefüllt wird * * @return Null bei Erfolg, ein Wert ungleich Null bei Fehler * * @author FloSoft * @author OLiver */ int libsiedler2::loader::LoadLST(const char *file, const ArchivItem_Palette *palette, ArchivInfo *items) { FILE *lst; unsigned short header; unsigned int count; if(file == NULL || items == NULL) return 1; // Datei zum lesen öffnen lst = fopen(file, "rb"); // hat das geklappt? if(lst == NULL) return 2; // Header einlesen if(libendian::be_read_us(&header, lst) != 0) return 3; // ist es eine GER/ENG-File? (Header 0xE7FD) if(header == 0xE7FD) { fclose(lst); return LoadTXT(file, items); } // ist es eine LST-File? (Header 0x204E) if(header != 0x204E) return 4; // Anzahl einlesen if(libendian::le_read_ui(&count, lst) != 0) return 5; // Platz für items anlegen items->alloc(count); // items einlesen for(unsigned int i = 0; i < count; ++i) { short used; short bobtype; // use-Flag einlesen if(libendian::be_read_s(&used, lst) != 0) return 6; // ist das Item benutzt? if(used != 0x0100) { //fprintf(stderr, "unused %04X\n", used); continue; } // bobtype des Items einlesen if(libendian::le_read_s(&bobtype, lst) != 0) return 7; //fprintf(stderr, "bobtype %d\n", bobtype); // Daten von Item auswerten if(LoadType(bobtype, lst, palette, items->getP(i)) != 0) return 8; } // Datei schliessen fclose(lst); // alles ok return 0; }