mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
Initialize Winsock so that Sockets works
This commit is contained in:
parent
3b36b56c4b
commit
ff943be87b
4 changed files with 27 additions and 6 deletions
|
@ -7,7 +7,8 @@ else
|
||||||
lib = get_option('ruby_lib')
|
lib = get_option('ruby_lib')
|
||||||
binding_dependencies += compiler.find_library(lib)
|
binding_dependencies += compiler.find_library(lib)
|
||||||
if host_system == 'windows'
|
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')
|
binding_dependencies += compiler.find_library('wsock32')
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
|
@ -16,10 +17,6 @@ else
|
||||||
add_project_arguments('-DOLD_RUBY', language: 'cpp')
|
add_project_arguments('-DOLD_RUBY', language: 'cpp')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('fix_essentials') == true
|
|
||||||
add_project_arguments('-DUSE_ESSENTIALS_FIXES', language: 'cpp')
|
|
||||||
endif
|
|
||||||
|
|
||||||
binding_headers = files(
|
binding_headers = files(
|
||||||
'binding-util.h',
|
'binding-util.h',
|
||||||
'binding-types.h',
|
'binding-types.h',
|
||||||
|
|
|
@ -8,6 +8,10 @@ if get_option('workdir_current') == true
|
||||||
add_project_arguments('-DWORKDIR_CURRENT', language: 'cpp')
|
add_project_arguments('-DWORKDIR_CURRENT', language: 'cpp')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if get_option('fix_essentials') == true
|
||||||
|
add_project_arguments('-DUSE_ESSENTIALS_FIXES', language: 'cpp')
|
||||||
|
endif
|
||||||
|
|
||||||
subdir('src')
|
subdir('src')
|
||||||
subdir('binding')
|
subdir('binding')
|
||||||
subdir('shader')
|
subdir('shader')
|
||||||
|
|
20
src/main.cpp
20
src/main.cpp
|
@ -42,6 +42,9 @@
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
#ifdef USE_ESSENTIALS_FIXES
|
||||||
|
#include <Winsock2.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "icon.png.xxd"
|
#include "icon.png.xxd"
|
||||||
|
@ -266,7 +269,19 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
return 0;
|
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;
|
SDL_Window *win;
|
||||||
Uint32 winFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_FOCUS;
|
Uint32 winFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_FOCUS;
|
||||||
|
|
||||||
|
@ -371,6 +386,9 @@ int main(int argc, char *argv[])
|
||||||
alcCloseDevice(alcDev);
|
alcCloseDevice(alcDev);
|
||||||
SDL_DestroyWindow(win);
|
SDL_DestroyWindow(win);
|
||||||
|
|
||||||
|
#if defined(__WINDOWS__) && defined(USE_ESSENTIALS_FIXES)
|
||||||
|
if (wsadata.wVersion) WSACleanup();
|
||||||
|
#endif
|
||||||
Sound_Quit();
|
Sound_Quit();
|
||||||
TTF_Quit();
|
TTF_Quit();
|
||||||
IMG_Quit();
|
IMG_Quit();
|
||||||
|
|
|
@ -19,6 +19,8 @@ if host_system == 'darwin'
|
||||||
if openal.type_name() != 'pkgconfig'
|
if openal.type_name() != 'pkgconfig'
|
||||||
add_project_arguments('-DUSE_MAC_OPENAL', language: 'cpp')
|
add_project_arguments('-DUSE_MAC_OPENAL', language: 'cpp')
|
||||||
endif
|
endif
|
||||||
|
elif host_system == 'windows' and get_option('fix_essentials')
|
||||||
|
main_dependencies += compiler.find_library('wsock32')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('shared_fluid') == true
|
if get_option('shared_fluid') == true
|
||||||
|
|
Loading…
Add table
Reference in a new issue