mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
This commit is contained in:
parent
6cb53e7d34
commit
c58549d512
|
@ -229,6 +229,8 @@ static void IConsoleWndProc(Window* w, WindowEvent* e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern const char _openttd_revision[];
|
||||||
|
|
||||||
void IConsoleInit(void)
|
void IConsoleInit(void)
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
|
@ -253,11 +255,7 @@ void IConsoleInit(void)
|
||||||
_iconsole_cbuffer[i] = 0;
|
_iconsole_cbuffer[i] = 0;
|
||||||
}
|
}
|
||||||
IConsoleStdLibRegister();
|
IConsoleStdLibRegister();
|
||||||
#if defined(WITH_REV)
|
|
||||||
IConsolePrintF(13, "OpenTTD Game Console Revision 6 - %s", _openttd_revision);
|
IConsolePrintF(13, "OpenTTD Game Console Revision 6 - %s", _openttd_revision);
|
||||||
#else
|
|
||||||
IConsolePrint(13, "OpenTTD Game Console Revision 6");
|
|
||||||
#endif
|
|
||||||
IConsolePrint(12, "---------------------------------");
|
IConsolePrint(12, "---------------------------------");
|
||||||
IConsolePrint(12, "use \"help\" for more info");
|
IConsolePrint(12, "use \"help\" for more info");
|
||||||
IConsolePrint(12, "");
|
IConsolePrint(12, "");
|
||||||
|
|
|
@ -783,6 +783,8 @@ bool NetworkClientConnectGame(const byte* host, unsigned short port)
|
||||||
return _networking;
|
return _networking;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern const char _openttd_revision[];
|
||||||
|
|
||||||
void NetworkInitGameInfo(void)
|
void NetworkInitGameInfo(void)
|
||||||
{
|
{
|
||||||
NetworkClientInfo *ci;
|
NetworkClientInfo *ci;
|
||||||
|
|
|
@ -43,6 +43,8 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_COMPANY_INFO)
|
||||||
NetworkSend_Packet(p, MY_CLIENT);
|
NetworkSend_Packet(p, MY_CLIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern const char _openttd_revision[];
|
||||||
|
|
||||||
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
|
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
|
@ -68,25 +68,27 @@ static void NetworkTruncateString(char *name, const int max_width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern const char _openttd_revision[];
|
||||||
|
|
||||||
static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch(e->event) {
|
switch(e->event) {
|
||||||
case WE_PAINT: {
|
case WE_PAINT: {
|
||||||
if (_selected_item == NULL)
|
|
||||||
w->disabled_state = (1<<17) | (1<<18);
|
|
||||||
else if (!_selected_item->online)
|
|
||||||
w->disabled_state = (1<<17); // Server offline, join button disabled
|
|
||||||
else if (_selected_item->info.clients_on == _selected_item->info.clients_max)
|
|
||||||
w->disabled_state = (1<<17); // Server full, join button disabled
|
|
||||||
#ifdef WITH_REV
|
|
||||||
else if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) {
|
|
||||||
if (strncmp(_selected_item->info.server_revision, "norev000", sizeof(_selected_item->info.server_revision)) != 0)
|
|
||||||
w->disabled_state = (1<<17); // Revision mismatch, join button disabled
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
w->disabled_state = 0;
|
w->disabled_state = 0;
|
||||||
|
|
||||||
|
if (_selected_item == NULL) {
|
||||||
|
SETBIT(w->disabled_state, 17); SETBIT(w->disabled_state, 18);
|
||||||
|
} else if (!_selected_item->online) {
|
||||||
|
SETBIT(w->disabled_state, 17); // Server offline, join button disabled
|
||||||
|
} else if (_selected_item->info.clients_on == _selected_item->info.clients_max) {
|
||||||
|
SETBIT(w->disabled_state, 17); // Server full, join button disabled
|
||||||
|
|
||||||
|
// revisions don't match, check if server has no revision; then allow connection
|
||||||
|
} else if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) {
|
||||||
|
if (strncmp(_selected_item->info.server_revision, NOREV_STRING, sizeof(_selected_item->info.server_revision)) != 0)
|
||||||
|
SETBIT(w->disabled_state, 17); // Revision mismatch, join button disabled
|
||||||
|
}
|
||||||
|
|
||||||
SetDParam(0, 0x00);
|
SetDParam(0, 0x00);
|
||||||
SetDParam(2, STR_NETWORK_LAN + _network_connection);
|
SetDParam(2, STR_NETWORK_LAN + _network_connection);
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
|
@ -105,12 +107,8 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
||||||
char servername[NETWORK_NAME_LENGTH];
|
char servername[NETWORK_NAME_LENGTH];
|
||||||
const NetworkGameList *cur_item = _network_game_list;
|
const NetworkGameList *cur_item = _network_game_list;
|
||||||
while (cur_item != NULL) {
|
while (cur_item != NULL) {
|
||||||
#ifdef WITH_REV
|
|
||||||
bool compatible = (strncmp(cur_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) == 0);
|
bool compatible = (strncmp(cur_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) == 0);
|
||||||
#else
|
if (strncmp(cur_item->info.server_revision, NOREV_STRING, sizeof(cur_item->info.server_revision)) == 0)
|
||||||
bool compatible = true; // We have no idea if we are compatible...
|
|
||||||
#endif
|
|
||||||
if (strncmp(cur_item->info.server_revision, "norev000", sizeof(cur_item->info.server_revision)) == 0)
|
|
||||||
compatible = true;
|
compatible = true;
|
||||||
|
|
||||||
if (cur_item == _selected_item)
|
if (cur_item == _selected_item)
|
||||||
|
@ -200,17 +198,15 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
y+=2;
|
y+=2;
|
||||||
|
|
||||||
#ifdef WITH_REV
|
|
||||||
if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) {
|
if (strncmp(_selected_item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH - 1) != 0) {
|
||||||
if (strncmp(_selected_item->info.server_revision, "norev000", sizeof(_selected_item->info.server_revision)) != 0)
|
if (strncmp(_selected_item->info.server_revision, NOREV_STRING, sizeof(_selected_item->info.server_revision)) != 0)
|
||||||
DrawStringMultiCenter(360, y, STR_NETWORK_VERSION_MISMATCH, 2); // server mismatch
|
DrawStringMultiCenter(360, y, STR_NETWORK_VERSION_MISMATCH, 2); // server mismatch
|
||||||
} else
|
} else if (_selected_item->info.clients_on == _selected_item->info.clients_max) {
|
||||||
#endif
|
|
||||||
if (_selected_item->info.clients_on == _selected_item->info.clients_max)
|
|
||||||
// Show: server full, when clients_on == clients_max
|
// Show: server full, when clients_on == clients_max
|
||||||
DrawStringMultiCenter(360, y, STR_NETWORK_SERVER_FULL, 2); // server full
|
DrawStringMultiCenter(360, y, STR_NETWORK_SERVER_FULL, 2); // server full
|
||||||
else if (_selected_item->info.use_password)
|
} else if (_selected_item->info.use_password)
|
||||||
DrawStringMultiCenter(360, y, STR_NETWORK_PASSWORD, 2); // password warning
|
DrawStringMultiCenter(360, y, STR_NETWORK_PASSWORD, 2); // password warning
|
||||||
|
|
||||||
y+=10;
|
y+=10;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -563,6 +563,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMPANY_INFO)
|
||||||
SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)(cs);
|
SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern const char _openttd_revision[];
|
||||||
|
|
||||||
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
|
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
|
||||||
{
|
{
|
||||||
char name[NETWORK_NAME_LENGTH];
|
char name[NETWORK_NAME_LENGTH];
|
||||||
|
@ -576,10 +578,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
|
||||||
|
|
||||||
NetworkRecv_string(p, client_revision, sizeof(client_revision));
|
NetworkRecv_string(p, client_revision, sizeof(client_revision));
|
||||||
|
|
||||||
// Too bad, when WITH_REV is disabled, we can not compare the version.
|
// Check if the client has revision control enabled
|
||||||
#if defined(WITH_REV)
|
if (strncmp(NOREV_STRING, client_revision, sizeof(client_revision)) != 0) {
|
||||||
// Check if the client has WITH_REV enabled
|
|
||||||
if (strncmp("norev000", client_revision, sizeof(client_revision)) != 0) {
|
|
||||||
if (strncmp(_network_game_info.server_revision, client_revision, sizeof(_network_game_info.server_revision) - 1) != 0) {
|
if (strncmp(_network_game_info.server_revision, client_revision, sizeof(_network_game_info.server_revision) - 1) != 0) {
|
||||||
// Different revisions!!
|
// Different revisions!!
|
||||||
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_REVISION);
|
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_REVISION);
|
||||||
|
@ -587,7 +587,6 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
NetworkRecv_string(p, name, sizeof(name));
|
NetworkRecv_string(p, name, sizeof(name));
|
||||||
playas = NetworkRecv_uint8(p);
|
playas = NetworkRecv_uint8(p);
|
||||||
|
|
10
strings.c
10
strings.c
|
@ -20,6 +20,14 @@ static byte *_langpack;
|
||||||
static uint _langtab_num[32]; // Offset into langpack offs
|
static uint _langtab_num[32]; // Offset into langpack offs
|
||||||
static uint _langtab_start[32]; // Offset into langpack offs
|
static uint _langtab_start[32]; // Offset into langpack offs
|
||||||
|
|
||||||
|
#if defined(WITH_REV)
|
||||||
|
extern const char _openttd_revision[];
|
||||||
|
#elif defined(WITH_REV_HACK)
|
||||||
|
const char _openttd_revision[] = WITH_REV_HACK;
|
||||||
|
#else
|
||||||
|
const char _openttd_revision[] = NOREV_STRING;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef byte *PlayerNameGeneratorProc(byte *buffr);
|
typedef byte *PlayerNameGeneratorProc(byte *buffr);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -433,9 +441,7 @@ static byte *DecodeString(byte *buff, const byte *str)
|
||||||
buff = FormatNoCommaNumber(buff, GetParamInt32());
|
buff = FormatNoCommaNumber(buff, GetParamInt32());
|
||||||
break;
|
break;
|
||||||
case 2: /* {REV} */
|
case 2: /* {REV} */
|
||||||
#ifdef WITH_REV
|
|
||||||
buff = str_cat(buff, (const byte*)_openttd_revision);
|
buff = str_cat(buff, (const byte*)_openttd_revision);
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case 3: { /* {SHORTCARGO} */
|
case 3: { /* {SHORTCARGO} */
|
||||||
// Short description of cargotypes. Layout:
|
// Short description of cargotypes. Layout:
|
||||||
|
|
5
ttd.c
5
ttd.c
|
@ -28,11 +28,6 @@
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* Define the _openttd_revision tag if it is not defined */
|
|
||||||
#ifndef WITH_REV
|
|
||||||
const char _openttd_revision[] = "norev000";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void GameLoop();
|
void GameLoop();
|
||||||
|
|
||||||
void IncreaseSpriteLRU();
|
void IncreaseSpriteLRU();
|
||||||
|
|
1
ttd.h
1
ttd.h
|
@ -1,6 +1,7 @@
|
||||||
#ifndef TTD_H
|
#ifndef TTD_H
|
||||||
#define TTD_H
|
#define TTD_H
|
||||||
|
|
||||||
|
#define NOREV_STRING "norev000"
|
||||||
// FIXME: Include only where really needed.
|
// FIXME: Include only where really needed.
|
||||||
// include sprites
|
// include sprites
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
|
|
17
ttd.vcproj
17
ttd.vcproj
|
@ -456,7 +456,6 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\md5.c">
|
RelativePath=".\md5.c">
|
||||||
</File>
|
</File>
|
||||||
|
|
||||||
<File
|
<File
|
||||||
RelativePath="minilzo.c">
|
RelativePath="minilzo.c">
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
|
@ -576,9 +575,6 @@
|
||||||
BasicRuntimeChecks="3"/>
|
BasicRuntimeChecks="3"/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\newgrf.c">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\network_client.c">
|
RelativePath=".\network_client.c">
|
||||||
</File>
|
</File>
|
||||||
|
@ -588,11 +584,14 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\network_gamelist.c">
|
RelativePath=".\network_gamelist.c">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\network_server.c">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\network_udp.c">
|
RelativePath=".\network_udp.c">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\network_server.c">
|
RelativePath=".\newgrf.c">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="oldloader.c">
|
RelativePath="oldloader.c">
|
||||||
|
@ -1172,9 +1171,6 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\network.h">
|
RelativePath=".\network.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\newgrf.h">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\network_client.h">
|
RelativePath=".\network_client.h">
|
||||||
</File>
|
</File>
|
||||||
|
@ -1187,11 +1183,14 @@
|
||||||
<File
|
<File
|
||||||
RelativePath=".\network_gamelist.h">
|
RelativePath=".\network_gamelist.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\network_server.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\network_udp.h">
|
RelativePath=".\network_udp.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\network_server.h">
|
RelativePath=".\newgrf.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="news.h">
|
RelativePath="news.h">
|
||||||
|
|
|
@ -426,13 +426,6 @@ VARDEF int _debug_grf_level;
|
||||||
VARDEF int _debug_ai_level;
|
VARDEF int _debug_ai_level;
|
||||||
VARDEF int _debug_net_level;
|
VARDEF int _debug_net_level;
|
||||||
|
|
||||||
/* Make the revision tag global */
|
|
||||||
extern const char _openttd_revision[];
|
|
||||||
#ifdef WITH_REV_HACK
|
|
||||||
/* Special rules for Windows */
|
|
||||||
#define WITH_REV
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void CDECL debug(const char *s, ...);
|
void CDECL debug(const char *s, ...);
|
||||||
#ifdef NO_DEBUG_MESSAGES
|
#ifdef NO_DEBUG_MESSAGES
|
||||||
#define DEBUG(name, level)
|
#define DEBUG(name, level)
|
||||||
|
|
10
win32.c
10
win32.c
|
@ -15,11 +15,6 @@
|
||||||
|
|
||||||
#define SMART_PALETTE_ANIM
|
#define SMART_PALETTE_ANIM
|
||||||
|
|
||||||
/* Declare the revision tag for Windows */
|
|
||||||
#ifdef WITH_REV_HACK
|
|
||||||
const char _openttd_revision[] = WITH_REV_HACK;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
HWND main_wnd;
|
HWND main_wnd;
|
||||||
HBITMAP dib_sect;
|
HBITMAP dib_sect;
|
||||||
|
@ -446,6 +441,8 @@ static void RegisterWndClass()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern const char _openttd_revision[];
|
||||||
|
|
||||||
static void MakeWindow(bool full_screen)
|
static void MakeWindow(bool full_screen)
|
||||||
{
|
{
|
||||||
_fullscreen = full_screen;
|
_fullscreen = full_screen;
|
||||||
|
@ -504,10 +501,9 @@ static void MakeWindow(bool full_screen)
|
||||||
SetWindowPos(_wnd.main_wnd, 0, x, y, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
|
SetWindowPos(_wnd.main_wnd, 0, x, y, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
|
||||||
} else {
|
} else {
|
||||||
char Windowtitle[50] = "OpenTTD ";
|
char Windowtitle[50] = "OpenTTD ";
|
||||||
#ifdef WITH_REV
|
|
||||||
// also show revision number/release in window title
|
// also show revision number/release in window title
|
||||||
strncat(Windowtitle, _openttd_revision, sizeof(Windowtitle)-(strlen(Windowtitle) + 1));
|
strncat(Windowtitle, _openttd_revision, sizeof(Windowtitle)-(strlen(Windowtitle) + 1));
|
||||||
#endif
|
|
||||||
_wnd.main_wnd = CreateWindow("TTD", Windowtitle, style, x, y, w, h, 0, 0, _inst, 0);
|
_wnd.main_wnd = CreateWindow("TTD", Windowtitle, style, x, y, w, h, 0, 0, _inst, 0);
|
||||||
if (_wnd.main_wnd == NULL)
|
if (_wnd.main_wnd == NULL)
|
||||||
error("CreateWindow failed");
|
error("CreateWindow failed");
|
||||||
|
|
Loading…
Reference in New Issue