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
Port for windows #18
Conversation
@@ -545,7 +545,7 @@ void StopServer() | |||
server.running = 0; | |||
} | |||
|
|||
static void* serverConsole(void* arg) | |||
static void serverConsole(void* arg) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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"); | ||
} | ||
|
There was a problem hiding this comment.
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")) { |
There was a problem hiding this comment.
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; | ||
|
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
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. 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. |
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 |
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 ;) |
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 |
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. |
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:
I'll fix this and do a PR when I can.