Exit._pike
Go to the documentation of this file.
1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * $Id: Exit.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
18  */
19 inherit "/classes/Link";
20 #include <classes.h>
21 #include <types.h>
22 #include <macros.h>
23 #include <attributes.h>
24 class Exit : public Link{
25 public:
26 
27 
28 
29 
30 
31 protected:
32  void delete_object()
33 {
34  object link = get_link_object();
35  LOG("Deleting link object !");
36  // two connected exits -> remove both
37  if ( objectp(link) && link->get_object_class() & CLASS_EXIT ) {
38  oLinkObject = 0; // set link to null before that !
39  LOG("Deleting connected Link !");
40  link->delete();
41  }
42  }
43  ::delete_object();
44 }
45 
46 public:
47 
48 mapping do_duplicate(void|mapping vars)
49 {
50  if ( !mappingp(vars) )
51  vars = ([ ]);
52  vars->exit_to = oLinkObject;
53  return ::do_duplicate(vars);
54 }
55 
56 /**
57  * Get the destination of this exit. This might be another exit or
58  * a room.
59  *
60  * @return the destination
61  */
62 final object
63 get_exit()
64 {
65  object destination = get_link_object();
66  if ( objectp(destination) &&
67  destination->get_object_class() & CLASS_EXIT )
68  return destination->get_environment();
69 
70  return destination;
71 }
72 
73 object get_destination()
74 {
75  return get_exit();
76 }
77 
78 /**
79  * This function returns the stat() of this object. This has the
80  * same format as statting a file.
81  *
82  * @return status array as in file_stat()
83  * @see get_content_size
84  */
85 array stat()
86 {
87  int creator_id = objectp(get_creator())?get_creator()->get_object_id():0;
88 
89 
90  return ({ 16832, -2, time(), time(), time(),
91  creator_id, creator_id,
92  "httpd/uni-directory" });
93 }
94 
95 object get_icon()
96 {
97  object destination = get_link_object();
98  // get the icon of the exit depending on the target
99  object icon = destination->query_attribute(OBJ_LINK_ICON);
100  if ( !objectp(icon) )
101  return query_attribute(OBJ_ICON);
102  return icon;
103 }
104 
105 int get_object_class() { return ::get_object_class() | CLASS_EXIT; }
106 
107 
108 
109 };