For people working on the C++ code.
lkjoel
Member
Posts: 779 Joined: Wed Feb 29, 2012 19:27
Location: Gallifrey
Contact:
by lkjoel » Tue Mar 27, 2012 23:03
Post
As many of you may know, when you type /status in a server, it gives this message (along other things, of course):
Code: Select all
clients={player1,player2,player3,}
You see the comma after player3? It's very minor, but it's enough to annoy me
. I decided to make a very simple patch for it (it also adds a space after the comma):
Code: Select all
4298,4299c4298,4313
< // Add name to information string
< os<<name<<L",";
---
> // Temporarily increase i to check if it's the last entry
> i++;
> if (i.atEnd() == false)
> {
> // This is not the last entry
> // Add name to information string
> os<<name<<L", ";
> }
> else
> {
> // This is the last entry
> // Add name to information string
> os<<name;
> }
> // Decrease temporarily increased i
> i--;
This is the new output:
Code: Select all
clients={player1, player2, player3}
Better, don't you think?
Death Dealer
Member
Posts: 1379 Joined: Wed Feb 15, 2012 18:46
Location: Limbo
Contact:
by Death Dealer » Tue Mar 27, 2012 23:14
Post
it what it should be, its grammatically correct:D
Keep calm and code python^_^
lkjoel
Member
Posts: 779 Joined: Wed Feb 29, 2012 19:27
Location: Gallifrey
Contact:
by lkjoel » Tue Mar 27, 2012 23:19
Post
lol
sdzen
Member
Posts: 1170 Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)
by sdzen » Tue Mar 27, 2012 23:28
Post
very nice just remember its serverside ikjoel XP
Zen S.D. The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno
lkjoel
Member
Posts: 779 Joined: Wed Feb 29, 2012 19:27
Location: Gallifrey
Contact:
by lkjoel » Tue Mar 27, 2012 23:49
Post
lol yeah I had that problem on C55's server lol
jordan4ibanez
Member
Posts: 1923 Joined: Tue Sep 27, 2011 18:44
GitHub:
jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez
by jordan4ibanez » Wed Mar 28, 2012 12:53
Post
this is a VERY SMALL fix, but being grammatically correct is awesome..i love it!
hello, am program. do language in rust. make computer do. okay i go now.
lkjoel
Member
Posts: 779 Joined: Wed Feb 29, 2012 19:27
Location: Gallifrey
Contact:
by lkjoel » Wed Mar 28, 2012 15:04
Post
I hope that c55 includes this fix lol
sfan5
Moderator
Posts: 4095 Joined: Wed Aug 24, 2011 09:44
GitHub:
sfan5
IRC: sfan5
Location: Germany
by sfan5 » Wed Mar 28, 2012 16:40
Post
+1 for this Fix!
jn
Member
Posts: 106 Joined: Tue Jan 03, 2012 19:15
by jn » Wed Mar 28, 2012 17:15
Post
A bit bloated, I got a smaller one: (EDIT: ok, this is not necessarily shorter)
Code: Select all
diff --git a/src/server.cpp b/src/server.cpp
index 02734bb..e2aafd8 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -4273,6 +4273,7 @@ RemoteClient* Server::getClient(u16 peer_id)
std::wstring Server::getStatusString()
{
std::wostringstream os(std::ios_base::binary);
+ bool not_first = false;
os<<L"# Server: ";
// Version
os<<L"version="<<narrow_to_wide(VERSION_STRING);
@@ -4284,6 +4285,11 @@ RemoteClient* Server::getClient(u16 peer_id)
i = m_clients.getIterator();
i.atEnd() == false; i++)
{
+ // add a comma
+ if(not_first)
+ os<<L",";
+ else
+ not_first = true;
// Get client and check that it is valid
RemoteClient *client = i.getNode()->getValue();
assert(client->peer_id == i.getNode()->getKey());
@@ -4296,7 +4302,7 @@ RemoteClient* Server::getClient(u16 peer_id)
if(player != NULL)
name = narrow_to_wide(player->getName());
// Add name to information string
- os<<name<<L",";
+ os<<name;
}
os<<L"}";
if(((ServerMap*)(&m_env->getMap()))->isSavingEnabled() == false)
Last edited by
jn on Wed Mar 28, 2012 17:16, edited 1 time in total.
lkjoel
Member
Posts: 779 Joined: Wed Feb 29, 2012 19:27
Location: Gallifrey
Contact:
by lkjoel » Wed Feb 27, 2013 18:04
Post
jn wrote: A bit bloated, I got a smaller one: (EDIT: ok, this is not necessarily shorter)
Code: Select all
diff --git a/src/server.cpp b/src/server.cpp
index 02734bb..e2aafd8 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -4273,6 +4273,7 @@ RemoteClient* Server::getClient(u16 peer_id)
std::wstring Server::getStatusString()
{
std::wostringstream os(std::ios_base::binary);
+ bool not_first = false;
os<<L"# Server: ";
// Version
os<<L"version="<<narrow_to_wide(VERSION_STRING);
@@ -4284,6 +4285,11 @@ RemoteClient* Server::getClient(u16 peer_id)
i = m_clients.getIterator();
i.atEnd() == false; i++)
{
+ // add a comma
+ if(not_first)
+ os<<L",";
+ else
+ not_first = true;
// Get client and check that it is valid
RemoteClient *client = i.getNode()->getValue();
assert(client->peer_id == i.getNode()->getKey());
@@ -4296,7 +4302,7 @@ RemoteClient* Server::getClient(u16 peer_id)
if(player != NULL)
name = narrow_to_wide(player->getName());
// Add name to information string
- os<<name<<L",";
+ os<<name;
}
os<<L"}";
if(((ServerMap*)(&m_env->getMap()))->isSavingEnabled() == false)
Nice!
Users browsing this forum: No registered users and 5 guests