Skip to content

Add network output, based on MAME's network output system #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

njz3
Copy link

@njz3 njz3 commented Apr 25, 2025

Add TCP server socket 8000 and UDP (broadcast) 8001 for network outputs.

Copy link
Owner

@trzy trzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good feature but substantial rework needed. I don't like the Windows-specific nature of this. I think it's unnecessary: UDP should be done via SDL2_net, not Winsock, and threading should be done with std::thread, not the Windows API.

Also, make sure to add the Supermodel file header to each source file.

struct Packet
{

static const UINT32 BUFFER_SIZE_UDP = 1460;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we convert tabs to spaces everywhere? I think we are using a 4-character tab stop.

#include <vector>
#include <thread>

namespace SMUDP
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this namespace at all?


#pragma comment(lib, "ws2_32.lib")

WinSockWrap::WinSockWrap()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is Winsock needed? SDL2_net has UDP, to my knowledge. This should be platform-agnostic, similar to the netplay TCP code, no?

@@ -1582,6 +1583,9 @@ static Util::Config::Node DefaultConfig()
#endif
config.Set("Outputs", "none");
config.Set("DumpTextures", false);
config.Set("NetOutputsWithLF", "1");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can probably drop the Net prefix here and just group these below "Outputs".

@@ -1582,6 +1583,9 @@ static Util::Config::Node DefaultConfig()
#endif
config.Set("Outputs", "none");
config.Set("DumpTextures", false);
config.Set("NetOutputsWithLF", "1");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OutputsWithLF should probably be a bool rather than int?

// Will do SendUdpBroadcastWithId();
}

LRESULT CNetOutputs::CreateServerThread()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor to eliminate all Windows dependencies here. std::thread can be used. No need for any Windows functions or types like LRESULT, DWORD, etc.

@@ -359,6 +359,10 @@ xcopy /D /Y "$(ProjectDir)..\Assets\*" "$(TargetDir)Assets"</Command>
<ClCompile Include="..\Src\Network\SimNetBoard.cpp" />
<ClCompile Include="..\Src\Network\TCPReceive.cpp" />
<ClCompile Include="..\Src\Network\TCPSend.cpp" />
<ClCompile Include="..\Src\Network\TCPSendAsync.cpp" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to update Rules.inc in Makefiles.

@dukeeeey
Copy link
Collaborator

All the network stuff is copy/paste from much earlier versions of supermodel before the networking code really worked. They shouldn't be needed I don't think for the mame outptut stuff. Tbh not even sure what it is / for.

@trzy
Copy link
Owner

trzy commented Apr 25, 2025

All the network stuff is copy/paste from much earlier versions of supermodel before the networking code really worked. They shouldn't be needed I don't think for the mame outptut stuff. Tbh not even sure what it is / for.

I've never used this feature but Nik hooked up the original output system to work with something called MameHooker (heh). It's for the various lights on the cabinets, for those who want to emulate those or implement them on custom cabs.

@trzy
Copy link
Owner

trzy commented Apr 25, 2025

The main thing is that the current outputs system is constrained to Windows but this one could actually be platform-independent. Better to do that.

@dukeeeey
Copy link
Collaborator

All the network code is what I wrote for spindizzi when we trying to get networking working. It wasn't required for the mame output stuff. In the end i rewrote the network code for SDL.

@njz3
Copy link
Author

njz3 commented Apr 25, 2025

@dukeeeey That's something I have done a long time ago for my own usage (forcefeedback software), maybe a few years ago, and forgot about it until somebody ask me an update today.
I simply updated the branch up to current master, and commited the files which explains why it is using old code from you.

When I will have spare time I will check your code review. Thank for spending time reviewing it.

@dukeeeey
Copy link
Collaborator

The only files you need are netoutputs.cpp / h. I am pretty sure the rest isn't needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants