[SDK]How to enable Civ to Read/Write std::map object?

stmartin

aka. poyuzhe
Joined
Aug 4, 2007
Messages
640
Location
Shanghai
I know that std::vector can be read/write perfectly, but hey, std::map sometimes can be real handy. If there's a way to do that, I'd like to know.:)

PS. vectors are read/write in this way in Civ:
Code:
        pStream->Read(&iNumElts);
	joinedSpecialistsNames.clear();
	for (int i = 0; i < iNumElts; ++i)
	{
		UnitClassTypes eUnitClass;
		pStream->Read((int*)&eUnitClass);
		CvWString strName;
		pStream->ReadString(strName);
		joinedSpecialistsNames.push_back(std::make_pair(eUnitClass, strName));
	}

        pStream->Write(joinedSpecialistsNames.size());
	for (std::vector< std::pair<UnitClassTypes, CvWString> >::iterator it = joinedSpecialistsNames.begin(); it != joinedSpecialistsNames.end(); ++it)
	{
		pStream->Write((*it).first);
		pStream->WriteString((*it).second);
	}
 
Yes, but I have found an example Civ Read/Write a map object.....Not too late:)

However, I still wonder how a multimap is handled in this case?

May be one day I'll come across another example in Civ handling Multimap, who knows.....
 
Top Bottom