Mercurial > hg > openttd
comparison src/station_cmd.cpp @ 5721:06a31b083e84 draft
(svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
author | KUDr <KUDr@openttd.org> |
---|---|
date | Thu, 18 Jan 2007 09:34:44 +0000 |
parents | e9077998bcac |
children | bcd4b73b9fd2 |
comparison
equal
deleted
inserted
replaced
5720:3b0fb1e298cc | 5721:06a31b083e84 |
---|---|
998 // (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags) | 998 // (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags) |
999 ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _patches.nonuniform_stations ? &est : NULL); | 999 ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _patches.nonuniform_stations ? &est : NULL); |
1000 if (CmdFailed(ret)) return ret; | 1000 if (CmdFailed(ret)) return ret; |
1001 | 1001 |
1002 st->train_tile = finalvalues[0]; | 1002 st->train_tile = finalvalues[0]; |
1003 if (!st->facilities) st->xy = finalvalues[0]; | 1003 st->AddFacility(FACIL_TRAIN, finalvalues[0]); |
1004 st->facilities |= FACIL_TRAIN; | |
1005 st->owner = _current_player; | |
1006 | 1004 |
1007 st->trainst_w = finalvalues[1]; | 1005 st->trainst_w = finalvalues[1]; |
1008 st->trainst_h = finalvalues[2]; | 1006 st->trainst_h = finalvalues[2]; |
1009 | |
1010 st->build_date = _date; | |
1011 | 1007 |
1012 st->rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY); | 1008 st->rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY); |
1013 | 1009 |
1014 tile_delta = (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); | 1010 tile_delta = (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
1015 track = AxisToTrack(axis); | 1011 track = AxisToTrack(axis); |
1413 //point to the correct item in the _busstops or _truckstops array | 1409 //point to the correct item in the _busstops or _truckstops array |
1414 *currstop = road_stop; | 1410 *currstop = road_stop; |
1415 | 1411 |
1416 //initialize an empty station | 1412 //initialize an empty station |
1417 road_stop->prev = prev; | 1413 road_stop->prev = prev; |
1418 if (!st->facilities) st->xy = tile; | 1414 st->AddFacility((type) ? FACIL_TRUCK_STOP : FACIL_BUS_STOP, tile); |
1419 st->facilities |= (type) ? FACIL_TRUCK_STOP : FACIL_BUS_STOP; | |
1420 st->owner = _current_player; | |
1421 | |
1422 st->build_date = _date; | |
1423 | 1415 |
1424 st->rect.BeforeAddTile(tile, StationRect::ADD_TRY); | 1416 st->rect.BeforeAddTile(tile, StationRect::ADD_TRY); |
1425 | 1417 |
1426 MakeRoadStop(tile, st->owner, st->index, type ? RS_TRUCK : RS_BUS, (DiagDirection)p1); | 1418 MakeRoadStop(tile, st->owner, st->index, type ? RS_TRUCK : RS_BUS, (DiagDirection)p1); |
1427 | 1419 |
1672 } | 1664 } |
1673 | 1665 |
1674 cost += _price.build_airport * w * h; | 1666 cost += _price.build_airport * w * h; |
1675 | 1667 |
1676 if (flags & DC_EXEC) { | 1668 if (flags & DC_EXEC) { |
1677 st->owner = _current_player; | |
1678 st->airport_tile = tile; | 1669 st->airport_tile = tile; |
1679 if (!st->facilities) st->xy = tile; | 1670 st->AddFacility(FACIL_AIRPORT, tile); |
1680 st->facilities |= FACIL_AIRPORT; | |
1681 st->airport_type = (byte)p1; | 1671 st->airport_type = (byte)p1; |
1682 st->airport_flags = 0; | 1672 st->airport_flags = 0; |
1683 | |
1684 st->build_date = _date; | |
1685 | 1673 |
1686 st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY); | 1674 st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY); |
1687 | 1675 |
1688 /* if airport was demolished while planes were en-route to it, the | 1676 /* if airport was demolished while planes were en-route to it, the |
1689 * positions can no longer be the same (v->u.air.pos), since different | 1677 * positions can no longer be the same (v->u.air.pos), since different |
1951 if (!GenerateStationName(st, tile, 3)) return CMD_ERROR; | 1939 if (!GenerateStationName(st, tile, 3)) return CMD_ERROR; |
1952 } | 1940 } |
1953 | 1941 |
1954 if (flags & DC_EXEC) { | 1942 if (flags & DC_EXEC) { |
1955 st->dock_tile = tile; | 1943 st->dock_tile = tile; |
1956 if (!st->facilities) st->xy = tile; | 1944 st->AddFacility(FACIL_DOCK, tile); |
1957 st->facilities |= FACIL_DOCK; | |
1958 st->owner = _current_player; | |
1959 | |
1960 st->build_date = _date; | |
1961 | 1945 |
1962 st->rect.BeforeAddRect(tile, _dock_w_chk[direction], _dock_h_chk[direction], StationRect::ADD_TRY); | 1946 st->rect.BeforeAddRect(tile, _dock_w_chk[direction], _dock_h_chk[direction], StationRect::ADD_TRY); |
1963 | 1947 |
1964 MakeDock(tile, st->owner, st->index, direction); | 1948 MakeDock(tile, st->owner, st->index, direction); |
1965 | 1949 |