Darkplaces master: one incorrect behavior execing cfgs without ending newline, and derivative game problem
Description:
Let’s introduce a demo script:
set testconcat ""
alias _append "testconcat \"$testconcat $1\""
_append hello
_append world
Save this to a file without ending newline, to somewhere like ~/.darkplaces/id1/testconcat.cfg
Build & launch darkplaces div0-stable, and give a test:
]exec testconcat.cfg
execing testconcat.cfg
]testconcat
testconcat is " hello world" [""] custom cvar
This is expected.
Do the same to master:
]exec testconcat.cfg
execing testconcat.cfg
]testconcat
testconcat is " worldtestconcat" [""] custom cvar
Which is faulty. Seems that it’s the last command’s name that being executed got appended directly after EOF.
If this file is saved with ending newline, both test will behave correctly.
It’s still unclear if this is relative to #364 (closed) and/or #377 (closed), Likely not relative. but as far as I know the commanding of DP was refactored a lot about one year ago.
Finding the root cause seems difficult to me: the problem itself is tricky, and DP’s commits between Okay now found, see merge request 143git bisect
can hardly be compiled.
Derivative problem:
In Xonotic, xonotic-common.cfg
is using a similar way to append cdtracks.
The gogetem soundtrack, which is at the end of cdtracks.cfg
without a newline, isn’t appended correctly to cdtrack list, thus maps using it (e.g. Boil, Bromine) comes without soundtrack played.
]g_cdtracks_remaplist
g_cdtracks_remaplist is "rising-of-the-phoenix ninesix ... variable x-force gogetem_cdtrack_0"] custom cvar
Note the last gogetem_cdtrack_0
entry. The last (internally evaluated) command executed is (the alias) _cdtrack_0
as well.
Giving cdtracks.cfg
an ending newline solves this problem as well.