From 15c9d2f6fd6df82d45ab4de7b0c756abdcd4ee12 Mon Sep 17 00:00:00 2001 From: Sergiotarxz Date: Fri, 23 Jun 2023 01:48:22 +0200 Subject: [PATCH] Fixing redis bug. --- .../Controller/Websocket/InputPacket/Init.pm | 34 +++++++++++-------- .../Bahdder/BosqueDelHeroe/TribuDeLaLima.pm | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/LasTres/Controller/Websocket/InputPacket/Init.pm b/lib/LasTres/Controller/Websocket/InputPacket/Init.pm index 7ea1128..849160d 100644 --- a/lib/LasTres/Controller/Websocket/InputPacket/Init.pm +++ b/lib/LasTres/Controller/Websocket/InputPacket/Init.pm @@ -49,7 +49,6 @@ sub handle ( $self, $ws, $session, $data ) { my @friends = grep { $pj->uuid ne $_->uuid } @team_members; my $team_pjs = [ map { $_->hash } ( $pj, @friends ) ]; my $location = $team->location; - my $connected_places = $self->_get_connected_places($pj); $pj->append_log_line( [ @@ -77,6 +76,7 @@ sub handle ( $self, $ws, $session, $data ) { my $info_packet_to_send = LasTres::Controller::Websocket::OutputPacket::Info->new( set_log => [ $pj->last_50_log ], + $self->_location_data($pj), team_pjs => $team_pjs, clear => $JSON::true, ); @@ -90,8 +90,23 @@ sub handle ( $self, $ws, $session, $data ) { } ); $session->{redis} = $redis; - $redis->publish( $redis->pj_subscription($pj), - to_json( { command => 'update-location' } ) ); +} + +sub _location_data($self, $pj) { + my $connected_places = $self->_get_connected_places($pj); + my $team = $pj->team; + my $location = $team->location; + return ( + location_data => { + current => $location->hash, + ( + ( $team->is_moving ) + ? ( moving_to => LasTres::Location::get(@{from_json( $team->moving_to )})->hash ) + : () + ), + connected_places => $connected_places, + }, +); } sub _on_redis_event ( $self, $ws, $session, $message, $topic, $topics ) { @@ -106,20 +121,9 @@ sub _on_redis_event ( $self, $ws, $session, $message, $topic, $topics ) { return; } if ( $data->{command} eq 'update-location' ) { - my $team = $pj->team; - my $location = $team->location; - my $connected_places = $self->_get_connected_places($pj); my $info_packet_to_send = LasTres::Controller::Websocket::OutputPacket::Info->new( - location_data => { - current => $location->hash, - ( - ( $team->is_moving ) - ? ( moving_to => LasTres::Location::get(@{from_json( $team->moving_to )})->hash ) - : () - ), - connected_places => $connected_places, - }, + $self->_location_data($pj) ); $info_packet_to_send->send($ws); diff --git a/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/TribuDeLaLima.pm b/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/TribuDeLaLima.pm index 684ccb2..9202dff 100644 --- a/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/TribuDeLaLima.pm +++ b/lib/LasTres/Planet/Bahdder/BosqueDelHeroe/TribuDeLaLima.pm @@ -27,7 +27,7 @@ sub get_auto_discover($self) { } sub frames_to_move { - return 1; + return 0; } sub identifier {