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 - Tytan

Pages: [1]
1
Network / Re: Tcp server dealing with clients disconnecting
« on: September 28, 2017, 12:59:43 pm »
Thank you so much!
I love you right now! :D

2
Network / Re: Tcp server dealing with clients disconnecting
« on: September 28, 2017, 09:41:55 am »
Was discussing the problem with a friend and he told me that std::unique_ptr doesn't call the constructor for sf::TcpSocket, and that I need to make them own the objects.

As far as I know, I could do this by using:

(click to show/hide)

But I don't know how I would do this in my case since I'm making a vector of them and can't pass args to the constructor of std::unique_ptr...

You're making some very basic mistakes here. You should probably look deeper into vectors and smart pointers.

Is this the what you were talking about?

3
Network / Re: Tcp server dealing with clients disconnecting
« on: September 28, 2017, 07:20:27 am »
Quote
while (listener.accept(clients[numClients + 1].get()) == sf::Socket::Done)
Would be used to accept the newest conection, but I get an error saying that the initial value of reference to non-const must be an lvalue, what does this mean?
Did you google the error message?
It's a C++ error message and I bet you'll find a general explanation of it on StackOverflow or other places.

The best way to get some fast help, is to create a compilable and minimal example that demonstrates the issue. That way anyone can see the full scope and understand what is going on.

The error with the code here doesn't seem to make as much sense to me. It would mean that accept() expects a reference (which it does), but you're passing a r-value object (i.e. temporary variable), which you aren't really. Instead you're passing a raw pointer to the accept function. So that's why I feel the error isn't really describing the problem of the posted code.

Yes I'm an idiot for not googling it.
Sorry about that.

Anyways, I took that same code listener.accept code and put it in a new project.
Same problem...

(click to show/hide)

Might show this to stack overflow (And also prepare for insults lol)

4
Network / Re: Tcp server dealing with clients disconnecting
« on: September 26, 2017, 06:37:10 am »
Please someone help me :(
This is very annoying...

5
Network / Re: Tcp server dealing with clients disconnecting
« on: August 24, 2017, 08:51:20 am »
Also *2, I might go with the unique_ptr option, because with std::list (I think) I would have to remake my entire server loop thingy lol

Also *3, this line:
Quote
while (listener.accept(clients[numClients + 1].get()) == sf::Socket::Done)
Would be used to accept the newest conection, but I get an error saying that the initial value of reference to non-const must be an lvalue, what does this mean?

6
Network / Re: Tcp server dealing with clients disconnecting
« on: August 24, 2017, 08:29:18 am »
Thank you so much!
I think you saved a newb a lot of time with this ;P

Also, which one is better out of the two options? ( If one is better of course ;P )

7
Network / Tcp server dealing with clients disconnecting
« on: August 23, 2017, 01:18:23 pm »
Oooookkayyyy, first off the code is for a server, but the problem is with me trying to remove a client from the list of connected clients.

Problematic code:
(click to show/hide)


Now wtf i'm trying to do:
When a client disconnects, I want to remove them from the list of clients (as said above), but the way I have set up the server makes this really annoying bug, basically if a client disconnects, it kicks the person that joined last.
The way I am trying to fix this is by moving the disconnected clients vector entry thingy to the back of the vector, so that it would continue server-ing normally.


Now the error I end up with by using the above code:

(click to show/hide)


What I've tried:
  • Using a deque instead of a vector to remove elements from the list, and move the ones above to it's place (Same error)
  • (Probs a dumb idea kek) Using a second vector to represent the other one, filled with ints that represent indexes in the client vector, allowing my to do clients[indexs].blah_blah

Extra notes:
  • Clients is a vector of sf::TcpSockets
  • The disconnect check thing is in a for loop iterating though each client connected
  • numClients is how many people are connected



Please don't treat me like people on stack overflow do xD

8
Network / Not sure if noob question... Or real problem
« on: June 03, 2017, 08:20:18 am »
(Sorry for the no-info-title lol.)

Hi! I have a server, and a client program, bothcompile and connect to each other fine, I can connect multiple users and all the good stuff...
But when I try to send data to the server from one of the clients, I need to put 10 characters infront of the message I want to send, otherwise the data is corrupt.
Does anyone know the cause of this madness?

Client (Only posted main loop)
(click to show/hide)

Server (only posted mian loop)
(click to show/hide)

All information will be useful :)

