Author Topic: Landmarks daemon  (Read 770 times)

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Landmarks daemon
« on: June 10, 2012, 10:42:06 PM »
This is a daemon for landmarks which function as points-of-interest and possess data which can be used to add fake-items to a room.

First, the support files that are needed:
Code: [Select]
/* ** HEADER for /secure/sefun/boxdrawing.c **
 * 2005-Jul-31 - T. Cook
 * boxdrawing character handling
 * -----
 * 2011-Aug-16 T. Cook revised for DeadSouls
 * 2011-Jul-17 T. Cook began altering for DeadSouls
 * 2010-May-21 T. Cook reformatted for notepad++
 * 2009-Dec-30 T. Cook modified for tublib, streamlined
 * 2005-Sep-27 T. Cook tidied up
 */
#pragma strong_types

#ifndef __boxdrawing__
#define __boxdrawing__
/* 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
*/
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 "";
}
#endif
/* EOF */

Code: [Select]
/* /secure/sefun/extra_format.c **
 * 2012-Jan-31 T. Cook
 * extra text-formatting macros
*/
#pragma strong_types

#ifndef __extraformat__
#define __extraformat__
string HelpInfo( mapping M_args ){
string s_text = "Syntax:  ", s_format_syntax = "'%%^B_WHITE%%^%%^BLACK%%^%s%%^RESET%%^'";
mixed m_arg;
int i_flag, i_count, i_max;
if( !mapp( M_args ) ){ return "Invalid data was passed to HelpInfo()."; }
if( member_array( "syntax", keys( M_args ) ) == -1 ){
s_text += "%^RED%^%^FLASH%^unknown%^RESET%^";
}else{
switch( typeof( M_args["syntax"] ) ){
case "array":
foreach( m_arg in M_args["syntax"] ){
if( !stringp( m_arg ) ){ continue; }
if( i_flag == 0 ){
i_flag = 1;
}else{
s_text += "         ";
}
s_text += sprintf( s_format_syntax, strip_colours( m_arg ) ) + "\n";
}
break;
case "string":
s_text += sprintf( s_format_syntax, strip_colours( M_args["syntax"] ) ) + "\n";
break;
default:
s_text += "%^RED%^%^FLASH%^unknown%^RESET%^";
break;
}
}
s_text += "\n";
if( member_array( "body", keys( M_args ) ) == -1 ){
s_text += "This help topic has no detailed information.";
}else{
if( !stringp( M_args["body"] ) ){
s_text += "This help topic has no detailed information.";
}else{
s_text += M_args["body"];
}
}
s_text += "\n";
if( member_array( "synonyms", keys( M_args ) ) > -1 ){
switch( typeof( M_args["synonyms"] ) ){
case "array":
s_text += "\nSynonyms:  ";
foreach( m_arg in M_args["synonyms"] ){
if( typeof( m_arg ) != "string" ){ M_args["synonyms"] -= ({ m_arg }); }
}
s_text += implode( M_args["synonyms"], ", " ) + "\n";
break;
case "string":
s_text += "\nSynonyms:  " + M_args["synonyms"] + "\n";
break;
default:
break;
}
}
if( member_array( "see also", keys( M_args ) ) > -1 ){
switch( typeof( M_args["see also"] ) ){
case "array":
s_text += "\nSee also:  ";
foreach( m_arg in M_args["see also"] ){
if( typeof( m_arg ) != "string" ){ M_args["see also"] -= ({ m_arg }); }
}
s_text += implode( M_args["see also"], ", " ) + "\n";
break;
case "string":
s_text += "\nSee also:  " + M_args["see also"] + "\n";
break;
default:
break;
}
}
return s_text;
}

varargs string DebugFun( string s_fun, mixed ret, mixed *args... ){
string C = "%^CYAN%^", BR = "%^BOLD%^%^RED%^", BG = "%^BOLD%^%^GREEN%^", X = "%^RESET%^";
string *sa_A = ({}), s_element;
string s_A, s_B, space = repeat_string( "          ", 20 );
int i, n, scr_x = this_player()->GetScreen()[0];
s_A = C;
if( !s_fun || !stringp( s_fun ) ){
s_A += "NO_FUNCTION";
}else{
s_A += s_fun;
}
s_A += BR + "( " + X;
if( arrayp( args ) && arrayp( args[0] ) && sizeof( args[0] ) > 1 ){
foreach( s_element in args[0] ){
sa_A += ({ sprintf( "%O", s_element ) });
}
}else if( arrayp( args ) && sizeof( args ) > 1 ){
foreach( s_element in args ){
sa_A += ({ sprintf( "%O", s_element ) });
}
}else{
sa_A += ({ args });
}
s_A += implode( sa_A, BR + ", " + X );
s_A += BR + " )" + X;
i = sizeof( strip_colours( s_A ) );
n = sizeof( strip_colours( sprintf( "%O", ret ) ) ) + 1;
if( ret ){
if( sizeof( sprintf( "%O", ret ) ) + 2 > scr_x - i ){
s_A += "\n" + sprintf( "%O", ret );
}else{
s_A += space[0..scr_x - i - n] + sprintf( "%s%O", ret == 0 ? BR : ret == 1 ? BG : "", ret ) + X;
}
}
return s_A;
}
#endif
/* EOF */

Code: [Select]
/* ** HEADER for /secure/sefuns/directions.c **
 * 2005-Jun-28 - T. Cook
 * convert horizontal coordinates to world directions
 * -----
 * 2012-Jun-10 T. Cook streamlined
 * 2012-Jun-05 T. Cook changed to mappings, made sefun
 * 2011-Jul-17 T. Cook began altering for DeadSouls
 * 2010-May-31 T. Cook reformatted for notepad++
 * 2009-Mar-15 T. Cook modified for tublib, tidied up
 * 2005-Sep-27 T. Cook tidied up, renamed functions
 */
#pragma strong_types

#ifndef __directions__
#define __directions__
/* info for az_dir()
func: convert azimuth to compass direction
args: mixed azimuth in degrees
rtrn: string compass direction
*/
string az_dir( mixed m_az ){
float f_item;
string s_output = "thataway";
mapping M_dirs = ([
  0.00: "north",
11.25: "north by northeast",
33.75: "northeast",
56.25: "east by northeast",
78.75: "east",
101.25: "east by southeast",
123.75: "southeast",
146.25: "south by southeast",
168.75: "south",
191.25: "south by southwest",
213.75: "southwest",
236.25: "west by southwest",
258.75: "west",
281.25: "west by northwest",
303.75: "northwest",
326.25: "north by northwest",
348.75: "north"
]);
foreach( f_item in sort_array( keys( M_dirs ), 1 ) ){
if( to_float( m_az ) >= f_item ){ s_output = M_dirs[f_item]; }
}
return s_output;
}
/* info for alt_dir()
func: convert altitude to direction
args: mixed altitude in degrees, int ground presence
rtrn: string direction
*/
varargs string alt_dir( mixed m_alt, int i_ground ){
mapping M_dirs = ([ ]);
float f_item;
string s_output = "in your mind";
if( i_ground ){
M_dirs = ([
-90.00: "below the horizon",
  0.00: "on the horizon",
11.25: "low in the sky",
33.75: "halfway to zenith",
56.25: "near zenith",
78.75: "at zenith"
]);
}else{
M_dirs = ([
-90.00: "straight down",
-78.75: "far below eye level",
-56.25: "below eye level",
-33.75: "just below eye level",
-11.25: "at eye level",
11.25: "just above eye level",
33.75: "above eye level",
56.25: "far above eye level",
78.75: "straight up"
]);
}
foreach( f_item in sort_array( keys( M_dirs ), 1 ) ){
if( to_float( m_alt ) >= f_item ){ s_output = M_dirs[f_item]; }
}
return s_output;
}
#endif
/* EOF */

Here is the landmarks daemon itself:
Code: [Select]
/*
 * /daemon/landmarks.c
 * hold a list of landmarks that can be queried for direction/distance for description use
 * 2011-Oct-21 T. Cook
 * -----
 * 2012-Jun-10 T. Cook added GetRelativePoint()
 *             T. Cook made relative distance based on horizon visible to player's GetHeight()
 * 2012-Jun-09 T. Cook removed corners for landmark, made single-point position
 * 2012-Jun-05 T. Cook made each sense have its own range
 * 2012-Jun-04 T. Cook added ChangeLandmarkSense()
 * 2012-May-31 T. Cook added better error messages to GetLandmarkPositions()
 *                     changed ia_locus to fa_locus
 * 2012-Jan-22 T. Cook simplified AddLandmark()
 *                     added ChangeLandmark()
 * 2011-Dec-03 T. Cook changed GetLandmarkLoci() to GetLandmarks()
 *                     added ["itemdesc"] mapping
 *                     added RemoveAll()
 * 2011-Dec-01 T. Cook changed (size x, z) to bounding box corner
 *                     changed (i_x, i_y, i_z) to ia_xyz
 *                     changed to mapping for "corner 1", "corner 2", "midpoint" elements
 * 2011-Nov-29 T. Cook added world property
 * 2011-Oct-25 T. Cook changed (string s_size) to (int i_size_x, int i_size_z)
 * 2011-Oct-24 T. Cook made RemoveLandmark() remove town from mapping if last landmark in that town removed
 *                     added size property to AddLandmark()
 *                     changed for() loops to foreach()
 * 2011-Oct-23 T. Cook added GetLandmarkList()
 *                     switched azimuth calculation to bearing() call
 * Note: square 1.75x1.75 units @ 100 units distance is 1x1 degree, @ 50 is 2x2 degrees, @ 200 is 0.5x0.5 degrees
 */
#include <lib.h>

inherit LIB_DAEMON;

mapping GetLandmarks();
mapping GetLandmarkPositions( string s_world, string s_town, float *fa_locus );
string GetLandmarkList( mapping M_LandmarkPos );
mixed AddLandmark( string s_world, string s_town, string s_name );
varargs mixed ChangeLandmarkSense( string s_world, string s_town, string s_name, string s_desc, string s_msg, float f_dist );
mixed ChangeLandmark( string s_world, string s_town, string s_name, string s_property, mixed m_val );
mixed RemoveLandmark( string s_world, string s_town, string s_name );
mixed RemoveAll();

mapping M_Landmarks = ([ ]);
static string SaveFile;

static void create(){
daemon::create();
SaveFile = save_file( "/save/landmarks.o" );
if( unguarded( (: file_exists( SaveFile ) :) ) ){
RestoreObject( SaveFile, 1 );
}
SaveObject( SaveFile, 1 );
}

/* name: GetLandmarks
 * args: none
 * rtrn: mapping of current landmarks
 */
mapping GetLandmarks(){
return M_Landmarks;
}

/* name: GetLandmarkPositions
 * args: string world, string town, coordinates( float x, float y, float z )
 * rtrn: mapping [world] : ([
 *         [town] : ([
 *           [landmark name] : ([
 *             ["corner 1"] : ([ "azimuth", "altitude", "distance" ]),
 *             ["corner 2"] : ([ "azimuth", "altitude", "distance" ]),
 *             ["midpoint"] : ([ "azimuth", "altitude", "distance" ]),
 *             ["vision"]   : "desc",
 *             ["smell"]    : "desc",
 *             ["listen"]   : "desc",
 *             ["touch"]    : "desc",
 *             ["taste"]    : "desc"
 *           ])
 *         ])
 *       ])
 */
mapping GetLandmarkPositions( string s_world, string s_town, float *fa_locus ){
mapping M_args = ([ ]);
string *sa_senses = ({ "vision", "smell", "listen", "touch", "taste" }), s_sense;
string s_landmark;
float f_range;
int i_count;
mapping M_LandmarkPosition = ([ ]);
// error-checking
if( !s_world || !s_town ){
return ([ ]);
}
if( !stringp( s_world ) ){
write( sprintf(
"Invalid, non-string world (%%^YELLOW%%^%s%%^RESET%%^) was passed to GetLandmarkPositions().",
identify( s_world )
) );
}
if( !stringp( s_town ) ){
write( sprintf(
"Invalid, non-string town (%%^YELLOW%%^%s%%^RESET%%^) was passed to GetLandmarkPositions().",
identify( s_town )
) );
}
if( !arrayp( fa_locus ) ){
write( sprintf(
"Invalid, non-array location (%%^YELLOW%^s%%^RESET%%^) was passed to GetLandmarkPositions().",
identify( fa_locus )
) );
return ([ ]);
}
if( sizeof( fa_locus ) != 3 ){
write( sprintf(
"Invalid location triplet (%%^YELLOW%%^%s%%^RESET%%^) was passed to GetLandmarkPositions().",
identify( fa_locus )[3..<4]
) );
return ([ ]);
}
for( i_count = 0; i_count < 3; ++i_count ){
if( !floatp( fa_locus[i_count] ) ){ fa_locus[i_count] = to_float( fa_locus[i_count] ); }
}
if(
sizeof( M_Landmarks ) == 0 ||
member_array( s_world, keys( M_Landmarks ) ) == -1 ||
member_array( s_town,  keys( M_Landmarks[s_world] ) ) == -1 ||
sizeof( M_Landmarks[s_world][s_town] ) == 0
){
return ([ ]);
}
foreach( s_landmark in keys( M_Landmarks[s_world][s_town] ) ){
//----- initialise mappings -----
M_LandmarkPosition[s_world] = ([ ]);
M_LandmarkPosition[s_world][s_town] = ([ ]);
M_LandmarkPosition[s_world][s_town][s_landmark] = ([ ]);
M_LandmarkPosition[s_world][s_town][s_landmark]["position"] = ([ ]);
M_LandmarkPosition[s_world][s_town][s_landmark]["vision"] = ([ ]);
M_LandmarkPosition[s_world][s_town][s_landmark]["smell"]  = ([ ]);
M_LandmarkPosition[s_world][s_town][s_landmark]["listen"] = ([ ]);
M_LandmarkPosition[s_world][s_town][s_landmark]["touch"]  = ([ ]);
M_LandmarkPosition[s_world][s_town][s_landmark]["taste"]  = ([ ]);
//----- maths for altitude/azimuth/distance -----
foreach( s_sense in sa_senses ){
if( M_Landmarks[s_world][s_town][s_landmark][s_sense]["dist"] ){
if( f_range < M_Landmarks[s_world][s_town][s_landmark][s_sense]["dist"] ){
f_range = M_Landmarks[s_world][s_town][s_landmark][s_sense]["dist"];
}
}
}
M_LandmarkPosition[s_world][s_town][s_landmark]["position"] = ([ ]);
M_args["position"] = ([ ]);
M_args["position"]["x"] = M_Landmarks[s_world][s_town][s_landmark]["position"]["x"];
M_args["position"]["y"] = M_Landmarks[s_world][s_town][s_landmark]["position"]["y"];
M_args["position"]["z"] = M_Landmarks[s_world][s_town][s_landmark]["position"]["z"];
M_args["position"]["dist locus to x"] = M_args["position"]["x"] - fa_locus[0];
M_args["position"]["dist locus to y"] = M_args["position"]["y"] - fa_locus[1];
M_args["position"]["dist locus to z"] = M_args["position"]["z"] - fa_locus[2];
M_args["position"]["dist locus to xy"] = sqrt(
M_args["position"]["dist locus to x"] * M_args["position"]["dist locus to x"] +
M_args["position"]["dist locus to y"] * M_args["position"]["dist locus to y"]
);
M_args["position"]["dist locus to xyz"] = sqrt(
M_args["position"]["dist locus to x"] * M_args["position"]["dist locus to x"] +
M_args["position"]["dist locus to y"] * M_args["position"]["dist locus to y"] +
M_args["position"]["dist locus to z"] * M_args["position"]["dist locus to z"]
);
// calculate altitude/azimuth if the landmark is in range
if( M_args["position"]["dist locus to xyz"] < f_range ){
M_LandmarkPosition[s_world][s_town][s_landmark]["position"]["azimuth"] =
bearing( fa_locus[0], fa_locus[1], M_args["position"]["x"], M_args["position"]["y"] );
if( M_args["position"]["dist locus to xy"] != 0.0 ){
M_LandmarkPosition[s_world][s_town][s_landmark]["position"]["altitude"] =
M_args["position"]["dist locus to z"] == 0.0 ? 0.0 : 360.0 * atan( (
M_args["position"]["dist locus to xyz"] - M_args["position"]["dist locus to xy"] ) /
M_args["position"]["dist locus to z"] ) / 3.1415926535;
}else{
M_LandmarkPosition[s_world][s_town][s_landmark]["position"]["altitude"] =
M_args["position"]["dist locus to z"] > 0.0 ? 90.0 : M_args["position"]["dist locus to z"] ?
0.0 : -90.0;
}
}
M_LandmarkPosition[s_world][s_town][s_landmark]["position"]["distance"] =
M_args["position"]["dist locus to xyz"];
//----- assign available sense descriptions that are within range ---
foreach( s_sense in sa_senses ){
if(
member_array( s_sense, keys( M_Landmarks[s_world][s_town][s_landmark] ) ) > -1 &&
M_Landmarks[s_world][s_town][s_landmark][s_sense] != "" &&
M_Landmarks[s_world][s_town][s_landmark][s_sense]["dist"] <= f_range
){
M_LandmarkPosition[s_world][s_town][s_landmark][s_sense] =
M_Landmarks[s_world][s_town][s_landmark][s_sense]["desc"];
}
}
//----- if the landmark doesn't actually have any sense descriptions, remove it from the list
f_range = M_LandmarkPosition[s_world][s_town][s_landmark]["position"]["dist locus to xyz"];
foreach( s_sense in keys( M_LandmarkPosition[s_world][s_town][s_landmark] ) ){
if( undefinedp( M_LandmarkPosition[s_world][s_town][s_landmark][s_sense] ) ){
map_delete( M_LandmarkPosition[s_world][s_town][s_landmark], s_sense );
}
}
if( sizeof( keys( M_LandmarkPosition[s_world][s_town][s_landmark] ) ) == 0 ){
map_delete( M_LandmarkPosition[s_world][s_town], s_landmark );
}
}
return M_LandmarkPosition[s_world][s_town];
}

/* name: GetRelativePoint
 * args: float azimuth, float altitude, float distance in metres
 * rtrn: string relative location of point
 */
string GetRelativePoint( float f_az, float f_alt, float f_dist, int i_ground ){
string s_elev = "", s_direction = "", s_distance = "";
float f_item;
mapping M_distances = ([
  -1.0: " right here",
   0.0: " within arm's reach",
   0.8: " a pace away",
   1.0: " very close by",
   5.0: " close by",
  10.0: " nearby",
  20.0: " a stone's throw",
  22.0: " a short distance",
100.0: " a ways",
840.0: " a ten minutes' walk",
880.0: " a good way",
1600.0: " a mile away",
1609.0: " in the distance",
2500.0: " a half-hour's walk",
2550.0: " a long way",
3200.0: " a very long way",
4000.0: " far away",
4750.0: " beyond the horizon"
]);
s_elev = alt_dir( f_alt, i_ground );
s_direction = az_dir( f_az );
foreach( f_item in sort_array( keys( M_distances ), 1 ) ){
if( f_dist >= f_item ){ s_distance = M_distances[f_item]; }
}
return s_elev +
( s_elev == "" || s_direction == "" ? "" : "," ) +
( s_elev != "" && s_direction == "" ? " and" : "" ) +
s_distance +
( s_direction == "" ? "" : " to the " + s_direction );
}

/* name: GetLandmarkList
 * args: mapping([ "landmark" : ([ "azimuth" : azimuth, "altitude" : altitude, "distance" : distance ]) ])
 * rtrn: string list of landmarks from mapping within given distance
 */
