DelayHistogram::
  DelayHistogram(size_t _nsets,
		 size_t _nbins,
		 double _ms_floor,
		 double _ms_ceiling,
		 size_t _oskip)
    : nsets(_nsets),
      nbins(_nbins),
      ms_floor(_ms_floor),
      ms_ceiling(_ms_ceiling),
      ms_range(_ms_ceiling - _ms_floor),
      oskip(_oskip),
      m_below(new size_t[_nsets]),
      m_above(new size_t[_nsets]),
      m_bin(new size_t[_nsets * _nbins]),
      m_start(new ::timeval[_nsets]),
      m_ms_min(new double[_nsets]),
      m_ms_max(new double[_nsets]),
      m_ms_sum(new double[_nsets]),
      m_ms_count(new size_t[_nsets]),
      m_bin_floor(new double[_nbins]),
      m_iteration(0)
  {
    for (size_t ii(0); ii < _nsets; ++ii)
      m_name.push_back("set " + sfl::to_string(ii));
    for (size_t ii(0); ii < _nbins; ++ii)
      m_bin_floor[ii] = ms_floor + ii * ms_range / nbins;
    ResetAll();
  }
Beispiel #2
0
bool Filter::ParseFilterRule(const std::string::const_iterator begin,
        const std::string::const_iterator end) {
    auto level_separator = std::find(begin, end, ':');
    if (level_separator == end) {
        LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: %s",
                std::string(begin, end).c_str());
        return false;
    }

    const Level level = GetLevelByName(level_separator + 1, end);
    if (level == Level::Count) {
        LOG_ERROR(Log, "Unknown log level in filter: %s", std::string(begin, end).c_str());
        return false;
    }

    if (Common::ComparePartialString(begin, level_separator, "*")) {
        ResetAll(level);
        return true;
    }

    const Class log_class = GetClassByName(begin, level_separator);
    if (log_class == Class::Count) {
        LOG_ERROR(Log, "Unknown log class in filter: %s", std::string(begin, end).c_str());
        return false;
    }

    SetClassLevel(log_class, level);
    return true;
}
Beispiel #3
0
void Game::HandleLostGraphicsDevice()
{
	// Test for and handle lost device
	hr = graphics->GetDeviceState();
	if(FAILED(hr)) // if graphics device is not in a valid state
	{
		// If the device is lost and not available for reset
		if(hr == D3DERR_DEVICELOST)
		{
			Sleep(100); // yield cpu time (100 mili-seconds)
			return;
		} 
		// The device was lost but is now available for reset
		else if(hr == D3DERR_DEVICENOTRESET)
		{
			ReleaseAll();
			hr = graphics->Reset(); // attempt to reset graphics device
			if(FAILED(hr)) // if reset failed
				return;
			ResetAll();
		}
		else
			return; // other device error
	}
}
Beispiel #4
0
void CUIDialogWnd::Show()
{
	inherited::Enable(true);
	inherited::Show(true);

	ResetAll();
}
void EventViewer::on_cmbDiffVars_currentIndexChanged(int index) //slot
{
    std::lock_guard<std::mutex> lock(_mutex);
    emit ListSelection(index);
    ResetAll();
    _sdfCurve->setPen( QPen(_colors.at(index%_colors.size())) );
}
//
// Function: main
//
// Description:
//    Initialize the NetBIOS interface, allocate some resources, add
//    the server name to each LANA, post an asynch NCBLISTEN on each
//    LANA with the appropriate callback.  Then wait for incoming
//    client connections at which time, spawn a worker thread to handle
//    it. The main thread simply waits while the server threads are 
//    handling client requests.  You wouldn't do this in a real app, 
//    but this sample is for illustrative purposes only... 
//
int main(int argc, char **argv)
{
    LANA_ENUM   lenum;
    int         i,
                num=0;

    // Enumerate all LANAs and reset each one
    //
    if (LanaEnum(&lenum) != NRC_GOODRET)
        return 1;
    if (ResetAll(&lenum, 254, 254, FALSE) != NRC_GOODRET)
        return 1;
    //
    // Add the server name to each LANA and issue a listen on each
    //
    for(i=0; i < lenum.length ;i++)
    {
        printf("Registering name '%s' on lana %d\n", SERVER_NAME, num);
        AddName(lenum.lana[i], SERVER_NAME, &num);
        Listen(lenum.lana[i], SERVER_NAME);
    }

    while (1)
    {        
        Sleep(5000);
    }
}
Beispiel #7
0
/*
 * Class holding the main armor class stat and general boni
 */
ArmorClass::ArmorClass()
{
	natural = 0;
	Owner = NULL;
	ResetAll();

	third = !!core->HasFeature(GF_3ED_RULES);
}
Beispiel #8
0
/*
 * Class holding the main to-hit/thac0 stat and general boni
 * NOTE: Always use it through GetCombatDetails to get the full state
 */
