Author Topic: Areacheck tool  (Read 539 times)

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Areacheck tool
« on: July 24, 2012, 10:07:56 AM »
I made this tool to simplify the process of verifying that the rooms in an area are all connected properly and have correctly-configured doors and a few other properties.  This code is free to take and use and do whatever with, public domain et cetera.  Initial testing indicates it is quite a help (for me, at least) in tracking down individual rooms in a batch of 70 files that are troublemakers, without having to personally run around the area checking exits (or having an NPC do it for you).

Code: [Select]
/* /cmds/creators/areacheck.c
 * 2012-Jul-21 T. Cook
 * -----
 * 2012-Jul-24 T. Cook finished initial version
 * To do:
 *   ambient light
 *   climate
 *   terraintype
 *   short/long (length)?
 */
#include <daemons.h>
#include <message_class.h>
#include <lib.h>

inherit LIB_COMMAND;

mapping M_exits = ([]);
string DoStuff( string s_arg, string s_enc, object o_TP );
string flipdir( string s_arg );
//string box( int i_form, string s_style );  // uncomment this and the function if you don't have the box() sefun

int cmd( string s_arg ){
object o_TP = this_player();
int scrX = o_TP->GetScreen()[0];
//string s_enc = o_TP->GetProperty( "Encoding" );
string s_enc = "default";
M_exits = ([]);

if( !s_arg ){
write( "This command needs a path as an argument." );
return 1;
}
if( !regexp( s_arg, "^/.*/$" ) ){
write( "This command needs a path that's delimited by single forward-slash characters." );
return 1;
}
if( !sizeof( get_dir( s_arg ) ) ){
write( "This command needs a valid path." );
return 1;
}

call_out( "DoStuff", 1, s_arg, s_enc, o_TP );
return 1;
}

string flipdir( string s_arg ){
switch( s_arg ){
case "north":     return "south";
case "northeast": return "southwest";
case "east":      return "west";
case "southeast": return "northwest";
case "south":     return "north";
case "southwest": return "northeast";
case "west":      return "east";
case "northwest": return "southeast";
case "up":        return "down";
case "down":      return "up";
default:          return "ERROR";
}
}

string DoStuff( string s_arg, string s_enc, object o_TP ){
string *sa_compassdirs = ({
"north", "northeast",
"east", "southeast",
"south", "southwest",
"west", "northwest",
"up", "down"
});
string *sa_exits;
string *sa_exit_exits;
string *sa_exit_exitfiles;
string s_direction;
string s_direction2;
string s_dot = s_enc == "OEM" ? "\xFE%^RESET%^" : "*%^RESET%^";
string s_dot2 = "%^G06%^" + s_dot;
string s_exitfile;
string s_filebody;
string s_roomfile;
string s_out = " \n";
string s_subexitfile;
string s_temp = "";
object o_exit;
object o_room;
int *ia_temp;
int i_temp;

foreach( s_roomfile in get_dir( s_arg ) ){
M_exits[s_roomfile] = ([ ]);
//---- check for valid file, load contents into string
if( catch( load_object( s_arg + s_roomfile ) ) ){
M_exits[s_roomfile]["error"] = "%^BOLD%^%^RED%^LOAD ERROR%^RESET%^";
continue;
}else{
o_room = load_object( s_arg + s_roomfile );
}
if( !o_room ){
M_exits[s_roomfile]["error"] = "%^BOLD%^%^RED%^LOAD ERROR%^RESET%^";
continue;
}
s_filebody = read_file( s_arg + s_roomfile );
//---- check for exits
sa_exits = o_room->GetExits();
if( sizeof( sa_exits ) ){ M_exits[s_roomfile]["exits"] = ([ ]); }
foreach( s_direction in sa_exits ){
s_exitfile = o_room->GetExit( s_direction );
if( s_exitfile[<2..] != ".c" ){ s_exitfile += ".c"; }
if( file_exists( s_exitfile ) ){
if( catch( load_object( s_exitfile ) ) ){
//M_exits[s_roomfile]["exits"][s_direction] = "%^F500%^";  // broken exit-room
M_exits[s_roomfile]["exits"][s_direction] = "%^BOLD%^%^RED%^";  // broken exit-room
}else{
o_exit = load_object( s_exitfile );
}
if( !o_exit ){
//M_exits[s_roomfile]["exits"][s_direction] = "%^F500%^";  // broken exit-room
M_exits[s_roomfile]["exits"][s_direction] = "%^BOLD%^%^RED%^";  // broken exit-room
}else{
//M_exits[s_roomfile]["exits"][s_direction] = "%^F020%^";  // exit-room loads
M_exits[s_roomfile]["exits"][s_direction] = "%^BOLD%^%^GREEN%^";  // exit-room loads
sa_exit_exitfiles = ({});
//---- check for exits from exit-room that return to room
sa_exit_exits = o_exit->GetExits();  // exit-room's exits
foreach( s_direction2 in sa_exit_exits ){
s_subexitfile = o_exit->GetExit( s_direction2 );
if( s_subexitfile[<2..] != ".c" ){ s_subexitfile += ".c"; }
if( file_exists( s_subexitfile ) ){
if( s_subexitfile == s_arg + s_roomfile ){  // shared connection
sa_exit_exitfiles += ({ s_subexitfile });
if( flipdir( s_direction2 ) == s_direction ){
//M_exits[s_roomfile]["exits"][s_direction] += "%^B040%^";  // connected Euclidean
M_exits[s_roomfile]["exits"][s_direction] += "%^B_GREEN%^";  // connected Euclidean
}else{
//M_exits[s_roomfile]["exits"][s_direction] += "%^B045%^";  // connected nonEuclidean
M_exits[s_roomfile]["exits"][s_direction] += "%^B_CYAN%^";  // connected nonEuclidean
}
}
}
}
//---- check for enters from exit-room that return to room
sa_exit_exits = filter(
o_exit->GetEnters(), (: sscanf( $1, "lib*std*dummy*%d", $(i_temp) ) == 1 :)
);  // exit-room's enters
foreach( s_direction2 in sa_exit_exits ){
s_subexitfile = o_exit->GetEnter( s_direction2 );
if( s_subexitfile[<2..] != ".c" ){ s_subexitfile += ".c"; }
if( file_exists( s_subexitfile ) ){
if( s_subexitfile == s_arg + s_roomfile ){  // shared connection
sa_exit_exitfiles += ({ s_subexitfile });
if( flipdir( s_direction2 ) == s_direction ){
//M_exits[s_roomfile]["exits"][s_direction] += "%^B040%^";  // connected Euclidean
M_exits[s_roomfile]["exits"][s_direction] += "%^B_GREEN%^";  // connected Euclidean
}else{
//M_exits[s_roomfile]["exits"][s_direction] += "%^B045%^";  // connected nonEuclidean
M_exits[s_roomfile]["exits"][s_direction] += "%^B_CYAN%^";  // connected nonEuclidean
}
}
}
}
//---- no shared connections
if( member_array( s_arg + s_roomfile, sa_exit_exitfiles ) == -1 ){
//M_exits[s_roomfile]["exits"][s_direction] += "%^B320%^";
M_exits[s_roomfile]["exits"][s_direction] += "%^B_ORANGE%^";
}
}
M_exits[s_roomfile]["exits"][s_direction] += s_dot;
}else{
//M_exits[s_roomfile]["exits"][s_direction] = "%^F500%^" + s_dot;  // nonexistant exit-file
M_exits[s_roomfile]["exits"][s_direction] = "%^BOLD%^%^RED%^" + s_dot;  // nonexistant exit-file
}
}
//---- check for enters
sa_exits = filter( o_room->GetEnters(), (: sscanf( $1, "lib*std*dummy*%d", $(i_temp) ) == 1 :) );
if( sizeof( sa_exits ) ){ M_exits[s_roomfile]["enters"] = ([ ]); }
foreach( s_direction in sa_exits ){
s_exitfile = o_room->GetEnter( s_direction );
if( s_exitfile[<2..] != ".c" ){ s_exitfile += ".c"; }
if( file_exists( s_exitfile ) ){
if( catch( load_object( s_exitfile ) ) ){
//M_exits[s_roomfile]["enters"][s_direction] = "%^F500%^";  // broken enter-room
M_exits[s_roomfile]["enters"][s_direction] = "%^BOLD%^%^RED%^";  // broken enter-room
}else{
o_exit = load_object( s_exitfile );
}
if( !o_exit ){
//M_exits[s_roomfile]["enters"][s_direction] = "%^F500%^";  // broken enter-room
M_exits[s_roomfile]["enters"][s_direction] = "%^BOLD%^%^RED%^";  // broken enter-room
}else{
//M_exits[s_roomfile]["enters"][s_direction] = "%^F020%^";  // enter-room loads
M_exits[s_roomfile]["enters"][s_direction] = "%^BOLD%^%^GREEN%^";  // enter-room loads
sa_exit_exitfiles = ({});
//---- check for exits from enter-room that return to room
sa_exit_exits = o_exit->GetExits();  // enter-room's exits
foreach( s_direction2 in sa_exit_exits ){
s_subexitfile = o_exit->GetExit( s_direction2 );
if( s_subexitfile[<2..] != ".c" ){ s_subexitfile += ".c"; }
if( file_exists( s_subexitfile ) ){
if( s_subexitfile == s_arg + s_roomfile ){  // shared connection
sa_exit_exitfiles += ({ s_subexitfile });
if( flipdir( s_direction2 ) == s_direction ){
//M_exits[s_roomfile]["enters"][s_direction] += "%^B040%^";  // connected Euclidean
M_exits[s_roomfile]["enters"][s_direction] += "%^B_GREEN%^";  // connected Euclidean
}else{
//M_exits[s_roomfile]["enters"][s_direction] += "%^B045%^";  // connected nonEuclidean
M_exits[s_roomfile]["enters"][s_direction] += "%^B_CYAN%^";  // connected nonEuclidean
}
}
}
}
//---- check for enters from enter-room that return to room
sa_exit_exits = filter(
o_exit->GetEnters(), (: sscanf( $1, "lib*std*dummy*%d", $(i_temp) ) == 1 :)
);  // exit-room's enters
foreach( s_direction2 in sa_exit_exits ){
s_subexitfile = o_exit->GetEnter( s_direction2 );
if( s_subexitfile[<2..] != ".c" ){ s_subexitfile += ".c"; }
if( file_exists( s_subexitfile ) ){
if( s_subexitfile == s_arg + s_roomfile ){  // shared connection
sa_exit_exitfiles += ({ s_subexitfile });
if( flipdir( s_direction2 ) == s_direction ){
//M_exits[s_roomfile]["enters"][s_direction] += "%^B040%^";  // connected Euclidean
M_exits[s_roomfile]["enters"][s_direction] += "%^B_GREEN%^";  // connected Euclidean
}else{
//M_exits[s_roomfile]["enters"][s_direction] += "%^B045%^";  // connected nonEuclidean
M_exits[s_roomfile]["enters"][s_direction] += "%^B_CYAN%^";  // connected nonEuclidean
}
}
}
}
//---- no shared connections
if( member_array( s_arg + s_roomfile, sa_exit_exitfiles ) == -1 ){
//M_exits[s_roomfile]["enters"][s_direction] += "%^B320%^";
M_exits[s_roomfile]["enters"][s_direction] += "%^B_RED%^";
}
}
M_exits[s_roomfile]["enters"][s_direction] += s_dot;
}else{
//M_exits[s_roomfile]["enters"][s_direction] = "%^F500%^" + s_dot;  // nonexistant enter-file
M_exits[s_roomfile]["enters"][s_direction] = "%^BOLD%^%^BLACK%^" + s_dot;  // nonexistant enter-file
}
}
//---- check for doors
if( sizeof( o_room->GetDoors() ) ){ M_exits[s_roomfile]["doors"] = ([ ]); }
foreach( s_direction in o_room->GetDoors() ){  // this is examining the doors in o_room
s_exitfile = o_room->GetDoor( s_direction );  // full path of the door object
if( s_exitfile[<2..] != ".c" ){ s_exitfile += ".c"; }
if( file_exists( s_exitfile ) ){
if( catch( load_object( s_exitfile ) ) ){
//M_exits[s_roomfile]["doors"][s_direction] = "%^F500%^";  // broken door-file
M_exits[s_roomfile]["doors"][s_direction] = "%^BOLD%^%^RED%^";  // broken door-file
}else{
o_exit = load_object( s_exitfile );
}
if( !o_exit ){
//M_exits[s_roomfile]["doors"][s_direction] = "%^F500%^";  // broken door-file
M_exits[s_roomfile]["doors"][s_direction] = "%^BOLD%^%^RED%^";  // broken door-file
}else{
//M_exits[s_roomfile]["doors"][s_direction] = "%^F020%^";  // door-file loads
M_exits[s_roomfile]["doors"][s_direction] = "%^BOLD%^%^GREEN%^";  // door-file loads
sa_exit_exitfiles = ({});
//---- check for doors from other side of door that return to room
if(
member_array( s_direction, o_room->GetExits() ) > -1 &&
catch( o_room->GetExit( s_direction )->GetDoors() )
){
//M_exits[s_roomfile]["doors"][s_direction] += "%^B500%^" + s_dot;
M_exits[s_roomfile]["doors"][s_direction] += "%^BOLD%^%^RED%^" + s_dot;
continue;
}else if(
member_array( s_direction, o_room->GetEnters() ) > -1 &&
catch( o_room->GetEnter( s_direction )->GetDoors() )
){
//M_exits[s_roomfile]["doors"][s_direction] += "%^B500%^" + s_dot;
M_exits[s_roomfile]["doors"][s_direction] += "%^BOLD%^%^RED%^" + s_dot;
continue;
}
if( member_array( s_direction, o_room->GetExits() ) > -1 && o_room->GetExit( s_direction ) ){
sa_exit_exits = o_room->GetExit( s_direction )->GetDoors();
s_temp = "exit";
}
if( member_array( s_direction, o_room->GetEnters() ) > -1 && o_room->GetEnter( s_direction ) ){
sa_exit_exits = o_room->GetEnter( s_direction )->GetDoors();
s_temp = "enter";
}
foreach( s_direction2 in sa_exit_exits ){  // examine the doors in the target room
if( s_temp == "exit" ){
s_subexitfile = o_room->GetExit( s_direction )->GetDoor( s_direction2 );
}else if( s_temp == "enter" ){
s_subexitfile = o_room->GetEnter( s_direction )->GetDoor( s_direction2 );
}
if( s_subexitfile[<2..] != ".c" ){ s_subexitfile += ".c"; }
if( file_exists( s_subexitfile ) ){
if( s_subexitfile == s_exitfile ){  // shared door
sa_exit_exitfiles += ({ s_subexitfile });
if( flipdir( s_direction2 ) == s_direction ){
//M_exits[s_roomfile]["doors"][s_direction] += "%^B040%^";  // connected Euclidean
M_exits[s_roomfile]["doors"][s_direction] += "%^B_GREEN%^";  // connected Euclidean
}else{
//M_exits[s_roomfile]["doors"][s_direction] += "%^B045%^";  // connected nonEuclidean
M_exits[s_roomfile]["doors"][s_direction] += "%^B_CYAN%^";  // connected nonEuclidean
}
}
}
}
//---- no shared connections
if( member_array( s_exitfile, sa_exit_exitfiles ) == -1 ){
//M_exits[s_roomfile]["doors"][s_direction] += "%^B320%^";
M_exits[s_roomfile]["doors"][s_direction] += "%^B_ORANGE%^";
}
}
s_temp = "";
M_exits[s_roomfile]["doors"][s_direction] += s_dot;
}else{
//M_exits[s_roomfile]["doors"][s_direction] = "%^F500%^" + s_dot;  // nonexistant file
M_exits[s_roomfile]["doors"][s_direction] = "%^BOLD%^%^RED%^" + s_dot;  // nonexistant file
}
}
//---- check for SetCoordinates()
//M_exits[s_roomfile]["coords"] = regexp( s_filebody, "SetCoordinates(.*);\n" ) ? "%^F020%^" : "%^F300%^";
M_exits[s_roomfile]["coords"] = regexp( s_filebody, "SetCoordinates(.*);\n" ) ? "%^GREEN%^" : "%^RED%^";
M_exits[s_roomfile]["coords"] += s_dot;
//---- check for SetWorld()
//M_exits[s_roomfile]["world"] = regexp( s_filebody, "SetWorld(.*);\n" ) ? "%^F020%^" : "%^F300%^";
M_exits[s_roomfile]["world"] = regexp( s_filebody, "SetWorld(.*);\n" ) ? "%^GREEN%^" : "%^RED%^";
M_exits[s_roomfile]["world"] += s_dot;
//---- check for SetTown()
//M_exits[s_roomfile]["town"] = regexp( s_filebody, "SetTown(.*);\n" ) ? "%^F020%^" : "%^F300%^";
M_exits[s_roomfile]["town"] = regexp( s_filebody, "SetTown(.*);\n" ) ? "%^GREEN%^" : "%^RED%^";
M_exits[s_roomfile]["town"] += s_dot;
//---- check for latitude/longitude/altitude
if(
o_room->GetProperty( "latitude" ) +
o_room->GetProperty( "longitude" ) +
o_room->GetProperty( "altitude" ) > 0
){
//M_exits[s_roomfile]["lla"] = "%^F020%^" + s_dot;
M_exits[s_roomfile]["lla"] = "%^GREEN%^" + s_dot;
}else{
//M_exits[s_roomfile]["lla"] = "%^F300%^" + s_dot;
M_exits[s_roomfile]["lla"] = "%^RED%^" + s_dot;
}
}
//===== generate output
s_out += sprintf(
"                %s%s%s%s World\n",
"%^G10%^", box( 0110, s_enc ), repeat_string( box( 0011, s_enc ), 14 ), "%^RESET%^"
);
s_out += sprintf(
"              %s%s  %s%s%s Town\n",
"%^G10%^", repeat_string( "  " + box( 1100, s_enc ) + " ", 1 ), box( 0110, s_enc ),
repeat_string( box( 0011, s_enc ), 10 ), "%^RESET%^"
);
s_out += sprintf(
"              %s%s  %s%s%s Coordinates\n",
"%^G10%^", repeat_string( "  " + box( 1100, s_enc ) + " ", 2 ), box( 0110, s_enc ),
repeat_string( box( 0011, s_enc ), 6 ), "%^RESET%^"
);
s_out += sprintf(
"              %s%s  %s%s%s Lat./Lon./Alt.\n",
"%^G10%^", repeat_string( "  " + box( 1100, s_enc ) + " ", 3 ), box( 0110, s_enc ),
repeat_string( box( 0011, s_enc ), 2 ), "%^RESET%^"
);
s_out += sprintf(
"                %s%s %s Exits %s\n",
repeat_string( "%^G10%^" + box( 1100, s_enc ) + "   ", 3 ), box( 1100, s_enc ) + "%^RESET%^",
box( 0110, s_enc ) + repeat_string( box( 0011, s_enc ), 7 ),
repeat_string( box( 0011, s_enc ), 7 ) + box( 0101, s_enc )
);
s_out += sprintf(
"Roomfile      %s%s N E S W UD   Others %s Enters %s Doors %s\n",
repeat_string( box( 1100, s_enc ) + " %^G10%^" + box( 1100, s_enc ) + "%^RESET%^ " , 4 ), box( 1100, s_enc ),
box( 1100, s_enc ), box( 1100, s_enc ), box( 1100, s_enc )
);
s_out += repeat_string( box( 0011, s_enc ), 14 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ), 3 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ), 3 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ), 3 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ), 3 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ), 12 ) + box( 0011, s_enc ) +
repeat_string( box( 0011, s_enc ), 8 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ), 8 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ), 7 ) + box( 1101, s_enc ) + "\n";

