MCPcopy Create free account
hub / github.com/SpartanJ/eepp / loadFromStream

Method loadFromStream

src/modules/maps/src/eepp/maps/tilemap.cpp:812–1076  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

810}
811
812bool TileMap::loadFromStream( IOStream& IOS ) {
813 sMapHdr MapHdr;
814 Uint32 i, z;
815
816 if ( IOS.isOpen() ) {
817 IOS.read( (char*)&MapHdr, sizeof( sMapHdr ) );
818
819 if ( MapHdr.Magic == EE_MAP_MAGIC ) {
820 if ( NULL == mForcedHeaders ) {
821 create( Sizei( MapHdr.SizeX, MapHdr.SizeY ), MapHdr.MaxLayers,
822 Sizei( MapHdr.TileSizeX, MapHdr.TileSizeY ), MapHdr.Flags );
823 } else {
824 create( mForcedHeaders->MapSize, mForcedHeaders->NumLayers,
825 mForcedHeaders->TileSize, mForcedHeaders->Flags );
826 }
827
828 setBaseColor( Color( MapHdr.BaseColor ) );
829
830 //! Load Properties
831 if ( MapHdr.PropertyCount ) {
832 sPropertyHdr* tProp = eeNewArray( sPropertyHdr, MapHdr.PropertyCount );
833
834 IOS.read( (char*)&tProp[0], sizeof( sPropertyHdr ) * MapHdr.PropertyCount );
835
836 for ( i = 0; i < MapHdr.PropertyCount; i++ ) {
837 addProperty( std::string( tProp[i].Name ), std::string( tProp[i].Value ) );
838 }
839
840 eeSAFE_DELETE_ARRAY( tProp );
841 }
842
843 //! Load Texture Atlases
844 if ( MapHdr.TextureAtlasCount ) {
845 sMapTextureAtlas* tSG = eeNewArray( sMapTextureAtlas, MapHdr.TextureAtlasCount );
846
847 IOS.read( (char*)&tSG[0], sizeof( sMapTextureAtlas ) * MapHdr.TextureAtlasCount );
848
849 std::vector<std::string> TextureAtlases;
850
851 for ( i = 0; i < MapHdr.TextureAtlasCount; i++ ) {
852 TextureAtlases.push_back( std::string( tSG[i].Path ) );
853 }
854
855 //! Load the Texture Atlases if needed
856 for ( i = 0; i < TextureAtlases.size(); i++ ) {
857 std::string sgname = FileSystem::fileRemoveExtension(
858 FileSystem::fileNameFromPath( TextureAtlases[i] ) );
859
860 if ( NULL == TextureAtlasManager::instance()->getByName( sgname ) ) {
861 TextureAtlasLoader* tgl = eeNew( TextureAtlasLoader, () );
862
863 if ( !VirtualFileSystem::instance()->fileExists( TextureAtlases[i] ) &&
864 !FileSystem::fileExists( TextureAtlases[i] ) ) {
865 std::string path( FileSystem::fileRemoveFileName( mPath ) );
866
867 if ( FileSystem::fileExists( path + TextureAtlases[i] ) ||
868 VirtualFileSystem::instance()->fileExists( path +
869 TextureAtlases[i] ) ) {

Callers

nothing calls this directly

Calls 15

eemaxFunction · 0.85
push_backMethod · 0.80
pushBackMethod · 0.80
isOpenMethod · 0.45
readMethod · 0.45
sizeMethod · 0.45
getByNameMethod · 0.45
fileExistsMethod · 0.45
loadFromFileMethod · 0.45
setOffsetMethod · 0.45
addPropertyMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected