Beispiel #1
0
void SupportMgr::SendGmTicket(WorldSession* session, GmTicket* ticket) const
{
    WorldPackets::Ticket::GMTicketGetTicketResponse response;

    if (ticket)
    {
        response.Result = GMTICKET_STATUS_HASTEXT;
        response.Info = boost::in_place();

        response.Info->TicketID = ticket->GetId();
        response.Info->TicketDescription = ticket->GetDescription();
        response.Info->Category = 1;
        response.Info->TicketOpenTime = GetAge(ticket->GetLastModifiedTime());
        response.Info->OldestTicketTime = sSupportMgr->GetOldestOpenTicket() ? GetAge(sSupportMgr->GetOldestOpenTicket()->GetLastModifiedTime()) : float(0);
        response.Info->UpdateTime = GetAge(sSupportMgr->GetLastChange());
        response.Info->AssignedToGM = ticket->GetAssigendToStatus();
        response.Info->OpenedByGM = ticket->GetOpenedByGmStatus();
        response.Info->WaitTimeOverrideMessage = "";
        response.Info->WaitTimeOverrideMinutes = 0;
    }
    else
        response.Result = GMTICKET_STATUS_DEFAULT;

    session->SendPacket(response.Write());
}
Beispiel #2
0
void GmTicket::WritePacket(WorldPacket& data) const
{
    data << GetAge(_lastModifiedTime);
    if (GmTicket* ticket = sTicketMgr->GetOldestOpenTicket())
        data << GetAge(ticket->GetLastModifiedTime());
    else
        data << float(0);

    // I am not sure how blizzlike this is, and we don't really have a way to find out
    data << GetAge(sTicketMgr->GetLastChange());

    data << uint8(std::min(_escalatedStatus, TICKET_IN_ESCALATION_QUEUE));                              // escalated data
    data << uint8(_viewed ? GMTICKET_OPENEDBYGM_STATUS_OPENED : GMTICKET_OPENEDBYGM_STATUS_NOT_OPENED); // whether or not it has been viewed
}
Beispiel #3
0
// On utilise cette fonction lorsque un coup refute le coup de la couche
// precedente.
int TTableTrans::StoreRefutation( TChessBoard& cb, int ply, int depth,
                                  int wtm, short valeur, int alpha, int beta,
                                  int danger )
{
  Bitboard* pTable;

  // Blanc ou noir?
  pTable = (wtm)?m_pTableBlanc:m_pTableNoir;

  // Retrouver la position dans la table.
  int  iPosition = (m_iMaskCle & (int)cb.CleHachage);
  pTable += iPosition*2;


  // Verifier si la position est meilleur que celle qu'on a dans la table.
  // Si l'age est setter alors toujours remplacer.
  if ( !GetAge( (*pTable) ) && GetDepth( (*pTable) ) > depth  ) {
	g_iTranspositionCollision++;
    return false;
  }

  // Mettre les informations dans la table.
  *pTable = 0;
  *(pTable+1) = cb.CleHachage;
  StoreValeur( (*pTable), valeur );
  int iType = BORNE_INFERIEUR;
  StoreType( (*pTable), iType );
  StoreDanger( (*pTable), danger );
  StoreCoup( (*pTable), 0 );
  StoreDepth( (*pTable), depth );

  return true;
}
Beispiel #4
0
void GalaxySetupPanel::GetSetupData(GalaxySetupData& setup_data) const {
    setup_data.m_seed =             GetSeed();
    setup_data.m_size =             Systems();
    setup_data.m_shape =            GetShape();
    setup_data.m_age =              GetAge();
    setup_data.m_starlane_freq =    GetStarlaneFrequency();
    setup_data.m_planet_density =   GetPlanetDensity();
    setup_data.m_specials_freq =    GetSpecialsFrequency();
    setup_data.m_monster_freq =     GetMonsterFrequency();
    setup_data.m_native_freq =      GetNativeFrequency();
    setup_data.m_ai_aggr =          GetAIAggression();
}
Beispiel #5
0
void GmTicket::WritePacket(WorldPacket& data) const
{
    data << uint32(GMTICKET_STATUS_HASTEXT);
    data << uint32(_id);
    data << _message;
    data << uint8(_haveTicket);
    data << GetAge(_lastModifiedTime);
    if (GmTicket* ticket = sTicketMgr->GetOldestOpenTicket())
        data << GetAge(ticket->GetLastModifiedTime());
    else
        data << float(0);

    // I am not sure how blizzlike this is, and we don't really have a way to find out
    data << GetAge(sTicketMgr->GetLastChange());

    data << uint8(std::min(_escalatedStatus, TICKET_IN_ESCALATION_QUEUE));                              // escalated data
    data << uint8(_viewed ? GMTICKET_OPENEDBYGM_STATUS_OPENED : GMTICKET_OPENEDBYGM_STATUS_NOT_OPENED); // whether or not it has been viewed

    // TODO: implement these
    std::string waitTimeOverrideMessage = "";
    data << waitTimeOverrideMessage;
    data << uint32(0); // waitTimeOverrideMinutes
}
Beispiel #6
0
// StoreBest est appelle quand tout les noeud d'un coup a ete explore
// et qu'il est temps de renvoyer la valeur du meilleur coup au noeud parent.
int TTableTrans::StoreBest( TChessBoard& cb, int ply, int depth,
                            int wtm, int alpha, int initial_alpha, int danger )
{
  Bitboard* pTable;

  // Blanc ou noir?
  pTable = (wtm)?m_pTableBlanc:m_pTableNoir;

  // Retrouver la position dans la table.
  int  iPosition = (m_iMaskCle & (int)cb.CleHachage);
  pTable += iPosition*2;


  // Verifier si la position est meilleur que celle qu'on a dans la table.
  // Si l'age est setter alors toujours remplacer.
  if ( !GetAge( (*pTable) ) && GetDepth( (*pTable) ) >= depth  )
    return false;

  // Mettre les informations dans la table.
  *pTable = 0;
  *(pTable+1) = cb.CleHachage;
  struct DeuxMot {
    int mot1;
    int mot2;
  };
  union Donnee {
    TMove move;
    DeuxMot deuxmot;
  };
  Donnee coup;
  coup.move = pv[ply][ply];
  StoreCoup( (*pTable), coup.deuxmot.mot1 );
  StoreDepth( (*pTable), depth );
  int iType;
  if ( alpha > initial_alpha ) {
    iType = SCORE_EXACTE;
    StoreValeur( (*pTable), alpha );
  }
  else {
    iType = BORNE_SUPERIEUR;
    StoreValeur( (*pTable), alpha );
  }
  StoreType( (*pTable), iType );

  return true;
}
/***************************************************************************
 * PrintAll
 * -------------------------------------------------------------------------
 * This method will print the attributes of the object
 *
 * Returns: none
 ***************************************************************************/
void Student::PrintAll() const
{
	const int WIDTH = 17;


	cout << fixed 			  << setprecision(2) << left;
	cout << "Student Information" << endl;
	cout << "-------------------" << endl;
	cout << setw(WIDTH)       << "Name: " 		    << GetName()    << endl;
	cout << setw(WIDTH)       << "ID: " 	        << GetId()      << endl;
	cout << setw(WIDTH)       << "Number: "         << GetNumber()  << endl;
	cout << setw(WIDTH)       << "Age: " 		    << GetAge()     << endl;
	cout << setw(WIDTH)       << "Gender: "	        << GetGender()  << endl;
	cout << setw(WIDTH)       << "Standing: "       << GetStanding()<< endl;
	cout << setw(WIDTH)       << "GPA: " 		    << GetGpa()     << endl;
	cout << setw(WIDTH)       << "Graduation Date: "<< GetDate()    << endl;
	cout << right;
}
Beispiel #8
0
bool nwxLockFile::WaitUntilUnlocked(
  const wxString &sFileName,
  time_t nWait,
  time_t nTimeout)
{
  wxString sLockFile = GetLockFileName(sFileName);
  time_t tUntil = 0;
  bool bDone = false;
  bool bRtn = false;
  while(!(bDone || bRtn))
  {
    if(!wxFileName::FileExists(sLockFile))
    {
      bRtn = true;
    }
    else
    {
      time_t tNow;
      time(&tNow);
      if(GetAge(sLockFile,tNow) >= nTimeout)
      {
        bRtn = true;
      }
      else if(!nWait)
      {
        bDone = true;
      }
      else if(!tUntil)
      {
        tUntil = tNow + nWait;
      }
      else if(tNow <= tUntil)
      {
        wxSleep(1);
      }
      else
      {
        bDone = true;
      }
    }
  }
  return bRtn;
}
bool RandomDivisionCellCycleModel::ReadyToDivide()
{
    assert(mpCell != NULL);

    if (!mReadyToDivide)
    {
        if (GetAge() > mMinimumDivisionAge)
        {
            double dt = SimulationTime::Instance()->GetTimeStep();
            if (!(mpCell->GetCellProliferativeType()->IsType<DifferentiatedCellProliferativeType>()))
            {
                RandomNumberGenerator* p_gen = RandomNumberGenerator::Instance();
                if (p_gen->ranf() < mDivisionProbability*dt)
                {
                    mReadyToDivide = true;
                }
            }
        }
    }
    return mReadyToDivide;
}
	void CUnit::RecieveMessage(CMessage &message){
		NLOG("CUnit::RecieveMessage");
		if(!IsValid()){
			return;
		}
		if(message.GetType() == string("update")){
			if(under_construction){
				return;
			}

			if(EVERY_((GetAge()%32+20))){
				if(currentTask.get() != 0){
					if(!currentTask->IsValid()){
						//
						taskManager->TaskFinished();
						currentTask = taskManager->GetNextTask();
						if(currentTask.get() != 0){
							currentTask->Init();
							G->RegisterMessageHandler(currentTask);
						}else{
							currentTask = boost::shared_ptr<IModule>();
						}
					}
				}else{
					//
					currentTask = taskManager->GetNextTask();
					if(currentTask.get() != 0){
						currentTask->Init();
						G->RegisterMessageHandler(currentTask);
					}
				}

			}

		}else if(message.GetType() == string("unitfinished")){
			if(message.GetParameter(0) == this->uid){
				under_construction = false;
				LoadBehaviours();
			}
		}else if(message.GetType() == string("unitdestroyed")){
			if(message.GetParameter(0) == uid){

				if(!utd->IsMobile()){
					G->BuildingPlacer->UnBlock(G->GetUnitPos(uid),utd);
				}

				G->RemoveHandler(currentTask);
				taskManager->RemoveAllTasks();
				//G->RemoveHandler(taskManager);

				if(!behaviours.empty()){
					behaviours.erase(behaviours.begin(),behaviours.end());
					behaviours.clear();
				}
				this->End();
				return;
			}
		}
		if(under_construction){
			return;
		}

	}
