[an error occurred while processing this directive]
[<a href="index.shtml">Package Index</a></code> | <a href="index_std.shtml">Mudlib Index</a></code> | <a href="index_eff.shtml">Effect Index</a></code>]<br><h2>File /d/am/inherit/am_prison.c</h2>
Inherit for the prisons in Ankh-Morpork.
Handles stuff such as confiscating weapons and magic equipment, removing
illegal items from players, whiping their item-savefiles on refresh and
delete.
There is no NPC as the guard, since that would open ways of harrassment by
letting players keep other players in jail for long.
Uses two mappings to store information, the first one "_cells" stores the
filenames of the cells belonging to the prison with the security-level
as the key.
The second one, "_prisoners" stores entries of the prisoner-class with
the player's name as the key.
<h2>Inherits</h2>
This class inherits the following classes <a href="cmds.speech.c.shtml">/cmds/speech.c</a> and .c<h2>Includes</h2>
This class includes the following files <a href="include.login_handler.h.shtml">/include/login_handler.h</a>, <a href="include.move_failures.h.shtml">/include/move_failures.h</a>, <a href="include.money.h.shtml">/include/money.h</a>, <a href="include.am_time.h.shtml">/include/am_time.h</a>, <a href="include.armoury.h.shtml">/include/armoury.h</a>, <a href="include.player_handler.h.shtml">/include/player_handler.h</a>, <a href="include.login.h.shtml">/include/login.h</a>, /include/shops/bank.h, <a href="include.language.h.shtml">/include/language.h</a>, <a href="include.chime.h.shtml">/include/chime.h</a>, /d/am/include/amcw.h and /d/am/inherit/path.h<h2>Class Index</h2>
<ul><li><a href="#class_prisoner">prisoner</a>
<br/>Class used to store the data for prisoners.
</ul><h2>Method index</h2>
<dl><ul>
<li><a href="#add_cell">add_cell</a>(string, int)<br/>
This function adds a cell to the prison.
<li><a href="#add_prisoner">add_prisoner</a>(object, int)<br/>
This function adds a player as a prisoner.
<li><a href="#calculate_bail">calculate_bail</a>(string)<br/>
Calculates the amount of money-units that bailing a player at this time
costs.
<li><a href="#check_prisoners">check_prisoners</a>()<br/>
This function is called by chime() to release all prisoners whos sentence
is over and reduce the time left for those who have to stay a bit longer.
<li><a href="#clean_records">clean_records</a>()<br/>
This function goes through the prisoner records and removes every one which
does not have a valid user as the key.
<li><a href="#confiscate_items">confiscate_items</a>(object, object, int)<li><a href="#do_bail_info">do_bail_info</a>(string)<br/>
This command gives the player info on how much it will cost to bail another
player.
<li><a href="#do_bail_out">do_bail_out</a>(object)<br/>
 This command bails a player from prison.
