Server

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
diho
Posts: 46
Joined: Fri May 20, 2011 9:01 pm
Location: Netherlands

Server

Post by diho »

Hi all,

What is the most efficient way to make a standalone server for an irrrlicht game?

-Diho
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: Server

Post by sudi »

Really depends on what your server has to do. There is no magic answer for this. The server does not even need irrlicht probably since it does not have to display anything.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
kormoran
Posts: 47
Joined: Mon Dec 28, 2015 4:50 pm
Location: Tolentino

Re: Server

Post by kormoran »

Irrlicht does just 3D, it does not mess with networking (or physics). To implement a game server, either use a proper framework/library along with Irrlicht or write your own 8)
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Server

Post by CuteAlien »

Yeah, for network you either use sockets or some higher-level network library like RakNet.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
diho
Posts: 46
Joined: Fri May 20, 2011 9:01 pm
Location: Netherlands

Re: Server

Post by diho »

I am aware of the fact that I would need a proper networking library.
Sudi wrote:Really depends on what your server has to do. There is no magic answer for this. The server does not even need irrlicht probably since it does not have to display anything.
I considered using even a complete different programming language for the server. But I thought it wasn't such a good idea. Even if I let the client handle all the collision and valid movement checks, don't I still need irrlicht, even without rendering?
e.g. When I implement a pathfinding AI for enemies. Doesn't the server need to know all the objects in the game, to calculate a path? Wouldn't this mean that I am forced to partially implement irrlicht into the server?
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: Server

Post by sudi »

Well you will have to implement the gamelogic that has to run on the server. But generally it is a bad idea to use irrlicht objects(SceneNodes) as game objects. You can think of it as the rendering component of your gameobjects. But yes if you have collision detection and things like that you will need a physics engine(irrlicht is not a physics engine) running on the server. So a math lib is probably needed. A different language is totally fine for all those things but you probably wanna use c++ as well when it comes to physics.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Server

Post by CuteAlien »

I like to have server/client as similar as possible. Often it's not trivial to figure out which parts of the code should run where. And it becomes easier to move code when server&client run more or less a similar world. So Irrlicht on the server can be fine. For testing you might even render stuff on the server.

For example depending on the game collision might happen on server & client. You have server collisions to ensure you have an instance making the decisions (Han shot first), but you have client collisions to show effects even before the server has decided who get's the points. Generally the server should have as much objects & information to be able to make all decisions that matter.

But it all depends on the game. If you are new to network programming it might help doing first a game which isn't about realtime and fast actions (like shooters). Turn-based games or games at least allowing some lag without affecting the gameplay might be easier (not easy... network never is).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
diho
Posts: 46
Joined: Fri May 20, 2011 9:01 pm
Location: Netherlands

Re: Server

Post by diho »

Sudi wrote:Well you will have to implement the gamelogic that has to run on the server. But generally it is a bad idea to use irrlicht objects(SceneNodes) as game objects. You can think of it as the rendering component of your gameobjects. But yes if you have collision detection and things like that you will need a physics engine(irrlicht is not a physics engine) running on the server. So a math lib is probably needed. A different language is totally fine for all those things but you probably wanna use c++ as well when it comes to physics.
How should I do calculations with in game objects, without irrlicht? Do you suggest that it's better to write own code for this?
CuteAlien wrote:I like to have server/client as similar as possible. Often it's not trivial to figure out which parts of the code should run where. And it becomes easier to move code when server&client run more or less a similar world. So Irrlicht on the server can be fine. For testing you might even render stuff on the server.

For example depending on the game collision might happen on server & client. You have server collisions to ensure you have an instance making the decisions (Han shot first), but you have client collisions to show effects even before the server has decided who get's the points. Generally the server should have as much objects & information to be able to make all decisions that matter.

But it all depends on the game. If you are new to network programming it might help doing first a game which isn't about realtime and fast actions (like shooters). Turn-based games or games at least allowing some lag without affecting the gameplay might be easier (not easy... network never is).
But beside debugging, how should I disable the rendering part? something like this maybe?

Code: Select all

IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL);
Will this stop every calculation for rendering purposes?
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Server

Post by CuteAlien »

diho wrote:But beside debugging, how should I disable the rendering part? something like this maybe?

Code: Select all

IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL);
Will this stop every calculation for rendering purposes?
That should mostly work. Or simply not doing the drawAll calls. It depends on the game what kind of stuff you need on the server. If you do a Poker game you probably don't need any Irrlicht on the server. If you do a Shooter then having a 3D engine on the server is maybe useful. But could also be you only need to run physics on the server (thought even then Irrlicht might be useful to load some mesh-formats).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: Server

Post by sudi »

diho wrote: How should I do calculations with in game objects, without irrlicht? Do you suggest that it's better to write own code for this?
Own code for what? You know that irrlicht is only a 3d engine+some input. But CuteAlien is right about using irrlicht to load 3d models. It really depends on what you wanna do. Maybe be a bit more specific about what you wanna do? Then we might be able to give you a better answer.
diho wrote: But beside debugging, how should I disable the rendering part? something like this maybe?

Code: Select all

IrrlichtDevice *nulldevice = createDevice(video::EDT_NULL);
Will this stop every calculation for rendering purposes?
Yes that works.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
diho
Posts: 46
Joined: Fri May 20, 2011 9:01 pm
Location: Netherlands

Re: Server

Post by diho »

Sudi wrote: Own code for what? You know that irrlicht is only a 3d engine+some input. But CuteAlien is right about using irrlicht to load 3d models. It really depends on what you wanna do. Maybe be a bit more specific about what you wanna do? Then we might be able to give you a better answer.
The idea is to make a little fps game. The server needs to update player positions to all clients, post-check bullet hits, control AI pathfinding etc. I am planning to use raknet. But as I said, don't I need to use irrlicht to load in the terrain and ingame objects, for at least the pathfinding algorithm if not more?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Server

Post by hendu »

Usually your physics representation is different from the graphics. You wouldn't use a hugely detailed 3d model with every triangle being a physics triangle, you'd use a box/sphere/ellipse/whatever. Then your server only needs to know the physics world, not the graphics world.
diho
Posts: 46
Joined: Fri May 20, 2011 9:01 pm
Location: Netherlands

Re: Server

Post by diho »

hendu wrote:Usually your physics representation is different from the graphics. You wouldn't use a hugely detailed 3d model with every triangle being a physics triangle, you'd use a box/sphere/ellipse/whatever. Then your server only needs to know the physics world, not the graphics world.
I don't see how a simplified representation of a terrainnode can work for pathfinding. Could you give a textual example of how you would tackle this? Besides, a physics lib or any lib for that matter has a different way it processes heightmaps to become a terrain mesh or model of some sort. It will be different than the one the client uses (using irrlicht), or do I see this the wrong way?
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Server

Post by CuteAlien »

Not sure if there is such a thing as a little FPS-game with Network, it's pretty hard stuff. You might consider starting with an existing open source game which already has those features. Sauerbraten engine for example (I never used that, but it's about that and has the same zlib license as Irrlicht). Or just write mods for an existing shooter. Not saying you can't do all that from scratch, but you should be a pretty experienced programmer for that already and have a lot of time (I already worked on 2 similar projects, first time we needed more than a year with several people, second time I had to give up after working on it for over a year). Generally a good idea to do some simpler games first to get some experience.

Anyway - even if you want to do from scratch - take a look at sources from a game like Sauerbraten (might be called Cube2 now) to get some idea how that stuff can work.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Re: Server

Post by sudi »

diho wrote: The idea is to make a little fps game. The server needs to update player positions to all clients, post-check bullet hits, control AI pathfinding etc. I am planning to use raknet. But as I said, don't I need to use irrlicht to load in the terrain and ingame objects, for at least the pathfinding algorithm if not more?
Yeah there is no small fps game. Besides in a case of a fps you can also declare one of the clients as the "server". Then you do not have to run an extra instance.

PS: This little deathmatch game like thing took 5 months. Youtube

PPS: Besides the fact the video does not show real multiplayer...it works...believe me :mrgreen:
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Post Reply