forked from github/server
use sbstring for make_movement_order.
This commit is contained in:
parent
2f7637f953
commit
b868a54f0b
1 changed files with 6 additions and 12 deletions
18
src/move.c
18
src/move.c
|
@ -1133,25 +1133,19 @@ order * cycle_route(order * ord, const struct locale *lang, int gereist)
|
||||||
|
|
||||||
order * make_movement_order(const struct locale *lang, direction_t steps[], int length)
|
order * make_movement_order(const struct locale *lang, direction_t steps[], int length)
|
||||||
{
|
{
|
||||||
char zOrder[128], *bufp = zOrder;
|
sbstring sbs;
|
||||||
size_t size = sizeof(zOrder) - 1;
|
char zOrder[128];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
sbs_init(&sbs, zOrder, sizeof(zOrder));
|
||||||
for (i = 0; i != length; ++i) {
|
for (i = 0; i != length; ++i) {
|
||||||
int bytes;
|
|
||||||
direction_t dir = steps[i];
|
direction_t dir = steps[i];
|
||||||
if (size > 1 && bufp != zOrder) {
|
if (i > 0) {
|
||||||
*bufp++ = ' ';
|
sbs_strcat(&sbs, " ");
|
||||||
--size;
|
|
||||||
}
|
}
|
||||||
bytes =
|
sbs_strcat(&sbs, LOC(lang, directions[dir]));
|
||||||
(int)str_strlcpy(bufp,
|
|
||||||
(const char *)LOC(lang, directions[dir]), size);
|
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
|
||||||
WARN_STATIC_BUFFER();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*bufp = 0;
|
|
||||||
return create_order(K_MOVE, lang, zOrder);
|
return create_order(K_MOVE, lang, zOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue