Esempio n. 1
0
		void Room::cacheProperties(const Hashtable& properties)
		{
			if(properties.contains(static_cast<nByte>(Properties::Room::MAX_PLAYERS)))
				mMaxPlayers = ValueObject<nByte>(properties.getValue(static_cast<nByte>(Properties::Room::MAX_PLAYERS))).getDataCopy();

			if(properties.contains(static_cast<nByte>(Properties::Room::IS_OPEN)))
				mIsOpen = ValueObject<bool>(properties.getValue(static_cast<nByte>(Properties::Room::IS_OPEN))).getDataCopy();

			if(properties.contains(static_cast<nByte>(Properties::Room::PLAYER_COUNT)))
				mPlayerCount = ValueObject<nByte>(properties.getValue(static_cast<nByte>(Properties::Room::PLAYER_COUNT))).getDataCopy();

			mCustomProperties.put(Utils::stripToCustomProperties(properties));
			mCustomProperties = Utils::stripKeysWithNullValues(mCustomProperties);
		}
Esempio n. 2
0
void LoadBalancingListener::afterRoomJoined(int localPlayerNr)
{
	mpView->info( "afterRoomJoined: localPlayerNr=", localPlayerNr );
	this->mLcalPlayerNr = localPlayerNr;
	MutableRoom& myRoom = mpLbc->getCurrentlyJoinedRoom();
	Hashtable props = myRoom.getCustomProperties();
	updateGridSize(props);
	if(props.contains("m"))
		mMap = ((ValueObject<JString>*)props.getValue("m"))->getDataCopy();

	mpView->initPlayers();
	mpView->setupScene(mGridSize);

	const JVector<Player*>& players = myRoom.getPlayers();
	for(unsigned int i=0; i<players.getSize(); ++i)
	{
		const Player* p = players[i];
		mpView->addPlayer(p->getNumber(), p->getName().UTF8Representation().cstr(), p->getNumber() == mpLbc->getLocalPlayer().getNumber());
	}
	mpView->changePlayerColor(localPlayerNr, mLocalPlayer.color);
	raiseColorEvent();
}
		void MutableRoom::cacheProperties(const Hashtable& properties)
		{
			if(properties.contains(static_cast<nByte>(Properties::Room::IS_VISIBLE)))
				mIsVisible = ValueObject<bool>(properties.getValue(static_cast<nByte>(Properties::Room::IS_VISIBLE))).getDataCopy();
			super::cacheProperties(properties);
		}