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
|
@ -47,6 +47,7 @@
|
|||
|
||||
static void *nsc_ver(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_ver_maxnoc(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_sct_track(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_pln_att(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_pln_def(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_lnd_att(struct valstr *, struct natstr *, void *);
|
||||
|
@ -153,7 +154,7 @@ struct castr sect_ca[] = {
|
|||
{"uran", fldoff(sct_uran), NSC_UCHAR, 0, NULL, EF_BAD, 0},
|
||||
{"oldown", fldoff(sct_oldown), NSC_NATID, 0, NULL, EF_NATION, 0},
|
||||
{"off", fldoff(sct_off), NSC_UCHAR, 0, NULL, EF_BAD, 0},
|
||||
{"track", fldoff(sct_track), NSC_UCHAR, 0, NULL, EF_BAD, NSC_EXTRA},
|
||||
{"track", 0, NSC_LONG, 0, nsc_sct_track, EF_BAD, NSC_EXTRA},
|
||||
NSC_IVEC(fldoff(sct_item), ""),
|
||||
NSC_IVEC(fldoff(sct_dist), "_dist"),
|
||||
NSC_IVEC(fldoff(sct_del), "_del"),
|
||||
|
@ -766,6 +767,13 @@ nsc_ver_maxnoc(struct valstr *val, struct natstr *np, void *ptr)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void *
|
||||
nsc_sct_track(struct valstr *val, struct natstr *np, void *ptr)
|
||||
{
|
||||
val->val_as.lng = sct_rail_track(ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *
|
||||
nsc_pln_def(struct valstr *val, struct natstr *np, void *ptr)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue