Author Topic: RakNet 2.44 released  (Read 14694 times)

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
RakNet 2.44 released
« on: February 11, 2006, 08:02:13 PM »
Lots of improvements in 2.44

  • Added WriteDelta and WriteCompressedDelta to BitStream class.
  • Changed BitStream class to use template and template specialization for native types.
  • Bitstreams can now read and write PlayerIDs directly.
  • Added replyFromTarget parameter to RPC so you can now use RPC as a blocking function that takes a reply from a remote system.
  • Improved performance of SingleProducerConsumer class and fixed a small chance of overrun or underruns on multiprocessor systems.
  • Improved documentation for DataReplicatorSystem. Clarified ObjectMemberRPC example.
  • Replaced critical section lock on incoming packet queue with a single producer consumer, improving read throughput rate by about 200%.

WriteDelta is useful if you encode many values in a single packet, some of which don't change everytime you do a send.  In those cases, WriteDelta will only write 1 bit.  It's easy to write yourself, but using WriteDelta drops down the number of lines you write from about 10 to about 1.

The new parameter of RPCs allows you to read return values from RPC calls.  This is very useful because now you can call functions like "GetMapName" when starting up a client and you won't have to write some kind of crazy loop that waits for a flag from somewhere else.  The RPC will block while it waits for the server to respond, so it is only useful for times when you don't mind blocking, such as when loading a map or sending a message before disconnecting.

I greatly expanded the documentation for the DataReplicator system so that should hopefully make it easier to understand.

The performance improvement removes the last critical section that is frequently called.  Because RakNet is already so fast, regular games won't notice it.  But if you use RakNet for super heavy transfer rates (such as MMOs or file transfers) you will find it reads data about twice as fast now.

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: RakNet 2.44 released
« Reply #1 on: February 11, 2006, 08:03:32 PM »
Oh yeah I'm also dropping CVS out of the build so you don't get these CVS directories littered all over the place.  I'll see if I can get subversion to work with sourceforge.

Van

  • Full Member
  • ***
  • Posts: 164
  • Karma: 5
    • View Profile
Re: RakNet 2.44 released
« Reply #2 on: February 11, 2006, 08:57:05 PM »

DOH!

What happen to the NetworkInterface::PushBackPacket() !?!?!?

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: RakNet 2.44 released
« Reply #3 on: February 11, 2006, 11:31:39 PM »
I put it back for you.

Download the zip again.  In the readme.txt it will say RakNet 2.442
« Last Edit: February 12, 2006, 12:09:17 AM by Rak'kar »

wrt

  • Full Member
  • ***
  • Posts: 139
  • Karma: 0
    • View Profile
Re: RakNet 2.44 released
« Reply #4 on: February 12, 2006, 04:30:10 AM »
hmm, gcc doesn't seam to like the new templates in bitstream.h, i'll have a look at it and tell you later if i found something that fixes it

edit:
1.
it's about the "template <>" starting in line 204 of bitstream.h, if i change it to "template <class templateType>" it compiles. I have no clue about templates, so i'm not sure if that breaks anything.

2. There is one place in the code where you just wrote "Sleep(30);" instead of the
Code: [Select]
#ifdef _WIN32
Sleep( 30 );
#else
usleep( 30 * 1000 );
#endif

stuff. This is on line 1146 in RakPeer.cpp.

one  more thing, in SingleProducerConsumer.h there's no newline at the end of the file.

with those changes it compiles happy
cu wrt
« Last Edit: February 12, 2006, 05:17:38 AM by wrt »

Valen

  • Full Member
  • ***
  • Posts: 117
  • Karma: 5
    • View Profile
Re: RakNet 2.44 released
« Reply #5 on: February 12, 2006, 12:35:50 PM »
it's about the "template <>" starting in line 204 of bitstream.h, if i change it to "template <class templateType>" it compiles. I have no clue about templates, so i'm not sure if that breaks anything.

That's a specialization of the template, and it should compile the way it is. I tried to do what you did in VC++ and it simply ignores the second definition (it's never used) if both are declared as the main template. If gcc reacts the same way, it would explain why it doesn't complain anymore. Should technically give an error, but templates are unique in that they're only compiled when the compiler decides to use them, so it may simply never compile that code.

wrt

  • Full Member
  • ***
  • Posts: 139
  • Karma: 0
    • View Profile
