/*-----------------------------------------------------------------------*/
void GRGameParser::parseGameRoomsList(GR_PACKET *Packet)
{
	wxUint8 *buf;
	wxUint32 gameCount;
	wxUint32 x;
	GRGameRoom *gameRoom;
	parseGameReturn *ret;
	GRGameManager *gameManager = conn->getGameManager();

	buf = Packet->payload;

	/* game room count */
	memcpy(&gameCount, buf, sizeof(wxUint32));
	gameCount = ntohl(gameCount);
	buf += sizeof(wxUint32);

	/* clear game rooms */
	gameManager->clearAll();

	/* add game rooms */
	for(x = 0; x < gameCount; x++)
	{
		ret = parseGame(buf);
		gameManager->addRoom(ret->gameRoom);
		buf = ret->ptr;
		delete(ret);
	}
}
Beispiel #2
0
RenJS::Result
RenJS::addGame(const CString& strFile)
{
	CFileException e;

	if (!mGameFile.Open(strFile, CFile::modeRead, &e))
	{
		mResult = OPEN_FILE_ERROR;
	}
	else
	{
		try
		{
			parseGame();

			if (mMoves.size() == 0)
			{
				mResult = EMPTY_ERROR;
			}
		}
		catch (Exception e)
		{
			mResult = e.getErrorCause();
		}

		mGameFile.Close();
	}

	if (mResult == VALID)
	{
		mResult = CheckMoves();
	}

	return mResult;
}
/*--------------------------------------------------------------------------------*/
void GRGameParser::parseGameRoomOpened(GR_PACKET *Packet)
{
	wxUint8 *buf;
	GRGameRoom *gameRoom;
	parseGameReturn *ret;

	buf = Packet->payload;

	ret = parseGame(buf);
	gameRoom = ret->gameRoom;
	delete(ret);

	conn->getGameManager()->addRoomAndNotify(gameRoom);
}