foreach( s_roomfile in sort_array( keys( M_exits ), 1 ) ){
s_out += sprintf(
"%-13' 's %s %s %s %s %s %s %s %s %s ",
s_roomfile[0..12], box( 1100, s_enc ),
M_exits[s_roomfile]["world"] ? M_exits[s_roomfile]["world"] : "-", box( 1100, s_enc ),
M_exits[s_roomfile]["town"] ? M_exits[s_roomfile]["town"] : "-", box( 1100, s_enc ),
M_exits[s_roomfile]["coords"] ? M_exits[s_roomfile]["coords"] : "-", box( 1100, s_enc ),
M_exits[s_roomfile]["lla"] ? M_exits[s_roomfile]["lla"] : "-", box( 1100, s_enc )
);
if( !undefinedp( M_exits[s_roomfile]["exits"] ) ){
s_out += M_exits[s_roomfile]["exits"]["north"]     ? M_exits[s_roomfile]["exits"]["north"]     : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["northeast"] ? M_exits[s_roomfile]["exits"]["northeast"] : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["east"]      ? M_exits[s_roomfile]["exits"]["east"]      : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["southeast"] ? M_exits[s_roomfile]["exits"]["southeast"] : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["south"]     ? M_exits[s_roomfile]["exits"]["south"]     : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["southwest"] ? M_exits[s_roomfile]["exits"]["southwest"] : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["west"]      ? M_exits[s_roomfile]["exits"]["west"]      : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["northwest"] ? M_exits[s_roomfile]["exits"]["northwest"] : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["up"]        ? M_exits[s_roomfile]["exits"]["up"]        : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["down"]      ? M_exits[s_roomfile]["exits"]["down"]      : s_dot2;
s_out += "   ";
foreach( s_direction in keys( M_exits[s_roomfile]["exits"] ) - sa_compassdirs ){
s_temp += M_exits[s_roomfile]["exits"][s_direction];
}
s_out += s_temp + "      "[0..<sizeof( keys( M_exits[s_roomfile]["exits"] ) - sa_compassdirs ) + 1 ];
s_temp = "";
}else if( undefinedp( M_exits[s_roomfile]["error"] ) ){
s_out += "     -NO EXITS-    ";
}
s_out += M_exits[s_roomfile]["error"] ? "     " + M_exits[s_roomfile]["error"] + "    " : "";
s_out += " " + box( 1100, s_enc );
if( !undefinedp( M_exits[s_roomfile]["enters"] ) ){
foreach( s_direction in keys( M_exits[s_roomfile]["enters"] ) ){
s_temp += M_exits[s_roomfile]["enters"][s_direction];
}
s_out += " " + s_temp + "      "[0..<sizeof( keys( M_exits[s_roomfile]["enters"] ) ) + 1] + " ";
s_temp = "";
}else{
s_out += "        ";
}
s_out += box( 1100, s_enc );
if( !undefinedp( M_exits[s_roomfile]["doors"] ) ){
foreach( s_direction in keys( M_exits[s_roomfile]["doors"] ) ){
s_temp += M_exits[s_roomfile]["doors"][s_direction];
}
s_out += " " + s_temp + "     "[0..<sizeof( keys( M_exits[s_roomfile]["doors"] ) ) + 1] + " ";
s_temp = "";
}else{
s_out += "       ";
}
s_out += box( 1100, s_enc );
s_out += "\n";
}
s_out += repeat_string( box( 0011, s_enc ), 14 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ), 3 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ), 3 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ), 3 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ), 3 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ), 12 ) + box( 0011, s_enc ) +
repeat_string( box( 0011, s_enc ), 8 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ), 8 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ), 7 ) + box( 1001, s_enc ) + "\n";
o_TP->eventPage( explode( s_out, "\n" ), MSG_ENV );
}