ToHitStats::ToHitStats()
{
	base = 0;
	babDecrement = 0;
	Owner = NULL;
	ResetAll();

	third = !!core->HasFeature(GF_3ED_RULES);
}
void CUITalkDialogWnd::Show()
{
	InventoryUtilities::SendInfoToActor				("ui_talk_show");
	InventoryUtilities::SendInfoToLuaScripts		("ui_talk_show");
	inherited::Show									(true);
	inherited::Enable								(true);

	ResetAll										();
}
Beispiel #10
0
void instance_violet_hold::OnPlayerEnter(Player* /*pPlayer*/)
{
    UpdateWorldState(m_auiEncounter[TYPE_MAIN] == IN_PROGRESS ? true : false);

    if (m_vRandomBosses.empty())
    {
        SetRandomBosses();
        ResetAll();
    }
}
Beispiel #11
0
void CUITradeWnd::Show()
{
	InventoryUtilities::SendInfoToActor("ui_trade");
	inherited::Show					(true);
	inherited::Enable				(true);

	SetCurrentItem					(NULL);
	ResetAll						();
	m_uidata->UIDealMsg				= NULL;
}
void instance_violet_hold::SetData(uint32 uiType, uint32 uiData)
{
    debug_log("SD2: instance_violet_hold: SetData got type % u, data %u.", uiType, uiData);

    switch(uiType)
    {
        case TYPE_MAIN:
        {
            if (uiData == m_auiEncounter[0])
                return;

            switch(uiData)
            {
                case NOT_STARTED:
                    ResetAll();
                    break;
                case IN_PROGRESS:
                    DoUseDoorOrButton(m_uiDoorSealGUID);
                    SetRandomBosses();
                    UpdateWorldState();
                    m_uiPortalId = urand(0, 2);
                    m_uiPortalTimer = 15000;
                    break;
                case FAIL:
                    if (Creature* pSinclari = instance->GetCreature(m_uiSinclariGUID))
                        pSinclari->Respawn();

                    break;
                case DONE:
                    break;
                case SPECIAL:
                    break;
            }
            m_auiEncounter[0] = uiData;
            break;
        }
        case TYPE_SEAL:
            m_auiEncounter[1] = uiData;
            break;
        case TYPE_PORTAL:
        {
            switch(uiData)
            {
                case SPECIAL:                               // timer to next
                    m_uiPortalTimer = 90000;
                    break;
                case DONE:                                  // portal done, set timer to 5 secs
                    m_uiPortalTimer = 5000;
                    break;
            }
            m_auiEncounter[2] = uiData;
            break;
        }
    }
}
Beispiel #13
0
void CUIListWnd::Reset()
{
	for(LIST_ITEM_LIST_it it=m_ItemList.begin();  m_ItemList.end() != it; ++it)
	{
		(*it)->Reset();
	}

	ResetAll();

	inherited::Reset();
}
Beispiel #14
0
//############################################################################//
//
// Function: Initialize()
//                                
// Purpose:  Initialize the model 
//                                
//############################################################################//
void FcRadar::Initialize()
{
  ResetAll();

  simTime = GetSimTime();

  nextFrameTime = initFrameTime;

  pxf = initPxf;
  pyf = initPyf;

}  // end Initialize()
//--------------------------------------------------------------------------------------------------
// Name: ~CBreakableGlassSystem
// Desc: Destructor
//--------------------------------------------------------------------------------------------------
CBreakableGlassSystem::~CBreakableGlassSystem()
{
	// Release all nodes and data
	ResetAll();

#ifdef GLASS_DEBUG_MODE
	// Remove debug cvars after all nodes that could be using them
	if (IConsole* pConsole = gEnv->pConsole)
	{
		pConsole->UnregisterVariable("g_glassSystem_draw");
		pConsole->UnregisterVariable("g_glassSystem_drawWireframe");
		pConsole->UnregisterVariable("g_glassSystem_drawDebugData");
		pConsole->UnregisterVariable("g_glassSystem_drawFragData");

		pConsole->UnregisterVariable("g_glassSystem_decalAlwaysRebuild");
		pConsole->UnregisterVariable("g_glassSystem_decalScale");
		pConsole->UnregisterVariable("g_glassSystem_decalMinRadius");
		pConsole->UnregisterVariable("g_glassSystem_decalMaxRadius");
		pConsole->UnregisterVariable("g_glassSystem_decalRandChance");
		pConsole->UnregisterVariable("g_glassSystem_decalRandScale");
		pConsole->UnregisterVariable("g_glassSystem_decalMinImpactSpeed");

		pConsole->UnregisterVariable("g_glassSystem_fragImpulseScale");
		pConsole->UnregisterVariable("g_glassSystem_fragAngImpulseScale");	
		pConsole->UnregisterVariable("g_glassSystem_fragImpulseDampen");
		pConsole->UnregisterVariable("g_glassSystem_fragAngImpulseDampen");
		pConsole->UnregisterVariable("g_glassSystem_fragSpread");
		pConsole->UnregisterVariable("g_glassSystem_fragMaxSpeed");

		pConsole->UnregisterVariable("g_glassSystem_particleFXEnable");
		pConsole->UnregisterVariable("g_glassSystem_particleFXUseColours");
		pConsole->UnregisterVariable("g_glassSystem_particleFXScale");
	}
#endif // GLASS_DEBUG_MODE

	SAFE_DELETE(m_pGlassCVars);

	// Remove system enabled cvar callback
	IConsole* pConsole = gEnv->pConsole;
	ICVar* pSysEnabledCVar = pConsole ? pConsole->GetCVar("g_glassSystemEnable") : NULL;

	if (pSysEnabledCVar)
	{
		pSysEnabledCVar->SetOnChangeCallback(NULL);
	}

	// Remove physics callback
	if (IPhysicalWorld* pPhysWorld = gEnv->pPhysicalWorld)
	{
		pPhysWorld->RemoveEventClient(EventPhysCollision::id, &CBreakableGlassSystem::HandleImpact, 1);
	}
}//-------------------------------------------------------------------------------------------------
NS_IMETHODIMP nsIMAPHostSessionList::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
{
  if (!strcmp(aTopic, "profile-before-change"))
    ResetAll();
  else if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
  {
    nsCOMPtr<nsIObserverService> observerService =
      mozilla::services::GetObserverService();
    NS_ENSURE_TRUE(observerService, NS_ERROR_UNEXPECTED);
    observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
    observerService->RemoveObserver(this, "profile-before-change");
  }
  return NS_OK;
}
Beispiel #17
0
//############################################################################//
//
// Function: Initialize()
//                                
// Purpose:  Initialize the model 
//                                
//############################################################################//
void Seeker::Initialize()
{
  ResetAll();

  simTime = GetSimTime();

  initFrameTime = pMsl->launchTime;

  nextFrameTime = initFrameTime;

  pxf = pMsl->pxf;
  pyf = pMsl->pyf;

}  // end Initialize()
NS_IMETHODIMP nsIMAPHostSessionList::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
{
  nsresult rv;
  if (!strcmp(aTopic, "profile-before-change"))
    ResetAll();
  else if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
  {
    nsCOMPtr<nsIObserverService> observerService =  do_GetService("@mozilla.org/observer-service;1", &rv);
    if (NS_SUCCEEDED(rv))
    {
      observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
      observerService->RemoveObserver(this, "profile-before-change");
    }
  }
  return NS_OK;
}
Beispiel #19
0
void BatchGUI::SetupConnect()
{
    connect( this->ui.addButton, SIGNAL(clicked()), this, SLOT(AddProcess()) );
    //
    connect( this->ui.beginButton, SIGNAL(clicked()), this, SLOT(BeginProcess()) );
    //
    connect( this->ui.appButton, SIGNAL(clicked()), this, SLOT(SelectFile()) );
    //
    connect( this->ui.cleanButton, SIGNAL(clicked()), this, SLOT(CleanAll()) );
    //
    connect( this->ui.stopButton, SIGNAL(clicked()), this, SLOT(StopAll()) );
    //
    connect( this->ui.resumeButton, SIGNAL(clicked()), this, SLOT(Resume()) );
    //
    connect( this->ui.resetButton, SIGNAL(clicked()), this, SLOT(ResetAll()) );
    return;
}
Beispiel #20
0
//############################################################################//
//
// Function: Initialize()
//                                
// Purpose:  Initialize the model 
//                                
//############################################################################//
void Missile::Initialize()
{
  ResetAll();

  simTime = GetSimTime();
  
  nextFrameTime = initFrameTime;

  vxb = 0.0;
  vyb = 0.0;

  vxf = vxb;
  vyf = vxb;

  pxf = -( pExec->tFinal - launchTime ) * initVxb;
  pyf = 0.0;

}  // End Initialize()
Beispiel #21
0
void Reset(s32 flag)
{
	s32 core;

	if(flag == 0) ResetAll();

	VoiceTransStatus[0]	= 1;
	VoiceTransStatus[1]	= 1;
	TransIntrCallbacks[0]	= NULL;
	TransIntrCallbacks[1]	= NULL;
	TransIntrHandlers[0]	= NULL;
	TransIntrHandlers[1]	= NULL;
	TransIntrData[0].mode	= 0;
	TransIntrData[1].mode	= 1;
	TransIntrData[0].data	= NULL;
	TransIntrData[1].data	= NULL;
	VoiceTransIoMode[0]		= 0;
	VoiceTransIoMode[1]		= 0;
	Spu2IntrHandler			= NULL;
	Spu2IrqCallback			= NULL;
	Spu2IntrData			= NULL;

	RegisterInterrupts();

	for(core = 0; core < 2; core++)
	{
		EffectAttr[core].core = core;
		EffectAttr[core].mode = 0;
		EffectAttr[core].depth_l = 0;
		EffectAttr[core].depth_r = 0;
		EffectAttr[core].delay = 0;
		EffectAttr[core].feedback = 0;
	}

	if(flag == 0)
	{
		for(core = 0; core < 2; core++)
		{
			EffectAddr[core] = GetEEA(core) - ((EffectSizes[0] << 4) - 2);
			SetESA(core, EffectAddr[core]);
		}
	}
}
//
// Function: main
//
// Description:
//    Setup the NetBIOS interface, parse the arguments, and call the
//    adapter status command either locally or remotely depending on
//    the user supplied arguments.
//
int main(int argc, char **argv)
{
    LANA_ENUM   lenum;
    int         i, num;

    ValidateArgs(argc, argv);
    //
    // Make sure both command line flags weren't set
    //
    if (bLocalName && bRemoteName)
    {
        printf("usage: astat [/l:LOCALNAME | /r:REMOTENAME]\n");
        return 1;
    }
    // Enumerate all LANAs and reset each one
    //
    if (LanaEnum(&lenum) != NRC_GOODRET)
        return 1;
    if (ResetAll(&lenum, (UCHAR)MAX_SESSIONS, (UCHAR)MAX_NAMES, 
            FALSE) != NRC_GOODRET)
        return 1;
    //
    // If we're called with a local name we need to add it to
    // the name table.
    //
    if (bRemoteName == FALSE)
    {
        for(i=0; i < lenum.length ;i++)
        {
            if (bLocalName)
                AddName(lenum.lana[i], szLocalName, &num);
            LanaStatus(lenum.lana[i], szLocalName);
        }
    }
    else
    {
        for(i=0; i < lenum.length ;i++)
            LanaStatus(lenum.lana[i], szRemoteName);
    }
    return 0;
}
Beispiel #23
0
 void Advance() {
     ResetAll();
     const Char* begin = format_;
     for (;;) {
         if (*format_ == _T('%')) {
             if (format_[1] != _T('%')) { // It's a format specifier
                 Write(begin, format_);
                 ++format_;
                 break;
             }
             // It's a "%%"
             Write(begin, ++format_);
             begin = ++format_;
             continue; 
         }
         if (*format_ == 0) {
             Write(begin, format_);
             break;
         }
         ++format_;
     }
 }
