Skip to content

Commit c7a2b78

Browse files
committed
Fix double space in messages like "X is standing over Y"
1 parent 1ba4240 commit c7a2b78

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/brogue/Movement.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,16 @@ void describeLocation(char *buf, short x, short y) {
355355
strcat(itemLocation, standsInTerrain ? " in " : " on ");
356356
strcat(itemLocation, tileText(x, y));
357357
}
358-
sprintf(buf, "%s %s %s %s%s.", subject, verb, preposition, object, itemLocation);
359-
describedItemName(theItem, object, DCOLS - strlen(buf));
360358

359+
describedItemName(theItem, object, DCOLS - strlen(buf));
360+
// This `sprintf` call is similar to the one at the end of this function, but that one
361+
// adds an extra space; to avoid the extra space in messages like "X is standing over Y",
362+
// we have to use a slightly different version here. A space is added to the end of the
363+
// verb (if not already present) a few lines above here, so we shouldn't add a space
364+
// after the verb in this `sprintf` call.
365+
sprintf(buf, "%s %s%s %s%s.", subject, verb, preposition, object, itemLocation);
366+
restoreRNG;
367+
return;
361368
} else {
362369
if (!prepositionLocked) {
363370
strcpy(preposition, subjectMoving ? (standsInTerrain ? "through" : "across")
@@ -384,7 +391,6 @@ void describeLocation(char *buf, short x, short y) {
384391
strcpy(preposition, standsInTerrain ? (subjectMoving ? "through" : "in")
385392
: (subjectMoving ? "across" : "on"));
386393

387-
sprintf(buf, "%s %s %s %s%s.", subject, verb, preposition, object, itemLocation);
388394
describedItemName(theItem, subject, DCOLS - strlen(buf));
389395

390396
} else { // no item

0 commit comments

Comments
 (0)