<li><a href="#do_imprison">do_imprison</a>(object)<br/>
The command used to imprison a criminal.
<li><a href="#do_release">do_release</a>(string)<br/>
This function is called when a player is due to be released from prison.
<li><a href="#do_return_stuff">do_return_stuff</a>(string)<br/>
This function loads a player's confiscated items, then calls out
get_stuff_from_container to actually return the items.
<li><a href="#event_lockpick">event_lockpick</a>(object, object, int)<li><a href="#get_stuff_from_container">get_stuff_from_container</a>(string)<br/>
Function which moves the items from a player's container back to the player.
<li><a href="#lock_cells">lock_cells</a>()<br/>
This function closes all cell-doors and locks them.
<li><a href="#perform_container_merge">perform_container_merge</a>(object, object)<li><a href="#prisoner_escape">prisoner_escape</a>(string)<br/>
This function is called by the cells if a player inside them leaves without
haveing the "being released from prison"-property on him.
<li><a href="#prisoner_login">prisoner_login</a>(string)<br/>
This function is called by the cells if a player logs in inside them.
<li><a href="#prisoner_net_dead">prisoner_net_dead</a>(string)<br/>
This function is called by the cells if a player inside them goes net-dead.
<li><a href="#prisoner_quit">prisoner_quit</a>(string)<br/>
This function is called by the cells if a player inside them quits.
<li><a href="#prisoner_refresh">prisoner_refresh</a>(string)<br/>
This function is called by the watch-handler if a registered criminal
refreshes or deletes.
<li><a href="#prisoner_release">prisoner_release</a>(string)<br/>
This function is used to delete a prisoner from the prisoners-mapping and
return his confiscated items.
<li><a href="#query_cells">query_cells</a>()<br/>
This function returns the filenames of all the cells associated with this
prison.
<li><a href="#query_prison">query_prison</a>()<br/>
Function to verify this is a prison.
<li><a href="#query_prisoner">query_prisoner</a>(string)<br/>
This function checks whether the specified player is a valid prisoner.
<li><a href="#query_prisoners">query_prisoners</a>()<br/>
Function to return the _prisoners-mapping.
<li><a href="#query_savepath">query_savepath</a>()<br/>
Queries the path where the prison saves everything.
<li><a href="#query_tells_used">query_tells_used</a>(string)<br/>
This function returns how many tells a prisoner has used.
<li><a href="#query_time_left">query_time_left</a>(string)<li><a href="#remove_cell">remove_cell</a>(int)<br/>
This function removes a cell from the prison.
<li><a href="#remove_corpse">remove_corpse</a>()<br/>
This function removes all corpses from all cells and dumps them here.
<li><a href="#return_boxed_items">return_boxed_items</a>(object, object)<li><a href="#send_away_npcs">send_away_npcs</a>()<br/>
This functions clears up all NPCs in the room, since for some reasons they
tend to pile up.
<li><a href="#set_guard">set_guard</a>(string)<br/>
This sets the name of the guard to use.
<li><a href="#set_savepath">set_savepath</a>(string)<br/>
This sets the path where the prison shall store its savefile and those of
the prisoners.
<li><a href="#tell_time_left">tell_time_left</a>(object)<br/>
This function tells a player how much time he has left to serve.
<li><a href="#tell_used">tell_used</a>(string)<br/>
This function is called when a prisoner uses up a tell.
<li><a href="#throw_out">throw_out</a>(object)<br/>
This function throws a player out of prison if he doesn't belong there.
<li><a href="#time_passed_in_quarter_hour">time_passed_in_quarter_hour</a>()<br/>
This function calculates the time necessary to correct the quarter-hour
reducing of the sentence directly after imprisonment.
</ul><h2>Public Functions</h2>
These are functions that everyone can access.<p>
.<ul><a name="add_cell">
add_cell</a><pre>
int add_cell(string cell,
             int security)
</pre></br>
This function adds a cell to the prison.  At the moment only one cell is
permitted per security level.
<br/><ul>
<li><b>Parameters:</b>
<br/>cell - the filename of the cell
<br/>security - the level of security, as defined in amcw.h
<li><b>Returns:</b>
<br/>1 on success, 0 on failure

</dl>

<ul><a name="add_prisoner">
add_prisoner</a><pre>
void add_prisoner(object prisoner,
                  int security)
</pre></br>
This function adds a player as a prisoner. Creates the container where to
store his item.s
<br/><ul>
<li><b>Parameters:</b>
<br/>prisoner - the player
<br/>security - The security-level of the cell the player will be thrown into

</dl>

<ul><a name="calculate_bail">
calculate_bail</a><pre>
int calculate_bail(string name)
</pre></br>
Calculates the amount of money-units that bailing a player at this time
costs.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the player
<li><b>Returns:</b>
<br/>the cost or -1 on failure

</dl>

<ul><a name="check_prisoners">
check_prisoners</a><pre>
void check_prisoners()
</pre></br>
This function is called by chime() to release all prisoners whos sentence
is over and reduce the time left for those who have to stay a bit longer.


<ul><a name="clean_records">
clean_records</a><pre>
void clean_records()
</pre></br>
This function goes through the prisoner records and removes every one which
does not have a valid user as the key.


<ul><a name="confiscate_items">
confiscate_items</a><pre>
void confiscate_items(object prisoner,
                      object container,
                      int security)
</pre>
<ul><a name="do_bail_info">
do_bail_info</a><pre>
int do_bail_info(string name)
</pre></br>
This command gives the player info on how much it will cost to bail another
player.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the target's name
<li><b>Returns:</b>
<br/>1 on success, 0 on failure

