ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf/mapscript.pm
(Generate patch)

Comparing deliantra/server/lib/cf/mapscript.pm (file contents):
Revision 1.7 by root, Tue Nov 3 23:44:21 2009 UTC vs.
Revision 1.12 by root, Tue Nov 6 21:52:55 2012 UTC

1#! perl
2
3# 1#
4# This file is part of Deliantra, the Roguelike Realtime MMORPG. 2# This file is part of Deliantra, the Roguelike Realtime MMORPG.
5# 3#
6# Copyright (©) 2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4# Copyright (©) 2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
7# 5#
8# Deliantra is free software: you can redistribute it and/or modify it under 6# Deliantra is free software: you can redistribute it and/or modify it under
9# the terms of the Affero GNU General Public License as published by the 7# the terms of the Affero GNU General Public License as published by the
10# Free Software Foundation, either version 3 of the License, or (at your 8# Free Software Foundation, either version 3 of the License, or (at your
11# option) any later version. 9# option) any later version.
12# 10#
13# This program is distributed in the hope that it will be useful, 11# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details. 14# GNU General Public License for more details.
17# 15#
18# You should have received a copy of the Affero GNU General Public License 16# You should have received a copy of the Affero GNU General Public License
19# and the GNU General Public License along with this program. If not, see 17# and the GNU General Public License along with this program. If not, see
20# <http://www.gnu.org/licenses/>. 18# <http://www.gnu.org/licenses/>.
21# 19#
22# The authors can be reached via e-mail to <support@deliantra.net> 20# The authors can be reached via e-mail to <support@deliantra.net>
23# 21#
24 22
25=head1 NAME 23=head1 NAME
26 24
40 38
41=over 4 39=over 4
42 40
43=cut 41=cut
44 42
45package safe::mapscript; 43package cf::mapscript::eval;
46 44
47use common::sense; 45use common::sense;
48 46
49=item $self 47=item $self
50 48
64The object that triggered the activator, usually (but not always) the 62The object that triggered the activator, usually (but not always) the
65player who stepped on a check inv, pulled a lever etc. Can be C<undef>. 63player who stepped on a check inv, pulled a lever etc. Can be C<undef>.
66 64
67=cut 65=cut
68 66
69our ($self, $state, $activator, $originator); 67use vars qw($self $state $activator $originator);
70 68
71=item @obs = find $id_or_object 69=item @obs = find $id_or_object
72 70
73Finds all objects with the given I<connected> C<$id>. If an object 71Finds all objects with the given I<connected> C<$id>. If an object
74reference is passed, it will be returned unchanged. 72reference is passed, it will be returned unchanged.
81} 79}
82 80
83=item trigger $id_or_object[, $state] 81=item trigger $id_or_object[, $state]
84 82
85Triggers the linked chain with the given I<connected> id, or the connected 83Triggers the linked chain with the given I<connected> id, or the connected
86chain associated with the given object (if an objetc reference is passed), 84chain associated with the given object (if an object reference is passed),
87and passes the given state (or C<1>, if missing) to it. 85and passes the given state (or C<1>, if missing) to it.
88 86
89=cut 87=cut
90 88
91sub trigger($;$) { 89sub trigger($;$) {
92 $self->map->trigger ($_[0], $#_ ? $_[1] : 1, $self); 90 $self->map->trigger ($_[0], $#_ ? $_[1] : 1, $self);
93} 91}
94 92
95=item timer $id_or_object, $seconds 93=item timer $id_or_object, $seconds
96 94
97Starts the timer on the given mapscript object (usually, $id_or_object is 95Starts the timer on the given mapscript object (usually, C<$id_or_object> is
98C<$self>). When the timer expires on the mapscript object, it will trigger 96C<$self>). When the timer expires on the mapscript object, it will trigger
99the script with C<$activator == $self> and C<$originator == undef>. 97the script with C<$activator == $self> and C<$originator == undef>.
100 98
101=cut 99=cut
102 100
106 $ob->set_speed (1); 104 $ob->set_speed (1);
107} 105}
108 106
109package cf::mapscript; 107package cf::mapscript;
110 108
111use strict qw(subs vars); 109use common::sense;
110
111*{"main::safe::cf::mapscript::eval::"} = \%{"main::cf::mapscript::eval::"};
112 112
113our %CACHE; 113our %CACHE;
114 114
115sub activate($$$) { 115sub activate($$$) {
116 package cf::mapscript::eval;
117
116 ($self, $state, $activator, $originator) = @_; 118 ($self, $state, $activator, $originator) = @_;
117 119
118 ( 120 (
119 $CACHE{$self->msg} ||= cf::safe_eval 121 $CACHE{$self->msg} ||= cf::safe_eval
120 "package mapscript; sub {\n" 122 "package cf::mapscript::eval; sub {\n"
121 . "#line 1 '" . ($self->debug_desc) . "'\n" 123 . "#line 1 '" . ($self->debug_desc) . "'\n"
122 . $self->msg 124 . $self->msg
123 . "\n}" 125 . "\n}"
124 or sub { } 126 or sub { }
125 )->(); 127 )->();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines