Fix to the extra comma on /status

lkjoel
Member
 
Posts: 778
Joined: Wed Feb 29, 2012 19:27

Fix to the extra comma on /status

by lkjoel » Tue Mar 27, 2012 23:03

As many of you may know, when you type /status in a server, it gives this message (along other things, of course):
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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):
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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

by Death Dealer » Tue Mar 27, 2012 23:14

it what it should be, its grammatically correct:D
Keep calm and code python^_^
 

lkjoel
Member
 
Posts: 778
Joined: Wed Feb 29, 2012 19:27

by lkjoel » Tue Mar 27, 2012 23:19

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

by sdzen » Tue Mar 27, 2012 23:28

very nice just remember its serverside ikjoel XP
[h]Zen S.D.[/h] 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: 778
Joined: Wed Feb 29, 2012 19:27

by lkjoel » Tue Mar 27, 2012 23:49

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: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Wed Mar 28, 2012 12:53

this is a VERY SMALL fix, but being grammatically correct is awesome..i love it!
If you can think it, you can make it.
 

lkjoel
Member
 
Posts: 778
Joined: Wed Feb 29, 2012 19:27

by lkjoel » Wed Mar 28, 2012 15:04

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.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Wed Mar 28, 2012 16:40

+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 » Wed Mar 28, 2012 17:15

A bit bloated, I got a smaller one: (EDIT: ok, this is not necessarily shorter)
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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: 778
Joined: Wed Feb 29, 2012 19:27

by lkjoel » Wed Feb 27, 2013 18:04

jn wrote:A bit bloated, I got a smaller one: (EDIT: ok, this is not necessarily shorter)
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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.
 


Return to Minetest Engine

Who is online

Users browsing this forum: No registered users and 20 guests

cron