Exemplo n.º 1
0
//-------------------------------------------------------------------------------------
void EntityIDClient::onAlloc(void)
{
	if(getSize() > id_enough_limit)
	{
		setReqServerAllocFlag(false);
		return;
	}
	
	if(hasReqServerAlloc())
		return;

	Mercury::Channel* pChannel = Components::getSingleton().getDbmgrChannel();

	if(pChannel == NULL)
	{
		ERROR_MSG("EntityIDClient::onAlloc: not found dbmgr!\n");
		return;
	}

	Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
	(*pBundle).newMessage(DbmgrInterface::onReqAllocEntityID);
	DbmgrInterface::onReqAllocEntityIDArgs2::staticAddToBundle((*pBundle), pApp_->componentType(), pApp_->componentID());
	(*pBundle).send(pApp_->networkInterface(), pChannel);
	Mercury::Bundle::ObjPool().reclaimObject(pBundle);

	setReqServerAllocFlag(true);

	WARNING_MSG(boost::format("EntityIDClient::onAlloc: not enough(%1%) entityIDs!\n") % id_enough_limit);
}
Exemplo n.º 2
0
//-------------------------------------------------------------------------------------
void EntityIDClient::onAlloc(void)
{
	if(size() > id_enough_limit)
	{
		setReqServerAllocFlag(false);
		return;
	}
	
	if(hasReqServerAlloc())
		return;

	Network::Channel* pChannel = Components::getSingleton().getDbmgrChannel();

	if(pChannel == NULL)
	{
		ERROR_MSG("EntityIDClient::onAlloc: not found dbmgr!\n");
		return;
	}

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();
	(*pBundle).newMessage(DbmgrInterface::onReqAllocEntityID);
	DbmgrInterface::onReqAllocEntityIDArgs2::staticAddToBundle((*pBundle), pApp_->componentType(), pApp_->componentID());
	pChannel->send(pBundle);

	setReqServerAllocFlag(true);

	WARNING_MSG(fmt::format("EntityIDClient::onAlloc: not enough({}) entityIDs!\n", id_enough_limit));
}
Exemplo n.º 3
0
//-------------------------------------------------------------------------------------
void EntityIDClient::onAlloc(void)
{
	if(hasReqServerAlloc() || getSize() > ID_ENOUGH_LIMIT || idList_.size() > 0)
		return;
	
	Mercury::Bundle bundle;
	bundle.newMessage(DbmgrInterface::onReqAllocEntityID);
	DbmgrInterface::onReqAllocEntityIDArgs2::staticAddToBundle(bundle, pApp_->componentType(), pApp_->componentID());

	Components::COMPONENTS cts =  Components::getSingleton().getComponents(DBMGR_TYPE);
	KBE_ASSERT(cts.size() > 0);
	Components::ComponentInfos* cinfos = &(*cts.begin());
	KBE_ASSERT(cinfos->pChannel != NULL);

	bundle.send(pApp_->getNetworkInterface(), cinfos->pChannel);
	ERROR_MSG("EntityIDClient::onAlloc: not enough(%d) entityIDs!\n", ID_ENOUGH_LIMIT);
}