Advertisement
Guest User

StreamingPartitionReader::marshalArrays

a guest
Jun 14th, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.63 KB | None | 0 0
  1. void __thiscall fb::StreamingPartitionReader::handleFixup(fb::StreamingPartitionReader *this)
  2. {
  3.   fb::StreamingPartitionReader *streamReader; // esi@1
  4.   const char *v2; // eax@1
  5.  
  6.   streamReader = this;
  7.   memcpy(this->m_targetStringBase, this->m_sourceStringBlock, this->m_header.stringTableSize);
  8.   v2 = fb::StreamingPartitionReader::layoutDataContainers(streamReader);
  9.   fb::StreamingPartitionReader::marshalDataContainers(streamReader, v2);
  10.   if ( streamReader->m_endianSwapRequired )
  11.     fb::StreamingPartitionReader::marshalArraysEndianSwap(streamReader);
  12.   else
  13.     fb::StreamingPartitionReader::marshalArrays(streamReader);
  14. }
  15.  
  16. void __thiscall fb::StreamingPartitionReader::marshalArrays(fb::StreamingPartitionReader *this)
  17. {
  18.   fb::StreamingPartitionReader *streamReader; // esi@1
  19.   unsigned int arrayIndex; // edi@1
  20.   fb::StreamingPartitionArrayEntry *currArray; // eax@4
  21.   const void *pArrayStart; // ebx@4
  22.   int count; // edx@4
  23.   fb::DataContainer *pDataContainer; // edi@7
  24.   fb::StreamingPartitionFieldDescriptor *currField; // ecx@11
  25.   unsigned int realType; // eax@11
  26.   int position; // ebx@23
  27.   int realPos; // ebx@33
  28.   int v12; // eax@39
  29.   fb::InternalDatabasePartition *partition; // eax@41
  30.   fb::StreamingPartitionTypeDescriptor *currType_2; // ebx@47
  31.   size_t secondaryInstanceSize; // ST48_4@52
  32.   const void *defaultValue; // eax@52
  33.   int v17; // eax@56
  34.   const unsigned int targetStride; // [sp+8h] [bp-28h]@49
  35.   const unsigned int sourceStride; // [sp+Ch] [bp-24h]@50
  36.   fb::ValueTypeInfo *vti; // [sp+10h] [bp-20h]@49
  37.   const char *sourceInstances; // [sp+14h] [bp-1Ch]@1
  38.   int currIndex; // [sp+18h] [bp-18h]@2
  39.   fb::StreamingPartitionTypeDescriptor *currType_1; // [sp+1Ch] [bp-14h]@4 MAPDST
  40.   int count2; // [sp+1Ch] [bp-14h]@21
  41.   int counter2; // [sp+1Ch] [bp-14h]@51
  42.   unsigned int i; // [sp+20h] [bp-10h]@1
  43.   const char *sourceCursor; // [sp+24h] [bp-Ch]@4
  44.   const unsigned int elementCount; // [sp+28h] [bp-8h]@4
  45.   char elementSize; // [sp+2Fh] [bp-1h]@12
  46.  
  47.   streamReader = this;
  48.   arrayIndex = 0;
  49.   sourceInstances = &this->m_sourceInstanceBlock[this->m_header.arrayOffset];
  50.   i = 0;
  51.   if ( this->m_header.arrayCount )
  52.   {
  53.     currIndex = 0;
  54.     while ( 1 )
  55.     {
  56.       currArray = &streamReader->m_arrayEntries[currIndex];
  57.       pArrayStart = &sourceInstances[currArray->offset];
  58.       count = currArray->elementCount;
  59.       currType_1 = &streamReader->m_typeDescriptors[currArray->typeDescriptorIndex];
  60.       elementCount = currArray->elementCount;
  61.       currType_1 = &streamReader->m_typeDescriptors[currArray->typeDescriptorIndex];
  62.       sourceCursor = &sourceInstances[currArray->offset];
  63.       if ( arrayIndex && arrayIndex >= streamReader->targetArrayOffsets.mpEnd - streamReader->targetArrayOffsets.mpBegin )
  64.       {
  65.         eastl::AssertionFailure("vector::operator[] -- out of range");
  66.         count = elementCount;
  67.         arrayIndex = i;
  68.       }
  69.       pDataContainer = (fb::DataContainer *)&streamReader->m_targetBuffer[streamReader->targetArrayOffsets.mpBegin[arrayIndex]];
  70.       *(_DWORD *)&pDataContainer[-1].m_flags = count;
  71.       if ( currType_1->fieldCount != 1 )
  72.       {
  73.         fb::Log::formattedLog(&stru_39E0FF8, "%s", &secret);
  74.         if ( fb::Log::shouldBreak() )
  75.           __debugbreak();
  76.         count = elementCount;
  77.       }
  78.       currField = &streamReader->m_fieldDescriptors[currType_1->layoutDescriptor];
  79.       realType = ((unsigned int)currField->flags.flagBits >> 4) & 0x1F;
  80.       if ( (signed int)realType < 0xA )
  81.       {
  82.         switch ( realType )
  83.         {
  84.           case 8u:
  85.             memcpy(pDataContainer, pArrayStart, 4 * count);
  86.             break;
  87.           case 3u:
  88.             if ( count )
  89.             {
  90.               count2 = count;
  91.               while ( 1 )
  92.               {
  93.                 position = *(_DWORD *)pArrayStart;
  94.                 if ( streamReader->m_endianSwapRequired )
  95.                   position = _byteswap_ulong(position);
  96.                 if ( position < 0 )
  97.                 {
  98.                   realPos = position & 0x7FFFFFFF;
  99.                   if ( realPos >= (unsigned int)(streamReader->m_imports.mpEnd - streamReader->m_imports.mpBegin) )
  100.                   {
  101.                     fb::Log::formattedLog(
  102.                       &`fb::StreamingPartitionReader::marshalReference'::`28'::location_macro_,
  103.                       "%s",
  104.                       &secret);
  105.                     if ( fb::Log::shouldBreak() )
  106.                       __debugbreak();
  107.                   }
  108.                   if ( realPos
  109.                     && realPos >= (unsigned int)(streamReader->m_imports.mpEnd - streamReader->m_imports.mpBegin) )
  110.                     eastl::AssertionFailure("vector::operator[] -- out of range");
  111.                   v12 = (int)streamReader->m_imports.mpBegin[realPos];
  112.                   if ( v12 )
  113.                   {
  114.                     pDataContainer->vfptr = (fb::ITypedObjectVtbl *)v12;
  115.                   }
  116.                   else
  117.                   {
  118.                     partition = streamReader->m_partition;
  119.                     pDataContainer->vfptr = (fb::ITypedObjectVtbl *)(partition ? (unsigned int)fb::InternalDatabaseDomain::getResolveRecord(
  120.                                                                                                  streamReader->m_domain,
  121.                                                                                                  "nopathavailable",
  122.                                                                                                  &streamReader->m_importEntries[realPos].partitionGuid,
  123.                                                                                                  &streamReader->m_importEntries[realPos].instanceGuid,
  124.                                                                                                  partition->m_name,
  125.                                                                                                  "No instance id available",
  126.                                                                                                  &fb::DataContainer::c_TypeInfo,
  127.                                                                                                  (fb::CtrRefBase *)pDataContainer) | 1 : 0);
  128.                   }
  129.                 }
  130.                 else
  131.                 {
  132.                   if ( position >= (unsigned int)(streamReader->m_containers.mpEnd - streamReader->m_containers.mpBegin) )
  133.                   {
  134.                     fb::Log::formattedLog(
  135.                       &`fb::StreamingPartitionReader::marshalReference'::`15'::location_macro_,
  136.                       "%s",
  137.                       &secret);
  138.                     if ( fb::Log::shouldBreak() )
  139.                       __debugbreak();
  140.                   }
  141.                   if ( position
  142.                     && position >= (unsigned int)(streamReader->m_containers.mpEnd - streamReader->m_containers.mpBegin) )
  143.                     eastl::AssertionFailure("vector::operator[] -- out of range");
  144.                   pDataContainer->vfptr = (fb::ITypedObjectVtbl *)&streamReader->m_containers.mpBegin[position]->vfptr;
  145.                 }
  146.                 sourceCursor += 4;
  147.                 pDataContainer = (fb::DataContainer *)((char *)pDataContainer + 4);
  148.                 --count2;
  149.                 if ( !count2 )
  150.                   break;
  151.                 pArrayStart = sourceCursor;
  152.               }
  153.             }
  154.             break;
  155.           case 2u:
  156.             currType_2 = &streamReader->m_typeDescriptors[currField->fieldType];
  157.             if ( (currType_2->typeFlags.flagBits & 0x4000) == 0x4000 )
  158.             {
  159.               memcpy(pDataContainer, sourceCursor, elementCount * currType_2->instanceSize);
  160.             }
  161.             else
  162.             {
  163.               vti = (fb::ValueTypeInfo *)*eastl::vector<fb::TypeInfo const *,eastl::fixed_vector_allocator<4,16,4,0,1,fb::eastl_arena_allocator>>::operator[](
  164.                                             (eastl::vector<fb::TypeInfo const *,eastl::fixed_vector_allocator<4,16,4,0,1,fb::eastl_arena_allocator> > *)&streamReader->m_typeInfos.mpBegin,
  165.                                             currField->fieldType);
  166.               targetStride = currType_2->secondaryInstanceSize;
  167.               if ( currType_2->secondaryInstanceSize )
  168.               {
  169.                 sourceStride = currType_2->instanceSize;
  170.                 if ( elementCount )
  171.                 {
  172.                   counter2 = elementCount;
  173.                   do
  174.                   {
  175.                     secondaryInstanceSize = currType_2->secondaryInstanceSize;
  176.                     defaultValue = fb::ValueTypeInfo::getDefaultValue(vti);
  177.                     memcpy(pDataContainer, defaultValue, secondaryInstanceSize);
  178.                     fb::StreamingPartitionReader::marshalFields(
  179.                       streamReader,
  180.                       currType_2,
  181.                       sourceCursor,
  182.                       (char *)pDataContainer);
  183.                     sourceCursor += sourceStride;
  184.                     pDataContainer = (fb::DataContainer *)((char *)pDataContainer + targetStride);
  185.                     --counter2;
  186.                   }
  187.                   while ( counter2 );
  188.                 }
  189.               }
  190.             }
  191.             break;
  192.           case 7u:
  193.             for ( ; count; --count )
  194.             {
  195.               v17 = (int)&streamReader->m_targetStringBase[*(_DWORD *)pArrayStart];
  196.               pArrayStart = (char *)pArrayStart + 4;
  197.               pDataContainer->vfptr = (fb::ITypedObjectVtbl *)v17;
  198.               pDataContainer = (fb::DataContainer *)((char *)pDataContainer + 4);
  199.             }
  200.             break;
  201.           default:
  202.             fb::Log::formattedLog(
  203.               &stru_39E0FD0,
  204.               "C:\\monkey\\VeniceOpenBeta.Deploy.Server\\TnT\\Code\\Engine/Core/Serialization/StreamingPartition.cpp(1586) : Function \"%s\" (%s) is not implemented!",
  205.               "fb::StreamingPartitionReader::marshalArrays",
  206.               "C:\\monkey\\VeniceOpenBeta.Deploy.Server\\TnT\\Code\\Engine/Core/Serialization/StreamingPartition.cpp");
  207.             if ( fb::Log::shouldBreak() )
  208.               __debugbreak();
  209.             break;
  210.         }
  211.       }
  212.       else
  213.       {
  214.         elementSize = mapTypeCodeToSize[realType];
  215.         if ( !elementSize )
  216.         {
  217.           fb::Log::formattedLog(&stru_39E0FE4, "%s", &secret);
  218.           if ( fb::Log::shouldBreak() )
  219.             __debugbreak();
  220.           count = elementCount;
  221.         }
  222.         memcpy(pDataContainer, pArrayStart, count * (unsigned __int8)elementSize);
  223.       }
  224.       ++currIndex;
  225.       ++i;
  226.       if ( i >= streamReader->m_header.arrayCount )
  227.         break;
  228.       arrayIndex = i;
  229.     }
  230.   }
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement