(svn r9853) [0.5] -Backport from trunk (r9837, r9827, r9785, r9775, r9758, r9716): 0.5
authorrubidium
Tue, 15 May 2007 22:02:32 +0000
branch0.5
changeset 5497 b9c8c76d31b7
parent 5496 e50adc01d7e3
child 5498 65a8d65f800a
(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
newgrf.c
newgrf_spritegroup.c
openttd.c
settings.c
station_cmd.c
--- a/network.c	Tue May 15 22:00:41 2007 +0000
+++ b/network.c	Tue May 15 22:02:32 2007 +0000
@@ -1397,11 +1397,13 @@
 		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
--- a/newgrf.c	Tue May 15 22:00:41 2007 +0000
+++ b/newgrf.c	Tue May 15 22:02:32 2007 +0000
@@ -2096,79 +2096,73 @@
 
 		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);
-
-			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;
+		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);
 				}
-
-				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 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;
+				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 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;
 
 #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_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_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;
 #endif
-			}
 		}
 	}
 }
--- a/newgrf_spritegroup.c	Tue May 15 22:00:41 2007 +0000
+++ b/newgrf_spritegroup.c	Tue May 15 22:02:32 2007 +0000
@@ -118,10 +118,10 @@
 		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; \
--- a/openttd.c	Tue May 15 22:00:41 2007 +0000
+++ b/openttd.c	Tue May 15 22:02:32 2007 +0000
@@ -1242,8 +1242,8 @@
 	// 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
--- a/settings.c	Tue May 15 22:00:41 2007 +0000
+++ b/settings.c	Tue May 15 22:02:32 2007 +0000
@@ -989,7 +989,7 @@
 #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 @@
 
 #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 */
 
--- a/station_cmd.c	Tue May 15 22:00:41 2007 +0000
+++ b/station_cmd.c	Tue May 15 22:02:32 2007 +0000
@@ -1096,7 +1096,7 @@
 			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 @@
 					/* 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;