Skip to content
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

Port for windows #18

Closed
wants to merge 4 commits into from
Closed

Port for windows #18

wants to merge 4 commits into from

Conversation

luizfernandonb
Copy link

Well, it's functional and it compiles and runs perfectly and without warnings on Windows, I haven't tested it on Linux distros or on MacOS because I don't have it in my hands, but I would be grateful if someone could talk later if there was any problem compiling/running on Linux/MacOS.

The only defect is in the console, which in Windows the escape characters are different, so the text output looks like this:
image

I'll fix this and do a PR when I can.

@@ -545,7 +545,7 @@ void StopServer()
server.running = 0;
}

static void* serverConsole(void* arg)
static void serverConsole(void* arg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave it as pointer please. Dont pretype it in the actual passtrough.

exit(-1);

return 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why ?

@@ -571,13 +571,14 @@ static void* serverConsole(void* arg)
rl_clear_history();
#endif

server_sleep(5); // seconds
StopServer();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not needed at all. Like it was there before. Rebase your commits. Dont fix up in later ones :|

@@ -9,7 +9,7 @@
void server_sleep(uint64 seconds)
{
#ifdef WIN32
Sleep(seconds * 1000);
Sleep(seconds * 1000); // The sleep function in Windows is in milliseconds
Copy link
Contributor

Choose a reason for hiding this comment

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

I mean kinda pointless comment. Its kinda obvious.

LOG_DEBUG("epic write fail");
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Pointless new line

if (write(STDIN_FILENO, "\n", sizeof("\n")) != sizeof("\n")) {

// 0 = STDIN_FILENO
if (write(0, "\n", sizeof("\n")) != sizeof("\n")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

No. Just hell no. If it doesnt exist on windows. Define it.

uint64 getNanos(void)
{
struct timespec ts;

Copy link
Contributor

Choose a reason for hiding this comment

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

No. Leave it as it is. It works on windows as it is. Adds pointless complexity.

You literally just copied what mingw does in the clock_gettime functions. Like why ?

Copy link
Author

Choose a reason for hiding this comment

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

clock_gettime is a POSIX function, not from Windows

Copy link
Contributor

Choose a reason for hiding this comment

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

since mingw is ok with it, perhaps wrap it in #ifdef MSVC ot something

if (WIN32)
set_target_properties(enet::enet PROPERTIES
INTERFACE_LINK_LIBRARIES "ws2_32;winmm"
if(WIN32)
Copy link
Contributor

Choose a reason for hiding this comment

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

Afaik ByteBit builds it without this mess ? And it works. You are also basically FORCING users to build with Visual Studio on windows. Which i do not like.

@@ -0,0 +1,16 @@
#include "Functions.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for 2 new files. Put it in 1 of the already existing files.

@@ -0,0 +1,5 @@
// Copyright Luiz Fernando 2022
Copy link
Contributor

Choose a reason for hiding this comment

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

Same. No need.

@@ -22,10 +22,37 @@
#include <string.h>
#include <time.h>

#ifdef WIN32
Copy link
Contributor

Choose a reason for hiding this comment

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

Including Windows api just for 1 function call. Like grrrrr. Let migw handle that.

Copy link
Contributor

Choose a reason for hiding this comment

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

#define WIN32_LEAN_AND_MEAN and we're good :)

@Haxk20
Copy link
Contributor

Haxk20 commented Jul 9, 2022

The entire PR is a mess. Truly. Commits are not properly squashed. Naming is completely off. Unneccessary changes at best. And i could go on. Also complaining that the escape character is wrong for windows while not actually fixing it in the PR.

The project DOES compile on windows AS IS. Without any additional other changes. In these changes you are FORCING users into Visual Studio and mingw or clang. Which they may not want to use or etc.

Considering that it builds on Windows AS IS this likely wont get merged unless there is a truly solid counter argument but even them im on the edge. Fix your build system. Not the project.

The main focus is Linux. And it will continue to be. Who wants to run game server on Windows ? You buy a cheapo VPS and run it on that.
That being said ByteBit did amazing changes to make it work on Windows which were minimal and they continue to work like that. No further tweaks were needed.
The recent builds failed because of pthreads. Which i just have to reinclude 1 library to fix that.

But lets see if it even builds on linux. (It doesnt).

But even then. As i said. It builds as is on Windows. And this just adds mess and complexity to something that already works.

@luizfernandonb
Copy link
Author

The entire PR is a mess. Truly. Commits are not properly squashed. Naming is completely off. Unneccessary changes at best. And i could go on. Also complaining that the escape character is wrong for windows while not actually fixing it in the PR.

The project DOES compile on windows AS IS. Without any additional other changes. In these changes you are FORCING users into Visual Studio and mingw or clang. Which they may not want to use or etc.

Considering that it builds on Windows AS IS this likely wont get merged unless there is a truly solid counter argument but even them im on the edge. Fix your build system. Not the project.

The main focus is Linux. And it will continue to be. Who wants to run game server on Windows ? You buy a cheapo VPS and run it on that. That being said ByteBit did amazing changes to make it work on Windows which were minimal and they continue to work like that. No further tweaks were needed. The recent builds failed because of pthreads. Which i just have to reinclude 1 library to fix that.

But lets see if it even builds on linux. (It doesnt).

But even then. As i said. It builds as is on Windows. And this just adds mess and complexity to something that already works.

If so, do you compile with MinGW?

@Haxk20
Copy link
Contributor

Haxk20 commented Jul 9, 2022

The entire PR is a mess. Truly. Commits are not properly squashed. Naming is completely off. Unneccessary changes at best. And i could go on. Also complaining that the escape character is wrong for windows while not actually fixing it in the PR.
The project DOES compile on windows AS IS. Without any additional other changes. In these changes you are FORCING users into Visual Studio and mingw or clang. Which they may not want to use or etc.
Considering that it builds on Windows AS IS this likely wont get merged unless there is a truly solid counter argument but even them im on the edge. Fix your build system. Not the project.
The main focus is Linux. And it will continue to be. Who wants to run game server on Windows ? You buy a cheapo VPS and run it on that. That being said ByteBit did amazing changes to make it work on Windows which were minimal and they continue to work like that. No further tweaks were needed. The recent builds failed because of pthreads. Which i just have to reinclude 1 library to fix that.
But lets see if it even builds on linux. (It doesnt).
But even then. As i said. It builds as is on Windows. And this just adds mess and complexity to something that already works.

If so, do you compile with MinGW?

I do not but ByteBit does yes.

@Haxk20
Copy link
Contributor

Haxk20 commented Jul 9, 2022

But i would like to see MSVC support. Make the PR the bare minimum to build on MSVC WITHOUT breaking MinGW or Linux builds.

https://discord.gg/yegsgU2D
You can join this discord to discuss if you want :)

@rndtrash
Copy link
Contributor

rndtrash commented Jul 9, 2022

we sure need MSVC support since most of the users rely on it. plus, vcpkg is a great addition actually! just add the mingw support as an alternative, fix the linux build, perhaps add some missing #define-s and its ready to merge!

@Haxk20
Copy link
Contributor

Haxk20 commented Jul 9, 2022

we sure need MSVC support since most of the users rely on it. plus, vcpkg is a great addition actually! just add the mingw support as an alternative, fix the linux build, perhaps add some missing #define-s and its ready to merge!

And massive cleanup of the other unneccesary changes ;)

@luizfernandonb
Copy link
Author

But i would like to see MSVC support. Make the PR the bare minimum to build on MSVC WITHOUT breaking MinGW or Linux builds.

https://discord.gg/yegsgU2D You can join this discord to discuss if you want :)

It's impossible to compile in MSVC without changing something, practically all POSIX functions are not in it, I don't think it's worth it, maybe a solution is to use MingGW, but I'm seeing if it's possible to use it in Visual Studio

@luizfernandonb
Copy link
Author

I didn't find a viable way and that doesn't give so much work to use MinGW + CMake + VCPKG on Windows, I'm going to close this PR, I hope someone in the future can port the server to Windows.

Anyway, thanks everyone.

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.

None yet

3 participants