</dl>

<ul><a name="do_bail_out">
do_bail_out</a><pre>
int do_bail_out(object player)
</pre></br>
 This command bails a player from prison.
<br/><ul>
<li><b>Parameters:</b>
<br/>player - the player to bail
<li><b>Returns:</b>
<br/>1 on success, 0 on failure

</dl>

<ul><a name="do_imprison">
do_imprison</a><pre>
int do_imprison(object player)
</pre></br>
The command used to imprison a criminal.  Gets the security level, removes
the arrested-effect and turns the player over to the prison.
NPCs are moved to the rubbish room.
<br/><ul>
<li><b>Parameters:</b>
<br/>player - the target of imprisonment
<li><b>Returns:</b>
<br/>1 on success, 0 on failure

</dl>

<ul><a name="do_release">
do_release</a><pre>
void do_release(string name)
</pre></br>
This function is called when a player is due to be released from prison.
Adds the "being released from prison"-property to prevent a player from
running while his stuff is being returned.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the player

</dl>

<ul><a name="do_return_stuff">
do_return_stuff</a><pre>
void do_return_stuff(string name)
</pre></br>
This function loads a player's confiscated items, then calls out
get_stuff_from_container to actually return the items.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the player

</dl>

<ul><a name="event_lockpick">
event_lockpick</a><pre>
void event_lockpick(object ob,
                    object player,
                    int success)
</pre>
<ul><a name="get_stuff_from_container">
get_stuff_from_container</a><pre>
void get_stuff_from_container(string name)
</pre></br>
Function which moves the items from a player's container back to the player.
If he can't carry them for any reason, they are dropped onto the floor.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the prisoner

</dl>

<ul><a name="lock_cells">
lock_cells</a><pre>
void lock_cells()
</pre></br>
This function closes all cell-doors and locks them.


<ul><a name="perform_container_merge">
perform_container_merge</a><pre>
void perform_container_merge(object container,
                             object box)
</pre>
<ul><a name="prisoner_escape">
prisoner_escape</a><pre>
void prisoner_escape(string name)
</pre></br>
This function is called by the cells if a player inside them leaves without
haveing the "being released from prison"-property on him.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the player

</dl>

<ul><a name="prisoner_login">
prisoner_login</a><pre>
void prisoner_login(string name)
</pre></br>
This function is called by the cells if a player logs in inside them.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the player

</dl>

<ul><a name="prisoner_net_dead">
prisoner_net_dead</a><pre>
void prisoner_net_dead(string name)
</pre></br>
This function is called by the cells if a player inside them goes net-dead.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the player

</dl>

<ul><a name="prisoner_quit">
prisoner_quit</a><pre>
void prisoner_quit(string name)
</pre></br>
This function is called by the cells if a player inside them quits.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the player

</dl>

<ul><a name="prisoner_refresh">
prisoner_refresh</a><pre>
void prisoner_refresh(string name)
</pre></br>
This function is called by the watch-handler if a registered criminal
refreshes or deletes. If he's got any items in this prison, the files are
erased.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the player

</dl>

<ul><a name="prisoner_release">
prisoner_release</a><pre>
void prisoner_release(string name)
</pre></br>
This function is used to delete a prisoner from the prisoners-mapping and
return his confiscated items.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the player

</dl>

<ul><a name="query_cells">
query_cells</a><pre>
string * query_cells()
</pre></br>
This function returns the filenames of all the cells associated with this
prison.
<br/><ul>
<li><b>Returns:</b>
<br/>an array containing the filenames

</dl>

<ul><a name="query_prison">
query_prison</a><pre>
int query_prison()
</pre></br>
Function to verify this is a prison.
<br/><ul>
<li><b>Returns:</b>
<br/>1

</dl>

<ul><a name="query_prisoner">
query_prisoner</a><pre>
int query_prisoner(string name)
</pre></br>
This function checks whether the specified player is a valid prisoner.
<br/><ul>
<li><b>Parameters:</b>
<br/>name - the name of the player
<li><b>Returns:</b>
<br/>1 if he is a prisoner, 0 if not

</dl>

