Question to pspeed about his bit stream class

@pspeed the code has been in production for 2 days. About 800 simultaneous users at peak times. It has not blown up yet and performs well under both tcp and udp. This is what I changed / fixed so far.

FrameState.java split() method hack to temporally get around the split bug.

long size = getHeaderBitSize(); int split = 0; while(split < states.size()) { ObjectState s = states.get(split); int bits = protocol.getEstimatedBitSize(s); if(size + bits > limit) break; size += bits; split++; } if(split == 0 || split == states.size()) { // throw new RuntimeException( "Error splitting message. split:" + // split ); // Zissis HACK!!! Somehow estimatedBitSize turnes to negative with // really large frames. return null; } long leftOverBits = estimatedBitSize - size;

StateWriter.java startMessage() method to fix a problem when the client has a temporarily very slow outbound connection and when it goes back to normal it floods ack packets.

protected void startMessage() {
	if(outbound != null)
	{
		return;
	}

	// Just in case we'll put a watchdog in here. The reason this
	// is unlikely to trigger is because the receivedAcks set only
	// grows when we've received a message from the client. And at
	// that point we get to remove every receivedAck the client
	// confirms. So one new ID should always nearly empty the set.
	int size = receivedAcks.size();

	// Zissis commented this out because it blows up the state collector
	// when a client is on a bad outbound connection
	// if( size >= 128 ) {
	// throw new RuntimeException( "Very bad things have happened in the
	// receivedAcks set." );
	// }

	// Build the ACKs array
	if(receivedAcksArray == null)
	{
		receivedAcksArray = new int[size];
		int index = 0;
		for(Integer s : receivedAcks)
		{
			receivedAcksArray[index++] = s;
		}
	}

	this.outbound = new SentState(-1, receivedAcksArray, new ArrayList<FrameState>());
	this.headerBits = outbound.getEstimatedHeaderSize();
	this.estimatedSize = headerBits;
}

There is one bug that I have to spend more time on. When I set the view-able extends past 1 … for example 3,3,3 … If an entity is located at 0,1,0 the frame is tagged as if it’s at 0,3,0. For now I have a HUGE grid and set the view-able extends to be 1,1,1

I will keep you posted if anything new comes up.

By the way, here’s your code in action with over 600 players in the game at the same time. I am looking at a solar system from over a kilometers away :slight_smile:

1 Like