mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-18 05:01:13 +00:00
Change: Increase house type limit from 512 to 4096. (#12288)
This moves HouseType from m4+m3[6] to m8 making it 'easier' to access.
This commit is contained in:
parent
8e948af3bc
commit
c72542431a
@ -721,10 +721,9 @@
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<li>m3 bit 6 : bit 8 of house type (m4), allowing 512 different types.</li>
|
||||
<li>m3 bit 5 : free</li>
|
||||
<li>m3 bits 6..5 : free</li>
|
||||
<li>m3 bits 4..0 : triggers activated <a href="#newhouses">(newhouses)</a></li>
|
||||
<li>m4 : <a href="landscape_externals.html">town building type</a> (with m3[6] bit)</li>
|
||||
<li>m4 : free</li>
|
||||
<li>m5 : see m3 bit 7</li>
|
||||
<li>m6 :
|
||||
<ul>
|
||||
@ -760,10 +759,12 @@
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>m8 bits 15..12 : free</li>
|
||||
<li>m8 bits 11..0 : <a href="landscape_externals.html">town building type</a></li>
|
||||
</ul>
|
||||
<small><a name="newhouses"></a>Newhouses is the name englobing a newGRF feature developed by TTDPatch devs (mainly Csaboka).<br>
|
||||
It allows the replacement of the properties as well as the graphics of houses in the game.<br>
|
||||
To distinguish between the standard behaviour and the newGRF one, HouseID (m4 + m3[6]) is tested for anything above 110.<br>
|
||||
To distinguish between the standard behaviour and the newGRF one, HouseID is tested for anything above 110.<br>
|
||||
110 is the count of standard houses. So above 110 means there is a new definition of at least one house</small>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -156,17 +156,17 @@ the array so you can quickly see what is used and what is not.
|
||||
<td class="caption">finished house</td>
|
||||
<td class="bits" rowspan=2><span class="used" title="House random bits">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="pool" title="Town index on pool">XXXX XXXX XXXX XXXX</span></td>
|
||||
<td class="bits"><span class="used" title="House is complete/in construction (see m5)">1</span> <span class="used" title="House type (m4 + m3[6])">X</span><span class="free">O</span><span class="usable" title="Activated triggers (bits 2..4 don't have a meaning)">XXX</span><span class="used" title="Activated triggers (bits 2..4 don't have a meaning)">XX</span></td>
|
||||
<td class="bits" rowspan=2><span class="used" title="House type (m4 + m3[6])">XXXX XXXX</span></td>
|
||||
<td class="bits"><span class="used" title="House is complete/in construction (see m5)">1</span><span class="free">OO</span><span class="usable" title="Activated triggers (bits 2..4 don't have a meaning)">X XX</span><span class="used" title="Activated triggers (bits 2..4 don't have a meaning)">XX</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OOOO OOOO</span></td>
|
||||
<td class="bits"><span class="used" title="Age in years, clamped at 255">XXXX XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="abuse" title="Newhouses activated: periodic processing time remaining; if not, lift position for houses 04 and 05">XXXX XX</span><span class="used" title="Animated tile state">XX</span></td>
|
||||
<td class="bits" rowspan=2><span class="abuse" title="If newhouses active, m7 is the current animation frame">XXXX</span> <span class="abuse" title="If newhouses active, m7 is the current animantion frame; if not, lift behaviour for houses 04 and 05">XXXX</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OOOO OOOO OOOO OOOO</span></td>
|
||||
<td class="bits" rowspan=2><span class="free">OOOO</span> <span class="used" title="House type">XXXX XXXX XXXX</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="caption">house under construction</td>
|
||||
<td class="bits"><span class="used" title="House is complete/in construction (see m5)">O</span> <span class="used" title="House type (m4 + m3[6])">X</span><span class="free">O</span><span class="usable" title="Activated triggers (bits 2..4 don't have a meaning)">XXX</span><span class="used" title="Activated triggers (bits 2..4 don't have a meaning)">XX</span></td>
|
||||
<td class="bits"><span class="free">OOO</span><span class="used" title="Construction stage">XX</span> <span class="used" title="Construction counter">XXX</span></td>
|
||||
<td class="bits"><span class="used" title="House is complete/in construction (see m5)">O</span><span class="used" title="House type (m4 + m3[6])">X</span><span class="free">O</span><span class="usable" title="Activated triggers (bits 2..4 don't have a meaning)">X XX</span><span class="used" title="Activated triggers (bits 2..4 don't have a meaning)">XX</span></td>
|
||||
<td class="bits"><span class="free">OOO</span><span class="used" title="Construction stage">X X</span><span class="used" title="Construction counter">XXX</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
|
10
src/house.h
10
src/house.h
@ -22,12 +22,12 @@
|
||||
*/
|
||||
static const uint8_t TOWN_HOUSE_COMPLETED = 3;
|
||||
|
||||
static const HouseID NUM_HOUSES_PER_GRF = 255; ///< Number of supported houses per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on.
|
||||
|
||||
static const uint HOUSE_NO_CLASS = 0;
|
||||
static const HouseID NEW_HOUSE_OFFSET = 110; ///< Offset for new houses.
|
||||
static const HouseID NUM_HOUSES = 512; ///< Total number of houses.
|
||||
static const HouseID INVALID_HOUSE_ID = 0xFFFF;
|
||||
static const HouseID NEW_HOUSE_OFFSET = 110; ///< Offset for new houses.
|
||||
static const HouseID NUM_HOUSES = 4096; ///< Total number of houses.
|
||||
static const HouseID INVALID_HOUSE_ID = UINT16_MAX;
|
||||
|
||||
static const HouseID NUM_HOUSES_PER_GRF = NUM_HOUSES; ///< Number of supported houses per NewGRF.
|
||||
|
||||
static const uint HOUSE_NUM_ACCEPTS = 16; ///< Max number of cargoes accepted by a tile
|
||||
static const uint HOUSE_ORIGINAL_NUM_ACCEPTS = 3; ///< Original number of accepted cargo types.
|
||||
|
@ -492,7 +492,7 @@ static uint32_t GetDistanceFromNearbyHouse(uint8_t parameter, TileIndex tile, Ho
|
||||
local_houseid = nearby_house_id;
|
||||
} else {
|
||||
local_houseid = (hs->grf_prop.grffile == this->ro.grffile ? 1 : 2) << 8;
|
||||
local_houseid |= hs->grf_prop.local_id;
|
||||
local_houseid |= ClampTo<uint8_t>(hs->grf_prop.local_id); // Spec only allows 8 bits, so all local-ids above 254 are clamped.
|
||||
}
|
||||
return houseclass << 16 | local_houseid;
|
||||
}
|
||||
|
@ -1539,6 +1539,17 @@ bool AfterLoadGame()
|
||||
}
|
||||
}
|
||||
|
||||
if (IsSavegameVersionBefore(SLV_INCREASE_HOUSE_LIMIT)) {
|
||||
for (auto t : Map::Iterate()) {
|
||||
if (IsTileType(t, MP_HOUSE)) {
|
||||
/* House type is moved from m4 + m3[6] to m8. */
|
||||
SetHouseType(t, t.m4() | (GB(t.m3(), 6, 1) << 8));
|
||||
t.m4() = 0;
|
||||
ClrBit(t.m3(), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check and update house and town values */
|
||||
UpdateHousesAndTowns();
|
||||
|
||||
|
@ -394,6 +394,7 @@ enum SaveLoadVersion : uint16_t {
|
||||
SLV_NONFLOODING_WATER_TILES, ///< 345 PR#13013 Store water tile non-flooding state.
|
||||
SLV_PATH_CACHE_FORMAT, ///< 346 PR#12345 Vehicle path cache format changed.
|
||||
SLV_ANIMATED_TILE_STATE_IN_MAP, ///< 347 PR#13082 Animated tile state saved for improved performance.
|
||||
SLV_INCREASE_HOUSE_LIMIT, ///< 348 PR#12288 Increase house limit to 4096.
|
||||
|
||||
SL_MAX_VERSION, ///< Highest possible saveload version
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ inline void SetTownIndex(Tile t, TownID index)
|
||||
inline HouseID GetCleanHouseType(Tile t)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
return t.m4() | (GB(t.m3(), 6, 1) << 8);
|
||||
return GB(t.m8(), 0, 12);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,8 +71,7 @@ inline HouseID GetHouseType(Tile t)
|
||||
inline void SetHouseType(Tile t, HouseID house_id)
|
||||
{
|
||||
assert(IsTileType(t, MP_HOUSE));
|
||||
t.m4() = GB(house_id, 0, 8);
|
||||
SB(t.m3(), 6, 1, GB(house_id, 8, 1));
|
||||
SB(t.m8(), 0, 12, house_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user