src/openttd.cpp
changeset 9652 0405e98d8e96
parent 9648 c79160082c0f
child 9655 bab7f10b3130
equal deleted inserted replaced
9651:1285c0b3a4de 9652:0405e98d8e96
   628 			if (player != NULL) {
   628 			if (player != NULL) {
   629 				_network_playas = (PlayerID)atoi(player);
   629 				_network_playas = (PlayerID)atoi(player);
   630 
   630 
   631 				if (_network_playas != PLAYER_SPECTATOR) {
   631 				if (_network_playas != PLAYER_SPECTATOR) {
   632 					_network_playas--;
   632 					_network_playas--;
   633 					if (!IsValidPlayer(_network_playas)) return false;
   633 					if (!IsValidPlayerID(_network_playas)) return false;
   634 				}
   634 				}
   635 			}
   635 			}
   636 			if (port != NULL) rport = atoi(port);
   636 			if (port != NULL) rport = atoi(port);
   637 
   637 
   638 			LoadIntroGame();
   638 			LoadIntroGame();
  1571 		 * However, in a dedicated server we are a spectator, so nothing needs to
  1571 		 * However, in a dedicated server we are a spectator, so nothing needs to
  1572 		 * happen. In case we are not a dedicated server, the local player always
  1572 		 * happen. In case we are not a dedicated server, the local player always
  1573 		 * becomes player 0, unless we are in the scenario editor where all the
  1573 		 * becomes player 0, unless we are in the scenario editor where all the
  1574 		 * players are 'invalid'.
  1574 		 * players are 'invalid'.
  1575 		 */
  1575 		 */
  1576 		if (!_network_dedicated && IsValidPlayer(PLAYER_FIRST)) {
  1576 		if (!_network_dedicated && IsValidPlayerID(PLAYER_FIRST)) {
  1577 			p = GetPlayer(PLAYER_FIRST);
  1577 			p = GetPlayer(PLAYER_FIRST);
  1578 			p->engine_renew        = _settings_client.gui.autorenew;
  1578 			p->engine_renew        = _settings_client.gui.autorenew;
  1579 			p->engine_renew_months = _settings_client.gui.autorenew_months;
  1579 			p->engine_renew_months = _settings_client.gui.autorenew_months;
  1580 			p->engine_renew_money  = _settings_client.gui.autorenew_money;
  1580 			p->engine_renew_money  = _settings_client.gui.autorenew_money;
  1581 		}
  1581 		}
  2320 				for (uint i = 0; i < 4; i++) { p->share_owners[i] = PLAYER_SPECTATOR; }
  2320 				for (uint i = 0; i < 4; i++) { p->share_owners[i] = PLAYER_SPECTATOR; }
  2321 			} else {
  2321 			} else {
  2322 				for (uint i = 0; i < 4; i++) {
  2322 				for (uint i = 0; i < 4; i++) {
  2323 					PlayerID o = p->share_owners[i];
  2323 					PlayerID o = p->share_owners[i];
  2324 					if (o == PLAYER_SPECTATOR) continue;
  2324 					if (o == PLAYER_SPECTATOR) continue;
  2325 					if (!IsValidPlayer(o) || o == p->index || !GetPlayer(o)->is_active) p->share_owners[i] = PLAYER_SPECTATOR;
  2325 					if (!IsValidPlayerID(o) || o == p->index || !GetPlayer(o)->is_active) p->share_owners[i] = PLAYER_SPECTATOR;
  2326 				}
  2326 				}
  2327 			}
  2327 			}
  2328 		}
  2328 		}
  2329 	}
  2329 	}
  2330 
  2330 
  2372 				SetWaterClass(t, WATER_CLASS_SEA);
  2372 				SetWaterClass(t, WATER_CLASS_SEA);
  2373 			}
  2373 			}
  2374 
  2374 
  2375 			if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
  2375 			if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
  2376 				Owner o = GetTileOwner(t);
  2376 				Owner o = GetTileOwner(t);
  2377 				if (IsValidPlayer(o) && !GetPlayer(o)->is_active) {
  2377 				if (IsValidPlayerID(o) && !GetPlayer(o)->is_active) {
  2378 					_current_player = o;
  2378 					_current_player = o;
  2379 					ChangeTileOwner(t, o, PLAYER_SPECTATOR);
  2379 					ChangeTileOwner(t, o, PLAYER_SPECTATOR);
  2380 				}
  2380 				}
  2381 				if (IsBuoyTile(t)) {
  2381 				if (IsBuoyTile(t)) {
  2382 					/* reset buoy owner to OWNER_NONE in the station struct
  2382 					/* reset buoy owner to OWNER_NONE in the station struct
  2386 			} else if (IsTileType(t, MP_ROAD)) {
  2386 			} else if (IsTileType(t, MP_ROAD)) {
  2387 				/* works for all RoadTileType */
  2387 				/* works for all RoadTileType */
  2388 				for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
  2388 				for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
  2389 					/* update even non-existing road types to update tile owner too */
  2389 					/* update even non-existing road types to update tile owner too */
  2390 					Owner o = GetRoadOwner(t, rt);
  2390 					Owner o = GetRoadOwner(t, rt);
  2391 					if (IsValidPlayer(o) && !GetPlayer(o)->is_active) SetRoadOwner(t, rt, OWNER_NONE);
  2391 					if (IsValidPlayerID(o) && !GetPlayer(o)->is_active) SetRoadOwner(t, rt, OWNER_NONE);
  2392 				}
  2392 				}
  2393 				if (IsLevelCrossing(t)) {
  2393 				if (IsLevelCrossing(t)) {
  2394 					Owner o = GetTileOwner(t);
  2394 					Owner o = GetTileOwner(t);
  2395 					if (!GetPlayer(o)->is_active) {
  2395 					if (!GetPlayer(o)->is_active) {
  2396 						/* remove leftover rail piece from crossing (from very old savegames) */
  2396 						/* remove leftover rail piece from crossing (from very old savegames) */