Re: RakNet 2.44 released
« Reply #6 on: February 12, 2006, 01:51:53 PM »
commenting it out works as well, would that be a better idea?

cu wrt

Valen

  • Full Member
  • ***
  • Posts: 117
  • Karma: 5
    • View Profile
Re: RakNet 2.44 released
« Reply #7 on: February 12, 2006, 08:13:48 PM »
A template specialization is like one version of an overloaded function. In reality that's not actually how it works because the whole point of templates is that the compiler generates a function for each data type you use the template function with (in other words, creates the overloaded functions automatically). But in any case, the point of a specialized template function is to pretty much tell the compiler "you've got a body for this template function that you should use for any data type, but for this specific data type I want you to use the function body I'm defining here." It's normally done when you want to perform specialized operations for some specific data types. I don't know what Rakkar is doing there, but he wanted to handle bool differently from other types, so he created that function. So to answer your question, the code certainly will compile without the specialized template function, but it will probably not work correctly when you send a bool to Write().

[edit]
Just looked at it briefly, and it seems that Rakkar optimized bool sending by using one bit to store bools for transfer. So, that's what the specialization is for (without it a bool will be stored as one byte). If you comment out the Read specialization for bool on line 428 (in addition to the write), you should be fine. I wonder why gcc is so fussy about that particular definition.
« Last Edit: February 12, 2006, 08:21:30 PM by Valen »

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: RakNet 2.44 released
« Reply #8 on: February 13, 2006, 12:06:54 PM »
You'd have to comment out the PlayerID one too.  I'd rather it be #ifdefed to work with gcc though.  Speak up if you know how to fix it.

wrt

  • Full Member
  • ***
  • Posts: 139
  • Karma: 0
    • View Profile
Re: RakNet 2.44 released
« Reply #9 on: February 13, 2006, 12:21:20 PM »
read through some documentation about template specialization yesterday, seams to look nice. The only thing i noticed was that on some websites they say that templates have to be ordered, starting with the most general case and than further specializing, but moving around the individual functions a bit didn't do any difference. For all of you who don't have a gcc available, here're the errors:
Code: [Select]
g++ -fPIC -ggdb -I/home/wrt/proggn/RakNet/speex-1.1.11.1/libspeex/ -I/home/wrt/proggn/RakNet/Include -I/home/wrt/proggn/RakNet/Include/RakVoice -w -c *.cpp
In file included from BitStream.cpp:42:
/home/wrt/proggn/RakNet/Include/BitStream.h:202: error: explicit specialization in non-namespace scope `class RakNet::BitStream'
/home/wrt/proggn/RakNet/Include/BitStream.h:204: error: `Write' is not a template function
/home/wrt/proggn/RakNet/Include/BitStream.h:204: error: invalid function declaration
/home/wrt/proggn/RakNet/Include/BitStream.h:215: error: explicit specialization in non-namespace scope `class RakNet::BitStream'
/home/wrt/proggn/RakNet/Include/BitStream.h:217: error: `Write' is not a template function
/home/wrt/proggn/RakNet/Include/BitStream.h:217: error: invalid function declaration
/home/wrt/proggn/RakNet/Include/BitStream.h:227: error: explicit specialization in non-namespace scope `class RakNet::BitStream'
/home/wrt/proggn/RakNet/Include/BitStream.h:229: error: `WriteDelta' is not a template function
/home/wrt/proggn/RakNet/Include/BitStream.h:229: error: invalid function declaration
/home/wrt/proggn/RakNet/Include/BitStream.h:250: error: explicit specialization in non-namespace scope `class RakNet::BitStream'
/home/wrt/proggn/RakNet/Include/BitStream.h:252: error: `WriteCompressedDelta' is not a template function
/home/wrt/proggn/RakNet/Include/BitStream.h:252: error: invalid function declaration
/home/wrt/proggn/RakNet/Include/BitStream.h:389: error: explicit specialization in non-namespace scope `class RakNet::BitStream'
/home/wrt/proggn/RakNet/Include/BitStream.h:391: error: `ReadDelta' is not a template function
/home/wrt/proggn/RakNet/Include/BitStream.h:391: error: invalid function declaration
/home/wrt/proggn/RakNet/Include/BitStream.h:427: error: explicit specialization in non-namespace scope `class RakNet::BitStream'
/home/wrt/proggn/RakNet/Include/BitStream.h:429: error: `Read' is not a template function
/home/wrt/proggn/RakNet/Include/BitStream.h:429: error: invalid function declaration
/home/wrt/proggn/RakNet/Include/BitStream.h:447: error: explicit specialization in non-namespace scope `class RakNet::BitStream'
/home/wrt/proggn/RakNet/Include/BitStream.h:449: error: `Read' is not a template function
/home/wrt/proggn/RakNet/Include/BitStream.h:449: error: invalid function declaration
/home/wrt/proggn/RakNet/Include/BitStream.h:454: error: explicit specialization in non-namespace scope `class RakNet::BitStream'
/home/wrt/proggn/RakNet/Include/BitStream.h:456: error: `ReadDelta' is not a template function
/home/wrt/proggn/RakNet/Include/BitStream.h:456: error: invalid function declaration
/home/wrt/proggn/RakNet/Include/BitStream.h:461: error: explicit specialization in non-namespace scope `class RakNet::BitStream'
/home/wrt/proggn/RakNet/Include/BitStream.h:463: error: `ReadCompressedDelta' is not a template function
/home/wrt/proggn/RakNet/Include/BitStream.h:463: error: invalid function declaration

