Skip to content

Commit c526c08

Browse files
authored
fix #315 - add custom colours to routes (#1109)
* fix #315 - add custom colours to routes * set fallback colour for routes
1 parent 86ef149 commit c526c08

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

config/usage.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ setdesc "sendmap" "manually sends map to the server"
761761
setdesc "getmap" "manually retrieves map from the server"
762762
setdesc "newmap" "create new map with the specified gridpower and name" "size" "name"
763763
setdesc "decalreset" "deletes all decal indices from map config file (including ones in use)"
764+
setdesc "routenames" "sets the routenames for race mode (list of names)" "text"
765+
setdesc "routecolours" "sets the routecolours for race mode (list of hexcolours)" "text"
764766

765767
listcomplete "newent" "actor affinity camera checkpoint decal envmap light lightfx mapmodel particles playerstart pusher rail route sound teleport trigger weapon wind"
766768
listcomplete "entfind" "actor affinity camera checkpoint decal envmap light lightfx mapmodel particles playerstart pusher rail route sound teleport trigger weapon wind unused"

src/game/entities.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ namespace entities
4343

4444
VARF(0, routeid, -1, -1, VAR_MAX, lastroutenode = -1; lastroutetime = 0; airnodes.setsize(0)); // selected route in race
4545
VARF(0, droproute, 0, 0, 1, lastroutenode = -1; lastroutetime = 0; airnodes.setsize(0); if(routeid < 0) routeid = 0);
46-
VAR(IDF_HEX, routecolour, 0, 0xFF22FF, 0xFFFFFF);
4746
VAR(0, droproutedist, 1, 16, VAR_MAX);
4847
VAR(0, routemaxdist, 0, 64, VAR_MAX);
4948
VAR(IDF_PERSIST, showroutenames, 0, 1, 1);
5049
FVAR(IDF_PERSIST, routenameblend, 0, 1, 1);
51-
SVARF(IDF_WORLD, routenames, "Easy Medium Hard", { string s; if(filterstring(s, routenames)) setsvar("routenames", s, false); });
50+
SVARF(IDF_WORLD, routenames, "Easy Medium Hard", { string s; if(filterstring(s, routenames)) { delete[] routenames; routenames = newstring(s); } });
51+
SVARF(IDF_WORLD, routecolours, "0x00FF00 0xFF7700 0xFF0000", { string s; if(filterstring(s, routecolours)) { delete[] routecolours; routecolours = newstring(s); } });
5252

5353
struct rail
5454
{
@@ -3037,7 +3037,16 @@ namespace entities
30373037
{
30383038
if(e.attrs[0] != routeid || (!m_edit(game::gamemode) && !m_race(game::gamemode))) break;
30393039
loopv(e.links) if(ents.inrange(e.links[i]) && ents[e.links[i]]->type == ROUTE && (!routemaxdist || o.dist(ents[e.links[i]]->o) <= routemaxdist))
3040-
part_flare(o, ents[e.links[i]]->o, 1, PART_LIGHTNING_FLARE, routecolour);
3040+
{
3041+
int col = 0xFF22FF;
3042+
char *rcol = indexlist(routecolours, routeid);
3043+
if(rcol)
3044+
{
3045+
if(*rcol) col = parseint(rcol);
3046+
delete[] rcol;
3047+
}
3048+
part_flare(o, ents[e.links[i]]->o, 1, PART_LIGHTNING_FLARE, col);
3049+
}
30413050

30423051
if(showroutenames && getfirstroute() == idx)
30433052
{

0 commit comments

Comments
 (0)