mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-05 21:53:03 +02:00
Initialize Winsock so that Sockets works
This commit is contained in:
parent
9ee77a8f2d
commit
e8fe65f862
4 changed files with 27 additions and 6 deletions
|
@ -7,7 +7,8 @@ else
|
|||
lib = get_option('ruby_lib')
|
||||
binding_dependencies += compiler.find_library(lib)
|
||||
if host_system == 'windows'
|
||||
if lib.endswith('-static')
|
||||
if lib.endswith('-static') and not get_option('fix_essentials')
|
||||
# if fixing up essentials this'll have been added already
|
||||
binding_dependencies += compiler.find_library('wsock32')
|
||||
endif
|
||||
else
|
||||
|
@ -16,10 +17,6 @@ else
|
|||
add_project_arguments('-DOLD_RUBY', language: 'cpp')
|
||||
endif
|
||||
|
||||
if get_option('fix_essentials') == true
|
||||
add_project_arguments('-DUSE_ESSENTIALS_FIXES', language: 'cpp')
|
||||
endif
|
||||
|
||||
binding_headers = files(
|
||||
'binding-util.h',
|
||||
'binding-types.h',
|
||||
|
|
|
@ -8,6 +8,10 @@ if get_option('workdir_current') == true
|
|||
add_project_arguments('-DWORKDIR_CURRENT', language: 'cpp')
|
||||
endif
|
||||
|
||||
if get_option('fix_essentials') == true
|
||||
add_project_arguments('-DUSE_ESSENTIALS_FIXES', language: 'cpp')
|
||||
endif
|
||||
|
||||
subdir('src')
|
||||
subdir('binding')
|
||||
subdir('shader')
|
||||
|
|
20
src/main.cpp
20
src/main.cpp
|
@ -42,6 +42,9 @@
|
|||
|
||||
#ifdef __WINDOWS__
|
||||
#include "resource.h"
|
||||
#ifdef USE_ESSENTIALS_FIXES
|
||||
#include <Winsock2.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "icon.png.xxd"
|
||||
|
@ -266,7 +269,19 @@ int main(int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__WINDOWS__) && defined(USE_ESSENTIALS_FIXES)
|
||||
// Init winsock, allows Win32API socket to work
|
||||
// MKXP itself doesn't need it so it's a little
|
||||
// hands-off
|
||||
WSAData wsadata = {0};
|
||||
if (WSAStartup(0x101, &wsadata) || wsadata.wVersion != 0x101)
|
||||
{
|
||||
char buf[200];
|
||||
sprintf(&buf, "Error initializing winsock: %08X", WSAGetLastError());
|
||||
showInitError(std::string(buf)); // Not an error worth ending the program over
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_Window *win;
|
||||
Uint32 winFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_FOCUS;
|
||||
|
||||
|
@ -371,6 +386,9 @@ int main(int argc, char *argv[])
|
|||
alcCloseDevice(alcDev);
|
||||
SDL_DestroyWindow(win);
|
||||
|
||||
#if defined(__WINDOWS__) && defined(USE_ESSENTIALS_FIXES)
|
||||
if (wsadata.wVersion) WSACleanup();
|
||||
#endif
|
||||
Sound_Quit();
|
||||
TTF_Quit();
|
||||
IMG_Quit();
|
||||
|
|
|
@ -19,6 +19,8 @@ if host_system == 'darwin'
|
|||
if openal.type_name() != 'pkgconfig'
|
||||
add_project_arguments('-DUSE_MAC_OPENAL', language: 'cpp')
|
||||
endif
|
||||
elif host_system == 'windows' and get_option('fix_essentials')
|
||||
main_dependencies += compiler.find_library('wsock32')
|
||||
endif
|
||||
|
||||
if get_option('shared_fluid') == true
|
||||
|
|
Loading…
Add table
Reference in a new issue