string GetHelp( string s_arg ){
string s_enc = this_player()->GetProperty( "Encoding" );
string s_dot = s_enc == "OEM" ? "\xFE%^RESET%^" : "*%^RESET%^";
return HelpInfo( ([
"syntax": "areacheck <PATH>",
"body": "Generates a table of information relating to rooms located in the specified path.\n" +
"Key:\n" +
/* this section is for if you've got xterm-256color mode available
"%^F020%^" + s_dot + " - used property, loadable exit or door\n" +
"%^F300%^" + s_dot + " - property not used\n" +
"%^F500%^" + s_dot + " - exit or door not loadable, or return-connection error\n" +
"%^B040%^%^F020%^" + s_dot + " - rooms have Euclidean connection\n" +
"%^B045%^%^F020%^" + s_dot + " - rooms have non-Euclidean connection\n" +
"%^B320%^%^F020%^" + s_dot + " - connection is one-way\n" +
"%^B500%^%^F020%^" + s_dot + " - error in door's return-connection\n" +
"%^BOLD%^%^RED%^LOAD ERROR%^RESET%^ - room file not loadable"
*/
"%^BOLD%^%^GREEN%^" + s_dot + " - used property, loadable exit or door\n" +
"%^RED%^" + s_dot + " - property not used\n" +
"%^BOLD%^%^RED%^" + s_dot + " - exit or door not loadable, or return-connection error\n" +
"%^B_GREEN%^%^BOLD%^%^GREEN%^" + s_dot + " - rooms have Euclidean connection\n" +
"%^B_CYAN%^%^BOLD%^%^GREEN%^" + s_dot + " - rooms have non-Euclidean connection\n" +
"%^B_ORANGE%^%^BOLD%^%^GREEN%^" + s_dot + " - connection is one-way\n" +
"%^B_RED%^%^BOLD%^%^GREEN%^" + s_dot + " - error in door's return-connection\n" +
"%^BOLD%^%^RED%^LOAD ERROR%^RESET%^ - room file not loadable"
]) );
}

/* info for box()
func: get boxdrawing character
args: int form (UDRL  1=single, 2=double, 0=none)
string style "OEM", "UTF-8", "Latin-1" [default]
rtrn: string boxdrawing character
(uncomment this function if you don't have box() as an sefun)
*/
/*
string box( int form, string style ){
switch( style ){
case "OEM":
switch( form ){
case 0000: return "\x20";
case 0011: return "\xC4";
case 0022: return "\xCD";
case 0101: return "\xBF";
case 0102: return "\xB8";
case 0110: return "\xDA";
case 0111: return "\xC2";
case 0120: return "\xD5";
case 0122: return "\xD1";
case 0201: return "\xB7";
case 0202: return "\xBB";
case 0210: return "\xD6";
case 0211: return "\xD2";
case 0220: return "\xC9";
case 0222: return "\xCB";
case 1001: return "\xD9";
case 1002: return "\xBE";
case 1010: return "\xC0";
case 1011: return "\xC1";
case 1020: return "\xD4";
case 1022: return "\xCF";
case 1100: return "\xB3";
case 1101: return "\xB4";
case 1102: return "\xB5";
case 1110: return "\xC3";
case 1111: return "\xC5";
case 1120: return "\xC6";
case 1122: return "\xD8";
case 2001: return "\xBD";
case 2002: return "\xBC";
case 2010: return "\xD3";
case 2011: return "\xD0";
case 2020: return "\xC8";
case 2022: return "\xCA";
case 2200: return "\xBA";
case 2201: return "\xB6";
case 2202: return "\xB9";
case 2210: return "\xC7";
case 2211: return "\xD7";
case 2220: return "\xCC";
case 2222: return "\xCE";
default:   return "\x3F";
}
break;
case "UTF-8":
switch( form ){
case 0000: return "\xE3\x80\x80";
case 0011: return "\xE2\x94\x80";
case 0022: return "\xE2\x95\x90";
case 0101: return "\xE2\x94\x90";
case 0102: return "\xE2\x95\x95";
case 0110: return "\xE2\x94\x8C";
case 0111: return "\xE2\x94\xAC";
case 0120: return "\xE2\x95\x92";
case 0122: return "\xE2\x95\xA4";
case 0201: return "\xE2\x95\x96";
case 0202: return "\xE2\x95\x97";
case 0210: return "\xE2\x95\x93";
case 0211: return "\xE2\x95\xA5";
case 0220: return "\xE2\x95\x94";
case 0222: return "\xE2\x95\xA6";
case 1001: return "\xE2\x94\x98";
case 1002: return "\xE2\x95\x9B";
case 1010: return "\xE2\x94\x94";
case 1011: return "\xE2\x94\xB4";
case 1020: return "\xE2\x95\x98";
case 1022: return "\xE2\x95\xA7";
case 1100: return "\xE2\x94\x82";
case 1101: return "\xE2\x94\xA4";
case 1102: return "\xE2\x95\xA1";
case 1110: return "\xE2\x94\x9C";
case 1111: return "\xE2\x94\xBC";
case 1120: return "\xE2\x95\x9E";
case 1122: return "\xE2\x95\xAA";
case 2001: return "\xE2\x95\x9C";
case 2002: return "\xE2\x95\x9D";
case 2010: return "\xE2\x95\x99";
case 2011: return "\xE2\x95\xA8";
case 2020: return "\xE2\x95\x9A";
case 2022: return "\xE2\x95\xA9";
case 2200: return "\xE2\x95\x91";
case 2201: return "\xE2\x95\xA2";
case 2202: return "\xE2\x95\xA3";
case 2210: return "\xE2\x95\x9F";
case 2211: return "\xE2\x95\xAB";
case 2220: return "\xE2\x95\xA0";
case 2222: return "\xE2\x95\xAC";
default:   return "\xEF\xBC\x9F";
}
break;
default:
switch( form ){
case 0000: return " ";
case 0011: return "-";
case 0022: return "=";
case 0101: return "+";
case 0102: return "+";
case 0110: return "+";
case 0111: return "+";
case 0120: return "+";
case 0122: return "+";
case 0201: return "+";
case 0202: return "+";
case 0210: return "+";
case 0211: return "+";
case 0220: return "+";
case 0222: return "+";
case 1001: return "+";
case 1002: return "+";
case 1010: return "+";
case 1011: return "+";
case 1020: return "+";
case 1022: return "+";
case 1100: return "|";
case 1101: return "+";
case 1102: return "+";
case 1110: return "+";
case 1111: return "+";
case 1120: return "+";
case 1122: return "+";
case 2001: return "+";
case 2002: return "+";
case 2010: return "+";
case 2011: return "+";
case 2020: return "+";
case 2022: return "+";
case 2200: return "|";
case 2201: return "+";
case 2202: return "+";
case 2210: return "+";
case 2211: return "+";
case 2220: return "+";
case 2222: return "+";
default:   return "?";
}
break;
}
return "";
}
//*/
/* EOF */

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Re: Areacheck tool
« Reply #1 on: July 24, 2012, 10:09:09 AM »
Sample output (using OEM characters and xterm-256color display) at http://i.imgur.com/8pppL.png of before files are fixed, and http://imgur.com/BCQA7.png after.

Offline detah

  • BFF
  • ***
  • Posts: 182
  • Ruler of 2D
    • View Profile
Re: Areacheck tool
« Reply #2 on: July 24, 2012, 11:32:59 AM »
This is a great idea. Thanks for sharing. I think this will be particularly useful for checking lightlevels, terrain types and doors in areas.

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Re: Areacheck tool
« Reply #3 on: July 24, 2012, 07:03:13 PM »
Still need to add the light level and terrain type checks, but those are a lot simpler than the exits and doors.

