// return the next event delay in ms
uint32 GameEventMgr::Update(ActiveEvents const* activeAtShutdown /*= nullptr*/)
{
    time_t currenttime = time(nullptr);

    uint32 nextEventDelay = max_ge_check_delay;             // 1 day
    uint32 calcDelay;
    for (uint16 itr = 1; itr < mGameEvent.size(); ++itr)
    {
        if (mGameEvent[itr].occurence == 0)
            continue;
        // sLog.outErrorDb("Checking event %u",itr);
        if (CheckOneGameEvent(itr, currenttime))
        {
            // DEBUG_LOG("GameEvent %u is active",itr->first);
            if (!IsActiveEvent(itr))
            {
                if (mGameEvent[itr].linkedTo == 0 || IsActiveEvent(mGameEvent[itr].linkedTo))
                {
                    bool resume = activeAtShutdown && (activeAtShutdown->find(itr) != activeAtShutdown->end());
                    StartEvent(itr, false, resume);
                }
            }
        }
        else
        {
            // DEBUG_LOG("GameEvent %u is not active",itr->first);
            if (IsActiveEvent(itr))
            {
                StopEvent(itr);
                if (mGameEvent[itr].linkedTo != 0)
                    StopEvent(mGameEvent[itr].linkedTo);
            }
            else
            {
                if (!m_IsGameEventsInit)
                {
                    int16 event_nid = (-1) * (itr);
                    // spawn all negative ones for this event
                    GameEventSpawn(event_nid);
                    UpdateWorldStates(itr, false);
                }
            }
        }
        calcDelay = NextCheck(itr);
        if (calcDelay < nextEventDelay)
            nextEventDelay = calcDelay;
    }
    BASIC_LOG("Next game event check in %u seconds.", nextEventDelay + 1);
    return (nextEventDelay + 1) * IN_MILLISECONDS;          // Add 1 second to be sure event has started/stopped at next call
}
Example #2
0
uint32 GameEvent::Update()                                  // return the next event delay in ms
{
    uint32 nextEventDelay = max_ge_check_delay;             // 1 day
    uint32 calcDelay;
    for (uint16 itr = 1; itr < mGameEvent.size(); ++itr)
    {
        //sLog.outErrorDb("Checking event %u",itr);
        if (CheckOneGameEvent(itr))
        {
            //sLog.outDebug("GameEvent %u is active",itr->first);
            if (!IsActiveEvent(itr))
                StartEvent(itr);
        }
        else
        {
            //sLog.outDebug("GameEvent %u is not active",itr->first);
            if (IsActiveEvent(itr))
                StopEvent(itr);
            else
            {
                if (!isSystemInit)
                {
                    int16 event_nid = (-1) * (itr);
                    // spawn all negative ones for this event
                    GameEventSpawn(event_nid);
                }
            }
        }
        calcDelay = NextCheck(itr);
        if (calcDelay < nextEventDelay)
            nextEventDelay = calcDelay;
    }
    sLog.outBasic("Next game event check in %u seconds.", nextEventDelay + 1);
    return (nextEventDelay + 1) * 1000;                     // Add 1 second to be sure event has started/stopped at next call
}
Example #3
0
//.event reload
bool ChatHandler::HandleEventReloadAllEvents(const char* /*args*/, WorldSession* m_session)
{
    SystemMessage(m_session, "Beginning reload of all game events");
    auto start = time(0);
    // Wait for GameEventMgr thread to stop
    if (!sGameEventMgrThread.Pause())
        return false;

    // Stop all events, then clear storage
    for (auto eventPair : sGameEventMgr.mGameEvents)
    {
        auto gameEvent = eventPair.second;
        gameEvent->StopEvent();
        delete gameEvent;
    }

    // Clear game events
    sGameEventMgr.mGameEvents.clear();

    // Reload events from DB
    sGameEventMgr.LoadFromDB();

    // Restart GameEventMgr thread
    sGameEventMgrThread.Resume();

    SystemMessage(m_session, "Reloaded all game events in %u ms", time(0)-start);
    return true;
}
bool CheckerboardEvent::RecordFrameInfo(uint32_t aCssPixelsCheckerboarded) {
  TimeStamp sampleTime = TimeStamp::Now();
  bool eventEnding = false;
  if (aCssPixelsCheckerboarded > 0) {
    if (!mCheckerboardingActive) {
      StartEvent();
    }
    MOZ_ASSERT(mCheckerboardingActive);
    MOZ_ASSERT(sampleTime >= mLastSampleTime);
    mTotalPixelMs +=
        (uint64_t)((sampleTime - mLastSampleTime).ToMilliseconds() *
                   aCssPixelsCheckerboarded);
    if (aCssPixelsCheckerboarded > mPeakPixels) {
      mPeakPixels = aCssPixelsCheckerboarded;
    }
    mFrameCount++;
  } else {
    if (mCheckerboardingActive) {
      StopEvent();
      eventEnding = true;
    }
    MOZ_ASSERT(!mCheckerboardingActive);
  }
  mLastSampleTime = sampleTime;
  return eventEnding;
}
Example #5
0
void AIBrainState::ClearEvents()
{
	//stop and delete events
	for( unsigned int i = 0; i < _eventList.size(); i++ )
	{
		StopEvent( _eventList[i]);
	}
	_eventList.clear();
}
Example #6
0
void AIBrainState::UnregisterEvent( AIEvent* oldEvent )
{
	for( EventList::iterator itr = _eventList.begin(); itr != _eventList.end(); itr++ )
	{
		if( (*itr) == oldEvent )
		{
			_eventList.erase( itr );
			StopEvent( oldEvent );
			return;
		}
	}
}
Example #7
0
uint32 GameEventMgr::Update()                               // return the next event delay in ms
{
    uint32 nextEventDelay = max_ge_check_delay;             // 1 day
    uint32 calcDelay;
    for (uint16 itr = 1; itr < mGameEvent.size(); ++itr)
    {
        //sLog.outErrorDb("Checking event %u",itr);
        if (CheckOneGameEvent(itr))
        {
            //DEBUG_LOG("GameEvent %u is active",itr->first);
            if (!IsActiveEvent(itr))
                StartEvent(itr);
        }
        else
        {
            //DEBUG_LOG("GameEvent %u is not active",itr->first);
            if (IsActiveEvent(itr))
                StopEvent(itr);
            else
            {
                if (!m_IsGameEventsInit)
                {
                    int16 event_nid = (-1) * (itr);
                    // spawn all negative ones for this event
                    GameEventSpawn(event_nid);

                    // disable any event specific quest (for cases where creature is spawned, but event not active).
                    UpdateEventQuests(itr, false);
                    UpdateWorldStates(itr, false);
                }
            }
        }
        calcDelay = NextCheck(itr);
        if (calcDelay < nextEventDelay)
            nextEventDelay = calcDelay;
    }
    BASIC_LOG("Next game event check in %u seconds.", nextEventDelay + 1);
    return (nextEventDelay + 1) * IN_MILLISECONDS;           // Add 1 second to be sure event has started/stopped at next call
}
Example #8
0
//.event stop
bool ChatHandler::HandleEventStopEvent(const char* args, WorldSession* m_session)
{
    uint32 eventid = atoi(args);
    if (eventid == 0)
    {
        SystemMessage(m_session, "Invalid argument: %s", args);
        return false;
    }

    for (auto eventPair : sGameEventMgr.mGameEvents)
    {
        auto gameEvent = eventPair.second;
        if (gameEvent->event_id == eventid)
        {
            SystemMessage(m_session, "Force stopping event %u (%s)", gameEvent->event_id, gameEvent->description.c_str());
            gameEvent->StopEvent(true);
            return true;
        }
    }

    SystemMessage(m_session, "Game event with ID %u not found", eventid);
    return false;
}
Example #9
0
int main(int argc, char **argv)
{
	unsigned short grafboard;
	extern int disk_error_handler(int errval, int ax, int bp, int si);
   char *p;

	allocatebuffers();
	if (init_mem_err)
   {
      cprintf("\r\n\r\nSorry, not enough memory to run Toy Universes.\r\n");
      return -1;
   }

	harderr(disk_error_handler);

	/* Find out if we have a VGA or EGA at all. */

	grafboard = QueryGrafix();


	if ((grafboard & 0x200) != 0x200)
	{
		printf("This programs requires EGA capability.\n");
		exit(-1);
	}

	if (grafboard == 0xffff || InitGrafix(-EGA640x350) < 0)
	{
		printf("Metagraphics not installed. Execute the command:\n");
		printf("metashel /i\n");
		printf("and then try again.\n");
		exit(-1);
	}

	vgaflag = -1;

	while (argc > 1)
	{
		if (argv[1][0] == '-')
		{
			switch (argv[1][1])
			{
			case 'e':
				vgaflag = 0;
				break;
         case 'v':
	    vgaflag = 1;
	    break;
			}
		}
		argc--;
		argv++;
	}

	if (vgaflag == -1)
	{
		if ((grafboard & 0x300) == 0x300)
			vgaflag = 1;
		else
			vgaflag = 0;
	}



	Comm = QueryComm();
	if (Comm == MsDriver)
		InitMouse(MsDriver);
	else if (Comm == MsCOM1)
		InitMouse(MsCOM1);
	else if (Comm == MsCOM2)
		InitMouse(MsCOM2);
	else if (Comm & 3)
		InitMouse(COM1);
	/*
	 * Probably wrong. Need to check for MS mouse address in some special
	 * way.
	 */


	randomize();


   p = searchpath("system16.fnt");
   if (p)
      LoadFont(p);
	installmode();

	load_preset_palettes();

	usepalette();

	current_main_item = 0;

	usepalette();
   TWICE(initialize_buttons());

	ShowCursor();
   if (allocatefailflag)
      ErrorBox("Not enough memory for hi-res.");

   /* Lets see if there is enough for a later gif */
   if (!memok(20712L))		    /* Added up mallocs in comprs.c */
           ErrorBox("There may not be enough memory to save or view a Gif.");


   prog_init = 1;

   if (!setjmp(beatit))
   {

	   while (!exitflag)
	   {

		   rebuildflag = 0;

		   if (newcaflag && !donescreenflag)
		   {
			   loadlookuptable(increment, maxstate);
			   newcaflag = 0;
		   }

		   if (newcaoflag)
		   {
	    unsigned char *p1,*p2;
	    static int firsttime = true;

	    switch(caotype)
	    {
	    case CA_HODGE:
	       p1 = (char *)HODGE_colortable;
	       p2 = HODGE_ct;
	       break;
	    case CA_EAT:
	       p1 = (char *)EAT_colortable;
	       p2 = EAT_ct;
	       break;
	    case CA_TUBE:
	       p1 = (char *)TUBE_colortable;
	       p2 = TUBE_ct;
	       break;
	    case CA_NLUKY:
	       p1 = (char *)NLUKY_colortable;
	       p2 = NLUKY_ct;
	       break;
	    }
	    memcpy(vgacolortable,p1,16*3);
	    if (!hasVGA)
	       memcpy(egacolortable,p2,16);


			   if (!firsttime)
	    {
	       TWICE(initialize_numbers());
	    }
	    else
	       firsttime = false;
			   usepalette();


			   newcaoflag = 0;
	    current_main_item = -1;
		   }

		   if (blankflag)
		   {
			   blankbuffers();
			   blankflag = 0;
		   }
		   if (randomizeflag)
		   {
			   carandomize();
			   randomizeflag = 0;
		   }
		   while (!exitflag && !rebuildflag)
		   {

			   if (onestep || !stopped)
			   {
				   if (display_mode == HI)
					   hiresupdate();
				   else
					   loresupdate();
				   if (onestep)
					   onestep--;

			   }
			   if (spinflag && (!stopped || (iteration++ > spinspeed)))
			   {
				   if (spinflag == 1)
					   spinpalette();
				   else
					   revspinpalette();
               iteration = 0;
			   }
			   checkkeyboard();

			   if (newcaflag)
				   rebuildflag = 1;
		   }
	   }
   }
	StopMouse();
	StopEvent();
	grayflag = 0;
	grayscale();
	SetDisplay(TextPg0);
	return exitflag;

}