Example #1
0
void WMPImporter::GetWorldMap(DataStream *str, WorldMap *m, unsigned int index)
{
	unsigned int i;
	unsigned int WorldMapsOffset;

	if (index && str==str2) {
		WorldMapsOffset=WorldMapsOffset2;
	}
	else {
		WorldMapsOffset=WorldMapsOffset1;
	}

	str->Seek( WorldMapsOffset + index * 184, GEM_STREAM_START );
	str->ReadResRef( m->MapResRef );
	str->ReadDword( &m->Width );
	str->ReadDword( &m->Height );
	str->ReadDword( &m->MapNumber );
	str->ReadDword( &m->AreaName );
	str->ReadDword( &m->unknown1 );
	str->ReadDword( &m->unknown2 );
	str->ReadDword( &m->AreaEntriesCount );
	str->ReadDword( &m->AreaEntriesOffset );
	str->ReadDword( &m->AreaLinksOffset );
	str->ReadDword( &m->AreaLinksCount );
	str->ReadResRef( m->MapIconResRef );

	// Load map bitmap
	ResourceHolder<ImageMgr> mos(m->MapResRef);
	if (!mos) {
		printMessage( "WMPImporter","Worldmap image not found.\n", LIGHT_RED );
	} else {
		m->SetMapMOS(mos->GetSprite2D());
	}

	// Load location icon bam
	if (!core->IsAvailable( IE_BAM_CLASS_ID )) {
		printMessage( "WMPImporter","No BAM Importer Available.\n", LIGHT_RED );
	} else {
		AnimationFactory* af = ( AnimationFactory* )
			gamedata->GetFactoryResource( m->MapIconResRef, IE_BAM_CLASS_ID, IE_NORMAL );
		if (af)
			m->SetMapIcons( af );
	}

	str->Seek( m->AreaEntriesOffset, GEM_STREAM_START );


	WMPAreaLink al;
	for (i = 0; i < m->AreaEntriesCount; i++) {
		//this weird stuff is requires so we don't create
		//data here, all data is created in the core
		m->SetAreaEntry(i,GetAreaEntry(str, m->GetNewAreaEntry()));
	}

	str->Seek( m->AreaLinksOffset, GEM_STREAM_START );
	for (i = 0; i < m->AreaLinksCount; i++) {
		m->SetAreaLink(i,GetAreaLink(str, &al));
	}

}
Example #2
0
/* virtual */
bool
WMAPResource::Load(Archive* archive, uint32 key)
{
	if (!Resource::Load(archive, key))
		return false;

	if (!CheckSignature(WMAP_SIGNATURE))
		return false;

	if (!CheckVersion(WMAP_VERSION_1))
		return false;

	fData->ReadAt(8, fCount);
	fData->ReadAt(12, fOffset);

	// TODO: Handle the case where there are more than one.
	fData->ReadAt(fOffset, fWorldMapEntry);

	fIcons = gResManager->GetBAM(fWorldMapEntry.map_icons_bam);

	for (uint32 c = 0; c < fWorldMapEntry.areaentries_count; c++) {
		area_entry areaEntry;
		if (GetAreaEntry(c, areaEntry)) {
			fData->ReadAt(
					fWorldMapEntry.areaentries_offset
					+ c * sizeof(area_entry),
					areaEntry);
			AreaEntry* entry = new AreaEntry(areaEntry);
			/*std::cout << "Area " << areaEntry.area;
			std::cout << ", short: " << areaEntry.shortname;
			std::cout << ", long: " <<  areaEntry.name;
			std::cout << ", tooltip: " << areaEntry.tooltip_ref;
			std::cout << ", loading " << areaEntry.loading_mos;
			std::cout << std::endl;
			*/

			entry->fIcon = const_cast<Bitmap*>(fIcons->FrameForCycle(areaEntry.icons_bam_sequence, 0));
			entry->fPosition.x = (int16)areaEntry.x;
			entry->fPosition.y = (int16)areaEntry.y;
			fAreaEntries.push_back(entry);
		}
	}

	return true;
}