Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [linux] Dedicated server / run in Console  (Read 1855 times)

0 Members and 2 Guests are viewing this topic.

sajuuk

  • Newbie
  • *
  • Posts: 5
    • View Profile
[linux] Dedicated server / run in Console
« on: September 23, 2012, 01:33:18 pm »
Hi all, I'm working on a little networked game created in c++ with SFML.
I would like to make a dedicated server that should be able to run in a console (no xserver).

I'm sharing the same classes between my client and server to manage the entities. And those classes have calls to some sfml-graphics functions (to draw my entities, to check for collision, etc...).

When I start a program in a tty I get a segfault from libsfml-window.so.2 even though I'm only linking with "-lsfml-graphics -lsfml-system -lsfml-network".

Is there a workaround to this problem or do I need to make a special version of my classes without any sfml-graphics related code ?

Thanks.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: [linux] Dedicated server / run in Console
« Reply #1 on: September 23, 2012, 02:25:11 pm »
Well sfml-graphics depends on sfml-window, so I don't really see how you could've successfully build your application without linking against sfml-window.

You probably shouldn't create a second version, but refactor your original one and separate the logic fully from the graphic (e.g. by using the MVC pattern), so it would be very easy to drop the graphics part and just run the game as server... ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

sajuuk

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: [linux] Dedicated server / run in Console
« Reply #2 on: September 23, 2012, 03:37:51 pm »
Thanks.

But I struggle finding a clean way to use the MVC pattern in this case. The problem is that my entities use different code to draw themself. So I'll need in my View class a special draw function for each entity types.

I don't know much about game design patterns. Do you know a better one for this case?

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
Re: [linux] Dedicated server / run in Console
« Reply #3 on: September 23, 2012, 06:59:14 pm »
Well, as exploiter said, the clean way would be to remove anything drawing related from the classes representing your world entities. If you want, you can still keep the graphics data and draw functions in classes, it should just be different ones, and your simulation shouldn't know about them.

 

anything