From 3a195edcadbfb1042c2b9f666f8256269501ca56 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 15 May 2007 22:02:32 +0000 Subject: [PATCH] (svn r9853) [0.5] -Backport from trunk (r9837, r9827, r9785, r9775, r9758, r9716): - Feature: Add server_lang in [network] section of openttd.cfg (r9716) - Fix: [NewGRF] Catch occurance of division-by-zero in varaction handling (r9837) - Fix: Only non dedicated servers cannot have 0 players [FS#765] (r9785) - Fix: Remove arbitrary limit on length of NewGRF strings (r9775) - Fix: [NewGRF] Ignore axis-bit of station tile layouts [FS#756] (r9758) --- network.c | 2 + newgrf.c | 120 ++++++++++++++++++++----------------------- newgrf_spritegroup.c | 8 +-- openttd.c | 4 +- settings.c | 49 +++++++++--------- station_cmd.c | 4 +- 6 files changed, 92 insertions(+), 95 deletions(-) diff --git a/network.c b/network.c index 7e1de138ac..bde0878627 100644 --- a/network.c +++ b/network.c @@ -1397,11 +1397,13 @@ void NetworkStartUp(void) byte cl_max = _network_game_info.clients_max; byte cp_max = _network_game_info.companies_max; byte sp_max = _network_game_info.spectators_max; + byte s_lang = _network_game_info.server_lang; memset(&_network_game_info, 0, sizeof(_network_game_info)); _network_game_info.clients_max = cl_max; _network_game_info.companies_max = cp_max; _network_game_info.spectators_max = sp_max; + _network_game_info.server_lang = s_lang; } // Let's load the network in windows diff --git a/newgrf.c b/newgrf.c index 2e56e889d0..d94a1a7345 100644 --- a/newgrf.c +++ b/newgrf.c @@ -2096,79 +2096,73 @@ static void FeatureNewName(byte *buf, int len) len -= (int)name_length; - if (name_length == 1) { - DEBUG(grf, 7) ("FeatureNewName: Can't add empty name"); - } else if (name_length > 127) { - DEBUG(grf, 7) ("FeatureNewName: Too long a name (%d)", name_length); - } else { - DEBUG(grf, 8) ("FeatureNewName: %d <- %s", id, name); + DEBUG(grf, 8) ("FeatureNewName: %d <- %s", id, name); - switch (feature) { - case GSF_TRAIN: - case GSF_ROAD: - case GSF_SHIP: - case GSF_AIRCRAFT: { - if (id < TOTAL_NUM_ENGINES) { - StringID string = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_8000_KIRBY_PAUL_TANK_STEAM + id); - SetCustomEngineName(id, string); - } else { - AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, id); - } - break; + switch (feature) { + case GSF_TRAIN: + case GSF_ROAD: + case GSF_SHIP: + case GSF_AIRCRAFT: { + if (id < TOTAL_NUM_ENGINES) { + StringID string = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_8000_KIRBY_PAUL_TANK_STEAM + id); + SetCustomEngineName(id, string); + } else { + AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, id); } + break; + } - default: - switch (GB(id, 8, 8)) { - case 0xC4: /* Station class name */ - if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { - grfmsg(GMS_WARN, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring.", GB(id, 0, 8)); - } else { - StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; - SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED)); - } - break; + default: + switch (GB(id, 8, 8)) { + case 0xC4: /* Station class name */ + if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { + grfmsg(GMS_WARN, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring.", GB(id, 0, 8)); + } else { + StationClassID sclass = _cur_grffile->stations[GB(id, 0, 8)]->sclass; + SetStationClassName(sclass, AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED)); + } + break; - case 0xC5: /* Station name */ - if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { - grfmsg(GMS_WARN, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring.", GB(id, 0, 8)); - } else { - _cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); - } - break; + case 0xC5: /* Station name */ + if (_cur_grffile->stations == NULL || _cur_grffile->stations[GB(id, 0, 8)] == NULL) { + grfmsg(GMS_WARN, "FeatureNewName: Attempt to name undefined station 0x%X, ignoring.", GB(id, 0, 8)); + } else { + _cur_grffile->stations[GB(id, 0, 8)]->name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); + } + break; - case 0xC9: - case 0xD0: - case 0xDC: - AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); - break; + case 0xC9: + case 0xD0: + case 0xDC: + AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED); + break; - default: - DEBUG(grf, 7) ("FeatureNewName: Unsupported ID (0x%04X)", id); - break; - } - break; + default: + DEBUG(grf, 7) ("FeatureNewName: Unsupported ID (0x%04X)", id); + break; + } + break; #if 0 - case GSF_CANAL : - case GSF_BRIDGE : - case GSF_TOWNHOUSE : - AddGRFString(_cur_spriteid, id, lang, name); - switch (GB(id, 8,8)) { - case 0xC9: /* House name */ - default: - DEBUG(grf, 7) ("FeatureNewName: Unsupported ID (0x%04X)", id); - } - break; + case GSF_CANAL : + case GSF_BRIDGE : + case GSF_TOWNHOUSE : + AddGRFString(_cur_spriteid, id, lang, name); + switch (GB(id, 8,8)) { + case 0xC9: /* House name */ + default: + DEBUG(grf, 7) ("FeatureNewName: Unsupported ID (0x%04X)", id); + } + break; - case GSF_INDUSTRIES : - case 0x48 : /* for generic strings */ - AddGRFString(_cur_spriteid, id, lang, name); - break; - default : - DEBUG(grf,7) ("FeatureNewName: Unsupported feature (0x%02X)", feature); - break; + case GSF_INDUSTRIES : + case 0x48 : /* for generic strings */ + AddGRFString(_cur_spriteid, id, lang, name); + break; + default : + DEBUG(grf,7) ("FeatureNewName: Unsupported feature (0x%02X)", feature); + break; #endif - } } } } diff --git a/newgrf_spritegroup.c b/newgrf_spritegroup.c index ef2ca90914..558849c4f8 100644 --- a/newgrf_spritegroup.c +++ b/newgrf_spritegroup.c @@ -118,10 +118,10 @@ static inline usize EvalAdjust_ ## size(const DeterministicSpriteGroupAdjust *ad case DSGA_OP_SMAX: return max(last_value, value); \ case DSGA_OP_UMIN: return min((usize)last_value, (usize)value); \ case DSGA_OP_UMAX: return max((usize)last_value, (usize)value); \ - case DSGA_OP_SDIV: return last_value / value; \ - case DSGA_OP_SMOD: return last_value % value; \ - case DSGA_OP_UDIV: return (usize)last_value / (usize)value; \ - case DSGA_OP_UMOD: return (usize)last_value % (usize)value; \ + case DSGA_OP_SDIV: return value == 0 ? last_value : last_value / value; \ + case DSGA_OP_SMOD: return value == 0 ? last_value : last_value % value; \ + case DSGA_OP_UDIV: return value == 0 ? (usize)last_value : (usize)last_value / (usize)value; \ + case DSGA_OP_UMOD: return value == 0 ? (usize)last_value : (usize)last_value % (usize)value; \ case DSGA_OP_MUL: return last_value * value; \ case DSGA_OP_AND: return last_value & value; \ case DSGA_OP_OR: return last_value | value; \ diff --git a/openttd.c b/openttd.c index 03edb0d7b4..e13c628995 100644 --- a/openttd.c +++ b/openttd.c @@ -1242,8 +1242,8 @@ bool AfterLoadGame(void) // If Load Scenario / New (Scenario) Game is used, // a player does not exist yet. So create one here. // 1 exeption: network-games. Those can have 0 players - // But this exeption is not true for network_servers! - if (!_players[0].is_active && (!_networking || (_networking && _network_server))) + // But this exeption is not true for non dedicated network_servers! */ + if (!_players[0].is_active && (!_networking || (_networking && _network_server && !_network_dedicated))) DoStartupNewPlayer(false); DoZoomInOutWindow(ZOOM_NONE, w); // update button status diff --git a/settings.c b/settings.c index 3257e11015..72ac28ffaa 100644 --- a/settings.c +++ b/settings.c @@ -989,7 +989,7 @@ static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list #define SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, from, to)\ SDTG_GENERAL(name, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, max, 0, full, str, proc, from, to) #define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, proc)\ - SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max full, str, proc, 0, SL_MAX_VERSION) + SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, 0, SL_MAX_VERSION) #define SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, from, to)\ SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, proc, from, to) @@ -1218,29 +1218,30 @@ static const SettingDescGlobVarList _misc_settings[] = { #ifdef ENABLE_NETWORK static const SettingDescGlobVarList _network_settings[] = { - SDTG_VAR("sync_freq", SLE_UINT16,C|S,0, _network_sync_freq, 100, 0, 100, 0, STR_NULL, NULL), - SDTG_VAR("frame_freq", SLE_UINT8,C|S,0, _network_frame_freq, 0, 0, 100, 0, STR_NULL, NULL), - SDTG_VAR("max_join_time", SLE_UINT16, S, 0, _network_max_join_time, 500, 0, 32000, 0, STR_NULL, NULL), - SDTG_BOOL("pause_on_join", S, 0, _network_pause_on_join, true, STR_NULL, NULL), - SDTG_STR("server_bind_ip", SLE_STRB, S, 0, _network_server_bind_ip_host, "0.0.0.0", STR_NULL, NULL), - SDTG_VAR("server_port", SLE_UINT16, S, 0, _network_server_port, NETWORK_DEFAULT_PORT, 0, 65535, 0, STR_NULL, NULL), - SDTG_BOOL("server_advertise", S, 0, _network_advertise, false, STR_NULL, NULL), - SDTG_VAR("lan_internet", SLE_UINT8, S, 0, _network_lan_internet, 0, 0, 1, 0, STR_NULL, NULL), - SDTG_STR("player_name", SLE_STRB, S, 0, _network_player_name, NULL, STR_NULL, NULL), - SDTG_STR("server_password", SLE_STRB, S, 0, _network_server_password, NULL, STR_NULL, NULL), - SDTG_STR("rcon_password", SLE_STRB, S, 0, _network_rcon_password, NULL, STR_NULL, NULL), - SDTG_STR("server_name", SLE_STRB, S, 0, _network_server_name, NULL, STR_NULL, NULL), - SDTG_STR("connect_to_ip", SLE_STRB, S, 0, _network_default_ip, NULL, STR_NULL, NULL), - SDTG_STR("network_id", SLE_STRB, S, 0, _network_unique_id, NULL, STR_NULL, NULL), - SDTG_BOOL("autoclean_companies", S, 0, _network_autoclean_companies, false, STR_NULL, NULL), - SDTG_VAR("autoclean_unprotected",SLE_UINT8, S, 0, _network_autoclean_unprotected,12, 0, 60, 0, STR_NULL, NULL), - SDTG_VAR("autoclean_protected", SLE_UINT8, S, 0, _network_autoclean_protected, 36, 0, 180, 0, STR_NULL, NULL), - SDTG_VAR("max_companies", SLE_UINT8, S, 0, _network_game_info.companies_max, 8, 0, 8, 0, STR_NULL, NULL), - SDTG_VAR("max_clients", SLE_UINT8, S, 0, _network_game_info.clients_max, 10, 0, 10, 0, STR_NULL, NULL), - SDTG_VAR("max_spectators", SLE_UINT8, S, 0, _network_game_info.spectators_max, 10, 0, 10, 0, STR_NULL, NULL), - SDTG_VAR("restart_game_year", SLE_INT32, S,D0, _network_restart_game_year, 0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL), - SDTG_VAR("min_players", SLE_UINT8, S, 0, _network_min_players, 0, 0, 10, 0, STR_NULL, NULL), - SDTG_END() + SDTG_VAR("sync_freq", SLE_UINT16,C|S,0, _network_sync_freq, 100, 0, 100, 0, STR_NULL, NULL), + SDTG_VAR("frame_freq", SLE_UINT8,C|S,0, _network_frame_freq, 0, 0, 100, 0, STR_NULL, NULL), + SDTG_VAR("max_join_time", SLE_UINT16, S, 0, _network_max_join_time, 500, 0, 32000, 0, STR_NULL, NULL), + SDTG_BOOL("pause_on_join", S, 0, _network_pause_on_join, true, STR_NULL, NULL), + SDTG_STR("server_bind_ip", SLE_STRB, S, 0, _network_server_bind_ip_host, "0.0.0.0", STR_NULL, NULL), + SDTG_VAR("server_port", SLE_UINT16, S, 0, _network_server_port, NETWORK_DEFAULT_PORT, 0, 65535, 0, STR_NULL, NULL), + SDTG_BOOL("server_advertise", S, 0, _network_advertise, false, STR_NULL, NULL), + SDTG_VAR("lan_internet", SLE_UINT8, S, 0, _network_lan_internet, 0, 0, 1, 0, STR_NULL, NULL), + SDTG_STR("player_name", SLE_STRB, S, 0, _network_player_name, NULL, STR_NULL, NULL), + SDTG_STR("server_password", SLE_STRB, S, 0, _network_server_password, NULL, STR_NULL, NULL), + SDTG_STR("rcon_password", SLE_STRB, S, 0, _network_rcon_password, NULL, STR_NULL, NULL), + SDTG_STR("server_name", SLE_STRB, S, 0, _network_server_name, NULL, STR_NULL, NULL), + SDTG_STR("connect_to_ip", SLE_STRB, S, 0, _network_default_ip, NULL, STR_NULL, NULL), + SDTG_STR("network_id", SLE_STRB, S, 0, _network_unique_id, NULL, STR_NULL, NULL), + SDTG_BOOL("autoclean_companies", S, 0, _network_autoclean_companies, false, STR_NULL, NULL), + SDTG_VAR("autoclean_unprotected",SLE_UINT8, S, 0, _network_autoclean_unprotected,12, 0, 60, 0, STR_NULL, NULL), + SDTG_VAR("autoclean_protected", SLE_UINT8, S, 0, _network_autoclean_protected, 36, 0, 180, 0, STR_NULL, NULL), + SDTG_VAR("max_companies", SLE_UINT8, S, 0, _network_game_info.companies_max, 8, 0, 8, 0, STR_NULL, NULL), + SDTG_VAR("max_clients", SLE_UINT8, S, 0, _network_game_info.clients_max, 10, 0, 10, 0, STR_NULL, NULL), + SDTG_VAR("max_spectators", SLE_UINT8, S, 0, _network_game_info.spectators_max, 10, 0, 10, 0, STR_NULL, NULL), + SDTG_VAR("restart_game_year", SLE_INT32, S,D0, _network_restart_game_year, 0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL), + SDTG_VAR("min_players", SLE_UINT8, S, 0, _network_min_players, 0, 0, 10, 0, STR_NULL, NULL), + SDTG_OMANY("server_lang", SLE_UINT8, S, 0, _network_game_info.server_lang, 0, 3, "ANY|ENGLISH|GERMAN|FRENCH", STR_NULL, NULL), + SDTG_END() }; #endif /* ENABLE_NETWORK */ diff --git a/station_cmd.c b/station_cmd.c index eaece49e1d..c9f06fb17d 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -1096,7 +1096,7 @@ int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint3 int w = plat_len; do { byte layout = *layout_ptr++; - MakeRailStation(tile, st->owner, st->index, axis, layout, GB(p2, 0, 4)); + MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, GB(p2, 0, 4)); SetCustomStationSpecIndex(tile, specindex); SetStationTileRandomBits(tile, GB(Random(), 0, 4)); @@ -1104,7 +1104,7 @@ int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint3 /* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */ uint32 platinfo = GetPlatformInfo(AXIS_X, 0, plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false); uint16 callback = GetStationCallback(CBID_STATION_TILE_LAYOUT, platinfo, 0, statspec, st, tile); - if (callback != CALLBACK_FAILED && callback < 8) SetStationGfx(tile, callback + axis); + if (callback != CALLBACK_FAILED && callback < 8) SetStationGfx(tile, (callback & ~1) + axis); } tile += tile_delta;