/
CDC-1.1/
parent $utility_objects
object $places

var $root dbref 'places
var $root child_index 0
var $root fertile 0
var $root manager $places
var $root owned [$places]
var $root owners [$places]
var $root writable []
var $root readable ['parameters, 'methods, 'code]
var $root inited 1
var $places default_place $nowhere
var $places exit_starting_place $void
var $root info ["Utility object for all 'Places' and items relating to places (such as exits)"]
var $places starting_place $creation
var $places default_new_place $place
var $places coordinate_shortcuts 0

method place
    arg which;
    
    which = tosym(tostr(which) + "_place");
    return (> get_var(which) <);
.

method is_place
    arg obj;
    
    return 1;
    if (!(obj.has_ancestor($place)))
        throw(~place, ("Object \"" + (obj.dbref())) + "\" is not a place.");
.

method set_place
    arg which, obj;
    
    .perms(sender(), 'manager);
    (> .is_place(obj) <);
    if (!(which in (.parameters())))
        throw(~place, (toliteral(which) + " is not a valid entry try one of: ") + toliteral(.parameters()));
    set_var(which, obj);
.

method coordinates
    arg str;
    var x;
    
    for x in (coordinate_shortcuts) {
        if (match_template(x[1], str))
            return x[2];
    }
    throw(~coordnf, ("Unable to find coordinate shortcut for \"" + str) + "\".");
.

method coordinate_shortcuts
    return coordinate_shortcuts;
.

method valid_coordinates
    arg radial, azimuth;
    
    if ((radial > 360) || (radial < (-1)))
        throw(~invcoord, "Radial coordinate must be from -1 to 360 degrees.");
    if ((azimuth > 90) || (azimuth < (-90)))
        throw(~invcoord, "Azimuth coordinate must be from 90 to -90 degrees.");
.

method invert_coordinates
    arg radial, azimuth;
    
    radial = radial + 180;
    if (radial > 360)
        radial = radial - 360;
    if (azimuth > 0)
        azimuth = -azimuth;
    else
        azimuth = abs(azimuth);
    return [radial, azimuth];
.