New option RAILWAYS
With RAILWAYS, highway-like sectors double as rail. They need to be at least 5% efficient to be operational, and then they additionally extend rail into adjacent sectors that are at least 60% efficient. New opt_RAILWAYS, SCT_HAS_RAIL(), sct_rail_track(). Update sector_mcost(), bp_neighbors(), lnd_mar_one_sector() for RAILWAYS mobility rules. Update sinfra(), spyline(), satdisp_sect() to show rail track instead of rail infrastructure for RAILWAYS. New virtual sector selector track, implemented by nsc_sct_track().
This commit is contained in:
parent
cacc393c53
commit
b27298d4c5
13 changed files with 93 additions and 7 deletions
|
@ -33,8 +33,10 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include "file.h"
|
||||
#include "misc.h"
|
||||
#include "nat.h"
|
||||
#include "optlist.h"
|
||||
#include "path.h"
|
||||
#include "sect.h"
|
||||
#include "xy.h"
|
||||
|
@ -48,6 +50,12 @@ sector_mcost(struct sctstr *sp, int mobtype)
|
|||
if (base < 0)
|
||||
return -1.0;
|
||||
|
||||
if (mobtype == MOB_RAIL && opt_RAILWAYS) {
|
||||
if (!SCT_HAS_RAIL(sp))
|
||||
return -1;
|
||||
mobtype = MOB_MARCH;
|
||||
}
|
||||
|
||||
/* linear function in eff, d_mob0 at 0%, d_mob1 at 100% */
|
||||
base += (dchr[sp->sct_type].d_mob1 - base) * sp->sct_effic / 100;
|
||||
if (CANT_HAPPEN(base < 0))
|
||||
|
@ -83,3 +91,33 @@ speed_factor(double effspd, int tech)
|
|||
{
|
||||
return 480.0 / (effspd + techfact(tech, effspd));
|
||||
}
|
||||
|
||||
/* Minimal efficiency for railway and railway extension (opt_RAILWAYS) */
|
||||
#define SCT_RAIL_EFF 5
|
||||
#define SCT_RAIL_EXT_EFF 60
|
||||
|
||||
/* Is sector SP a railway? */
|
||||
#define SCT_IS_RAILWAY(sp) \
|
||||
(dchr[(sp)->sct_type].d_mob1 == 0 && (sp)->sct_effic >= SCT_RAIL_EFF)
|
||||
/* May sector SP have a railway extension? */
|
||||
#define SCT_MAY_HAVE_RAIL_EXT(sp) \
|
||||
((sp)->sct_effic >= SCT_RAIL_EXT_EFF)
|
||||
/* Does railway sector SP extend railway track into sector TOSP? */
|
||||
#define SCT_EXTENDS_RAIL(sp, tosp) \
|
||||
((sp)->sct_own == (tosp)->sct_own && SCT_MAY_HAVE_RAIL_EXT(tosp))
|
||||
|
||||
int
|
||||
sct_rail_track(struct sctstr *sp)
|
||||
{
|
||||
int i, res;
|
||||
struct sctstr *nsp;
|
||||
|
||||
res = !!SCT_IS_RAILWAY(sp);
|
||||
for (i = DIR_FIRST; i <= DIR_LAST; i++) {
|
||||
nsp = getsectp(sp->sct_x + diroff[i][0],
|
||||
sp->sct_y + diroff[i][1]);
|
||||
if (SCT_IS_RAILWAY(nsp) && SCT_EXTENDS_RAIL(nsp, sp))
|
||||
res++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
static void *nsc_ver(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_ver_maxnoc(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_sct_terr(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_sct_track(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_cargo_nplane(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_cargo_nchopper(struct valstr *, struct natstr *, void *);
|
||||
static void *nsc_cargo_nxlight(struct valstr *, struct natstr *, void *);
|
||||
|
@ -160,6 +161,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", 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"),
|
||||
|
@ -772,6 +774,13 @@ nsc_sct_terr(struct valstr *val, struct natstr *np, void *ptr)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
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_cargo_nplane(struct valstr *val, struct natstr *np, void *ptr)
|
||||
{
|
||||
|
|
|
@ -218,8 +218,7 @@ bp_neighbors(struct as_coord c, struct as_coord *cp, void *pp)
|
|||
move through it. We calculate it later. */
|
||||
if (dchr[sp->sct_type].d_mob0 < 0)
|
||||
continue;
|
||||
if (bp->bp_mobtype == MOB_RAIL
|
||||
&& (!intrchr[INT_RAIL].in_enable || sp->sct_rail == 0))
|
||||
if (bp->bp_mobtype == MOB_RAIL && !SCT_HAS_RAIL(sp))
|
||||
continue;
|
||||
if (sp->sct_own != from->sct_own)
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue