Fix to the extra comma on /status

For people working on the C++ code.
Post Reply
lkjoel
Member
Posts: 779
Joined: Wed Feb 29, 2012 19:27
Location: Gallifrey
Contact:

Fix to the extra comma on /status

by lkjoel » 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 :P. 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?
My mods: The Nether | Doctor Who (WIP)

I have quit minetest ... again. I am heavily unimpressed by both the game and the community.

User avatar
Death Dealer
Member
Posts: 1379
Joined: Wed Feb 15, 2012 18:46
Location: Limbo
Contact:

by Death Dealer » 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 » Post

lol
My mods: The Nether | Doctor Who (WIP)

I have quit minetest ... again. I am heavily unimpressed by both the game and the community.

User avatar
sdzen
Member
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » 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 » Post

lol yeah I had that problem on C55's server lol
My mods: The Nether | Doctor Who (WIP)

I have quit minetest ... again. I am heavily unimpressed by both the game and the community.

User avatar
jordan4ibanez
Member
Posts: 1923
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » 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 » Post

I hope that c55 includes this fix lol
My mods: The Nether | Doctor Who (WIP)

I have quit minetest ... again. I am heavily unimpressed by both the game and the community.

sfan5
Moderator
Posts: 4095
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

+1 for this Fix! :D
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

jn
Member
Posts: 106
Joined: Tue Jan 03, 2012 19:15

by jn » 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 » 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! :D
My mods: The Nether | Doctor Who (WIP)

I have quit minetest ... again. I am heavily unimpressed by both the game and the community.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests