diff --git a/projects/openrct2.vcxproj.user b/projects/openrct2.vcxproj.user
index 60b61f231a..e10da7a3ba 100644
--- a/projects/openrct2.vcxproj.user
+++ b/projects/openrct2.vcxproj.user
@@ -12,8 +12,7 @@
$(TargetDir)
WindowsLocalDebugger
$(TargetDir)\openrct2.exe
-
-
+
$(TargetDir)
diff --git a/src/audio/audio.c b/src/audio/audio.c
index 75e4be97d8..4418a6e017 100644
--- a/src/audio/audio.c
+++ b/src/audio/audio.c
@@ -29,6 +29,7 @@
#include "../world/sprite.h"
#include "audio.h"
#include "mixer.h"
+#include "../openrct2.h"
int gAudioDeviceCount;
audio_device *gAudioDevices = NULL;
@@ -1835,7 +1836,7 @@ void unpause_sounds()
*/
void stop_vehicle_sounds()
{
- if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) {
+ if (!gOpenRCT2Headless && RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) {
for (int i = 0; i < countof(gVehicleSoundList)/*7*/; i++) {
rct_vehicle_sound* vehicle_sound = &gVehicleSoundList[i];
//rct_vehicle_sound* vehicle_sound = &RCT2_ADDRESS(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound)[i];
diff --git a/src/cmdline.c b/src/cmdline.c
index a5678a896a..70c5a48996 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -71,12 +71,13 @@ static const char *const usage[] = {
int cmdline_run(const char **argv, int argc)
{
//
- int version = 0, verbose = 0, width = 0, height = 0, port = 0;
+ int version = 0, headless = 0, verbose = 0, width = 0, height = 0, port = 0;
char *server = NULL;
argparse_option_t options[] = {
OPT_HELP(),
OPT_BOOLEAN('v', "version", &version, "show version information and exit"),
+ OPT_BOOLEAN(0, "headless", &headless, "run OpenRCT2 headless"),
OPT_BOOLEAN(0, "verbose", &verbose, "log verbose messages"),
OPT_INTEGER('m', "mode", &sprite_mode, "the type of sprite conversion. 0 = default, 1 = simple closest pixel match, 2 = dithering"),
OPT_STRING(0, "server", &server, "server to connect to"),
@@ -95,6 +96,9 @@ int cmdline_run(const char **argv, int argc)
return 0;
}
+ if (headless)
+ gOpenRCT2Headless = true;
+
if (verbose)
_log_levels[DIAGNOSTIC_LEVEL_VERBOSE] = 1;
diff --git a/src/input.c b/src/input.c
index fd7c50010b..04b0db3b39 100644
--- a/src/input.c
+++ b/src/input.c
@@ -42,6 +42,7 @@
#include "world/map.h"
#include "world/sprite.h"
#include "world/scenery.h"
+#include "openrct2.h"
static int _dragX, _dragY;
static rct_windowclass _dragWindowClass;
@@ -1331,7 +1332,7 @@ void game_handle_keyboard_input()
// Handle key input
- while ((key = get_next_key()) != 0) {
+ while (!gOpenRCT2Headless && (key = get_next_key()) != 0) {
if (key == 255)
continue;
diff --git a/src/platform/shared.c b/src/platform/shared.c
index 75e9efe81c..4e6572e199 100644
--- a/src/platform/shared.c
+++ b/src/platform/shared.c
@@ -184,59 +184,64 @@ void platform_draw()
int width = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16);
int height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16);
- if (gConfigGeneral.hardware_display) {
- void *pixels;
- int pitch;
- if (SDL_LockTexture(gBufferTexture, NULL, &pixels, &pitch) == 0) {
- uint8 *src = (uint8*)_screenBuffer;
- int padding = pitch - (width * 4);
- if (pitch == width * 4) {
- uint32 *dst = pixels;
- for (int i = width * height; i > 0; i--) { *dst++ = *(uint32 *)(&gPaletteHWMapped[*src++]); }
- } else
- if (pitch == (width * 2) + padding) {
- uint16 *dst = pixels;
- for (int y = height; y > 0; y++) {
- for (int x = width; x > 0; x--) { *dst++ = *(uint16 *)(&gPaletteHWMapped[*src++]); }
- dst = (uint16*)(((uint8 *)dst) + padding);
+ if (!gOpenRCT2Headless) {
+ if (gConfigGeneral.hardware_display) {
+ void *pixels;
+ int pitch;
+ if (SDL_LockTexture(gBufferTexture, NULL, &pixels, &pitch) == 0) {
+ uint8 *src = (uint8*)_screenBuffer;
+ int padding = pitch - (width * 4);
+ if (pitch == width * 4) {
+ uint32 *dst = pixels;
+ for (int i = width * height; i > 0; i--) { *dst++ = *(uint32 *)(&gPaletteHWMapped[*src++]); }
}
- } else
- if (pitch == width + padding) {
- uint8 *dst = pixels;
- for (int y = height; y > 0; y++) {
- for (int x = width; x > 0; x--) { *dst++ = *(uint8 *)(&gPaletteHWMapped[*src++]); }
- dst += padding;
+ else
+ if (pitch == (width * 2) + padding) {
+ uint16 *dst = pixels;
+ for (int y = height; y > 0; y++) {
+ for (int x = width; x > 0; x--) { *dst++ = *(uint16 *)(&gPaletteHWMapped[*src++]); }
+ dst = (uint16*)(((uint8 *)dst) + padding);
+ }
+ }
+ else
+ if (pitch == width + padding) {
+ uint8 *dst = pixels;
+ for (int y = height; y > 0; y++) {
+ for (int x = width; x > 0; x--) { *dst++ = *(uint8 *)(&gPaletteHWMapped[*src++]); }
+ dst += padding;
+ }
+ }
+ SDL_UnlockTexture(gBufferTexture);
+ }
+
+ SDL_RenderCopy(gRenderer, gBufferTexture, NULL, NULL);
+ SDL_RenderPresent(gRenderer);
+ }
+ else {
+ // Lock the surface before setting its pixels
+ if (SDL_MUSTLOCK(_surface)) {
+ if (SDL_LockSurface(_surface) < 0) {
+ log_error("locking failed %s", SDL_GetError());
+ return;
}
}
- SDL_UnlockTexture(gBufferTexture);
- }
- SDL_RenderCopy(gRenderer, gBufferTexture, NULL, NULL);
- SDL_RenderPresent(gRenderer);
- } else {
- // Lock the surface before setting its pixels
- if (SDL_MUSTLOCK(_surface)) {
- if (SDL_LockSurface(_surface) < 0) {
- log_error("locking failed %s", SDL_GetError());
- return;
+ // Copy pixels from the virtual screen buffer to the surface
+ memcpy(_surface->pixels, _screenBuffer, _surface->pitch * _surface->h);
+
+ // Unlock the surface
+ if (SDL_MUSTLOCK(_surface))
+ SDL_UnlockSurface(_surface);
+
+ // Copy the surface to the window
+ if (SDL_BlitSurface(_surface, NULL, SDL_GetWindowSurface(gWindow), NULL)) {
+ log_fatal("SDL_BlitSurface %s", SDL_GetError());
+ exit(1);
+ }
+ if (SDL_UpdateWindowSurface(gWindow)) {
+ log_fatal("SDL_UpdateWindowSurface %s", SDL_GetError());
+ exit(1);
}
- }
-
- // Copy pixels from the virtual screen buffer to the surface
- memcpy(_surface->pixels, _screenBuffer, _surface->pitch * _surface->h);
-
- // Unlock the surface
- if (SDL_MUSTLOCK(_surface))
- SDL_UnlockSurface(_surface);
-
- // Copy the surface to the window
- if (SDL_BlitSurface(_surface, NULL, SDL_GetWindowSurface(gWindow), NULL)) {
- log_fatal("SDL_BlitSurface %s", SDL_GetError());
- exit(1);
- }
- if (SDL_UpdateWindowSurface(gWindow)) {
- log_fatal("SDL_UpdateWindowSurface %s", SDL_GetError());
- exit(1);
}
}
}
diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c
index 6b8dcfa672..f3647fe600 100644
--- a/src/ride/vehicle.c
+++ b/src/ride/vehicle.c
@@ -27,6 +27,7 @@
#include "ride.h"
#include "ride_data.h"
#include "vehicle.h"
+#include "../openrct2.h"
static void vehicle_update(rct_vehicle *vehicle);
@@ -167,7 +168,7 @@ int sub_6BC2F3(rct_vehicle* vehicle)
*/
void vehicle_sounds_update()
{
- if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1 && !gGameSoundsOff && gConfigSound.sound) {
+ if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1 && !gGameSoundsOff && gConfigSound.sound && !gOpenRCT2Headless) {
RCT2_GLOBAL(0x00F438A4, rct_viewport*) = (rct_viewport*)-1;
rct_viewport* viewport = (rct_viewport*)-1;
rct_window* window = RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*);
diff --git a/src/world/map.c b/src/world/map.c
index f144dda8d7..1342e3a536 100644
--- a/src/world/map.c
+++ b/src/world/map.c
@@ -36,6 +36,7 @@
#include "map_animation.h"
#include "park.h"
#include "scenery.h"
+#include "../openrct2.h"
/* Replaces 0x00993CCC & 0x00993CCE */
const rct_xy16 TileDirectionDelta[] = {
@@ -3847,7 +3848,7 @@ void map_invalidate_tile_under_zoom(int x, int y, int z0, int z1, int maxZoom)
y2 = y + 32 - z0;
viewport = RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_VIEWPORT_PTR_ARRAY, rct_viewport*);
- while (viewport->width != 0) {
+ while (!gOpenRCT2Headless && viewport->width != 0) {
if (maxZoom == -1 || viewport->zoom <= maxZoom) {
viewport_invalidate(viewport, x1, y1, x2, y2);
}