<ul><a name="query_prisoners">
query_prisoners</a><pre>
mapping query_prisoners()
</pre></br>
Function to return the _prisoners-mapping.  The elements are of the
prisoner-class.
<br/><ul>
<li><b>Returns:</b>
<br/>the mapping

</dl>

<ul><a name="query_savepath">
query_savepath</a><pre>
string query_savepath()
</pre></br>
Queries the path where the prison saves everything.
<br/><ul>
<li><b>Returns:</b>
<br/>the path

</dl>

<ul><a name="query_tells_used">
query_tells_used</a><pre>
int query_tells_used(string name)
</pre></br>
This function returns how many tells a prisoner has used.
<br/><ul>
<li><b>Parameters:</b>
<br/>the - name of the player
<li><b>Returns:</b>
<br/>the number of tells used, -1 on failure

</dl>

<ul><a name="query_time_left">
query_time_left</a><pre>
int query_time_left(string name)
</pre>
<ul><a name="remove_cell">
remove_cell</a><pre>
int remove_cell(int security)
</pre></br>
This function removes a cell from the prison.
<br/><ul>
<li><b>Parameters:</b>
<br/>security - the level of security, as defined in amcw.h
<li><b>Returns:</b>
<br/>1 on success, 0 on failure

</dl>

<ul><a name="remove_corpse">
remove_corpse</a><pre>
void remove_corpse()
</pre></br>
This function removes all corpses from all cells and dumps them here.


<ul><a name="return_boxed_items">
return_boxed_items</a><pre>
void return_boxed_items(object prisoner,
                        object container)
</pre>
<ul><a name="send_away_npcs">
send_away_npcs</a><pre>
void send_away_npcs()
</pre></br>
This functions clears up all NPCs in the room, since for some reasons they
tend to pile up.
Fighting NPCs are ignored.
If the NPC does not have any move zones, it is assumed it is not supposed to
wander around and moved to the rubbish room.  If it does have one which is
not Ankh-Morpork, add AM and send it away.
Otherwise ignore it.


<ul><a name="set_guard">
set_guard</a><pre>
int set_guard(string name)
</pre></br>
This sets the name of the guard to use.
<br/><ul>
<li><b>Parameters:</b>
<br/>the - name to use, i.e. "Sergeant Flint"
<li><b>Returns:</b>
<br/>1 on success, 0 on failure

</dl>

<ul><a name="set_savepath">
set_savepath</a><pre>
int set_savepath(string path)
</pre></br>
This sets the path where the prison shall store its savefile and those of
the prisoners.
<br/><ul>
<li><b>Parameters:</b>
<br/>path - The path to use
<li><b>Returns:</b>
<br/>1 on success, 0 on failure

</dl>

<ul><a name="tell_time_left">
tell_time_left</a><pre>
void tell_time_left(object player)
</pre></br>
This function tells a player how much time he has left to serve.
<br/><ul>
<li><b>Parameters:</b>
<br/>player - the player

</dl>

<ul><a name="tell_used">
tell_used</a><pre>
void tell_used(string name)
</pre></br>
This function is called when a prisoner uses up a tell.
<br/><ul>
<li><b>Parameters:</b>
<br/>the - name of the player

</dl>

<ul><a name="throw_out">
throw_out</a><pre>
void throw_out(object player)
</pre></br>
This function throws a player out of prison if he doesn't belong there.
<br/><ul>
<li><b>Parameters:</b>
<br/>player - the player

</dl>

<ul><a name="time_passed_in_quarter_hour">
time_passed_in_quarter_hour</a><pre>
int time_passed_in_quarter_hour()
</pre></br>
This function calculates the time necessary to correct the quarter-hour
reducing of the sentence directly after imprisonment.


<h2>Classes</h2>
These are nice data types for dealing with...  Data!<p>
<ul>
<li><a name="class_prisoner">
prisoner</a><pre>
class prisoner {
                 int cell;
                 int time_to_serve;
                 int logged_on;
                 int confiscated;
                 int tells_used;
}

</pre><br/>Class used to store the data for prisoners.
cell - an integer representing the security level, as defined in amcw.h
time_to_serve - how long the sentence will be, in seconds
logged_on - no longer used
confiscated - 1 if items have been confiscated, 0 if not
tells_used - the number of tells used by the player
<p>

</ul>
[an error occurred while processing this directive]