9
Audio / Re: Possible bug in sf::sound
« on: December 02, 2016, 09:51:32 am »
Thank god! Though it was something to do with my code xD

Thanks :)

10
Audio / Possible bug in sf::sound
« on: December 02, 2016, 09:17:47 am »
So, I have a average game, with networking audio, and graphics, I start the game for another round of debugging, and see this in the console window:
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80004005
Failed to open the audio device
An internal OpenAL call failed in SoundBuffer.cpp(46).
Expression:
   alGenBuffers(1, &m_buffer)
Error description:
   AL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundBuffer.cpp(265).
Expression:
   alBufferData(m_buffer, format, &m_samples[0], size, sampleRate)
Error description:
   AL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundSource.cpp(37).
Expression:
   alGenSources(1, &m_source)
Error description:
   AL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenAL call failed in SoundSource.cpp(38).
Expression:
   alSourcei(m_source, AL_BUFFER, 0)
Error description:
   AL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

An internal OpenAL call failed in Sound.cpp(104).
Expression:
   alSourcei(m_source, AL_BUFFER, m_buffer->m_buffer)
Error description:
   AL_INVALID_OPERATION
   The specified operation is not allowed in the current state.

 

Not quite sure if you need the source code for my game, or what this means, is it a bug I have to deal with? xD

11
Graphics / Re: rect.getLocalBounds().contains errors
« on: November 28, 2016, 10:32:44 am »
Awesome! That fixed it instantly :D
Thanks!

12
Graphics / rect.getLocalBounds().contains errors
« on: November 28, 2016, 09:58:43 am »
Ok, I'm getting 8 errors and I have no clue why...
Here is the line of code that I've narrowed it down too:
if (exitRect.getGlobalBounds().contains(window.mapPixelToCoords(sf::Mouse::getPosition(window))))

And here is the db output:
>c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\rect.inl(81): error C2589: '(': illegal token on right side of '::'
1>  c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\rect.inl(77): note: while compiling class template member function 'bool sf::Rect<float>::contains(T,T) const'
1>          with
1>          [
1>              T=float
1>          ]
1>  c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\rect.inl(94): note: see reference to function template instantiation 'bool sf::Rect<float>::contains(T,T) const' being compiled
1>          with
1>          [
1>              T=float
1>          ]
1>  c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\rect.inl(40): note: while compiling class template member function 'sf::Rect<float>::Rect(T,T,T,T)'
1>          with
1>          [
1>              T=float
1>          ]
1>  c:\users\ty\desktop\code stuff\cpp\new work\test\main\main.cpp(64): note: see reference to function template instantiation 'sf::Rect<float>::Rect(T,T,T,T)' being compiled
1>          with
1>          [
1>              T=float
1>          ]
1>  c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\shape.hpp(315): note: see reference to class template instantiation 'sf::Rect<float>' being compiled
1>c:\users\ty\desktop\code stuff\cpp\new work\testclient\sfml\include\sfml\graphics\rect.inl(81): error C2059: syntax error: '::'
1>c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\rect.inl(82): error C2589: '(': illegal token on right side of '::'
1>c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\rect.inl(82): error C2059: syntax error: '::'
1>c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\rect.inl(83): error C2589: '(': illegal token on right side of '::'
1>c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\rect.inl(83): error C2059: syntax error: '::'
1>c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\rect.inl(84): error C2589: '(': illegal token on right side of '::'
1>c:\users\ty\desktop\code stuff\cpp\new work\test\sfml\include\sfml\graphics\rect.inl(84): error C2059: syntax error: '::'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 

If you would want more information, just tell me  :)

Pages: [1]
anything