(svn r1090) -Fix: Made the _openttd_revision variable global, and with that

hopefully killed the windows-revision problem. If WITH_REV is defined, 
for both Windows as *nix system _openttd_revision is filled with normal 
info, else _openttd_revision is set to 'norev000'
-Fix: Small possible server-crash
This commit is contained in:
truelight 2004-12-14 20:27:00 +00:00
parent 52aeaebde0
commit b6c74c1c20
9 changed files with 26 additions and 53 deletions

View File

@ -232,14 +232,6 @@ static void IConsoleWndProc(Window* w, WindowEvent* e)
void IConsoleInit(void)
{
uint i;
#ifdef WITH_REV_HACK
#define WITH_REV
const char _openttd_revision[] = WITH_REV_HACK;
#else
#if defined(WITH_REV)
extern char _openttd_revision[];
#endif
#endif
_iconsole_output_file = NULL;
_iconsole_color_default = 1;
_iconsole_color_error = 3;
@ -604,7 +596,7 @@ void IConsoleAliasExec(const char* cmdline, char* tokens[20], byte tokentypes[20
if (cmdline[i] == '+') {
// all params seperated: "[param 1]" "[param 2]"
t=1;
while ((tokens[t]!=NULL) && (t<20) &&
while ((tokens[t]!=NULL) && (t<20) &&
((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) {
int l2 = strlen(tokens[t]);
*linestream = '"';
@ -623,7 +615,7 @@ void IConsoleAliasExec(const char* cmdline, char* tokens[20], byte tokentypes[20
t=1;
*linestream = '"';
linestream++;
while ((tokens[t]!=NULL) && (t<20) &&
while ((tokens[t]!=NULL) && (t<20) &&
((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) {
int l2 = strlen(tokens[t]);
memcpy(linestream,tokens[t],l2);
@ -640,7 +632,7 @@ void IConsoleAliasExec(const char* cmdline, char* tokens[20], byte tokentypes[20
// one specific parameter: %A = [param 1] %B = [param 2] ...
int l2;
t = ((byte)cmdline[i]) - 64;
if ((t<20) && (tokens[t]!=NULL) &&
if ((t<20) && (tokens[t]!=NULL) &&
((tokentypes[t] == ICONSOLE_VAR_STRING) || (tokentypes[t] == ICONSOLE_VAR_UNKNOWN))) {
l2 = strlen(tokens[t]);
*linestream = '"';

View File

@ -785,16 +785,6 @@ bool NetworkClientConnectGame(const byte* host, unsigned short port)
void NetworkInitGameInfo(void)
{
#ifdef WITH_REV_HACK
#define WITH_REV
const char _openttd_revision[] = WITH_REV_HACK;
#else
#if defined(WITH_REV)
extern char _openttd_revision[];
#else
const char _openttd_revision[] = "norev000";
#endif
#endif
NetworkClientInfo *ci;
ttd_strlcpy(_network_game_info.server_name, _network_server_name, sizeof(_network_game_info.server_name));

View File

@ -56,16 +56,6 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
// String: Unique id to find the player back in server-listing
//
#ifdef WITH_REV_HACK
#define WITH_REV
const char _openttd_revision[] = WITH_REV_HACK;
#else
#if defined(WITH_REV)
extern char _openttd_revision[];
#else
const char _openttd_revision[] = "norev000";
#endif
#endif
Packet *p;
_network_join_status = NETWORK_JOIN_STATUS_AUTHORIZING;
InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);

View File

@ -47,15 +47,6 @@ enum {
static NetworkGameList *_selected_item = NULL;
static int8 _selected_company_item = -1;
#ifdef WITH_REV_HACK
#define WITH_REV
const char _openttd_revision[] = WITH_REV_HACK;
#else
#ifdef WITH_REV
extern char _openttd_revision[];
#endif
#endif
// Truncates a string to max_width (via GetStringWidth) and adds 3 dots
// at the end of the name.
static void NetworkTruncateString(char *name, const int max_width)

View File

@ -577,7 +577,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
NetworkRecv_string(p, client_revision, sizeof(client_revision));
// Too bad, when WITH_REV is disabled, we can not compare the version.
#if defined(WITH_REV) || defined (WITH_REV_HACK)
#if defined(WITH_REV)
// 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) {
@ -1215,6 +1215,9 @@ void NetworkUpdateClientInfo(uint16 client_index)
ci = NetworkFindClientInfoFromIndex(client_index);
if (ci == NULL)
return;
FOR_ALL_CLIENTS(cs) {
SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, ci);
}

View File

@ -20,15 +20,6 @@ static byte *_langpack;
static uint _langtab_num[32]; // Offset into langpack offs
static uint _langtab_start[32]; // Offset into langpack offs
#ifdef WITH_REV_HACK
#define WITH_REV
const char _openttd_revision[] = WITH_REV_HACK;
#else
#ifdef WITH_REV
extern const char _openttd_revision[];
#endif
#endif
typedef byte *PlayerNameGeneratorProc(byte *buffr);
typedef struct {

7
ttd.c
View File

@ -28,6 +28,11 @@
#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 IncreaseSpriteLRU();
@ -645,7 +650,7 @@ int ttd_main(int argc, char* argv[])
// initialize the ingame console
IConsoleInit();
IConsoleCmdExec("exec scripts/autoexec.scr 0");
InitPlayerRandoms();
#ifdef ENABLE_NETWORK

View File

@ -426,6 +426,13 @@ VARDEF int _debug_grf_level;
VARDEF int _debug_ai_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, ...);
#ifdef NO_DEBUG_MESSAGES
#define DEBUG(name, level)

View File

@ -15,6 +15,11 @@
#define SMART_PALETTE_ANIM
/* Declare the revision tag for Windows */
#ifdef WITH_REV_HACK
const char _openttd_revision[] = WITH_REV_HACK;
#endif
static struct {
HWND main_wnd;
HBITMAP dib_sect;
@ -499,9 +504,8 @@ static void MakeWindow(bool full_screen)
SetWindowPos(_wnd.main_wnd, 0, x, y, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
} else {
char Windowtitle[50] = "OpenTTD ";
#ifdef WITH_REV_HACK
#ifdef WITH_REV
// also show revision number/release in window title
extern const char _openttd_revision[];
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);