Author Topic: Quixadhal's generic bug fixes/improvements/stupid stuff for DS.  (Read 2273 times)

Offline quixadhal

  • BFF
  • ***
  • Posts: 642
    • View Profile
    • WileyMUD
Didn't see a thread already, so here's a spot where I can toss the occasional bug fix or improvement (in MY eyes) to the DS mudlib. :)

First up is a one-liner for the help command.  It just replaces the hard-coded "2000" character breakpoint for passing things to the pager with a more sensible "screen size - 2 lines".  There are quite a few legacy places where things are hardcoded with assumptions like this (80x25 screen size), but this is the first I found while adding my local changes to my git repository of DS 3.2.

Code: [Select]
bloodlines@brezhnev:~/lib$ git diff cmds/common/help.c
diff --git a/lib/cmds/common/help.c b/lib/cmds/common/help.c
index 639c2aa..b7064bf 100755
--- a/lib/cmds/common/help.c
+++ b/lib/cmds/common/help.c
@@ -50,7 +50,8 @@ mixed cmd(string arg) {
         }
     }
     help = center(mud_name()+" System Help", screen[0]) + tmp;
-    if(sizeof(help) < 2000)    help = wrap(help, screen[0]);
+    if(sizeof(help) < screen[0] * (screen[1] - 2))
+        help = wrap(help, screen[0]);
     who->eventPage(explode(help, "\n"), MSG_HELP);
     return 1;
 }

Offline quixadhal

  • BFF
  • ***
  • Posts: 642
    • View Profile
    • WileyMUD
Re: Quixadhal's generic bug fixes/improvements/stupid stuff for DS.
« Reply #1 on: March 03, 2011, 03:38:57 am »
Here's another one, a small change to cmds/players/terminal.c to list the available (recognized) terminal types as part of the error message when you don't enter one.

Code: [Select]
bloodlines@brezhnev:~/lib$ git diff cmds/players/terminal.c
diff --git a/lib/cmds/players/terminal.c b/lib/cmds/players/terminal.c
index 82fccfc..e2061dc 100755
--- a/lib/cmds/players/terminal.c
+++ b/lib/cmds/players/terminal.c
@@ -9,7 +9,11 @@
 inherit LIB_DAEMON;

 mixed cmd(string args) {
-    if( !args || args == "" ) return "Set it to what?";
+    if( !args || args == "" ) return "Currently set to \"" +
+        this_player()->GetTerminal() +
+        "\"\nAvailable: [" +
+        implode(sort_array(TERMINAL_D->query_terms(), 1), ", ") +
+        "]\nSet it to what?";
     message("system", "Terminal set to " +
             this_player()->SetTerminal(args) + ".", this_player());
     return 1;

Offline quixadhal

  • BFF
  • ***
  • Posts: 642
    • View Profile
    • WileyMUD
Re: Quixadhal's generic bug fixes/improvements/stupid stuff for DS.
« Reply #2 on: March 15, 2011, 12:49:14 pm »
Here's a small change to /secure/cmds/creators/ls.c.  It's always bugged me that some files showed up in the short display as "1   foo", while others were "001 foo".  So, I tracked that down and made it more consistent.  Also, one needs to divide by 1000, not by 1024, if you want to ensure a 3 digit display.

I also changed both versions to right-justify numbers, as that's *usually* what you want, so the numbers line up by size.  I also got rid of the tab... tabs are bad (IMHO).

Code: [Select]
bloodlines@brezhnev:~/lib/secure/cmds/creators$ git diff ls.c
diff --git a/lib/secure/cmds/creators/ls.c b/lib/secure/cmds/creators/ls.c
index 4fc326a..531832d 100755
--- a/lib/secure/cmds/creators/ls.c
+++ b/lib/secure/cmds/creators/ls.c
@@ -135,7 +135,7 @@ static private string long_list(string dir, mixed *files) {
     for(i=0, maxi=sizeof(files); i<maxi; i++) {
         if(files[i][1] == -2) loaded = "";
         else loaded = (find_object(dir+files[i][0]) ? "*" : "");
-        ret += sprintf("%:-3s%:-5s%:-30s %d\t%s",
+        ret += sprintf("%:-3s%:-5s%:-25s %8d %s",
                 loaded, acc, ctime(files[i][2]),
                 files[i][1], files[i][0]);
         if(files[i][1] == -2) ret += "/\n";
@@ -184,9 +184,9 @@ static string map_files(mixed *file, int *flags) {
     else tmp = "";
     if(!flags[2]) {
         if(file[1] == -2) tmp = tmp + "    ";
-        else if(!file[1]) tmp = tmp + "0   ";
-        else if(file[1] < 1024) tmp = " 1   ";
-        else tmp = sprintf("%s%:-3d ", tmp, (file[1]/1024));
+        else if(!file[1]) tmp = tmp + "  0 ";
+        else if(file[1] < 1000) tmp = tmp + "  1 ";
+        else tmp = sprintf("%s%3d ", tmp, (file[1]/1000));
     }
     return tmp + file[0] + ((file[1] == -2) ? "/" : "");
 }