コード例 #1
0
ファイル: Room.cpp プロジェクト: dyf303/Landlord
void Room::Update(const uint32 diff)
{
	for (PlayerMapType::iterator itr = _playerMap.begin(),next; itr != _playerMap.end(); itr = next)
	{
		next = itr;
		next++;
		Player* player = itr->second;

		player->Update(diff);

		if (player->LogOut())
		{
			if (!player->inTheGame())
			{
				_playerMap.erase(itr);
				if (player->idle())
					delete player;
			}	
			continue;
		}
		if (player->getGameStatus() == GAME_STATUS_STARTED && player->getQueueFlags() == QUEUE_FLAGS_NULL)
		{
		   player->setQueueFlags(QUEUE_FLAGS_ONE);
		   _OnePlayerList.push_back(player);
		}		
	}
	UpdateOne(diff);
	UpdateTwo(diff);
	UpdateThree(diff);
}
コード例 #2
0
ファイル: DataBaseManager.cpp プロジェクト: wfmdyh/wecan
//存储大表数据
BOOL CDataBaseManager::UpdateBigMeterData(vector<CGPRSBigMeter> vecBigMeters)
{
	BOOL bResult = TRUE;
	wostringstream wss;
	wss << L"当前大表设备数量:";
	wss << vecBigMeters.size();
	wss << L"\n";
	wstring strMsg = wss.str();
	OutputDebugString(strMsg.c_str());

	//vector<CGPRSBigMeter> vecSave;
	//需要保存只有更新过的数据才进行存储
	vector<CGPRSBigMeter>::iterator ite = vecBigMeters.begin();
	for (; ite != vecBigMeters.end(); ite++)
	{
		vector<CGPRSBigMeter>::iterator iteNewMeter = find_if(m_listMeters.begin(), m_listMeters.end(), MeterCompare(ite->GetDeviceID()));
		if (iteNewMeter == m_listMeters.end())
		{
			//新设备
			m_listMeters.push_back(*ite);
			UpdateOne(*ite);
		}
		else{
			//判断时间戳是否改变过,改变则存储
			time_t tNew = ite->GetLastTime();
			time_t tOld = iteNewMeter->GetLastTime();
			if (tNew > tOld)
			{
				UpdateOne(*ite);
				iteNewMeter->SetLastTime(tNew);
			}
		}
	}

	return bResult;
}