mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r5972) -Fix: usr strrchr instead of your own function (tnx Darkvater)
-Codechange: added some comments and const correctness (Darkvater)
This commit is contained in:
parent
2309eeb8de
commit
c07a8613a2
@ -1492,6 +1492,9 @@ static void SendChat(const char *buf)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the next item of the list of things that can be auto-completed.
|
* 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)
|
static const char *ChatTabCompletionNextItem(uint *item)
|
||||||
{
|
{
|
||||||
@ -1506,7 +1509,7 @@ static const char *ChatTabCompletionNextItem(uint *item)
|
|||||||
|
|
||||||
/* Then, try townnames */
|
/* Then, try townnames */
|
||||||
if (*item < (uint)MAX_CLIENT_INFO + GetTownPoolSize()) {
|
if (*item < (uint)MAX_CLIENT_INFO + GetTownPoolSize()) {
|
||||||
Town *t;
|
const Town *t;
|
||||||
|
|
||||||
FOR_ALL_TOWNS_FROM(t, *item - MAX_CLIENT_INFO) {
|
FOR_ALL_TOWNS_FROM(t, *item - MAX_CLIENT_INFO) {
|
||||||
int32 temp[1];
|
int32 temp[1];
|
||||||
@ -1536,19 +1539,11 @@ static char *ChatTabCompletionFindText(char *buf)
|
|||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
/* Scan from the right to the left */
|
p = strrchr(buf, ' ');
|
||||||
p = &buf[strlen(buf)];
|
if (p == NULL) return 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--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Not found, so complete the whole text */
|
*p = '\0';
|
||||||
return p;
|
return p + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user