Leechers/Non programmers move on. This isn't a source.
"There is no MCI 8 player limit!"
Read the following code until you get it.
Players is a collection which changes constantly as players join and leave. MCI is an array of 8 elements and always is. So when you have 9 players, you are trying to access the 9th element of MCI which doesn't exist which will give you an MCI exception.
"Ok so lets just change all Players.Count to MCI.NumC"
Well MCI.NumC at max can be 8. So if you have 9 players, that last player wont be updated.
"But it would send 8 and then 1!"
So you would be updating the first players stuff with the 9th players when you get the 1.
"Ok so what do we do?"
I did the simplest thing. I added the CompCar Packet struct to the clsPlayer structure. Here is an example of how I changed MCI.
So now we always have data for the cars in the clsPlayer structure. Now we can access the cars data anywhere. Unlike before were we could only access the cars data from the MCI thread. Now you can rewrite a lot of code and remove most of the MCI stuff and put it in different spots. No more waiting until MCI is executed to engage a target.
This fixes so many problems.
1. Not being able to access car data anywhere but the MCI thread.
2. Out of bounds error from Players being larger than MCI.
3. Lots more (brain fart)
I am working on this, just this should be enough to get ya started.
"There is no MCI 8 player limit!"
Read the following code until you get it.
for (int i = 0; i < Players.Count; i++)
{
//Do something with MCI[i]
}
Players is a collection which changes constantly as players join and leave. MCI is an array of 8 elements and always is. So when you have 9 players, you are trying to access the 9th element of MCI which doesn't exist which will give you an MCI exception.
"Ok so lets just change all Players.Count to MCI.NumC"
Well MCI.NumC at max can be 8. So if you have 9 players, that last player wont be updated.
"But it would send 8 and then 1!"
So you would be updating the first players stuff with the 9th players when you get the 1.
"Ok so what do we do?"
I did the simplest thing. I added the CompCar Packet struct to the clsPlayer structure. Here is an example of how I changed MCI.
//CompCar is the CompCar packet structure I added to clsPlayer
int idx = 0;
for (int i = 0; i < MCI.NumC; i++)
{
idx = GetPlyIdx(MCI.Info[i].PLID);
Players[idx].CompCar.AngVel = MCI.Info[i].AngVel; //They aren't structures so you cant serialize!
Players[idx].CompCar.Direction = MCI.Info[i].Direction;
Players[idx].CompCar.Heading = MCI.Info[i].Heading;
Players[idx].CompCar.Info = MCI.Info[i].Info;
Players[idx].CompCar.Lap = MCI.Info[i].Lap;
Players[idx].CompCar.Node = MCI.Info[i].Node;
Players[idx].CompCar.PLID = MCI.Info[i].PLID;
Players[idx].CompCar.Position = MCI.Info[i].Position;
Players[idx].CompCar.Speed = MCI.Info[i].Speed;
Players[idx].CompCar.X = MCI.Info[i].X;
Players[idx].CompCar.Y = MCI.Info[i].Y;
Players[idx].CompCar.Z = MCI.Info[i].Z;
}
So now we always have data for the cars in the clsPlayer structure. Now we can access the cars data anywhere. Unlike before were we could only access the cars data from the MCI thread. Now you can rewrite a lot of code and remove most of the MCI stuff and put it in different spots. No more waiting until MCI is executed to engage a target.
This fixes so many problems.
1. Not being able to access car data anywhere but the MCI thread.
2. Out of bounds error from Players being larger than MCI.
3. Lots more (brain fart)
I am working on this, just this should be enough to get ya started.