Re. your inquiry about the characters, to display the boxdrawing characters and centre-block you need to have your client set to use (for instance) Terminal as its font (in Windows), and use the flavour of encoding it wants to be able to do that.  It's pretty finicky across clients, systems, and so forth, so you kind of have to play around to find the right settings for it.

I thought I'd gone through the code and cleaned it up so that the OEM version was commented out in favour of using vanilla ASCII, but that might not be the case.

There's the command 'ascii' that's default to DS that will spit out the characters.

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Re: Areacheck tool
« Reply #4 on: July 26, 2012, 04:57:31 AM »
And here's the revised and improved version of the tool.

Added a check for SetEnters() that don't have associated SetItems(), listing of ambient light, climate, and terrain types, and a check of xterm-256color mode so behaviour is based on user setting.

Code: [Select]
/* /cmds/creators/areacheck.c
 * 2012-Jul-21 T. Cook
 * -----
 * 2012-Jul-26 T. Cook added check for enters without associated items
 *             T. Cook added listing for ambient light, climate, terrain
 *             T. Cook merged xterm-256color mode with basic
 * 2012-Jul-24 T. Cook finished initial version
 * To do:
 *   short/long (length)?
 */
#include <daemons.h>
#include <message_class.h>
#include <lib.h>

inherit LIB_COMMAND;

mapping M_exits = ([]);
string DoStuff( string s_arg, string s_enc, object o_TP );
string flipdir( string s_arg );
//string box( int i_form, string s_style );  // uncomment this and the function if you don't have the box() sefun

int cmd( string s_arg ){
object o_TP = this_player();
int scrX = o_TP->GetScreen()[0];
string s_enc = o_TP->GetProperty( "Encoding" );
M_exits = ([]);

if( !s_arg ){
write( "This command needs a path as an argument." );
return 1;
}
if( !regexp( s_arg, "^/.*/$" ) ){
write( "This command needs a path that's delimited by single forward-slash characters." );
return 1;
}
if( !sizeof( get_dir( s_arg ) ) ){
write( "This command needs a valid path." );
return 1;
}

call_out( "DoStuff", 1, s_arg, s_enc, o_TP );
return 1;
}

string flipdir( string s_arg ){
switch( s_arg ){
case "north":     return "south";
case "northeast": return "southwest";
case "east":      return "west";
case "southeast": return "northwest";
case "south":     return "north";
case "southwest": return "northeast";
case "west":      return "east";
case "northwest": return "southeast";
case "up":        return "down";
case "down":      return "up";
default:          return "ERROR";
}
}

