Example #1
0
        //masterserver inform gameserver to start challenge
        void Packet47(NetIncomingMessage inmsg)
        {
            bool officiallyStarted;
            int  fixtureID;
            bool botsEnabled;
            byte maxPlayers;

            int[]    tID       = new int[2];
            string[] teamnames = new string[2];
            bool[]   isOfficialLeagueBotTeam = new bool[2];
            byte[]   selectedKit             = new byte[2]; //0-1 (home or away colors)
            byte[]   shirtstyle = new byte[2];              //0-9 (which mask is used)
            byte[,] shirtRgb     = new byte[2, 24];
            byte[,] shirtColorsH = new byte[4, 3];
            byte[,] shirtColorsA = new byte[4, 3];

            try
            {
                officiallyStarted = inmsg.ReadBoolean();
            }
            catch
            {
                return;
            }
            try
            {
                fixtureID = inmsg.ReadInt32();
            }
            catch
            {
                return;
            }
            //****
            try
            {
                botsEnabled = inmsg.ReadBoolean();
            }
            catch
            {
                return;
            }
            try
            {
                maxPlayers = inmsg.ReadByte();
            }
            catch
            {
                return;
            }

            //****
            for (int i = 0; i < 2; i++)
            {
                try
                {
                    isOfficialLeagueBotTeam[i] = inmsg.ReadBoolean();
                }
                catch
                {
                    return;
                }
                try
                {
                    tID[i] = inmsg.ReadInt32();
                }
                catch
                {
                    return;
                }
                try
                {
                    teamnames[i] = inmsg.ReadString();
                }
                catch
                {
                    return;
                }
                try
                {
                    selectedKit[i] = inmsg.ReadByte();
                }
                catch
                {
                    return;
                }
                try
                {
                    shirtstyle[i] = inmsg.ReadByte();
                }
                catch
                {
                    return;
                }

                for (int j = 0; j < 24; j++)
                {
                    try
                    {
                        shirtRgb[i, j] = inmsg.ReadByte();
                    }
                    catch
                    {
                        return;
                    }
                }
            }

            //data readed

            //"convert" shirtRgb->shirtColors
            //home
            int startID;
            int nextID = 0;

            if (selectedKit[0] == 0)
            {
                startID = 0;
            }
            else
            {
                startID = 12;
            }

            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    shirtColorsH[j, k] = shirtRgb[0, nextID + startID];
                    nextID++;
                }
            }

            //away
            nextID = 0;
            if (selectedKit[1] == 0)
            {
                startID = 0;
            }
            else
            {
                startID = 12;
            }

            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    shirtColorsA[j, k] = shirtRgb[1, nextID + startID];
                    nextID++;
                }
            }



            TeamData[] teams = new TeamData[2];

            teams[0] = new TeamData(isOfficialLeagueBotTeam[0], tID[0], teamnames[0], "", shirtstyle[0], shirtColorsH);
            teams[1] = new TeamData(isOfficialLeagueBotTeam[1], tID[1], teamnames[1], "", shirtstyle[1], shirtColorsA);

            roomHandler.CreateChallengeRoom(officiallyStarted, fixtureID, teams[0], teams[1], botsEnabled, maxPlayers);

            //inform masterserver, that match created
            NetOutgoingMessage outmsg = client.CreateMessage();

            outmsg.Write((byte)52);

            for (int i = 0; i < 2; i++)
            {
                outmsg.Write(tID[i]);
                outmsg.Write(teamnames[i]);
            }

            client.SendMessage(outmsg, NetDeliveryMethod.ReliableOrdered, 0);
        }
Example #2
0
 public void CreateChallengeRoom(bool officiallyStarted, int fixtureID, TeamData teams0, TeamData teams1, bool botsEnabled, byte maxPlayers)
 {
     lock (rooms)
     {
         rooms.Add(new RoomData(officiallyStarted, fixtureID, server, clientToMS, RoomType.Challenge, GetUniqueID(), teams0, teams1, botsEnabled, maxPlayers));
     }
 }