String ConsoleObject::_getLogMessage(const char* fmt, va_list args) const
{
   String objClass = "UnknownClass";
   if(getClassRep())
      objClass = getClassRep()->getClassName();
   
   String formattedMessage = String::VToString(fmt, args);
   return String::ToString("%s - Object at %x - %s", 
      objClass.c_str(), this, formattedMessage.c_str());
}
Exemple #2
0
bool Forest::onAdd()
{
   if (!Parent::onAdd())
      return false;

   const char *name = getName();
   if(name && name[0] && getClassRep())
   {
      Namespace *parent = getClassRep()->getNameSpace();
      Con::linkNamespaces(parent->mName, name);
      mNameSpace = Con::lookupNamespace(name);
   }

   setGlobalBounds();
   resetWorldBox();

   // TODO: Make sure this calls the script "onAdd" which will
   // populate the object with forest entries before creation.
   addToScene();

   // If we don't have a file name and the editor is 
   // enabled then create an empty forest data file.
   if ( isServerObject() && ( !mDataFileName || !mDataFileName[0] ) )
      createNewFile();
   else
   {
      // Try to load the forest file.
      mData = ResourceManager::get().load( mDataFileName );
      if ( !mData )
      {
         if ( isClientObject() )
            NetConnection::setLastError( "You are missing a file needed to play this mission: %s", mDataFileName );

         return false;
      }
   }

   updateCollision();

   smCreatedSignal.trigger( this );

   if ( isClientObject() )
   {
      mZoningDirty = true;
      SceneZoneSpaceManager::getZoningChangedSignal().notify( this, &Forest::_onZoningChanged );

      ForestWindMgr::getAdvanceSignal().notify( this, &Forest::getLocalWindTrees );
   }

   return true;
}
bool EditManager::onAdd()
{
   if(!Parent::onAdd())
      return(false);

   // hook the namespace
   const char * name = getName();
   if(name && name[0] && getClassRep())
   {
      Namespace * parent = getClassRep()->getNameSpace();
      Con::linkNamespaces(parent->mName, name);
      mNameSpace = Con::lookupNamespace(name);
   }

   return(true);
}
bool TCPObject::onAdd()
{
   if(!Parent::onAdd())
      return false;

   const char *name = getName();

   if(name && name[0] && getClassRep())
   {
      Namespace *parent = getClassRep()->getNameSpace();
      Con::linkNamespaces(parent->mName, name);
      mNameSpace = Con::lookupNamespace(name);

   }

   Sim::getTCPGroup()->addObject(this);

   return true;
}
bool SimObject::writeObject(Stream *stream)
{
   stream->writeString(getName() ? getName() : "");

   // Static fields
   AbstractClassRep *rep = getClassRep();
   AbstractClassRep::FieldList &fieldList = rep->mFieldList;
   AbstractClassRep::FieldList::iterator itr;
   
   U32 savePos = stream->getPosition();
   U32 numFields = fieldList.size();
   stream->write(numFields);

   for(itr = fieldList.begin();itr != fieldList.end();itr++)
   {
      if( itr->type >= AbstractClassRep::ARCFirstCustomField )
      {
         numFields--;
         continue;
      }

      const char *field = getDataField(itr->pFieldname, NULL);
      if(field == NULL)
         field = "";

      stream->writeString(itr->pFieldname);
      stream->writeString(field);
   }

   // Dynamic Fields
   if(mCanSaveFieldDictionary)
   {
      SimFieldDictionary * fieldDictionary = getFieldDictionary();
      for(SimFieldDictionaryIterator ditr(fieldDictionary); *ditr; ++ditr)
      {
         SimFieldDictionary::Entry * entry = (*ditr);

         stream->writeString(entry->slotName);
         stream->writeString(entry->value);
         numFields++;
      }
   }

   // Overwrite the number of fields with the correct value
   U32 savePos2 = stream->getPosition();
   stream->setPosition(savePos);
   stream->write(numFields);
   stream->setPosition(savePos2);

   return true;
}
bool SceneObject::isSelectionEnabled() const
{
   AbstractClassRep *classRep = getClassRep();
   return ( mObjectFlags.test( SelectionEnabledFlag ) && classRep->isSelectionEnabled() );
}