예제 #1
0
    virtual void endFrame()
    {
        char buffer[ 256 ];

        for( U32 i = 0; i < mRecords.size(); ++ i )
        {
            if( i != 0 )
                mStream.write( 1, "," );

            SampleRecord& record = mRecords[ i ];
            if( record.mSet )
            {
                if( record.mType == TypeBool )
                {
                    if( record.mValue.mBool )
                        mStream.write( 4, "true" );
                    else
                        mStream.write( 5, "false" );
                }
                else if( record.mType == TypeS32 )
                {
                    dSprintf( buffer, sizeof( buffer ), "%d", record.mValue.mS32 );
                    mStream.write( dStrlen( buffer ), buffer );
                }
                else if( record.mType == TypeF32 )
                {
                    dSprintf( buffer, sizeof( buffer ), "%f", record.mValue.mF32 );
                    mStream.write( dStrlen( buffer ), buffer );
                }
                else if( record.mType == TypeString )
                {
                    //FIXME: does not do doubling of double quotes in the string at the moment
                    mStream.write( 1, "\"" );
                    mStream.write( dStrlen( record.mValue.mString ), record.mValue.mString );
                    mStream.write( 1, "\"" );
                }
                else
                    AssertWarn( false, "CSVSamplerBackend::endFrame - bug: invalid sample type" );
            }

            record.clean();
        }

        newline();
    }