string GetLandmarkList( mapping M_LandmarkPos ){
string *sa_landmarks = ({}), *sa_keys = ({});
string *sa_senses = ({ "vision", "smell", "listen", "touch", "taste" }), s_sense;
string *sa_wworp = ({});
string s_landmark = "";

if( sizeof( M_LandmarkPos ) == 0 ){ return "There are no significant landmarks here."; }
foreach( s_landmark in keys( M_LandmarkPos ) ){
sa_keys = keys( M_LandmarkPos[s_landmark]["position"] );
if(
member_array( "azimuth",  sa_keys ) == -1 ||
member_array( "altitude", sa_keys ) == -1 ||
member_array( "distance", sa_keys ) == -1
){
continue;
}
foreach( s_sense in sa_senses ){
if( !undefinedp( M_LandmarkPos[s_landmark][s_sense] ) ){
switch( s_sense ){
case "vision": sa_wworp += ({ "seen" }); break;
case "smell":  sa_wworp += ({ "smelled" }); break;
case "listen": sa_wworp += ({ "heard" }); break;
case "touch":  sa_wworp += ({ "felt" }); break;
case "taste":  sa_wworp += ({ "tasted" }); break;
default:       sa_wworp += ({ "sensed" }); break;
}
}
}
if( s_landmark == "" ){ s_landmark = "something"; }
sa_landmarks += ({
( s_landmark == "" ? "something" : GetArticle( s_landmark ) + " " + s_landmark ) + " which can be " +
item_list( sa_wworp ) + " " +
GetRelativePoint(
M_LandmarkPos[s_landmark]["position"]["azimuth"],
M_LandmarkPos[s_landmark]["position"]["altitude"],
M_LandmarkPos[s_landmark]["position"]["distance"],
1
)
});
}
return sizeof( sa_landmarks ) == 0 ? "" : "There " +
( sizeof( sa_landmarks ) == 1 ? "is " : "are " ) + item_list( sa_landmarks ) + ".";
}

/* name: AddLandmark
 * args: string name, corner 1 locus( int x, int y, int z ), corner 2 locus( int x, int y, int z ), mapping descs
 * rtrn: set mapping value for landmark of given size centred at given coordinates if nonexistant
 */
mixed AddLandmark( string s_world, string s_town, string s_name ){
if( !stringp( s_world ) ){ write( "Invalid world passed to AddLandmark()." ); return 0; }
if( !stringp( s_town )  ){ write( "Invalid town passed to AddLandmark()."  ); return 0; }
if( !stringp( s_name )  ){ write( "Invalid landmark name passed to AddLandmark()." ); return 0; }
if( member_array( s_world, keys( M_Landmarks ) ) == -1 ){ M_Landmarks[s_world] = ([ ]); }
if( member_array( s_town,  keys( M_Landmarks[s_world] ) ) == -1 ){
M_Landmarks[s_world][s_town] = ([ ]);
}
if( member_array( s_name, keys( M_Landmarks[s_world][s_town] ) ) > -1 ){
return "The landmark '" + s_name + "' in the town '" + s_town + "' on the world '" +
s_world + "' already exists!";
}else{
M_Landmarks[s_world][s_town][s_name] = ([
"position": ([ "x": 0.0, "y": 0.0, "z": 0.0 ]),
"vision":   ([ "dist": 0.0 ]),
"smell":    ([ "dist": 0.0 ]),
"listen":   ([ "dist": 0.0 ]),
"touch":    ([ "dist": 0.0 ]),
"taste":    ([ "dist": 0.0 ]),
]);
}
SaveObject( SaveFile, 1 );
return 1;
}

/* name: ChangeLandmarkSense
 * args: string world, town, name, sense, description, notification message, float distance for sense description
 * rtrn: int success state
 */
 varargs mixed ChangeLandmarkSense(
string s_world, string s_town, string s_name, string s_sense, string s_desc, string s_msg, float f_dist
){
string *sa_senses = ({ "vision", "smell", "listen", "touch", "taste" }), s_what;
object *oa_viewers = ({});
mapping M_tmp;
if( !s_world || !stringp( s_world ) || member_array( s_world, keys( M_Landmarks ) ) == -1 ){
write( "Invalid world passed to ChangeLandmarkSense()." ); return 0;
}
if( !s_town || !stringp( s_town ) || member_array( s_town, keys( M_Landmarks[s_world] ) ) == -1 ){
write( "Invalid town passed to ChangeLandmarkSense()."  ); return 0;
}
if( !s_name || !stringp( s_name ) || member_array( s_name, keys( M_Landmarks[s_world][s_town] ) ) == -1 ){
write( "Invalid landmark name passed to ChangeLandmarkSense()." ); return 0;
}
if( !s_sense || !stringp( s_sense ) || member_array( lower_case( s_sense ), sa_senses ) == -1 ){
write( "Invalid sense passed to ChangeLandmarkSense()." ); return 0;
}
if( !f_dist ){
f_dist = 0.0;
}
oa_viewers = filter(
users(),
(: member_array( $(s_name), keys( GetLandmarkPositions( $(s_world), $(s_town), ({
to_float( environment( $1 )->GetProperty( "latitude" ) ),
to_float( environment( $1 )->GetProperty( "longitude" ) ),
to_float( environment( $1 )->GetProperty( "altitude" ) )
}) ) ) ) != -1 :)
);
//----- sense removed from landmark -----
if( !s_desc || !stringp( s_desc ) || s_desc == "" || s_desc == "\"\"" ){
map_delete( M_Landmarks[s_world][s_town][s_name], s_sense );
switch( s_sense ){
case "vision": s_what = "visible"; break;
case "smell":  s_what = "odorous"; break;
case "listen": s_what = "audible"; break;
case "touch":  s_what = "tangible"; break;
case "taste":  s_what = "tastable"; break;
default:       s_what = "perceivable"; break;
}
message(
"landmark",
s_msg ? s_msg : capitalize( s_name ) + " is no longer " + s_what + ".",
oa_viewers
);
//---- new sense added to landmark -----
}else if( !M_Landmarks[s_world][s_town][s_name][s_sense] ){
M_Landmarks[s_world][s_town][s_name][s_sense]["desc"] = s_desc;
M_Landmarks[s_world][s_town][s_name][s_sense]["dist"] = f_dist;
switch( s_sense ){
case "vision": s_what = "seen"; break;
case "smell":  s_what = "smelled"; break;
case "listen": s_what = "heard"; break;
case "touch":  s_what = "felt"; break;
case "taste":  s_what = "tasted"; break;
default:       s_what = "perceived"; break;
}
message(
"landmark",
s_msg ? s_msg : capitalize( s_name ) + " can now be " + s_what + ".",
oa_viewers
);
//----- existing sense for landmark has changed -----
}else{
M_Landmarks[s_world][s_town][s_name][s_sense]["desc"] = s_desc;
M_Landmarks[s_world][s_town][s_name][s_sense]["dist"] = f_dist;
switch( s_sense ){
case "vision": s_what = "appearance"; break;
case "smell":  s_what = "smell"; break;
case "listen": s_what = "sound"; break;
case "touch":  s_what = "texture"; break;
case "taste":  s_what = "taste"; break;
default:       s_what = "somehow"; break;
}
message(
"landmark",
s_msg ? s_msg : capitalize( s_name ) + " changes " + s_what + ".",
oa_viewers
);
}
return 1;
}

/* name: ChangeLandmark
 * args: string world, town, name, property, mixed value
 * rtrn: int success state
 */
 mixed ChangeLandmark( string s_world, string s_town, string s_name, string s_property, mixed m_val ){
string *sa_senses = ({ "vision", "smell", "listen", "touch", "taste" }), s_sense, s_what, s_val;
object *oa_viewers = ({});
float f_dist;
mapping M_tmp;
if( member_array( s_world, keys( M_Landmarks ) ) == -1 ){
write( "Invalid world passed to ChangeLandmark()." ); return 0;
}
if( member_array( s_town, keys( M_Landmarks[s_world] ) ) == -1 ){
write( "Invalid town passed to ChangeLandmark()."  ); return 0;
}
if( member_array( s_name, keys( M_Landmarks[s_world][s_town] ) ) == -1 ){
write( "Invalid landmark name passed to ChangeLandmark()." ); return 0;
}
switch( s_property ){
case "position":
if( !mapp( m_val ) ){
write( "Values for modifying landmark location must be in mapping form." );
return 0;
}
if( undefinedp( m_val["x"] ) || undefinedp( m_val["y"] ) || undefinedp( m_val["z"] ) ){
write( "Mapping for modifying landmark corner requires \"x\", \"y\", and \"z\" values." );
return 0;
}
M_Landmarks[s_world][s_town][s_name]["position"] = ([
"x": to_float( m_val["x"] ), "y": to_float( m_val["y"] ), "z": to_float( m_val["z"] )
]);
SaveObject( SaveFile, 1 );
write( "Changed " + s_property + " for " + s_name + "." );
return 1;
case "vision": case "smell": case "listen": case "touch": case "taste":
if( !stringp( m_val ) ){
write( "Values for modifying landmark descriptions must be in string form." );
return 0;
}
if( sscanf( m_val, "%f, %s", f_dist, s_val ) == 2 ){
ChangeLandmarkSense( s_world, s_town, s_name, s_property, s_val, "", f_dist );
}else{
write( "Sense for landmark needs distance and string.  '<DISTANCE>, <DESC>'" );
return 0;
}
SaveObject( SaveFile, 1 );
message(
"landmark",
( m_val == "" ? "Remov": "Chang" ) + "ed " + s_property + " for " + s_name + ".",
this_player()
);
return 1;
default:
if( member_array( s_property, keys( M_Landmarks[s_world][s_town][s_name] ) ) == -1 ){
write( "That property doesn't exist for landmarks." );
return 0;
}
M_Landmarks[s_world][s_town][s_name][s_property] = m_val;
SaveObject( SaveFile, 1 );
write( "Changed " + s_property + " for " + s_name + "." );
return 1;
}
 }

/* name: RemoveLandmark
 * args: string name
 * rtrn: remove landmark from mapping if it exists
 */
mixed RemoveLandmark( string s_world, string s_town, string s_name ){
if(
member_array( s_world, keys( M_Landmarks ) ) == -1 &&
member_array( s_town, keys( M_Landmarks[s_world] ) ) == -1 &&
member_array( s_name, keys( M_Landmarks[s_world][s_town] ) ) == -1
){
return "The landmark '" + s_name + "' in the town '" + s_town + "' on the world '" +
s_world + "' didn't even exist!";
}
map_delete( M_Landmarks[s_world][s_town], s_name );
if( sizeof( M_Landmarks[s_world][s_town] ) == 0 ){
map_delete( M_Landmarks[s_world], s_town );
}
if( sizeof( M_Landmarks[s_world] ) == 0 ){
map_delete( M_Landmarks, s_world );
}
SaveObject( SaveFile, 1 );
return 1;
}

/* name: RemoveAll
 * args: [none]
 * rtrn: remove all landmarks from mapping
 */
mixed RemoveAll(){
M_Landmarks = ([ ]);
SaveObject( SaveFile, 1 );
return 1;
}
/* EOF */

Here is the admin command for adding, removing, listing, and modifying landmarks:
Code: [Select]
/* /secure/cmds/admins/landmark.c
 * manage landmarks
 * 2011-Oct-22 T. Cook
 * -----
 * 2012-Jun-09 T. Cook removed corners from landmark, made single-point position
 * 2012-Jun-05 T. Cook made each sense have its own range
 * 2012-Jun-04 T. Cook separated detailed info from listing of all landmarks
 * 2012-Jun-01 T. Cook improved syntax, typo fixed
 * 2012-Jan-22 T. Cook simplified "add landmark"
 *                     added "change landmark"
 * 2011-Dec-03 T. Cook changed GetLandmarkLoci() to GetLandmarks()
 *                     added ["itemdesc"]
 *                     added 'remove all'
 * 2011-Dec-01 T. Cook changed (size x, z) to bounding box corner
 *                     changed (i_x, i_y, i_z) to ia_xyz
 * 2011-Nov-29 T. Cook added world property
 * 2011-Oct-25 T. Cook changed (string s_size) to (int i_size_x, int i_size_z)
 * 2011-Oct-24 T. Cook improved handling of add/remove, added size property
 *                     changed for() loops to foreach()
 * Note: square 1.75x1.75 units @ 100 units distance is 1x1 degree, @ 50 is 02x2 degrees, @200 is 0.5x0.5 degrees
 */
#include <lib.h>
#include <daemons.h>

inherit LIB_DAEMON;
string GetHelp( string s_str );
int RemoveLandmarks( string s_arg );

mixed cmd( string s_args ){
string s_World, s_Town, s_Name, s_opts, s_pair, s_enc, s_prop, s_val, *sa_keyval;
string *sa_senses = ({ "vision", "smell", "listen", "touch", "taste" }), s_sense;
string *sa_props = sa_senses + ({ "position" });
string *sa_worlds = ({}), *sa_towns = ({}), *sa_names = ({});
string s_color;
string s_blah = "";
int i_x, i_y, i_z, i_flag;
float f_x, f_y, f_z;
mixed m_val;
mapping M_Landmarks = LANDMARKS_D->GetLandmarks();
mapping M_c = ([
"BGW": "%^B_WHITE%^%^BLACK%^",
"X": "%^RESET%^",
"Y": "%^YELLOW%^",
"G": "%^GREEN%^",
"C": "%^CYAN%^",
"R": "%^RED%^",
"BC": "%^BOLD%^%^CYAN%^",
"BG": "%^BOLD%^%^GREEN%^",
"BW": "%^BOLD%^%^WHITE%^",
"BR": "%^BOLD%^%^RED%^"
]);
foreach( s_World in keys( M_Landmarks ) ){
sa_worlds += ({ lower_case( s_World ) });
foreach( s_Town in keys( M_Landmarks[s_World] ) ){
sa_towns += ({ lower_case( s_Town ) });
foreach( s_Name in keys( M_Landmarks[s_World][s_Town] ) ){
sa_names += ({ lower_case( s_Name ) });
}
}
}
//----- LIST ALL LANDMARKS -----
if( !s_args || s_args == "" ){
if( sizeof( M_Landmarks ) == 0 ){
write( "There are no landmarks available." );
}else{
s_enc = this_player()->GetProperty( "Encoding" );
write( M_c["BC"] + "** LANDMARKS **" + M_c["X"] );
write( sprintf(
"%s%s%s : %s%s%s : %s%-20s%s  <POSITION>",
M_c["Y"], "World", M_c["X"], M_c["C"], "Town", M_c["X"], M_c["BG"], "Landmark", M_c["X"]
) );
write( repeat_string( box( 0011, s_enc ), this_player()->GetScreen()[0] ) );
foreach( s_World in keys( M_Landmarks ) ){
foreach( s_Town in keys( M_Landmarks[s_World] ) ){
foreach( s_Name in keys( M_Landmarks[s_World][s_Town] ) ){
f_x = to_float( M_Landmarks[s_World][s_Town][s_Name]["position"]["x"] );
f_y = to_float( M_Landmarks[s_World][s_Town][s_Name]["position"]["y"] );
f_z = to_float( M_Landmarks[s_World][s_Town][s_Name]["position"]["z"] );
write( sprintf(
"%s%s%s : %s%s%s : %s%-20s%s  <%3.1f, %3.1f, %3.1f>",
M_c["Y"], s_World, M_c["X"], M_c["C"], s_Town, M_c["X"], M_c["BG"], s_Name, M_c["X"],
f_x, f_y, f_z
) );
}
}
}
}
//----- ADD LANDMARK -----
}else if( sscanf( s_args, "add %s", s_opts ) == 1 ){
if( regexp( lower_case( s_opts ), "(^| |:)(add|change|remove)($| |:)" ) == 1 ){
write( "The words 'add', 'change', or 'remove' can't be used as part of a world, town, or landmark name." );
return 1;
}
if( sscanf( s_opts, "%s:%s:%s", s_World, s_Town, s_Name ) == 3 ){
if(
member_array( lower_case( s_World ), sa_worlds ) > -1 &&
member_array( lower_case( s_Town  ), sa_towns  ) > -1 &&
member_array( lower_case( s_Name  ), sa_names  ) > -1
){
write( sprintf(
"The landmark '%s' already existed in the town '%s' on the world '%s'.", s_Name, s_Town, s_World
) );
return 1;
}
LANDMARKS_D->AddLandmark( s_World, s_Town, s_Name );
write( sprintf( "Landmark '%s' added to the town '%s' on the world '%s'.", s_Name, s_Town, s_World ) );
}else{
write( sprintf(
"\nSyntax:  '%slandmark add <WORLD>:<TOWN>:<NAME>%s'\n\n" +
"Where <WORLD>, <TOWN>, and <NAME> are the names of the world, town, and landmark.\n",
M_c["BGW"], M_c["X"]
) );
}
//----- CHANGE LANDMARK PROPERTY -----
}else if( sscanf( s_args, "change %s", s_opts ) == 1 ){
if( sscanf( s_opts, "%s for %s:%s:%s to %s", s_prop, s_World, s_Town, s_Name, s_val ) == 5 ){
if( member_array( lower_case( s_prop ), sa_props ) == -1 ){
write( sprintf( "The property '%s' isn't valid for landmarks.", s_prop ) );
return 1;
}
if(
member_array( s_World, keys( M_Landmarks ) ) == -1 ||
member_array( s_Town,  keys( M_Landmarks[s_World] ) ) == -1 ||
member_array( s_Name,  keys( M_Landmarks[s_World][s_Town] ) ) == -1
){
write( sprintf(
"Couldn't find landmark '%s' in the town '%s' on the world '%s'.  This command is case-sensitive.",
s_Name, s_Town, s_World
) );
return 1;
}
if(
regexp( lower_case( s_World ), "(^| |:)(add|change|remove)($| |:)" ) == 1 ||
regexp( lower_case( s_Town  ), "(^| |:)(add|change|remove)($| |:)" ) == 1 ||
regexp( lower_case( s_Name  ), "(^| |:)(add|change|remove)($| |:)" ) == 1
){
write(
"The words 'add', 'change', or 'remove' can't be used as part of a world, town, or landmark name."
);
return 1;
}
if( sscanf( s_val, "%f,%f,%f", f_x, f_y, f_z ) == 3 ){
m_val = ([ "x": f_x, "y": f_y, "z": f_z ]);
}else if( sscanf( s_val, "%d,%d,%d", i_x, i_y, i_z ) == 3 ){
m_val = ([ "x": to_float( i_x ), "y": to_float( i_y ), "z": to_float( i_z ) ]);
}else{
m_val = s_val;
}
LANDMARKS_D->ChangeLandmark( s_World, s_Town, s_Name, s_prop, m_val );
}else{
write( sprintf(
"\nSyntax:  '%slandmark change <WHAT> for <WORLD>:<TOWN>:<NAME> to <VALUE>%s'\n\n" +
"Where <WORLD>, <TOWN>, and <NAME> are the names of the world, town and landmark, <WHAT> is the " +
"property to be changed (currently 'vision', 'smell', 'listen', 'touch', 'taste', 'corner 1', and " +
"'corner 2'), and <VALUE> is the property's new value (note: landmark descriptions cannot contain " +
"commas!).\n",
M_c["BGW"], M_c["X"]
) );
}
//----- REMOVE LANDMARK -----
}else if( sscanf( s_args, "remove %s", s_opts ) == 1 ){
if( regexp( lower_case( s_opts ), "(^| |:)(add|change|remove)($| |:)" ) == 1 ){
write( "The words 'add', 'change', or 'remove' can't be used as part of a world, town, or landmark name." );
return 1;
}
if( sscanf( s_opts, "%s:%s:%s", s_World, s_Town, s_Name ) == 3 ){
if(
member_array( s_World, keys( M_Landmarks ) ) != -1 &&
member_array( s_Town,  keys( M_Landmarks[s_World] ) ) != -1 &&
member_array( s_Name,  keys( M_Landmarks[s_World][s_Town] ) ) != -1
){
LANDMARKS_D->RemoveLandmark( s_World, s_Town, s_Name );
previous_object()->eventPrint( "Landmark removed." );
}else{
write( sprintf(
"Couldn't find the landmark '%s' in the town '%s' on the world '%s' to remove.",
s_Name, s_Town, s_World
) );
}
}else if( s_opts == "all" ){
write( "This will remove all landmarks!  Are you certain you wish to do this (y/n)?  " );
input_to( (: RemoveLandmarks :) );
}else{
write( sprintf(
"Syntax:  '%slandmark remove <WORLD>,<TOWN>,<NAME>%s' or '%slandmark remove all%s'",
M_c["BGW"], M_c["X"], M_c["BGW"], M_c["X"]
) );
}
//----- LIST INDIVIDUAL LANDMARK -----
}else if( sscanf( s_args, "%s:%s:%s", s_World, s_Town, s_Name ) == 3 ){
if(
member_array( s_World, keys( M_Landmarks ) ) > -1 &&
member_array( s_Town,  keys( M_Landmarks[s_World] ) ) > -1 &&
member_array( s_Name,  keys( M_Landmarks[s_World][s_Town] ) ) > -1
){
write( sprintf(
"%s%s%s : %s%s%s : %s%-20s%s  <%3.1f, %3.1f, %3.1f>",
M_c["Y"], s_World, M_c["X"], M_c["C"], s_Town, M_c["X"], M_c["BG"], s_Name, M_c["X"],
to_float( M_Landmarks[s_World][s_Town][s_Name]["position"]["x"] ),
to_float( M_Landmarks[s_World][s_Town][s_Name]["position"]["y"] ),
to_float( M_Landmarks[s_World][s_Town][s_Name]["position"]["z"] )
) );
foreach( s_sense in sa_senses ){
s_color = member_array(
s_sense, keys( M_Landmarks[s_World][s_Town][s_Name] )
) > -1 && !undefinedp( M_Landmarks[s_World][s_Town][s_Name][s_sense]["desc"] ) &&
M_Landmarks[s_World][s_Town][s_Name][s_sense]["desc"] != "" ? M_c["G"] : M_c["R"];
i_flag += member_array( s_sense, keys( M_Landmarks[s_World][s_Town][s_Name] ) ) > -1 ? 1 : 0;
s_blah += sprintf(
"\t%s%-6s%s  (%4.2f):  %s\n",
s_color, s_sense, M_c["X"],
!undefinedp( M_Landmarks[s_World][s_Town][s_Name][s_sense]["dist"] ) ?
to_float( M_Landmarks[s_World][s_Town][s_Name][s_sense]["dist"] ) : 0.0,
!undefinedp( M_Landmarks[s_World][s_Town][s_Name][s_sense]["desc"] ) ||
stringp( M_Landmarks[s_World][s_Town][s_Name][s_sense]["desc"] ) ?
M_Landmarks[s_World][s_Town][s_Name][s_sense]["desc"] : "No description."
);
}
write( i_flag ? s_blah[0..<2] : "\t" + M_c["BR"] + "Error:" + M_c["X"] + "  No sense descriptions." );
}else{
write( sprintf(
"Couldn't find the landmark '%s' in the town '%s' on the world '%s'.  This command is case-sensitive.",
s_Name, s_Town, s_World
) );
}
//----- LANDMARK HELP -----
}else{
return GetHelp( "" );
}
return 1;
}

int RemoveLandmarks( string s_arg ){
if( lower_case( s_arg )[0..0] == "y" ){
LANDMARKS_D->RemoveAll();
previous_object()->eventPrint( "All landmarks removed." );
}else{
previous_object()->eventPrint( "Landmarks unchanged." );
}
return 1;
}

string GetHelp( string s_str ){
return ( HelpInfo( ([
"syntax": ({
"landmark",
"landmark <NAME>",
"landmark add <WORLD>:<TOWN>:<NAME>",
"landmark remove <WORLD>:<TOWN>:<NAME>",
"landmark remove all",
"landmark change position for <WORLD>:<TOWN>:<NAME> to <X>,<Y>,<Z>",
"landmark change <SENSE>:desc for <WORLD>:<TOWN>:<NAME> to <DESCRIPTION>",
"landmark change <SENSE>:dist for <WORLD>:<TOWN>:<NAME> to <DESCRIPTION>"
}),
"body": "Landmarks are points of interest that the MUD can include in an outdoor room's description if a " +
"player is within a certain distance of it.  The 'landmark' command allows management of landmark daemon " +
"elemnts.  Using 'landmark' by itself will display a list of current landmarks, and 'landmark <NAME>' " +
"will show all properties of the specified landmark.  <WORLD> is the world name, <TOWN> is the town name, " +
"<NAME> is the landmark name, <X>, <Y>, and <Z> are the floating-point coordinates of the center of the" +
"landmark, <DISTANCE> is a floating-point distance, <SENSE> is one of the sense vision, smell, listen, " +
"touch, or taste, and <DESCRIPTION> is a string.  If \"\" is used for <DESCRIPTION>, that property will be " +
"removed from the landmark."
]) ) );
}
/* EOF */

IMPORTANT:  Don't forget to...
add to /secure/include/daemons.h:
#define LANDMARKS_D          DIR_DAEMONS "/landmarks"

add to /secure/sefun/sefun.h:
//===== boxdrawing.c
string box( int form, string style );
//===== extra_format.c
string HelpInfo( mapping M_args );
varargs string DebugFun( string s_fun, mixed ret, mixed *args... );
//===== directions.c
string az_dir( mixed az );
varargs string alt_dir( mixed f_alt, int i_ground );


add to /secure/sefun/sefun.c:
#include "/secure/sefun/extra_format.c"
#include "/secure/sefun/directions.c"
#include "/secure/sefun/boxdrawing.c"

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Re: Landmarks daemon
« Reply #1 on: June 10, 2012, 11:09:58 PM »
What follows is the abomination that is my own adjustments to /lib/events/describe.c:

Code: [Select]
/*  /lib/events/describe.c
 *  this handles the descriptions of:  rooms
 *  -----------
 *  2011-Sep-09 T. Cook modified formatting
 *  2011-Sep-09 T. Cook modified to allow expansion
 *  2011-Sep-15 T. Cook finished making text flow around minimap/wizmap
 *  2011-Nov-06 T. Cook added check for BARE_EXITS
 *  2011-Nov-08 T. Cook attempted wrapping-error correction
 *  2011-Nov-10 T. Cook fixed wrapping error (?)
 *  2011-Nov-11 T. Cook fixed wrapping error per suggestion from Quixadhal to rewrap block instead of counting words
 *  2011-Nov-19 T. Cook imported GetDistantInput() code from /domains/guri/PeriodDesc
 *  2011-Nov-29 T. Cook added GetWorld()
 *  2011-Dec-12 T. Cook simplified inanimate object listing code, positioned objects listing code
 *  2011-Dec-13 T. Cook added door listing code
 *  2012-Jan-16 T. Cook rolled desc, smell, sound, touch vars into M_desc
 *  2012-Jan-27 T. Cook fixed issues with M_desc
 *  2012-May-11 T. Cook added separate border state checking
 *  2012-May-24 T. Cook added check for map use
 *  2012-May-26 T. Cook tidied up border & descstyle checking
 *  2012-May-31 T. Cook added else-case for no exits to set to ""
 *  To do:
 *  room-specific door hiding check
 */
#include <lib.h>
#include <daemons.h>
#include <message_class.h>
#include <vision.h>
#include <medium.h>
#include <position.h>
#include <terrain_types.h>

private static mixed globaltmp, tmp;
private static mapping M_desc2 = ([
"desc": "",
"smell": "",
"sound": "",
"touch": ""
]);
private static mapping M_desc = ([ "locus": "", "vision": "", "exits": "", "map": "", "contents": "" ]);
private static int i_vision, maxi;
string GetDistantInput();

