Don't store RAILWAYS track in sectors
Storing track in sectors is problematic, because we need to update adjacent sectors when updating a sector in a way that changes its capability to extend railway into its neighbors. This invalidates cached adjacent sectors, and calling code may not be prepared for that. Specifically, bridge building caches the bridge head, and writes it back later, wiping out the track update. Replace struct sctstr member sct_track by new sct_rail_track(). Make selector track virtual. Remove the code to keep sct_track up-to-date: set_railway(), update_railway(). Unfortunately, this causes cyclic dependencies between link libraries: the virtual selector needs to be referenced from src/lib/global/nsc.c, and it needs to reference stuff from src/lib/common/file.c. Hack around it in Make.mk for now.
This commit is contained in:
parent
11100f23e5
commit
fa5fa4abcc
10 changed files with 46 additions and 79 deletions
|
@ -77,7 +77,6 @@ struct sctstr {
|
|||
natid sct_oldown; /* old owner of sector (for liberation) */
|
||||
unsigned char sct_updated; /* Has this sect been updated? */
|
||||
unsigned char sct_off; /* Should this sector produce? */
|
||||
unsigned char sct_track; /* nearby railways (RAILWAYS) */
|
||||
short sct_item[I_MAX+1]; /* amount of items stored here */
|
||||
short sct_del[I_MAX+1]; /* delivieries */
|
||||
short sct_dist[I_MAX+1]; /* distribution thresholds */
|
||||
|
@ -189,7 +188,7 @@ extern struct dchrstr bigcity_dchr;
|
|||
|
||||
/* Can trains enter sector SP? */
|
||||
#define SCT_HAS_RAIL(sp) \
|
||||
(opt_RAILWAYS ? (sp)->sct_track != 0 \
|
||||
(opt_RAILWAYS ? sct_rail_track((sp)) != 0 \
|
||||
: intrchr[INT_RAIL].in_enable && (sp)->sct_rail != 0)
|
||||
|
||||
#define MOB_MOVE 0
|
||||
|
@ -227,5 +226,6 @@ struct sctintrins {
|
|||
extern struct sctintrins intrchr[INT_DEF + 2];
|
||||
|
||||
extern int fort_fire(struct sctstr *);
|
||||
extern int sct_rail_track(struct sctstr *);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue