Пример #1
0
int CShrapnelManager::Update (CObject* objP)
{
if ((objP->LifeLeft () <= 0) || !m_data.buffer [objP->Index ()].Update ())
	Destroy (objP);
return 0;
}
Пример #2
0
void
TopCanvas::Create(PixelSize new_size,
                  bool full_screen, bool resizable)
{
#ifdef USE_FB
  assert(fd < 0);

#ifdef USE_TTY
  InitialiseTTY();
#endif

  const char *path = "/dev/fb0";
  fd = open(path, O_RDWR | O_NOCTTY | O_CLOEXEC);
  if (fd < 0) {
    fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
    return;
  }

  struct fb_fix_screeninfo finfo;
  if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
    fprintf(stderr, "FBIOGET_FSCREENINFO failed: %s\n", strerror(errno));
    Destroy();
    return;
  }

  if (finfo.type != FB_TYPE_PACKED_PIXELS) {
    fprintf(stderr, "Unsupported console hardware\n");
    Destroy();
    return;
  }

  switch (finfo.visual) {
  case FB_VISUAL_TRUECOLOR:
  case FB_VISUAL_PSEUDOCOLOR:
  case FB_VISUAL_STATIC_PSEUDOCOLOR:
  case FB_VISUAL_DIRECTCOLOR:
    break;

  default:
    fprintf(stderr, "Unsupported console hardware\n");
    Destroy();
    return;
  }

  /* Memory map the device, compensating for buggy PPC mmap() */
  const off_t page_size = getpagesize();
  off_t offset = off_t(finfo.smem_start)
    - (off_t(finfo.smem_start) &~ (page_size - 1));
  off_t map_size = finfo.smem_len + offset;

  map = mmap(nullptr, map_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  if (map == (void *)-1) {
    fprintf(stderr, "Unable to memory map the video hardware: %s\n",
            strerror(errno));
    map = nullptr;
    Destroy();
    return;
  }

  /* Determine the current screen depth */
  struct fb_var_screeninfo vinfo;
  if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
    fprintf(stderr, "Couldn't get console pixel format: %s\n",
            strerror(errno));
    Destroy();
    return;
  }