void eventDescribeEnvironment( int brief ){
/*===== variable declarations =====*/
int i_count, i_countmax, i_envtype, i_flag, i_linesdesc, i_linesmap, i_mapstyle, i_pos, i_screenX, i_var, i_var2;
int i_wordcount, i_items, i_bor = this_player()->GetProperty( "Borders" ) == "on" ? 1 : 0;
mapping M_pos, M_shorts;
mixed *ma_words, *ma_words2;
object o_element, o_env, o_mount, o_ob, o_transport;
object *oa_mountinv, *oa_obs;
string border, s_invis, s_key, s_line, s_mapside, s_mount_inv, s_pos, s_style, s_temp, s_temp2, X;
string s_enc = this_player()->GetProperty( "Encoding" );
string *sa_map, *sa_mount_inv, *sa_shorts, *sa_textblock, *sa_textblock2;
mapping M_box = ([
"+1": box( i_bor ? 1111 : 0000, s_enc ),
"+2": box( i_bor ? 2222 : 0000, s_enc ),
"+3": box( i_bor ? 1122 : 0000, s_enc ),
"+4": box( i_bor ? 2211 : 0000, s_enc ),
"h":  box( i_bor ? 0011 : 0000, s_enc ),
"c1": box( i_bor ? 0101 : 0000, s_enc ),  // top-left
"c2": box( i_bor ? 0110 : 0000, s_enc ),  // top-right
"c3": box( i_bor ? 1001 : 0000, s_enc ),  // bottom-left
"c4": box( i_bor ? 1010 : 0000, s_enc ),  // bottom-right
"v":  box( i_bor ? 1100 : 0000, s_enc ),
"H":  box( i_bor ? 0022 : 0000, s_enc ),
"C1": box( i_bor ? 0202 : 0000, s_enc ),
"C2": box( i_bor ? 0220 : 0000, s_enc ),
"C3": box( i_bor ? 2002 : 0000, s_enc ),
"C4": box( i_bor ? 2020 : 0000, s_enc ),
"V":  box( i_bor ? 2200 : 0000, s_enc ),
"tt": box( i_bor ? 0111 : 0000, s_enc ),
"tb": box( i_bor ? 1011 : 0000, s_enc ),
"tl": box( i_bor ? 1110 : 0000, s_enc ),
"tr": box( i_bor ? 1101 : 0000, s_enc ),
"tT": box( i_bor ? 0211 : 0000, s_enc ),
"tB": box( i_bor ? 2011 : 0000, s_enc ),
"tL": box( i_bor ? 1120 : 0000, s_enc ),
"tR": box( i_bor ? 1102 : 0000, s_enc ),
"Tt": box( i_bor ? 0122 : 0000, s_enc ),
"Tb": box( i_bor ? 1022 : 0000, s_enc ),
"Tl": box( i_bor ? 2210 : 0000, s_enc ),
"Tr": box( i_bor ? 2201 : 0000, s_enc ),
"TT": box( i_bor ? 0222 : 0000, s_enc ),
"TB": box( i_bor ? 2022 : 0000, s_enc ),
"TL": box( i_bor ? 2220 : 0000, s_enc ),
"TR": box( i_bor ? 2202 : 0000, s_enc )
]);
mapping M_mapOEMreplace;

/*===== general variable assignments =====*/
border = "%^BOLD%^%^BLUE%^";
i_flag = 0;
i_mapstyle = 0;
i_screenX = this_player()->GetScreen()[0];
M_desc["vision"] = "";
M_pos = ([ ]);
M_pos["floating"]  = ([ ]);
M_pos["flying"]    = ([ ]);
M_pos["furniture"] = ([ ]);
M_pos["kneeling"]  = ([ ]);
M_pos["lying"]     = ([ ]);
M_pos["null"]      = ([ ]);
M_pos["sitting"]   = ([ ]);
M_pos["standing"]  = ([ ]);
M_pos["swimming"]  = ([ ]);
ma_words = ({});
ma_words2 = ({});
s_mapside = this_player()->GetProperty( "MapSide" );
if( s_mapside != "left" && s_mapside != "right" ){ this_player()->SetProperty( "MapSide", "left" ); }
s_style = this_player()->GetProperty( "DescStyle" );
s_temp = "";
s_temp2 = "";
sa_mount_inv = ({});
sa_textblock = ({});
sa_textblock2 = ({});
X = "%^RESET%^";

/*===== error handling =====*/
if( !(  o_env = environment( this_object() ) ) ){
M_desc["locus"] = "Nowhere";
M_desc["vision"] = "You are nowhere.";
}
if( o_env->GetMount() || base_name( o_env ) == LIB_CORPSE ){
o_env = environment( environment( this_player() ) );
if( !o_env ){
M_desc["locus"] = "???";
M_desc["vision"] += "%^BOLD%^%^RED%^You are in serious trouble!" + X + "  Ask an admin for help.";
i_flag = 1;
}
i_vision = this_object()->GetEffectiveVision( o_env );
}else{
i_vision =  this_object()->GetEffectiveVision();
}
if( i_flag == 1 ){ M_desc["vision"] += "  "; } i_flag = 0;

/*===== sensory deprivation & overload =====*/
switch( i_vision ){
case VISION_BLIND:      M_desc["vision"] += "You are blind and can see nothing."; i_flag = 1; break;
case VISION_TOO_DARK:   M_desc["vision"] += "It is much too dark to see."; i_flag = 1; break;
case VISION_DARK:       M_desc["vision"] += "It is too dark to see."; i_flag = 1; break;
case VISION_BRIGHT:     M_desc["vision"] += "It is too %^YELLOW%^bright" + X + " to see."; i_flag = 1; break;
case VISION_TOO_BRIGHT: M_desc["vision"] += "It is much too %^BOLD%^bright" + X + " to see."; i_flag = 1; break;
}

/*===== short description, exits, map, basic sense descriptions =====*/
i_var = sizeof( o_env->GetExits() );
i_countmax = sizeof( o_env->GetEnters() );
for( i_count = 0; i_count < i_countmax; i_count++ ){
if( o_env->GetEnters()[i_count][0..13] == "lib*std*dummy*" ){ i_var++; }
}
if( !brief ){
if( i_vision == VISION_CLEAR ){
s_temp = o_env->GetObviousExits() || "";
if( s_temp != "" ){
M_desc["locus"] = capitalize( o_env->GetShort() || "somewhere" ) + "  [" + s_temp + "]";
}else{
M_desc["locus"] = capitalize( o_env->GetShort() || "somewhere" );
}
if( o_env->GetObviousVisible() ){
if( !NM_STYLE_EXITS ){
M_desc["locus"] = capitalize( o_env->GetShort() || "somewhere" );
if( s_style == "verbose" ){
M_desc["exits"] = i_var > 0 ?
"There " + ( i_var > 1 ? "are" : "is" ) + " the following way$Q to leave this place:  " +
s_temp + "." :
"There is apparently no exit from here.";
}else{
M_desc["exits"] = s_temp != "" ? "Obvious exit$Q:  " + s_temp : "";
}
}
}else{
M_desc["exits"] = "";
}
}else{
M_desc["locus"] = "Somewhere";
}
if( i_vision == VISION_CLEAR || i_vision == VISION_LIGHT || i_vision == VISION_DIM ){
//----- generate map
#if MINIMAP
if( this_object()->GetProperty( "minimapping" ) ){
i_mapstyle = 1;
sa_map = explode( simple_map( o_env ), "\n" );
if( sizeof( sa_map ) == 0 || o_env->GetMapUse() == 0 ){
M_desc["map"] = ""; i_mapstyle = 0;
}else if( sizeof( sa_map ) > 1 ){
if( i_bor == 1 ){
M_desc["map"]  = sa_map[1][1..7] + "\n";
M_desc["map"] += sa_map[2][1..7] + "\n";
M_desc["map"] += sa_map[3][1..7] + "\n";
M_desc["map"] += sa_map[4][1..7] + "\n";
M_desc["map"] += sa_map[5][1..7];
}else{
M_desc["map"] = implode( sa_map, "\n" );
}
}
}
#endif
#if (WIZMAP && GRID)
if( MASTER_D->GetPerfOK() && this_object()->GetProperty( "wizmapping" ) ){
i_mapstyle = 2;
sa_map = explode( MAP_D->GetMap( environment( this_object() ), 7 ), "\n" );
if( sa_map[0] == "%^RED%^Map unavailable." + X || o_env->GetObviousExits() == "" ){
M_desc["map"] = ""; i_mapstyle = 0;
}else if( sizeof( sa_map ) > 1 ){
M_desc["map"] = "";
i_countmax = sizeof( sa_map );
for( i_count = 0; i_count < i_countmax; i_count++ ){
M_desc["map"] += sa_map[i_count];
if( i_count < i_countmax - 1 ){ M_desc["map"] += "\n"; }
}
}
}
#endif
//*****
if( sizeof( M_desc["vision"] ) == 0 ){
M_desc["vision"] = o_env->GetLong();
}else{
M_desc["vision"] += o_env->GetLong();
}
}
if( functionp( tmp = o_env->GetSmell(  "default" ) ) ){ tmp = ( *tmp )( "default" ); }
M_desc2["smell"] = tmp;
if( functionp( tmp = o_env->GetListen( "default" ) ) ){ tmp = ( *tmp )( "default" ); }
M_desc2["sound"] = tmp;
if( functionp( tmp = o_env->GetTouch(  "default" ) ) ){ tmp = evaluate( tmp, "default" ); }
M_desc2["touch"] = tmp;
}else{
if( i_vision == VISION_CLEAR || i_vision == VISION_LIGHT || i_vision == VISION_DIM ){
M_desc["locus"] = o_env->GetShort() ? o_env->GetShort() : "Somewhere";
s_temp = o_env->GetObviousExits() || "";
if( this_object()->GetProperty( "minimapping" ) ){
M_desc["map"] = simple_map( o_env )+"\n";
}
if( o_env->GetObviousVisible() ){
if( NM_STYLE_EXITS ){
if( s_temp != "" ){ M_desc["locus"] += "  [" + s_temp + "]"; }
}else{
if( s_style == "verbose" ){
M_desc["exits"] = i_var > 0 ?
"There " + ( i_var > 1 ? "are" : "is" ) + " the following exit$Q:  " + s_temp + "." :
"There is apparently no exit from here.";
}else{
M_desc["exits"] = s_temp != "" ? "Obvious exit$Q:  " + s_temp : "";
}
}
}else{
M_desc["exits"] = "";
}
}else{
if( sizeof( M_desc["vision"] ) == 0 ){ M_desc["vision"] = o_env->GetLong(); }
else{ M_desc["vision"] += o_env->GetLong(); }
}
if( functionp( tmp = o_env->GetSmell(  "default" ) ) ){ tmp = ( *tmp )( "default" ); }
M_desc2["smell"] = tmp;
if( functionp( tmp = o_env->GetListen( "default" ) ) ){ tmp = ( *tmp )( "default" ); }
M_desc2["sound"] = tmp;
if( functionp( tmp = o_env->GetTouch(  "default" ) ) ){ tmp = evaluate( tmp, "default" ); }
M_desc2["touch"] = tmp;
}
if( o_env->GetMapUse() == 0 ){ i_mapstyle = 0; }
if( sizeof( M_desc["exits"] ) ){
M_desc["exits"] = replace_string( M_desc["exits"], "$Q", i_var > 1 ? "s" : "" );
}
/*===== generate list of inanimate objects if visible =====*/
if( i_vision == VISION_CLEAR ){
// non-doors
sa_shorts = map( filter( all_inventory( o_env ), function( object o_ob ){
if( living( o_ob ) ){ return 0; }
if( o_ob->GetInvis( this_object() ) && !o_ob->GetDoor() ){ return 0; }
if( o_ob->GetDoor() && load_object( o_ob->GetDoor() )->GetHiddenDoor() ){ return 0; }
if( o_ob->isFreshCorpse() ){ return 0; }
return 1;
}), (:
function_exists( "CanOpen", $1 ) != 0 && base_name( $1 )->CanOpen() == 1 ?
( $1->GetOpen() == 1 ? "an open " : "a closed " ) + remove_article( $1->GetShort() ) :
$1->GetShort()
:) );
s_temp = "";
foreach( s_temp in sa_shorts ){ if( s_temp ){ M_pos["lying"][s_temp]++; } }
sa_shorts = ({});
foreach( s_key in keys( M_pos["lying"] ) ){
sa_shorts += ({ consolidate( M_pos["lying"][s_key], s_key ) });
i_items += M_pos["lying"][s_key];
}
M_desc["contents"] = capitalize( item_list( sa_shorts ) );
if( sizeof( sa_shorts ) > 0 ){
M_desc["contents"] += ( sizeof( keys( M_pos["lying"] ) ) == 1 && i_items == 1 ? " is" : " are" ) + " here.";
i_flag = 1;
}
// doors & door-like items
M_pos["doors"] = ([ ]);
foreach( o_ob in all_inventory( o_env ) ){
if(
o_ob->GetDoor() &&
load_object( o_ob->GetDoor() )->GetHiddenDoor() &&
load_object( o_ob->GetDoor() )->GetOpacity() > 33
){
s_temp = (
load_object( o_ob->GetDoor( o_ob->GetDoorSide() ) )->GetClosed() == 0
? "an open " : "a closed "
) +
remove_article( environment( this_player() )->GetDoor( o_ob->GetDoorSide() )->GetShort() );
if( !M_pos["doors"][s_temp] ){ M_pos["doors"][s_temp] = ({}); }
M_pos["doors"][s_temp] += ({ o_ob->GetDoorSide() });
}
}
s_temp = "";
sa_shorts = ({});
foreach( s_key in keys( M_pos["doors"] ) ){
if( sizeof( M_pos["doors"][s_key] ) == 1 ){
sa_shorts += ({ s_key + ( s_key[0..3] == "an o" ? " leads " : " bars the way " ) +
item_list( M_pos["doors"][s_key] ) });
}else{
sa_shorts += ({ pluralize( remove_article( s_key ) ) + ( M_pos["doors"][s_key[0..3]] == "an o" ?
" lead " : " bar the way " ) + item_list( M_pos["doors"][s_key] ) });
}
}
M_desc["vision"] += capitalize( item_list( sa_shorts ) ) + ( sizeof( keys( M_pos["doors"] ) ) > 0 ? ".  " : "" );
map_delete( M_pos, "doors" );
}
/*===== generate list of nonmount animate objects in different positions if vision is dim to light =====*/
s_key = 0;
i_vision = this_object()->GetEffectiveVision( o_env );
if( i_vision == VISION_CLEAR || i_vision == VISION_LIGHT || i_vision == VISION_DIM ){
M_pos["floating"] = ([ ]);
M_pos["flying"] = ([ ]);
M_pos["kneeling"] = ([ ]);
M_pos["lying"] = ([ ]);
M_pos["sitting"] = ([ ]);
M_pos["standing"] = ([ ]);
M_pos["swimming"] = ([ ]);
i_pos = 0;
if( this_player() ){ o_mount = this_player()->GetProperty( "mount" ); }
oa_obs = filter( all_inventory( o_env ), function( object o_ob ){
if( o_ob->GetInvis( this_object() ) && !this_object()->GetWizVision() ){ return 0; }
if( living( o_ob ) ){ return 1; }
if( o_ob->isFreshCorpse() )
return 1;
} ) - ({ this_object(), o_mount });
maxi = sizeof(
sa_shorts = map( oa_obs, (: ( $1->GetInvis() ? "(invisible) " : "" ) + $1->GetHealthShort() :) )
);
foreach( o_ob in oa_obs ){
i_envtype = environment( o_ob )->GetMedium();
s_temp = o_ob->GetHealthShort();
i_pos = o_ob->GetPosition();
if( !s_temp ){ continue; }
if( o_ob->GetInvis() && this_object()->GetWizVision() ){ s_temp = "(invis) " + s_temp; }
if( o_ob->GetProperty( "furniture" ) ){ s_temp += "BEGIN" + random( 999999 ) + "END"; }
if( o_ob->GetProperty( "furniture" ) ){
M_pos["furniture"][s_temp] = o_ob->GetProperty( "furniture" );
}else if( !M_pos["furniture"][s_temp] ) M_pos["furniture"][s_temp] = 0;

switch( i_pos ){
case POSITION_STANDING: M_pos["standing"][s_temp]++; break;
case POSITION_LYING:    M_pos["lying"][s_temp]++; break;
case POSITION_SITTING:  M_pos["sitting"][s_temp]++; break;
case POSITION_FLYING:   M_pos["flying"][s_temp]++; break;
case POSITION_FLOATING: M_pos["floating"][s_temp]++; break;
case POSITION_SWIMMING: M_pos["swimming"][s_temp]++; break;
case POSITION_KNEELING: M_pos["kneeling"][s_temp]++; break;
case POSITION_NULL:     M_pos["null"][s_temp]++; break;
default:
if( o_ob->isFreshCorpse() && i_envtype != MEDIUM_LAND ){
M_pos["floating"][s_temp]++;
}else{
M_pos["lying"][s_temp]++;
}
break;
}
}
tmp = "";
s_temp = s_style == "verbose" ? "  " : "\n";
foreach( s_key, i_var2 in M_pos["lying"] ){
globaltmp = s_key;
if( grepp( s_key, "BEGIN" ) ){ sscanf( s_key, "%sBEGIN%*s", s_key ); }
if( i_flag == 1 ){ tmp += s_temp; i_flag = 0; }
if( M_pos["lying"][globaltmp] > 1 && !M_pos["furniture"][globaltmp] ){
tmp += capitalize( consolidate( i_var2, globaltmp ) ) + X + " are lying down."; i_flag = 1;
}else if( M_pos["lying"][globaltmp] < 2 && !M_pos["furniture"][globaltmp] ){
tmp += capitalize( s_key ) + X + " is lying down.";
i_flag = 1;
}else if( M_pos["furniture"][globaltmp] ){
tmp += capitalize( s_key ) + X + " is lying down" + ( ( M_pos["furniture"][globaltmp] ) ?
M_pos["furniture"][globaltmp] : "" ) + ".";
i_flag = 1;
}else if( M_pos["furniture"][s_key] ){
tmp += capitalize( s_key ) + X + " is lying down" + ( ( M_pos["furniture"][s_key]) ?
M_pos["furniture"][s_key] : "" ) + ".";
i_flag = 1;
}else{
tmp += "WtF?  I am " + s_key + ", furniture[" + globaltmp + "] is:  " +
M_pos["furniture"][globaltmp] + "\n" +
"  furniture[" + s_key + "] is:  " + M_pos["furniture"][s_key] + ", and i_var2 is: " + i_var2;
i_flag = 1;
}
}
foreach( s_key, i_var2 in M_pos["sitting"] ){
globaltmp = s_key;
if( grepp( s_key, "BEGIN" ) ){ sscanf( s_key, "%sBEGIN%*s", s_key ); }
if( i_flag == 1 ){ tmp += s_temp; i_flag = 0; }
if( M_pos["sitting"][globaltmp] > 1 && !M_pos["furniture"][globaltmp] ){
tmp += capitalize( consolidate( i_var2, globaltmp ) ) + X + " are sitting down.";
}else if( M_pos["sitting"][globaltmp] < 2 && !M_pos["furniture"][globaltmp] ){
tmp += capitalize( s_key ) + X + " is sitting down.";
i_flag = 1;
}else if( M_pos["furniture"][globaltmp] ){
tmp += capitalize( s_key ) + X + " is sitting down" + ( ( M_pos["furniture"][globaltmp] ) ?
M_pos["furniture"][globaltmp] : "" ) + ".";
i_flag = 1;
}else if( M_pos["furniture"][s_key] ){
tmp += capitalize( s_key ) + X + " is sitting down" + ( ( M_pos["furniture"][s_key] ) ?
M_pos["furniture"][s_key] : "" ) + ".";
i_flag = 1;
}else{
tmp += "WtF?  I am " + s_key + ", furniture[" + globaltmp + "] is:  " +
M_pos["furniture"][globaltmp] + "\n" +
"  furniture[" + s_key + "] is:  " + M_pos["furniture"][s_key] + ", and i_var2 is:  " + i_var2;
i_flag = 1;
}
}
foreach( s_pos in keys( M_pos ) ){
if( member_array( s_pos, ({ "standing", "flying", "floating", "swimming", "kneeling", "null" }) ) > -1 ){
foreach( s_key, i_var2 in M_pos[s_pos] ){
if( s_pos == "standing" ){
if( grepp( s_key, "BEGIN" ) ){ sscanf( s_key, "%sBEGIN%*s", s_key ); }
}
if( i_flag == 1 ){ tmp += s_temp; i_flag = 0; }
s_temp2 = s_pos == "null" ? "" : s_pos + " ";
if( i_var2 < 2 ){
tmp += capitalize( s_key ) + X + " is " + s_temp2 + "here.";
}else{
tmp += capitalize( consolidate( i_var2, s_key ) ) + X + " are " + s_temp2 + "here.";
}
i_flag = 1;
}
}
}
}
if( sizeof( tmp ) > 0 ){
if( sizeof( M_desc["contents"] ) == 0 ){
M_desc["contents"] = tmp;
}else{
M_desc["contents"] += tmp;
}
}
/*===== player is riding something =====*/
if( this_player() && o_transport = this_player()->GetProperty( "mount" ) ){
s_mount_inv = "Nothing";
oa_mountinv = filter( all_inventory( o_transport ), (:
( ( ( $1->GetInvis() ) && this_object()->GetWizVision() ) ||
!( $1->GetInvis() ) ) && !( $1 == this_player() )
:) );
if( sizeof( oa_mountinv ) ){
foreach( o_element in oa_mountinv ){
s_invis = ( o_element->GetInvis() ? "(invisible) " : "" );
sa_mount_inv += ({ s_invis + o_element->GetShort() });
}
s_mount_inv = conjunction( sa_mount_inv );
}
if( !sizeof( M_desc["contents"] ) ){ M_desc["contents"] = ""; }
if( inherits( LIB_CHAMBER, o_transport ) ){
s_temp = o_transport->GetVehicleInterior();
if( !s_temp || !sizeof( s_temp ) ){
if( i_flag == 1 ){ M_desc["contents"] += s_style == "verbose" ? "  " : "\n"; i_flag = 0; }
M_desc["contents"] += "You are in " + o_transport->GetPlainShort() + "."; i_flag = 1;
}else{
if( i_flag == 1 ){ M_desc["contents"] += s_style == "verbose" ? "  " : "\n"; i_flag = 0; }
M_desc["contents"] += s_temp; i_flag = 1;
if( i_flag == 1 ){ M_desc["contents"] += s_style == "verbose" ? "  " : "\n"; i_flag = 0; }
M_desc["contents"] += "Here you see:  " + s_mount_inv+"."; i_flag = 1;
}
}else if( inherits( LIB_VEHICLE, o_transport ) ){
s_temp = o_transport->GetVehicleInterior();
if( !s_temp || !sizeof( s_temp ) ){
if( i_flag == 1 ){ M_desc["contents"] += s_style == "verbose" ? "  " : "\n"; i_flag = 0; }
M_desc["contents"] += "You are riding in " + o_transport->GetPlainShort() + "."; i_flag = 1;
}else{
if( i_flag == 1 ){ M_desc["contents"] += s_style == "verbose" ? "  " : "\n"; i_flag = 0; }
M_desc["contents"] += s_temp; i_flag = 1;
}
if( i_flag == 1 ){ M_desc["contents"] += s_style == "verbose" ? "  " : "\n"; i_flag = 0; }
M_desc["contents"] += "Here you see:  " + s_mount_inv + "."; i_flag = 1;
}else{
if( i_flag == 1 ){ M_desc["contents"] += s_style == "verbose" ? "  " : "\n"; i_flag = 0; }
M_desc["contents"] += "You are riding on " + o_transport->GetPlainShort() + "."; i_flag = 1;
if( i_flag == 1 ){ M_desc["contents"] += s_style == "verbose" ? "  " : "\n"; i_flag = 0; }
M_desc["contents"] += "On " + o_transport->GetPlainShort() + " you see:  " + s_mount_inv + "."; i_flag = 1;
}
}
M_mapOEMreplace = ([
"*" : "%^RED%^\xDB%^RESET%^",
"+" : "\xF9",
"|" : M_box["v"],
"-" : M_box["h"],
"#" : "\xB1",
"o" : "%^GREEN%^\xB0%^RESET%^",
"$" : "\xB0",
]);
switch( s_style ){
case "verbose":
M_desc2["raw"]  = M_desc["vision"] + ( M_desc["vision"][<2..] == "  " ? "" : "  " );
M_desc2["raw"] += "%^CYAN%^" + GetDistantInput() + X;
M_desc2["raw"] += M_desc2["sound"] ?
( sizeof( GetDistantInput() ) > 2 && GetDistantInput()[<2..] == "  " ? "" :
( sizeof( GetDistantInput() ) ? "  " : "" ) ) + M_desc2["sound"] : "";
M_desc2["raw"] += M_desc2["smell"] ?
( sizeof( M_desc2["sound"]   ) > 2 && M_desc2["sound"][<2..]   == "  " ? "" : "  " ) +
M_desc2["smell"] : "";
M_desc2["raw"] += M_desc2["touch"] ?
( sizeof( M_desc2["smell"]   ) > 2 && M_desc2["smell"][<2..]   == "  " ? "" : "  " ) +
M_desc2["touch"] : "";
M_desc2["raw"] += sizeof( M_desc["contents"] ) ? "\n\n" + M_desc["contents"] : "";
M_desc2["raw"] += sizeof( M_desc["exits"] ) && BARE_EXITS == 0 ? "\n\n" + M_desc["exits"] : "";
break;
default:
M_desc2["raw"]  = M_desc["vision"];
M_desc2["raw"] += M_desc2["smell"] ? "\n%^GREEN%^" + M_desc2["smell"] + X : "";
M_desc2["raw"] += M_desc2["sound"] ? "\n%^CYAN%^" + M_desc2["sound"] + X : "";
M_desc2["raw"] += M_desc2["touch"] ? "\n%^YELLOW%^" + M_desc2["touch"] + X : "";
M_desc2["raw"] += GetDistantInput() ? "\n%^CYAN%^" + GetDistantInput() + X : "";
M_desc2["raw"] += ( sizeof( M_desc["exits"] ) > 0 && BARE_EXITS == 0 ) ? "\n" + M_desc["exits"] : "";
M_desc2["raw"] += ( sizeof( M_desc["contents"] ) > 0 ) ? "\n%^MAGENTA%^" + M_desc["contents"] + X : "";
break;
}
/*===== generate the output =====*/
switch( i_bor ){
case 1:{
i_var = i_mapstyle == 1 ? 7 : i_mapstyle == 2 ? 17 : 0;
M_desc2["desc"] = "%^BOLD%^%^CYAN%^%^B_BLUE%^ " + M_desc["locus"] + " " + X + "\n";
M_desc2["desc"] += border + M_box["c2"];
if( s_mapside == "right" ){
M_desc2["desc"] += repeat_string( M_box["h"], i_screenX - 3 - i_var );
M_desc2["desc"] += i_mapstyle > 0 ? M_box["tt"] : M_box["h"];
M_desc2["desc"] += repeat_string( M_box["h"], i_var );
}else{
M_desc2["desc"] += repeat_string( M_box["h"], i_var );
M_desc2["desc"] += i_mapstyle > 0 ? M_box["tt"] : M_box["h"];
M_desc2["desc"] += repeat_string( M_box["h"], i_screenX - 3 - i_var );
}
M_desc2["desc"] += M_box["c1"] + X + "\n";
s_temp2 = "";
if( i_mapstyle > 0 ){
sa_textblock = TERMINAL_D->WrapText( M_desc2["raw"], i_screenX - 5 - i_var );
i_linesmap = i_mapstyle == 1 ? 5 : sizeof( explode( M_desc["map"], "\n" ) );
}else{
sa_textblock = TERMINAL_D->WrapText( M_desc2["raw"], i_screenX - 4 - i_var );
}
//write( M_desc["map"] );
if( s_enc == "OEM" ){
M_desc2["map"] = M_desc["map"];
foreach( string s_char in keys( M_mapOEMreplace ) ){
M_desc2["map"] = replace_string( M_desc2["map"], s_char, M_mapOEMreplace[s_char] );
}
}else{
M_desc2["map"] = replace_string( M_desc["map"], "*", "%^RED%^*%^RESET%^" );
}
i_linesdesc = sizeof( sa_textblock );  // total lines in initial wrapped description
for( i_count = 0, i_countmax = i_linesmap > 0 ? i_linesmap : i_linesdesc; i_count < i_countmax; i_count++ ){
s_temp2 += border + M_box["v"] + X;
// add map line to left if turned on and set to left
if( s_mapside == "left" && i_mapstyle > 0 ){
s_temp2 += explode( M_desc2["map"], "\n" )[i_count];
s_temp2 += border + M_box["v"] + X;
}
// if there are more lines in the description than the map, add the line of text
if( i_linesdesc > i_count ){
s_temp2 += sprintf( " %s ", sa_textblock[i_count] );
}else{
// ...otherwise add a line of spaces
s_temp2 += " " + repeat_string( " ", i_screenX - 4 - i_var );
}
// add map line to right if turned on and set to right
if( s_mapside == "right" && i_mapstyle > 0 ){
s_temp2 += border + M_box["v"] + X;
s_temp2 += explode( M_desc2["map"], "\n" )[i_count];
}
// if the description has fewer lines than map add intersection with bottom border
if( i_linesdesc <= i_countmax ){ i_flag = 1; }else{ i_flag = 0; }
s_temp2 += border + M_box["v"] + X;
// add newline
s_temp2 += "\n";
}
//----- bottom border of map if there's a line of text there
if( i_mapstyle > 0 && i_linesdesc > i_countmax ){
s_temp2 += border;
if( s_mapside == "right" ){  // map is to the right, add vert. bar and text, then map bottom border
s_temp2 += M_box["v"] + X + " " + sa_textblock[i_count] + " " + border + M_box["c3"];
s_temp2 += repeat_string( M_box["h"], i_var ) + M_box["tr"];
}else{                       // map is to the left, add map bottom border, text and vert bar
s_temp2 += M_box["tl"] + repeat_string( M_box["h"], i_var ) + M_box["c3"] + X;
s_temp2 += " " + sa_textblock[i_count] + " " + border + M_box["v"];
}
s_temp2 += X + "\n";
}
//----- done with map, onto post-map text (rewrap lines from textblock)
if( i_linesdesc > i_countmax && i_mapstyle > 0 ){
sa_textblock = TERMINAL_D->WrapText( implode( sa_textblock[i_countmax + 1..], "\n" ), i_screenX - 4 );
foreach( s_line in sa_textblock ){
s_temp2 += border + M_box["v"] + X;
s_temp2 += " " + s_line + " ";
s_temp2 += border + M_box["v"] + X;
s_temp2 += "\n";
}
}
//----- done with post-map text, add it to the description
M_desc2["desc"] += s_temp2;
i_var = i_mapstyle == 1 ? 7 : i_mapstyle == 2 ? 17 : 0;
M_desc2["desc"] += border + M_box["c4"];
M_desc2["desc"] += repeat_string( M_box["h"], s_mapside == "right" ? i_screenX - 3 - i_var : i_var );
M_desc2["desc"] += ( i_mapstyle > 0 && i_flag == 1 ) ? M_box["tb"] : M_box["h"];
M_desc2["desc"] += repeat_string( M_box["h"], s_mapside != "right" ? i_screenX - 3 - i_var : i_var );
M_desc2["desc"] += M_box["c3"] + X + "\n";
break;}
default:{
M_desc2["desc"] = "\n%^B_BLUE%^%^BOLD%^%^CYAN%^ " + M_desc["locus"] + " " + X;
if( sizeof( M_desc2["map"] ) > 0 ){ M_desc2["desc"] += "\n" + M_desc2["map"]; }
M_desc2["desc"] += "\n" + M_desc2["raw"];
break;}
}
if( sizeof( M_desc2["desc"] ) ){
if( check_string_length( M_desc2["desc"] ) ){ this_object()->eventPrint( M_desc2["desc"], MSG_ROOMDESC ); }
else{ print_long_string( this_player(), M_desc2["desc"] ); }
}
}

