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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Tukimitzu

Pages: 1 ... 3 4 [5] 6 7 8
61
Network / Re: Non-blocking usage and Status handling
« on: April 14, 2016, 03:47:56 am »
Thx nicox11!

62
SFML projects / Re: [Release][GUI] SFML + ImGui lib
« on: April 12, 2016, 06:29:16 pm »
I love that library.

Aside from the new
ImGui::Image(someTexture);
(which is indeed very convenient), what else is new from the original repo? Also, when I was using the original, I noticed that if you resize the window after creation, the ImGui objects stopped rendering and working properly. Did you experience that too? And if so, is that fixed?

63
SFML projects / Re: Pointless Wars - [Turn-Based Pointless Strategy]
« on: April 12, 2016, 06:18:26 pm »
Not all of the versions. The MinGW-w64 fork has support via pwinthread if you pick the POSIX threading model builds (e.g. this build). ;)

Ah, now I know! Thank you!

64
SFML projects / Re: Pointless Wars - [Turn-Based Pointless Strategy]
« on: April 11, 2016, 07:02:36 pm »
Obligatory post so that this thread doesn't leave the front page

I've been working on multiplayer stuff for the past few days, and I successfully implemented a match-making server. It is definitely not finished, but it works and if you are interested, it's a single .cpp file (sshhh, who needs .h anyway):

Match-making server:
(click to show/hide)

Server features:
- Runs on linux and windows*.
- Runs on command-line only.
- Has a user-input thread so that the user can type commands in the command-line while it is running.

*MinGW c++ compiler doesn't support std::thread yet, that's why I'm using mingw.thread.h.

It is a black-box match-making system. It does one thing and one thing only: links players who want to play the same game mode. Just like Hearthstone.

Quick Overview (aka lazy explanation):
- Player connects to server, player is now in now expected to choose a game mode.
- Once it chooses the game mode, server looks for that game mode on the wait-list.
- If no game of that game mode is on the wait-list, a new game is created and inserted in the wait-list.
- If game is found, player enters the game and the game is removed from the wait-list. Start game.

Other things yet to implement:
- Give the player the option to have his match private, so only someone who knows the match ID can connect.
- Match-making based on the player rank, but this is for much later, when I actually have a player-base lol.

I rented a linux machine at ops.mnx.io, accessed with SSH Secure Shell Client in my windows PC, compiled, ran and tested with a little tic-tac-toe client that I made. I played a few games and didn't have any problems. Specially in the first months of beta-testing, this VPS solution will be very useful.

I didn't test it with Pointless Wars yet, but in terms of multiplayer communication, tic-tac-toe and Pointless Wars are pretty much the same.

If you are a somewhat experienced network programmer and have any thoughts about any of this, please let me know.

Cheers!

65
General / Re: Problem locking framerate
« on: April 11, 2016, 06:05:13 am »
If SEV_Framelock is 60 seconds (and you converted to microseconds), allocFrameTime will be 0, because 1,000,000/60,000,000 is 0.0166 and allocFrameTime is an integer type.

Then between < allocFrameTime will always be false (except I don't know what between holds).

But why do you want to sleep anyway? Are you using threads?


66
Network / Non-blocking usage and Status handling
« on: April 10, 2016, 08:09:21 am »
Hello friends,

When I have non-blocking sf::TcpSockets updated in a loop, what are the correct ways to send and receive data?
This is how I've been doing:

Listening to connections:
    sf::Status status;
    sf::TcpSocket* socket = new sf::TcpSocket;
    while ((status = listener.accept(*socket)) == sf::Socket::Done){
        // store socket somewhere, then...
        socket = new sf::TcpSocket;
    }
    delete socket;
 

Receiving data:
    sf::Packet packet;
    sf::Socket::Status status;
    while ((status = socket->receive(packet)) == sf::Socket::Done){
        // read packet
    }
    if (status == sf::Socket::Disconnected){
        // delete socket, remove from storage
    }
 

Sending data:
    // when I want to send a packet, I don't send it right away, I store it in a queue
    peer.packetsToSend.push_back(packet);
    //...
    // further in another moment I actually send it
    if (!peer.packetsToSend.empty()){
        sf::Packet& packet = peer.packetsToSend.front();
        if ((status = socket->send(packet)) == sf::Socket::Done){
            peer.packetsToSend.pop_front();
        }
    }
 

Question #1: is the packet send queue necessary? Do I need a receive queue too?
Question #2: can the send method return sf::Socket::Disconected as well? If so, do I have to handle it or you think it's fine handling it only on receive (considering I call receive 60 times per second)?
Question #3: how to proceed if send(...) returns an error? Should I try to send the whole thing again?
Question #4: how to proceed if receive(...) returns an error?

Thanks!

67
Window / Re: Window size changing
« on: April 04, 2016, 10:49:06 pm »
On the creation method, for the sf::Style parameter:
sf::Style::Default ^ sf::Style::Resize

68
Network / Re: My generic questions about network
« on: April 04, 2016, 06:48:18 pm »
Thanks for the help man, I might open other threads with more specific questions as the troubles come.  :)

69
Network / Re: My generic questions about network
« on: April 04, 2016, 05:39:41 pm »
Ok, you convinced me about the importance of a central server.
What I want to do is exactly what a game like Hearthstone does.
- It is a 1v1 turn-based strategy game, the player only needs to communicate with his adversary.
- There's no lobby, the match-making is a black box.
- The data transferred is not time critical, which is why I'm using TCP/IP.
- The data transferred is very small.

So how exactly does a server like this work? This is how I imagine:
- Player connects to server.
- Server matches 2 players together.
- Players start match.
- Whenever a player has some information to send to the other player, it says to the server: "Hey, I don't know who am I playing with (his IP Adress), but whoever it is, could you please send this to him?"
- Server says: "Sure buddy! Let me just check if you are cheating."

Is that right?

And also, considering the complexity of the calculations performed by this server in this scenario, and considering that the game is moderately successful (meaning there will be thousands of games happening in any given time) is renting a machine recommended? Or is there another solution?

Thanks!

70
Network / Re: My generic questions about network
« on: April 04, 2016, 04:36:40 pm »
Question 1 : I don't think there is any problem with this (you should maybe wait for a more experienced response).
Waiting...

Question 2 : Why don't you test it yourself ? :)
Is laziness a valid answer?

Question 3 : Check your firewall, this is surely the problem. Take in account that you need to open the specified port into your router if it has a firewall function. Make sure to use your public IP address (since you said you were beginner, we never know :) ).
Yep, I was using the local address  ;D

Question 4 : I see some problem with your idea. I don't think player should be able to know their IP address and connect directly. This can lead to severe problems, especialy in an anonymous center. Instead, player shoudl always connect to the server, and then the server send back the data to the other player (allowing you to check for the validity of the data before sending it if you want, proventing your application from cheating systems). You can check the documentation of selector since it will surely do want you want.
I understand the cheating possibility. But here is what I'm most concerned about: money. I don't even know if that's a big deal or not, I'm just trying to foresee my future, but if I make so that all the data being transferred within the players passes through a server to be processed first, I would need the server to be running in a better machine with a better internet connection, right? But if I have the server acting only as a hub where the match-making happens, I can run the server in a much cheaper machine.

Also, as far as I know, cheating will always be a possibility if the cheater is brave enough.

Thoughts?

71
Network / My generic questions about network
« on: April 04, 2016, 05:35:09 am »
Hello friends,
I don't have any problems really, I'm just looking for more experienced programmers to point me to the right direction. This is a little chat I've made using SFML + Dear ImGui. It works fine, it does what it is supposed to do, yet, I want to make sure to learn everything I can with this little program.

ChatSystem.h:
(click to show/hide)

ChatSystem.cpp:
(click to show/hide)

Keep in mind that I have 0 (zero) experience with network programming (not true since I got this chat working  ;D).

Question #1: I only have one socket that I use for everything, connecting, sending and receiving data. Since it is an unblocking socket, could that be a problem? What if I try to send something when it is receiving something? (the send function is not inside any loop).

Question #2: Do sockets have an internal queue or something? In unblocking mode, if I call receive (and there are things to receive) right after I call send, will it return NOT_READY on the second call if it's not done?

Question #3: I'm only able to connect with computers in LAN, why is that?

Question #4: I'm doing this as an exercise for something bigger, a turn-based strategy game. This is how I have the match-making in my mind:
- Player connects to server.
- Server is connected to all the players who are looking for match-making.
- Server says to player: "Hey, you and him are connected to me, which means you are both looking for a match. Here is his sf::IPAddress, try to connect with him."
- If successful, match starts.
- Then it's pretty much like a chat, where player send commands to each other.
Did I get it right? Is it really that simple (I should not say that, I know I'll regret)? What other concepts should I grasp?

Thanks!

72
Window / Re: Poll Event issues
« on: April 03, 2016, 05:31:14 pm »
Since I create the sf::Clock right before the pollEvent call and print and reset it right after the call, there's only one function that can be taking that long to return, am I missing something?


If the while(pollEvent) returns false for multiple frames, it doesn't matter because the clock will always reset before it is called.

The code is pretty minimal already, after your suggestion, I even commented the rest of the loop, but I don't think the rest of the code matters, because as I said, the sf::Clock is always reset.


Hmm....

73
Window / Poll Event issues
« on: April 03, 2016, 07:02:57 am »
Briefly put, the issue is this: a few seconds after having the program running, the pollEvent function in one of its iterations takes a long time (more than 1 second) to do whatever it does.

1) This lag spike happens only once in the entire execution, and it only happens some time within the first 5 seconds of execution. It will run normally after that.

2) I had this problem with SFML 2.0 and now with SFML 2.3.2.

3) I'm using sf::RenderWindow.

This is the code:
...
    while(window.isOpen()){
        sf::Event ev;
        sf::Clock cl;
        while(window.pollEvent(ev)){
            printf("ev.type = %d took %.6fs\n", ev.type, cl.restart().asSeconds());
            if (ev.type == sf::Event::Closed){
                window.close();
            }
        }
    }
...

First execution:


Second execution:


Third execution:


Detailed description: I run the executable, it opens the window and runs the code fine, display whatever it has to display, 2-5 seconds after started, the lag spike happens. It doesn't matter if I let the mouse resting on screen or off-screen, if I don't move the mouse during this first 5 seconds, the next time I move the mouse, the lag spike will happen, 100% of the times.

I'm running Windows 10 and MinGW-4.9.3 compiler, although it also happened when using Windows 8.1 and some other previous MinGW version that I can't recall.

Thanks for helping!

74
SFML projects / Re: Pointless Wars - [Turn-Based Pointless Strategy]
« on: April 01, 2016, 10:56:28 pm »
All caps bold letters with 4 exclamation points, no pressure.  ;D

I can't say how long it will take until I release a test version, all I can say is that I'm the most interested person in finishing the game as quick as possible. I applaud people who can do it for years, but I'm not that person. That's why my game is a circle rather than a line.

Once you draw a circle, that's it. Even if you want to increase its size, you can't unless you redraw it. And if it is a nice circle, people will say "hey nice circle". Another property of a circle is that if it is missing the smallest section, it is not a circle anymore, it is a broken circle, or even worse, an imperfect line.

On the other hand, a line can always be increased in size, and the drawer is always struggling with how further should the line go. If a line is missing a section, it is still a line, and can still be appreciated as such.

My point is, even for testing, I need a complete game.

Does my game design analogy with geometry makes sense? Or more importantly, who cares?  ::)

75
SFML projects / Re: Pointless Wars - [Turn-Based Pointless Strategy]
« on: April 01, 2016, 02:08:34 am »
Thanks, I'm glad you like what you see.
I have a bunch of animations to work on, and on the user interface. Then it will be playable.



(Fullscreen)
(click to show/hide)

I need a way to show the player which units are being targeted.
I'm using a circle, the darker the color, more resistant is the unit for the attack.
A circle highlight works fine, right?

Pages: 1 ... 3 4 [5] 6 7 8