Files @ r12269:f94731e7dc53
Branch filter:

Location: cpp/openttd-patchpack/source/src/landscape.h

rubidium
(svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
* cheating by starting to unload and after getting paid rushing to the depot to get sold (or unloading, loading and getting paid again for the remainder)
* cargo being dropped onto a station at the moment a stockpiling industry doesn't accept it anymore
* industries getting cargo that has not been unloaded yet and subsequently dumping it back on the station in one go
Note: you will now get paid after the unloading has finished, so you'll have to wait a bit longer for 'your' money.
/* $Id$ */

/** @file landscape.h Functions related to OTTD's landscape. */

#ifndef LANDSCAPE_H
#define LANDSCAPE_H

#include "core/geometry_type.hpp"
#include "tile_cmd.h"
#include "slope_type.h"
#include "direction_type.h"

enum {
	SNOW_LINE_MONTHS = 12, ///< Number of months in the snow line table.
	SNOW_LINE_DAYS   = 32, ///< Number of days in each month in the snow line table.
};

/** Structure describing the height of the snow line each day of the year
 * @ingroup SnowLineGroup */
struct SnowLine {
	byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]; ///< Height of the snow line each day of the year
	byte highest_value; ///< Highest snow line of the year
	byte lowest_value;  ///< Lowest snow line of the year
};

bool IsSnowLineSet();
void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]);
byte GetSnowLine();
byte HighestSnowLine();
byte LowestSnowLine();
void ClearSnowLine();

uint GetPartialZ(int x, int y, Slope corners);
uint GetSlopeZ(int x, int y);
void GetSlopeZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2);
int GetSlopeZInCorner(Slope tileh, Corner corner);
Slope GetFoundationSlope(TileIndex tile, uint *z);

static inline Point RemapCoords(int x, int y, int z)
{
	Point pt;
	pt.x = (y - x) * 2;
	pt.y = y + x - z;
	return pt;
}

static inline Point RemapCoords2(int x, int y)
{
	return RemapCoords(x, y, GetSlopeZ(x, y));
}

uint ApplyFoundationToSlope(Foundation f, Slope *s);
void DrawFoundation(TileInfo *ti, Foundation f);

void DoClearSquare(TileIndex tile);
void RunTileLoop();

void InitializeLandscape();
void GenerateLandscape(byte mode);

#endif /* LANDSCAPE_H */