Page 1 of 2

Server

Posted: Sun Feb 28, 2016 7:25 pm
by diho
Hi all,

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

-Diho

Re: Server

Posted: Sun Feb 28, 2016 8:08 pm
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.

Re: Server

Posted: Sun Feb 28, 2016 10:19 pm
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)

Re: Server

Posted: Sun Feb 28, 2016 11:02 pm
by CuteAlien
Yeah, for network you either use sockets or some higher-level network library like RakNet.

Re: Server

Posted: Sun Feb 28, 2016 11:58 pm
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?

Re: Server

Posted: Mon Feb 29, 2016 12:43 am
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.

Re: Server

Posted: Mon Feb 29, 2016 12:57 am
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).

Re: Server

Posted: Mon Feb 29, 2016 8:02 am
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?

Re: Server

Posted: Mon Feb 29, 2016 11:25 am
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).

Re: Server

Posted: Mon Feb 29, 2016 6:23 pm
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.

Re: Server

Posted: Tue Mar 01, 2016 7:18 am
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?

Re: Server

Posted: Tue Mar 01, 2016 8:40 am
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.

Re: Server

Posted: Tue Mar 01, 2016 11:24 am
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?

Re: Server

Posted: Tue Mar 01, 2016 11:37 am
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.

Re: Server

Posted: Tue Mar 01, 2016 6:40 pm
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: