////////////////////////////////////////////////////////////////////////// ReadObjectDynCreate //////////////////////////////////////////////////////////////////////////
| 239 | // ReadObjectDynCreate |
| 240 | /////////////////////////////////////////////////////////////////////////////// |
| 241 | iTypedSerializable* cSerializerImpl::ReadObjectDynCreate() |
| 242 | { |
| 243 | cDebug d("cSerializerImpl::ReadObjectDynCreate"); |
| 244 | //d.TraceDetail("Entering... archive offset = %d\n", mpArchive->CurrentPos()); |
| 245 | |
| 246 | int32 size, objIdx; |
| 247 | uint32 crc; |
| 248 | // first, get the type... |
| 249 | mpArchive->ReadInt32(reinterpret_cast<int32&>(crc)); |
| 250 | |
| 251 | // read in the version |
| 252 | int32 version; |
| 253 | mpArchive->ReadInt32(version); |
| 254 | |
| 255 | // read in the size and the index... |
| 256 | mpArchive->ReadInt32(size); |
| 257 | |
| 258 | // Save the position so we can seek correctly later on |
| 259 | //int64 sizePos = mpArchive->CurrentPos(); |
| 260 | |
| 261 | mpArchive->ReadInt32(objIdx); |
| 262 | if (objIdx == 0) |
| 263 | { |
| 264 | // the object is not reference counted; create and read in the object |
| 265 | // first, we need to create the object. |
| 266 | SerMap::iterator si; |
| 267 | si = mSerCreateMap.find(crc); |
| 268 | if (si == mSerCreateMap.end()) |
| 269 | { |
| 270 | // unable to find the creation function... |
| 271 | d.TraceError("Unable to find creation function for non-ref counted object %d\n", crc); |
| 272 | TOSTRINGSTREAM str; |
| 273 | #ifdef DEBUG |
| 274 | // Let's only report the actual crc in debug mode |
| 275 | str << (int32)crc << std::ends; |
| 276 | #endif |
| 277 | ThrowAndAssert(eSerializerUnknownType(str.str(), mFileName, eSerializer::TY_FILE)); |
| 278 | } |
| 279 | iTypedSerializable* pObj = ((*si).second)(); |
| 280 | d.TraceDetail("Created non-ref counted object %s(%p)\n", pObj->GetType().AsString(), pObj); |
| 281 | pObj->Read(this, version); |
| 282 | |
| 283 | // seek past this object in case filepos is not correct! |
| 284 | //mpArchive->Seek(sizePos + size, cBidirArchive::BEGINNING); |
| 285 | |
| 286 | return pObj; |
| 287 | } |
| 288 | else |
| 289 | { |
| 290 | // refrence counted... |
| 291 | iSerRefCountObj* pObj; |
| 292 | pObj = mRefCtObjTbl.Lookup(objIdx); |
| 293 | if (pObj == NULL) |
| 294 | { |
| 295 | // not in table yet...first find the creation function |
| 296 | SerRefCountMap::iterator rci; |
| 297 | rci = mSerRefCountCreateMap.find(crc); |
| 298 | if (rci == mSerRefCountCreateMap.end()) |