Merge pull request #1823 from runelaenen/headless

--headless
This commit is contained in:
Ted John 2015-08-19 18:32:11 +01:00
commit 4e578aeaf2
7 changed files with 67 additions and 55 deletions

View File

@ -12,8 +12,7 @@
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommand>$(TargetDir)\openrct2.exe</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>
</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments></LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release with Tests|Win32'">
<LocalDebuggerWorkingDirectory>$(TargetDir)</LocalDebuggerWorkingDirectory>

View File

@ -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];

View File

@ -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;

View File

@ -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;

View File

@ -184,6 +184,7 @@ void platform_draw()
int width = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16);
int height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16);
if (!gOpenRCT2Headless) {
if (gConfigGeneral.hardware_display) {
void *pixels;
int pitch;
@ -193,14 +194,16 @@ void platform_draw()
if (pitch == width * 4) {
uint32 *dst = pixels;
for (int i = width * height; i > 0; i--) { *dst++ = *(uint32 *)(&gPaletteHWMapped[*src++]); }
} else
}
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
}
else
if (pitch == width + padding) {
uint8 *dst = pixels;
for (int y = height; y > 0; y++) {
@ -213,7 +216,8 @@ void platform_draw()
SDL_RenderCopy(gRenderer, gBufferTexture, NULL, NULL);
SDL_RenderPresent(gRenderer);
} else {
}
else {
// Lock the surface before setting its pixels
if (SDL_MUSTLOCK(_surface)) {
if (SDL_LockSurface(_surface) < 0) {
@ -239,6 +243,7 @@ void platform_draw()
exit(1);
}
}
}
}
static void platform_resize(int width, int height)

View File

@ -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*);

View File

@ -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);
}