Files
@ r28060:53690f1ef210
Branch filter:
Location: cpp/openttd-patchpack/source/src/town_map.h - annotation
r28060:53690f1ef210
9.4 KiB
text/x-c
Feature: Base graphics can offer parameters for additional settings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r12988:3ff331d79bb7 r12239:4ede50b8e95b r27166:64e04a3ef9b1 r5475:3f5cd13d1b63 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r12988:3ff331d79bb7 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r12988:3ff331d79bb7 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r5475:3f5cd13d1b63 r12988:3ff331d79bb7 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r12988:3ff331d79bb7 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5969:076c978402fa r6332:7393965b5322 r14015:da5c9695fabe r14015:da5c9695fabe r14015:da5c9695fabe r14015:da5c9695fabe r14015:da5c9695fabe r26931:7d5bce03e821 r14015:da5c9695fabe r14015:da5c9695fabe r26931:7d5bce03e821 r14015:da5c9695fabe r14015:da5c9695fabe r14015:da5c9695fabe r14015:da5c9695fabe r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r5969:076c978402fa r14015:da5c9695fabe r5969:076c978402fa r5969:076c978402fa r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6422:5983361e241a r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r5475:3f5cd13d1b63 r6332:7393965b5322 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r19944:25a78576fb5e r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r26931:7d5bce03e821 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r10360:db7bc0d116e9 r10360:db7bc0d116e9 r9006:5d1cd69ad697 r9006:5d1cd69ad697 r9006:5d1cd69ad697 r26931:7d5bce03e821 r9006:5d1cd69ad697 r9006:5d1cd69ad697 r26931:7d5bce03e821 r9006:5d1cd69ad697 r9006:5d1cd69ad697 r9006:5d1cd69ad697 r10360:db7bc0d116e9 r10360:db7bc0d116e9 r10360:db7bc0d116e9 r10360:db7bc0d116e9 r26931:7d5bce03e821 r10360:db7bc0d116e9 r10360:db7bc0d116e9 r26931:7d5bce03e821 r10360:db7bc0d116e9 r10360:db7bc0d116e9 r10360:db7bc0d116e9 r10360:db7bc0d116e9 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r27166:64e04a3ef9b1 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r26931:7d5bce03e821 r7861:9082dbb3187c r7861:9082dbb3187c r26931:7d5bce03e821 r7861:9082dbb3187c r7861:9082dbb3187c r7861:9082dbb3187c r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6418:8a4b147a8f33 r6418:8a4b147a8f33 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r6332:7393965b5322 r6332:7393965b5322 r26931:7d5bce03e821 r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r26931:7d5bce03e821 r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r15923:6550af31238a r26931:7d5bce03e821 r26931:7d5bce03e821 r26931:7d5bce03e821 r15923:6550af31238a r15923:6550af31238a r26931:7d5bce03e821 r15924:f5bba173626e r15923:6550af31238a r6332:7393965b5322 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 | /*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file town_map.h Accessors for towns */
#ifndef TOWN_MAP_H
#define TOWN_MAP_H
#include "road_map.h"
#include "house.h"
#include "timer/timer_game_calendar.h"
/**
* Get the index of which town this house/street is attached to.
* @param t the tile
* @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
* @return TownID
*/
static inline TownID GetTownIndex(Tile t)
{
assert(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)));
return t.m2();
}
/**
* Set the town index for a road or house tile.
* @param t the tile
* @param index the index of the town
* @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
*/
static inline void SetTownIndex(Tile t, TownID index)
{
assert(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)));
t.m2() = index;
}
/**
* Get the type of this house, which is an index into the house spec array
* without doing any NewGRF related translations.
* @param t the tile
* @pre IsTileType(t, MP_HOUSE)
* @return house type
*/
static inline HouseID GetCleanHouseType(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
return t.m4() | (GB(t.m3(), 6, 1) << 8);
}
/**
* Get the type of this house, which is an index into the house spec array
* @param t the tile
* @pre IsTileType(t, MP_HOUSE)
* @return house type
*/
static inline HouseID GetHouseType(Tile t)
{
return GetTranslatedHouseID(GetCleanHouseType(t));
}
/**
* Set the house type.
* @param t the tile
* @param house_id the new house type
* @pre IsTileType(t, MP_HOUSE)
*/
static 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));
}
/**
* Check if the lift of this animated house has a destination
* @param t the tile
* @return has destination
*/
static inline bool LiftHasDestination(Tile t)
{
return HasBit(t.m7(), 0);
}
/**
* Set the new destination of the lift for this animated house, and activate
* the LiftHasDestination bit.
* @param t the tile
* @param dest new destination
*/
static inline void SetLiftDestination(Tile t, byte dest)
{
SetBit(t.m7(), 0);
SB(t.m7(), 1, 3, dest);
}
/**
* Get the current destination for this lift
* @param t the tile
* @return destination
*/
static inline byte GetLiftDestination(Tile t)
{
return GB(t.m7(), 1, 3);
}
/**
* Stop the lift of this animated house from moving.
* Clears the first 4 bits of m7 at once, clearing the LiftHasDestination bit
* and the destination.
* @param t the tile
*/
static inline void HaltLift(Tile t)
{
SB(t.m7(), 0, 4, 0);
}
/**
* Get the position of the lift on this animated house
* @param t the tile
* @return position, from 0 to 36
*/
static inline byte GetLiftPosition(Tile t)
{
return GB(t.m6(), 2, 6);
}
/**
* Set the position of the lift on this animated house
* @param t the tile
* @param pos position, from 0 to 36
*/
static inline void SetLiftPosition(Tile t, byte pos)
{
SB(t.m6(), 2, 6, pos);
}
/**
* Get the completion of this house
* @param t the tile
* @return true if it is, false if it is not
*/
static inline bool IsHouseCompleted(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
return HasBit(t.m3(), 7);
}
/**
* Mark this house as been completed
* @param t the tile
* @param status
*/
static inline void SetHouseCompleted(Tile t, bool status)
{
assert(IsTileType(t, MP_HOUSE));
SB(t.m3(), 7, 1, !!status);
}
/**
* House Construction Scheme.
* Construction counter, for buildings under construction. Incremented on every
* periodic tile processing.
* On wraparound, the stage of building in is increased.
* GetHouseBuildingStage is taking care of the real stages,
* (as the sprite for the next phase of house building)
* (Get|Inc)HouseConstructionTick is simply a tick counter between the
* different stages
*/
/**
* Gets the building stage of a house
* Since the stage is used for determining what sprite to use,
* if the house is complete (and that stage no longer is available),
* fool the system by returning the TOWN_HOUSE_COMPLETE (3),
* thus showing a beautiful complete house.
* @param t the tile of the house to get the building stage of
* @pre IsTileType(t, MP_HOUSE)
* @return the building stage of the house
*/
static inline byte GetHouseBuildingStage(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
return IsHouseCompleted(t) ? (byte)TOWN_HOUSE_COMPLETED : GB(t.m5(), 3, 2);
}
/**
* Gets the construction stage of a house
* @param t the tile of the house to get the construction stage of
* @pre IsTileType(t, MP_HOUSE)
* @return the construction stage of the house
*/
static inline byte GetHouseConstructionTick(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
return IsHouseCompleted(t) ? 0 : GB(t.m5(), 0, 3);
}
/**
* Sets the increment stage of a house
* It is working with the whole counter + stage 5 bits, making it
* easier to work: the wraparound is automatic.
* @param t the tile of the house to increment the construction stage of
* @pre IsTileType(t, MP_HOUSE)
*/
static inline void IncHouseConstructionTick(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
AB(t.m5(), 0, 5, 1);
if (GB(t.m5(), 3, 2) == TOWN_HOUSE_COMPLETED) {
/* House is now completed.
* Store the year of construction as well, for newgrf house purpose */
SetHouseCompleted(t, true);
}
}
/**
* Sets the age of the house to zero.
* Needs to be called after the house is completed. During construction stages the map space is used otherwise.
* @param t the tile of this house
* @pre IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)
*/
static inline void ResetHouseAge(Tile t)
{
assert(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t));
t.m5() = 0;
}
/**
* Increments the age of the house.
* @param t the tile of this house
* @pre IsTileType(t, MP_HOUSE)
*/
static inline void IncrementHouseAge(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
if (IsHouseCompleted(t) && t.m5() < 0xFF) t.m5()++;
}
/**
* Get the age of the house
* @param t the tile of this house
* @pre IsTileType(t, MP_HOUSE)
* @return year
*/
static inline TimerGameCalendar::Year GetHouseAge(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
return IsHouseCompleted(t) ? t.m5() : 0;
}
/**
* Set the random bits for this house.
* This is required for newgrf house
* @param t the tile of this house
* @param random the new random bits
* @pre IsTileType(t, MP_HOUSE)
*/
static inline void SetHouseRandomBits(Tile t, byte random)
{
assert(IsTileType(t, MP_HOUSE));
t.m1() = random;
}
/**
* Get the random bits for this house.
* This is required for newgrf house
* @param t the tile of this house
* @pre IsTileType(t, MP_HOUSE)
* @return random bits
*/
static inline byte GetHouseRandomBits(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
return t.m1();
}
/**
* Set the activated triggers bits for this house.
* This is required for newgrf house
* @param t the tile of this house
* @param triggers the activated triggers
* @pre IsTileType(t, MP_HOUSE)
*/
static inline void SetHouseTriggers(Tile t, byte triggers)
{
assert(IsTileType(t, MP_HOUSE));
SB(t.m3(), 0, 5, triggers);
}
/**
* Get the already activated triggers bits for this house.
* This is required for newgrf house
* @param t the tile of this house
* @pre IsTileType(t, MP_HOUSE)
* @return triggers
*/
static inline byte GetHouseTriggers(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
return GB(t.m3(), 0, 5);
}
/**
* Get the amount of time remaining before the tile loop processes this tile.
* @param t the house tile
* @pre IsTileType(t, MP_HOUSE)
* @return time remaining
*/
static inline byte GetHouseProcessingTime(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
return GB(t.m6(), 2, 6);
}
/**
* Set the amount of time remaining before the tile loop processes this tile.
* @param t the house tile
* @param time the time to be set
* @pre IsTileType(t, MP_HOUSE)
*/
static inline void SetHouseProcessingTime(Tile t, byte time)
{
assert(IsTileType(t, MP_HOUSE));
SB(t.m6(), 2, 6, time);
}
/**
* Decrease the amount of time remaining before the tile loop processes this tile.
* @param t the house tile
* @pre IsTileType(t, MP_HOUSE)
*/
static inline void DecHouseProcessingTime(Tile t)
{
assert(IsTileType(t, MP_HOUSE));
t.m6() -= 1 << 2;
}
/**
* Make the tile a house.
* @param t tile index
* @param tid Town index
* @param counter of construction step
* @param stage of construction (used for drawing)
* @param type of house. Index into house specs array
* @param random_bits required for newgrf houses
* @pre IsTileType(t, MP_CLEAR)
*/
static inline void MakeHouseTile(Tile t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
{
assert(IsTileType(t, MP_CLEAR));
SetTileType(t, MP_HOUSE);
t.m1() = random_bits;
t.m2() = tid;
t.m3() = 0;
SetHouseType(t, type);
SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED);
t.m5() = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
SetAnimationFrame(t, 0);
SetHouseProcessingTime(t, HouseSpec::Get(type)->processing_time);
}
#endif /* TOWN_MAP_H */
|