示例#1
0
void HaltonSequence::operator++()
{
   const double one = 1.0 - 1e-10;
   double h, hh, remainder;
   
   n++;
   
   if(n & 8191)
   {
      for(int j = 0; j < dimension; j++)
      {
	 remainder = one - X[j];
	 
	 if(remainder < 0.0)
	    X[j] = 0.0;
	 else if(Radical[j] < remainder)
	    X[j] += Radical[j];
	 else
	 {
	    h = Radical[j];
	    
	    do
	    {
	       hh = h;
	       h *= Radical[j];
	    }
	    while(h >= remainder);
	    
	    X[j] += hh + h - 1.0;
	 }
      }
      /* updated 30.april 1996
	 if((h = X[j] + Radical[j]) <= one)
	    X[j] = h;
	 else
	 {
	    if(X[j] >= one)
	       X[j] = 0;
	    else
	    {
	       h = Radical[j];
	       
	       do
	       {
		  h *= Radical[j];
	       }
	       while(X[j] + h >= one); 
	       
	       X[j] += h / Radical[j] + h - 1.0;
	    }
	 }*/
   }
   else 
      /// change 5.10.94
      if(n >= 1073741824)   // == 2^30
	 SetInstance(0);
      else
	 /// change 5.10.94
	 SetInstance(n);
}
示例#2
0
/*
 * WinMain - entry point for the application
 */
int PASCAL WinMain( HINSTANCE currinst, HINSTANCE previnst, LPSTR cmdline, int cmdshow )
{
    MSG         msg;

    cmdline = cmdline;
    Instance = currinst;
    SetInstance( Instance );

    if( !InitGblStrings() ) {
        MessageBox( NULL, "Unable to find string resources", AppName, MB_OK );
        return( 0 );
    }
    if( previnst == NULL ) {
        if( !firstInstInit() ) {
            return( 0 );
        }
    }
    if( !everyInstInit( cmdshow ) ) {
        return( 0 );
    }

    while( GetMessage( &msg, NULL, 0, 0 ) ) {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
    }
    DdeUninitialize( DDEInstId );
    JDialogFini();
#ifndef NOUSE3D
    CvrCtl3dUnregister( Instance );
    CvrCtl3DFini( Instance );
#endif
    return( 1 );

} /* WinMain */
示例#3
0
文件: AppWin.cpp 项目: rohith10/Tejas
//
//   FUNCTION: CreateInstance(HINSTANCE, int)
//
//   Saves the instance handle, creates and displays the main window.
//
BOOL AppWin::CreateInstance(HINSTANCE inHInstance, int inNCmdShow)
{
    SetInstance(inHInstance);
    RegisterWindowClass(L"FrontEndMain");

    s_hWnd = CreateWindow(s_windowClassName.c_str(), s_windowTitle.c_str(), WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, s_hThisInst, NULL);

    if (!s_hWnd)
    {
        return FALSE;
    }

    ShowWindow(s_hWnd, inNCmdShow);
    UpdateWindow(s_hWnd);

    s_hAccelTable = LoadAccelerators(s_hThisInst, MAKEINTRESOURCE(IDC_APPMAIN));

    RECT activeArea;
    GetClientRect(s_hWnd, &activeArea);
    s_width = abs(activeArea.right - activeArea.left);
    s_height = abs(activeArea.bottom - activeArea.top);

    return TRUE;
}
示例#4
0
void CameraManager::Construct(PE::GameContext &context, PE::MemoryArena arena)
{
	Handle h("CAMERA_MANAGER", sizeof(CameraManager));
	CameraManager *pCameraManager = new(h) CameraManager(context, arena, h);
	pCameraManager->addDefaultComponents();
	SetInstance(h);
}
示例#5
0
StringBrowser::StringBrowser (
    const char* name,
    ButtonState* bs, int r, int c, boolean u, int h, const char* d
) {
    SetInstance(name);
    Init(bs, r, c, u, h, d);
}
示例#6
0
//
// App is exiting
//
void plNetClientMgr::Shutdown()
{
    ISendDirtyState(hsTimer::GetSysSeconds());

    plNetLinkingMgr::GetInstance()->LeaveAge(true);

    // release all avatar clones
    IUnloadRemotePlayers();
    IUnloadNPCs();

    // Finally, pump the dispatch system so all the new refs get delivered.
    plgDispatch::Dispatch()->MsgQueueProcess();

    if (fMsgRecorder)
    {
        delete fMsgRecorder;
        fMsgRecorder = nil;
    }
    for (int i = 0; i < fMsgPlayers.size(); i++)
        delete fMsgPlayers[i];
    fMsgPlayers.clear();

    IRemoveCloneRoom();

    VaultDestroy();

    // commit hara-kiri
    UnRegisterAs(kNetClientMgr_KEY);
    SetInstance(nullptr);
}
示例#7
0
void WRESEAPI WMenuInit( void )
{
    HINSTANCE   inst;

    inst = WGetEditInstance();
    if( AccelTable == (HACCEL)NULL ) {
        AccelTable = LoadAccelerators( inst, "WMenuAccelTable");
    }
    if( InsertBefore == (HBITMAP)NULL ) {
        InsertBefore = LoadBitmap( inst, "InsertBefore");
    }
    if( InsertAfter == (HBITMAP)NULL ) {
        InsertAfter = LoadBitmap( inst, "InsertAfter");
    }
    if( InsertSub == (HBITMAP)NULL ) {
        InsertSub = LoadBitmap( inst, "InsertSub");
    }
    if( InsertNoSub == (HBITMAP)NULL ) {
        InsertNoSub = LoadBitmap( inst, "InsertNoSub");
    }
    if( ref_count == 0 ) {
        WRInit();
        SetInstance( inst );
        WInit( inst );
        WInitDummyMenuEntry();
    }
    ref_count++;
}
示例#8
0
//-----------------------------------------
//perseguir por posicion de personaje(sin colisiones)
//-----------------------------------------
//void CZombie::Perseguir(Vect3f hisPosition,float _elapsedtime)
//{
//  Vect3f myPosition = GetInstance()->GetPosition();
//  GetEjeMovimientoIA()->MovAgentIA(hisPosition,myPosition,GetMoveSpeed(),_elapsedtime);
//  
//  //posicion y rotacion del muñeco
//  
////  GetInstance()->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
//  //GetInstance()->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
//
//  CRenderableObject* myinstance = CORE->GetRenderableObjectsManager()->GetInstance(this->GetInstance()->GetName());
//  myinstance->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
//  myinstance->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
//  SetInstance((CRenderableAnimatedInstanceModel*)myinstance);
//}
//-----------------------------------------
//perseguir por vector director
//-----------------------------------------
void CZombie::Perseguir(Vect3f hisPosition,float _elapsedtime, float height)
{
  Vect3f myPosition = GetInstance()->GetPosition();
  float mySpeed = GetMoveSpeed();

  GetEjeMovimientoIA()->MovAgentIA(hisPosition,myPosition,mySpeed,_elapsedtime);
  
  Vect3f aux = GetEjeMovimientoIA()->GetVectorDirector();
  aux.y = 0.0f;
  GetPhysicController()->Move(aux /** _elapsedtime*/ * mySpeed, _elapsedtime);

  Vect3f controllerPosition = GetPhysicController()->GetPosition();
  //controllerPosition.y = 0.0f;
  //myinstance->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
  CRenderableObject* myinstance = GetInstance();
  float l_fPosY = controllerPosition.y - GetPhysicController()->GetRadius()*height ;
  if(height == 1.0f)//boss
    myinstance->SetPosition(Vect3f(controllerPosition.x, l_fPosY -(height/4.0f), controllerPosition.z));
  else              //zombie
    myinstance->SetPosition(Vect3f(controllerPosition.x, l_fPosY, controllerPosition.z));
    
  myinstance->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
  
  SetInstance((CRenderableAnimatedInstanceModel*)myinstance);
}
JNIEXPORT void JNICALL Java_luc_fourestier_rbook_BookManager__1Release(JNIEnv *env, jobject thiz) {
    RBook::BookManager *bm = GetInstance(env, thiz);
    if (bm != NULL) {
        delete bm;
    }

    SetInstance(env, thiz, NULL);
}
示例#10
0
//==============================================================================
// ParserFactory::GetInstance
//
//==============================================================================
AutoPtr<ParserFactory> ParserFactory::GetInstance()
{
	if(s_pInstance == NULL)
	{
		SetInstance(new ParserFactory);
	}
	QC_DBG_ASSERT(s_pInstance!=0);
	return s_pInstance;
}
示例#11
0
static BOOL initApplication( void )
{
    RegisterMainWindow( InstanceHandle );
    // RegisterContainerWindow( InstanceHandle );

    // Init ldstr.c
    SetInstance( InstanceHandle );
    return( TRUE );
}
示例#12
0
//==============================================================================
AutoPtr<XMLReaderFactory> XMLReaderFactory::GetInstance()
{
	if(s_pInstance == NULL)
	{
		SetInstance(new XMLReaderFactory);
	}
	QC_DBG_ASSERT(s_pInstance!=0);
	return s_pInstance;
}
示例#13
0
CGapManager::CGapManager(CParkManager *pManager)
{
	m_currentId = 2000;

	for (int i = 0; i < vMAX_GAPS; i++)
		mp_gapInfoTab[i] = NULL;

	mp_manager = pManager;
	SetInstance();
}
示例#14
0
FileChooser::FileChooser(
    const char* name, const char* t, const char* subt, const char* d, 
    int r, int c, const char* acceptLabel, Alignment a
) : StringChooser(new ButtonState, a) {
    SetInstance(name);
    FileBrowser* fb = new FileBrowser(state, d, r, c);
    StringChooser::Init(new StringEditor(state, fb->GetDirectory()), fb);
    Init(t, subt);
    Insert(Interior(acceptLabel));
}
示例#15
0
nsresult nsWidget::CreateWidget(nsIWidget *aParent,
                                const nsRect &aRect,
                                EVENT_CALLBACK aHandleEventFunction,
                                nsIDeviceContext *aContext,
                                nsIAppShell *aAppShell,
                                nsIToolkit *aToolkit,
                                nsWidgetInitData *aInitData,
                                nsNativeWidget aNativeParent)
{

    PtWidget_t *parentWidget = nsnull;



    if( aNativeParent ) {
        parentWidget = (PtWidget_t*)aNativeParent;
        // we've got a native parent so listen for resizes
        mListenForResizes = PR_TRUE;
    }
    else if( aParent ) {
        parentWidget = (PtWidget_t*) (aParent->GetNativeData(NS_NATIVE_WIDGET));
        mListenForResizes = aInitData ? aInitData->mListenForResizes : PR_FALSE;
    }

    if( aInitData->mWindowType == eWindowType_child && !parentWidget ) return NS_ERROR_FAILURE;

    nsIWidget *baseParent = aInitData &&
                            (aInitData->mWindowType == eWindowType_dialog ||
                             aInitData->mWindowType == eWindowType_toplevel ||
                             aInitData->mWindowType == eWindowType_invisible) ?
                            nsnull : aParent;

    BaseCreate( baseParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData );

    mParent = aParent;
    mBounds = aRect;

    CreateNative (parentWidget);

    if( aRect.width > 1 && aRect.height > 1 ) Resize(aRect.width, aRect.height, PR_FALSE);

    if( mWidget ) {
        SetInstance(mWidget, this);
        PtAddCallback( mWidget, Pt_CB_GOT_FOCUS, GotFocusCallback, this );
        PtAddCallback( mWidget, Pt_CB_LOST_FOCUS, LostFocusCallback, this );
        PtAddCallback( mWidget, Pt_CB_IS_DESTROYED, DestroyedCallback, this );
#ifdef PHOTON_DND
        PtAddCallback( mWidget, Pt_CB_DND, DndCallback, this );
#endif
    }

    DispatchStandardEvent(NS_CREATE);

    return NS_OK;
}
示例#16
0
//
// DESTRUCT
//
plNetClientMgr::~plNetClientMgr()
{
    plSynchedObject::PushSynchDisabled(true);       // disable dirty tracking

    IDeInitNetClientComm(); 

    if (this==GetInstance())
        SetInstance(nil);       // we're going down boys
    IClearPendingLoads();
    delete fTaskProgBar;
}
JNIEXPORT void JNICALL Java_luc_fourestier_rbook_BookManager__1Create(JNIEnv *env, jobject thiz) {
    InitializeInstanceField(env, thiz);

    RBook::BookManager *bm = new RBook::BookManager();
    if (bm == NULL) {
        JNIThrowException(env, "java/lang/RuntimeException", NULL);
        return;
    }

    // Register instance at Java level
    SetInstance(env, thiz, bm);
}
示例#18
0
//---------------------------------------------------------------------------
// Initialize configuration partition as a copy of another
NaConfigPart::NaConfigPart (const NaConfigPart& rCP)
{
    const char  *szType = rCP.GetType();
    const char  *szInstance = rCP.GetInstance();

    szTypeName = new char[strlen(szType) + 1];
    strcpy(szTypeName, szType);

    szInstanceName = NULL;
    SetInstance(szInstance);

    pSelfData = NULL;
}
示例#19
0
//no utilizada
CZombie& CZombie::operator = (CZombie& z)
{
  SetHealth(z.GetHealth());
  SetInstance(z.GetInstance());
  SetModelFilename(z.GetModelFilename());
  SetMoveSpeed(z.GetMoveSpeed());
  SetRotSpeed(z.GetRotSpeed());
  GetInstance()->SetScalar(z.GetInstance()->GetScalarX(),z.GetInstance()->GetScalarX(),z.GetInstance()->GetScalarX());
  SetRadiusSmelling(z.GetRadiusSmelling());
  SetRadiuwViewing(z.GetRadiusViewing());
  GetInstance()->SetName(z.GetInstance()->GetName());
  SetEjeMovimientoIA(z.GetEjeMovimientoIA());

  return *this;
}
示例#20
0
void WRESEAPI WAccelInit( void )
{
    HINSTANCE   inst;

    inst = WGetEditInstance();
    if( AccelTable == (HACCEL)NULL ) {
        AccelTable = LoadAccelerators( inst, "WAccelAccelTable");
    }
    if( ref_count == 0 ) {
        WRInit();
        SetInstance( inst );
        WInit( inst );
    }
    ref_count++;
}
示例#21
0
//
// DESTRUCT
//
plAgeLoader::~plAgeLoader()
{
    delete fInitialAgeState;
    fInitialAgeState=nil;

    if ( PendingAgeFniFiles().size() )
        plNetClientApp::StaticErrorMsg( "~plAgeLoader(): {} pending age fni files", PendingAgeFniFiles().size() );
    if ( PendingPageOuts().size() )
        plNetClientApp::StaticErrorMsg( "~plAgeLoader(): {} pending page outs", PendingPageOuts().size() );

    ClearPageExcludeList();     // Clear our debugging exclude list, just to be tidy
    
    if (fInstance==this)
        SetInstance(nil);
}
示例#22
0
文件: TileSet.cpp 项目: pluraldj/for
void TileSet::LoadFromFile(string path)
{
    // Attempt load from XML
    TileSetParser *tp = new TileSetParser();
    
    // New tile set
    TileSet *newTileSet = tp->Load();
    
    // Delete old
    delete this;
    
    // Set static pointer to new one
    SetInstance(newTileSet);
    
    // Clean up parser object
    delete tp;
}
示例#23
0
void Control::Init(const char* name, Interactor* i) {
    if (name != nil) {
	SetInstance(name);
    }
    enabled_ = true;
    parent_ = nil;
    state_ = new ControlState;
    state_->Attach(this);
    input = new Sensor;
    input->Catch(EnterEvent);
    input->Catch(LeaveEvent);
    input->Catch(DownEvent);
    input->Catch(UpEvent);
    if (i != nil) {
	Insert(i);
    }
}
示例#24
0
NPError GetValue(NPP instance, NPPVariable variable, void *value) {
  switch (variable) {
    case NPPVpluginScriptableNPObject: {
      javascriptListener = (NPObject *)browserFuncs->createobject(instance, (NPClass *)&JavascriptListener_NPClass);
      *((NPObject **)value) = javascriptListener;
      SetInstance(instance, javascriptListener);
      break;
    }
    case NPPVpluginNeedsXEmbed: {
      *((bool *)value) = true;
      break;
    }
    default: {
      return NPERR_INVALID_PARAM;
    }
  }
  return NPERR_NO_ERROR;
}
示例#25
0
//-----------------------------------------
// encarando por vector director
//-----------------------------------------
void CZombie::Encarando(Vect3f hisPosition,float _elapsedtime, float height)
{
  Vect3f myPosition = GetInstance()->GetPosition();
  GetEjeMovimientoIA()->MovAgentIA(hisPosition,myPosition,0.0f,_elapsedtime,true);
  
  Vect3f controllerPosition = GetPhysicController()->GetPosition();
  //controllerPosition.y = 0.0f;
  //myinstance->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
  CRenderableObject* myinstance = GetInstance();
  float l_fPosY = controllerPosition.y - GetPhysicController()->GetRadius()*height;
  if(height == 1.0f)//boss
    myinstance->SetPosition(Vect3f(controllerPosition.x, l_fPosY -(height/4.0f), controllerPosition.z));
  else              //zombie
    myinstance->SetPosition(Vect3f(controllerPosition.x, l_fPosY, controllerPosition.z));

  myinstance->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
  SetInstance((CRenderableAnimatedInstanceModel*)myinstance);
}
示例#26
0
/*
 * WinMain - main entry point
 */
int WINMAINENTRY WinMain( HINSTANCE currinst, HINSTANCE previnst, LPSTR cmdline,
                          int cmdshow )
{
    MSG         msg;
    HWND        prev_hwnd;
    char        *errstr;

    cmdline = cmdline;
    errstr = errstr;
    SetInstance( currinst );
#ifdef __NT__

    /* because of the shared memory used by the NT spy we can only allow
     * one spy to exist at a time */

    prev_hwnd = FindWindow( SPY_CLASS_NAME, NULL );
    if( prev_hwnd != NULL ) {
        errstr = GetRCString( STR_ONLY_1_SPY_ALLOWED );
        MessageBox( NULL, errstr, SpyName, MB_OK | MB_ICONEXCLAMATION );

        /* setting the window topmost then not topmost is a kludge to
         * make sure the window is really moved to the top */

        SetWindowPos( prev_hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
        SetWindowPos( prev_hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
        exit( 0 );
    }
#else
    prev_hwnd = prev_hwnd;
#endif
    if( !spyInit( currinst, previnst, cmdshow ) ) {
        exit( 0 );
    }

    while( GetMessage( &msg, (HWND)NULL, 0, 0 ) ) {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
    }
    SpyFini();
    return( 1 );

} /* WinMain */
bool CZombieOlfateador::Init(CZombie &z)
{
	bool bIsOk = Inherited::Init(z);
  if (!bIsOk)
  {
		printf("a CZombieOlfateador instace couldnt allocate memory");
    Done();								//We call Done()  to release before the parent class
	}
  else
  {
    SetHealth(z.GetHealth());
    SetInstance(z.GetInstance());
    SetModelFilename(z.GetModelFilename());
    SetMoveSpeed(z.GetMoveSpeed());
    SetRotSpeed(z.GetRotSpeed());
    GetInstance()->SetScalar(z.GetInstance()->GetScalarX(),z.GetInstance()->GetScalarY(),z.GetInstance()->GetScalarZ());
    SetSiguiendoRuta(false);
  }

  return bIsOk;
}
示例#28
0
HaltonSequence::HaltonSequence(UL_int Dimension, Rng * rng_ptr, UL_int offset, int *Primes)
   : Sequence(Dimension,rng_ptr)
{
   n       = offset;
   n0      = offset;

   Radical = new double[dimension];
   assert(Radical);
   
   ownBase = (! Primes);   
   if(ownBase)
      Base = FirstPrimes((L_int)dimension);
   else
      Base = Primes;
   
   for(int j = 0; j < dimension; j++)
   {
      Radical[j] = 1.0 / (double) Base[j];
      X[j] = 0.0;
   }
   SetInstance(n0);
}
示例#29
0
Scroller::Scroller(const char* name, Interactor* i, int n) {
    SetInstance(name);
    interactor = i;
    size = n;
    Init();
}
示例#30
0
Panner::Panner (const char* name, Interactor* i, int size) {
    SetInstance(name);
    Init(i, size);
}