string GetDistantInput(){
float *fa_locus;
object o_env;
string s_world, s_town, s_landmarks = "", s_dir, s_item, s_enter;
string *sa_Dirs = ({}), *sa_UDO = ({}), *sa_udo = ({}), *sa_Enters = ({}), *sa_enters = ({});
string *sa_senses, s_sense, *sa_desckeys, *sa_landmarknames, *sa_newitems;
mapping M_SenseDirs = ([ ]), M_SenseDesc = ([ ]), M_landmarks = ([ ]);

o_env = environment( this_player() );
if( !o_env ){ return "You have no environment.  You should file a bugreport about this!"; }
fa_locus = ({
to_float( o_env->GetProperty( "latitude" ) ),
to_float( o_env->GetProperty( "longitude" ) ),
to_float( o_env->GetProperty( "altitude" ) )
});

sa_senses = ({ "vision", "smell", "sound", "touch", "taste" });
sa_Dirs = ({ "north", "northeast", "east", "southeast", "south", "southwest", "west", "northwest" });
sa_UDO = ({ "up", "down", "out" });
foreach( s_dir in o_env->GetEnters() ){ if( sizeof( s_dir ) > 13 && s_dir[0..13] == "lib*std*dummy*" ){
sa_Enters += ({ remove_article( find_object( "/lib/std/dummy#" + s_dir[14..] )->GetKeyName() ) });
} }
sa_Dirs += sa_UDO + sa_Enters;

s_world = o_env->GetWorld() ? o_env->GetWorld() : "World";
s_town = o_env->GetTown() ? o_env->GetTown() : "wilderness";
M_landmarks = LANDMARKS_D->GetLandmarkPositions( s_world, s_town, fa_locus );
sa_landmarknames = keys( M_landmarks );
sa_newitems = sa_landmarknames - o_env->GetDummyItems();
foreach( s_item in sa_newitems ){
M_SenseDesc = M_landmarks[s_item];
sa_desckeys = keys( M_SenseDesc );
if( !undefinedp( M_SenseDesc["vision"] ) ){ o_env->AddItem(   s_item, M_SenseDesc["vision"] ); }
if( !undefinedp( M_SenseDesc["smell"]  ) ){ o_env->AddSmell(  s_item, M_SenseDesc["smell"] ); }
if( !undefinedp( M_SenseDesc["sound"]  ) ){ o_env->AddListen( s_item, M_SenseDesc["sound"] ); }
if( !undefinedp( M_SenseDesc["touch"]  ) ){ o_env->AddTouch(  s_item, M_SenseDesc["touch"] ); }
}

{M_SenseDirs = ([
"vision" : ([  // "It is...over there."
"black as pitch"  : ({ }), "too dark to see" : ({ }), "dark"      : ({ }), "dim"               : ({ }),
"clear"           : ({ }), "light"           : ({ }), "bright"    : ({ }), "too bright to see" : ({ })
]),
"sound" : ([  // "It is...over there."
"eerily silent"   : ({ }), "too quiet"     : ({ }), "quiet"     : ({ }), "somewhat quiet"  : ({ }),
"a bit noisy"     : ({ }), "loud"          : ({ }), "very loud" : ({ }), "painfully loud"  : ({ })
]),
"smell" : ([  // "There is...over there."
"no smell"        : ({ }), "a faint scent" : ({ }), "a scent"   : ({ }), "a faint aroma"   : ({ }),
"an aroma"        : ({ }), "a pungence"    : ({ }), "a stench"  : ({ }), "a noxious odor"  : ({ })
]),
"taste" : ([  // "There is...taste over there." (?)
"flavorless"      : ({ }), "bland"         : ({ }), "weak"      : ({ }), "subtly-flavored" : ({ }),
"flavorful"       : ({ }), "rich"          : ({ }), "bold"      : ({ }), "nauseating"      : ({ })
]),
"touch" : ([  // "It feels...over there." (?)
"insubstantial"   : ({ }), "frictionless"  : ({ }), "smooth"    : ({ }), "soft"            : ({ }),
"rough"           : ({ }), "bumpy"         : ({ }), "coarse"    : ({ }), "abrasive"        : ({ })
])
]);}

if( !( o_env->GetTerrainType() & T_INDOORS ) ){
s_landmarks += LANDMARKS_D->GetLandmarkList( M_landmarks );
}

foreach( s_dir in sa_Dirs ){
if(
( o_env->GetExit( s_dir )  || o_env->GetEnter( s_dir ) ) &&
( !o_env->GetDoor( s_dir ) || ( o_env->GetDoor( s_dir ) && ( o_env->GetDoor( s_dir ) )->CanPeer() ) )
){
switch( this_player()->GetEffectiveVision( o_env->GetExit( s_dir ) ) ){
case VISION_BLIND:      M_SenseDirs["vision"]["blind"]             += ({ s_dir }); break;
case VISION_TOO_DARK:   M_SenseDirs["vision"]["too dark to see"]   += ({ s_dir }); break;
case VISION_DARK:       M_SenseDirs["vision"]["dark"]              += ({ s_dir }); break;
case VISION_DIM:        M_SenseDirs["vision"]["dim"]               += ({ s_dir }); break;
case VISION_LIGHT:      M_SenseDirs["vision"]["light"]             += ({ s_dir }); break;
case VISION_BRIGHT:     M_SenseDirs["vision"]["bright"]            += ({ s_dir }); break;
case VISION_TOO_BRIGHT: M_SenseDirs["vision"]["too bright to see"] += ({ s_dir }); break;
default:                break;//M_SenseDirs["vision"]["clear"]      += ({ s_dir }); break;
}
}
}
foreach( string s_level in keys( M_SenseDirs["vision"] ) ){
if( sizeof( M_SenseDirs["vision"][s_level] ) ){
//write( s_level + " : " + item_list( M_SenseDirs["vision"][s_level] ) );
sa_udo = ({}); sa_enters = ({});
if( member_array( "up",   M_SenseDirs["vision"][s_level] ) > -1 ){ sa_udo += ({ "above"   }); }
if( member_array( "down", M_SenseDirs["vision"][s_level] ) > -1 ){ sa_udo += ({ "below"   }); }
if( member_array( "out",  M_SenseDirs["vision"][s_level] ) > -1 ){ sa_udo += ({ "outside" }); }
foreach( s_enter in sa_Enters ){ if( member_array( s_enter, M_SenseDirs["vision"][s_level] ) > -1 ){
sa_enters += ({ "the " + s_enter });
} }
if( sizeof( s_landmarks ) ){ s_landmarks += "  "; }
//write( "sa_enters = " + item_list( sa_enters ) );
s_landmarks += "It is " + s_level + (
sizeof( M_SenseDirs["vision"][s_level] - sa_UDO - sa_Enters ) ? " to the " +
item_list( M_SenseDirs["vision"][s_level] - sa_UDO - sa_Enters ) + " of here" +
( sizeof( sa_udo + sa_enters ) ? ", and" : "" ) : "" ) +
( sizeof( sa_udo ) ? " " + item_list( sa_udo ) + " here" : "" ) +
( sizeof( sa_enters ) ? " inside " + item_list( sa_enters ) : "" ) + ".";
}
}

return s_landmarks;
//return LANDMARKS_D->GetLandmarkList( ([ "star" : ([ "azimuth" : 45, "altitude" : 56, "distance" : 10 ]) ]) );
}
/* EOF */

And these are the files which were modified to appease the deities:
/lib/std/room.c
[code]/*    /lib/obj/room.c
 *    From the Dead Souls LPC Library
 *    The room object used to represent any room in the game
 *    Created by Descartes of Borg 940711
 *    Version: @(#) room.c 1.20@(#)
 *    Last Modified: 050912
 *    2011-Oct-09 T. Cook corrected GenerateObviousExits() output for enter-only room handling
 *    2011-Nov-29 T. Cook added SetWorld(), GetWorld()
 *    2012-May-24 T. Cook added GetObviousVisible(), GetMapUse(), SetMapUse()
 */

#ifndef NM_STYLE_EXITS
#define NM_STYLE_EXITS 1
#endif

#include <lib.h>
#include ROOMS_H
#include <daemons.h>
#include <function.h>
#include <medium.h>
#include <message_class.h>
#include <talk_type.h>
#include <terrain_types.h>
#include <respiration_types.h>
#include <medium.h>
#include <privs.h>

inherit LIB_SHADOW_HOOK;
inherit LIB_CLEAN;
inherit LIB_CONTAINER;
inherit LIB_EXITS;
inherit LIB_DESCRIPTION;
inherit LIB_INVENTORY;
inherit LIB_LOOK;
inherit LIB_PROPERTIES;
inherit LIB_AMBIANCE;
inherit LIB_READ;
inherit LIB_MONEY;

private function        Bury          = 0;
private string          Climate       = "temperate";
private int             DayLight      = -1970;
private int             counter       = 0;
private static string   DayLong       = 0;
private object array    DummyItems    = ({});
private static int      GasCheck      = time();
private float           Gravity       = 1.0;
private static mixed    Listen        = 0;
private int             NightLight    = -1970;
private static string   NightLong     = 0;
private static int      NoReplace     = 0;
private static int      PlayerKill    = 0;
private static int      PoisonGas     = 0;
private static int      ResetNumber   = 0;
private static mixed    Search        = 0;
private static int      Shade         = 0;
private static mixed    Smell         = 0;
private static mixed    Touch         = 0;
private string          Town          = "wilderness";
private string          World         = "World";
private int      DefaultExits  = 1;
private int      Flying        = 1;
private int      Sitting       = 0;
private int      Kneeling      = 0;
private int      Standing      = 0;
private int      Swimming      = 0;
private int      UseMap        = 1;
private int      ObviousVisible       = 1;
private int      ActionChance  = 10;
mapping         ItemsMap      = ([]);
private static mixed    global_item;
private static mixed   Action;
private int      tick_resolution   = 5;
private int      TerrainType   = T_OUTDOORS;
private int      RespirationType;
private int      Medium     = MEDIUM_LAND;
private mapping         ActionsMap      = ([]);
private string          SinkRoom        = "";
private string          FlyRoom         = "";
private string          Elevator         = "";
private int             FlowLimit       = 0;
private int array       Coords          = ({});
private string array    Neighbors       = ({});
private mixed array     NeighborCoords  = ({});

string GetClimate();
int GetNightLight();
int GetDayLight();
int GetShade();
int GetMapUse();
int SetMapUse( int val );
int GetObviousVisible();
varargs mixed DestructEmptyVirtual(object ob);

mixed direct_delete_exit_str(){
    return 1;
}

mixed indirect_delete_exit_str(){
    return 1;
}

varargs int eventPrint(string msg, mixed arg2, mixed arg3);

/***********      /lib/room.c data manipulation functions      **********/

void CheckActions(){
    if(sizeof(ActionsMap)){
        foreach(mixed key, mixed val in ActionsMap){
            if( val > random(100) ){
                if(functionp(key)) evaluate(key);
                else eventPrint(key);
            }
        }
    }

    if( ActionChance > random(100) ){
        int x;

        if( functionp(Action) ) evaluate(Action);
        else if( pointerp(Action) && (x = sizeof(Action)) ){
            mixed act;

            act = Action[random(x)];
            if(functionp(act)){
                evaluate(act);
                return;
            }
            else eventPrint(act);
        }
    }
}

void heart_beat(){
    counter++;
    DestructEmptyVirtual();
    inventory::heart_beat();
    if(counter > 9999) counter = 0;
    CheckActions();
}

void SetAction(int chance, mixed val){
    ActionChance = chance;
    if( stringp(val) ) val = ({ val });
    else if( !functionp(val) && !pointerp(val) )
        error("Bad argument 2 to SetAction()\n");
    Action = val;
}

mixed GetAction(){ return Action; }

mapping SetActionsMap(mapping ActMap){
    if(ActMap && sizeof(ActMap)) ActionsMap = ActMap;
    return copy(ActionsMap);
}

mapping GetActionsMap(){
    return copy(ActionsMap);
}

int SetFrequency(int tick){
    if(tick) tick_resolution = tick;
    else tick_resolution = 5;
    set_heart_beat(0);
    return tick_resolution;
}

int GetFrequency(){
    return tick_resolution;
}

int GetTerrainType(){
    return TerrainType;
}

int SetTerrainType(int i){
    if(i) TerrainType = i;
    else return TerrainType;
}

int AddTerrainType(int i){
    if(!bitshiftedp(i)) return 0;
    else TerrainType = TerrainType | i;
    return TerrainType;
}

string *GetTerrainTypeName(){
   string *Terrains = ({ });
   if(GetTerrainType() & T_SPACE         ){ Terrains += ({ "space" }); }
   if(GetTerrainType() & T_PLASMA        ){ Terrains += ({ "plasma" }); }
   if(GetTerrainType() & T_MIDAIR        ){ Terrains += ({ "midair" }); }
   if(GetTerrainType() & T_OUTDOORS      ){ Terrains += ({ "outdoors" }); }
   if(GetTerrainType() & T_SEAFLOOR      ){ Terrains += ({ "seafloor" }); }
   if(GetTerrainType() & T_UNDERWATER    ){ Terrains += ({ "underwater" }); }
   if(GetTerrainType() & T_WATERSHALLOW  ){ Terrains += ({ "shallow water" }); }
   if(GetTerrainType() & T_SURFACE       ){ Terrains += ({ "sea" }); }
   if(GetTerrainType() & T_SAND          ){ Terrains += ({ "sand" }); }
   if(GetTerrainType() & T_ROAD          ){ Terrains += ({ "road" }); }
   if(GetTerrainType() & T_SWAMP         ){ Terrains += ({ "swamp" }); }
   if(GetTerrainType() & T_WOODS         ){ Terrains += ({ "woods" }); }
   if(GetTerrainType() & T_JUNGLE        ){ Terrains += ({ "jungle" }); }
   if(GetTerrainType() & T_ROUGH         ){ Terrains += ({ "rough" }); }
   if(GetTerrainType() & T_SNOW          ){ Terrains += ({ "snow" }); }
   if(GetTerrainType() & T_ICE           ){ Terrains += ({ "ice" }); }
   if(GetTerrainType() & T_INDOORS       ){ Terrains += ({ "indoors" }); }
   if(GetTerrainType() & T_INDOORSWINDOW ){ Terrains += ({ "windowed" }); }
   if(GetTerrainType() & T_BIOLOGICAL    ){ Terrains += ({ "biological" }); }
   if(GetTerrainType() & T_UNDERGROUND   ){ Terrains += ({ "underground" }); }
   if(GetTerrainType() & T_MAGMA         ){ Terrains += ({ "magma" }); }
   if(GetTerrainType() & T_PLANAR        ){ Terrains += ({ "another plane" }); }
   if(GetTerrainType() & T_CUSTOM        ){ Terrains += ({ "custom" }); }
   return Terrains;
}

int RemoveTerrainType(int i){
    if(!bitshiftedp(i)) return 0;
    else TerrainType = TerrainType ^ i;
    return TerrainType;
}

int GetAmbientLight(){
    int a, dayset, nightset;

    dayset = this_object()->GetDayLight();
    nightset = this_object()->GetNightLight();

    if(dayset == -1970 && nightset == -1970 ){
        a = ambiance::GetAmbientLight();
    }

    else if( query_night() && nightset != -1970 ){
        a = nightset;
    }
    else if(!query_night() && dayset != -1970){
        a = dayset;
    }
    else {
        a = ambiance::GetAmbientLight();
    }

    foreach(object ob in all_inventory()){
        a += ob->GetRadiantLight();
    }

    return a;
}

function GetBury(){
    return Bury;
}

function SetBury(function what){
    Bury = what;
}

static string GetExtraLong(){
    int i;
    string *l = ({}),*tmp;
    string ret;
    object array stuff;
    ret = "  ";
    tmp = ({});
    stuff=all_inventory(this_object());
    for(i=0; i<sizeof(stuff);i++){
        if(sizeof(tmp = ({ stuff->GetRoomAffectLong() })) ) l += tmp;
    }
    if( !sizeof(l) ) return 0;
    ret += implode(l, "  ");
    return ret;
}

string GetInternalDesc(){
    string ret, tmp;

    if( DayLong && !query_night() ){
        ret = DayLong;
    }
    else if( NightLong && query_night() ){
        ret = NightLong;
    }
    else {
        ret = container::GetInternalDesc();
    }
    if( !ret ){
        ret = "";
    }
    if( tmp = GetExtraLong() ){
        ret += GetExtraLong();
    }
    return ret;
}

int GetResetNumber(){
    return ResetNumber;
}

string array GetId(){ return ({}); }

string SetDayLong(string str){ return (DayLong = str); }

string GetDayLong(){ return DayLong; }

string SetNightLong(string str){ return (NightLong = str); }

string GetNightLong(){ return NightLong; }

string SetClimate(string str){
    if(str == "indoors" && TerrainType == T_OUTDOORS) TerrainType = T_INDOORS;
    return (Climate = str);
}

string GetClimate(){ return Climate; }

float SetGravity(float h){ return (Gravity = h); }

float GetGravity(){ return Gravity; }

int GetMapUse(){ return UseMap; }

int SetMapUse( int val ){ return ( UseMap = val ? 1 : 0 ); }

int GetDayLight(){
    return DayLight;
}

static int SetDayLight(int x){
    return (DayLight = x);
}

object array GetDummyItems(){
    DummyItems = ({});
    foreach(object item in all_inventory(this_object())){
        if(base_name(item) == LIB_DUMMY){
            DummyItems += ({ item });
        }
    }
    return DummyItems;
}

varargs void AddItem(mixed item, mixed val, mixed adjectives){
    object ob, same_dummy;
    object *dummies = filter(all_inventory(this_object()), (: base_name(LIB_DUMMY) :) );
    global_item = item;

    if( objectp(item) ){
        same_dummy = filter(all_inventory(),(: base_name($1) == base_name(global_item) :));
        if(sizeof(same_dummy) && base_name(item) != LIB_ELEVATOR_BUTTON){
            return;
        }
        ob = item;
    }
    else {
        if( stringp(item) ){
            item = ({ item });
        }
        if( stringp(adjectives) ){
            adjectives = ({ adjectives });
        }
        same_dummy = filter(dummies,(: member_array(global_item[0],$1->GetId()) != -1 :));
        if(sizeof(same_dummy)) return;
        ob = new(LIB_DUMMY, item, val, adjectives);
    }
    ob->eventMove(this_object());
    DummyItems = ({ DummyItems..., ob });
}

mapping RemoveItem(mixed item){
    if( objectp(item) ){
        DummyItems -= ({ item });
        item->eventDestruct();
        return copy(Items);
    }
    else if( !arrayp(item) ){
        item = ({ item });
    }
    foreach(object ob in GetDummyItems()){
        if( sizeof(ob->GetId() & item) ){
            ob->eventDestruct();
            DummyItems -= ({ ob });
            return copy(Items);
        }
    }
}