string DoStuff( string s_arg, string s_enc, object o_TP ){
string *sa_compassdirs = ({
"north", "northeast",
"east", "southeast",
"south", "southwest",
"west", "northwest",
"up", "down"
});
string *sa_exits;
string *sa_exit_exits;
string *sa_exit_exitfiles;
string s_direction;
string s_direction2;
string s_dot = s_enc == "OEM" ? "\xFE%^RESET%^" : "*%^RESET%^";
string s_dot2 = "%^G06%^" + s_dot;
string s_exitfile;
string s_filebody;
string s_roomfile;
string s_out = " \n";
string s_subexitfile;
string s_temp = "", s_temp2, s_temp3, s_temp4;
object o_exit;
object o_room;
int *ia_temp;
int i_256 = o_TP->GetTerminal() == "xterm-256color" ? 1 : 0;
int i_ter = 0;  // set this to 1 if you have GetTerrainTypeName() in /lib/std/room.c
int i_temp;

foreach( s_roomfile in get_dir( s_arg ) ){
M_exits[s_roomfile] = ([ ]);
//---- check for valid file, load contents into string
if( catch( load_object( s_arg + s_roomfile ) ) ){
M_exits[s_roomfile]["error"] = "%^BOLD%^%^RED%^LOAD ERROR%^RESET%^";
continue;
}else{
o_room = load_object( s_arg + s_roomfile );
}
if( !o_room ){
M_exits[s_roomfile]["error"] = "%^BOLD%^%^RED%^LOAD ERROR%^RESET%^";
continue;
}
s_filebody = read_file( s_arg + s_roomfile );
//---- check for exits
sa_exits = o_room->GetExits();
if( sizeof( sa_exits ) ){ M_exits[s_roomfile]["exits"] = ([ ]); }
foreach( s_direction in sa_exits ){
s_exitfile = o_room->GetExit( s_direction );
if( s_exitfile[<2..] != ".c" ){ s_exitfile += ".c"; }
if( file_exists( s_exitfile ) ){
if( catch( load_object( s_exitfile ) ) ){
M_exits[s_roomfile]["exits"][s_direction] = "%^BOLD%^%^RED%^";  // broken exit-room
}else{
o_exit = load_object( s_exitfile );
}
if( !o_exit ){
M_exits[s_roomfile]["exits"][s_direction] = "%^BOLD%^%^RED%^";  // broken exit-room
}else{
M_exits[s_roomfile]["exits"][s_direction] = i_256 ? "%^F020%^" : "%^BOLD%^%^GREEN%^";  // exit loads
sa_exit_exitfiles = ({});
//---- check for exits from exit-room that return to room
sa_exit_exits = o_exit->GetExits();  // exit-room's exits
foreach( s_direction2 in sa_exit_exits ){
s_subexitfile = o_exit->GetExit( s_direction2 );
if( s_subexitfile[<2..] != ".c" ){ s_subexitfile += ".c"; }
if( file_exists( s_subexitfile ) ){
if( s_subexitfile == s_arg + s_roomfile ){  // shared connection
sa_exit_exitfiles += ({ s_subexitfile });
if( flipdir( s_direction2 ) == s_direction ){
M_exits[s_roomfile]["exits"][s_direction] += i_256 ? "%^B040%^" : "%^B_GREEN%^";
}else{
M_exits[s_roomfile]["exits"][s_direction] += i_256 ? "%^B045%^" : "%^B_CYAN%^";
}
}
}
}
//---- check for enters from exit-room that return to room
sa_exit_exits = filter(
o_exit->GetEnters(), (: sscanf( $1, "lib*std*dummy*%d", $(i_temp) ) == 1 :)
);  // exit-room's enters
foreach( s_direction2 in sa_exit_exits ){
s_subexitfile = o_exit->GetEnter( s_direction2 );
if( s_subexitfile[<2..] != ".c" ){ s_subexitfile += ".c"; }
if( file_exists( s_subexitfile ) ){
if( s_subexitfile == s_arg + s_roomfile ){  // shared connection
sa_exit_exitfiles += ({ s_subexitfile });
if( flipdir( s_direction2 ) == s_direction ){
M_exits[s_roomfile]["exits"][s_direction] += i_256 ? "%^B040%^" : "%^B_GREEN%^";
}else{
M_exits[s_roomfile]["exits"][s_direction] += i_256 ? "%^B045%^" : "%^B_CYAN%^";
}
}
}
}
//---- no shared connections
if( member_array( s_arg + s_roomfile, sa_exit_exitfiles ) == -1 ){
M_exits[s_roomfile]["exits"][s_direction] += i_256 ? "%^B320%^" : "%^B_ORANGE%^";
}
}
M_exits[s_roomfile]["exits"][s_direction] += s_dot;
}else{
M_exits[s_roomfile]["exits"][s_direction] = "%^BOLD%^%^RED%^" + s_dot;  // nonexistant exit-file
}
}
//---- check for enters with no associated dummy-items
if( sscanf( s_filebody, "%sSetEnters(%s);%s", s_temp, s_temp2, s_temp3 ) == 3 ){
if( sscanf( trim( s_temp2 ), "([%s])", s_temp3 ) == 1 ){
foreach( s_temp in explode( s_temp3, "," ) ){
if( sscanf(
trim( implode( explode( s_temp, "\n" ), "\n" ) ),
"\"%s\"%s:%s\"%s\"",
s_direction, s_temp2, s_temp3, s_temp4
) == 4 ){
if( member_array( s_direction, map( o_room->GetDummyItems(), (: $1->GetKeyName() :) ) ) == -1 ){
if( undefinedp( M_exits[s_roomfile]["enters"] ) ){ M_exits[s_roomfile]["enters"] = ([ ]); }
M_exits[s_roomfile]["enters"][s_direction] = "%^BOLD%^%^RED%^" + s_dot;
}
}
}
}
}
s_temp = "";
//---- check for enters with associated dummy-items
sa_exits = filter( o_room->GetEnters(), (: sscanf( $1, "lib*std*dummy*%d", $(i_temp) ) == 1 :) );
if( undefinedp( M_exits[s_roomfile]["enters"] ) && sizeof( sa_exits ) ){
M_exits[s_roomfile]["enters"] = ([ ]);
}
foreach( s_direction in sa_exits ){
s_exitfile = o_room->GetEnter( s_direction );
if( s_exitfile[<2..] != ".c" ){ s_exitfile += ".c"; }
if( file_exists( s_exitfile ) ){
if( catch( load_object( s_exitfile ) ) ){
M_exits[s_roomfile]["enters"][s_direction] = "%^BOLD%^%^RED%^";  // broken enter-room
}else{
o_exit = load_object( s_exitfile );
}
if( !o_exit ){
M_exits[s_roomfile]["enters"][s_direction] = "%^BOLD%^%^RED%^";  // broken enter-room
}else{
M_exits[s_roomfile]["enters"][s_direction] = i_256 ? "%^F020%^" : "%^BOLD%^%^GREEN%^";  // loads
sa_exit_exitfiles = ({});
//---- check for exits from enter-room that return to room
sa_exit_exits = o_exit->GetExits();  // enter-room's exits
foreach( s_direction2 in sa_exit_exits ){
s_subexitfile = o_exit->GetExit( s_direction2 );
if( s_subexitfile[<2..] != ".c" ){ s_subexitfile += ".c"; }
if( file_exists( s_subexitfile ) ){
if( s_subexitfile == s_arg + s_roomfile ){  // shared connection
sa_exit_exitfiles += ({ s_subexitfile });
if( flipdir( s_direction2 ) == s_direction ){
M_exits[s_roomfile]["enters"][s_direction] += i_256 ? "%^B040%^" : "%^B_GREEN%^";
}else{
M_exits[s_roomfile]["enters"][s_direction] += i_256 ? "%^B045%^" : "%^B_CYAN%^";
}
}
}
}
//---- check for enters from enter-room that return to room
sa_exit_exits = filter(
o_exit->GetEnters(), (: sscanf( $1, "lib*std*dummy*%d", $(i_temp) ) == 1 :)
);  // exit-room's enters
foreach( s_direction2 in sa_exit_exits ){
s_subexitfile = o_exit->GetEnter( s_direction2 );
if( s_subexitfile[<2..] != ".c" ){ s_subexitfile += ".c"; }
if( file_exists( s_subexitfile ) ){
if( s_subexitfile == s_arg + s_roomfile ){  // shared connection
sa_exit_exitfiles += ({ s_subexitfile });
if( flipdir( s_direction2 ) == s_direction ){
M_exits[s_roomfile]["enters"][s_direction] += i_256 ? "%^B040%^" : "%^B_GREEN%^";
}else{
M_exits[s_roomfile]["enters"][s_direction] += i_256 ? "%^B045%^" : "%^B_CYAN%^";
}
}
}
}
//---- no shared connections
if( member_array( s_arg + s_roomfile, sa_exit_exitfiles ) == -1 ){
M_exits[s_roomfile]["enters"][s_direction] += i_256 ? "%^B320%^" : "%^B_ORANGE%^";
}
}
M_exits[s_roomfile]["enters"][s_direction] += s_dot;
}else{
M_exits[s_roomfile]["enters"][s_direction] = "%^BOLD%^%^RED%^" + s_dot;  // nonexistant enter-file
}
}
//---- check for doors
if( sizeof( o_room->GetDoors() ) ){ M_exits[s_roomfile]["doors"] = ([ ]); }
foreach( s_direction in o_room->GetDoors() ){  // this is examining the doors in o_room
s_exitfile = o_room->GetDoor( s_direction );  // full path of the door object
if( s_exitfile[<2..] != ".c" ){ s_exitfile += ".c"; }
if( file_exists( s_exitfile ) ){
if( catch( load_object( s_exitfile ) ) ){
M_exits[s_roomfile]["doors"][s_direction] = "%^BOLD%^%^RED%^";  // broken door-file
}else{
o_exit = load_object( s_exitfile );
}
if( !o_exit ){
M_exits[s_roomfile]["doors"][s_direction] = "%^BOLD%^%^RED%^";  // broken door-file
}else{
M_exits[s_roomfile]["doors"][s_direction] = i_256 ? "%^F020%^" : "%^BOLD%^%^GREEN%^";  // loads
sa_exit_exitfiles = ({});
//---- check for doors from other side of door that return to room
if(
member_array( s_direction, o_room->GetExits() ) > -1 &&
catch( o_room->GetExit( s_direction )->GetDoors() )
){
M_exits[s_roomfile]["doors"][s_direction] += "%^BOLD%^%^RED%^" + s_dot;
continue;
}else if(
member_array( s_direction, o_room->GetEnters() ) > -1 &&
catch( o_room->GetEnter( s_direction )->GetDoors() )
){
M_exits[s_roomfile]["doors"][s_direction] += "%^BOLD%^%^RED%^" + s_dot;
continue;
}
if( member_array( s_direction, o_room->GetExits() ) > -1 && o_room->GetExit( s_direction ) ){
sa_exit_exits = o_room->GetExit( s_direction )->GetDoors();
s_temp = "exit";
}
if( member_array( s_direction, o_room->GetEnters() ) > -1 && o_room->GetEnter( s_direction ) ){
sa_exit_exits = o_room->GetEnter( s_direction )->GetDoors();
s_temp = "enter";
}
foreach( s_direction2 in sa_exit_exits ){  // examine the doors in the target room
if( s_temp == "exit" ){
s_subexitfile = o_room->GetExit( s_direction )->GetDoor( s_direction2 );
}else if( s_temp == "enter" ){
s_subexitfile = o_room->GetEnter( s_direction )->GetDoor( s_direction2 );
}
if( s_subexitfile[<2..] != ".c" ){ s_subexitfile += ".c"; }
if( file_exists( s_subexitfile ) ){
if( s_subexitfile == s_exitfile ){  // shared door
sa_exit_exitfiles += ({ s_subexitfile });
if( flipdir( s_direction2 ) == s_direction ){
M_exits[s_roomfile]["doors"][s_direction] += i_256 ? "%^B040%^" : "%^B_GREEN%^";
}else{
M_exits[s_roomfile]["doors"][s_direction] += i_256 ? "%^B045%^" : "%^B_CYAN%^";
}
}
}
}
//---- no shared connections
if( member_array( s_exitfile, sa_exit_exitfiles ) == -1 ){
M_exits[s_roomfile]["doors"][s_direction] += i_256 ? "%^B320%^" : "%^B_ORANGE%^";
}
}
s_temp = "";
M_exits[s_roomfile]["doors"][s_direction] += s_dot;
}else{
M_exits[s_roomfile]["doors"][s_direction] = "%^BOLD%^%^RED%^" + s_dot;  // nonexistant file
}
}
//---- check for SetCoordinates()
M_exits[s_roomfile]["coords"] = regexp( s_filebody, "SetCoordinates(.*);\n" ) ?
i_256 ? "%^F020%^" : "%^GREEN%^" : i_256 ? "%^F300%^" : "%^RED%^";
M_exits[s_roomfile]["coords"] += s_dot;
//---- check for SetWorld()
M_exits[s_roomfile]["world"] = regexp( s_filebody, "SetWorld(.*);\n" ) ?
i_256 ? "%^F020%^" : "%^GREEN%^" : i_256 ? "%^F300%^" : "%^RED%^";
M_exits[s_roomfile]["world"] += s_dot;
//---- check for SetTown()
M_exits[s_roomfile]["town"] = regexp( s_filebody, "SetTown(.*);\n" ) ?
i_256 ? "%^F020%^" : "%^GREEN%^" : i_256 ? "%^F300%^" : "%^RED%^";
M_exits[s_roomfile]["town"] += s_dot;
//---- check for latitude/longitude/altitude
if(
o_room->GetProperty( "latitude" ) +
o_room->GetProperty( "longitude" ) +
o_room->GetProperty( "altitude" ) > 0
){
M_exits[s_roomfile]["lla"] = ( i_256 ? "%^F020%^" : "%^GREEN%^" ) + s_dot;
}else{
M_exits[s_roomfile]["lla"] = ( i_256 ? "%^F300%^" : "%^RED%^" ) + s_dot;
}
//---- check ambient light
M_exits[s_roomfile]["light"] = o_room->GetAmbientLight();
//---- check climate
M_exits[s_roomfile]["climate"] = o_room->GetClimate() ? o_room->GetClimate() : "";
//---- check terrain-type
M_exits[s_roomfile]["terrain"] = i_ter ? o_room->GetTerrainTypeName() : o_room->GetTerrainType();
}
//===== generate output
s_out += sprintf(
"                %s%s%s%s World\n",
"%^G10%^", box( 0110, s_enc ), repeat_string( box( 0011, s_enc ), 14 ), "%^RESET%^"
);
s_out += sprintf(
"              %s%s  %s%s%s Town\n",
"%^G10%^", repeat_string( "  " + box( 1100, s_enc ) + " ", 1 ), box( 0110, s_enc ),
repeat_string( box( 0011, s_enc ), 10 ), "%^RESET%^"
);
s_out += sprintf(
"              %s%s  %s%s%s Coordinates\n",
"%^G10%^", repeat_string( "  " + box( 1100, s_enc ) + " ", 2 ), box( 0110, s_enc ),
repeat_string( box( 0011, s_enc ), 6 ), "%^RESET%^"
);
s_out += sprintf(
"              %s%s  %s%s%s Lat./Lon./Alt.\n",
"%^G10%^", repeat_string( "  " + box( 1100, s_enc ) + " ", 3 ), box( 0110, s_enc ),
repeat_string( box( 0011, s_enc ), 2 ), "%^RESET%^"
);
s_out += sprintf(
"                %s%s %s Exits %s\n",
repeat_string( "%^G10%^" + box( 1100, s_enc ) + "   ", 3 ), box( 1100, s_enc ) + "%^RESET%^",
box( 0110, s_enc ) + repeat_string( box( 0011, s_enc ), 7 ),
repeat_string( box( 0011, s_enc ), 7 ) + box( 0101, s_enc )
);
s_out += sprintf(
"Roomfile      %s%s N E S W UD   Others %s Enters %s Doors %s Lit %s Climate   %s Terrain   %s%s\n",
repeat_string( box( 1100, s_enc ) + " %^G10%^" + box( 1100, s_enc ) + "%^RESET%^ " , 4 ), box( 1100, s_enc ),
box( 1100, s_enc ), box( 1100, s_enc ), box( 1100, s_enc ), box( 1100, s_enc ), box( 1100, s_enc ),
i_ter ? "   " : "", box( 1100, s_enc )
);
s_out += repeat_string( box( 0011, s_enc ), 14 ) + box( 1111, s_enc ) +
repeat_string( repeat_string( box( 0011, s_enc ), 3 ) + box( 1111, s_enc ), 4 ) +
repeat_string( box( 0011, s_enc ), 21 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ),  8 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ),  7 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ),  5 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ), 11 ) + box( 1111, s_enc ) +
repeat_string( box( 0011, s_enc ), i_ter ? 14 : 11 ) + box( 1101, s_enc ) + "\n";
foreach( s_roomfile in sort_array( keys( M_exits ), 1 ) ){
s_out += sprintf(
"%-13' 's %s %s %s %s %s %s %s %s %s ",
s_roomfile[0..12], box( 1100, s_enc ),
M_exits[s_roomfile]["world"] ? M_exits[s_roomfile]["world"] : "-", box( 1100, s_enc ),
M_exits[s_roomfile]["town"] ? M_exits[s_roomfile]["town"] : "-", box( 1100, s_enc ),
M_exits[s_roomfile]["coords"] ? M_exits[s_roomfile]["coords"] : "-", box( 1100, s_enc ),
M_exits[s_roomfile]["lla"] ? M_exits[s_roomfile]["lla"] : "-", box( 1100, s_enc )
);
if( !undefinedp( M_exits[s_roomfile]["exits"] ) ){
s_out += M_exits[s_roomfile]["exits"]["north"]     ? M_exits[s_roomfile]["exits"]["north"]     : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["northeast"] ? M_exits[s_roomfile]["exits"]["northeast"] : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["east"]      ? M_exits[s_roomfile]["exits"]["east"]      : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["southeast"] ? M_exits[s_roomfile]["exits"]["southeast"] : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["south"]     ? M_exits[s_roomfile]["exits"]["south"]     : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["southwest"] ? M_exits[s_roomfile]["exits"]["southwest"] : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["west"]      ? M_exits[s_roomfile]["exits"]["west"]      : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["northwest"] ? M_exits[s_roomfile]["exits"]["northwest"] : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["up"]        ? M_exits[s_roomfile]["exits"]["up"]        : s_dot2;
s_out += M_exits[s_roomfile]["exits"]["down"]      ? M_exits[s_roomfile]["exits"]["down"]      : s_dot2;
s_out += "   ";
foreach( s_direction in keys( M_exits[s_roomfile]["exits"] ) - sa_compassdirs ){
s_temp += M_exits[s_roomfile]["exits"][s_direction];
}
s_out += s_temp + "      "[0..<sizeof( keys( M_exits[s_roomfile]["exits"] ) - sa_compassdirs ) + 1 ];
s_temp = "";
}else if( undefinedp( M_exits[s_roomfile]["error"] ) ){
s_out += "     -NO EXITS-    ";
}
s_out += M_exits[s_roomfile]["error"] ? "     " + M_exits[s_roomfile]["error"] + "    " : "";
s_out += " " + box( 1100, s_enc );
if( !undefinedp( M_exits[s_roomfile]["enters"] ) ){
foreach( s_direction in keys( M_exits[s_roomfile]["enters"] ) ){
s_temp += M_exits[s_roomfile]["enters"][s_direction];
}
s_out += " " + s_temp + "      "[0..<sizeof( keys( M_exits[s_roomfile]["enters"] ) ) + 1] + " ";
s_temp = "";
}else{
s_out += "        ";
}
s_out += box( 1100, s_enc );
if( !undefinedp( M_exits[s_roomfile]["doors"] ) ){
foreach( s_direction in keys( M_exits[s_roomfile]["doors"] ) ){
s_temp += M_exits[s_roomfile]["doors"][s_direction];
}
s_out += " " + s_temp + "     "[0..<sizeof( keys( M_exits[s_roomfile]["doors"] ) ) + 1] + " ";
s_temp = "";
}else{
s_out += "       ";
}
i_temp = M_exits[s_roomfile]["light"];
s_out += sprintf(
i_ter ? "%s%s%3d %s %-9s %s %12s %s" : "%s%s%3d %s %-9s %s %9d %s",
box( 1100, s_enc ),
i_temp < -999 ? "%^BOLD%^%^RED%^-" : i_temp > 999 ? "%^YELLOW%^+" : i_temp < 0 ? "%^RED%^-" : " ",
i_temp < -999 ? 999 : i_temp > 999 ? 999 : abs( i_temp ),
box( 1100, s_enc ), M_exits[s_roomfile]["climate"][0..9],
box( 1100, s_enc ),
i_ter ? item_list( M_exits[s_roomfile]["terrain"] )[0..11] : M_exits[s_roomfile]["terrain"],
box( 1100, s_enc )
);
s_out += "\n";
}
s_out += repeat_string( box( 0011, s_enc ), 14 ) + box( 1011, s_enc ) +
repeat_string( repeat_string( box( 0011, s_enc ),  3 ) + box( 1011, s_enc ), 4 ) +
repeat_string( box( 0011, s_enc ), 21 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ),  8 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ),  7 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ),  5 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ), 11 ) + box( 1011, s_enc ) +
repeat_string( box( 0011, s_enc ), i_ter ? 14 : 11 ) + box( 1001, s_enc ) + "\n";
o_TP->eventPage( explode( s_out, "\n" ), MSG_ENV );
}

