mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
-Fix: [1030393] some screensizes crashes OTTD. Fix in general bug that only allows resolutions which were multiple of 8 in width and height. Also use closest possible resolution in fullscreen if window size is not a valid resolution (Tron)
This commit is contained in:
parent
d72abf6c3e
commit
f3758d133a
6
gfx.c
6
gfx.c
@ -1660,7 +1660,7 @@ void DrawMouseCursor()
|
|||||||
memcpy_pitch(
|
memcpy_pitch(
|
||||||
_cursor_backup,
|
_cursor_backup,
|
||||||
_screen.dst_ptr + _cursor.draw_pos.x + _cursor.draw_pos.y * _screen.pitch,
|
_screen.dst_ptr + _cursor.draw_pos.x + _cursor.draw_pos.y * _screen.pitch,
|
||||||
_cursor.draw_size.x, _cursor.draw_size.y, _screen.width, _cursor.draw_size.x);
|
_cursor.draw_size.x, _cursor.draw_size.y, _screen.pitch, _cursor.draw_size.x);
|
||||||
|
|
||||||
// Draw cursor on screen
|
// Draw cursor on screen
|
||||||
_cur_dpi = &_screen;
|
_cur_dpi = &_screen;
|
||||||
@ -1711,8 +1711,8 @@ void DrawDirtyBlocks()
|
|||||||
{
|
{
|
||||||
byte *b = _dirty_blocks;
|
byte *b = _dirty_blocks;
|
||||||
int x=0,y=0;
|
int x=0,y=0;
|
||||||
int w = (_screen.width + 63) & ~63;
|
const int w = (_screen.width + 63) & ~63;
|
||||||
int h = _screen.height;
|
const int h = (_screen.height + 7) & ~7;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (*b != 0) {
|
if (*b != 0) {
|
||||||
|
41
sdl.c
41
sdl.c
@ -248,9 +248,8 @@ static void GetVideoModes(void) {
|
|||||||
for(i = 0; modes[i]; i++) {
|
for(i = 0; modes[i]; i++) {
|
||||||
int w = modes[i]->w;
|
int w = modes[i]->w;
|
||||||
int h = modes[i]->h;
|
int h = modes[i]->h;
|
||||||
if (IS_INT_INSIDE(w, 640, MAX_SCREEN_WIDTH+1) &&
|
if (IS_INT_INSIDE(w, 640, MAX_SCREEN_WIDTH + 1) &&
|
||||||
IS_INT_INSIDE(h, 480, MAX_SCREEN_HEIGHT+1) &&
|
IS_INT_INSIDE(h, 480, MAX_SCREEN_HEIGHT + 1)) {
|
||||||
w%8 == 0 && h%8 == 0) { // disable screen resolutions which are not multiples of 8
|
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < n; ++j)
|
for (j = 0; j < n; ++j)
|
||||||
if (_resolutions[j][0] == w && _resolutions[j][1] == h)
|
if (_resolutions[j][0] == w && _resolutions[j][1] == h)
|
||||||
@ -270,35 +269,42 @@ static void GetVideoModes(void) {
|
|||||||
static int GetAvailableVideoMode(int *w, int *h)
|
static int GetAvailableVideoMode(int *w, int *h)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
int best;
|
||||||
|
uint delta;
|
||||||
|
|
||||||
// all modes available?
|
// all modes available?
|
||||||
if (_all_modes)
|
if (_all_modes)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// is the wanted mode among the available modes?
|
// is the wanted mode among the available modes?
|
||||||
for(i = 0; i != _num_resolutions; i++) {
|
for (i = 0; i != _num_resolutions; i++) {
|
||||||
if(*w == _resolutions[i][0] && *h == _resolutions[i][1])
|
if(*w == _resolutions[i][0] && *h == _resolutions[i][1])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// use the closest possible resolution
|
||||||
|
best = 0;
|
||||||
|
delta = abs((_resolutions[0][0] - *w) * (_resolutions[0][1] - *h));
|
||||||
|
for (i = 1; i != _num_resolutions; ++i) {
|
||||||
|
uint newdelta = abs((_resolutions[i][0] - *w) * (_resolutions[i][1] - *h));
|
||||||
|
if (newdelta < delta) {
|
||||||
|
best = i;
|
||||||
|
delta = newdelta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// use the default mode
|
// use the default mode
|
||||||
*w = _resolutions[0][0];
|
*w = _resolutions[best][0];
|
||||||
*h = _resolutions[0][1];
|
*h = _resolutions[best][1];
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CreateMainSurface(int w, int h)
|
static bool CreateMainSurface(int w, int h)
|
||||||
{
|
{
|
||||||
SDL_Surface *newscreen;
|
SDL_Surface *newscreen;
|
||||||
bool sizechange;
|
|
||||||
|
|
||||||
GetAvailableVideoMode(&w, &h);
|
GetAvailableVideoMode(&w, &h);
|
||||||
|
|
||||||
sizechange = (_screen.width != w || _screen.height != h);
|
|
||||||
_screen.pitch = _screen.width = w;
|
|
||||||
_screen.height = h;
|
|
||||||
|
|
||||||
DEBUG(misc, 0) ("sdl: using mode %dx%d", w, h);
|
DEBUG(misc, 0) ("sdl: using mode %dx%d", w, h);
|
||||||
|
|
||||||
// DO NOT CHANGE TO HWSURFACE, IT DOES NOT WORK
|
// DO NOT CHANGE TO HWSURFACE, IT DOES NOT WORK
|
||||||
@ -306,14 +312,17 @@ static bool CreateMainSurface(int w, int h)
|
|||||||
if(newscreen == NULL)
|
if(newscreen == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
_screen.width = newscreen->w;
|
||||||
|
_screen.height = newscreen->h;
|
||||||
|
_screen.pitch = newscreen->pitch;
|
||||||
|
|
||||||
_sdl_screen = newscreen;
|
_sdl_screen = newscreen;
|
||||||
InitPalette();
|
InitPalette();
|
||||||
|
|
||||||
SDL_CALL SDL_WM_SetCaption("OpenTTD", "OpenTTD");
|
SDL_CALL SDL_WM_SetCaption("OpenTTD", "OpenTTD");
|
||||||
SDL_CALL SDL_ShowCursor(0);
|
SDL_CALL SDL_ShowCursor(0);
|
||||||
|
|
||||||
// if(sizechange)
|
GameSizeChanged();
|
||||||
GameSizeChanged();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -491,8 +500,8 @@ static int PollEvent() {
|
|||||||
w = ev.resize.w;
|
w = ev.resize.w;
|
||||||
h = ev.resize.h;
|
h = ev.resize.h;
|
||||||
|
|
||||||
w = clamp(w & ~0x7, 64, MAX_SCREEN_WIDTH);
|
w = clamp(w, 64, MAX_SCREEN_WIDTH);
|
||||||
h = clamp(h & ~0x7, 64, MAX_SCREEN_HEIGHT);
|
h = clamp(h, 64, MAX_SCREEN_HEIGHT);
|
||||||
|
|
||||||
ChangeResInGame(w, h);
|
ChangeResInGame(w, h);
|
||||||
|
|
||||||
|
@ -53,8 +53,9 @@ static StringID *BuildDynamicDropdown(StringID base, int num)
|
|||||||
static int GetCurRes()
|
static int GetCurRes()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i!=_num_resolutions; i++)
|
for(i = 0; i != _num_resolutions; i++)
|
||||||
if (_resolutions[i][0] == _cur_resolution[0] && _resolutions[i][1] == _cur_resolution[1])
|
if (_resolutions[i][0] == _screen.width &&
|
||||||
|
_resolutions[i][1] == _screen.height)
|
||||||
break;
|
break;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
28
win32.c
28
win32.c
@ -340,8 +340,8 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
|||||||
w = r->right - r->left - (r2.right - r2.left);
|
w = r->right - r->left - (r2.right - r2.left);
|
||||||
h = r->bottom - r->top - (r2.bottom - r2.top);
|
h = r->bottom - r->top - (r2.bottom - r2.top);
|
||||||
if (_wnd.double_size) { w >>= 1; h >>= 1; }
|
if (_wnd.double_size) { w >>= 1; h >>= 1; }
|
||||||
w = clamp(w & ~0x7, 64, MAX_SCREEN_WIDTH);
|
w = clamp(w, 64, MAX_SCREEN_WIDTH);
|
||||||
h = clamp(h & ~0x7, 64, MAX_SCREEN_HEIGHT);
|
h = clamp(h, 64, MAX_SCREEN_HEIGHT);
|
||||||
if (_wnd.double_size) { w <<= 1; h <<= 1; }
|
if (_wnd.double_size) { w <<= 1; h <<= 1; }
|
||||||
SetRect(&r2, 0, 0, w, h);
|
SetRect(&r2, 0, 0, w, h);
|
||||||
|
|
||||||
@ -506,13 +506,14 @@ static bool AllocateDibSection(int w, int h)
|
|||||||
BITMAPINFO *bi;
|
BITMAPINFO *bi;
|
||||||
HDC dc;
|
HDC dc;
|
||||||
|
|
||||||
w = clamp(w & ~7, 64, MAX_SCREEN_WIDTH);
|
w = clamp(w, 64, MAX_SCREEN_WIDTH);
|
||||||
h = clamp(h & ~7, 64, MAX_SCREEN_HEIGHT);
|
h = clamp(h, 64, MAX_SCREEN_HEIGHT);
|
||||||
|
|
||||||
if (w == _screen.width && h == _screen.height)
|
if (w == _screen.width && h == _screen.height)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_screen.width = _screen.pitch = w;
|
_screen.width = w;
|
||||||
|
_screen.pitch = (w + 3) & ~0x3;
|
||||||
_screen.height = h;
|
_screen.height = h;
|
||||||
|
|
||||||
if (_wnd.alloced_bits) {
|
if (_wnd.alloced_bits) {
|
||||||
@ -524,17 +525,16 @@ static bool AllocateDibSection(int w, int h)
|
|||||||
memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256);
|
memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256);
|
||||||
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
|
||||||
{
|
if (_wnd.double_size) {
|
||||||
if (_wnd.double_size) {
|
w = (w + 3) & ~0x3;
|
||||||
_wnd.alloced_bits = _wnd.buffer_bits = (byte*)malloc(w * h);
|
_wnd.alloced_bits = _wnd.buffer_bits = (byte*)malloc(w * h);
|
||||||
w *= 2;
|
w *= 2;
|
||||||
h *= 2;
|
h *= 2;
|
||||||
}
|
|
||||||
|
|
||||||
bi->bmiHeader.biWidth = _wnd.width = w;
|
|
||||||
bi->bmiHeader.biHeight = -(_wnd.height = h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bi->bmiHeader.biWidth = _wnd.width = w;
|
||||||
|
bi->bmiHeader.biHeight = -(_wnd.height = h);
|
||||||
|
|
||||||
bi->bmiHeader.biPlanes = 1;
|
bi->bmiHeader.biPlanes = 1;
|
||||||
bi->bmiHeader.biBitCount = 8;
|
bi->bmiHeader.biBitCount = 8;
|
||||||
bi->bmiHeader.biCompression = BI_RGB;
|
bi->bmiHeader.biCompression = BI_RGB;
|
||||||
|
Loading…
Reference in New Issue
Block a user