コード例 #1
0
void GameClient::StartRequest(PacketFunctions& Packet)
{
	int firstbyte = Packet.Read1();
	int secondbyte = Packet.Read1();
	int thirdbyte = Packet.Read1();
	Player[0].feet = firstbyte/16;
	Player[1].feet = firstbyte%16;

	if ((Player[0].feet > 0)&&(Player[1].feet > 0))
		twoPlayers = true;

	Player[0].diff = secondbyte/16;
	Player[1].diff = secondbyte%16;

	startPosition = thirdbyte/16;
	gameInfo.title = Packet.ReadNT();
	gameInfo.subtitle = Packet.ReadNT();
	gameInfo.artist = Packet.ReadNT();
	gameInfo.course = Packet.ReadNT();

	for (int x = 0; x < 2; ++x)
	 {
		Player[x].score = 0;
		Player[x].combo = 0;
		Player[x].projgrade = 0;
		Player[x].maxCombo = 0;

		memset(Player[x].steps, 0, sizeof(int)*9);
	}

	GotStartRequest = true;
}
コード例 #2
0
ファイル: SMOnlineRoom.cpp プロジェクト: freem/SMOnline-v1
void SMOnlineRoom::SMOnlineParse(PacketFunctions &Packet, int clientnum) {
    int command = Packet.Read1();
    switch (command) {
    case 0:
        //Login
        break;
    case 1:
        //Change Room
    {
        int command = Packet.Read1();
        MString title = Packet.ReadNT();
        MString pw = Packet.ReadNT();
        ChangeRoom(command, title, clientnum, pw);
    }
    break;
    case 2:
        //Create new room
        if (m_allowgamerooms) {
            CreateRoom(Packet);
            ChangeRoom(1, m_joinrooms[m_joinrooms.size()-1]->GetTitle(), clientnum, "", true);
        }
        break;
    case 3:
        //Additional room info
        GenAdditionalInfo(Packet.ReadNT(), clientnum);
        break;
    default:
        LOG->Write(ssprintf("Invalid SMOnline command:%d", command));
        break;
    }
}
コード例 #3
0
void GameClient::StyleUpdate(PacketFunctions& Packet)
{
	int playernumber = 0;
	Player[0].name = Player[1].name = "";
	twoPlayers = Packet.Read1()-1;
	for (int x = 0; x < twoPlayers+1; ++x)
	{
		playernumber = Packet.Read1();
		Player[playernumber].name = Packet.ReadNT();
	}
}
コード例 #4
0
void StepManiaLanServer::ScreenNetMusicSelectStatus(PacketFunctions& Packet, unsigned int clientNum)
{
	CString message = "";
	int EntExitCode = Packet.Read1();

	message += Client[clientNum]->Player[0].name;
	if (Client[clientNum]->twoPlayers)
		message += "&";
	message += Client[clientNum]->Player[1].name;

	if (EntExitCode % 2 == 1)
		Client[clientNum]->inNetMusicSelect = true;
	else
		Client[clientNum]->inNetMusicSelect = false;

	switch (EntExitCode)
	{
	case 0:
		message += " left the song selection.";
		break;
	case 1:
		message += " entered the song selection.";
		break;
	case 2:
		message += " went into options.";
		break;
	case 3:
		message += " came back from options.";
		break;
	}
	ServerChat(message);
}
コード例 #5
0
ファイル: SMOnlineRoom.cpp プロジェクト: freem/SMOnline-v1
void SMOnlineRoom::CreateRoom(PacketFunctions& Packet) {
    bool origional_name = true;
    SMOnlineRoom* tmp = NULL;
    int type = Packet.Read1();
    MString title = Packet.ReadNT();
    MString sub = Packet.ReadNT();
    MString passwd = Packet.ReadNT();

    if (!title.empty())
    {
        if (title.size() > m_roomNameLength)
            title = title.substr(0, m_roomNameLength);

        for (unsigned int x = 0; (x < m_joinrooms.size()) && origional_name; ++x)
            if (title == m_joinrooms[x]->m_title)
                origional_name = false;

        if (origional_name) {
            if (type) {
                tmp = new SMOnlineGameRoom(title, sub);
            } else {
                tmp = new SMOnlineRoom(title, sub);
            }

            if (tmp) {
                LOG->Write("Created room");
                if (!passwd.empty())
                    tmp->m_passwd = passwd;
                SERVER->GetRooms().push_back(tmp);
                JoinToRoom(tmp);
                SendRoomList();
            }
        }
    }
}
コード例 #6
0
void GameClient::UpdateStats(PacketFunctions& Packet)
{
	//Get the Stats from a packet
	char firstbyte = Packet.Read1();
	char secondbyte = Packet.Read1();
	int pID = int(firstbyte/16); /* MSN */

	Player[pID].currstep = int(firstbyte%16); /* LSN */
	Player[pID].projgrade = int(secondbyte/16);
	Player[pID].score = Packet.Read4();
	Player[pID].combo = Packet.Read2();

	if (Player[pID].combo > Player[pID].maxCombo)
		Player[pID].maxCombo = Player[pID].combo;

	Player[pID].health = Packet.Read2();
	Player[pID].offset = ((double)abs(int(Packet.Read2())-32767)/2000);
	Player[pID].steps[Player[pID].currstep]++;
}
コード例 #7
0
void StepManiaLanServer::ParseData(PacketFunctions& Packet, const unsigned int clientNum)
{
	int command = Packet.Read1();
	switch (command)
	{
	case NSCPing:
		// No Operation
		SendValue(NSServerOffset + NSCPingR, clientNum);
		break;
	case NSCPingR:
		// No Operation response
		break;
	case NSCHello:
		// Hello
		Hello(Packet, clientNum);
		break;
	case NSCGSR:
		// Start Request
		Client[clientNum]->StartRequest(Packet);
		CheckReady();  //This is what ACTUALLY starts the games
		break;
	case NSCGON:
		// GameOver 
		GameOver(Packet, clientNum);
		break;
	case NSCGSU:
		// StatsUpdate
		Client[clientNum]->UpdateStats(Packet);
		if (!Client[clientNum]->lowerJudge)
			CheckLowerJudge(clientNum);
		break;
	case NSCSU:
		// Style Update
		Client[clientNum]->StyleUpdate(Packet);
		SendUserList();
		break;
	case NSCCM:
		// Chat message
		AnalizeChat(Packet, clientNum);
		break;
	case NSCRSG:
		SelectSong(Packet, clientNum);
		break;
	case NSCSMS:
		ScreenNetMusicSelectStatus(Packet, clientNum);
		break;
	case NSCUPOpts:
		Client[clientNum]->Player[0].options = Packet.ReadNT();		
		Client[clientNum]->Player[1].options = Packet.ReadNT();		
		break;
	default:
		break;
	}
}	 
コード例 #8
0
ファイル: NetworkSyncServer.cpp プロジェクト: BitMax/openitg
void StepManiaLanServer::ScreenNetMusicSelectStatus(PacketFunctions& Packet, unsigned int clientNum)
{
	CString message = "";
	int EntExitCode = Packet.Read1();

	message += Client[clientNum]->Player[0].name;
	if (Client[clientNum]->twoPlayers)
		message += "&";
	message += Client[clientNum]->Player[1].name;

	if (EntExitCode % 2 == 1)
		Client[clientNum]->inNetMusicSelect = true;
	else
		Client[clientNum]->inNetMusicSelect = false;

	GameClient::LastNetScreen LastScreenInfo = GameClient::NS_NOWHERE;

	switch (EntExitCode)
	{
	case 0:
		message += " left the song selection.";
		break;
	case 1:
		message += " entered the song selection.";
		LastScreenInfo = GameClient::NS_SELECTSCREEN;
		break;
	case 2:
		message += " exited options.";
		break;
	case 3:
		message += " went into options.";
		LastScreenInfo = GameClient::NS_OPTIONS;
		break;
	case 4:
		//no need to mention exiting of options
		break;
	case 5:
		message += " finished the game.";
		LastScreenInfo = GameClient::NS_EVALUATION;
		break;
	}
	ServerChat(message);
	Client[clientNum]->NetScreenInfo = LastScreenInfo;
	SendUserList ();
}
コード例 #9
0
void StepManiaLanServer::Hello(PacketFunctions& Packet, const unsigned int clientNum)
{
	int ClientVersion = Packet.Read1();
	CString build = Packet.ReadNT();

	Client[clientNum]->SetClientVersion(ClientVersion, build);

	Reply.ClearPacket();
	Reply.Write1( NSCHello + NSServerOffset );
	Reply.Write1(1);
	Reply.WriteNT(servername);

	SendNetPacket(clientNum, Reply);

	if (ClientHost == -1)
		ClientHost = clientNum;

}
コード例 #10
0
ファイル: SMOnlineRoom.cpp プロジェクト: freem/SMOnline-v1
void SMOnlineRoom::ParseData(PacketFunctions& Packet, int clientnum)
{
    /* Try not to do any Packet Parsing here here because a lot of parsing
    was done in the Client. Parsing again would be a waste.
    Packet has been unaltered previous to this point.*/
    int command = Packet.Read1();
    switch (command)
    {
    case NSCPing:
        // No Operation
//		SendValue(NSServerOffset + NSCPingR, clientNum);
        break;
    case NSCPingR:
        // No Operation response
        break;
    case NSCHello:
        // Hello
        break;
    case NSCSU:
        // Style Update
        break;
    case NSCCM:
        // Chat message
        AnalizeChat(clientnum, Packet);
        break;
    case NSCSMS:
        //Room Status Change
        SendRoomTitle(clientnum);
        SendRoomList(clientnum);
        break;
    case NSSMONL:
        SMOnlineParse(Packet, clientnum);
        break;
    default:
        break;
    }
}
コード例 #11
0
void StepManiaLanServer::SelectSong(PacketFunctions& Packet, unsigned int clientNum)
{
	int use = Packet.Read1();
	CString message;

	if (use == 2)
	{
		if (clientNum == 0)
		{ 
			SecondSameSelect = false;

			CurrentSongInfo.title = Packet.ReadNT();
			CurrentSongInfo.artist = Packet.ReadNT();
			CurrentSongInfo.subtitle = Packet.ReadNT();

			Reply.ClearPacket();
			Reply.Write1(NSCRSG + NSServerOffset);
			Reply.Write1(1);
			Reply.WriteNT(CurrentSongInfo.title);
			Reply.WriteNT(CurrentSongInfo.artist);
			Reply.WriteNT(CurrentSongInfo.subtitle);		

			//Only send data to clients currently in ScreenNetMusicSelect
			for (unsigned int x = 0; x < Client.size(); ++x)
				if (Client[x]->inNetMusicSelect)
					SendNetPacket(x, Reply);

			//The following code forces the host to select the same song twice in order to play it.
			if ((strcmp(CurrentSongInfo.title, LastSongInfo.title) == 0) &&
				(strcmp(CurrentSongInfo.artist, LastSongInfo.artist) == 0) &&
				(strcmp(CurrentSongInfo.subtitle, LastSongInfo.subtitle) == 0))
					SecondSameSelect = true;

			if (!SecondSameSelect)
			{
				LastSongInfo.title = CurrentSongInfo.title;
				LastSongInfo.artist = CurrentSongInfo.artist;
				LastSongInfo.subtitle = CurrentSongInfo.subtitle;
				message = "Play \"";
				message += CurrentSongInfo.title + " " + CurrentSongInfo.subtitle;
				message += "\"?";
				ServerChat(message);
			}

		}
		else
		{
			message = servername;
			message += ": You do not have permission to pick a song.";
			Reply.ClearPacket();
			Reply.Write1(NSCCM + NSServerOffset);
			Reply.WriteNT(message);
			SendNetPacket(clientNum, Reply);
		}
	}

	if (use == 1)
	{
		//If user dosn't have song
		Client[clientNum]->hasSong = false;
		message = Client[clientNum]->Player[0].name;

		if (Client[clientNum]->twoPlayers)
		{
			message += "&";
			message += Client[clientNum]->Player[1].name;
		}

		message += " lacks song \"";
		message += CurrentSongInfo.title;
		message += "\"";
		ServerChat(message);
	}

	//If client has song
	if (use == 0)
		Client[clientNum]->hasSong = true;

	//Only play if everyone has the same song and the host has select the same song twice.
	if ( CheckHasSongState() && SecondSameSelect && (clientNum == 0) )
	{
		ClientsSongSelectStart();

		//Reset last song in case host picks same song again (otherwise dual select is bypassed)
		ResetLastSongInfo();
	}
}