diff options
author | peter1138 <peter1138@openttd.org> | 2006-05-17 13:05:44 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-05-17 13:05:44 +0000 |
commit | d40bc5a2649f7f5b7dda429614a290f6bbc1f69c (patch) | |
tree | c63f306640b4d3fe81270d36d0dd0b456b5bdb25 | |
parent | 5a65e3301ef6698f42332cc5275af58fcd47460f (diff) | |
download | openttd-d40bc5a2649f7f5b7dda429614a290f6bbc1f69c.tar.xz |
(svn r4897) - NewGRF: don't allow addition of empty strings in action 4
-rw-r--r-- | newgrf.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1793,7 +1793,7 @@ static void VehicleNewName(byte *buf, int len) for (; id < endid && len > 0; id++) { size_t ofs = strlen(name) + 1; - if (ofs < 128) { + if (ofs > 1 && ofs < 128) { DEBUG(grf, 8) ("VehicleNewName: %d <- %s", id, name); switch (feature) { @@ -1857,7 +1857,13 @@ static void VehicleNewName(byte *buf, int len) #endif } } else { - DEBUG(grf, 7) ("VehicleNewName: Too long a name (%d)", ofs); + /* ofs is the string length + 1, so if the string is empty, ofs + * is 1 */ + if (ofs == 1) { + DEBUG(grf, 7) ("VehicleNewName: Can't add empty name"); + } else { + DEBUG(grf, 7) ("VehicleNewName: Too long a name (%d)", ofs); + } } name += ofs; len -= ofs; |