예제 #2
0
bool PlatformAssert::process(Type         assertType,
                             const char  *filename,
                             U32          lineNumber,
                             const char  *message)
{
    // If we're somehow recursing, just die.
    if(processing)
        Platform::debugBreak();
    
    processing = true;
    bool ret = false;
    
    // always dump to the Assert to the Console
    if (Con::isActive())
    {
        if (assertType == Warning)
            Con::warnf(ConsoleLogEntry::Assert, "%s(%ld,0): {%s} - %s", filename, lineNumber, typeName[assertType], message);
        else
            Con::errorf(ConsoleLogEntry::Assert, "%s(%ld,0): {%s} - %s", filename, lineNumber, typeName[assertType], message);
    }
    
    // if not a WARNING pop-up a dialog box
    if (assertType != Warning)
    {
        // used for processing navGraphs (an assert won't botch the whole build)
        if(Con::getBoolVariable("$FP::DisableAsserts", false) == true)
            Platform::forceShutdown(1);
        
        char buffer[2048];
        dSprintf(buffer, 2048, "%s: (%s @ %ld)", typeName[assertType], filename, lineNumber);
        if( !ignoreAll )
        {
            // Display message box with Debug, Ignore, Ignore All, and Exit options
            switch( Platform::AlertAssert(buffer, message) )
            {
                case Platform::ALERT_ASSERT_DEBUG:				
                    ret = true;
                    break;
                case Platform::ALERT_ASSERT_IGNORE:
                    ret = false;
                    break;
                case Platform::ALERT_ASSERT_IGNORE_ALL:
                    ignoreAll = true;
                    ret = false;
                    break;
                default:
                case Platform::ALERT_ASSERT_EXIT:
                    Platform::forceShutdown(1);
                    break;
            }
        }
    }
    
    processing = false;
    
    return ret;
}
예제 #3
0
void EditTSCtrl::_renderScene( ObjectRenderInst*, SceneRenderState *state, BaseMatInstance* )
{
   GFXTransformSaver saver;

   // render through console callbacks
   SimSet * missionGroup = static_cast<SimSet*>(Sim::findObject("MissionGroup"));
   if(missionGroup)
   {
      mConsoleRendering = true;

      // [ rene, 27-Jan-10 ] This calls onEditorRender on the server objects instead
      //    of on the client objects which seems a bit questionable to me.
 
      for(SimSetIterator itr(missionGroup); *itr; ++itr)
      {
         SceneObject* object = dynamic_cast< SceneObject* >( *itr );
         if( object && object->isRenderEnabled() && !object->isHidden() )
         {
            char buf[2][16];
            dSprintf(buf[0], 16, object->isSelected() ? "true" : "false");
            dSprintf(buf[1], 16, object->isExpanded() ? "true" : "false");
            
           object->onEditorRender_callback( getIdString(), buf[0], buf[1] );
         }
      }

      mConsoleRendering = false;
   }

   // render the mission area...
   renderMissionArea();

   // Draw the grid
   if ( mRenderGridPlane )
      renderGrid();

   // render the editor stuff
   renderScene(mSaveViewport);

	// Draw the camera axis
   GFX->setClipRect(mSaveViewport);
   GFX->setStateBlock(mDefaultGuiSB);
   renderCameraAxis();
}
예제 #4
0
static void netToIPSocketAddress(const NetAddress *address, struct sockaddr_in *sockAddr)
{
   dMemset(sockAddr, 0, sizeof(struct sockaddr_in));
   sockAddr->sin_family = AF_INET;
   sockAddr->sin_port = htons(address->port);
   char tAddr[20];
   dSprintf(tAddr, 20, "%d.%d.%d.%d", address->netNum[0],  address->netNum[1], address->netNum[2], address->netNum[3]);
   //fprintf(stdout,"netToIPSocketAddress(): %s\n",tAddr);fflush(NULL);
   sockAddr->sin_addr.s_addr = inet_addr(tAddr);
}
const char *SimDataBlockEvent::getDebugName()
{
   SimObject *obj = Sim::findObject(id);
   static char buffer[256];
   dSprintf(buffer, sizeof(buffer), "%s [%s - %s]",
            getClassName(),
            obj ? obj->getName() : "",
            obj ? obj->getClassName() : "NONE");
   return buffer;
}
예제 #6
0
void PixelParamsDefHLSL::print( Stream &stream, bool isVerterShader )
{
   assignConstantNumbers();

   const char * opener = "Fragout main( ConnectData IN";
   stream.write( dStrlen(opener), opener );

   // find all the sampler & uniform variables and print them out
   for( U32 i=0; i<LangElement::elementList.size(); i++)
   {
      Var *var = dynamic_cast<Var*>(LangElement::elementList[i]);
      if( var )
      {
         if( var->uniform )
         {
            WRITESTR( ",\r\n              " );

            U8 varNum[32];

            if( var->sampler )
            {
               //dSprintf( (char*)varNum, sizeof(varNum), ": register(S%d)", var->constNum );
               varNum[0] = NULL;
            }
            else
            {
               dSprintf( (char*)varNum, sizeof(varNum), ": register(C%d)", var->constNum );
            }

            U8 output[256];
            if (var->arraySize <= 1)
               dSprintf( (char*)output, sizeof(output), "uniform %-9s %-15s %s", var->type, var->name, varNum );
            else
               dSprintf( (char*)output, sizeof(output), "uniform %-9s %s[%d] %s", var->type, var->name, var->arraySize, varNum );

            WRITESTR( (char*) output );
         }
      }
   }

   const char *closer = "\r\n)\r\n{\r\n   Fragout OUT;\r\n\r\n";
   stream.write( dStrlen(closer), closer );
}
예제 #7
0
 void script_simobject_setfield_float(U32 objectId, const char* fieldName, F32 v)
 {
    SimObject *object = Sim::findObject( objectId );
    if( object )
    {
       char buf[256];
       dSprintf(buf, 256, "%g", v );
       object->setDataField(fieldName, "", buf);
    }
 }
예제 #8
0
파일: net.cpp 프로젝트: Adhdcrazzy/Torque3D
   const char* RemoteCommandEvent::addTaggedString(const char* str)
	   {
	   NetStringHandle s(str);
	   gNetStringTable->incStringRefScript(s.getIndex());

	   char *ret = Con::getReturnBuffer(10);
	   ret[0] = StringTagPrefixByte;
	   dSprintf(ret + 1, 9, "%d", s.getIndex());
	   return ret;
	   }
예제 #9
0
XftFont *loadFont(const char *name, S32 size, Display *display)
{
  XftFont *fontInfo = NULL;
  char* fontname = const_cast<char*>(name);
  if (dStrlen(fontname)==0)
    fontname = "arial";
  else if (stristr(const_cast<char*>(name), "arial") != NULL)
    fontname = "arial";
  else if (stristr(const_cast<char*>(name), "lucida console") != NULL)
    fontname = "lucida console";

  char* weight = "medium";
  char* slant = "roman"; // no slant

  if (stristr(const_cast<char*>(name), "bold") != NULL)
    weight = "bold";
  if (stristr(const_cast<char*>(name), "italic") != NULL)
    slant = "italic";

  int mSize = size - 2 - (int)((float)size * 0.1);
  char xfontName[512];
  // We specify a lower DPI to get 'correct' looking fonts, if we go with the
  // native DPI the fonts are to big and don't fit the widgets.
  dSprintf(xfontName, 512, "%s-%d:%s:slant=%s:dpi=76", fontname, mSize, weight, slant);

  // Lets see if Xft can get a font for us.
  char xftname[1024];
  fontInfo = XftFontOpenName(display, DefaultScreen(display), xfontName);
  // Cant find a suitabke font, default to a known font (6x10)
  if ( !fontInfo )
    {
  	dSprintf(xfontName, 512, "6x10-%d:%s:slant=%s:dpi=76", mSize, weight, slant);
      fontInfo = XftFontOpenName(display, DefaultScreen(display), xfontName);
    }
      XftNameUnparse(fontInfo->pattern, xftname, 1024);

#ifdef DEBUG
      Con::printf("Font '%s %d' mapped to '%s'\n", name, size, xftname);
#endif

  return fontInfo;
}
예제 #10
0
static bool isMainDotCsPresent(char *dir)
{ 
   char maincsbuf[MAX_MAC_PATH_LONG];
   const char *maincsname = "/main.cs";
   const U32 len = dStrlen(dir) + dStrlen(maincsname)+1;
   AssertISV(len < MAX_MAC_PATH_LONG, "Sorry, path is too long, I can't run from this folder.");
   
   dSprintf(maincsbuf,MAX_MAC_PATH_LONG,"%s%s", dir, maincsname);
   
   return Platform::isFile(maincsbuf);
}
예제 #11
0
 void script_simobject_setfield_int(U32 objectId, const char* fieldName, S32 v)
 {
    SimObject *object = Sim::findObject( objectId );
    if( object )
    {
       // this seems pretty lame, though it is how it is handled in consoleType.cpp
       char buf[256];
       dSprintf(buf, 256, "%d", v );
       object->setDataField(fieldName, "", buf);
    }
 }
 bool Platform::hasSubDirectory(const char *pPath)
 {
   if (!pPath)
     return false;

   struct dirent *d;
   DIR           *dip;
   dip = opendir(pPath);
   if (dip == NULL)
     return false;

   while (d = readdir(dip))
     {
	bool isDir = false;
	if (d->d_type == DT_UNKNOWN)
	{
		char child [1024];
		if ((pPath[dStrlen(pPath) - 1] == '/'))
			dSprintf(child, 1024, "%s%s", pPath, d->d_name);
		else
			dSprintf(child, 1024, "%s/%s", pPath, d->d_name);
		isDir = Platform::isDirectory (child);
	}
	else if (d->d_type & DT_DIR)
		isDir = true;
	  	if( isDir )
	  	{
 	  	// Skip the . and .. directories
 	  	if (dStrcmp(d->d_name, ".") == 0 ||dStrcmp(d->d_name, "..") == 0)
 		    continue;
 		if (Platform::isExcludedDirectory(d->d_name))
 		    continue;
 		  Platform::clearExcludedDirectories();
 		  closedir(dip);
 		  return true;
 	}
     }
   closedir(dip);
   Platform::clearExcludedDirectories();
   return false;
 }
예제 #13
0
bool GuiGradientSwatchCtrl::onWake()
{
	if ( !Parent::onWake() )
      return false;
	
	static const U32 bufSize = 512;
	char* altCommand = Con::getReturnBuffer(bufSize);
	dSprintf( altCommand, bufSize, "%s(%i.color, \"%i.setColor\");", mColorFunction, getId(), getId() );
	setField( "altCommand", altCommand );

	return true;
}
예제 #14
0
bool CIniFile::SetAllValues(const string &section, const string &prefix, const Vector<string> &values)
{
   char key[256];
   bool stat = true;
   for(S32 i = 0; i < values.size(); i++)
   {
      dSprintf(key, 255, "%s%d", prefix.c_str(), i);
      stat &= SetValue(section, key, values[i], true);
   }

   return stat;      // true if all worked, false if any failed
}
예제 #15
0
//-------------------------------------------------------------
//------------------------------ 时间格式化(YYYY-MM-DD HH:MM:SS)
pc_str	time_format		(uint64 _time)
{
	tm	tmTime;
	memset(&tmTime,0,sizeof(tmTime));
	if(getLocalTime(&tmTime,_time) != 0)
		return "";

	static char szDate[32] = {0};
	dSprintf(szDate,sizeof(szDate),"%.4d-%.2d-%.2d %.2d:%.2d:%.2d",tmTime.tm_year + 1900,tmTime.tm_mon + 1,tmTime.tm_mday,tmTime.tm_hour,tmTime.tm_min,tmTime.tm_sec);

	return szDate;
}
예제 #16
0
void PostEffectVis::_setDefaultCaption( VisWindow &vis, U32 texIndex )
{
   PostEffect *pfx = vis.pfx;
   GuiWindowCtrl *winCtrl = vis.window[texIndex];
   
   if ( texIndex == Target )
   {
      char caption[256];           
      char name[256];

      if ( pfx->getName() == NULL || dStrlen( pfx->getName() ) == 0 )
         dSprintf( name, 256, "(none)" );
      else
         dSprintf( name, 256, "%s", pfx->getName() );

      dSprintf( caption, 256, "%s[%i] target [NOT ENABLED]", name, pfx->getId() );

      winCtrl->setDataField( StringTable->insert("text"), NULL, caption );
   }
   else
   {
      char caption[256];            
      char name[256];

      if ( pfx->getName() == NULL || dStrlen( pfx->getName() ) == 0 )
         dSprintf( name, 256, "(none)" );
      else
         dSprintf( name, 256, "%s", pfx->getName() );

      dSprintf( caption, 256, "%s[%i] input%i - %s [NOT ENABLED]", name, pfx->getId(), texIndex-1, pfx->mTexFilename[texIndex-1].c_str() );

      winCtrl->setDataField( StringTable->insert("text"), NULL, caption );
   }
}
예제 #17
0
//--------------------------------------------------------------------------
void Projectile::onCollision(const Point3F& hitPosition, const Point3F& hitNormal, SceneObject* hitObject)
{
   // No client specific code should be placed or branched from this function
   if(isClientObject())
      return;

   if (hitObject != NULL && isServerObject())
   {
      char *posArg = Con::getArgBuffer(64);
      char *normalArg = Con::getArgBuffer(64);

      dSprintf(posArg, 64, "%g %g %g", hitPosition.x, hitPosition.y, hitPosition.z);
      dSprintf(normalArg, 64, "%g %g %g", hitNormal.x, hitNormal.y, hitNormal.z);

      Con::executef(mDataBlock, "onCollision",
         scriptThis(),
         Con::getIntArg(hitObject->getId()),
         Con::getFloatArg(mFadeValue),
         posArg,
         normalArg);
   }
}
void SimDataBlock::write(Stream &stream, U32 tabStop, U32 flags)
{
   // Only output selected objects if they want that.
   if((flags & SelectedOnly) && !isSelected())
      return;

   stream.writeTabs(tabStop);
   char buffer[1024];

   // Client side datablocks are created with 'new' while
   // regular server datablocks use the 'datablock' keyword.
   if ( isClientOnly() )
      dSprintf(buffer, sizeof(buffer), "new %s(%s) {\r\n", getClassName(), getName() ? getName() : "");
   else
      dSprintf(buffer, sizeof(buffer), "datablock %s(%s) {\r\n", getClassName(), getName() ? getName() : "");

   stream.write(dStrlen(buffer), buffer);
   writeFields(stream, tabStop + 1);

   stream.writeTabs(tabStop);
   stream.write(4, "};\r\n");
}
예제 #19
0
string HttpRequest::buildRequest()
{
   // location is anything that comes after the first '/'
   TNL::U32 index = mUrl.find('/');
   string location = mUrl.substr(index, mUrl.length() - index);

   // request line
   mRequest = mMethod + " " + location + " HTTP/1.0";

   // content type and data encoding for POST requests
   if(mMethod == PostMethod)
   {
      stringstream encodedData("");
      for(map<string, string>::iterator it = mData.begin(); it != mData.end(); it++)
      {
         encodedData << "--" + HttpRequestBoundary + "\r\n";
         encodedData << "Content-Disposition: form-data; name=\"" + (*it).first + "\"\r\n\r\n";
         encodedData << (*it).second + "\r\n";
      }

      for(list<HttpRequestFileInfo>::iterator it = mFiles.begin(); it != mFiles.end(); it++)
      {
         stringstream fileData;
         fileData.write((const char*) (*it).data, (*it).length);

         encodedData << "--" + HttpRequestBoundary + "\r\n";
         encodedData << "Content-Disposition: form-data; name=\"" + (*it).fieldName + "\"; filename=\"" + (*it).fileName + "\"\r\n";
         encodedData << "Content-Type: image/png\r\n";
         encodedData << "Content-Transfer-Encoding: binary\r\n\r\n";
         encodedData << fileData.str();
         encodedData << "\r\n";
      }

      encodedData << "--" + HttpRequestBoundary + "\r\n";

      char contentLengthHeaderBuffer[1024] = { 0 };
      dSprintf(contentLengthHeaderBuffer, 1024, "\r\nContent-Length: %d", (U32) encodedData.tellp());

      mRequest += contentLengthHeaderBuffer;
      mRequest += "\r\nUser-Agent: Bitfighter";
      mRequest += "\r\nContent-Type: multipart/form-data, boundary=" + HttpRequestBoundary;
      mRequest += "\r\n\r\n";
      mRequest += encodedData.str();
   }
   else
   {
      mRequest += "\r\n\r\n";
   }

   return mRequest;
}
예제 #20
0
void SFXALProvider::init()
{
   if( LoadOAL10Library( NULL, &mOpenAL ) != AL_TRUE )
   {
      Con::printf( "SFXALProvider - OpenAL not available." );
      return;
   }
   mALDL = new ALDeviceList( mOpenAL );

   // Did we get any devices?
   if ( mALDL->GetNumDevices() < 1 )
   {
      Con::printf( "SFXALProvider - No valid devices found!" );
      return;
   }

   // Cool, loop through them, and caps em
   const char *deviceFormat = "OpenAL v%d.%d %s";

   char temp[256];
   for( S32 i = 0; i < mALDL->GetNumDevices(); i++ )
   {
      ALDeviceInfo* info = new ALDeviceInfo;
      
      info->name = String( mALDL->GetDeviceName( i ) );

      S32 major, minor, eax = 0;

      mALDL->GetDeviceVersion( i, &major, &minor );

      // Apologies for the blatent enum hack -patw
      for( S32 j = SFXALEAX2; j < SFXALEAXRAM; j++ )
         eax += (int)mALDL->IsExtensionSupported( i, (SFXALCaps)j );

      if( eax > 0 )
      {
         eax += 2; // EAX support starts at 2.0
         dSprintf( temp, sizeof( temp ), "[EAX %d.0] %s", eax, ( mALDL->IsExtensionSupported( i, SFXALEAXRAM ) ? "EAX-RAM" : "" ) );
      }
      else
         dStrcpy( temp, "" );

      info->driver = String::ToString( deviceFormat, major, minor, temp );
      info->hasHardware = eax > 0;
      info->maxBuffers = mALDL->GetMaxNumSources( i );

      mDeviceInfo.push_back( info );
   }

   regProvider( this );
}
예제 #21
0
bool TurretShapeData::preload(bool server, String &errorStr)
{
   if (!Parent::preload(server, errorStr))
      return false;

   // We have mShape at this point.  Resolve nodes.
   headingNode = mShape->findNode("heading");
   pitchNode = mShape->findNode("pitch");

   // Find any mirror pitch nodes
   for (U32 i = 0; i < NumMirrorDirectionNodes; ++i)
   {
      char name[32];
      dSprintf(name, 31, "pitch%d", i+1);
      pitchNodes[i] = mShape->findNode(name);

      dSprintf(name, 31, "heading%d", i+1);
      headingNodes[i] = mShape->findNode(name);
   }

   // Resolve weapon mount point node indexes
   for (U32 i = 0; i < ShapeBase::MaxMountedImages; i++) {
      char fullName[256];
      dSprintf(fullName,sizeof(fullName),"weaponMount%d",i);
      weaponMountNode[i] = mShape->findNode(fullName);
   }

   // Recoil animations
   recoilSequence[0] = mShape->findSequence("light_recoil");
   recoilSequence[1] = mShape->findSequence("medium_recoil");
   recoilSequence[2] = mShape->findSequence("heavy_recoil");

   // Optional sequences used when the turret rotates
   pitchSequence = mShape->findSequence("pitch");
   headingSequence = mShape->findSequence("heading");

   return true;
}
예제 #22
0
//---------------------------------------------------------------------------
void GameTSCtrl::makeScriptCall(const char *func, const GuiEvent &evt) const
{
   // write screen position
   char *sp = Con::getArgBuffer(32);
   dSprintf(sp, 32, "%d %d", evt.mousePoint.x, evt.mousePoint.y);

   // write world position
   char *wp = Con::getArgBuffer(32);
   Point3F camPos;
   mLastCameraQuery.cameraMatrix.getColumn(3, &camPos);
   dSprintf(wp, 32, "%g %g %g", camPos.x, camPos.y, camPos.z);

   // write click vector
   char *vec = Con::getArgBuffer(32);
   Point3F fp(evt.mousePoint.x, evt.mousePoint.y, 1.0);
   Point3F ray;
   unproject(fp, &ray);
   ray -= camPos;
   ray.normalizeSafe();
   dSprintf(vec, 32, "%g %g %g", ray.x, ray.y, ray.z);

   Con::executef( (SimObject*)this, func, sp, wp, vec );
}
예제 #23
0
MainMenuUserInterface::MainMenuUserInterface()
{
   dSprintf(titleBuffer, sizeof(titleBuffer), "%s:", ZAP_GAME_STRING);
   menuTitle = titleBuffer;
   motd[0] = 0;
   menuSubTitle = "A TORQUE NETWORK LIBRARY GAME - WWW.OPENTNL.ORG";
   menuFooter = "(C) 2004 GARAGEGAMES.COM, INC.";

   menuItems.push_back(MenuItem("JOIN LAN/INTERNET GAME", 0));
   menuItems.push_back(MenuItem("HOST GAME",1));
   menuItems.push_back(MenuItem("INSTRUCTIONS",2));
   menuItems.push_back(MenuItem("OPTIONS",3));
   menuItems.push_back(MenuItem("QUIT",4));
}
예제 #24
0
void OculusVRSensorDevice::buildCodeTable()
{
    // Obtain all of the device codes
    for(U32 i=0; i<OculusVRConstants::MaxSensors; ++i)
    {
        OVR_SENSORROT[i] = INPUTMGR->getNextDeviceCode();

        OVR_SENSORROTANG[i] = INPUTMGR->getNextDeviceCode();

        OVR_SENSORROTAXISX[i] = INPUTMGR->getNextDeviceCode();
        OVR_SENSORROTAXISY[i] = INPUTMGR->getNextDeviceCode();

        OVR_SENSORACCELERATION[i] = INPUTMGR->getNextDeviceCode();
        OVR_SENSORANGVEL[i] = INPUTMGR->getNextDeviceCode();
        OVR_SENSORMAGNETOMETER[i] = INPUTMGR->getNextDeviceCode();

        OVR_SENSORPOSITION[i] = INPUTMGR->getNextDeviceCode();
    }

    // Build out the virtual map
    char buffer[64];
    for(U32 i=0; i<OculusVRConstants::MaxSensors; ++i)
    {
        dSprintf(buffer, 64, "ovr_sensorrot%d", i);
        INPUTMGR->addVirtualMap( buffer, SI_ROT, OVR_SENSORROT[i] );

        dSprintf(buffer, 64, "ovr_sensorrotang%d", i);
        INPUTMGR->addVirtualMap( buffer, SI_POS, OVR_SENSORROTANG[i] );

        dSprintf(buffer, 64, "ovr_sensorrotaxisx%d", i);
        INPUTMGR->addVirtualMap( buffer, SI_AXIS, OVR_SENSORROTAXISX[i] );
        dSprintf(buffer, 64, "ovr_sensorrotaxisy%d", i);
        INPUTMGR->addVirtualMap( buffer, SI_AXIS, OVR_SENSORROTAXISY[i] );

        dSprintf(buffer, 64, "ovr_sensoracceleration%d", i);
        INPUTMGR->addVirtualMap( buffer, SI_POS, OVR_SENSORACCELERATION[i] );

        dSprintf(buffer, 64, "ovr_sensorangvel%d", i);
        INPUTMGR->addVirtualMap( buffer, SI_POS, OVR_SENSORANGVEL[i] );

        dSprintf(buffer, 64, "ovr_sensormagnetometer%d", i);
        INPUTMGR->addVirtualMap( buffer, SI_POS, OVR_SENSORMAGNETOMETER[i] );

        dSprintf(buffer, 64, "ovr_sensorpos%d", i);
        INPUTMGR->addVirtualMap( buffer, SI_POS, OVR_SENSORPOSITION[i] );
    }
}
예제 #25
0
파일: net.cpp 프로젝트: Adhdcrazzy/Torque3D
   void RemoteCommandEvent::process(NetConnection *conn)
   {
      static char idBuf[10];

      // de-tag the command name

      for(S32 i = mArgc - 1; i >= 0; i--)
      {
         char *arg = mArgv[i+1];
         if(*arg == StringTagPrefixByte)
         {
            // it's a tag:
            U32 localTag = dAtoi(arg + 1);
            NetStringHandle tag = conn->translateRemoteStringId(localTag);
            NetStringTable::expandString( tag,
                                          mBuf,
                                          sizeof(mBuf),
                                          (mArgc - 1) - i,
                                          (const char**)(mArgv + i + 2) );
            dFree(mArgv[i+1]);
            mArgv[i+1] = dStrdup(mBuf);
         }
      }
      const char *rmtCommandName = dStrchr(mArgv[1], ' ') + 1;
      if(conn->isConnectionToServer())
      {
         dStrcpy(mBuf, "clientCmd");
         dStrcat(mBuf, rmtCommandName);

         char *temp = mArgv[1];
         mArgv[1] = mBuf;

         Con::execute(mArgc, (const char **) mArgv+1);
         mArgv[1] = temp;
      }
      else
      {
         dStrcpy(mBuf, "serverCmd");
         dStrcat(mBuf, rmtCommandName);
         char *temp = mArgv[1];

         dSprintf(idBuf, sizeof(idBuf), "%d", conn->getId());
         mArgv[0] = mBuf;
         mArgv[1] = idBuf;

         Con::execute(mArgc+1, (const char **) mArgv);
         mArgv[1] = temp;
      }
   }
예제 #26
0
String ZipObject::getFileEntry(S32 idx)
{
   if(mZipArchive == NULL)
      return "";

   const Zip::CentralDir &dir = (*mZipArchive)[idx];
   char buffer[1024];
   int chars = dSprintf(buffer, sizeof(buffer), "%s\t%d\t%d\t%d\t%08x",
            dir.mFilename.c_str(), dir.mUncompressedSize, dir.mCompressedSize,
            dir.mCompressMethod, dir.mCRC32);
   if (chars < sizeof(buffer))
      buffer[chars] = 0;

   return String(buffer);
}
예제 #27
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;
}
예제 #28
0
void ProjectileData::initPersistFields()
{
   addNamedField(particleEmitter,  TypeParticleEmitterDataPtr, ProjectileData);
   addNamedField(particleWaterEmitter, TypeParticleEmitterDataPtr, ProjectileData);

   addNamedField(projectileShapeName, TypeFilename, ProjectileData);
   addNamedField(scale, TypePoint3F, ProjectileData);

   addNamedField(sound, TypeSFXProfilePtr, ProjectileData);

   addNamedField(explosion, TypeExplosionDataPtr, ProjectileData);
   addNamedField(waterExplosion, TypeExplosionDataPtr, ProjectileData);

   addNamedField(splash, TypeSplashDataPtr, ProjectileData);

   addNamedField(decal, TypeDecalDataPtr, ProjectileData);

   addNamedField(lightDesc, TypeLightDescriptionPtr, ProjectileData );

   static FRangeValidator lightRadiusValidator( 1, 20 );
   static FRangeValidator velInheritFactorValidator( 0, 1 );
   static FRangeValidator muzzleVelocityValidator( 0, 10000 );

   addNamedField(isBallistic, TypeBool, ProjectileData);
	addNamedFieldV(velInheritFactor, TypeF32, ProjectileData, &velInheritFactorValidator );
   addNamedFieldV(muzzleVelocity, TypeF32, ProjectileData, &muzzleVelocityValidator );
   addNamedField(impactForce, TypeF32, ProjectileData);

   static IRangeValidatorScaled lifetimeValidator( TickMs, 0, Projectile::MaxLivingTicks );
   static IRangeValidatorScaled armingDelayValidator( TickMs, 0, Projectile::MaxLivingTicks );
   static IRangeValidatorScaled fadeDelayValidator( TickMs, 0, Projectile::MaxLivingTicks );

   char message[1024];
   dSprintf(message, sizeof(message), "Milliseconds, values will be adjusted to fit %d millisecond tick intervals", TickMs);
   addProtectedField("lifetime", TypeS32, Offset(lifetime, ProjectileData), &setLifetime, &getScaledValue, message);
   addProtectedField("armingDelay", TypeS32, Offset(armingDelay, ProjectileData), &setArmingDelay, &getScaledValue, message);
   addProtectedField("fadeDelay", TypeS32, Offset(fadeDelay, ProjectileData), &setFadeDelay, &getScaledValue, message);

   static FRangeValidator bounceElasticityValidator( 0, 0.999f );
   static FRangeValidator bounceFrictionValidator( 0, 1 );
   static FRangeValidator gravityModValidator( 0, 1 );

   addNamedFieldV(bounceElasticity, TypeF32, ProjectileData, &bounceElasticityValidator );
   addNamedFieldV(bounceFriction, TypeF32, ProjectileData, &bounceFrictionValidator );
   addNamedFieldV(gravityMod, TypeF32, ProjectileData, &gravityModValidator );

   Parent::initPersistFields();
}
예제 #29
0
void ScatterSkyComponent::generateSkyCubeBegin()
{
   // Initialize temporary buffers to use to generate sky cube.
   for (U32 side = 0; side < 6; ++side)
   {
      char viewName[64];
      dSprintf(viewName, 64, "GenerateSkyCubeSide%d", side);

      mTempSkyCubeView[side] = Torque::Graphics.getTemporaryView(Torque::StringTableLink->insert(viewName), 350, NULL);
      bgfx::Attachment fbAttachment;
      fbAttachment.handle = mTexture;
      fbAttachment.layer = side;
      fbAttachment.mip = 0;
      mTempSkyCubeBuffers[side] = Torque::bgfx.createFrameBufferA(1, &fbAttachment, false);
   }
}
예제 #30
0
//-----------------------------------------------------------------------------
bool Platform::createPath(const char *file)
{
   //<Mat> needless console noise
   //Con::warnf("creating path %s",file);
   // if the path exists, we're done.
   struct stat statData;
   if( stat(file, &statData) == 0 )
   {
	  return true;               // exists, rejoice.
   }

   // get the parent path.
   // we're not using basename because it's not thread safe.
   const U32 len = dStrlen(file) + 1;
   char parent[len];
   bool isDirPath = false;

   dSprintf(parent, len, "%s", file);

   if(parent[len - 2] == '/')
   {
	  parent[len - 2] = '\0';    // cut off the trailing slash, if there is one
	  isDirPath = true;          // we got a trailing slash, so file is a directory.
   }

   // recusively create the parent path.
   // only recurse if newpath has a slash that isn't a leading slash.
   char *slash = dStrrchr(parent,'/');
   if( slash && slash != parent)
   {
	  // snip the path just after the last slash.
	  slash[1] = '\0';
	  // recusively create the parent path. fail if parent path creation failed.
	  if(!Platform::createPath(parent))
		 return false;
   }

   // create *file if it is a directory path.
   if(isDirPath)
   {
	  // try to create the directory
	  if( mkdir(file, 0777) != 0) // app may reside in global apps dir, and so must be writable to all.
		 return false;
   }

   return true;
}