src/signal_func.h
author Tero Marttila <terom@fixme.fi>
Tue, 22 Jul 2008 23:20:33 +0300
changeset 11184 88c967f1422b
parent 10544 bef2e2b68666
permissions -rw-r--r--
add an empty bin/cache dir
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2049
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2049
diff changeset
     2
8634
5ffca02f9115 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8619
diff changeset
     3
/** @file signal_func.h Functions related to signals. */
2274
d94004c14b6c (svn r2798) -Codechange: Unified the rail toolbars into one that is modified by
celestar
parents: 2254
diff changeset
     4
8634
5ffca02f9115 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8619
diff changeset
     5
#ifndef SIGNAL_FUNC_H
5ffca02f9115 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8619
diff changeset
     6
#define SIGNAL_FUNC_H
2254
72f8883ff3ac (svn r2774) -Codechange: Removed TRACKTYPE_SPRITE_PITCH globally and replaced it by a member of RailtypeInfo
celestar
parents: 2236
diff changeset
     7
8634
5ffca02f9115 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8619
diff changeset
     8
#include "track_type.h"
8734
b7fc8c6fd379 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8634
diff changeset
     9
#include "tile_type.h"
b7fc8c6fd379 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8634
diff changeset
    10
#include "direction_type.h"
b7fc8c6fd379 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8634
diff changeset
    11
#include "track_type.h"
8796
81b0d6b54a1f (svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz
parents: 8734
diff changeset
    12
#include "player_type.h"
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    13
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    14
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    15
 * Maps a trackdir to the bit that stores its status in the map arrays, in the
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    16
 * direction along with the trackdir.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    17
 */
6488
07bbbafd4f70 (svn r8912) -Codechange: coding style cleanup and moving of two global externs into the functions that use them.
rubidium
parents: 6482
diff changeset
    18
static inline byte SignalAlongTrackdir(Trackdir trackdir)
07bbbafd4f70 (svn r8912) -Codechange: coding style cleanup and moving of two global externs into the functions that use them.
rubidium
parents: 6482
diff changeset
    19
{
07bbbafd4f70 (svn r8912) -Codechange: coding style cleanup and moving of two global externs into the functions that use them.
rubidium
parents: 6482
diff changeset
    20
	extern const byte _signal_along_trackdir[TRACKDIR_END];
07bbbafd4f70 (svn r8912) -Codechange: coding style cleanup and moving of two global externs into the functions that use them.
rubidium
parents: 6482
diff changeset
    21
	return _signal_along_trackdir[trackdir];
07bbbafd4f70 (svn r8912) -Codechange: coding style cleanup and moving of two global externs into the functions that use them.
rubidium
parents: 6482
diff changeset
    22
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    23
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    24
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    25
 * Maps a trackdir to the bit that stores its status in the map arrays, in the
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    26
 * direction against the trackdir.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    27
 */
6488
07bbbafd4f70 (svn r8912) -Codechange: coding style cleanup and moving of two global externs into the functions that use them.
rubidium
parents: 6482
diff changeset
    28
static inline byte SignalAgainstTrackdir(Trackdir trackdir)
07bbbafd4f70 (svn r8912) -Codechange: coding style cleanup and moving of two global externs into the functions that use them.
rubidium
parents: 6482
diff changeset
    29
{
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
    30
	extern const byte _signal_against_trackdir[TRACKDIR_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
    31
	return _signal_against_trackdir[trackdir];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
    32
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    33
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    34
/**
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    35
 * Maps a Track to the bits that store the status of the two signals that can
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    36
 * be present on the given track.
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    37
 */
6488
07bbbafd4f70 (svn r8912) -Codechange: coding style cleanup and moving of two global externs into the functions that use them.
rubidium
parents: 6482
diff changeset
    38
static inline byte SignalOnTrack(Track track)
07bbbafd4f70 (svn r8912) -Codechange: coding style cleanup and moving of two global externs into the functions that use them.
rubidium
parents: 6482
diff changeset
    39
{
1948
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
    40
	extern const byte _signal_on_track[TRACK_END];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
    41
	return _signal_on_track[track];
e5f34b543a3c (svn r2454) * Codechange: Move #include "stdafx.h" and "openttd.h" from rail.h to rail.c
matthijs
parents: 1947
diff changeset
    42
}
1942
634961366cdc (svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
diff changeset
    43
10544
bef2e2b68666 (svn r13088) -Codechange: use SigSegState enum instead of bool variable (michi_cc)
smatz
parents: 8802
diff changeset
    44
/** State of the signal segment */
bef2e2b68666 (svn r13088) -Codechange: use SigSegState enum instead of bool variable (michi_cc)
smatz
parents: 8802
diff changeset
    45
enum SigSegState {
bef2e2b68666 (svn r13088) -Codechange: use SigSegState enum instead of bool variable (michi_cc)
smatz
parents: 8802
diff changeset
    46
	SIGSEG_FREE,    ///< Free and has no pre-signal exits or at least one green exit
bef2e2b68666 (svn r13088) -Codechange: use SigSegState enum instead of bool variable (michi_cc)
smatz
parents: 8802
diff changeset
    47
	SIGSEG_FULL,    ///< Occupied by a train
bef2e2b68666 (svn r13088) -Codechange: use SigSegState enum instead of bool variable (michi_cc)
smatz
parents: 8802
diff changeset
    48
};
bef2e2b68666 (svn r13088) -Codechange: use SigSegState enum instead of bool variable (michi_cc)
smatz
parents: 8802
diff changeset
    49
bef2e2b68666 (svn r13088) -Codechange: use SigSegState enum instead of bool variable (michi_cc)
smatz
parents: 8802
diff changeset
    50
SigSegState UpdateSignalsOnSegment(TileIndex tile, DiagDirection side, Owner owner);
8796
81b0d6b54a1f (svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz
parents: 8734
diff changeset
    51
void SetSignalsOnBothDir(TileIndex tile, Track track, Owner owner);
8802
e08824cdab46 (svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz
parents: 8796
diff changeset
    52
void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner);
e08824cdab46 (svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz
parents: 8796
diff changeset
    53
void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner);
e08824cdab46 (svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz
parents: 8796
diff changeset
    54
void UpdateSignalsInBuffer();
8734
b7fc8c6fd379 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8634
diff changeset
    55
8634
5ffca02f9115 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8619
diff changeset
    56
#endif /* SIGNAL_FUNC_H */