irrNetLite 2.1 [BETA]

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
Likort
Posts: 8
Joined: Wed Mar 28, 2007 9:28 pm

Post by Likort »

How I set up irrNettLite 2 Beta with DevCpp:

(Originally I was going to post my error messages and ask for help but I could finally solve all of them)
(I guess for most of you this was super easy but as it took me some time to figure it out I'll post it for people who are too scared to ask :oops:)

Add \irrNetLite2Beta\irrNetLite\include to Include Directories
Add /irrNetLite2Beta/irrNetLite/lib/libirrnet.a to Linker
Add example1.cpp to Project

Compile: [Linker error] undefined reference to `irr::net::createIrrNetServer(irr::net::INetCallback*, unsigned int, irr::net::SNetParams const&)' etcetc
Add CNetManager.cpp, SPacket.cpp to Project

Compile: [Linker error] undefined reference to `enet_initialize'
Get libenet.a from http://www.allegro.cc/files/download-at ... &id=689470
Add ../../irrNetLite2Beta/irrNetLite/lib/libenet-mingw/libenet.a to Linker

Compile: [Linker error] undefined reference to `compressBound'
Get zdll.lib from http://www.zlib.net/zlib123-dll.zip
Add ../../irrNetLite2Beta/irrNetLite/source/zlib/zlib123-dll/lib/zdll.lib to Linker

Compile: [Linker error] undefined reference to `htonl@4' etc
Add C:/Dev-Cpp/lib/libws2_32.a to Linker

Compile & Link: success -> Crash
Copy irrNetLite2Beta\irrNetLite\source\zlib\zlib123-dll\zlib1.dll to Project Directory

Finally, the Question "Client (c) or Server (s)?" pops up.

Works with example2.cpp too
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Haha, quite a journey there. I hope you find the examples informative.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Likort
Posts: 8
Joined: Wed Mar 28, 2007 9:28 pm

Post by Likort »

Sure, they are easy to understand. You kept it really clean.

Maybe if you got some time you could try to port your IrrNet 0.36 examples 1 2 3 4 to irrNet2+irrLicht 1.5 too as they are a bit more interactive.

Anyways, I ran into a small problem playing around a bit. I use an irrKlang Example to record some audio and would like to send it then with irrNet to another client. But I am getting the following error message:

Code: Select all

recordclient.cpp:141: error: ambiguous overload for 'operator<<' in 'packet << &data'
SPacket.h:23: note: candidates are: irr::net::SOutPacket& irr::net::SOutPacket::operator<<(irr::c8) <near match>
SPacket.h:25: note:                 irr::net::SOutPacket& irr::net::SOutPacket::operator<<(irr::u16) <near match>
SPacket.h:27: note:                 irr::net::SOutPacket& irr::net::SOutPacket::operator<<(irr::u32) <near match>
SPacket.h:29: note:                 irr::net::SOutPacket& irr::net::SOutPacket::operator<<(irr::u8) <near match>
SPacket.h:31: note:                 irr::net::SOutPacket& irr::net::SOutPacket::operator<<(irr::s16) <near match>
SPacket.h:33: note:                 irr::net::SOutPacket& irr::net::SOutPacket::operator<<(irr::s32) <near match>
SPacket.h:41: note:                 irr::net::SOutPacket& irr::net::SOutPacket::operator<<(const irr::c8*) <near match>
SPacket.h:43: note:                 irr::net::SOutPacket& irr::net::SOutPacket::operator<<(const irr::core::stringc&)
SPacket.h:45: note:                 irr::net::SOutPacket& irr::net::SOutPacket::operator<<(const std::string&) <near match>
SPacket.h:47: note:                 irr::net::SOutPacket& irr::net::SOutPacket::operator<<(const irr::core::stringw&)
The various lines that lead up to this should be those here:

Code: Select all

irrklang::ISoundSource* recordedSound = recorder->addSoundSourceFromRecordedAudio("myRecordedVoice");
[...]
void* data = recordedSound->getSampleData();
[...]
packet << &data;
I guess I need to take something like this

Code: Select all

SOutPacket& SOutPacket::operator << (const u32 data)
{
	enlargeBuffer(4);
	memcpy(buff.pointer() + buff.size() - 4, &data, 4);
	return *this;
}
and change it to be able to handle this:
virtual void* irrklang::ISoundSource::getSampleData ( ) [pure virtual]

Returns a pointer to the loaded and decoded sample data.

Returns:
Returns a pointer to the sample data. The data is provided in decoded PCM data.[...]
With the data variable I was already able to do stuff like

Code: Select all

irrklang::SAudioStreamFormat format = recordedSound->getAudioFormat();
[...]
unsigned long  dataLen = format.getSampleDataSize();
[...]
fwrite(data, dataLen, 1, file);
You got an idea how to make your << operator able to handle it?

Edit: and as you're at it, the >> operator as well :wink:
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I recommend casting the void* to a char* and copying it to a string. Then add the string to an SOutPacket and send that.

When receiving just put it in a stringc and retrieve the raw data using c_str().

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Likort
Posts: 8
Joined: Wed Mar 28, 2007 9:28 pm

Post by Likort »

I had issues with converting from and to chars and strings but after some time of thinking about slashing my wrists I was able to use an array of u32's. It's working now, thanks! And thanks again in general for the library.

Oh btw is there a limit to how much you can send in one packet?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

There shouldn't be a limit. The underlying Enet lib splits packets up into smaller ones if they get too big, and re-orders them. Although I would suspect sending a really large packet (> 1 MB) may cause the app to hang unless you multithread it.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

BlindSide, are you still working on this project? How active is it?

Would you recommend using it in a large project? Like say.. a Game Engine? :P

Thanks.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

How about you actually take a look at it and decide yourself :?

I'm sure you won't be disappointed :D
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Post by zerochen »

hi

if i include irrlicht.h in the example the program crashs when it is in the client mode..

Unhandled exception at 0x00451c81 in Client.exe: 0xC0000005: Access violation reading at position 0xccccccd4.

if i debug the program
the debugger say that the error is here->

irrAllocator.h

Code: Select all

	//! Deallocate memory for an array of objects
	void deallocate(T* ptr)
	{
		internal_delete(ptr);   <<--here
	}
i use visual 2008
maybe this can important too->
> Client.exe!irr::core::irrAllocator<char>::deallocate(char * ptr=0x00366958) Zeile 40 + 0xe Bytes C++
Client.exe!irr::core::array<char,irr::core::irrAllocator<char> >::~array<char,irr::core::irrAllocator<char> >() Zeile 64 C++
Client.exe!irr::net::SOutPacket::~SOutPacket() + 0x2b Bytes C++
Client.exe!main() Zeile 94 + 0xc Bytes C++
Client.exe!__tmainCRTStartup() Zeile 266 + 0x19 Bytes C
Client.exe!mainCRTStartup() Zeile 182 C
kernel32.dll!7c817067()


plz help me:(
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Did you read the warning at the top of the page that said you have to recompile the MSVC lib yourself else it will crash?
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Post by zerochen »

of course i read it! but thats not the error
i compile the irrnetlite.lib

i can connect to the server and send something but after this the client crashs
if i exclude irrlicht.h the program works fine
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

of course i read it!
Haha sorry, I will expect better of you next time!

Can you post full source code of example app that causes this problem?

Thank you
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Post by zerochen »

i created a new project
included Tutorial.cpp from the irrnetlite2beta.zip
then i got many errors like this

LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a ist bereits in MSVCRTD.lib(cinitexe.obj) definiert.

i changed the project settings from Multithreaded-Debug-DLL (/MDd) to Multithreaded-Debug (/MTd)

the programm works fine i can send und getting information without any errors

i included irrlicht.h at the beginning auf the tutorial.cpp
the program run a few seconds then i got an error like->

Image
if i click debug i get->

Image

[/img]
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I think its because the Irrlicht versions of irrArray, string, etc, don't match the ones provided with irrNetLite (For convenience and seperation). So delete all the Irrlicht included files that came with irrNetLite, then recompile the irrNetLite lib using irrlicht.h (Just include this in irrNetLite files) and it should be ok.

I will probably update the lib later on to have a #define that takes care of this.

EDIT: Oh yeah, if it is still causing you problems you can try not using a lib at all and just include all the irrNetLite and enet files (Except for the ones that already come with Irrlicht) as part of your project, always works for me!

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Post by zerochen »

jeeeeeeeeeeeeeha it works

big thx
Post Reply