Exemplo n.º 1
0
void LoadBalancingListener::onRoomListUpdate()
{	
	const JVector<Room*>& rooms = mpLbc->getRoomList();
	const char** names = MemoryManagement::allocateArray<const char*>(rooms.getSize());
	for(unsigned int i=0; i<rooms.getSize(); ++i) 
	{
		const Room* r = rooms.getElementAt(i);
		UTF8String u = r->getName();
		const char* name = u.cstr();
		char* tmp = MemoryManagement::allocateArray<char>(strlen(name) + 1);
		strcpy(tmp, name);
		names[i] = tmp;
	}
	mpView->updateRoomList(names, rooms.getSize());
	for(unsigned int i = 0; i < rooms.getSize();++i) 
		MemoryManagement::deallocateArray(names[i]);
	MemoryManagement::deallocateArray(names);
}
Exemplo n.º 2
0
// updates state bar and game message
void Game::refreshInfo()
{
    if(lbl->getClient()->getIsInGameRoom()) // put some additional info in state bar
	{
		const int INFO_SIZE = 1024;
		char info[INFO_SIZE];
		int otherNr = lbl->getNextPlayer(myActorNr());
		if(otherNr == myActorNr())
			otherNr = 0;
		bool otherInactive = false;
		if(otherNr)
		{
			const ExitGames::LoadBalancing::Player* o = lbl->getClient()->getCurrentlyJoinedRoom().getPlayerForNumber(otherNr);
			otherInactive = o && o->getIsInactive();
		}
		const int OTHER_STR_SIZE = 20;
		char otherStr[OTHER_STR_SIZE];
		if(otherNr)
			sprintf(otherStr, "%d", otherNr);
		else
			sprintf(otherStr, "%s", "?");
		sprintf(info, "%s, %d vs. %s%s%s, sc: %d/%d, t: %d",
			lbl->getClient()->getCurrentlyJoinedRoom().getName().UTF8Representation().cstr(),
			myActorNr(),
			otherInactive ? "(" : "",
			otherStr,
			otherInactive ? ")" : "",
			myPoints, othersPoints, nextTurnPlayer
			);
		view->refreshStateInfo(info);
	}
	else
		view->refreshStateInfo(NULL);
        		
	UTF8String msg = renderMessage();
	view->refreshMessage(msg.cstr());
}