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.6 by root, Wed Oct 21 00:44:39 2009 UTC vs.
Revision 1.13 by root, Sat Nov 17 23:40:02 2018 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines