Esempio n. 1
0
void
World::SendWorldText(const char* text, WorldSession *self)
{
    WorldPacket data;
    sChatHandler.FillSystemMessageData(&data, 0, text);
    SendGlobalMessage(&data, self);
}
Esempio n. 2
0
void CComponentManager::PostMessage(entity_id_t ent, const CMessage& msg)
{
	PROFILE2_IFSPIKE("Post Message", 0.0005);
	PROFILE2_ATTR("%s", msg.GetScriptHandlerName());
	// Send the message to components of ent, that subscribed locally to this message
	std::map<MessageTypeId, std::vector<ComponentTypeId> >::const_iterator it;
	it = m_LocalMessageSubscriptions.find(msg.GetType());
	if (it != m_LocalMessageSubscriptions.end())
	{
		std::vector<ComponentTypeId>::const_iterator ctit = it->second.begin();
		for (; ctit != it->second.end(); ++ctit)
		{
			// Find the component instances of this type (if any)
			std::map<ComponentTypeId, std::map<entity_id_t, IComponent*> >::const_iterator emap = m_ComponentsByTypeId.find(*ctit);
			if (emap == m_ComponentsByTypeId.end())
				continue;

			// Send the message to all of them
			std::map<entity_id_t, IComponent*>::const_iterator eit = emap->second.find(ent);
			if (eit != emap->second.end())
				eit->second->HandleMessage(msg, false);
		}
	}

	SendGlobalMessage(ent, msg);
}
Esempio n. 3
0
void
World::SendWorldString(std::string text)
{
	WorldSession *self = 0;
    WorldPacket data;
	sChatHandler.FillSystemMessageData(&data, 0, text.c_str());
    SendGlobalMessage(&data, self);
}
Esempio n. 4
0
void
World::SendWorldWideText(const char* text, WorldSession *self)
{
	WorldPacket data;
	data.Initialize(SMSG_AREA_TRIGGER_MESSAGE);
	data << (uint32)0 << text << (uint8)0x00;
    SendGlobalMessage(&data, self);
}
Esempio n. 5
0
void World::ShuttDownMsg()
{
    WorldPacket data;

    data.Initialize(SMSG_SERVER_MESSAGE);

    std::ostringstream ss;
    ss << m_ShutdownTimer << " Second(s).";

    data << uint32(1) << ss.str().c_str() << (uint8)0x00;

    SendGlobalMessage( &data );

    data.clear();
    ss.clear();

    DEBUG_LOG("Server is shuttingdown in %d seconds",m_ShutdownTimer);
}
Esempio n. 6
0
void CComponentManager::BroadcastMessage(const CMessage& msg) const
{
	// Send the message to components of all entities that subscribed locally to this message
	std::map<MessageTypeId, std::vector<ComponentTypeId> >::const_iterator it;
	it = m_LocalMessageSubscriptions.find(msg.GetType());
	if (it != m_LocalMessageSubscriptions.end())
	{
		std::vector<ComponentTypeId>::const_iterator ctit = it->second.begin();
		for (; ctit != it->second.end(); ++ctit)
		{
			// Find the component instances of this type (if any)
			std::map<ComponentTypeId, std::map<entity_id_t, IComponent*> >::const_iterator emap = m_ComponentsByTypeId.find(*ctit);
			if (emap == m_ComponentsByTypeId.end())
				continue;

			// Send the message to all of them
			std::map<entity_id_t, IComponent*>::const_iterator eit = emap->second.begin();
			for (; eit != emap->second.end(); ++eit)
				eit->second->HandleMessage(msg, false);
		}
	}

	SendGlobalMessage(INVALID_ENTITY, msg);
}
Esempio n. 7
0
void
World::ShuttingDownMsg()
{
	if(m_ShutdownTimer <= 0)
		raise(SIGINT);
	char msg[256];
	std::stringstream ss;
	WorldPacket data;

	sprintf((char*)msg, "[Server] Shutdown in %d seconds", m_ShutdownTimer);
	SendWorldWideText( msg );

	data.Initialize(SMSG_SERVER_MESSAGE);
	ss << m_ShutdownTimer << " Second(s).";
	data << uint32(1) << ss.str().c_str() << (uint8)0x00;
	SendGlobalMessage( &data );

	data.clear();
	ss.clear();

	sLog.outColor(3);
	sLog.outString("[Server] Shutdown in %d seconds...\n", m_ShutdownTimer);
	sLog.outColor(2);
}
Esempio n. 8
0
void CArchonProcess::Run (void)

//	Run
//
//	This thread will start all engines and continue running
//	until all engines stop.

	{
	int i;

	if (m_bDebugger)
		DebugBreak();

	//	If we could not boot properly, then we stop

	if (m_iState == stateBootError)
		return;

	//	Set event indicating that thread should run

	m_RunEvent.Set();

	//	Start some threads

	m_ImportThread.Start();

	//	Start all engines. At this point we have multiple threads
	//	potentially calling on the IArchonProcessCtx interface
	//
	//	This allows the engines to start at least one thread.
	//	LATER: Catch errors.

	for (i = 0; i < m_Engines.GetCount(); i++)
		m_Engines[i].pEngine->StartRunning(m_RunEvent, m_PauseEvent, m_QuitEvent);

	//	Do stuff now that the module has started

	OnModuleStart();

	//	At this point it is safe to call the logging system

	if (m_bCentralModule)
		Log(MSG_LOG_INFO, STR_CENTRAL_MODULE_STARTED);
	else if (!m_bConsoleMode)
		Log(MSG_LOG_INFO, STR_BOOT_COMPLETE);

	//	If we've in console mode, then run the input loop.

	CConsoleThread Console(this);
	if (m_bConsoleMode)
		Console.Start();

	//	Loop until we quit. We stop every so often to do clean up
	//	tasks such as garbage collection.

	CWaitArray Wait;
	int QUIT_SIGNAL = Wait.Insert(m_QuitSignalEvent);

	while (true)
		{
		int iEvent = Wait.WaitForAny(15000);
		if (iEvent == QUIT_SIGNAL)
			break;
		else if (iEvent == OS_WAIT_TIMEOUT)
			{
			if (m_bConsoleMode)
				Console.OnStartHousekeeping();

			CollectGarbage();
			SendGlobalMessage(MSG_ARC_HOUSEKEEPING);

			if (m_bConsoleMode)
				Console.OnEndHousekeeping();
			}
		}

	//	Some engines still need an explicit call (because they don't have
	//	their own main thread).

	for (i = 0; i < m_Engines.GetCount(); i++)
		m_Engines[i].pEngine->SignalShutdown();

	//	Signal the engines to quit

	m_QuitEvent.Set();

	//	We wait until all engines have been shut down

	for (i = 0; i < m_Engines.GetCount(); i++)
		m_Engines[i].pEngine->WaitForShutdown();

	//	Done

	Shutdown();
	}