string GetHelp( string s_arg ){
string s_enc = this_player()->GetProperty( "Encoding" );
string s_dot = s_enc == "OEM" ? "\xFE%^RESET%^" : "*%^RESET%^";
return
"syntax:  'areacheck <PATH>'\n\n" +
"Generates a table of information relating to rooms located in the specified path.\n" +
"Key:\n" +
( this_player()->GetTerminal() == "xterm-256color" ?
"%^F020%^" + s_dot + " - used property, loadable exit or door\n" +
"%^F300%^" + s_dot + " - property not used\n" +
"%^BOLD%^%^RED%^" + s_dot + " - exit, enter, or door not loadable, or return-connection error\n" +
"%^B040%^%^F020%^" + s_dot + " - rooms have Euclidean connection\n" +
"%^B045%^%^F020%^" + s_dot + " - rooms have non-Euclidean connection\n" +
"%^B320%^%^F020%^" + s_dot + " - connection is one-way\n" +
"%^B500%^%^F020%^" + s_dot + " - error in door's return-connection\n" +
"%^BOLD%^%^RED%^LOAD ERROR%^RESET%^ - room file not loadable"
:
"%^BOLD%^%^GREEN%^" + s_dot + " - used property, loadable exit or door\n" +
"%^RED%^" + s_dot + " - property not used\n" +
"%^BOLD%^%^RED%^" + s_dot + " - exit, enter, or door not loadable, or return-connection error\n" +
"%^B_GREEN%^%^BOLD%^%^GREEN%^" + s_dot + " - rooms have Euclidean connection\n" +
"%^B_CYAN%^%^BOLD%^%^GREEN%^" + s_dot + " - rooms have non-Euclidean connection\n" +
"%^B_ORANGE%^%^BOLD%^%^GREEN%^" + s_dot + " - connection is one-way\n" +
"%^B_RED%^%^BOLD%^%^GREEN%^" + s_dot + " - error in door's return-connection\n" +
"%^BOLD%^%^RED%^LOAD ERROR%^RESET%^ - room file not loadable"
);
}

