diff --git a/.travis.yml b/.travis.yml index 546134c0e3..172a8d25ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,9 @@ cache: env: - OPENRCT2_CMAKE_OPTS="-DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt" - OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt" + - OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DDISABLE_HTTP_TWITCH=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt" + - OPENRCT2_CMAKE_OPTS="-DDISABLE_HTTP_TWITCH=ON -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt" + - OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DDISABLE_HTTP_TWITCH=ON -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8" sudo: required diff --git a/CMakeLists.txt b/CMakeLists.txt index 104931660c..14b4af5259 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,8 +26,10 @@ project(${PROJECT}) add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}") add_definitions(-DHAVE_CONFIG_H) add_definitions(-DCURL_STATICLIB) -#uncomment the line bellow if you don't want to build openrct2 with twitch integration -#add_definitions(-DDISABLE_HTTP -DDISABLE_TWITCH) +option(DISABLE_HTTP_TWITCH "Disable HTTP and Twitch support.") +if (DISABLE_HTTP_TWITCH) + add_definitions(-DDISABLE_HTTP -DDISABLE_TWITCH) +endif (DISABLE_HTTP_TWITCH) option(DISABLE_NETWORK "Disable multiplayer functionality. Mainly for testing.") if (DISABLE_NETWORK) @@ -37,7 +39,7 @@ endif (DISABLE_NETWORK) set(ORCTLIBS_INCLUDE /usr/local/cross-tools/orctlibs/include) set(JANSSON_INCLUDE /usr/local/cross-tools/orctlibs/include/jansson) set(ORCTLIBS_LIB_DIR /usr/local/cross-tools/orctlibs/lib) -set(ORCTLIBS_LIB jansson curl ssl crypto ws2_32) +set(ORCTLIBS_LIB jansson curl ssl crypto) # include lib include_directories("lib/") @@ -75,6 +77,6 @@ set_target_properties(${PROJECT} PROPERTIES PREFIX "") TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES} ${ORCTLIBS_LIB}) if (WIN32) - target_link_libraries(${PROJECT} winmm.lib -limm32 -lversion -ldsound) + target_link_libraries(${PROJECT} winmm.lib -limm32 -lversion -ldsound ws2_32) endif (WIN32) diff --git a/Dockerfile b/Dockerfile index 7ddbfc3594..a4202ee790 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,43 +1,60 @@ FROM nfnty/arch-mini -MAINTAINER s0r00t -ENV DISPLAY :0 RUN pacman -Syyu --noconfirm -RUN pacman -S --noconfirm git yajl cmake wget unzip wine +RUN pacman -S --noconfirm git curl jshon expac RUN pacman -S --noconfirm --needed base-devel +RUN pacman -S --noconfirm yajl RUN useradd -mg root travis RUN usermod -aG wheel travis RUN sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers -USER travis WORKDIR /tmp -RUN curl -sL https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=package-query -o PKGBUILD +USER travis +RUN curl -sLO https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=package-query +RUN mv PKGBUILD?h=package-query PKGBUILD RUN makepkg USER root RUN pacman --noconfirm -U *.pkg.tar.xz USER travis -RUN curl -sL https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=yaourt -o PKGBUILD +RUN curl -sLO https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=yaourt +RUN mv PKGBUILD?h=yaourt PKGBUILD RUN makepkg USER root RUN pacman --noconfirm -U *.pkg.tar.xz +RUN pacman -R --noconfirm gcc +RUN yes | pacman -S gcc-libs-multilib +RUN pacman -S --noconfirm gcc-multilib cmake +RUN pacman -S --noconfirm cmake USER travis +RUN yaourt -S --noconfirm mingw-w64-headers +RUN yaourt -S --noconfirm mingw-w64-gcc +RUN yaourt -S --noconfirm wine +RUN yaourt -S --noconfirm mingw-w64-zlib mingw-w64-pkg-config RUN gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys D9C4D26D0E604491 BB5869F064EA74AB 9D5EAAF69013B842 D605848ED7E69871 4DE8FF2A63C7CC90 -RUN yaourt -S --noconfirm mingw-w64-gcc mingw-w64-zlib mingw-w64-pkg-config mingw-w64-openssl mingw-w64-jansson mingw-w64-libtasn1 mingw-w64-gmp mingw-w64-nettle mingw-w64-libffi mingw-w64-p11-kit mingw-w64-readline mingw-w64-gnutls mingw-w64-libunistring mingw-w64-termcap mingw-w64-libidn mingw-w64-curl mingw-w64-expat mingw-w64-libdbus mingw-w64-sdl2 mingw-w64-sdl2_ttf mingw-w64-configure -USER root -RUN pacman --noconfirm -Rns $(pacman -Qttdq) -RUN pacman -Scc --noconfirm -WORKDIR /tmp -RUN rm -r * -WORKDIR /home/travis -USER travis -RUN git clone https://github.com/OpenRCT2/OpenRCT2 -WORKDIR OpenRCT2 -RUN ln -s /usr/i686-w64-mingw32/bin/libfreetype-6.dll -RUN ln -s /usr/i686-w64-mingw32/bin/libwinpthread-1.dll -RUN ln -s /usr/i686-w64-mingw32/bin/SDL2_ttf.dll -RUN ln -s /usr/i686-w64-mingw32/bin/SDL2.dll -RUN ln -s /usr/i686-w64-mingw32/bin/libbz2-1.dll -RUN ./install.sh -RUN ./build.sh +RUN yaourt -S --noconfirm mingw-w64-openssl +RUN yaourt -S --noconfirm mingw-w64-jansson +RUN yaourt -S --noconfirm mingw-w64-libtasn1 +RUN yaourt -S --noconfirm mingw-w64-gmp +RUN yaourt -S --noconfirm mingw-w64-nettle +RUN yaourt -S --noconfirm mingw-w64-libffi +RUN yaourt -S --noconfirm mingw-w64-p11-kit +RUN yaourt -S --noconfirm mingw-w64-readline +RUN yaourt -S --noconfirm mingw-w64-gnutls +RUN yaourt -S --noconfirm mingw-w64-libunistring +RUN yaourt -S --noconfirm mingw-w64-termcap +RUN yaourt -S --noconfirm mingw-w64-gettext +RUN yaourt -S --noconfirm mingw-w64-libidn +RUN yaourt -S --noconfirm mingw-w64-curl +RUN yaourt -S --noconfirm mingw-w64-expat +RUN yaourt -S --noconfirm mingw-w64-libdbus +RUN yaourt -S --noconfirm mingw-w64-sdl2 +RUN yaourt -S --noconfirm mingw-w64-sdl2_ttf +RUN yaourt -S --noconfirm wget unzip +RUN yaourt -S --noconfirm lib32-jansson lib32-curl lib32-sdl2 lib32-sdl2_ttf +RUN yaourt -S --noconfirm lib32-speex +#RUN git clone https://github.com/OpenRCT2/OpenRCT2 +#WORKDIR /tmp/OpenRCT2 +#RUN ./install.sh +#RUN ./build.sh diff --git a/install.sh b/install.sh index 71a204430a..06fdc181b3 100755 --- a/install.sh +++ b/install.sh @@ -74,7 +74,9 @@ if [[ `uname` == "Darwin" ]]; then popd fi elif [[ `uname` == "Linux" ]]; then - sudo dpkg --add-architecture i386 + if [[ ! -z "$TRAVIS" ]]; then + sudo dpkg --add-architecture i386 + fi sudo apt-get update if [[ -z "$TRAVIS" ]]; then sudo apt-get install -y binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 cmake @@ -85,7 +87,9 @@ elif [[ `uname` == "Linux" ]]; then apt-cache search libsdl2 apt-cache policy libsdl2-dev:i386 apt-cache policy libsdl2-dev - sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 cmake libsdl2-dev:i386 libsdl2-ttf-dev:i386 + sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 cmake libsdl2-dev:i386 libsdl2-ttf-dev:i386 gcc-4.8 pkg-config:i386 g++-4.8-multilib gcc-4.8-multilib libjansson-dev:i386 libspeex-dev:i386 libspeexdsp-dev:i386 + export CC=gcc-4.8 + export CXX=g++-4.8 fi fi @@ -148,6 +152,11 @@ if [[ ! -f $cachedir/i686-w64-mingw32-pkg-config ]]; then echo -e "#!/bin/sh\nexport PKG_CONFIG_LIBDIR=/usr/local/cross-tools/i686-w64-mingw32/lib/pkgconfig\npkg-config \$@" > $cachedir/i686-w64-mingw32-pkg-config; fi +set -x +dpkg -L libsdl2-dev +dpkg -L libsdl2-ttf-dev +set +x + chmod +x $cachedir/i686-w64-mingw32-pkg-config sudo cp $cachedir/i686-w64-mingw32-pkg-config /usr/local/bin/ diff --git a/src/audio/audio.c b/src/audio/audio.c index 7531f7b216..07c940768b 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -18,7 +18,9 @@ * along with this program. If not, see . *****************************************************************************/ +#ifdef _WIN32 #include +#endif // _WIN32 #include "../addresses.h" #include "../config.h" @@ -41,11 +43,13 @@ typedef struct { uint32 var_110; uint32 var_114; uint32 var_118; +#ifdef _WIN32 HGLOBAL hmem; // 0x11C HMMIO hmmio; // 0x120 MMCKINFO mmckinfo1; // 0x124 MMCKINFO mmckinfo2; // 0x138 LPDIRECTSOUNDBUFFER dsbuffer; // 0x14C +#endif // _WIN32 uint32 bufsize; // 0x150 uint32 playpos; // 0x154 uint32 var_158; @@ -57,7 +61,9 @@ typedef struct { struct rct_sound_effect { uint32 size; +#ifdef _WIN32 WAVEFORMATEX format; +#endif // _WIN32 uint8* data; }; @@ -73,6 +79,7 @@ void *gCrowdSoundChannel = 0; void *gTitleMusicChannel = 0; bool gGameSoundsOff = false; +#ifdef _WIN32 void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2, int channel); int sound_effect_loadvars(struct rct_sound_effect* sound_effect, LPWAVEFORMATEX* waveformat, char** data, DWORD* buffersize); MMRESULT mmio_open(const char* filename, HMMIO* hmmio, HGLOBAL* hmem, LPMMCKINFO mmckinfo); @@ -86,6 +93,7 @@ int sound_fill_buffer(LPDIRECTSOUNDBUFFER dsbuffer, char* src, DWORD size); void sound_channel_free(HMMIO* hmmio, HGLOBAL* hmem); LPVOID map_file(LPCWSTR lpFileName, DWORD dwCreationDisposition, DWORD dwNumberOfBytesToMap); int unmap_file(LPCVOID base); +#endif // _WIN32 void audio_init(int i) { @@ -126,6 +134,7 @@ void audio_get_devices() } } +#ifdef _WIN32 /** * * rct2: 0x00401000 @@ -329,6 +338,7 @@ int CALLBACK audio_timer_callback(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DW } return 0; } +#endif // _WIN32 /** * @@ -336,6 +346,7 @@ int CALLBACK audio_timer_callback(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DW */ int sub_40153B(int channel) { +#ifdef _WIN32 rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel]; if (sound_channel->var_4) { if (sound_channel->hmmio) { @@ -354,6 +365,9 @@ int sub_40153B(int channel) return 0; } } +#else + STUB(); +#endif // _WIN32 return 1; } @@ -369,6 +383,7 @@ int sub_4015E7(int channel) int buf2size; int read; int zero = 0; +#ifdef _WIN32 rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel]; LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel]; int result = dsbuffer->lpVtbl->Lock(dsbuffer, 0, sound_channel->bufsize, (LPVOID*)&buf1, (LPDWORD)&buf1size, (LPVOID*)&buf2, (LPDWORD)&buf2size, 0); @@ -401,6 +416,10 @@ int sub_4015E7(int channel) sound_channel->playpos = 0; } return result; +#else + STUB(); + return 0; +#endif // _WIN32 } /** @@ -409,6 +428,7 @@ int sub_4015E7(int channel) */ int sound_channel_load_file(int channel, const char* filename, int offset) { +#ifdef _WIN32 rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel]; sound_channel->hmem; sound_channel->hmmio; @@ -441,9 +461,13 @@ int sound_channel_load_file(int channel, const char* filename, int offset) sub_4015E7(channel); sound_channel->var_158 = offset; sound_channel->stopped = 0; +#else + STUB(); +#endif // _WIN32 return 0; } +#ifdef _WIN32 /** * * rct2: 0x00401822 @@ -467,6 +491,7 @@ int mmio_open_channel(int channel, char* filename, LONG offset) sound_channel->var_158 = offset; return 0; } +#endif // _WIN32 /** * @@ -474,6 +499,7 @@ int mmio_open_channel(int channel, char* filename, LONG offset) */ int audio_create_timer() { +#ifdef _WIN32 if (RCT2_GLOBAL(0x009E1AA4, int)) { return 0; } @@ -485,6 +511,9 @@ int audio_create_timer() if (!RCT2_GLOBAL(0x009E1AA0, MMRESULT)) { return 0; } +#else + STUB(); +#endif // _WIN32 RCT2_GLOBAL(0x009E1AA4, int) = 1; return 1; } @@ -498,6 +527,7 @@ int audio_remove_timer() for (int i = 0; i < 4; i++) { sound_channel_stop(i); } +#ifdef _WIN32 if (RCT2_GLOBAL(0x009E1AA4, int)) { timeKillEvent(RCT2_GLOBAL(0x009E1AA0, MMRESULT)); timeEndPeriod(50); @@ -508,6 +538,9 @@ int audio_remove_timer() RCT2_GLOBAL(0x009E1AA4, int) = 0; return result; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -536,6 +569,7 @@ int sound_channel_load_file2(int channel, const char* filename, int offset) */ int sound_channel_play(int channel, int a2, int volume, int pan, int frequency) { +#ifdef _WIN32 rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel]; sound_channel->var_164 = a2; sound_channel_set_frequency(channel, frequency); @@ -545,6 +579,9 @@ int sound_channel_play(int channel, int a2, int volume, int pan, int frequency) dsbuffer->lpVtbl->SetCurrentPosition(dsbuffer, 0); dsbuffer->lpVtbl->Play(dsbuffer, 0, 0, DSBPLAY_LOOPING); sound_channel->playing = 1; +#else + STUB(); +#endif // _WIN32 return 1; } @@ -554,6 +591,7 @@ int sound_channel_play(int channel, int a2, int volume, int pan, int frequency) */ int sound_channel_stop(int channel) { +#ifdef _WIN32 rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel]; sound_channel->playing = 0; sound_channel->stopped = 1; @@ -571,6 +609,9 @@ int sound_channel_stop(int channel) RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel] = 0; } _InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 0); +#else + STUB(); +#endif // _WIN32 return 1; } @@ -580,12 +621,16 @@ int sound_channel_stop(int channel) */ int sound_channel_set_frequency(int channel, int frequency) { +#ifdef _WIN32 LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel]; if (dsbuffer) { if (SUCCEEDED(dsbuffer->lpVtbl->SetFrequency(dsbuffer, frequency))) return 1; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -595,12 +640,16 @@ int sound_channel_set_frequency(int channel, int frequency) */ int sound_channel_set_pan(int channel, int pan) { +#ifdef _WIN32 LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel]; if (dsbuffer) { if (SUCCEEDED(dsbuffer->lpVtbl->SetPan(dsbuffer, pan))) return 1; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -610,12 +659,16 @@ int sound_channel_set_pan(int channel, int pan) */ int sound_channel_set_volume(int channel, int volume) { +#ifdef _WIN32 LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel]; if (dsbuffer) { if (SUCCEEDED(dsbuffer->lpVtbl->SetVolume(dsbuffer, volume))) return 1; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -668,6 +721,7 @@ int sound_channel_is_playing(int channel) int audio_release() { sound_stop_all(); +#ifdef _WIN32 if (RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)) { RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)); RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER) = 0; @@ -682,6 +736,10 @@ int audio_release() RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0; } return result; +#else + STUB(); + return 0; +#endif // _WIN32 } /** @@ -690,6 +748,7 @@ int audio_release() */ int map_sound_effects(const char* filename) { +#ifdef _WIN32 if (RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID)) { return 0; } else { @@ -698,6 +757,10 @@ int map_sound_effects(const char* filename) free(wcFilename); return RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID) != 0; } +#else + STUB(); + return 0; +#endif // _WIN32 } /** @@ -706,12 +769,16 @@ int map_sound_effects(const char* filename) */ int unmap_sound_effects() { +#ifdef _WIN32 if (RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID)) { sound_stop_all(); unmap_file(RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID)); RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID) = 0; return 1; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -721,6 +788,7 @@ int unmap_sound_effects() */ int sound_prepare(int sound_id, rct_sound *sound, int channels, int software) { +#ifdef _WIN32 DSBUFFERDESC bufferdesc; char* buffer = 0; memset(&bufferdesc, 0, sizeof(bufferdesc)); @@ -772,6 +840,9 @@ int sound_prepare(int sound_id, rct_sound *sound, int channels, int software) sound->dsbuffer = 0; } } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -781,6 +852,7 @@ int sound_prepare(int sound_id, rct_sound *sound, int channels, int software) */ int sound_duplicate(rct_sound* newsound, rct_sound* sound) { +#ifdef _WIN32 if (FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->DuplicateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), sound->dsbuffer, &newsound->dsbuffer))) { return 0; } else { @@ -790,6 +862,10 @@ int sound_duplicate(rct_sound* newsound, rct_sound* sound) sound_add(newsound); return 1; } +#else + STUB(); + return 1; +#endif // _WIN32 } /** @@ -798,11 +874,15 @@ int sound_duplicate(rct_sound* newsound, rct_sound* sound) */ int sound_stop(rct_sound* sound) { +#ifdef _WIN32 if (sound->dsbuffer) { sound->dsbuffer->lpVtbl->Release(sound->dsbuffer); sound->dsbuffer = 0; return sound_remove(sound) ? 1 : 0; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -825,6 +905,7 @@ int sound_stop_all() */ void sound_bufferlost_check() { +#ifdef _WIN32 rct_sound* sound = RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*); while (sound && sound != RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*)) { DWORD status; @@ -835,6 +916,9 @@ void sound_bufferlost_check() } sound = sound->next; } +#else + STUB(); +#endif // _WIN32 } /** @@ -842,6 +926,7 @@ void sound_bufferlost_check() * rct2: 0x00404E53 */ int sound_is_playing(rct_sound* sound){ +#ifdef _WIN32 if (sound->dsbuffer) { DWORD status; if (SUCCEEDED(sound->dsbuffer->lpVtbl->GetStatus(sound->dsbuffer, &status))) { @@ -850,6 +935,9 @@ int sound_is_playing(rct_sound* sound){ } } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -859,6 +947,7 @@ int sound_is_playing(rct_sound* sound){ */ int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency) { +#ifdef _WIN32 if (sound->dsbuffer) { sound_set_frequency(sound, frequency); sound_set_pan(sound, pan); @@ -876,6 +965,9 @@ int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency return 1; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -885,11 +977,15 @@ int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency */ int sound_set_frequency(rct_sound* sound, int frequency) { +#ifdef _WIN32 if (sound->dsbuffer) { if (SUCCEEDED(sound->dsbuffer->lpVtbl->SetFrequency(sound->dsbuffer, frequency))) return 1; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -899,11 +995,15 @@ int sound_set_frequency(rct_sound* sound, int frequency) */ int sound_set_pan(rct_sound* sound, int pan) { +#ifdef _WIN32 if (sound->dsbuffer) { if (SUCCEEDED(sound->dsbuffer->lpVtbl->SetPan(sound->dsbuffer, pan))) return 1; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -913,11 +1013,15 @@ int sound_set_pan(rct_sound* sound, int pan) */ int sound_set_volume(rct_sound* sound, int volume) { +#ifdef _WIN32 if (sound->dsbuffer) { if (SUCCEEDED(sound->dsbuffer->lpVtbl->SetVolume(sound->dsbuffer, volume))) return 1; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -927,9 +1031,13 @@ int sound_set_volume(rct_sound* sound, int volume) */ int sound_load3dparameters() { +#ifdef _WIN32 if (SUCCEEDED(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->GetAllParameters(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER), &RCT2_GLOBAL(0x009A6084, DS3DBUFFER)))) { return 1; } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -945,6 +1053,7 @@ int sound_load3dposition() return 0; } +#ifdef _WIN32 /** * * rct2: 0x00404F85 @@ -1017,6 +1126,7 @@ int sound_fill_buffer(LPDIRECTSOUNDBUFFER dsbuffer, char* src, DWORD size) } return 0; } +#endif // _WIN32 /** * @@ -1091,6 +1201,7 @@ rct_sound* sound_remove(rct_sound* sound) */ int sound_bufferlost_restore(rct_sound* sound) { +#ifdef _WIN32 DWORD buffersize = 0; LPWAVEFORMATEX waveformat = 0; char* data = 0; @@ -1102,6 +1213,9 @@ int sound_bufferlost_restore(rct_sound* sound) } } } +#else + STUB(); +#endif // _WIN32 return 0; } @@ -1111,12 +1225,17 @@ int sound_bufferlost_restore(rct_sound* sound) */ struct rct_sound_effect* sound_get_effect(uint16 sound_id) { +#ifdef _WIN32 if (RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID) && sound_id < RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, uint32*)[0]) { return (struct rct_sound_effect*)(RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, int) + RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, uint32*)[sound_id + 1]); } +#else + STUB(); +#endif // _WIN32 return 0; } +#ifdef _WIN32 /** * * rct2: 0x00405222 @@ -1458,6 +1577,7 @@ int get_dsound_devices() } return 0; } +#endif // _WIN32 /** * @@ -1734,6 +1854,7 @@ void stop_title_music() void audio_init1() { int devicenum = 0; +#ifdef _WIN32 if (RCT2_GLOBAL(0x009AAC5C, uint8)) { rct_dsdevice* dsdevice = &RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[0]; while (dsdevice->guid.Data1 != RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_GUID, GUID).Data1 || @@ -1763,6 +1884,9 @@ void audio_init1() } } } +#else + STUB(); +#endif // _WIN32 } /** @@ -1782,7 +1906,12 @@ void audio_init2(int device) other_sound->id = 0xFFFF; } RCT2_GLOBAL(0x014241BC, uint32) = 1; +#ifdef _WIN32 int successdsound = dsound_create_primary_buffer(0, device, 2, 22050, 16); +#else + int successdsound = 0; + STUB(); +#endif // _WIN32 RCT2_GLOBAL(0x014241BC, uint32) = 0; if (!successdsound) { return; @@ -1799,7 +1928,11 @@ void audio_init2(int device) } RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = device; rct_dsdevice dsdevice = RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[device]; +#ifdef _WIN32 RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_GUID, GUID) = dsdevice.guid; +#else + STUB(); +#endif // _WIN32 RCT2_GLOBAL(0x009AAC5C, uint8) = 1; config_save_default(); RCT2_GLOBAL(0x014241BC, uint32) = 1; diff --git a/src/audio/audio.h b/src/audio/audio.h index 648d937ac7..7c6ca1431d 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -8,12 +8,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program. If not, see . *****************************************************************************/ @@ -21,7 +21,9 @@ #ifndef _AUDIO_H_ #define _AUDIO_H_ +#ifdef _WIN32 #include +#endif // _WIN32 #include "../common.h" #include "../world/sprite.h" @@ -44,16 +46,24 @@ void audio_get_devices(); * Represents a single directsound device. */ typedef struct { +#ifdef _WIN32 GUID guid; char desc[256]; char drvname[256]; +#else + uint8 padding[16+256+256]; +#endif // _WIN32 } rct_dsdevice; /** * Represents a prepared sound. */ typedef struct rct_sound { +#ifdef _WIN32 struct IDirectSoundBuffer *dsbuffer; +#else + void *padding; +#endif // _WIN32 uint16 id; uint16 var_8; int has_caps; @@ -162,15 +172,19 @@ int sound_set_pan(rct_sound* sound, int pan); int sound_set_volume(rct_sound* sound, int volume); int sound_load3dparameters(); int sound_load3dposition(); +#ifdef _WIN32 int dsound_count_devices(); +#endif // _WIN32 rct_sound* sound_begin(); rct_sound* sound_next(rct_sound* sound); rct_sound* sound_add(rct_sound* sound); rct_sound* sound_remove(rct_sound* sound); int sound_bufferlost_restore(rct_sound* sound); struct rct_sound_effect* sound_get_effect(uint16 sound_id); +#ifdef _WIN32 int dsound_create_primary_buffer(int a, int device, int channels, int samples, int bits); int get_dsound_devices(); +#endif // _WIN32 int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z); void stop_completed_sounds(); void start_title_music(); diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp index 909347c73b..26470fe369 100644 --- a/src/audio/mixer.cpp +++ b/src/audio/mixer.cpp @@ -18,7 +18,9 @@ * along with this program. If not, see . *****************************************************************************/ +#ifdef _WIN32 #include +#endif // _WIN32 extern "C" { #include "../config.h" @@ -103,7 +105,11 @@ bool Source_Sample::LoadWAV(const char* filename) if (spec != NULL) { format.freq = spec->freq; +#ifdef _WIN32 format.format = spec->format; +#else + STUB(); +#endif // _WIN32 format.channels = spec->channels; issdlwav = true; } else { @@ -138,11 +144,15 @@ bool Source_Sample::LoadCSS1(const char *filename, unsigned int offset) Uint32 soundsize; SDL_RWread(rw, &soundsize, sizeof(soundsize), 1); length = soundsize; +#ifdef _WIN32 WAVEFORMATEX waveformat; SDL_RWread(rw, &waveformat, sizeof(waveformat), 1); format.freq = waveformat.nSamplesPerSec; format.format = AUDIO_S16LSB; format.channels = waveformat.nChannels; +#else + STUB(); +#endif // _WIN32 data = new (std::nothrow) uint8[length]; if (!data) { log_verbose("Unable to allocate data"); @@ -170,6 +180,7 @@ void Source_Sample::Unload() bool Source_Sample::Convert(AudioFormat format) { +#ifdef _WIN32 if(Source_Sample::format.format != format.format || Source_Sample::format.channels != format.channels || Source_Sample::format.freq != format.freq){ SDL_AudioCVT cvt; if (SDL_BuildAudioCVT(&cvt, Source_Sample::format.format, Source_Sample::format.channels, Source_Sample::format.freq, format.format, format.channels, format.freq) < 0) { @@ -188,6 +199,9 @@ bool Source_Sample::Convert(AudioFormat format) Source_Sample::format = format; return true; } +#else + STUB(); +#endif // _WIN32 return false; } @@ -262,6 +276,7 @@ bool Source_SampleStream::LoadWAV(SDL_RWops* rw) return false; } Uint64 chunkstart = SDL_RWtell(rw); +#ifdef _WIN32 PCMWAVEFORMAT waveformat; SDL_RWread(rw, &waveformat, sizeof(waveformat), 1); SDL_RWseek(rw, chunkstart + fmtchunk_size, RW_SEEK_SET); @@ -283,6 +298,9 @@ bool Source_SampleStream::LoadWAV(SDL_RWops* rw) break; } format.channels = waveformat.wf.nChannels; +#else + STUB(); +#endif // _WIN32 const Uint32 DATA = 0x61746164; Uint32 datachunk_size = FindChunk(rw, DATA); if (!datachunk_size) { @@ -444,6 +462,7 @@ void Mixer::Init(const char* device) { Close(); SDL_AudioSpec want, have; +#ifdef _WIN32 SDL_zero(want); want.freq = 44100; want.format = AUDIO_S16SYS; @@ -455,6 +474,9 @@ void Mixer::Init(const char* device) format.format = have.format; format.channels = have.channels; format.freq = have.freq; +#else + STUB(); +#endif // _WIN32 const char* filename = get_file_path(PATH_ID_CSS1); for (int i = 0; i < countof(css1sources); i++) { Source_Sample* source_sample = new Source_Sample; @@ -567,6 +589,7 @@ void SDLCALL Mixer::Callback(void* arg, uint8* stream, int length) void Mixer::MixChannel(Channel& channel, uint8* data, int length) { +#ifdef _WIN32 if (channel.source && channel.source->Length() > 0 && !channel.done && gConfigSound.sound) { AudioFormat streamformat = channel.source->Format(); int loaded = 0; @@ -710,6 +733,9 @@ void Mixer::MixChannel(Channel& channel, uint8* data, int length) channel.done = true; } } +#else + STUB(); +#endif // _WIN32 } void Mixer::EffectPanS16(Channel& channel, sint16* data, int length) @@ -752,10 +778,14 @@ void Mixer::EffectFadeU8(uint8* data, int length, int startvolume, int endvolume bool Mixer::MustConvert(Source& source) { +#ifdef _WIN32 const AudioFormat sourceformat = source.Format(); if (sourceformat.format != format.format || sourceformat.channels != format.channels || sourceformat.freq != format.freq) { return true; } +#else + STUB(); +#endif // _WIN32 return false; } @@ -880,4 +910,4 @@ void* Mixer_Play_Music(int pathid, int loop, int streaming) } } return 0; -} \ No newline at end of file +} diff --git a/src/audio/mixer.h b/src/audio/mixer.h index 3f592fa6f3..fde3658d73 100644 --- a/src/audio/mixer.h +++ b/src/audio/mixer.h @@ -21,8 +21,15 @@ #ifndef _MIXER_H_ #define _MIXER_H_ +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus #include "../common.h" #include +#include "../platform/platform.h" +#ifdef __cplusplus +} +#endif // __cplusplus #define USE_MIXER @@ -206,11 +213,15 @@ void Mixer_Channel_SetGroup(void* channel, int group); void* Mixer_Play_Music(int pathid, int loop, int streaming); static int DStoMixerVolume(int volume) { return (int)(SDL_MIX_MAXVOLUME * (SDL_pow(10, (float)volume / 2000))); }; +#ifdef _WIN32 static float DStoMixerPan(int pan) { return (((float)pan + -DSBPAN_LEFT) / DSBPAN_RIGHT) / 2; }; +#else +static float DStoMixerPan(int pan) { STUB(); return ((float)pan) / 2; }; +#endif // _WIN32 static double DStoMixerRate(int frequency) { return (double)frequency / 22050; }; #ifdef __cplusplus } #endif -#endif \ No newline at end of file +#endif diff --git a/src/drawing/rect.c b/src/drawing/rect.c index 297dafd849..70894fe0ac 100644 --- a/src/drawing/rect.c +++ b/src/drawing/rect.c @@ -21,6 +21,7 @@ #include "../addresses.h" #include "../common.h" #include "drawing.h" +#include "../platform/platform.h" /** * @@ -324,4 +325,4 @@ void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short ri } } } -} \ No newline at end of file +} diff --git a/src/hook.c b/src/hook.c index 185d4680b5..0471ad3037 100644 --- a/src/hook.c +++ b/src/hook.c @@ -18,13 +18,17 @@ * along with this program. If not, see . *****************************************************************************/ +#ifdef _WIN32 #include +#endif // _WIN32 #include "hook.h" +#include "platform/platform.h" void* g_hooktableaddress = 0; int g_hooktableoffset = 0; int g_maxhooks = 1000; +#ifdef _WIN32 void hookfunc(int address, int newaddress, int stacksize, int registerargs[], int registersreturned, int eaxDestinationRegister) { int i = 0; @@ -211,9 +215,11 @@ void hookfunc(int address, int newaddress, int stacksize, int registerargs[], in WriteProcessMemory(GetCurrentProcess(), (LPVOID)address, data, i, 0); } +#endif // _WIN32 void addhook(int address, int newaddress, int stacksize, int registerargs[], int registersreturned, int eaxDestinationRegister) { +#ifdef _WIN32 if (!g_hooktableaddress) { g_hooktableaddress = VirtualAllocEx(GetCurrentProcess(), NULL, g_maxhooks * 100, MEM_COMMIT, PAGE_EXECUTE_READWRITE); } @@ -229,4 +235,7 @@ void addhook(int address, int newaddress, int stacksize, int registerargs[], int WriteProcessMemory(GetCurrentProcess(), (LPVOID)address, data, i, 0); hookfunc(hookaddress, newaddress, stacksize, registerargs, registersreturned, eaxDestinationRegister); g_hooktableoffset++; -} \ No newline at end of file +#else + STUB(); +#endif // _WIN32 +} diff --git a/src/localisation/LanguagePack.cpp b/src/localisation/LanguagePack.cpp index 2b1c9953f7..f50ffb3519 100644 --- a/src/localisation/LanguagePack.cpp +++ b/src/localisation/LanguagePack.cpp @@ -2,6 +2,7 @@ extern "C" { #include "../common.h" #include "../util/util.h" #include "localisation.h" + #include "../platform/platform.h" } #include "../core/FileStream.hpp" diff --git a/src/localisation/localisation.c b/src/localisation/localisation.c index 5149ff66cf..bf532f5639 100644 --- a/src/localisation/localisation.c +++ b/src/localisation/localisation.c @@ -18,6 +18,9 @@ * along with this program. If not, see . *****************************************************************************/ +#ifdef _WIN32 +#include +#endif // _WIN32 #include "../addresses.h" #include "../config.h" #include "../game.h" @@ -848,8 +851,13 @@ int win1252_to_utf8(utf8string dst, const char *src, int maxBufferLength) } } +#ifdef _WIN32 MultiByteToWideChar(CP_ACP, 0, src, -1, intermediateBuffer, bufferCount); int result = WideCharToMultiByte(CP_UTF8, 0, intermediateBuffer, -1, dst, maxBufferLength, NULL, NULL); +#else + STUB(); + int result = 0; +#endif // _WIN32 if (heapBuffer != NULL) { free(heapBuffer); diff --git a/src/network/http.h b/src/network/http.h index ffc051a235..57454af491 100644 --- a/src/network/http.h +++ b/src/network/http.h @@ -1,6 +1,7 @@ #ifndef _HTTP_H_ #define _HTTP_H_ +#ifndef DISABLE_HTTP #include #include "../common.h" @@ -9,10 +10,13 @@ typedef struct { json_t *root; } http_json_response; -void http_init(); -void http_dispose(); http_json_response *http_request_json(const char *url); void http_request_json_async(const char *url, void (*callback)(http_json_response*)); void http_request_json_dispose(http_json_response *response); +#endif // DISABLE_HTTP + +// These callbacks are defined anyway, but are dummy if HTTP is disabled +void http_init(); +void http_dispose(); #endif diff --git a/src/network/network.cpp b/src/network/network.cpp index 304e286999..ba16e7da5e 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -18,7 +18,9 @@ * along with this program. If not, see . *****************************************************************************/ -#include +extern "C" { +#include "../platform/platform.h" +} #include "network.h" diff --git a/src/network/network.h b/src/network/network.h index a5de8b6f99..85652193f6 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -44,6 +44,10 @@ extern "C" { #ifndef DISABLE_NETWORK +#ifdef _WIN32 +#include +#endif // _WIN32 + enum { NETWORK_AUTH_NONE, NETWORK_AUTH_REQUESTED, diff --git a/src/openrct2.c b/src/openrct2.c index 2778948fef..d2df37bac4 100644 --- a/src/openrct2.c +++ b/src/openrct2.c @@ -8,12 +8,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program. If not, see . *****************************************************************************/ @@ -62,7 +62,7 @@ static void openrct2_copy_files_over(const utf8 *originalDirectory, const utf8 * utf8 *ch, filter[MAX_PATH], oldPath[MAX_PATH], newPath[MAX_PATH]; int fileEnumHandle; file_info fileInfo; - + if (!platform_ensure_directory_exists(newDirectory)) { log_error("Could not create directory %s.", newDirectory); return; @@ -80,7 +80,7 @@ static void openrct2_copy_files_over(const utf8 *originalDirectory, const utf8 * while (platform_enumerate_files_next(fileEnumHandle, &fileInfo)) { strcpy(newPath, newDirectory); strcat(newPath, fileInfo.path); - + strcpy(oldPath, originalDirectory); ch = strchr(oldPath, '*'); if (ch != NULL) @@ -115,6 +115,7 @@ static void openrct2_copy_files_over(const utf8 *originalDirectory, const utf8 * // TODO move to platform static void openrct2_set_exe_path() { +#ifdef _WIN32 wchar_t exePath[MAX_PATH]; wchar_t tempPath[MAX_PATH]; wchar_t *exeDelimiter; @@ -127,6 +128,16 @@ static void openrct2_set_exe_path() tempPath[exeDelimiterIndex] = L'\0'; _wfullpath(exePath, tempPath, MAX_PATH); WideCharToMultiByte(CP_UTF8, 0, exePath, countof(exePath), gExePath, countof(gExePath), NULL, NULL); +#else + char exePath[MAX_PATH]; + ssize_t bytesRead; + bytesRead = readlink("/proc/self/exe", exePath, MAX_PATH); + if (bytesRead == -1) { + log_fatal("failed to read /proc/self/exe"); + } + exePath[MAX_PATH - 1] = '\0'; + strncpy(gExePath, exePath, MAX_PATH); +#endif // _WIN32 } /** @@ -179,7 +190,11 @@ bool openrct2_initialise() if (!gOpenRCT2Headless) { audio_init(); audio_get_devices(); +#ifdef _WIN32 get_dsound_devices(); +#else + STUB(); +#endif // _WIN32 } language_open(gConfigGeneral.language); http_init(); @@ -331,7 +346,7 @@ static void openrct2_loop() _spritelocations1[i].y = g_sprite_list[i].unknown.y; _spritelocations1[i].z = g_sprite_list[i].unknown.z; } - + // Update the game so the sprite positions update rct2_update(); diff --git a/src/platform/platform.h b/src/platform/platform.h index 55ef8a5461..23934c5661 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (c) 2014 Ted John * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. - * + * * This file is part of OpenRCT2. - * + * * OpenRCT2 is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -17,11 +17,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . *****************************************************************************/ - + #ifndef _PLATFORM_H_ #define _PLATFORM_H_ +#ifdef _WIN32 #define HAVE_MATH_H +#endif // _WIN32 #include @@ -136,6 +138,26 @@ uint8 platform_get_locale_temperature_format(); int windows_get_registry_install_info(rct2_install_info *installInfo, char *source, char *font, uint8 charset); HWND windows_get_window_handle(); -#endif +#endif // _WIN32 -#endif \ No newline at end of file +#ifdef __linux__ +#include +#include +#define STUB() log_warning("Function %s at %s:%d is a stub.\n", __PRETTY_FUNCTION__, __FILE__, __LINE__) +#define _strcmpi _stricmp +#define _stricmp(x, y) strcasecmp((x), (y)) +#define _strnicmp(x, y, n) strncasecmp((x), (y), (n)) + +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define RCT2_ENDIANESS __ORDER_LITTLE_ENDIAN__ +#define LOBYTE(w) ((uint8_t)(w)) +#define HIBYTE(w) ((uint8_t)(((uint16_t)(w)>>8)&0xFF)) +#endif // __BYTE_ORDER__ + +#ifndef RCT2_ENDIANESS +#error Unknown endianess! +#endif // RCT2_ENDIANESS + +#endif // __linux__ + +#endif diff --git a/src/platform/shared.c b/src/platform/shared.c index a80dffaa05..dc48f40c8c 100644 --- a/src/platform/shared.c +++ b/src/platform/shared.c @@ -736,6 +736,7 @@ void platform_set_cursor(char cursor) static void platform_load_cursors() { RCT2_GLOBAL(0x14241BC, uint32) = 2; +#ifdef _WIN32 HINSTANCE hInst = RCT2_GLOBAL(RCT2_ADDRESS_HINSTANCE, HINSTANCE); RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_ARROW, HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x74)); RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_BLANK, HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0xA1)); @@ -764,6 +765,9 @@ static void platform_load_cursors() RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_ENTRANCE_DOWN, HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0x9F)); RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_HAND_OPEN, HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0xA6)); RCT2_GLOBAL(RCT2_ADDRESS_HCURSOR_HAND_CLOSED, HCURSOR) = LoadCursor(hInst, MAKEINTRESOURCE(0xA5)); +#else + STUB(); +#endif // _WIN32 _cursors[0] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); _cursors[1] = SDL_CreateCursor(blank_cursor_data, blank_cursor_mask, 32, 32, BLANK_CURSOR_HOTX, BLANK_CURSOR_HOTY); diff --git a/src/rct2.c b/src/rct2.c index d432f5d692..e59d65d098 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -333,6 +333,7 @@ int check_files_integrity() { int i; const char *path; +#ifdef _WIN32 HANDLE file; WIN32_FIND_DATA find_data; @@ -350,6 +351,9 @@ int check_files_integrity() FindClose(file); } +#else + STUB(); +#endif // _WIN32 return 1; } @@ -439,6 +443,7 @@ const utf8 *get_file_path(int pathId) */ void get_system_info() { +#ifdef _WIN32 OSVERSIONINFO versionInfo; SYSTEM_INFO sysInfo; MEMORYSTATUS memInfo; @@ -450,10 +455,12 @@ void get_system_info() RCT2_GLOBAL(RCT2_ADDRESS_OS_MINOR_VERSION, uint32) = versionInfo.dwMinorVersion; RCT2_GLOBAL(RCT2_ADDRESS_OS_BUILD_NUMBER, uint32) = versionInfo.dwBuildNumber; } else { +#endif // _WIN32 RCT2_GLOBAL(RCT2_ADDRESS_OS_PLATFORM_ID, uint32) = -1; RCT2_GLOBAL(RCT2_ADDRESS_OS_MAJOR_VERSION, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_OS_MINOR_VERSION, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_OS_BUILD_NUMBER, uint32) = 0; +#ifdef _WIN32 } GetSystemInfo(&sysInfo); @@ -494,6 +501,9 @@ void get_system_info() RCT2_GLOBAL(0x1423C18, sint32) = 1; RCT2_GLOBAL(0x01423C20, uint32) = (SDL_HasMMX() == SDL_TRUE); +#else + STUB(); +#endif // _WIN32 } @@ -503,6 +513,7 @@ void get_system_info() */ void get_system_time() { +#ifdef _WIN32 SYSTEMTIME systime; GetSystemTime(&systime); @@ -510,6 +521,9 @@ void get_system_time() RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MONTH, sint16) = systime.wMonth; RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_YEAR, sint16) = systime.wYear; RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAYOFWEEK, sint16) = systime.wDayOfWeek; +#else + STUB(); +#endif // _WIN32 } /** @@ -518,11 +532,15 @@ void get_system_time() */ void get_local_time() { +#ifdef _WIN32 SYSTEMTIME systime; GetLocalTime(&systime); RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_HOUR, sint16) = systime.wHour; RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MINUTE, sint16) = systime.wMinute; +#else + STUB(); +#endif // _WIN32 } /** diff --git a/src/util/util.c b/src/util/util.c index f96fa54731..f17ac3f424 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -20,6 +20,7 @@ #include "util.h" #include +#include "../platform/platform.h" int squaredmetres_to_squaredfeet(int squaredMetres) {