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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines