Ejemplo n.º 1
0
void BuildCacheCRC()
{
#ifdef ENABLE_DATABLOCK_CACHE
    SimDataBlockGroup* pGroup = Sim::getDataBlockGroup();
    SimDataBlock* pDataBlock = 0;
    const U32 iCount = pGroup->size();
    BitStream* stream = new InfiniteBitStream;
    U32 crc=0;
    for (U32 i = 0; i < iCount; i++)
    {
        pDataBlock = (SimDataBlock*)(*pGroup)[i];
        pDataBlock->packData(stream);
    }
    //U32 crc = CRC::calculateCRCStream(stream); //Stream CRC doesn't seem reliable.

    FileStream* datablocksOut = FileStream::createAndOpen("ServerCRC.dmp", Torque::FS::File::Write );
    if (datablocksOut==NULL)
        Con::errorf("### Datablock Cache: Unable to Build Server Datablock CRC Key File.");
    else
    {
        datablocksOut->writeBitStream(stream);
        datablocksOut->close();
        crc=Con::getFileCRC("ServerCRC.dmp");
        Con::deleteFile("ServerCRC.dmp");
    }
    Con::setVariable("$ServerDatablockCacheCRC", Con::getuIntArg(crc));
    Con::warnf("### Datablock Cache: Server Datablock CRC is %u",crc);

    delete stream;
#endif
}
void SimDataBlockEvent::notifyDelivered(NetConnection *conn, bool )
{
   // if the modified key for this event is not the current one,
   // we've already resorted and resent some blocks, so fall out.
   if(conn->isRemoved())
      return;
   GameConnection *gc = (GameConnection *) conn;
   if(gc->getDataBlockSequence() != mMissionSequence)
      return;

   U32 nextIndex = mIndex + DataBlockQueueCount;
   SimDataBlockGroup *g = Sim::getDataBlockGroup();

   if(mIndex == g->size() - 1)
   {
      gc->setDataBlockModifiedKey(gc->getMaxDataBlockModifiedKey());
      gc->sendConnectionMessage(GameConnection::DataBlocksDone, mMissionSequence);
   }

   if(g->size() <= nextIndex)
      return;

   SimDataBlock *blk = (SimDataBlock *) (*g)[nextIndex];
   gc->postNetEvent(new SimDataBlockEvent(blk, nextIndex, g->size(), mMissionSequence));
}
Ejemplo n.º 3
0
GuiControl* GuiInspectorDatablockField::constructEditControl()
{
   GuiControl* retCtrl = new GuiPopUpMenuCtrl();

   // If we couldn't construct the control, bail!
   if( retCtrl == NULL )
      return retCtrl;

   GuiPopUpMenuCtrl *menu = dynamic_cast<GuiPopUpMenuCtrl*>(retCtrl);

   // Let's make it look pretty.
   retCtrl->setDataField( StringTable->insert("profile"), NULL, "InspectorTypeEnumProfile" );

   menu->setField("text", getData());

   _registerEditControl( retCtrl );

   // Configure it to update our value when the popup is closed
   char szBuffer[512];
   dSprintf( szBuffer, 512, "%d.apply(%d.getText());%d.inspect(%d);",getId(), retCtrl->getId(),mParent->mParent->getId(), mTarget->getId() );
   //dSprintf( szBuffer, 512, "%d.%s = %d.getText();%d.inspect(%d);",mTarget->getId(), getFieldName(), menu->getId(), mParent->mParent->getId(), mTarget->getId() );
   menu->setField("Command", szBuffer );

   Vector<StringTableEntry> entries;

   SimDataBlockGroup * grp = Sim::getDataBlockGroup();
   for(SimDataBlockGroup::iterator i = grp->begin(); i != grp->end(); i++)
   {
      SimDataBlock * datablock = dynamic_cast<SimDataBlock*>(*i);

      // Skip non-datablocks if we somehow encounter them.
      if(!datablock)
         continue;

      // Ok, now we have to figure inheritance info.
      if( datablock && datablock->getClassRep()->isClass(mDesiredClass) )
         entries.push_back(datablock->getName());
   }

   // sort the entries
   dQsort(entries.address(), entries.size(), sizeof(StringTableEntry), stringCompare);

   // add them to our enum
   for(U32 j = 0; j < entries.size(); j++)
      menu->addEntry(entries[j], 0);

   return retCtrl;
}