[SOLVED]Opendungeons : SFML "not milling" the network
 Posted: 23 Mar 2020, 18:53
Posted: 23 Mar 2020, 18:53SOLVED VIA IRC -- thanks Rampoina[m]
Hi,
As you know I try to write a new game editor for Opendungeons, and our forum is empty ( well except Danimal, hello ! ) .... I was wondering why there was no load option in the old game editor - now I see how hard it is to implement one .... Problem is I need to restart the ODServer and ODClient of which code uses the SFML api. But to the point :
ODClient should send a message "hello" and ODServer should respond with "load_level" message and the packet with the map info , problem is that message gets lost .... I mean it does finally that message when the main loop of the game mills several times ... but I need that recived at the point I pasted here ( because I need to start minimap and object culling, and I don't imagine doing that afterwards, after several iterations of main game loop ) ....
I though
Intuitively I need to force SFML library to flush out the packet which stands on the server side ....
So any SFML expert on board ?
https://github.com/tomluchowski/OpenDungeons/tree/new-editor
			Hi,
As you know I try to write a new game editor for Opendungeons, and our forum is empty ( well except Danimal, hello ! ) .... I was wondering why there was no load option in the old game editor - now I see how hard it is to implement one .... Problem is I need to restart the ODServer and ODClient of which code uses the SFML api. But to the point :
- {l Code}: {l Select All Code}
- if(ODClient::getSingleton().isConnected())
 ODClient::getSingleton().disconnect(mKeepReplayAtDisconnect);
 if(ODServer::getSingleton().isConnected())
 ODServer::getSingleton().stopServer();
 // Now that the server is stopped, we can clear the client game map
 mGameMap->clearAll();
 ConfigManager& config = ConfigManager::getSingleton();
 std::string nickname = config.getGameValue(Config::NICKNAME, std::string(), false);
 if(!ODServer::getSingleton().startServer(nickname, dialogFullPath, ServerMode::ModeEditor, false))
 {
 OD_LOG_ERR("Could not start server for editor !!!");
 return true;
 }
 int port = ODServer::getSingleton().getNetworkPort();
 uint32_t timeout = ConfigManager::getSingleton().getClientConnectionTimeout();
 std::string replayFilename = ResourceManager::getSingleton().getReplayDataPath()
 + ResourceManager::getSingleton().buildReplayFilename();
 // We connect ourself
 if(!ODClient::getSingleton().connect("localhost", port, timeout, replayFilename))
 {
 OD_LOG_ERR("Could not connect to server for editor !!!");
 return true;
 }
 ODClient::getSingleton().processClientSocketMessages();
 ODClient::getSingleton().processClientNotifications();
ODClient should send a message "hello" and ODServer should respond with "load_level" message and the packet with the map info , problem is that message gets lost .... I mean it does finally that message when the main loop of the game mills several times ... but I need that recived at the point I pasted here ( because I need to start minimap and object culling, and I don't imagine doing that afterwards, after several iterations of main game loop ) ....
I though
- {l Code}: {l Select All Code}
- ODClient::getSingleton().processClientSocketMessages();
 ODClient::getSingleton().processClientNotifications();
- {l Code}: {l Select All Code}
- bool ODSocketClient::isDataAvailable()
 {
 switch(mSource)
 {
 case ODSource::none:
 {
 return false;
 }
 case ODSource::network:
 {
 // There is only 1 socket in the selector so it should be ready if
 // wait returns true but it doesn't hurt to return isReady...
 if(!mSockSelector.wait(sf::milliseconds(5)))
 return false;
 return mSockSelector.isReady(mSockClient);
 }
- {l Code}: {l Select All Code}
- if(!mSockSelector.wait(sf::milliseconds(5)))
 return false;
Intuitively I need to force SFML library to flush out the packet which stands on the server side ....
So any SFML expert on board ?
https://github.com/tomluchowski/OpenDungeons/tree/new-editor