... (repeated several times)



so it looks like it has some problems with the combination of the namespace and the template?

cu wrt

Valen

  • Full Member
  • ***
  • Posts: 117
  • Karma: 5
    • View Profile
Re: RakNet 2.44 released
« Reply #10 on: February 13, 2006, 01:25:11 PM »
Based on the error wrt is getting, below is what I dug up in google groups. It's an exerpt from the C++ standard. According to this, you need to declare member template specializations outside the body of the class. Visual C++ doesn't enforce this, but some other compilers do.

Quote
(14.7.3/2):
"An explicit specialization shall be declared in the namespace of
 which the template is a member, or, for member templates, in the
 namespace of which the enclosing class or enclosing class template
 is a member.  An explicit specialization of a member function,
 member class or static data member of a class template shall be
 declared in the namespace of which the class template is a member.
 Such a declaration may also be a definition. If the declaration is
 not a definition, the specialization may be defined later in the
 name-space in which the explicit specialization was declared, or
 in a namespace that encloses the one in which the explicit
 specialization was declared."
« Last Edit: February 13, 2006, 01:29:22 PM by Valen »

Van

  • Full Member
  • ***
  • Posts: 164
  • Karma: 5
    • View Profile
Re: RakNet 2.44 released
« Reply #11 on: February 13, 2006, 02:27:45 PM »

DOH!

What happen to the NetworkInterface::PushBackPacket() !?!?!?


I put it back for you.

Download the zip again.  In the readme.txt it will say RakNet 2.442


* bump *

 ;)

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: RakNet 2.44 released
« Reply #12 on: February 13, 2006, 11:30:06 PM »
Can someone with gcc make that change, let me know if it works, and send the code?

Based on the error wrt is getting, below is what I dug up in google groups. It's an exerpt from the C++ standard. According to this, you need to declare member template specializations outside the body of the class. Visual C++ doesn't enforce this, but some other compilers do.

Quote
(14.7.3/2):
"An explicit specialization shall be declared in the namespace of
 which the template is a member, or, for member templates, in the
 namespace of which the enclosing class or enclosing class template
 is a member.  An explicit specialization of a member function,
 member class or static data member of a class template shall be
 declared in the namespace of which the class template is a member.
 Such a declaration may also be a definition. If the declaration is
 not a definition, the specialization may be defined later in the
 name-space in which the explicit specialization was declared, or
 in a namespace that encloses the one in which the explicit
 specialization was declared."

pinniped

  • Full Member
  • ***
  • Posts: 133
  • Karma: -1
    • View Profile
Re: RakNet 2.44 released
« Reply #13 on: February 14, 2006, 02:32:27 AM »
Uh... do I have to wait a while then before things are available via SF? :(  I have very little time, so I can't download the zip, unpack it, fix for gcc/Linux, then perform diffs and upload via cvs.


Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: RakNet 2.44 released
« Reply #14 on: February 14, 2006, 02:26:19 PM »
How do I disable CVS from creating source control directories on my local harddrive?  If there's no way to do that I'm going to have to get another host so I can use subversion instead.