Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed small forgotten reference bug and added query functionality.

  • Loading branch information...
commit 99137f4460c6c5099bdc5caadc5449b8f9b6cd97 1 parent 3dd4fe9
@elmex elmex authored
View
6 KNOWN_BUGS
@@ -0,0 +1,6 @@
+- Opening a new UI dialog while a key is pressed leads to
+ keyrepeats in the non-visible window. Currently the server needs
+ to be very clean w.r.t. opening/closing windows.
+
+- Pending timer events might have a reference to a partly destructed player
+ object. Think of a better way to handle logouts and player destruction.
View
10 lib/Games/Construder/Server/Objects.pm
@@ -17,25 +17,21 @@ Games::Construder::Server::Objects - desc
=cut
-our $PL;
-our $POS;
-
our %TYPES = (
36 => \&ia_construction_pad,
);
sub interact {
my ($player, $type, $pos) = @_;
- $PL = $player;
- $POS = $pos;
-
my $cb = $TYPES{$type}
or return;
- $cb->();
+ $cb->($player, $pos);
}
sub ia_construction_pad {
+ my ($PL, $POS) = @_;
+
my $a = Games::Construder::World::get_pattern (@$POS, 0);
if ($a) {
my $obj = $Games::Construder::Server::RES->get_object_by_pattern ($a);
View
16 lib/Games/Construder/Server/Player.pm
@@ -362,7 +362,7 @@ sub logout {
delete $self->{upd_score_hl_tmout};
delete $self->{death_timer};
warn "player $self->{name} logged out\n";
- #d# print Devel::FindRef::track $self;
+ print Devel::FindRef::track $self;
}
my $world_c = 0;
@@ -490,6 +490,20 @@ sub update_score {
# TODO: Continue here with UI rewrite:
+sub query {
+ my ($self, $pos) = @_;
+ return unless @$pos;
+
+ world_mutate_at ($pos, sub {
+ my ($data) = @_;
+ if ($data->[0]) {
+ $self->{uis}->{material_view}->show ($data->[0]);
+ }
+ return 0;
+ });
+
+}
+
sub interact {
my ($self, $pos) = @_;
warn "INTERACT: @$pos\n";
View
3  lib/Games/Construder/Server/UI.pm
@@ -281,6 +281,7 @@ sub commands {
c => "cheat",
t => "location_book",
e => "interact",
+ q => "query",
)
}
@@ -303,6 +304,8 @@ sub handle_command {
$pl->teleport ([0, 0, 0]);
} elsif ($cmd eq 'interact') {
$pl->interact ($pos->[0]) if @{$pos->[0] || []};
+ } elsif ($cmd eq 'query') {
+ $pl->query ($pos->[0]);
} elsif ($cmd eq 'exit_server') {
exit;
}
Please sign in to comment.
Something went wrong with that request. Please try again.