#ifdef GREYSCALE
  /* switch the frame buffer to 8 bits per pixel greyscale */

  vinfo.bits_per_pixel = 8;
  vinfo.grayscale = true;

  if (ioctl(fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) {
    fprintf(stderr, "Couldn't set greyscale pixel format: %s\n",
            strerror(errno));
    Destroy();
    return;
  }

  /* read new finfo */
  ioctl(fd, FBIOGET_FSCREENINFO, &finfo);

  map_bpp = 1;
#else
  map_bpp = vinfo.bits_per_pixel / 8;
  if (map_bpp != 2 && map_bpp != 4) {
    fprintf(stderr, "Unsupported console hardware\n");
    Destroy();
    return;
  }
#endif

  map_pitch = finfo.line_length;
  epd_update_marker = 0;

#ifdef KOBO
  ioctl(fd, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE_AND_MERGE);
#endif

  new_size = ::GetSize(vinfo);
#elif defined(USE_VFB)
  /* allocate buffer as requested by caller */
#else
#error No implementation
#endif

  buffer.Allocate(new_size.cx, new_size.cy);
}
Пример #3
0
Application::~Application()
{
  Destroy ();
}
Пример #4
0
void AProjectile::TimerExpired()
{
	Destroy();
}
Пример #5
0
void test ()
{	
	BinarySort * tree = Init(10);
	
	uint64_t* nombresPremiers1 = ( uint64_t* ) malloc( sizeof( uint64_t ) * 64 );
	nombresPremiers1[0] = 2;
	nombresPremiers1[1] = 3;
	nombresPremiers1[2] = 5;
	Decomposition *dec1 = (Decomposition*) malloc (sizeof(Decomposition));
	dec1 -> value = 30;
	dec1 -> tabSize = 3;
	dec1 -> primeNumbers = nombresPremiers1;
	
	uint64_t* nombresPremiers2 = ( uint64_t* ) malloc( sizeof( uint64_t ) * 64 );
	nombresPremiers2[0] = 2;
	nombresPremiers2[1] = 2;
	nombresPremiers2[2] = 7;
	Decomposition *dec2 = (Decomposition*) malloc (sizeof(Decomposition));
	dec2 -> value = 28;
	dec2 -> tabSize = 3;
	dec2 -> primeNumbers = nombresPremiers2;
	
	uint64_t* nombresPremiers5 = ( uint64_t* ) malloc( sizeof( uint64_t ) * 64 );
	nombresPremiers5[0] = 29;
	Decomposition *dec5 = (Decomposition*) malloc (sizeof(Decomposition));
	dec5 -> value = 29;
	dec5 -> tabSize = 1;
	dec5 -> primeNumbers = nombresPremiers5;
	
	uint64_t* nombresPremiers3 = ( uint64_t* ) malloc( sizeof( uint64_t ) * 64 );
	nombresPremiers3[0] = 3;
	nombresPremiers3[1] = 3;
	nombresPremiers3[2] = 11;
	Decomposition *dec3 = (Decomposition*) malloc (sizeof(Decomposition));
	dec3 -> value = 99;
	dec3 -> tabSize = 3;
	dec3 -> primeNumbers = nombresPremiers3;
	
	uint64_t* nombresPremiers4 = ( uint64_t* ) malloc( sizeof( uint64_t ) * 64 );
	nombresPremiers4[0] = 2;
	nombresPremiers4[1] = 2;
	Decomposition *dec4 = (Decomposition*) malloc (sizeof(Decomposition));
	dec4 -> value = 4;
	dec4 -> tabSize = 2;
	dec4 -> primeNumbers = nombresPremiers4;
	
	InsertValue(tree,dec1);
	InsertValue(tree,dec4);
	InsertValue(tree,dec2);
	InsertValue(tree,dec5);
	InsertValue(tree,dec3);

	printf("%d\r\n", tree->filled);

	int indiceTab=0;
	int compteurValeur=0;
	int j;
	while ( compteurValeur < tree->filled )
	{	if (tree->array[indiceTab] != NULL)
		{	printf( "indice : " );
			printf( "%d\r\n" , indiceTab );
			printf( "%ju\r\n" , tree->array[indiceTab]->value);
			for ( j = 0 ; j < tree -> array[indiceTab] -> tabSize ; j++ )
			{	
				printf( "%ju\r\n" , tree -> array[indiceTab] -> primeNumbers[j] );
			}
		 	compteurValeur++;
		}
	 	indiceTab++;
	}


	Destroy (tree);


	
}
Пример #6
0
apoAttrCalcHelper::apoAttrCalcHelper()
{

	m_current_parse = 0;
	Destroy();
}
Пример #7
0
void gConfigDialog::OnCancel(wxCommandEvent &event)
{
    EndModal(wxID_CANCEL);
    Destroy();
}
Пример #8
0
COptionDialog::~COptionDialog()
{
	Destroy();
}
Пример #9
0
BOOL CNetFile::Download(LPCTSTR pUrl, LPCTSTR pLocal, BOOL bCloseFileAfterDownload, HWND hWndParent)
{_STT();
	// Lose previous file
	Destroy();

	// Downloading
	m_bUpload = FALSE;

	// Save parent window
	m_hWndParent = hWndParent;

	// Save close file status
	m_bCloseFileAfterDownload = bCloseFileAfterDownload;

	// Sanity check
	if ( pUrl == NULL || *pUrl == NULL ) return FALSE;

	// Are we downloading to file or ram?
	m_bMem = ( pLocal == NULL );

	{ // Copy the url
		
		char buf[ sizeof( m_szUrl ) ];
		DWORD size = sizeof( m_szUrl ) - 1;

		// Is it a local file?
		if ( GetFileAttributes( pUrl ) == MAXDWORD )
		{
			// Fix the url
			if ( InternetCanonicalizeUrl( pUrl, buf, &size, 0 ) )
			{	strcpy_sz( m_szUrl, buf ); }

			// Copy the url name
			else strcpy_sz( m_szUrl, pUrl );
		} // end if
		
		// Copy the local file name
		else strcpy_sz( m_szUrl, pUrl );

	} // end copy url	

	// Is it a local file?
	if ( GetFileAttributes( m_szUrl ) != MAXDWORD )
	{
		CWinFile	file;

		if ( file.OpenExisting( m_szUrl, GENERIC_READ ) )
		{
			DWORD size = file.Size();

			if ( m_bMem )
			{
				// Allocate memory
				m_pMem = new BYTE[ size + 1 ];
				if ( m_pMem == NULL ) 
				{	m_dwTransferStatus = NETFILE_DS_ERROR;
					return FALSE;
				} // end if

				// Read in the file
				if ( !file.Read( m_pMem, size, &m_dwDataRead ) )
				{	m_dwTransferStatus = NETFILE_DS_ERROR;
					return FALSE;
				} // end if

				// NULL terminate for good measure
				m_pMem[ size ] = 0;

			} // end if

			else
			{
				// Where to download the file
				if ( pLocal != DOWNLOADTEMP ) { strcpy_sz( m_szLocal, pLocal ); }
				else CWinFile::CreateTemp( m_szLocal );	

				// Copy the file
				CopyFile( m_szUrl, m_szLocal, FALSE );

				// Open the file
				if ( !m_local.OpenExisting( m_szLocal, GENERIC_READ | GENERIC_WRITE ) )
				{	m_dwTransferStatus = NETFILE_DS_ERROR;
					return FALSE;
				} // end if

				// Get the file size
				m_dwDataRead = m_local.Size();

			} // end else

			// Memory read complete
			m_dwTransferStatus = NETFILE_DS_DONE;

			return TRUE;

		} // end if

	} // end if

	if ( !m_bMem )
	{
		// Where to download the file
		if ( pLocal != DOWNLOADTEMP ) { strcpy_sz( m_szLocal, pLocal ); }
		else CWinFile::CreateTemp( m_szLocal );	

		// Create a file to load data
		if ( !m_local.OpenNew( m_szLocal, GENERIC_READ | GENERIC_WRITE ) )
			return FALSE;
	} // end else
	
	// Set status	
	m_dwTransferStatus = NETFILE_DS_INITIALIZING;

	// Create a thread to download the file
	if ( !StartThread() )
	{	Destroy();
		m_dwTransferStatus = NETFILE_DS_ERROR;		
		return FALSE;
	} // end if

	return TRUE;
}
Пример #10
0
void DAutosaver::Tick ()
{
	Net_WriteByte (DEM_CHECKAUTOSAVE);
	Destroy ();
}
Пример #11
0
/** The main entry point. */
int main(int argc, char *argv[])
{
   char *temp;
   int x;
   enum {
      ACTION_RUN,
      ACTION_RESTART,
      ACTION_EXIT,
      ACTION_RELOAD,
      ACTION_PARSE
   } action;

   StartDebug();

   /* Get the name of the user's local configuration file. */
   temp = getenv("HOME");
   if(temp) {
      const size_t temp_len = strlen(temp);
      const size_t config_len = sizeof(CONFIG_FILE);
      configPath = Allocate(temp_len + config_len);
      memcpy(configPath, temp, temp_len);
      memcpy(&configPath[temp_len], CONFIG_FILE, config_len);
   } else {
      configPath = CopyString(CONFIG_FILE);
   }

   /* Parse command line options. */
   action = ACTION_RUN;
   for(x = 1; x < argc; x++) {
      if(!strcmp(argv[x], "-v")) {
         DisplayAbout();
         DoExit(0);
      } else if(!strcmp(argv[x], "-h")) {
         DisplayHelp();
         DoExit(0);
      } else if(!strcmp(argv[x], "-p")) {
         action = ACTION_PARSE;
      } else if(!strcmp(argv[x], "-restart")) {
         action = ACTION_RESTART;
      } else if(!strcmp(argv[x], "-exit")) {
         action = ACTION_EXIT;
      } else if(!strcmp(argv[x], "-reload")) {
         action = ACTION_RELOAD;
      } else if(!strcmp(argv[x], "-display") && x + 1 < argc) {
         displayString = argv[++x];
      } else if(!strcmp(argv[x], "-f") && x + 1 < argc) {
         Release(configPath);
         configPath = CopyString(argv[++x]);
      } else {
         printf("unrecognized option: %s\n", argv[x]);
         DisplayHelp();
         DoExit(1);
      }
   }

   switch(action) {
   case ACTION_PARSE:
      Initialize();
      ParseConfig(configPath);
      DoExit(0);
   case ACTION_RESTART:
      SendRestart();
      DoExit(0);
   case ACTION_EXIT:
      SendExit();
      DoExit(0);
   case ACTION_RELOAD:
      SendReload();
      DoExit(0);
   default:
      break;
   }

#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS)
   setlocale(LC_ALL, "");
#endif
#ifdef HAVE_GETTEXT
   bindtextdomain("jwm", LOCALEDIR);
   textdomain("jwm");
#endif

   /* The main loop. */
   StartupConnection();
   do {

      isRestarting = shouldRestart;
      shouldExit = 0;
      shouldRestart = 0;
      shouldReload = 0;

      /* Prepare JWM components. */
      Initialize();

      /* Parse the configuration file. */
      ParseConfig(configPath);

      /* Start up the JWM components. */
      Startup();

      /* The main event loop. */
      EventLoop();

      /* Shutdown JWM components. */
      Shutdown();

      /* Perform any extra cleanup. */
      Destroy();

   } while(shouldRestart);
   ShutdownConnection();

   /* If we have a command to execute on shutdown, run it now. */
   if(exitCommand) {
      execl(SHELL_NAME, SHELL_NAME, "-c", exitCommand, NULL);
      Warning(_("exec failed: (%s) %s"), SHELL_NAME, exitCommand);
      DoExit(1);
   } else {
      DoExit(0);
   }

   /* Control shoud never get here. */
   return -1;

}
Пример #12
0
CMenuItemList::~CMenuItemList()
{	Destroy();
}
Пример #13
0
/* Function that runs the application */
INT CXBApplicationEx::Run()
{
  CLog::Log(LOGNOTICE, "Running the application..." );

  unsigned int lastFrameTime = 0;
  unsigned int frameTime = 0;
  const unsigned int noRenderFrameTime = 15;  // Simulates ~66fps

#ifdef XBMC_TRACK_EXCEPTIONS
  BYTE processExceptionCount = 0;
  BYTE frameMoveExceptionCount = 0;
  BYTE renderExceptionCount = 0;
  const BYTE MAX_EXCEPTION_COUNT = 10;
#endif

  // Run xbmc
  while (!m_bStop)
  {
#ifdef HAS_PERFORMANCE_SAMPLE
    CPerformanceSample sampleLoop("XBApplicationEx-loop");
#endif
    //-----------------------------------------
    // Animate and render a frame
    //-----------------------------------------
#ifdef XBMC_TRACK_EXCEPTIONS
    try
    {
#endif
      lastFrameTime = XbmcThreads::SystemClockMillis();
      Process();
      //reset exception count
#ifdef XBMC_TRACK_EXCEPTIONS
      processExceptionCount = 0;

    }
    catch (const XbmcCommons::UncheckedException &e)
    {
      e.LogThrowMessage("CApplication::Process()");
      processExceptionCount++;
      //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
      if (processExceptionCount > MAX_EXCEPTION_COUNT)
      {
        CLog::Log(LOGERROR, "CApplication::Process(), too many exceptions");
        throw;
      }
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::Process()");
      processExceptionCount++;
      //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
      if (processExceptionCount > MAX_EXCEPTION_COUNT)
      {
        CLog::Log(LOGERROR, "CApplication::Process(), too many exceptions");
        throw;
      }
    }
#endif
    // Frame move the scene
#ifdef XBMC_TRACK_EXCEPTIONS
    try
    {
#endif
      if (!m_bStop) FrameMove(true, m_renderGUI);
      //reset exception count
#ifdef XBMC_TRACK_EXCEPTIONS
      frameMoveExceptionCount = 0;

    }
    catch (const XbmcCommons::UncheckedException &e)
    {
      e.LogThrowMessage("CApplication::FrameMove()");
      frameMoveExceptionCount++;
      //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
      if (frameMoveExceptionCount > MAX_EXCEPTION_COUNT)
      {
        CLog::Log(LOGERROR, "CApplication::FrameMove(), too many exceptions");
        throw;
      }
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::FrameMove()");
      frameMoveExceptionCount++;
      //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
      if (frameMoveExceptionCount > MAX_EXCEPTION_COUNT)
      {
        CLog::Log(LOGERROR, "CApplication::FrameMove(), too many exceptions");
        throw;
      }
    }
#endif

    // Render the scene
#ifdef XBMC_TRACK_EXCEPTIONS
    try
    {
#endif
      if (m_renderGUI && !m_bStop) Render();
      else if (!m_renderGUI)
      {
        frameTime = XbmcThreads::SystemClockMillis() - lastFrameTime;
        if(frameTime < noRenderFrameTime)
          Sleep(noRenderFrameTime - frameTime);
      }
#ifdef XBMC_TRACK_EXCEPTIONS
      //reset exception count
      renderExceptionCount = 0;

    }
    catch (const XbmcCommons::UncheckedException &e)
    {
      e.LogThrowMessage("CApplication::Render()");
      renderExceptionCount++;
      //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
      if (renderExceptionCount > MAX_EXCEPTION_COUNT)
      {
        CLog::Log(LOGERROR, "CApplication::Render(), too many exceptions");
        throw;
      }
    }
    catch (...)
    {
      CLog::Log(LOGERROR, "exception in CApplication::Render()");
      renderExceptionCount++;
      //MAX_EXCEPTION_COUNT exceptions in a row? -> bail out
      if (renderExceptionCount > MAX_EXCEPTION_COUNT)
      {
        CLog::Log(LOGERROR, "CApplication::Render(), too many exceptions");
        throw;
      }
    }
#endif
  } // while (!m_bStop)
  Destroy();

  CLog::Log(LOGNOTICE, "application stopped..." );
  return m_ExitCode;
}
Пример #14
0
void JavaString::Reset(const JavaString& str) {
	Destroy();
	JavaObject::Reset(str);
	Init();
}
Пример #15
0
void Menu::CreatePopUp()
{
    Destroy();
    mid = new QsciSciPopup();
}
Пример #16
0
void CNetFile::Close()
{_STT();
	Destroy();
}
Пример #17
0
int main () {
    T_handler handler;
    unsigned ok;
    unsigned ad;
    printf("Uno\n");
    Create(&handler);
    Show(handler);

    Allocate(&handler,50,&ad,&ok);
    Allocate(&handler,50,&ad,&ok);
    Show(handler);
    Deallocate(&handler,25,0);
    Show(handler);
    Deallocate(&handler,25,50);
    Show(handler);
    Deallocate(&handler,25,25);
    Show(handler);
    Deallocate(&handler,25,75);
    Show(handler);

    printf("Dos\n");

    Allocate(&handler,50,&ad,&ok);
    if (ok) {
        Show(handler);
        printf("Starting address is: %d\n", ad);
    } else {
        printf("Unable to allocate such a memory\n");
    }

    Deallocate(&handler, 20,0);
    Show (handler);

    Allocate(&handler,25,&ad,&ok);
    if (ok) {
        Show(handler);
        printf("Starting address is: %d\n", ad);
    } else {
        printf("Unable to allocate such a memory\n");
    }

    Deallocate(&handler,10,50);
    Show(handler);

    Allocate(&handler,25,&ad,&ok);
    if (ok) {
        Show(handler);
        printf("Starting address is: %d\n", ad);
    } else {
        printf("Unable to allocate such a memory\n");
    }

    Deallocate(&handler, 20,75);
    Show(handler);

    Destroy(&handler);
    Show (handler);


    return 0;
}
Пример #18
0
BOOL CNetFile::Upload(LPCTSTR pUrl, LPCTSTR pLocal, BOOL bPassive)
{_STT();
	// Stop whatever else we were doing
	if ( pLocal != NULL ) Destroy();

	// Uploading file
	m_bUpload = TRUE;
	m_dwDataWritten = 0;
	m_bPassive = bPassive;
	
	// Save parent window
	m_hWndParent = NULL;

	// Sanity check
	if ( pUrl == NULL || *pUrl == NULL ) return FALSE;

	// Are we downloading to file or ram?
	m_bMem = ( pLocal == NULL );

	{ // Copy the url
		
		char buf[ sizeof( m_szUrl ) ];
		DWORD size = sizeof( m_szUrl ) - 1;

		// Is it a local file?
		if ( GetFileAttributes( pUrl ) == MAXDWORD )
		{
			// Fix the url
			if ( InternetCanonicalizeUrl( pUrl, buf, &size, 0 ) )
			{ strcpy_sz( m_szUrl, buf ); }

			// Copy the url name
			else strcpy_sz( m_szUrl, pUrl );
		} // end if
		
		// Copy the local file name
		else strcpy_sz( m_szUrl, pUrl );

	} // end copy url	

	if ( !m_bMem )
	{
		// Where to download the file
		if ( pLocal != DOWNLOADTEMP ) { strcpy_sz( m_szLocal, pLocal ); }
		else CWinFile::CreateTemp( m_szLocal );	

		// Create a file to load data
		if ( !m_local.OpenExisting( m_szLocal, GENERIC_READ | GENERIC_WRITE ) )
			return FALSE;
	} // end else

	// Set status	
	m_dwTransferStatus = NETFILE_DS_INITIALIZING;

	// Create a thread to download the file
	if ( !StartThread() )
	{	Destroy();
		m_dwTransferStatus = NETFILE_DS_INITIALIZING;
		return FALSE;
	} // end if

	return TRUE;
}
Пример #19
0
LibSVMBinaryReader<ElemType>::~LibSVMBinaryReader()
{
    Destroy();
}
Пример #20
0
CNetFile::~CNetFile()
{_STT();
	Destroy();
}
Пример #21
0
void DCeiling::Tick ()
{
	EResult res;
		
	switch (m_Direction)
	{
	case 0:
		// IN STASIS
		break;
	case 1:
		// UP
		res = MoveCeiling (m_Speed, m_TopHeight, m_Direction);
		
		if (res == pastdest)
		{
			switch (m_Type)
			{
			case ceilCrushAndRaise:
				m_Direction = -1;
				m_Speed = m_Speed1;
				if (!SN_IsMakingLoopingSound (m_Sector))
					PlayCeilingSound ();
				break;
				
			// movers with texture change, change the texture then get removed
			case genCeilingChgT:
			case genCeilingChg0:
				m_Sector->SetSpecial(&m_NewSpecial);
				// fall through
			case genCeilingChg:
				m_Sector->SetTexture(sector_t::ceiling, m_Texture);
				// fall through
			default:
				SN_StopSequence (m_Sector, CHAN_CEILING);
				Destroy ();
				break;
			}
		}
		break;
		
	case -1:
		// DOWN
		res = MoveCeiling (m_Speed, m_BottomHeight, m_Crush, m_Direction, m_Hexencrush);
		
		if (res == pastdest)
		{
			switch (m_Type)
			{
			case ceilCrushAndRaise:
			case ceilCrushRaiseAndStay:
				m_Speed = m_Speed2;
				m_Direction = 1;
				if (!SN_IsMakingLoopingSound (m_Sector))
					PlayCeilingSound ();
				break;

			// in the case of ceiling mover/changer, change the texture
			// then remove the active ceiling
			case genCeilingChgT:
			case genCeilingChg0:
				m_Sector->SetSpecial(&m_NewSpecial);
				// fall through
			case genCeilingChg:
				m_Sector->SetTexture(sector_t::ceiling, m_Texture);
				// fall through
			default:
				SN_StopSequence (m_Sector, CHAN_CEILING);
				Destroy ();
				break;
			}
		}
		else // ( res != pastdest )
		{
			if (res == crushed)
			{
				switch (m_Type)
				{
				case ceilCrushAndRaise:
				case ceilLowerAndCrush:
				case ceilLowerAndCrushDist:
					if (m_Speed1 == FRACUNIT && m_Speed2 == FRACUNIT)
						m_Speed = FRACUNIT / 8;
						break;

				default:
					break;
				}
			}
		}
		break;
	}
}
Пример #22
0
BOOL CNetFile::HttpRequest(LPCTSTR pUrl, CRKey *pHeaders, CRKey *pData, LPCTSTR pMethod, LPCTSTR pLocal, BOOL bCloseFileAfterDownload, HWND hWndParent, DWORD dwUrlEncoding)
{_STT();
	// Lose previous file
	Destroy();

	// Downloading
	m_bUpload = FALSE;

	// Save parent window
	m_hWndParent = hWndParent;

	// Save close file status
	m_bCloseFileAfterDownload = bCloseFileAfterDownload;

	// Sanity check
	if ( pUrl == NULL || *pUrl == NULL ) return FALSE;

	// Are we downloading to file or ram?
	m_bMem = ( pLocal == NULL );

	{ // Copy the url
		
		char buf[ sizeof( m_szUrl ) ] = { 0 };
		DWORD size = sizeof( m_szUrl ) - 1;

		// Is it a local file?
		if ( GetFileAttributes( pUrl ) == MAXDWORD )
		{
			// Fix the url
			if ( InternetCanonicalizeUrl( pUrl, buf, &size, 0 ) )
			{	strcpy_sz( m_szUrl, buf ); }

			// Copy the url name
			else strcpy_sz( m_szUrl, pUrl );
		} // end if
		
		// Copy the local file name
		else strcpy_sz( m_szUrl, pUrl );

	} // end copy url	

	if ( !m_bMem )
	{
		// Where to download the file
		if ( pLocal != DOWNLOADTEMP ) { strcpy_sz( m_szLocal, pLocal ); }
		else CWinFile::CreateTemp( m_szLocal );	

		// Create a file to load data
		if ( !m_local.OpenNew( m_szLocal, GENERIC_READ | GENERIC_WRITE ) )
			return FALSE;
	} // end else
	
	// Set status	
	m_dwTransferStatus = NETFILE_DS_INITIALIZING;

	// Save request method
	if ( pMethod == NULL || *pMethod == 0 ) m_sMethod = "POST";
	else m_sMethod = pMethod;

	// Set data
	DWORD dwContentLength = 0;
	if ( pData != NULL )
	{	CPipe pipe;
		pData->EncodeUrl( &pipe, dwUrlEncoding );
		m_sData.copy( (LPCTSTR)pipe.GetBuffer(), pipe.GetBufferSize() );
		dwContentLength = pipe.GetBufferSize();
	} // end if

	// Set headers
	if ( strcmpi( m_sMethod, "GET" ) )
	{
		CRKey rkHeaders;
		if ( pHeaders != NULL ) rkHeaders.Copy( pHeaders );
		
		rkHeaders.Set( "Content-Type", "application/x-www-form-urlencoded" );
		rkHeaders.Set( "Content-Length", dwContentLength );

		CPipe pipe;
		rkHeaders.EncodeHttpHeaders( &pipe );
		m_sHeaders.copy( (LPCTSTR)pipe.GetBuffer(), pipe.GetBufferSize() );

	} // end if

	// Create a thread to download the file
	if ( !StartThread() )
	{	Destroy();
		m_dwTransferStatus = NETFILE_DS_ERROR;		
		return FALSE;
	} // end if

	return TRUE;
}
void CBTFootbotRecruitmentRootBehavior::Reset(CCI_FootBotState& c_robot_state) {
	Destroy(c_robot_state);
	Init(c_robot_state);
}
	//
	// 从数据流加载资源
	//
	BOOL CRenderFlow::LoadFromStream(CStream *pStream, FLOAT scalePPI)
	{
		//
		// 1. 数据流有效性检查
		//
		if (pStream == NULL) {
			return FALSE;
		}

		if (pStream->IsValid() == FALSE) {
			return FALSE;
		}

		//
		// 2. 释放渲染流程
		//
		Destroy();
		Free();

		//
		// 3. 加载渲染流程
		//
		try {
			//
			// 3.1. 设置缩放比
			//
			m_scalePPI = scalePPI;

			//
			// 3.2. 打开XML
			//
			TiXmlDocument doc;
			if (doc.LoadFile((CHAR *)pStream->GetCurrentAddress(), pStream->GetFreeSize()) == FALSE) {
				throw "Invalid xml format.";
			}

			//
			// 3.3. 获得渲染流程节点
			//
			TiXmlNode *pRenderFlowNode = doc.FirstChild("RenderFlow");
			if (pRenderFlowNode == NULL) throw "Invalid render flow format.";

			//
			// 3.4. 加载渲染流程
			//
			LoadRenderTargets(pRenderFlowNode);
			LoadRenderSolutions(pRenderFlowNode);

			//
			// 3.5. 创建渲染流程
			//
			Create();

			return TRUE;
		}
		catch (const CHAR *szError) {
			WriteLogE("Error CRenderFlow::LoadFromStream: %s %s %d\n", szError, __FILE__, __LINE__);
			Free();

			return FALSE;
		}
	}
Пример #25
0
CRscLinkMgr::~CRscLinkMgr(void)
{
    Destroy();
}
	CRenderFlow::~CRenderFlow(VOID)
	{
		Destroy();
		Free();
	}
Пример #27
0
CBillboardAnimation::~CBillboardAnimation( void )
{
	Destroy();
}
Пример #28
0
//-----------------------------------------------------------------------------
// Name: ~CXBPackedResource()
// Desc: Destructor
//-----------------------------------------------------------------------------
CXBPackedResource::~CXBPackedResource()
{
    Destroy();
}
NS_METHOD 
compzillaRenderingContext::SetDimensions (PRInt32 width, PRInt32 height)
{
  DEBUG ("SetDimensions (%d,%d)\n", width, height);

    Destroy();

#if false
    // Check that the dimensions are sane
    if (!CheckSaneImageSize(width, height))
        return NS_ERROR_FAILURE;
#endif

    mWidth = width;
    mHeight = height;

#ifdef MOZ_CAIRO_GFX
    DEBUG ("thebes\n");

    mThebesSurface = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize (width, height), gfxASurface::ImageFormatARGB32);
    mThebesContext = new gfxContext(mThebesSurface);

    mSurface = mThebesSurface->CairoSurface();
    cairo_surface_reference(mSurface);
    mCairo = mThebesContext->GetCairo();
    cairo_reference(mCairo);

    DEBUG ("/thebes\n");
#else
    // non-cairo gfx
    // On most current X servers, using the software-only surface
    // actually provides a much smoother and faster display.
    // However, we provide MOZ_CANVAS_USE_RENDER for whomever wants to
    // go that route.

    //if (getenv("MOZ_CANVAS_USE_RENDER")) {
        XRenderPictFormat *fmt = XRenderFindStandardFormat (GDK_DISPLAY(),
                                                            PictStandardARGB32);
        if (fmt) {
            int npfmts = 0;
            XPixmapFormatValues *pfmts = XListPixmapFormats(GDK_DISPLAY(), &npfmts);
            for (int i = 0; i < npfmts; i++) {
                if (pfmts[i].depth == 32) {
                    npfmts = -1;
                    break;
                }
            }
            XFree(pfmts);

            if (npfmts == -1) {
                mSurfacePixmap = XCreatePixmap (GDK_DISPLAY(),
                                                DefaultRootWindow(GDK_DISPLAY()),
                                                width, height, 32);
                mSurface = cairo_xlib_surface_create_with_xrender_format
                    (GDK_DISPLAY(), mSurfacePixmap, DefaultScreenOfDisplay(GDK_DISPLAY()),
                     fmt, mWidth, mHeight);
            }
        }
    //}

    // fall back to image surface
    if (!mSurface) {
        mImageSurfaceData = (PRUint8*) PR_Malloc (mWidth * mHeight * 4);
        if (!mImageSurfaceData)
            return NS_ERROR_OUT_OF_MEMORY;

        mSurface = cairo_image_surface_create_for_data (mImageSurfaceData,
                                                        CAIRO_FORMAT_ARGB32,
                                                        mWidth, mHeight,
                                                        mWidth * 4);
    }

    mCairo = cairo_create(mSurface);
#endif

    cairo_set_operator(mCairo, CAIRO_OPERATOR_CLEAR);
    cairo_new_path(mCairo);
    cairo_rectangle(mCairo, 0, 0, mWidth, mHeight);
    cairo_fill(mCairo);

    cairo_set_line_width(mCairo, 1.0);
    cairo_set_operator(mCairo, CAIRO_OPERATOR_OVER);
    cairo_set_miter_limit(mCairo, 10.0);
    cairo_set_line_cap(mCairo, CAIRO_LINE_CAP_BUTT);
    cairo_set_line_join(mCairo, CAIRO_LINE_JOIN_MITER);

    cairo_new_path(mCairo);

    return NS_OK;
}
Пример #30
0
void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
    Destroy();
}