mapping SetItems(mixed items){
    if(sizeof(DummyItems)) DummyItems->eventDestruct();
    DummyItems = ({});
    if( arrayp(items) ){
        items->eventMove(this_object());
        DummyItems = items;
    }
    else if( mapp(items) ){
        ItemsMap = items;
        foreach(mixed key, mixed val in items){
            string array adjs = ({});
            object ob;

            if( objectp(key) ){
                object *same_dummy = ({});
                global_item = key;
                same_dummy = filter(all_inventory() ,(: base_name($1) == base_name(global_item) :));
                if(sizeof(same_dummy)) continue;
                ob = key;
            }

            if( stringp(key) ){
                key = ({ key });
            }
            else {
                if( sizeof(key) == 2 && arrayp(key[0]) ){
                    adjs = key[1];
                    key = key[0];
                }
            }
            ob = new(LIB_DUMMY, key, val, adjs);
            ob->eventMove(this_object());
            DummyItems = ({ DummyItems..., ob });
        }
    }
    else {
        error("Bad argument 1 to SetItems(), expected object array or "
                "mapping.\n");
    }
    return copy(ItemsMap);
}

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Re: Landmarks daemon
« Reply #2 on: June 10, 2012, 11:47:52 PM »
Minor bug, it will spit out an error on attempting to remove all landmarks (it'll still remove them if you say yes, but it will error).  Here's the corrected function for /secure/cmds/admins/landmark.c:
Code: [Select]
int RemoveLandmarks( string s_arg ){
if( lower_case( s_arg )[0..0] == "y" ){
LANDMARKS_D->RemoveAll();
message( "info", "All landmarks removed.", this_player() );
}else{
message( "info", "Landmarks unchanged.", this_player() );
}
return 1;
}

Also, /daemon/landmarks.c isn't happy with line 141 if you've got some other format for the landmarks (as in from a previous version of this daemon).  See if this fixes the problem:
Code: [Select]
if( !undefinedp( M_Landmarks[s_world][s_town][s_landmark][s_sense]["dist"] ) ){

Offline detah

  • BFF
  • ***
  • Posts: 182
  • Ruler of 2D
    • View Profile
Re: Landmarks daemon
« Reply #3 on: June 11, 2012, 09:00:40 AM »
Could you please repost /lib/std/room.c. Looks like your CODE tags didn't paste correctly.

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Re: Landmarks daemon
« Reply #4 on: June 12, 2012, 04:46:00 AM »
Oops.

/lib/obj/room.c
Code: [Select]
/*    /lib/obj/room.c
 *    From the Dead Souls LPC Library
 *    The room object used to represent any room in the game
 *    Created by Descartes of Borg 940711
 *    Version: @(#) room.c 1.20@(#)
 *    Last Modified: 050912
 *    2011-Oct-09 T. Cook corrected GenerateObviousExits() output for enter-only room handling
 *    2011-Nov-29 T. Cook added SetWorld(), GetWorld()
 *    2012-May-24 T. Cook added GetObviousVisible(), GetMapUse(), SetMapUse()
 */

#ifndef NM_STYLE_EXITS
#define NM_STYLE_EXITS 1
#endif

#include <lib.h>
#include ROOMS_H
#include <daemons.h>
#include <function.h>
#include <medium.h>
#include <message_class.h>
#include <talk_type.h>
#include <terrain_types.h>
#include <respiration_types.h>
#include <medium.h>
#include <privs.h>

inherit LIB_SHADOW_HOOK;
inherit LIB_CLEAN;
inherit LIB_CONTAINER;
inherit LIB_EXITS;
inherit LIB_DESCRIPTION;
inherit LIB_INVENTORY;
inherit LIB_LOOK;
inherit LIB_PROPERTIES;
inherit LIB_AMBIANCE;
inherit LIB_READ;
inherit LIB_MONEY;

private function        Bury          = 0;
private string          Climate       = "temperate";
private int             DayLight      = -1970;
private int             counter       = 0;
private static string   DayLong       = 0;
private object array    DummyItems    = ({});
private static int      GasCheck      = time();
private float           Gravity       = 1.0;
private static mixed    Listen        = 0;
private int             NightLight    = -1970;
private static string   NightLong     = 0;
private static int      NoReplace     = 0;
private static int      PlayerKill    = 0;
private static int      PoisonGas     = 0;
private static int      ResetNumber   = 0;
private static mixed    Search        = 0;
private static int      Shade         = 0;
private static mixed    Smell         = 0;
private static mixed    Touch         = 0;
private string          Town          = "wilderness";
private string          World         = "World";
private int DefaultExits  = 1;
private int Flying        = 1;
private int Sitting       = 0;
private int Kneeling      = 0;
private int Standing      = 0;
private int Swimming      = 0;
private int UseMap        = 1;
private int ObviousVisible       = 1;
private int ActionChance  = 10;
mapping ItemsMap      = ([]);
private static mixed    global_item;
private static mixed Action;
private int tick_resolution = 5;
private int TerrainType = T_OUTDOORS;
private int RespirationType;
private int Medium  = MEDIUM_LAND;
private mapping         ActionsMap      = ([]);
private string          SinkRoom        = "";
private string          FlyRoom         = "";
private string          Elevator         = "";
private int             FlowLimit       = 0;
private int array       Coords          = ({});
private string array    Neighbors       = ({});
private mixed array     NeighborCoords  = ({});

string GetClimate();
int GetNightLight();
int GetDayLight();
int GetShade();
int GetMapUse();
int SetMapUse( int val );
int GetObviousVisible();
varargs mixed DestructEmptyVirtual(object ob);

mixed direct_delete_exit_str(){
    return 1;
}

mixed indirect_delete_exit_str(){
    return 1;
}

varargs int eventPrint(string msg, mixed arg2, mixed arg3);

/***********      /lib/room.c data manipulation functions      **********/

void CheckActions(){
    if(sizeof(ActionsMap)){
        foreach(mixed key, mixed val in ActionsMap){
            if( val > random(100) ){
                if(functionp(key)) evaluate(key);
                else eventPrint(key);
            }
        }
    }

    if( ActionChance > random(100) ){
        int x;

        if( functionp(Action) ) evaluate(Action);
        else if( pointerp(Action) && (x = sizeof(Action)) ){
            mixed act;

            act = Action[random(x)];
            if(functionp(act)){
                evaluate(act);
                return;
            }
            else eventPrint(act);
        }
    }
}

void heart_beat(){
    counter++;
    DestructEmptyVirtual();
    inventory::heart_beat();
    if(counter > 9999) counter = 0;
    CheckActions();
}

void SetAction(int chance, mixed val){
    ActionChance = chance;
    if( stringp(val) ) val = ({ val });
    else if( !functionp(val) && !pointerp(val) )
        error("Bad argument 2 to SetAction()\n");
    Action = val;
}

mixed GetAction(){ return Action; }

mapping SetActionsMap(mapping ActMap){
    if(ActMap && sizeof(ActMap)) ActionsMap = ActMap;
    return copy(ActionsMap);
}

mapping GetActionsMap(){
    return copy(ActionsMap);
}

int SetFrequency(int tick){
    if(tick) tick_resolution = tick;
    else tick_resolution = 5;
    set_heart_beat(0);
    return tick_resolution;
}

int GetFrequency(){
    return tick_resolution;
}

int GetTerrainType(){
    return TerrainType;
}

int SetTerrainType(int i){
    if(i) TerrainType = i;
    else return TerrainType;
}

int AddTerrainType(int i){
    if(!bitshiftedp(i)) return 0;
    else TerrainType = TerrainType | i;
    return TerrainType;
}

string *GetTerrainTypeName(){
string *Terrains = ({ });
if(GetTerrainType() & T_SPACE         ){ Terrains += ({ "space" }); }
if(GetTerrainType() & T_PLASMA        ){ Terrains += ({ "plasma" }); }
if(GetTerrainType() & T_MIDAIR        ){ Terrains += ({ "midair" }); }
if(GetTerrainType() & T_OUTDOORS      ){ Terrains += ({ "outdoors" }); }
if(GetTerrainType() & T_SEAFLOOR      ){ Terrains += ({ "seafloor" }); }
if(GetTerrainType() & T_UNDERWATER    ){ Terrains += ({ "underwater" }); }
if(GetTerrainType() & T_WATERSHALLOW  ){ Terrains += ({ "shallow water" }); }
if(GetTerrainType() & T_SURFACE       ){ Terrains += ({ "sea" }); }
if(GetTerrainType() & T_SAND          ){ Terrains += ({ "sand" }); }
if(GetTerrainType() & T_ROAD          ){ Terrains += ({ "road" }); }
if(GetTerrainType() & T_SWAMP         ){ Terrains += ({ "swamp" }); }
if(GetTerrainType() & T_WOODS         ){ Terrains += ({ "woods" }); }
if(GetTerrainType() & T_JUNGLE        ){ Terrains += ({ "jungle" }); }
if(GetTerrainType() & T_ROUGH         ){ Terrains += ({ "rough" }); }
if(GetTerrainType() & T_SNOW          ){ Terrains += ({ "snow" }); }
if(GetTerrainType() & T_ICE           ){ Terrains += ({ "ice" }); }
if(GetTerrainType() & T_INDOORS       ){ Terrains += ({ "indoors" }); }
if(GetTerrainType() & T_INDOORSWINDOW ){ Terrains += ({ "windowed" }); }
if(GetTerrainType() & T_BIOLOGICAL    ){ Terrains += ({ "biological" }); }
if(GetTerrainType() & T_UNDERGROUND   ){ Terrains += ({ "underground" }); }
if(GetTerrainType() & T_MAGMA         ){ Terrains += ({ "magma" }); }
if(GetTerrainType() & T_PLANAR        ){ Terrains += ({ "another plane" }); }
if(GetTerrainType() & T_CUSTOM        ){ Terrains += ({ "custom" }); }
return Terrains;
}

int RemoveTerrainType(int i){
    if(!bitshiftedp(i)) return 0;
    else TerrainType = TerrainType ^ i;
    return TerrainType;
}

int GetAmbientLight(){
    int a, dayset, nightset;

    dayset = this_object()->GetDayLight();
    nightset = this_object()->GetNightLight();

    if(dayset == -1970 && nightset == -1970 ){
        a = ambiance::GetAmbientLight();
    }

    else if( query_night() && nightset != -1970 ){
        a = nightset;
    }
    else if(!query_night() && dayset != -1970){
        a = dayset;
    }
    else {
        a = ambiance::GetAmbientLight();
    }

    foreach(object ob in all_inventory()){
        a += ob->GetRadiantLight();
    }

    return a;
}

function GetBury(){
    return Bury;
}

function SetBury(function what){
    Bury = what;
}

static string GetExtraLong(){
    int i;
    string *l = ({}),*tmp;
    string ret;
    object array stuff;
    ret = "  ";
    tmp = ({});
    stuff=all_inventory(this_object());
    for(i=0; i<sizeof(stuff);i++){
        if(sizeof(tmp = ({ stuff[i]->GetRoomAffectLong() })) ) l += tmp;
    }
    if( !sizeof(l) ) return 0;
    ret += implode(l, "  ");
    return ret;
}

string GetInternalDesc(){
    string ret, tmp;

    if( DayLong && !query_night() ){
        ret = DayLong;
    }
    else if( NightLong && query_night() ){
        ret = NightLong;
    }
    else {
        ret = container::GetInternalDesc();
    }
    if( !ret ){
        ret = "";
    }
    if( tmp = GetExtraLong() ){
        ret += GetExtraLong();
    }
    return ret;
}

int GetResetNumber(){
    return ResetNumber;
}

string array GetId(){ return ({}); }

string SetDayLong(string str){ return (DayLong = str); }

string GetDayLong(){ return DayLong; }

string SetNightLong(string str){ return (NightLong = str); }

string GetNightLong(){ return NightLong; }

string SetClimate(string str){
    if(str == "indoors" && TerrainType == T_OUTDOORS) TerrainType = T_INDOORS;
    return (Climate = str);
}

string GetClimate(){ return Climate; }

float SetGravity(float h){ return (Gravity = h); }

float GetGravity(){ return Gravity; }

int GetMapUse(){ return UseMap; }

int SetMapUse( int val ){ return ( UseMap = val ? 1 : 0 ); }

int GetDayLight(){
    return DayLight;
}

static int SetDayLight(int x){
    return (DayLight = x);
}

object array GetDummyItems(){
    DummyItems = ({});
    foreach(object item in all_inventory(this_object())){
        if(base_name(item) == LIB_DUMMY){
            DummyItems += ({ item });
        }
    }
    return DummyItems;
}

varargs void AddItem(mixed item, mixed val, mixed adjectives){
    object ob, same_dummy;
    object *dummies = filter(all_inventory(this_object()), (: base_name(LIB_DUMMY) :) );
    global_item = item;

    if( objectp(item) ){
        same_dummy = filter(all_inventory(),(: base_name($1) == base_name(global_item) :));
        if(sizeof(same_dummy) && base_name(item) != LIB_ELEVATOR_BUTTON){
            return;
        }
        ob = item;
    }
    else {
        if( stringp(item) ){
            item = ({ item });
        }
        if( stringp(adjectives) ){
            adjectives = ({ adjectives });
        }
        same_dummy = filter(dummies,(: member_array(global_item[0],$1->GetId()) != -1 :));
        if(sizeof(same_dummy)) return;
        ob = new(LIB_DUMMY, item, val, adjectives);
    }
    ob->eventMove(this_object());
    DummyItems = ({ DummyItems..., ob });
}

mapping RemoveItem(mixed item){
    if( objectp(item) ){
        DummyItems -= ({ item });
        item->eventDestruct();
        return copy(Items);
    }
    else if( !arrayp(item) ){
        item = ({ item });
    }
    foreach(object ob in GetDummyItems()){
        if( sizeof(ob->GetId() & item) ){
            ob->eventDestruct();
            DummyItems -= ({ ob });
            return copy(Items);
        }
    }
}

mapping SetItems(mixed items){
    if(sizeof(DummyItems)) DummyItems->eventDestruct();
    DummyItems = ({});
    if( arrayp(items) ){
        items->eventMove(this_object());
        DummyItems = items;
    }
    else if( mapp(items) ){
        ItemsMap = items;
        foreach(mixed key, mixed val in items){
            string array adjs = ({});
            object ob;

            if( objectp(key) ){
                object *same_dummy = ({});
                global_item = key;
                same_dummy = filter(all_inventory() ,(: base_name($1) == base_name(global_item) :));
                if(sizeof(same_dummy)) continue;
                ob = key;
            }

            if( stringp(key) ){
                key = ({ key });
            }
            else {
                if( sizeof(key) == 2 && arrayp(key[0]) ){
                    adjs = key[1];
                    key = key[0];
                }
            }
            ob = new(LIB_DUMMY, key, val, adjs);
            ob->eventMove(this_object());
            DummyItems = ({ DummyItems..., ob });
        }
    }
    else {
        error("Bad argument 1 to SetItems(), expected object array or "
                "mapping.\n");
    }
    return copy(ItemsMap);
}

mapping GetItemsMap(){
    return copy(ItemsMap);
}

mapping GetSmellMap(){
    mapping Smells = ([]);
    foreach(object ob in GetDummyItems()){
        if( ob->GetSmell() ){
            Smells[ob->GetId()] = ob->GetSmell();
        }
    }
    if(this_object()->GetSmell()) Smells["default"] = this_object()->GetSmell();
    return copy(Smells);

}

mapping GetListenMap(){
    mapping Listens = ([]);
    foreach(object ob in GetDummyItems()){
        if( ob->GetListen() ){
            Listens[ob->GetId()] = ob->GetListen();
        }
    }
    if(this_object()->GetListen()) Listens["default"] = this_object()->GetListen();
    return copy(Listens);
}

mapping QueryMap(string str){
    switch(str){
        case "SetItems" : return GetItemsMap();break;
        case "SetSmell" : return GetSmellMap();break;
        case "SetListen" : return GetListenMap();break;
        case "SetInventory" : return this_object()->GetInventory();break;
        default : return ([]);
    }

}

varargs void AddListen(mixed item, mixed val){
    if( !val ){
        Listen = item;
        return;
    }
    if( !item || item == "default" ){
        Listen = val;
        return;
    }
    if( stringp(item) ){
        item = ({ item });
    }
    foreach(string tmp in item){
        foreach(object ob in GetDummyItems()){
            if( ob->id(tmp) ){
                ob->SetListen(val);
                break;
            }
        }
    }
}

mixed GetListen(){
    return Listen;
}

varargs void RemoveListen(mixed item){
    if( !item || item == "default" ){
        Listen = 0;
        return;
    }
    foreach(object ob in GetDummyItems()){
        if( stringp(item) ){
            if( ob->id(item) ){
                ob->SetListen(0);
            }
        }
        else if( arrayp(item) ){
            if( sizeof(ob->GetId() & item) ){
                ob->SetListen(0);
            }
        }
    }
}

varargs void SetListen(mixed items, mixed arg){
    if( !mapp(items) ){
        if( !arg ){
            AddListen("default", items);
        }
        else {
            AddListen(items, arg);
        }
        return;
    }
    foreach(mixed key, mixed val in items){
        AddListen(key, val);
    }
}

int SetMedium(int medium){
    Medium = medium;
    return Medium;
}

int GetMedium(){
    return Medium;;
}

string GetMediumName(){
string Medium = "";
if(GetMedium() == MEDIUM_SPACE   ){ Medium = "space"; }
if(GetMedium() == MEDIUM_METHANE ){ Medium = "methane"; }
if(GetMedium() == MEDIUM_AIR     ){ Medium = "air"; }
if(GetMedium() == MEDIUM_SURFACE ){ Medium = "surface"; }
if(GetMedium() == MEDIUM_WATER   ){ Medium = "water"; }
if(GetMedium() == MEDIUM_LAND    ){ Medium = "land"; }
return Medium;
}

int GetNightLight(){
    return NightLight;
}

int GetClimateExposed(){
    string *nonexposed_media = ({ MEDIUM_SPACE, MEDIUM_WATER });
    int nonexposed_terrain = (T_SEAFLOOR|T_INDOORS|T_UNDERWATER|T_WATERSHALLOW|T_UNDERGROUND|T_SPACE|T_PLANAR|T_BIOLOGICAL);
    if(GetClimate()=="indoors") return 0;
    if(GetTerrainType() & (nonexposed_terrain)) return 0;
    if(member_array(GetMedium(), nonexposed_media) != -1) return 0;
    return 1;
}

static int SetNightLight(int x){
    return (NightLight = x);
}

int SetNoReplace(int x){ return (NoReplace = x); }

int GetNoReplace(){ return NoReplace; }

int GetPlayerKill(){
    return PlayerKill;
}

int SetPlayerKill(int x){
    return (PlayerKill = x);
}

int AddPoisonGas(int x){
    PoisonGas += x;
    return PoisonGas;
}

int GetPoisonGas(){
    int x;

    if( PoisonGas < 1 ){
        return 0;
    }
    x = time() - GasCheck;
    GasCheck = time();
    if( x > 0 && x < 4 ){
        x = 1;
    }
    else {
        x = x/4;
    }
    PoisonGas -= x;
    if( PoisonGas < 0 ){
        PoisonGas = 0;
    }
    return PoisonGas;
}

int SetPoisonGas(int x){
    return (PoisonGas = x);
}

varargs void AddRead(mixed item, mixed val, string lang){
    if( stringp(item) ){
        item = ({ item });
    }
    foreach(string tmp in item){
        foreach(object ob in GetDummyItems()){
            if( ob->id(tmp) ){
                ob->SetRead(val);
                if(lang) ob->SetLanguage(lang);
                break;
            }
        }
    }
}

void RemoveRead(mixed item){
    foreach(object ob in GetDummyItems()){
        if( stringp(item) ){
            if( ob->id(item) ){
                ob->SetRead(0);
            }
        }
        else if( arrayp(item) ){
            if( sizeof(ob->GetId() & item) ){
                ob->SetRead(0);
            }
        }
    }
}

varargs void SetRead(mixed items, mixed arg){
    if( !mapp(items) ){
        AddRead(items, arg);
        return;
    }
    else foreach(mixed key, mixed val in items){
        AddRead(key, val, ((arg && stringp(arg)) ? arg : 0));
    }
}

int GetShade(){
    return Shade;
}

static int SetShade(int x){
    return (Shade = x);
}

varargs void AddSearch(mixed item, mixed val){
    if( !val ){
        Search = item;
        return;
    }
    if( !item || item == "default" ){
        Search = val;
        return;
    }
    if( stringp(item) ){
        item = ({ item });
    }
    foreach(string tmp in item){
        foreach(object ob in GetDummyItems()){
            if( ob->id(tmp) ){
                ob->SetSearch(val);
                break;
            }
        }
    }
}

varargs mixed GetSearch(){
    return Search;
}

varargs void RemoveSearch(mixed item){
    if( !item || item == "default" ){
        Search = 0;
        return;
    }
    foreach(object ob in GetDummyItems()){
        if( stringp(item) ){
            if( ob->id(item) ){
                ob->SetSearch(0);
            }
        }
        else if( arrayp(item) ){
            if( sizeof(ob->GetId() & item) ){
                ob->SetSearch(0);
            }
        }
    }
}

varargs void SetSearch(mixed items, mixed arg){
    if( !mapp(items) ){
        if( !arg ){
            AddSearch("default", items);
        }
        else {
            AddSearch(items, arg);
        }
        return;
    }
    foreach(mixed key, mixed val in items){
        AddSearch(key, val);
    }
}

varargs void AddSmell(mixed item, mixed val){
    if( !val ){
        Smell = item;
        return;
    }
    if( !item || item == "default" ){
        Smell = val;
        return;
    }
    if( stringp(item) ){
        item = ({ item });
    }
    foreach(string tmp in item){
        foreach(object ob in GetDummyItems()){
            if( ob->id(tmp) ){
                ob->SetSmell(val);
                break;
            }
        }
    }
}

varargs mixed GetSmell(){
    return Smell;
}

varargs void RemoveSmell(mixed item){
    if( !item || item == "default" ){
        Smell = 0;
        return;
    }
    foreach(object ob in GetDummyItems()){
        if( stringp(item) ){
            if( ob->id(item) ){
                ob->SetSmell(0);
            }
        }
        else if( arrayp(item) ){
            if( sizeof(ob->GetId() & item) ){
                ob->SetSmell(0);
            }
        }
    }
}

varargs void SetSmell(mixed items, mixed arg){
    if( !mapp(items) ){
        if( !arg ){
            AddSmell("default", items);
        }
        else {
            AddSmell(items, arg);
        }
        return;
    }
    foreach(mixed key, mixed val in items){
        AddSmell(key, val);
    }
}

varargs void AddTouch(mixed item, mixed val){
    if( !val ){
        Touch = item;
        return;
    }
    if( !item || item == "default" ){
        Touch = val;
        return;
    }
    if( stringp(item) ){
        item = ({ item });
    }
    foreach(string tmp in item){
        foreach(object ob in GetDummyItems()){
            if( ob->id(tmp) ){
                ob->SetTouch(val);
                break;
            }
        }
    }
}

varargs void RemoveTouch(mixed item){
    if( !item || item == "default" ){
        Touch = 0;
        return;
    }
    foreach(object ob in GetDummyItems()){
        if( stringp(item) ){
            if( ob->id(item) ){
                ob->SetTouch(0);
            }
        }
        else if( arrayp(item) ){
            if( sizeof(ob->GetId() & item) ){
                ob->SetTouch(0);
            }
        }
    }
}

varargs void SetTouch(mixed items, mixed arg){
    if( !mapp(items) ){
        if( !arg ){
            AddTouch("default", items);
        }
        else {
            AddTouch(items, arg);
        }
        return;
    }
    foreach(mixed key, mixed val in items){
        AddTouch(key, val);
    }
}

string GetTown(){ return Town; }

string SetTown(string town){ return (Town = town); }

string GetWorld(){ return World && World != "" ? World : "World"; }

string SetWorld( string world ){ return ( World && World != "" ? world : "World" ); }

/** this stuff is for backwards compat **/

mixed SetProperty(string prop, mixed val){
    if( prop == "light" ){
        if( !val ) return val;
        if( val < 0 ) return val;
        else return ambiance::SetAmbientLight(val*25);
    }
    else if( prop == "night light" ){
        if( !val ) return val;
        if( val < 0 ) return val;
        else return SetNightLight(15*val);
    }

    else return properties::SetProperty(prop, val);
}

mixed SetProperties(mapping mp){
    if( mp["light"] ){
        SetProperty("light", mp["light"]);
    }
    else if( mp["night light"] ){
        SetProperty("night light", mp["night light"]);
    }
    return properties::SetProperties(mp);
}


string GetLong(){
    return GetInternalDesc();
}

string SetLong(string str){
    return SetInternalDesc(str);
}

int CanAttack( object attacker, object who ){
    if( PlayerKill ){
        return 1;
    }
    attacker->RemoveHostile( who );
    return 0;
}

varargs int eventShow(object who, string args){
    string str;

    if( !(str = SEASONS_D->GetLong(args)) ){
        who->eventPrint("You do not see that there.");
        return 1;
    }
    who->eventPrint(str);
    eventPrint(who->GetName() + " looks at the " + args + ".", who);
}

/***********          /lib/room.c events          ***********/
mixed eventBuryItem(object who, object tool, object what){
    if( !functionp(Bury) ){
        return "You cannot bury things here!";
    }
    if( functionp(Bury) & FP_OWNER_DESTED ){
        return "You cannot bury things here.";
    }
    return evaluate(Bury, who, tool, what);
}

varargs mixed eventHearTalk(object who, object target, int cls, string verb,
        string msg, string lang){
    object *obs;
    string exit, door;

    switch(cls){
        case TALK_PRIVATE:
            return 1;

        case TALK_SEMI_PRIVATE:
            target->eventHearTalk(who, target, cls, verb, msg, lang);
            eventPrint("%^BOLD%^CYAN%^" + who->GetName() +
                    " whispers something to " + target->GetName() + ".",
                    MSG_CONV, ({ who, target }));
            return 1;

        case TALK_LOCAL:
            obs = get_livings(this_object(),1);
            if(sizeof(obs)) obs -= ({ who });
            if(sizeof(obs))
                obs->eventHearTalk(who, target, cls, verb, msg, lang);
            obs = get_livings(this_object(),2);
            if(sizeof(obs)) obs -= ({ who });
            if(sizeof(obs))
                obs->eventHearTalk(who, target, cls, verb, msg, lang);
            return 1;

        case TALK_AREA:
            foreach(exit in GetExits()){
                string tmp;

                tmp = GetExit(exit);
                if( !find_object(tmp) ) continue;
                tmp->eventHearTalk(who, target, TALK_LOCAL, verb, msg, lang);
            }
            foreach(exit in GetEnters(1)){
                string tmp;

                tmp = GetEnter(exit);
                if( !find_object(tmp) ) continue;
                if( (door = GetDoor(exit)) && door->GetClosed() ) continue;
                tmp->eventHearTalk(who, target, TALK_LOCAL, verb, msg, lang);
            }
            obs = filter(all_inventory(),
                    (: $1->is_living() && $1 != $(who) :));
            obs->eventHearTalk(who, target, cls, verb, msg, lang);
            return 1;

    }
}

int eventMove(){ return 0; }

varargs int eventPrint(string msg, mixed arg2, mixed arg3){
    object *targs;
    int msg_class;
    targs = filter(all_inventory(),
            (: $1->is_living() || $1->GeteventPrints() :));

    if( !arg2 && !arg3 ){
        msg_class = MSG_ENV;
    }
    else if( objectp(arg2) || arrayp(arg2) ){
        if( objectp(arg2) ) arg2 = ({ arg2 });
        foreach(mixed mount in arg2){
            object *riders;
            if(!mount) continue;
            riders = mount->GetRiders();
            if(riders) targs += riders;
        }
        targs -=  arg2;
        if( !arg3 ) msg_class = MSG_ENV;
        else if(intp(arg3)) msg_class = arg3;
    }
    else if(!arg3){
        if(intp(arg2)) msg_class = arg2;
        else msg_class = MSG_ENV;
    }
    else if( objectp(arg3) || arrayp(arg3) ){
        if( objectp(arg3) ) arg3 = ({ arg3 });
        foreach(mixed mount in arg3){
            object *riders;
            if(!mount) continue;
            riders = mount->GetRiders();
            if(riders) targs += riders;
        }
        targs -= arg3;
        msg_class = arg2;
    }
    if(sizeof(targs)) targs->eventPrint(msg, msg_class);
    return 1;
}

static void create(){
    exits::create();
    inventory::reset(query_reset_number());
    set_heart_beat(0);
    if( replaceable(this_object()) && !GetNoReplace() ){
        string array tmp= inherit_list(this_object());
        if( sizeof(tmp) == 1 ){
            replace_program(tmp[0]);
        }
    }
}

int eventDestruct(){
    if(GetPersistent()){
        SaveObject();
    }
    return ::eventDestruct();
}

int CanReceive(object ob){
    if(!GetProperty("no teleport") || !living(ob)) return container::CanReceive(ob);
    else {
        string verb = query_verb();
        string *allowed = ({ "go", "climb", "jump", "enter", "fly", "crawl" });
        if(member_array(verb, allowed) == -1 && !archp(this_player())){
            write("Your teleportation is prevented.");
            return 0;
        }
    }
    return container::CanReceive(ob);
}

varargs void reset(int count){
    mixed *inv;

    if(origin() == "driver") return;

    inv = deep_inventory(this_object());
    if(inv && sizeof(inv)){
        if( sizeof(filter(inv, (: interactive($1) || $1->GetNoClean() :))) ){
            return;
        }
    }
    inventory::reset(count);
    all_inventory()->reset(count);
    ResetNumber++;
}

int id(){
    return 0;
}

int inventory_accessible(){
    return 1;
}

int inventory_visible(){
    return 1;
}

int SetNoDefaultExits(int i){
    if(!i) i = 0;
    DefaultExits = bool_reverse(i);
    ObviousVisible = DefaultExits;
    return DefaultExits;
}

int SetDefaultExits(int i){
    if(!i) i = 0;
    DefaultExits = i;
    ObviousVisible = DefaultExits;
    return DefaultExits;
}

int SetCanFly(int i){
    if(i && i > 0) Flying = 1;
    else Flying = 0;
}

mixed CanFly(object who, string dest){
    if(!who) who = this_player();
    if(!dest) dest = "";
    if(MEDIUM_WATER == Medium || MEDIUM_SPACE == Medium) return 0;
    if(sizeof(FlyRoom)) return 1;
    return Flying;
}

int SetCanSwim(int i){
    if(i && i > 0) Swimming = 1;
    else Swimming = 0;
}

mixed CanSwim(object who, string dest){
    if(!who) who = this_player();
    if(!dest) dest = "";
    if((MEDIUM_WATER == Medium) || (MEDIUM_SURFACE == Medium) ) return 1;
    if(GetTerrainType() & (T_ALL_SEA)) return 1;
    return Swimming;
}

int SetCanStand(int i){
    if(i && i > 0) Standing = 1;
    else Standing = 0;
}

mixed CanStand(object who, string dest){
    if(!who) who = this_player();
    if(!dest) dest = "";
    if(GetTerrainType() & (T_SPACE | T_UNDERWATER | T_WATERSHALLOW | T_SURFACE)) return 0;
    if(GetTerrainType() & (T_SEAFLOOR)) return 1;
    if((MEDIUM_AIR == Medium | MEDIUM_WATER == Medium | MEDIUM_SPACE == Medium)) return 0;
    if((MEDIUM_LAND == Medium)) return 1;
    return Standing;
}

int SetCanSit(int i){
    if(i && i > 0) Sitting = 1;
    else Sitting = 0;
}

mixed CanSit(object who, string dest){
    if(!who) who = this_player();
    if(!dest) dest = "";
    if(GetTerrainType() & (T_SPACE | T_UNDERWATER | T_WATERSHALLOW | T_SURFACE)) return 0;
    if(GetTerrainType() & (T_SEAFLOOR)) return 1;
    if((MEDIUM_AIR == Medium | MEDIUM_WATER == Medium | MEDIUM_SPACE == Medium)) return 0;
    if((MEDIUM_LAND == Medium)) return 1;
    return Sitting;
}

int SetCanKneel(int i){
    if(i && i > 0) Kneeling = 1;
    else Kneeling = 0;
}

mixed CanKneel(object who, string dest){
    if(!who) who = this_player();
    if(!dest) dest = "";
    if(GetTerrainType() & (T_SPACE | T_UNDERWATER | T_WATERSHALLOW | T_SURFACE)) return 0;
    if(GetTerrainType() & (T_SEAFLOOR)) return 1;
    if((MEDIUM_AIR == Medium | MEDIUM_WATER == Medium | MEDIUM_SPACE == Medium)) return 0;
    if((MEDIUM_LAND == Medium)) return 1;
    return Kneeling;
}

int SetNoObviousExits(int i){
    if(!i) i = 0;
    ObviousVisible = bool_reverse(i);
    DefaultExits = ObviousVisible;
    return ObviousVisible;
}

int GetObviousVisible(){ return ObviousVisible; }

int GenerateObviousExits(){
    string *normals;
    string *exits;
    string dir_string, enters;
    exits = filter(GetExits(), (: !($1 == "up" && !(this_object()->GetVirtualSky()) &&
                    load_object(GetExit($1))->GetVirtualSky()) :) );
    enters = "";
    normals = ({ "north", "south", "east", "west", "up", "down" });
    normals += ({ "northeast", "southeast", "northwest", "southwest" });
    normals += ({ "out" });
    dir_string = "";

    if(sizeof(GetEnters(1)-({0}))){
        foreach(string enter in this_object()->GetEnters(1)){
            enters += "enter "+enter;
            if(member_array(enter,this_object()->GetEnters(1)) !=
                    sizeof(this_object()->GetEnters(1)) -1){
                enters +=", ";
            }
        }
    }

    if(NM_STYLE_EXITS){
        if(member_array("north",exits) != -1) dir_string += "n, ";
        if(member_array("south",exits) != -1) dir_string += "s, ";
        if(member_array("east",exits) != -1) dir_string += "e, ";
        if(member_array("west",exits) != -1) dir_string += "w, ";
        if(member_array("northeast",exits) != -1) dir_string += "ne, ";
        if(member_array("northwest",exits) != -1) dir_string += "nw, ";
        if(member_array("southeast",exits) != -1) dir_string += "se, ";
        if(member_array("southwest",exits) != -1) dir_string += "sw, ";
        if(member_array("up",exits) != -1) dir_string += "u, ";
        if(member_array("down",exits) != -1) dir_string += "d, ";
        if(member_array("out",exits) != -1) dir_string += "out, ";
    }
    else dir_string = implode(exits,", ")+", ";
    if(sizeof(this_object()->GetEnters(1) - ({0}) )){
        if(sizeof(this_object()->GetExits())) dir_string += ", ";
        dir_string += enters;
    }
    //if(last(dir_string,2) == ", ") dir_string = truncate(dir_string,2);
if( dir_string[<2..] == ", "){ dir_string = dir_string[0..<3]; }
if( dir_string[0..1] == ", "){ dir_string = dir_string[2..]; }
    dir_string = replace_string(dir_string,", , ",", ");
    if(ObviousVisible) SetObviousExits(dir_string);
    return 1;
}

int eventReceiveObject(object ob){
    return container::eventReceiveObject(ob);
}

int eventReleaseObject(object ob){
    return container::eventReleaseObject(ob);
}

string SetFlyRoom(string str){
    FlyRoom = str;
    return FlyRoom;
}

string GetFlyRoom(){
    return FlyRoom;
}

string SetSinkRoom(string str){
    SinkRoom = str;
    return SinkRoom;
}

string GetSinkRoom(){
    return SinkRoom;
}

int SetFlowLimit(int i){
    FlowLimit = i;
    return FlowLimit;
}

int GetFlowLimit(){
    return FlowLimit;
}

int SetRespirationType(int i){
    RespirationType = i;
    return RespirationType;
}

int GetRespirationType(){
    return RespirationType;
}

string *GetRespirationTypeName(){
string *Respiration = ({ });
if(GetRespirationType() & R_VACUUM  ){ Respiration += ({ "vacuum" }); }
if(GetRespirationType() & R_METHANE ){ Respiration += ({ "methane" }); }
if(GetRespirationType() & R_AIR     ){ Respiration += ({ "air" }); }
if(GetRespirationType() & R_WATER   ){ Respiration += ({ "water" }); }
return Respiration;
}

varargs mixed DestructEmptyVirtual(object ob){
    mixed *inv;
    if(ob && environment(ob) && environment(ob) == this_object()) return 0;
    if(!this_object()->GetVirtual()){
        return 0;
    }
    if(this_object()->GetNoClean()){
        return 0;
    }
    if(this_object()->GetExemptVirtual()){
        return 0;
    }
    inv  = filter(all_inventory(this_object()),
            (: !inherits(LIB_BASE_DUMMY, $1) :) );
    if(!sizeof(inv)){
        all_inventory(this_object())->eventDestruct();
        return eventDestruct();
    }
}

mixed eventPostRelease(object ob){
    mixed *inv;
    mixed ret = ::eventPostRelease(ob);
    DestructEmptyVirtual(ob);
    return ret;
}

void CompileNeighbors(mixed coords){
#if GRID
    int x, x2;
    int y, y2;
    int a, b, c;
    if(!Neighbors) Neighbors = ({});
    if(sizeof(Neighbors) || !(MASTER_D->GetPerfOK())) return;
    if(!sizeof(Coords)){
        mixed crds = ROOMS_D->GetCoordinates(this_object());
        if(sizeof(crds)){
            sscanf(crds,"%d,%d,%d",a,b,c);
            Coords = ({ a, b, c });
        }
        if(!sizeof(Coords)) return;
    }
    x2 = Coords[0]+2;
    y2 = Coords[1]+2;
    NeighborCoords = ({ });
    for(x = Coords[0]-1; x < x2; x++){
        for(y = Coords[1]-1; y < y2; y++){
            NeighborCoords += ({ ({ x, y, 0 }) });
        }
    }
    NeighborCoords -= ({ Coords });
    foreach(mixed foo in NeighborCoords){
        mixed bar = ROOMS_D->GetGrid(foo[0]+","+foo[1]+","+foo[2]);
        if(bar && bar["room"]){
            Neighbors += ({ bar["room"] });
        }
    }
#endif
}

mixed GetNeighbors(){
    return copy(Neighbors);
}

mixed GetNeighborCoords(){
    return copy(NeighborCoords);
}

mixed GetCoords(){
    return copy(Coords);
}

string SetCoordinates(string str){
    string ret;
    int x, y, z, i;
    if(!str) return 0;
    i = sscanf(str, "%d,%d,%d", x, y, z);
    if(i != 3){
        i = sscanf(str, "%d,%d", x, y);
        z = 0;
    }
    if(i < 2) return 0;
    ret = x+","+y+","+z;
    if(sizeof(ROOMS_D->GetGrid(ret))) return 0;
    ROOMS_D->SetRoom(this_object(), this_object(), ret);
    Coords = ({ x, y, z });
    return ret;
}

static void init(){
    object prev = previous_object();
    if(undefinedp(RespirationType)){
        switch(GetMedium()){
            case MEDIUM_WATER : RespirationType = R_WATER; break;
            case MEDIUM_SPACE : RespirationType = R_VACUUM; break;
            case MEDIUM_AIR : RespirationType = R_AIR; break;
            case MEDIUM_LAND : RespirationType = R_AIR; break;
            case MEDIUM_SURFACE : RespirationType = (R_AIR | R_WATER); break;
            case MEDIUM_METHANE : RespirationType = R_METHANE; break;
            default : RespirationType = R_AIR; break;
        }
    }
    if(this_object()->GetProperty("indoors")) SetClimate("indoors");
    if(!sizeof(GetObviousExits()) && DefaultExits > 0 && ObviousVisible){
        GenerateObviousExits();
    }
    if((Action && (sizeof(Action) || functionp(Action)))
            || sizeof(ActionsMap)){
        set_heart_beat(tick_resolution);
    }
#if GRID
    if(this_object() && prev && (living(prev) || prev->GetMapper())){
        if(MASTER_D->GetPerfOK()){
            Coords = ROOMS_D->SetRoom(this_object(), prev);
            CompileNeighbors(Coords);
        }
    }
#endif
    if(this_object()->GetVirtual() && !query_heart_beat()){
        set_heart_beat(1);
    }
}

string GetElevator(){
    return Elevator;
}

string SetElevator(string str){
    if(str) Elevator = str;
    return Elevator;
}

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Re: Landmarks daemon
« Reply #5 on: June 12, 2012, 04:48:25 AM »
Further required files.

/daemon/map.c
Code: [Select]
/*  /lib/daemon/map.c
 *  2011-Sep-10 T. Cook modified formatting, added OEM output, changed default sizes to odd numbers, fixed output
 *  2012-May-25 T. Cook removed OEM elements, handling should be done in /lib/events/display.c
 */
#include <lib.h>
#include <daemons.h>
#include <save.h>
#define FLOW_DEBUGGING 0
#ifndef MAP_CACHE
#define MAP_CACHE 1
#endif

inherit LIB_DAEMON;
mapping MapMap, MapCache;
static int heart_count = 1, sweepflag, roomcount, caching = 0;
static string SaveFile;
static string *sweeprooms = ({});

void create(){
#if WIZMAP
SaveFile = save_file( SAVE_MAP );
if( !file_exists( SaveFile ) && file_exists( old_savename( SaveFile ) ) ){
cp( old_savename( SaveFile ), SaveFile );
}
if( file_exists( SaveFile ) ){
RestoreObject( SaveFile, 1 );
}
set_heart_beat( 1 );
#endif
}

void zero(){
MapMap = ([]);
MapCache = ([]);
SaveObject( SaveFile, 1 );
}

void heart_beat(){
if( !( heart_count % 900 ) ){  // Every 15 minutes save the cache
SaveObject( SaveFile, 1 );
}
if( !( heart_count % 64800 ) ){  // Every 18 hours refresh the cache
if( !sweepflag ){
sweepflag = 1;
sweeprooms = keys( MapMap );
}
}
if( sweepflag ){
if( sizeof( sweeprooms ) <= roomcount ){
sweepflag = 0;
roomcount = 0;
return;
}
if( MapMap[sweeprooms[roomcount]]["name"] ){
this_object()->GetMap( MapMap[sweeprooms[roomcount]]["name"], 8, 1 );
}else{
map_delete( MapMap, sweeprooms[roomcount] );
map_delete( MapCache, sweeprooms[roomcount] );
}
roomcount++;
}
heart_count++;
}

int eventDestruct(){
SaveObject( SaveFile, 1 );
return daemon::eventDestruct();
}

int RemoveCache( string str ){
if( MapCache && MapCache[str] ){
MapCache[str] = 0;
return 1;
}
return 0;
}

int SetCaching( int x ){
if( x ){ caching = 1; }
else caching = 0;
return caching;
}

int GetCaching(){
return caching;
}

varargs mixed GetMap( mixed args, int size, int forced ){
#if WIZMAP
string ret = "";
int i, x, line, tempy, tmpres, res = size, i_screenX;
mapping Lines = ([]);
mapping myspot;
string mycoords;
mapping start;
i_screenX = this_player()->GetScreen()[0];
if( !( MASTER_D->GetPerfOK() ) ){
return ret;
}
if( !size ){ size = 3; }
if( size > 15 && !creatorp( this_player() ) ){ size = 7; }
if( i_screenX < size * 2 + 1 ){ size = ( i_screenX - 1 ) / 2; }
if(!args){ args = base_name( environment( this_player() ) ); }
if( objectp( args ) ){ args = base_name( args ); }
myspot = ROOMS_D->GetGridMap( args );
if( !myspot ){ return 0; }
mycoords = myspot["coord"];
res = size;
if( !MapCache ){ MapCache = ([]); }
if( !myspot["coords"] || ( mycoords == "0,0,0" && ROOMS_D->GetRoomZero() != args ) ){
ret = "%^RED%^Map unavailable.%^RESET%^";
return ret;
}
if( !forced && caching && MapCache[mycoords] ){
return MapCache[mycoords];
}
start = ([
"x" : myspot["coords"]["x"] - ( res / 2 ),
"y" : myspot["coords"]["y"] + ( res / 2 ),
"z" : myspot["coords"]["z"]
]);
if( !MapMap ){ MapMap = ([]); }
if( sizeof( MapMap ) >= 64000 ){ MapMap = ([]); }
for( tempy = start["y"]; tempy > start["y"] - res; tempy-- ){
mapping ppos = ([]);
int xcount;
line += 2;
for( tmpres = start["x"]; tmpres < start["x"] + res; tmpres++ ){
string room, coord = tmpres + "," + tempy + "," + start["z"];
mixed tmp = ROOMS_D->GetGrid( coord );
xcount += 2;
if( tmp ){
room = tmp["room"];
MapMap[coord] = ([ "name" : room ]);
}
if( !Lines[line] ){
string pre = ( tempy > -1 ? " " : "" );
Lines[line] = pre + ( tempy % 10 ) + repeat_string( " ", res * 2 + 1 );
}
if( !Lines[line + 1] ){
Lines[line + 1] = " " + repeat_string( " ", res * 2 + 2 );
}
if( !Lines[line - 1] ){
Lines[line - 1] = " " + repeat_string( " ", res * 2 + 2 );
}
if( MapMap[coord] ){
mapping gridmap;
mapping dirs;
object croom;
if( !MapMap[coord]["name"] ){ continue; }
gridmap = ROOMS_D->GetGridMap( MapMap[coord]["name"] );
if( !sizeof( gridmap ) ){ continue; }
if( gridmap["exits"] ){ dirs = gridmap["exits"]; }
if( mycoords == coord ){
Lines[line][xcount + 1 ] = '*';
}else{
#if FLOW_DEBUGGING
object flow;
croom = find_object( MapMap[coord]["name"] );
if( croom && flow = present( "flow", croom ) ){
int press = flow->GetPressure();
if( press == 1 ){ Lines[line][xcount + 1 ] = '1'; }
if( press == 2 ){ Lines[line][xcount + 1 ] = '2'; }
if( press == 3 ){ Lines[line][xcount + 1 ] = '3'; }
if( press == 4 ){ Lines[line][xcount + 1 ] = '4'; }
if( press  > 4 ){ Lines[line][xcount + 1 ] = '5'; }
}else{ Lines[line][xcount + 1] = '#'; }
#else
croom = find_object( MapMap[coord]["name"] );
if( croom && member_array( "indoors", croom->GetTerrainTypeName() ) > -1 ){
Lines[line][xcount + 1] = '#';
}else if( croom && member_array( "outdoors", croom->GetTerrainTypeName() ) > -1 ){
Lines[line][xcount + 1] = 'o';
}else{
Lines[line][xcount + 1] = '$';
}
#endif
}
if( sizeof( dirs ) ){
foreach( string dir in keys( dirs ) ){
switch( dir ){
case "north":
if( Lines[line - 1] ){
Lines[line - 1][xcount + 1] = '|';
}
break;
case "south":
if( Lines[line + 1] ){
Lines[line + 1][xcount + 1] = '|';
}
break;
case "east":
Lines[line][xcount + 2] = '-';
break;
case "west":
Lines[line][xcount] = '-';
break;
case "northeast":
if( Lines[line - 1] ){
if( Lines[line - 1][xcount + 2] == '\\' ){ Lines[line - 1][xcount + 2] = 'X'; }
else{ Lines[line - 1][xcount + 2] = '/'; }
}
break;
case "northwest":
if( Lines[line - 1] ){
if( Lines[line - 1][xcount] == '/' ){ Lines[line - 1][xcount] = 'X'; }
else{ Lines[line - 1][xcount] = '\\'; }
}
break;
case "southeast":
if( Lines[line + 1] ){
if( Lines[line + 1][xcount + 2] == '/' ){ Lines[line + 1][xcount + 2] = 'X'; }
else{ Lines[line + 1][xcount + 2] = '\\'; }
}
break;
case "southwest":
if( Lines[line + 1] ){
if( Lines[line + 1][xcount] == '\\' ){ Lines[line + 1][xcount] = 'X'; }
else{ Lines[line + 1][xcount] = '/'; }
}
break;
}
}
}
}else{
}
}
xcount = 0;
}
if( line == size * 2 ){
int xcount = size;
string pre;
x = start["x"] - 1;
Lines[line + 1 + 1 ] = "  ";
while( xcount ){
x++;
if( x < 0 ){ pre = "-"; }
else{ pre = " "; }
Lines[line + 2] += pre + abs( ( x % 10 ) );
xcount--;
}
Lines[line + 2] += " ";
}
for( i = sizeof( Lines ), x = 0; x < i + 1; x++ ){
if( Lines[x] && x < i + 1 ){ ret += Lines[x] + "\n"; }
}
#if FLOW_DEBUGGING
ret = replace_string( ret, "1", "%^GREEN%^A%^RESET%^" );
ret = replace_string( ret, "2", "%^YELLOW%^B%^RESET%^" );
ret = replace_string( ret, "3", "%^CYAN%^C%^RESET%^" );
ret = replace_string( ret, "4", "%^BLUE%^D%^RESET%^" );
ret = replace_string( ret, "5", "%^MAGENTA%^F%^RESET%^" );
#endif
MapCache[mycoords] = ret;
return ret;
#else
/* Wizmapping not enabled in config.h */
return "";
#endif
}

/secure/sefun/minimap.c
Code: [Select]
/* 2011-Sep-10 T. Cook improved
 * 2012-May-24 T. Cook made borderless with compass points
 * 2012-May-26 T. Cook simplified output to vanilla
 */
string query_door( object what, string direction ){
string door = what->GetDoor( direction );
object puerta;
if( !door ){
return "#";
}else{
puerta = load_object( door );
if( !puerta ){ return "#"; }
if( puerta->GetClosed() ){ return "?"; }
return "#";
}
return " ";
}

varargs string simple_map( mixed arg ){
string *exits;
string *extra_desc = ({});
string ret = "";
string line0 = "    N    \n";
string line6 = "    S    \n";
string line3 = "W       E\n";
string line1 = "         \n";
string line2, line4, line5;
line2 = line4 = line5 = line1;
if( !arg && !this_player() ){ return ""; }
if( !arg ){ arg = environment( this_player() ); }
if( stringp( arg ) ){ arg = load_object( arg ); }
if( living( arg ) || arg->GetMount() ){ arg = environment( arg ); }
if( !arg ){ return ""; }
exits = arg->GetExits();
if( !exits || !sizeof( exits ) ){ return ""; }
line3[4..4] = "*";

foreach( string element in exits ){
switch( element ){
case "north":
line1[4..4] = query_door( arg, element );
line2[4..4] = query_door( arg, element ) == "?" ? "+" : "|";
break;
case "south":
line5[4..4] = query_door( arg, element );
line4[4..4] = query_door( arg, element ) == "?" ? "+" : "|";
break;
case "east":
line3[7..7] = query_door( arg, element );
line3[5..5] = query_door( arg, element ) == "?" ? "+" : "-";
line3[6..6] = query_door( arg, element ) == "?" ? " " : "-";
break;
case "west":
line3[1..1] = query_door( arg, element );
line3[2..2] = query_door( arg, element ) == "?" ? " " : "-";
line3[3..3] = query_door( arg, element ) == "?" ? "+" : "-";
break;
case "northeast":
line1[7..7] = query_door( arg, element );
line2[6..6] = query_door( arg, element ) == "?" ? "+" : "/";
break;
case "northwest":
line1[1..1] = query_door( arg, element );
line2[2..2] = query_door( arg, element ) == "?" ? "+" : "\\";
break;
case "southeast":
line5[7..7] = query_door( arg, element );
line4[6..6] = query_door( arg, element ) == "?" ? "+" : "\\";
break;
case "southwest":
line5[1..1] = query_door( arg, element );
line4[2..2] = query_door( arg, element ) == "?" ? "+" : "/";
break;
default : extra_desc += ({ element }); break;
}
}
if( sizeof( extra_desc ) ){
line3 = replace_string( line3, "\n", " Also available:  " + item_list( extra_desc ) + ".\n" );
}
ret = line0 + line1 + line2 + line3 + line4 + line5 + line6;
return ret;
}
/* EOF */

/daemon/terminal.c
Code: [Select]
/*    /daemon/terminal.c
 *    from the Dead Souls Object Library
 *    daemon storing terminal information
 *    created by Pinkfish@Discworld
 *    rewritten for Dead Souls by Descartes of Borg 930903
 *    Version: @(#) terminal.c 1.5@(#)
 *    Last modified: 96/11/11
 */

#include <lib.h>

inherit LIB_DAEMON;

#define ANSI(p) sprintf("%c["+(p)+"m", 27)
#define ESC(p) sprintf("%c"+(p), 27)

static mapping term_info;

void create() {
    mapping nohtml;

    daemon::create();
    SetNoClean(1);
    nohtml = ([ "BR": "", "P" : "", "/P" : "", "HREF" : "", ">" : "",
            "NAME" : "", "/A" : "", "I" : "", "/I" : "", "PRE" : "",
            "/PRE" : "", "STRONG" : "", "/STRONG" : "", "TABLE" : "",
            "/TABLE" : "", "TR" : "", "/TR" : "", "TD" : "", "/TD" : ""]);
    term_info = ([ ]);
    term_info["unknown"] =
        ([ "RESET": "", "BOLD": "", "FLASH":"", "BLACK":"", "RED":"",
         "BLUE":"", "CYAN":"", "MAGENTA":"", "ORANGE":"", "YELLOW":"",
         "GREEN":"", "WHITE":"", "BLACK":"", "B_RED":"", "B_ORANGE":"",
         "B_YELLOW":"", "B_BLACK":"", "B_CYAN":"","B_WHITE":"", "B_GREEN":"",
         "B_MAGENTA":"", "STATUS":"", "WINDOW":"", "INITTERM": "",
         "ENDTERM":""]) + nohtml;
    term_info["ansi"] =
        ([ "RESET":ANSI("0"), "BOLD":ANSI(1), "FLASH":ANSI(5),
         "BLACK":ANSI(30), "RED":ANSI(31), "GREEN":ANSI(32),
         "ORANGE":ANSI(33),     "YELLOW":ANSI(1)+ANSI(33), "BLUE": ANSI(34),
         "CYAN":ANSI(36), "MAGENTA":ANSI(35), "BLACK":ANSI(30),
         "WHITE": ANSI(37), "B_RED":ANSI(41), "B_GREEN":ANSI(42),
         "B_ORANGE":ANSI(43), "B_YELLOW":ANSI(1)+ANSI(43), "B_BLUE":ANSI(44),
         "B_CYAN":ANSI(46), "B_BLACK":ANSI(40), "B_WHITE": ANSI(47),
         "CLEARLINE":ESC("[L")+ESC("[G"), "B_MAGENTA":ANSI(45), "STATUS":"",
         "WINDOW":"", "INITTERM":ESC("[H")+ESC("[2J"), "ENDTERM":"" ]) +
        nohtml;
    term_info["freedom"] =
        ([ "RESET": ESC("G0"), "BOLD":ESC("G@"), "FLASH":ESC("G2"),
         "BLACK":"", "RED":"", "GREEN":"", "ORANGE":"", "YELLOW":"", "BLUE":"",
         "CYAN":"", "MAGENTA":"", "BLACK":"", "WHITE":"", "B_RED":ESC("GD"),
         "B_GREEN": ESC("GD"), "B_ORANGE":ESC("G4"), "B_YELLOW":ESC("G4"),
         "B_BLUE":ESC("G4"), "B_CYAN":ESC("GD"), "B_BLACK": ESC("GD"),
         "B_WHITE":ESC("G4"), "B_MAGENTA":("G4"), "STATUS":"", "WINDOW":"",
         "CLEARLINE":CARRIAGE_RETURN, "INITTERM":"", "ENDTERM":"" ]) + nohtml;
    term_info["ansi-status"] =
        ([ "RESET": ANSI("0;37;40"), "BOLD":ANSI(1), "FLASH":ANSI(5),
         "BLACK":ANSI(30), "RED":ANSI(31), "GREEN":ANSI(32), "ORANGE":ANSI(33),
         "YELLOW":ANSI(33), "BLUE":ANSI(34), "CYAN": ANSI(36),
         "MAGENTA": ANSI(35), "BLACK":ANSI(30), "WHITE":ANSI(37),
         "B_RED":ANSI(41), "B_GREEN":ANSI(42), "B_ORANGE":ANSI(43),
         "B_YELLOW": ANSI(1)+ANSI(43), "B_BLUE":ANSI(44),
         "B_CYAN": ANSI(46), "B_BLACK":ANSI(40), "B_WHITE":ANSI(47),
         "B_MAGENTA":ANSI(45), "STATUS":ESC("[23;24r")+ESC(8),
         "WINDOW":ESC(7)+ESC("[0;22r")+ESC("[22H\n"),
         "INITTERM":ESC("[H")+ESC("[J")+ESC("[23;24r")+ESC("23H\n"),
         "CLEARLINE":CARRIAGE_RETURN, "ENDTERM":ESC("[0r")+ESC("[H")+ESC("[J") ]) +nohtml;
    term_info["xterm"] =
        ([ "RESET":ANSI("0"), "BOLD":ANSI(1), "FLASH":ANSI(5),
         "BLACK":ANSI(30), "RED":ANSI(31), "GREEN":ANSI(32),
         "ORANGE":ANSI(33),     "YELLOW":ANSI(1)+ANSI(33), "BLUE": ANSI(34),
         "CYAN":ANSI(36), "MAGENTA":ANSI(35), "BLACK":ANSI(30),
         "WHITE": ANSI(37), "B_RED":ANSI(41), "B_GREEN":ANSI(42),
         "B_ORANGE":ANSI(43), "B_YELLOW":ANSI(1)+ANSI(43), "B_BLUE":ANSI(44),
         "B_CYAN":ANSI(46), "B_BLACK":ANSI(40), "B_WHITE": ANSI(47),
         "CLEARLINE":ESC("[L")+ESC("[G"), "B_MAGENTA":ANSI(45), "STATUS":"",
         "WINDOW":"", "INITTERM":ESC("[H")+ESC("[2J"), "ENDTERM":"" ]) +
        nohtml;
    term_info["html"] = term_info["unknown"] +
        ([ "RED"  : "<FONT COLOR=\"#FF0000\">",
         "GREEN" : "<FONT COLOR=\"#00FF00\">",
         "BLUE"  : "<FONT COLOR=\"#0000FF\">",
         "YELLOW" : "<FONT COLOR=\"#FFFF00\">",
         "CYAN" : "<FONT COLOR=\"#00A0DD\">",
         "MAGENTA" : "<FONT COLOR=\"#C50067\">",
         "YELLOW" : "<FONT COLOR=\"#FFFF00\">",
         "RESET": "</FONT>",
         "BR" : "<BR>", "P" : "<P>", "/P" : "</P>", ">" : ">",
         "HREF" : "<A HREF=", "NAME" : "<A NAME=", "/A" : "</A>",
         "I" : "<I>", "/I" : "</I>", "PRE" : "</PRE>", "/PRE" : "</PRE>",
         "STRONG" : "<STRONG>", "/STRONG" : "</STRONG>",
         "TABLE" : "<TABLE>", "/TABLE" : "</TABLE>", "TR" : "<TR>",
         "/TR" : "</TR>", "TD" : "<TD>" , "/TD" : "</TD>" ]);
}

mapping query_term_info(string type) {
    return (term_info[type] ? term_info[type] : term_info["unknown"]);
}

string *query_terms() { return keys(term_info); }

int query_term_support(string str) {
    return (term_info[str] ? 1 : 0);
}

string no_colours(string str) {
    return terminal_colour(str, term_info["unknown"]);
}

string no_colors(string str){
    return no_colours(str);
}

string GetHTML(string str) {
    int i, tot, fcount = 0, ncount = 0;
    string tmp;

    str = terminal_colour(str, term_info["html"]);
    tmp = str;
    while( (i = strsrch(tmp, "<FONT")) != -1 ) {
        fcount++;
        tmp = tmp[(i+5)..];
    }
    if( fcount < 1 ) {
        return str;
    }
    tmp = str;
    while( (i = strsrch(tmp, "</FONT")) != -1 ) {
        ncount++;
        tmp = tmp[(i+6)..];
    }
    tot = fcount - ncount;
    if( tot > 0 ) {
        while( tot-- ) {
            str += "</FONT>";
        }
    }
    return str;
}

#ifdef __DSLIB__
int GetCharmode(object ob){
    return query_charmode(ob);
}
#endif

/* 2011-Sep-11 - T. Cook
 * text-wrapping that handles colours and outputs into a space-padded array to allow easy adding of a border
 * 2011-Oct-26 - changed outer for() to foreach()
 * 2011-Oct-27 - added check for colour strings to continue on newline
 *             - fixed problem caused by colour strings being an isolated word
 * 2011-Oct-28 - replaced majority of code with terminal_colour() call
 * 2011-Oct-29 - replaced hardcoding of pinkfish codes with TERMINAL_D call, courtesy Quixadhal@Bloodlines
 * 2011-Nov-07 - moved wraptext() to TERMINAL_D instead of as an sefun
 */
 string *WrapText( string s_str, int i_width ){
string s_line = "";
string *sa_temptext1, *sa_temptext2 = ({});
int i_count, i_screenX;
mapping m_colors = ([ ]);

foreach( mapping t in map( keys( query_term_info( LIB_INTERFACE->GetTerminal() ) ),
(: ([ $1 : "%^" + $1 + "%^" ]) :) ) ){
m_colors = m_colors + t;
}
i_screenX = this_player()->GetScreen()[0];
if( i_width > i_screenX ){ i_width = i_screenX; }

sa_temptext1 = explode( terminal_colour( replace_string( s_str, "\t", "     " ), m_colors, i_width ), "\n" );
foreach( s_line in sa_temptext1 ){
i_count = sizeof( strip_colors( s_line ) );
if( i_count <= i_width ){ sa_temptext2 += ({ s_line + repeat_string( " ", i_width - i_count ) }); }
}
return sa_temptext2;
}

Offline detah

  • BFF
  • ***
  • Posts: 182
  • Ruler of 2D
    • View Profile
Re: Landmarks daemon
« Reply #6 on: June 12, 2012, 08:22:34 AM »
Something is wrong with this thread. It looks like ITALICS are on for every post. I did not use italics when I posted my previous comment. It looks like the problem started occurring 3 or 4 posts ago in the middle of the GetExtraLong fun.

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Re: Landmarks daemon
« Reply #7 on: June 15, 2012, 02:33:59 AM »
Heh.  Looks like the code-barf of the first post with room.c has [ i ] as an array item reference that's making everything after it italic.

Offline detah

  • BFF
  • ***
  • Posts: 182
  • Ruler of 2D
    • View Profile
Re: Landmarks daemon
« Reply #8 on: June 15, 2012, 08:39:41 AM »
BB code LOL. This is a test This is a second test.

Confirmed. Adding a single closing tag or adding a brand new set of italics tags does nothing to fix this problem. BB code LOL indeed.

Remove Formatting seems to do nothing.

Preview shows what you would expect the post to look like in the absence of this italics fiasco.  :-X
« Last Edit: June 15, 2012, 08:45:35 AM by detah »