summaryrefslogtreecommitdiff
path: root/network_gui.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-08-20 12:03:39 +0000
committertruelight <truelight@openttd.org>2006-08-20 12:03:39 +0000
commitc07a8613a2efa80deba600cfcf36debe3928f708 (patch)
treee011a2c2758db027093a1983577e34b5838058af /network_gui.c
parent2309eeb8de5d1bb28b2e28caf0e0baf3112749e2 (diff)
downloadopenttd-c07a8613a2efa80deba600cfcf36debe3928f708.tar.xz
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
-Codechange: added some comments and const correctness (Darkvater)
Diffstat (limited to 'network_gui.c')
-rw-r--r--network_gui.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/network_gui.c b/network_gui.c
index a957e71dd..8a8b9d460 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -1492,6 +1492,9 @@ static void SendChat(const char *buf)
/**
* Find the next item of the list of things that can be auto-completed.
+ * @param item The current indexed item to return. This function can, and most
+ * likely will, alter item, to skip empty items in the arrays.
+ * @return Returns the char that matched to the index.
*/
static const char *ChatTabCompletionNextItem(uint *item)
{
@@ -1506,7 +1509,7 @@ static const char *ChatTabCompletionNextItem(uint *item)
/* Then, try townnames */
if (*item < (uint)MAX_CLIENT_INFO + GetTownPoolSize()) {
- Town *t;
+ const Town *t;
FOR_ALL_TOWNS_FROM(t, *item - MAX_CLIENT_INFO) {
int32 temp[1];
@@ -1536,19 +1539,11 @@ static char *ChatTabCompletionFindText(char *buf)
{
char *p;
- /* Scan from the right to the left */
- p = &buf[strlen(buf)];
- while (p != buf) {
- /* If we find a space, we try to complete the thing right of it */
- if (*p == ' ') {
- *p = '\0';
- return p + 1;
- }
- p--;
- }
+ p = strrchr(buf, ' ');
+ if (p == NULL) return buf;
- /* Not found, so complete the whole text */
- return p;
+ *p = '\0';
+ return p + 1;
}
/**