void AbstractOdeBasedPhaseBasedCellCycleModel::UpdateCellCyclePhase()
{
    assert(mpOdeSystem != nullptr);

    double current_time = SimulationTime::Instance()->GetTime();

    // Update the phase from M to G1 when necessary
    if (mCurrentCellCyclePhase == M_PHASE)
    {
        double m_duration = GetMDuration();
        if (GetAge() >= m_duration)
        {
            mCurrentCellCyclePhase = G_ONE_PHASE;
            mLastTime = m_duration + mBirthTime;
        }
        else
        {
            // Still dividing; don't run ODEs
            return;
        }
    }

    if (current_time > mLastTime)
    {
        if (!this->mFinishedRunningOdes)
        {
            // Update whether a stopping event has occurred
            this->mFinishedRunningOdes = SolveOdeToTime(current_time);

            // Check no concentrations have gone negative
            for (unsigned i=0; i<mpOdeSystem->GetNumberOfStateVariables(); i++)
            {
                if (mpOdeSystem->rGetStateVariables()[i] < -DBL_EPSILON)
                {
                    // LCOV_EXCL_START
                    EXCEPTION("A protein concentration " << i << " has gone negative (" <<
                              mpOdeSystem->rGetStateVariables()[i] << ")\n"
                              << "Chaste predicts that the CellCycleModel numerical method is probably unstable.");
                    // LCOV_EXCL_STOP
                }
            }

            if (this->mFinishedRunningOdes)
            {
                // Update durations of each phase
                mG1Duration = GetOdeStopTime() - mBirthTime - GetMDuration();
                mG2PhaseStartTime = GetOdeStopTime() + GetSDuration();
                mDivideTime = mG2PhaseStartTime + GetG2Duration();

                // Update phase
                if (current_time >= mG2PhaseStartTime)
                {
                    mCurrentCellCyclePhase = G_TWO_PHASE;
                }
                else
                {
                    mCurrentCellCyclePhase = S_PHASE;
                }
            }
        }
        else
        {
            // ODE model finished, just increasing time until division...
            if (current_time >= mG2PhaseStartTime)
            {
                mCurrentCellCyclePhase = G_TWO_PHASE;
            }
        }
    }
}
Beispiel #12
0
bool nwxLockFile::LockWait(const wxString &sFileName, time_t nWait, time_t nTimeout)
{
  wxString sFileLockName = GetLockFileName(sFileName);
  bool bRtn = false;
  if(sFileLockName.Len())
  {
    wxFile fl;
    time_t tUntil = 0;
    bool bDone = false;
    while(!bDone)
    {
      if(!wxFileName::FileExists(sFileLockName))
      {
        //if(AccessAge(sFileName) > 1) //-- too many problems
        {
          bRtn = fl.Create(sFileLockName.c_str(),false);
          bDone = true;
        }
      }
      else if(m_setFileName.find(sFileName) != m_setFileName.end())
      {
        //
        // file exists and was locked by this instance
        //
        bRtn = true;
        bDone = true;
        wxFileName fn(sFileLockName);
        fn.Touch(); // update file time to prevent timeout
        sFileLockName.Clear();
      }
      else if(GetAge(sFileLockName) >= nTimeout)
      {
        bRtn = fl.Create(sFileLockName.c_str(),true);
        bDone = true;
      }
      if(!bDone)
      {
        time_t tNow;
        time(&tNow);
        if(!nWait)
        {
          bDone = true;
        }
        else if(!tUntil)
        {
          tUntil = tNow + nWait;
        }
        else if(tNow <= tUntil)
        {
          wxSleep(1);
        }
        else
        {
          bDone = true;
        }
      }
    }
    if(bRtn && sFileLockName.Len())
    {
      m_setFileName.insert(sFileName);
    }
  }
  if(!bRtn)
  {
    wxString s(_T("Cannot lock file: "));
    time_t t;
    s.Append(sFileName);
    time(&t);
    wxLog::OnLog(wxLOG_Message,s,t);
    wxASSERT_MSG(false,s);
  }
  return bRtn;
}
void ContactInhibitionCellCycleModel::UpdateCellCyclePhase()
{
    if ((mQuiescentVolumeFraction == DOUBLE_UNSET) || (mEquilibriumVolume == DOUBLE_UNSET))
    {
        EXCEPTION("The member variables mQuiescentVolumeFraction and mEquilibriumVolume have not yet been set.");
    }

    // Get cell volume
    double cell_volume = mpCell->GetCellData()->GetItem("volume");

    // Removes the cell label
    mpCell->RemoveCellProperty<CellLabel>();

    if (mCurrentCellCyclePhase == G_ONE_PHASE)
    {
        // Update G1 duration based on cell volume
        double dt = SimulationTime::Instance()->GetTimeStep();
        double quiescent_volume = mEquilibriumVolume * mQuiescentVolumeFraction;

        if (cell_volume < quiescent_volume)
        {
            // Update the duration of the current period of contact inhibition.
            mCurrentQuiescentDuration = SimulationTime::Instance()->GetTime() - mCurrentQuiescentOnsetTime;
            mG1Duration += dt;

            /*
             * This method is usually called within a CellBasedSimulation, after the CellPopulation
             * has called CellPropertyRegistry::TakeOwnership(). This means that were we to call
             * CellPropertyRegistry::Instance() here when adding the CellLabel, we would be creating
             * a new CellPropertyRegistry. In this case the CellLabel's cell count would be incorrect.
             * We must therefore access the CellLabel via the cell's CellPropertyCollection.
             */
            boost::shared_ptr<AbstractCellProperty> p_label =
                mpCell->rGetCellPropertyCollection().GetCellPropertyRegistry()->Get<CellLabel>();
            mpCell->AddCellProperty(p_label);
        }
        else
        {
            // Reset the cell's quiescent duration and update the time at which the onset of quiescent occurs
            mCurrentQuiescentDuration = 0.0;
            mCurrentQuiescentOnsetTime = SimulationTime::Instance()->GetTime();
        }
    }

    double time_since_birth = GetAge();
    assert(time_since_birth >= 0);

    if (mpCell->GetCellProliferativeType()->IsType<DifferentiatedCellProliferativeType>())
    {
        mCurrentCellCyclePhase = G_ZERO_PHASE;
    }
    else if ( time_since_birth < GetMDuration() )
    {
        mCurrentCellCyclePhase = M_PHASE;
    }
    else if ( time_since_birth < GetMDuration() + mG1Duration)
    {
        mCurrentCellCyclePhase = G_ONE_PHASE;
    }
    else if ( time_since_birth < GetMDuration() + mG1Duration + GetSDuration())
    {
        mCurrentCellCyclePhase = S_PHASE;
    }
    else if ( time_since_birth < GetMDuration() + mG1Duration + GetSDuration() + GetG2Duration())
    {
        mCurrentCellCyclePhase = G_TWO_PHASE;
    }
}
Beispiel #14
0
void Bunny :: PrintBunnyObject()
{
	cout << GetBunnyName()<< "   -   "<< GetAge() <<"   -   "<<GetBunnyMutant() << "   -   " <<GetBunnyColorStr() << "   -   "<<GetBunnyGenderStr() <<endl;
}