OpenTTD
Data Structures | Functions | Variables
newgrf_canal.cpp File Reference

Implementation of NewGRF canals. More...

#include "stdafx.h"
#include "debug.h"
#include "newgrf_spritegroup.h"
#include "newgrf_canal.h"
#include "water.h"
#include "water_map.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  CanalScopeResolver
 Scope resolver of a canal tile. More...
 
struct  CanalResolverObject
 Resolver object for canals. More...
 

Functions

SpriteID GetCanalSprite (CanalFeature feature, TileIndex tile)
 Lookup the base sprite to use for a canal. More...
 
static uint16 GetCanalCallback (CallbackID callback, uint32 param1, uint32 param2, CanalFeature feature, TileIndex tile)
 Run a specific callback for canals. More...
 
uint GetCanalSpriteOffset (CanalFeature feature, TileIndex tile, uint cur_offset)
 Get the new sprite offset for a water tile. More...
 

Variables

WaterFeature _water_feature [CF_END]
 Table of canal 'feature' sprite groups.
 

Detailed Description

Implementation of NewGRF canals.

Definition in file newgrf_canal.cpp.

Function Documentation

◆ GetCanalCallback()

static uint16 GetCanalCallback ( CallbackID  callback,
uint32  param1,
uint32  param2,
CanalFeature  feature,
TileIndex  tile 
)
static

Run a specific callback for canals.

Parameters
callbackCallback ID.
param1Callback parameter 1.
param2Callback parameter 2.
featureFor which feature to run the callback.
tileTile index of canal.
Returns
Callback result or CALLBACK_FAILED if the callback failed.

Definition at line 155 of file newgrf_canal.cpp.

Referenced by GetCanalSpriteOffset().

◆ GetCanalSprite()

SpriteID GetCanalSprite ( CanalFeature  feature,
TileIndex  tile 
)

Lookup the base sprite to use for a canal.

Parameters
featureWhich canal feature we want.
tileTile index of canal, if appropriate.
Returns
Base sprite returned by GRF, or 0 if none.

Definition at line 137 of file newgrf_canal.cpp.

References SpriteGroup::Resolve().

◆ GetCanalSpriteOffset()

uint GetCanalSpriteOffset ( CanalFeature  feature,
TileIndex  tile,
uint  cur_offset 
)

Get the new sprite offset for a water tile.

Parameters
tileTile index of the canal/water tile.
featureFor which feature to get the new sprite offset.
cur_offsetCurrent sprite offset.
Returns
New sprite offset.

Definition at line 168 of file newgrf_canal.cpp.

References CALLBACK_FAILED, CBID_CANALS_SPRITE_OFFSET, CBM_CANAL_SPRITE_OFFSET, GetCanalCallback(), and HasBit().