diff --git a/CMakeLists.txt b/CMakeLists.txt index cdd5e12..ad8266b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.24) +cmake_minimum_required(VERSION 3.16) project(skeldal) # Najít SDL2 knihovnu diff --git a/game/advconfig.c b/game/advconfig.c index 85d18c3..26e56a5 100644 --- a/game/advconfig.c +++ b/game/advconfig.c @@ -2,7 +2,7 @@ #include "advconfig.h" -#include +#include #include diff --git a/game/builder.c b/game/builder.c index e9d253c..a863fa4 100644 --- a/game/builder.c +++ b/game/builder.c @@ -237,7 +237,7 @@ void chveni(int i) pos=!pos; } -void objekty_mimo() +void objekty_mimo(THE_TIMER *t) { schovej_mysku(); ukaz_kompas(1); diff --git a/game/globals.h b/game/globals.h index 4305e99..47676bd 100644 --- a/game/globals.h +++ b/game/globals.h @@ -671,7 +671,7 @@ typedef void (*TIMER_PROC)(THE_TIMER *t); THE_TIMER *add_to_timer(int id,int delay,int maxcall,TIMER_PROC proc); void delete_from_timer(int id); THE_TIMER *find_timer(int id); -void objekty_mimo(void); +void objekty_mimo(THE_TIMER *t); void mouse_set_cursor(int cursor); #define FONT_TSHADOW 0x10000 #define FONT_TSHADOW_GRAY 0x30000 @@ -1006,7 +1006,7 @@ void zmen_skupinu(THUMAN *p); void add_to_group(int num); void group_all(void); const void *build_items_called(const void *p, int32_t *s); -void real_regeneration(void); //regenerace postav behem hry v realu (pouze kondice a mana) +void real_regeneration(THE_TIMER *t); //regenerace postav behem hry v realu (pouze kondice a mana) char sleep_regenerace(THUMAN *p); //regenerace postav behem spani char check_jidlo_voda(THUMAN *p); void prepocitat_postavu(THUMAN *human_selected); diff --git a/game/inv.c b/game/inv.c index daebf73..cdae9ac 100644 --- a/game/inv.c +++ b/game/inv.c @@ -1117,7 +1117,7 @@ char sleep_regenerace(THUMAN *p) } -void real_regeneration() +void real_regeneration(THE_TIMER *t) { int i; THUMAN *p; diff --git a/game/skeldal.c b/game/skeldal.c index 7695d03..6a3c1fa 100644 --- a/game/skeldal.c +++ b/game/skeldal.c @@ -507,7 +507,7 @@ void clrscr(void) -void back_music(void) +void back_music(THE_TIMER *t) { mix_back_sound(0); } @@ -577,7 +577,7 @@ void timming(EVENT_MSG *msg,void **data) THE_TIMER *z; z=&timer_tree;while(z->next!=p && z->next!=NULL) z=z->next; - if (z->next==NULL) return NULL; + if (z->next==NULL) return; } q=p; } @@ -639,7 +639,7 @@ void hold_timer(int id,char hld) SEND_LOG("(TIMER) Timer hold id: %d status: %s",id,hld?"Hold":"Unhold"); } -THE_TIMER *add_to_timer(int id,int delay,int maxcall,void *proc) +THE_TIMER *add_to_timer(int id,int delay,int maxcall,TIMER_PROC proc) { THE_TIMER *q; diff --git a/platform/sdl/sdl_context.cpp b/platform/sdl/sdl_context.cpp index 67e8191..bc7043f 100644 --- a/platform/sdl/sdl_context.cpp +++ b/platform/sdl/sdl_context.cpp @@ -8,6 +8,7 @@ #include #include #include +#include void SDLContext::SDL_Deleter::operator ()(SDL_Window* window) { SDL_DestroyWindow(window); } @@ -508,7 +509,7 @@ SDL_Rect SDLContext::get_window_aspect_rect() const { SDL_Rect w; int ww; int wh; - SDL_GetWindowSizeInPixels(_window.get(), &ww, &wh); + SDL_GetWindowSize(_window.get(), &ww, &wh); if (aspect_x && aspect_y) { int apw = wh * aspect_x / aspect_y; int aph = ww * aspect_y / aspect_x; @@ -575,7 +576,6 @@ void SDLContext::set_quit_callback(std::function fn) { } SDLContext::AudioInfo SDLContext::init_audio(const AudioConfig &config, SDL_AudioCallback cb, void *cb_ctx) { - char buff[256]; _audio.reset(); SDL_AudioSpec aspec = {}; aspec.callback = cb; @@ -587,8 +587,19 @@ SDLContext::AudioInfo SDLContext::init_audio(const AudioConfig &config, SDL_Audi SDL_AudioSpec obtaied = {}; auto id = SDL_OpenAudioDevice(config.audioDevice, 0, &aspec, &obtaied, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_SAMPLES_CHANGE); if (id < 1) { - snprintf(buff, sizeof(buff), "SDL Error create audio: %s\n", SDL_GetError()); - throw std::runtime_error(buff); + std::ostringstream err; + err << "SDL Error create audio:" << SDL_GetError() << "\n"; + int n = SDL_GetNumAudioDevices(0); + if (n == 0) err << "No audio devices are available" << "\n"; + else { + err << "Available audio devices:"; + char sep = ' '; + for (int i = 0; i < n; ++i) { + err << sep << SDL_GetAudioDeviceName(i, 0); + sep = ','; + } + } + throw std::runtime_error(err.str()); } _audio.reset(reinterpret_cast(id));