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.8 by root, Sun Jan 10 19:21:47 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines