File tree Expand file tree Collapse file tree 6 files changed +30
-7
lines changed Expand file tree Collapse file tree 6 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -1180,8 +1180,17 @@ void ApplicationInit()
11801180 if (*GetOptions ().Graphics .showFPS )
11811181 EnableFrameCount ();
11821182
1183- init_create_window ();
1184- was_window_init = true ;
1183+ if (!HeadlessMode) {
1184+ init_create_window ();
1185+ was_window_init = true ;
1186+ } else {
1187+ #ifdef USE_SDL1
1188+ // Unfortunately no way to init only events queue for SDL1.2
1189+ SDL_Init (SDL_INIT_VIDEO);
1190+ #else
1191+ SDL_Init (SDL_INIT_EVENTS);
1192+ #endif
1193+ }
11851194
11861195 InitializeScreenReader ();
11871196 LanguageInitialize ();
@@ -1237,9 +1246,10 @@ void DiabloInit()
12371246
12381247 DiabloInitScreen ();
12391248
1240- snd_init ();
1241-
1242- ui_sound_init ();
1249+ if (!HeadlessMode) {
1250+ snd_init ();
1251+ ui_sound_init ();
1252+ }
12431253
12441254 // Item graphics are loaded early, they already get touched during hero selection.
12451255 InitItemGFX ();
Original file line number Diff line number Diff line change @@ -312,6 +312,10 @@ void effects_play_sound(SfxID id)
312312
313313int GetSFXLength (SfxID nSFX)
314314{
315+ if (!gbSndInited || !gbSoundOn) {
316+ return 0 ;
317+ }
318+
315319 TSFX &sfx = sgSFX[static_cast <int16_t >(nSFX)];
316320 if (sfx.pSnd == nullptr )
317321 sfx.pSnd = sound_file_load (sfx.pszName .c_str (),
Original file line number Diff line number Diff line change @@ -152,6 +152,8 @@ int CapVolume(int volume)
152152
153153void OptionAudioChanged ()
154154{
155+ if (HeadlessMode)
156+ return ;
155157 effects_cleanup_sfx ();
156158 music_stop ();
157159 snd_deinit ();
@@ -289,6 +291,9 @@ void music_start(_music_id nTrack)
289291{
290292 const char *trackPath;
291293
294+ if (HeadlessMode)
295+ return ;
296+
292297 assert (nTrack < NUM_MUSIC);
293298 music_stop ();
294299 if (!gbMusicOn)
Original file line number Diff line number Diff line change 1616#include " engine/clx_sprite.hpp"
1717#include " engine/render/clx_render.hpp"
1818#include " engine/surface.hpp"
19+ #include " headless_mode.hpp"
1920#include " utils/display.h"
2021#include " utils/sdl_bilinear_scale.hpp"
2122#include " utils/sdl_wrap.h"
@@ -164,6 +165,8 @@ void SetHardwareCursor(CursorInfo cursorInfo)
164165#if SDL_VERSION_ATLEAST(2, 0, 0)
165166 CurrentCursorInfo = cursorInfo;
166167 CurrentCursorInfo.setNeedsReinitialization (false );
168+ if (HeadlessMode)
169+ return ;
167170 switch (cursorInfo.type ()) {
168171 case CursorType::Game:
169172#if LOG_HWCURSOR
Original file line number Diff line number Diff line change @@ -151,7 +151,7 @@ void mainmenu_loop()
151151
152152 do {
153153 _mainmenu_selections menu = MAINMENU_NONE;
154- if (demo::IsRunning ())
154+ if (demo::IsRunning () || HeadlessMode )
155155 menu = MAINMENU_SINGLE_PLAYER;
156156 else if (!UiMainMenuDialog (gszProductName, &menu, 30 ))
157157 app_fatal (_ (" Unable to display mainmenu" ));
Original file line number Diff line number Diff line change 1717#include " engine/render/clx_render.hpp"
1818#include " engine/render/primitive_render.hpp"
1919#include " engine/render/text_render.hpp"
20+ #include " headless_mode.hpp"
2021#include " playerdat.hpp"
2122#include " textdat.h"
2223#include " utils/language.h"
@@ -162,7 +163,7 @@ void InitQTextMsg(_speech_id m)
162163 default :
163164 break ;
164165 }
165- if (Speeches[m].scrlltxt ) {
166+ if (!HeadlessMode && Speeches[m].scrlltxt ) {
166167 QuestLogIsOpen = false ;
167168 LoadText (_ (Speeches[m].txtstr ));
168169 qtextflag = true ;
You can’t perform that action at this time.
0 commit comments