CPDF_VariableText::~CPDF_VariableText() {
  ResetAll();
}
Beispiel #25
0
void instance_violet_hold::SetData(uint32 uiType, uint32 uiData)
{
    debug_log("SD2: instance_violet_hold: SetData got type %u, data %u.", uiType, uiData);

    switch (uiType)
    {
        case TYPE_MAIN:
        {
            if (uiData == m_auiEncounter[uiType])
                return;
            if (m_auiEncounter[uiType] == DONE)
                return;

            switch (uiData)
            {
                case IN_PROGRESS:
                    // ToDo: enable the prison defense system when implemented
                    DoUseDoorOrButton(GO_PRISON_SEAL_DOOR);
                    UpdateWorldState();
                    m_bIsDefenseless = true;
                    m_uiPortalId = urand(0, 2);
                    m_uiPortalTimer = 15000;
                    break;
                case FAIL:
                    if (Creature* pSinclari = GetSingleCreatureFromStorage(NPC_SINCLARI))
                        pSinclari->DealDamage(pSinclari, pSinclari->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                    if (Creature* pController = GetSingleCreatureFromStorage(NPC_EVENT_CONTROLLER))
                        pController->AI()->EnterEvadeMode();
                    // Reset the event (creature cleanup is handled in creature_linking)
                    DoUseDoorOrButton(GO_PRISON_SEAL_DOOR); // open instance door
                    ResetAll();
                    m_uiEventResetTimer = 20000;            // Timer may not be correct - 20 sec is default reset timer for blizz
                    break;
                case DONE:
                    DoUseDoorOrButton(GO_PRISON_SEAL_DOOR);
                    UpdateWorldState(false);
                    break;
                case SPECIAL:
                    break;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        }
        case TYPE_SEAL:
            m_auiEncounter[uiType] = uiData;
            if (uiData == SPECIAL)
            {
                --m_uiWorldStateSealCount;
                DoUpdateWorldState(WORLD_STATE_SEAL, m_uiWorldStateSealCount);

                // Yell at 75%, 50% and 25% shield
                if (m_uiWorldStateSealCount < 100 - 25 * m_uiSealYellCount)
                {
                    if (Creature* pSinclari = GetSingleCreatureFromStorage(NPC_SINCLARI_ALT))
                    {
                        // ToDo: I'm not sure if the last yell should be at 25% or at 5%. Needs research
                        ++m_uiSealYellCount;
                        DoScriptText(aSealWeakYell[m_uiSealYellCount - 1], pSinclari);
                    }
                }

                // set achiev to failed
                if (m_bIsDefenseless)
                    m_bIsDefenseless = false;

                if (!m_uiWorldStateSealCount)
                {
                    SetData(TYPE_MAIN, FAIL);
                    SetData(TYPE_SEAL, NOT_STARTED);
                }
            }
            break;
        case TYPE_PORTAL:
        {
            switch (uiData)
            {
                case SPECIAL:                               // timer to next
                    m_uiPortalTimer = 90000;
                    break;
                case DONE:                                  // portal done, set timer to 5 secs
                    m_uiPortalTimer = 3000;
                    break;
            }
            m_auiEncounter[uiType] = uiData;
            break;
        }
        case TYPE_LAVANTHOR:
        case TYPE_MORAGG:
        case TYPE_EREKEM:
        case TYPE_ICHORON:
        case TYPE_XEVOZZ:
        case TYPE_ZURAMAT:
            if (uiData == DONE)
                m_uiPortalTimer = 35000;
            if (m_auiEncounter[uiType] != DONE)             // Keep the DONE-information stored
                m_auiEncounter[uiType] = uiData;
            // Handle achievements if necessary
            if (uiData == IN_PROGRESS)
            {
                if (uiType == TYPE_ZURAMAT)
                    m_bIsVoidDance = true;
                else if (uiType == TYPE_ICHORON)
                    m_bIsDehydratation = true;
            }
            if (uiData == SPECIAL && uiType == TYPE_ICHORON)
                m_bIsDehydratation = false;
            if (uiData == FAIL)
                SetData(TYPE_MAIN, FAIL);
            break;
        case TYPE_CYANIGOSA:
            if (uiData == DONE)
                SetData(TYPE_MAIN, DONE);
            if (uiData == FAIL)
                SetData(TYPE_MAIN, FAIL);
            m_auiEncounter[uiType] = uiData;
            break;
        default:
            return;
    }

    if (uiData == DONE)
    {
        OUT_SAVE_INST_DATA;

        std::ostringstream saveStream;
        saveStream << m_auiEncounter[0] << " " << m_auiEncounter[1] << " " << m_auiEncounter[2] << " "
                   << m_auiEncounter[3] << " " << m_auiEncounter[4] << " " << m_auiEncounter[5] << " "
                   << m_auiEncounter[6] << " " << m_auiEncounter[7] << " " << m_auiEncounter[8] << " "
                   << m_auiEncounter[9];

        m_strInstData = saveStream.str();

        SaveToDB();
        OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Beispiel #26
0
void Game::SetDisplayMode(GraphicsNS::DISPLAY_MODE mode)
{
	ReleaseAll(); // free all user created surfaces
	graphics->ChangeDisplayMode(mode);
	ResetAll(); // recreate surfaces
}
Beispiel #27
0
//
// Find:
// Take nodes out of the tree with NextNode,
// until null (NextNode will return 0 at the end of our range).
//
NS_IMETHODIMP
nsFind::Find(const PRUnichar *aPatText, nsIDOMRange* aSearchRange,
             nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint,
             nsIDOMRange** aRangeRet)
{
#ifdef DEBUG_FIND
  printf("============== nsFind::Find('%s'%s, %p, %p, %p)\n",
         NS_LossyConvertUTF16toASCII(aPatText).get(),
         mFindBackward ? " (backward)" : " (forward)",
         (void*)aSearchRange, (void*)aStartPoint, (void*)aEndPoint);
#endif

  NS_ENSURE_ARG(aSearchRange);
  NS_ENSURE_ARG(aStartPoint);
  NS_ENSURE_ARG(aEndPoint);
  NS_ENSURE_ARG_POINTER(aRangeRet);
  *aRangeRet = 0;

  if (!aPatText)
    return NS_ERROR_NULL_POINTER;

  ResetAll();

  nsAutoString patAutoStr(aPatText);
  if (!mCaseSensitive)
    ToLowerCase(patAutoStr);

  // Ignore soft hyphens in the pattern  
  static const char kShy[] = { char(CH_SHY), 0 };
  patAutoStr.StripChars(kShy);

  const PRUnichar* patStr = patAutoStr.get();
  PRInt32 patLen = patAutoStr.Length() - 1;

  // current offset into the pattern -- reset to beginning/end:
  PRInt32 pindex = (mFindBackward ? patLen : 0);

  // Current offset into the fragment
  PRInt32 findex = 0;

  // Direction to move pindex and ptr*
  int incr = (mFindBackward ? -1 : 1);

  nsCOMPtr<nsIContent> tc;
  const nsTextFragment *frag = nsnull;
  PRInt32 fragLen = 0;

  // Pointers into the current fragment:
  const PRUnichar *t2b = nsnull;
  const char      *t1b = nsnull;

  // Keep track of when we're in whitespace:
  // (only matters when we're matching)
  bool inWhitespace = false;

  // Place to save the range start point in case we find a match:
  nsCOMPtr<nsIDOMNode> matchAnchorNode;
  PRInt32 matchAnchorOffset = 0;

  // Get the end point, so we know when to end searches:
  nsCOMPtr<nsIDOMNode> endNode;
  PRInt32 endOffset;
  aEndPoint->GetEndContainer(getter_AddRefs(endNode));
  aEndPoint->GetEndOffset(&endOffset);

  PRUnichar prevChar = 0;
  while (1)
  {
#ifdef DEBUG_FIND
    printf("Loop ...\n");
#endif

    // If this is our first time on a new node, reset the pointers:
    if (!frag)
    {

      tc = nsnull;
      NextNode(aSearchRange, aStartPoint, aEndPoint, false);
      if (!mIterNode)    // Out of nodes
      {
        // Are we in the middle of a match?
        // If so, try again with continuation.
        if (matchAnchorNode)
          NextNode(aSearchRange, aStartPoint, aEndPoint, true);

        // Reset the iterator, so this nsFind will be usable if
        // the user wants to search again (from beginning/end).
        ResetAll();
        return NS_OK;
      }

      // We have a new text content.  If its block parent is different
      // from the block parent of the last text content, then we
      // need to clear the match since we don't want to find
      // across block boundaries.
      nsCOMPtr<nsIDOMNode> blockParent;
      GetBlockParent(mIterNode, getter_AddRefs(blockParent));
#ifdef DEBUG_FIND
      printf("New node: old blockparent = %p, new = %p\n",
             (void*)mLastBlockParent.get(), (void*)blockParent.get());
#endif
      if (blockParent != mLastBlockParent)
      {
#ifdef DEBUG_FIND
        printf("Different block parent!\n");
#endif
        mLastBlockParent = blockParent;
        // End any pending match:
        matchAnchorNode = nsnull;
        matchAnchorOffset = 0;
        pindex = (mFindBackward ? patLen : 0);
        inWhitespace = false;
      }
 
      // Get the text content:
      tc = do_QueryInterface(mIterNode);
      if (!tc || !(frag = tc->GetText())) // Out of nodes
      {
        mIterator = nsnull;
        mLastBlockParent = 0;
        ResetAll();
        return NS_OK;
      }

      fragLen = frag->GetLength();

      // Set our starting point in this node.
      // If we're going back to the anchor node, which means that we
      // just ended a partial match, use the saved offset:
      if (mIterNode == matchAnchorNode)
        findex = matchAnchorOffset + (mFindBackward ? 1 : 0);

      // mIterOffset, if set, is the range's idea of an offset,
      // and points between characters.  But when translated
      // to a string index, it points to a character.  If we're
      // going backward, this is one character too late and
      // we'll match part of our previous pattern.
      else if (mIterOffset >= 0)
        findex = mIterOffset - (mFindBackward ? 1 : 0);

      // Otherwise, just start at the appropriate end of the fragment:
      else if (mFindBackward)
        findex = fragLen - 1;
      else
        findex = 0;

      // Offset can only apply to the first node:
      mIterOffset = -1;

      // If this is outside the bounds of the string, then skip this node:
      if (findex < 0 || findex > fragLen-1)
      {
#ifdef DEBUG_FIND
        printf("At the end of a text node -- skipping to the next\n");
#endif
        frag = 0;
        continue;
      }

#ifdef DEBUG_FIND
      printf("Starting from offset %d\n", findex);
#endif
      if (frag->Is2b())
      {
        t2b = frag->Get2b();
        t1b = nsnull;
#ifdef DEBUG_FIND
        nsAutoString str2(t2b, fragLen);
        printf("2 byte, '%s'\n", NS_LossyConvertUTF16toASCII(str2).get());
#endif
      }
      else
      {
        t1b = frag->Get1b();
        t2b = nsnull;
#ifdef DEBUG_FIND
        nsCAutoString str1(t1b, fragLen);
        printf("1 byte, '%s'\n", str1.get());
#endif
      }
    }
    else // still on the old node
    {
      // Still on the old node.  Advance the pointers,
      // then see if we need to pull a new node.
      findex += incr;
#ifdef DEBUG_FIND
      printf("Same node -- (%d, %d)\n", pindex, findex);
#endif
      if (mFindBackward ? (findex < 0) : (findex >= fragLen))
      {
#ifdef DEBUG_FIND
        printf("Will need to pull a new node: mAO = %d, frag len=%d\n",
               matchAnchorOffset, fragLen);
#endif
        // Done with this node.  Pull a new one.
        frag = nsnull;
        continue;
      }
    }

    // Have we gone past the endpoint yet?
    // If we have, and we're not in the middle of a match, return.
    if (mIterNode == endNode &&
        ((mFindBackward && (findex < endOffset)) ||
         (!mFindBackward && (findex > endOffset))))
    {
      ResetAll();
      return NS_OK;
    }

    // The two characters we'll be comparing:
    PRUnichar c = (t2b ? t2b[findex] : CHAR_TO_UNICHAR(t1b[findex]));
    PRUnichar patc = patStr[pindex];

#ifdef DEBUG_FIND
    printf("Comparing '%c'=%x to '%c' (%d of %d), findex=%d%s\n",
           (char)c, (int)c, patc, pindex, patLen, findex,
           inWhitespace ? " (inWhitespace)" : "");
#endif

    // Do we need to go back to non-whitespace mode?
    // If inWhitespace, then this space in the pat str
    // has already matched at least one space in the document.
    if (inWhitespace && !IsSpace(c))
    {
      inWhitespace = false;
      pindex += incr;
#ifdef DEBUG
      // This shouldn't happen -- if we were still matching, and we
      // were at the end of the pat string, then we should have
      // caught it in the last iteration and returned success.
      if (OVERFLOW_PINDEX)
        NS_ASSERTION(false, "Missed a whitespace match\n");
#endif
      patc = patStr[pindex];
    }
    if (!inWhitespace && IsSpace(patc))
      inWhitespace = true;

    // convert to lower case if necessary
    else if (!inWhitespace && !mCaseSensitive && IsUpperCase(c))
      c = ToLowerCase(c);

    // ignore soft hyphens in the document
    if (c == CH_SHY)
      continue;

    // a '\n' between CJ characters is ignored
    if (pindex != (mFindBackward ? patLen : 0) && c != patc && !inWhitespace) {
      if (c == '\n' && t2b && IS_CJ_CHAR(prevChar)) {
        PRInt32 nindex = findex + incr;
        if (mFindBackward ? (nindex >= 0) : (nindex < fragLen)) {
          if (IS_CJ_CHAR(t2b[nindex]))
            continue;
        }
      }
    }

    // Compare
    if ((c == patc) || (inWhitespace && IsSpace(c)))
    {
      prevChar = c;
#ifdef DEBUG_FIND
      if (inWhitespace)
        printf("YES (whitespace)(%d of %d)\n", pindex, patLen);
      else
        printf("YES! '%c' == '%c' (%d of %d)\n", c, patc, pindex, patLen);
#endif

      // Save the range anchors if we haven't already:
      if (!matchAnchorNode) {
        matchAnchorNode = mIterNode;
        matchAnchorOffset = findex;
      }

      // Are we done?
      if (DONE_WITH_PINDEX)
        // Matched the whole string!
      {
#ifdef DEBUG_FIND
        printf("Found a match!\n");
#endif

        // Make the range:
        nsCOMPtr<nsIDOMNode> startParent;
        nsCOMPtr<nsIDOMNode> endParent;
        nsCOMPtr<nsIDOMRange> range = CreateRange();
        if (range)
        {
          PRInt32 matchStartOffset, matchEndOffset;
          // convert char index to range point:
          PRInt32 mao = matchAnchorOffset + (mFindBackward ? 1 : 0);
          if (mFindBackward)
          {
            startParent = do_QueryInterface(tc);
            endParent = matchAnchorNode;
            matchStartOffset = findex;
            matchEndOffset = mao;
          }
          else
          {
            startParent = matchAnchorNode;
            endParent = do_QueryInterface(tc);
            matchStartOffset = mao;
            matchEndOffset = findex+1;
          }
          if (startParent && endParent && 
              IsVisibleNode(startParent) && IsVisibleNode(endParent))
          {
            range->SetStart(startParent, matchStartOffset);
            range->SetEnd(endParent, matchEndOffset);
            *aRangeRet = range.get();
            NS_ADDREF(*aRangeRet);
          }
          else {
            startParent = nsnull; // This match is no good -- invisible or bad range
          }
        }

        if (startParent) {
          // If startParent == nsnull, we didn't successfully make range
          // or, we didn't make a range because the start or end node were invisible
          // Reset the offset to the other end of the found string:
          mIterOffset = findex + (mFindBackward ? 1 : 0);
  #ifdef DEBUG_FIND
          printf("mIterOffset = %d, mIterNode = ", mIterOffset);
          DumpNode(mIterNode);
  #endif

          ResetAll();
          return NS_OK;
        }
        matchAnchorNode = nsnull;  // This match is no good, continue on in document
      }

      if (matchAnchorNode) {
        // Not done, but still matching.
        // Advance and loop around for the next characters.
        // But don't advance from a space to a non-space:
        if (!inWhitespace || DONE_WITH_PINDEX || IsSpace(patStr[pindex+incr]))
        {
          pindex += incr;
          inWhitespace = false;
#ifdef DEBUG_FIND
          printf("Advancing pindex to %d\n", pindex);
#endif
        }
      
        continue;
      }
    }

#ifdef DEBUG_FIND
    printf("NOT: %c == %c\n", c, patc);
#endif

    // If we didn't match, go back to the beginning of patStr,
    // and set findex back to the next char after
    // we started the current match.
    if (matchAnchorNode)    // we're ending a partial match
    {
      findex = matchAnchorOffset;
      mIterOffset = matchAnchorOffset;
          // +incr will be added to findex when we continue

      // Are we going back to a previous node?
      if (matchAnchorNode != mIterNode)
      {
        nsCOMPtr<nsIContent> content (do_QueryInterface(matchAnchorNode));
        nsresult rv = NS_ERROR_UNEXPECTED;
        if (content)
          rv = mIterator->PositionAt(content);
        frag = 0;
        NS_ASSERTION(NS_SUCCEEDED(rv), "Text content wasn't nsIContent!");
#ifdef DEBUG_FIND
        printf("Repositioned anchor node\n");
#endif
      }
#ifdef DEBUG_FIND
      printf("Ending a partial match; findex -> %d, mIterOffset -> %d\n",
             findex, mIterOffset);
#endif
    }
    matchAnchorNode = nsnull;
    matchAnchorOffset = 0;
    inWhitespace = false;
    pindex = (mFindBackward ? patLen : 0);
#ifdef DEBUG_FIND
    printf("Setting findex back to %d, pindex to %d\n", findex, pindex);
           
#endif
  } // end while loop

  // Out of nodes, and didn't match.
  ResetAll();
  return NS_OK;
}
Beispiel #28
0
void AntiSmokeBlocker::RT_ProcessOnTick ( float const curtime )
{
	METRICS_ENTER_SECTION ( "AntiSmokeBlocker::OnFrame" );

	SmokeListT::elem_t* it ( m_smokes.GetFirst () );

	// remove old smokes
	while( it != nullptr )
	{
		if( curtime - ( it->m_value.bang_time + ConfigManager::GetInstance ()->m_smoke_time ) > 0.0f )
			it = m_smokes.Remove ( it );
		else it = it->m_next;
	}

	ST_R_STATIC SmokeInfoT empty;
	ResetAll ( &empty );

	it = m_smokes.GetFirst ();
	if( it == nullptr ) return;

	// Test if players are immersed in smoke
	ProcessFilter::InTestsNoBot l1_filter;
	ProcessFilter::InTestsOrBot l2_filter;
	for( PlayerHandler::const_iterator ph ( &l1_filter ); ph != PlayerHandler::end (); ph+=&l1_filter )
	{
		SourceSdk::Vector delta, other_delta;

		MathInfo const & x_math ( MathCache::GetInstance ()->RT_GetCachedMaths ( ph.GetIndex () ) );

		do // At this stage, m_smokes ! empty
		{
			if( curtime - it->m_value.bang_time > ConfigManager::GetInstance ()->m_smoke_timetobang )
			{
				SourceSdk::vec_t dst;
				SourceSdk::VectorDistanceSqr ( x_math.m_eyepos, it->m_value.pos, delta, dst );
				if( dst < ConfigManager::GetInstance ()->m_innersmoke_radius_sqr )
				{
					GetPlayerDataStructByIndex ( ph.GetIndex () )->is_in_smoke = true;
				}

				/* Players can't see eachother if they are behind a smoke */

				const SourceSdk::vec_t ang_smoke ( tanf ( ConfigManager::GetInstance ()->m_smoke_radius / sqrtf ( dst ) ) );
				SourceSdk::VectorNorm ( delta );

				for( PlayerHandler::const_iterator other_ph ( &l2_filter ); other_ph != PlayerHandler::end (); other_ph+=&l2_filter )
				{
					if( ph == other_ph ) continue;

					MathInfo const & y_math ( MathCache::GetInstance ()->RT_GetCachedMaths ( other_ph.GetIndex () ) );

					// Is he behind the smoke against us ?

					SourceSdk::vec_t other_dst;
					SourceSdk::VectorDistanceSqr ( x_math.m_eyepos, y_math.m_abs_origin, other_delta, other_dst );
					if( dst + ConfigManager::GetInstance ()->m_smoke_radius < other_dst )
					{
						// Hidden by the hull of the smoke ?

						SourceSdk::VectorNorm ( other_delta );

						SourceSdk::vec_t dp;
						SourceSdk::VectorDotProduct ( other_delta, delta, dp );
						const SourceSdk::vec_t angle_player ( fabs ( acos ( dp ) ) );

						if( angle_player < ang_smoke )
						{
							GetPlayerDataStructByIndex ( ph.GetIndex () )->can_not_see_this_player[ other_ph.GetIndex () ] = true;
						}
					}
				}
			}
			it = it->m_next;
		}
		while( it != nullptr );
		it = m_smokes.GetFirst ();
	}

	METRICS_LEAVE_SECTION ( "AntiSmokeBlocker::OnFrame" );
}
void instance_violet_hold::SetData(uint32 uiType, uint32 uiData)
{
    debug_log("SD2: instance_violet_hold: SetData got type % u, data %u.", uiType, uiData);

    switch(uiType)
    {
        case TYPE_MAIN:
        {
            if (uiData == m_auiEncounter[0])
                return;

            switch(uiData)
            {
                case NOT_STARTED:
                    ResetAll();
                    break;
                case IN_PROGRESS:
                    
                    //DoUseDoorOrButton(m_uiSealDoorGUID); // is not working for unknown reason
                    if(pSealDoor)
                        pSealDoor->UseDoorOrButton();
                    UpdateWorldState();
                    m_uiPortalId = urand(0, 2);
                    m_uiPortalTimer = 15000;
                    break;
                case FAIL:
                    /*if (Creature* pSinclari = instance->GetCreature(m_uiSinclariGUID))
                        pSinclari->Respawn();
                        ResetAll();*/
                case DONE:
                    UpdateWorldState(false);
                    //DoUseDoorOrButton(m_uiSealDoorGUID);
                    if(pSealDoor)
                        pSealDoor->ResetDoorOrButton();
                    if(Creature* pDoorSeal = instance->GetCreature(m_uiSealDoorGUID))
                        pDoorSeal->ForcedDespawn();
                    break;
                case SPECIAL:
                    break;
            }
            m_auiEncounter[0] = uiData;
            break;
        }
        case TYPE_SEAL:
            m_auiEncounter[1] = uiData;
            if(uiData == SPECIAL && m_auiEncounter[TYPE_MAIN] == IN_PROGRESS) 
            {
                --m_uiWorldStateSealCount;
                if(Creature* pSinclari = instance->GetCreature(m_uiSinclariGUID))
                {
                    if(m_uiSealDmgSay==0 && m_uiWorldStateSealCount<=75)
                    {
                        ++m_uiSealDmgSay;
                        DoScriptText(SAY_SEAL_75,pSinclari);
                    }
                    else if(m_uiSealDmgSay==1 && m_uiWorldStateSealCount<=50)
                    {
                        ++m_uiSealDmgSay;
                        DoScriptText(SAY_SEAL_50,pSinclari);
                    }
                    else if(m_uiSealDmgSay==2 && m_uiWorldStateSealCount<=5)
                    {
                        ++m_uiSealDmgSay;
                        DoScriptText(SAY_SEAL_5,pSinclari);
                    }
                    UpdateWorldState();
                    if(m_uiWorldStateSealCount <= 0)
                        SetData(TYPE_MAIN,FAIL);
                }
            }
            break;
        case TYPE_PORTAL:
        {
            if(m_auiEncounter[TYPE_MAIN] == IN_PROGRESS)
                switch(uiData)
                {
                    case SPECIAL:                               // timer to next
                        m_uiPortalTimer = 90000;
                        break;
                    case DONE:                                  // portal done, set timer to 5 secs
                        m_uiPortalTimer = 5000;
                        break;
                }
            m_auiEncounter[2] = uiData;
            break;
        }
        case TYPE_EREKEM: 
        case TYPE_MORAGG:
        case TYPE_ICHORON:
        case TYPE_XEVOZZ:
        case TYPE_LAVANTHOR:
        case TYPE_ZURAMAT:
            m_auiEncounter[uiType] = uiData;
            if(uiData == DONE)
                m_uiPortalTimer = 20000;
            break;
        case TYPE_CYANIGOSA:
            m_auiEncounter[uiType] = uiData;
            if(uiType == DONE)
                SetData(TYPE_MAIN,DONE);
            break;
    }
    if (uiData == DONE)
    {
        //check if boss was completed
        for(int i = TYPE_EREKEM;i<TYPE_CYANIGOSA+1;i++)
            if(m_auiEncounter[i]==IN_PROGRESS || m_auiEncounter[i]==SPECIAL)
                return;

            OUT_SAVE_INST_DATA;

            std::ostringstream saveStream;

            for(uint8 i = 0; i < MAX_ENCOUNTER; ++i)
                saveStream << m_auiEncounter[i] << " ";

            m_strInstData = saveStream.str();

            SaveToDB();
            OUT_SAVE_INST_DATA_COMPLETE;
    }
}
Beispiel #30
0
void CdynControlDlg::OnBnClickedButton2()
{
    // TODO: Add your control notification handler code here
    ResetAll();
}