glob2-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[glob2-devel] Beta 4 Bug Fix


From: Bradley Arsenault
Subject: [glob2-devel] Beta 4 Bug Fix
Date: Sun, 28 Dec 2008 20:31:07 -0500

I figured out the bug in Beta 4. Unfortunately, just as I was sending the email and committing the patch, the power went off in my house. The desktop where my globulation 2 work is on no longer worked. So I'm on the laptop sending this email.

I figured out that the bug was due to the step-push up. The networking system queues up messages in queues as they are arriving across the network. The front of the queues represent the messages to be executed at each frame and are sychronized across the network. However the back of queues, since messages are arriving at different times, aren't sychronized at all, but the order of the messages is still maintained and sychronized across the network. What was happening is that the network push-up code was pushing a message to the end of the queues. Because the ends of the queues are desychronized across network systems, adding one more message will corrupt the order of the ends of the queues, which must stay schronized across across the network. Because the ends of the queues are in the wrong order and desychronized, eventually after executing several frames the front of the queue, which also must be sychronized, will become desychronized.

The flaw in the desync detection function failed to detect this specific desychronization properly, so the desycnronization detection itself is desychronized across the network systems.

The solution is for the network push-up function to push to the front of the queue rather then back of the queue. Because the front of the queue stays sychronized normally, adding an order would stay sychronized across the network, so nothing bocomes out of order and desychronized across the systems computers.

The fix is to change a push_back to a push_front.

Line src/NetEngine.h:90 revision 8a1d2e4e3e63

std::vector<std::vector<boost::shared_ptr<Order> > > orders;

Starting at line src/NetEngine.cpp:90:

for(int i=0; i<diff; ++i)
{
for(int p=0; p<orders.size(); ++p)
{
                 boost::shared_ptr<Order> order = boost::shared_ptr<Order>(new NullOrder),
order->sender=p;
orders[p].insert(orders[p].begin(), order);

}
}
Line 119 in the original file, which was
         
orders[playerNumber].push(norder)
will become
          orders[playerNumber].push_back(norder);

Line 128 which was
         return orders[playerNumber].front()
will become
         return *orders[playerNumber].begin()

Line 100 in the original file which was
        orders[p].pop();
will become
        orders[p].erase(orders[p].begin());



And I am pretty sure that is all of the changes. What I have done here is first, i had to convert the type of the order queues from std::queue to std::vector because we needed to be able to push to the front of the queue, and std::queue did not allow that semantic. The second thing i needed to to do was change the latency push up function to push to the front of the queue manually, rather then using the NetEngine::pushOrder function.

What i wrote here isn't formatted correctly and i'm not sure its not bug free, like i missed a line that needs change in the conversions.

The result: bug solved. Try it out! Do not work from the patched debug place, i'm 99% sure this will fix the bug.

--
Extra cheese comes at a cost. Bradley Arsenault.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]