/* info for box()
func: get boxdrawing character
args: int form (UDRL  1=single, 2=double, 0=none)
string style "OEM", "UTF-8", "Latin-1" [default]
rtrn: string boxdrawing character
(uncomment this function if you don't have box() as an sefun)
*/
/*
string box( int form, string style ){
switch( style ){
case "OEM":
switch( form ){
case 0000: return "\x20";
case 0011: return "\xC4";
case 0022: return "\xCD";
case 0101: return "\xBF";
case 0102: return "\xB8";
case 0110: return "\xDA";
case 0111: return "\xC2";
case 0120: return "\xD5";
case 0122: return "\xD1";
case 0201: return "\xB7";
case 0202: return "\xBB";
case 0210: return "\xD6";
case 0211: return "\xD2";
case 0220: return "\xC9";
case 0222: return "\xCB";
case 1001: return "\xD9";
case 1002: return "\xBE";
case 1010: return "\xC0";
case 1011: return "\xC1";
case 1020: return "\xD4";
case 1022: return "\xCF";
case 1100: return "\xB3";
case 1101: return "\xB4";
case 1102: return "\xB5";
case 1110: return "\xC3";
case 1111: return "\xC5";
case 1120: return "\xC6";
case 1122: return "\xD8";
case 2001: return "\xBD";
case 2002: return "\xBC";
case 2010: return "\xD3";
case 2011: return "\xD0";
case 2020: return "\xC8";
case 2022: return "\xCA";
case 2200: return "\xBA";
case 2201: return "\xB6";
case 2202: return "\xB9";
case 2210: return "\xC7";
case 2211: return "\xD7";
case 2220: return "\xCC";
case 2222: return "\xCE";
default:   return "\x3F";
}
break;
case "UTF-8":
switch( form ){
case 0000: return "\xE3\x80\x80";
case 0011: return "\xE2\x94\x80";
case 0022: return "\xE2\x95\x90";
case 0101: return "\xE2\x94\x90";
case 0102: return "\xE2\x95\x95";
case 0110: return "\xE2\x94\x8C";
case 0111: return "\xE2\x94\xAC";
case 0120: return "\xE2\x95\x92";
case 0122: return "\xE2\x95\xA4";
case 0201: return "\xE2\x95\x96";
case 0202: return "\xE2\x95\x97";
case 0210: return "\xE2\x95\x93";
case 0211: return "\xE2\x95\xA5";
case 0220: return "\xE2\x95\x94";
case 0222: return "\xE2\x95\xA6";
case 1001: return "\xE2\x94\x98";
case 1002: return "\xE2\x95\x9B";
case 1010: return "\xE2\x94\x94";
case 1011: return "\xE2\x94\xB4";
case 1020: return "\xE2\x95\x98";
case 1022: return "\xE2\x95\xA7";
case 1100: return "\xE2\x94\x82";
case 1101: return "\xE2\x94\xA4";
case 1102: return "\xE2\x95\xA1";
case 1110: return "\xE2\x94\x9C";
case 1111: return "\xE2\x94\xBC";
case 1120: return "\xE2\x95\x9E";
case 1122: return "\xE2\x95\xAA";
case 2001: return "\xE2\x95\x9C";
case 2002: return "\xE2\x95\x9D";
case 2010: return "\xE2\x95\x99";
case 2011: return "\xE2\x95\xA8";
case 2020: return "\xE2\x95\x9A";
case 2022: return "\xE2\x95\xA9";
case 2200: return "\xE2\x95\x91";
case 2201: return "\xE2\x95\xA2";
case 2202: return "\xE2\x95\xA3";
case 2210: return "\xE2\x95\x9F";
case 2211: return "\xE2\x95\xAB";
case 2220: return "\xE2\x95\xA0";
case 2222: return "\xE2\x95\xAC";
default:   return "\xEF\xBC\x9F";
}
break;
default:
switch( form ){
case 0000: return " ";
case 0011: return "-";
case 0022: return "=";
case 0101: return "+";
case 0102: return "+";
case 0110: return "+";
case 0111: return "+";
case 0120: return "+";
case 0122: return "+";
case 0201: return "+";
case 0202: return "+";
case 0210: return "+";
case 0211: return "+";
case 0220: return "+";
case 0222: return "+";
case 1001: return "+";
case 1002: return "+";
case 1010: return "+";
case 1011: return "+";
case 1020: return "+";
case 1022: return "+";
case 1100: return "|";
case 1101: return "+";
case 1102: return "+";
case 1110: return "+";
case 1111: return "+";
case 1120: return "+";
case 1122: return "+";
case 2001: return "+";
case 2002: return "+";
case 2010: return "+";
case 2011: return "+";
case 2020: return "+";
case 2022: return "+";
case 2200: return "|";
case 2201: return "+";
case 2202: return "+";
case 2210: return "+";
case 2211: return "+";
case 2220: return "+";
case 2222: return "+";
default:   return "?";
}
break;
}
return "";
}
//*/
/* EOF */

Example output using default character encoding and ansi terminal type at http://imgur.com/xNGj6.