lace.events: Fix bugs.
This commit is contained in:
@@ -72,6 +72,11 @@ is
|
|||||||
Sequence : in sequence_Id)
|
Sequence : in sequence_Id)
|
||||||
is
|
is
|
||||||
begin
|
begin
|
||||||
|
if not Self.sequence_Id_Map.contains (from_Subject)
|
||||||
|
then
|
||||||
|
Self.sequence_Id_Map.insert (from_Subject, 0);
|
||||||
|
end if;
|
||||||
|
|
||||||
Self.Responses.receive (Self, the_Event, from_Subject);
|
Self.Responses.receive (Self, the_Event, from_Subject);
|
||||||
end receive;
|
end receive;
|
||||||
|
|
||||||
@@ -146,6 +151,11 @@ is
|
|||||||
begin
|
begin
|
||||||
my_Responses.Element (from_Subject).delete (to_Kind);
|
my_Responses.Element (from_Subject).delete (to_Kind);
|
||||||
|
|
||||||
|
if my_Responses.Element (from_Subject).is_Empty
|
||||||
|
then
|
||||||
|
Self.sequence_Id_Map.delete (from_Subject);
|
||||||
|
end if;
|
||||||
|
|
||||||
if Observer.Logger /= null
|
if Observer.Logger /= null
|
||||||
then
|
then
|
||||||
Observer.Logger.log_rid_Response (the_Response,
|
Observer.Logger.log_rid_Response (the_Response,
|
||||||
|
|||||||
@@ -140,4 +140,5 @@ private
|
|||||||
sequence_Id_Map : Containers.name_Map_of_sequence_Id; -- Contains the next expected sequence ID from each subject.
|
sequence_Id_Map : Containers.name_Map_of_sequence_Id; -- Contains the next expected sequence ID from each subject.
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
|
|
||||||
end lace.event.make_Observer;
|
end lace.event.make_Observer;
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ with
|
|||||||
system.RPC,
|
system.RPC,
|
||||||
ada.unchecked_Deallocation;
|
ada.unchecked_Deallocation;
|
||||||
|
|
||||||
|
with ada.Text_IO; use ada.Text_IO;
|
||||||
|
|
||||||
|
|
||||||
package body lace.event.make_Subject
|
package body lace.event.make_Subject
|
||||||
is
|
is
|
||||||
@@ -88,7 +90,7 @@ is
|
|||||||
of_Kind : in Event.Kind)
|
of_Kind : in Event.Kind)
|
||||||
is
|
is
|
||||||
begin
|
begin
|
||||||
Self.safe_Observers.rid (the_Observer, of_Kind);
|
Self.safe_Observers.rid (the_Observer, of_Kind, Self.sequence_Id_Map);
|
||||||
|
|
||||||
if Subject.Logger /= null
|
if Subject.Logger /= null
|
||||||
then
|
then
|
||||||
@@ -297,7 +299,7 @@ is
|
|||||||
use event_Observer_Vectors,
|
use event_Observer_Vectors,
|
||||||
event_kind_Maps_of_event_observers;
|
event_kind_Maps_of_event_observers;
|
||||||
|
|
||||||
Cursor : constant event_kind_Maps_of_event_observers.Cursor := the_Observers.find (of_Kind);
|
Cursor : constant event_kind_Maps_of_event_observers.Cursor := the_Observers.find (of_Kind);
|
||||||
the_event_Observers : event_Observer_Vector_view;
|
the_event_Observers : event_Observer_Vector_view;
|
||||||
begin
|
begin
|
||||||
if has_Element (Cursor)
|
if has_Element (Cursor)
|
||||||
@@ -314,12 +316,39 @@ is
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
procedure rid (the_Observer : in Observer.view;
|
procedure rid (the_Observer : in Observer.view;
|
||||||
of_Kind : in Event.Kind)
|
of_Kind : in Event.Kind;
|
||||||
|
sequence_Id_Map : in out Containers.safe_sequence_Id_Map)
|
||||||
is
|
is
|
||||||
the_event_Observers : event_Observer_Vector renames the_Observers.Element (of_Kind).all;
|
the_event_Observers : event_Observer_Vector renames the_Observers.Element (of_Kind).all;
|
||||||
begin
|
begin
|
||||||
the_event_Observers.delete (the_event_Observers.find_Index (the_Observer));
|
the_event_Observers.delete (the_event_Observers.find_Index (the_Observer));
|
||||||
|
|
||||||
|
declare
|
||||||
|
Found : Boolean := False;
|
||||||
|
begin
|
||||||
|
for each_of_the_event_Observers of the_Observers
|
||||||
|
loop
|
||||||
|
declare
|
||||||
|
the_event_Observers : event_Observer_Vector renames each_of_the_event_Observers.all;
|
||||||
|
begin
|
||||||
|
for each_Observer of the_event_Observers
|
||||||
|
loop
|
||||||
|
if each_Observer = the_Observer
|
||||||
|
then
|
||||||
|
Found := True;
|
||||||
|
exit;
|
||||||
|
end if;
|
||||||
|
end loop;
|
||||||
|
end;
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
if not Found
|
||||||
|
then
|
||||||
|
sequence_Id_Map.rid (the_Observer.Name);
|
||||||
|
end if;
|
||||||
|
|
||||||
|
end;
|
||||||
end rid;
|
end rid;
|
||||||
|
|
||||||
|
|
||||||
@@ -347,7 +376,7 @@ is
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function observer_Count return Natural
|
function observer_Count return Natural -- TODO: This is wrong.
|
||||||
is
|
is
|
||||||
use event_kind_Maps_of_event_observers;
|
use event_kind_Maps_of_event_observers;
|
||||||
|
|
||||||
|
|||||||
@@ -121,8 +121,9 @@ private
|
|||||||
procedure add (the_Observer : in Observer.view;
|
procedure add (the_Observer : in Observer.view;
|
||||||
of_Kind : in Event.Kind);
|
of_Kind : in Event.Kind);
|
||||||
|
|
||||||
procedure rid (the_Observer : in Observer.view;
|
procedure rid (the_Observer : in Observer.view;
|
||||||
of_Kind : in Event.Kind);
|
of_Kind : in Event.Kind;
|
||||||
|
sequence_Id_Map : in out Containers.safe_sequence_Id_Map);
|
||||||
|
|
||||||
function fetch_Observers (of_Kind : in Event.Kind) return Subject.Observer_views;
|
function fetch_Observers (of_Kind : in Event.Kind) return Subject.Observer_views;
|
||||||
function observer_Count return Natural;
|
function observer_Count return Natural;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ is
|
|||||||
|
|
||||||
procedure get_Next (Id : out event.sequence_Id;
|
procedure get_Next (Id : out event.sequence_Id;
|
||||||
for_Name : in String);
|
for_Name : in String);
|
||||||
procedure decrement (for_Name : in String);
|
procedure decrement (for_Name : in String); -- TODO: Rid.
|
||||||
|
|
||||||
private
|
private
|
||||||
the_Map : name_Map_of_sequence_Id;
|
the_Map : name_Map_of_sequence_Id;
|
||||||
|
|||||||
@@ -136,6 +136,11 @@ is
|
|||||||
begin
|
begin
|
||||||
if Self.Responses.contains (subject_Name.all)
|
if Self.Responses.contains (subject_Name.all)
|
||||||
then
|
then
|
||||||
|
if not Self.sequence_Id_Map.contains (subject_Name.all)
|
||||||
|
then
|
||||||
|
Self.sequence_Id_Map.insert (subject_Name.all, 0);
|
||||||
|
end if;
|
||||||
|
|
||||||
Sorter.sort (the_Events);
|
Sorter.sort (the_Events);
|
||||||
actuate (Self.Responses.Element (subject_Name.all),
|
actuate (Self.Responses.Element (subject_Name.all),
|
||||||
the_Events,
|
the_Events,
|
||||||
|
|||||||
@@ -786,7 +786,8 @@ is
|
|||||||
if the_Collision.near_Sprite /= null
|
if the_Collision.near_Sprite /= null
|
||||||
then
|
then
|
||||||
declare
|
declare
|
||||||
sprite_clicked_Event : constant gel.Events.sprite_click_down_Event := (mouse_Button => the_Event.Button,
|
sprite_clicked_Event : constant gel.Events.sprite_click_down_Event := (Sprite => the_Collision.near_Sprite.Id,
|
||||||
|
mouse_Button => the_Event.Button,
|
||||||
world_Site => Site_world_space);
|
world_Site => Site_world_space);
|
||||||
begin
|
begin
|
||||||
the_Collision.near_Sprite.emit (sprite_clicked_Event);
|
the_Collision.near_Sprite.emit (sprite_clicked_Event);
|
||||||
@@ -805,7 +806,8 @@ is
|
|||||||
if the_Collision.near_Sprite /= null
|
if the_Collision.near_Sprite /= null
|
||||||
then
|
then
|
||||||
declare
|
declare
|
||||||
sprite_clicked_Event : constant gel.Events.sprite_click_down_Event := (mouse_Button => the_Event.Button,
|
sprite_clicked_Event : constant gel.Events.sprite_click_down_Event := (Sprite => the_Collision.near_Sprite.Id,
|
||||||
|
mouse_Button => the_Event.Button,
|
||||||
world_Site => the_Collision.Site_world);
|
world_Site => the_Collision.Site_world);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@@ -855,8 +857,6 @@ is
|
|||||||
|
|
||||||
Site_world_space : constant Vector_3 := the_Camera.to_world_Site (Site_window_space);
|
Site_world_space : constant Vector_3 := the_Camera.to_world_Site (Site_window_space);
|
||||||
|
|
||||||
sprite_Event : constant gel.Events.sprite_click_up_Event := (mouse_Button => the_Event.Button,
|
|
||||||
world_Site => Site_world_space);
|
|
||||||
begin
|
begin
|
||||||
case the_world_Info.World.space_Kind
|
case the_world_Info.World.space_Kind
|
||||||
is
|
is
|
||||||
@@ -865,10 +865,16 @@ is
|
|||||||
the_Collision : ray_Collision := the_world_Info.World.cast_Ray (From => the_Camera.Site,
|
the_Collision : ray_Collision := the_world_Info.World.cast_Ray (From => the_Camera.Site,
|
||||||
To => Site_world_space);
|
To => Site_world_space);
|
||||||
begin
|
begin
|
||||||
if the_Collision.near_Sprite /= null
|
declare
|
||||||
then
|
click_Event : constant gel.Events.sprite_click_up_Event := (Sprite => the_Collision.near_Sprite.Id,
|
||||||
the_Collision.near_Sprite.emit (sprite_Event);
|
mouse_Button => the_Event.Button,
|
||||||
end if;
|
world_Site => Site_world_space);
|
||||||
|
begin
|
||||||
|
if the_Collision.near_Sprite /= null
|
||||||
|
then
|
||||||
|
the_Collision.near_Sprite.emit (click_Event);
|
||||||
|
end if;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
when physics.Box2D =>
|
when physics.Box2D =>
|
||||||
@@ -881,7 +887,13 @@ is
|
|||||||
begin
|
begin
|
||||||
if the_Collision.near_Sprite /= null
|
if the_Collision.near_Sprite /= null
|
||||||
then
|
then
|
||||||
the_Collision.near_Sprite.emit (sprite_Event);
|
declare
|
||||||
|
click_Event : constant gel.Events.sprite_click_up_Event := (Sprite => the_Collision.near_Sprite.Id,
|
||||||
|
mouse_Button => the_Event.Button,
|
||||||
|
world_Site => Site_world_space);
|
||||||
|
begin
|
||||||
|
the_Collision.near_Sprite.emit (click_Event);
|
||||||
|
end;
|
||||||
end if;
|
end if;
|
||||||
end;
|
end;
|
||||||
end case;
|
end case;
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ is
|
|||||||
|
|
||||||
type sprite_click_down_Event is new lace.Event.item with
|
type sprite_click_down_Event is new lace.Event.item with
|
||||||
record
|
record
|
||||||
|
Sprite : gel.sprite_Id;
|
||||||
mouse_Button : gel.Mouse.Button_Id;
|
mouse_Button : gel.Mouse.Button_Id;
|
||||||
world_Site : math.Vector_3;
|
world_Site : math.Vector_3;
|
||||||
end record;
|
end record;
|
||||||
@@ -83,6 +84,7 @@ is
|
|||||||
|
|
||||||
type sprite_click_up_Event is new lace.Event.item with
|
type sprite_click_up_Event is new lace.Event.item with
|
||||||
record
|
record
|
||||||
|
Sprite : gel.sprite_Id;
|
||||||
mouse_Button : gel.Mouse.Button_Id;
|
mouse_Button : gel.Mouse.Button_Id;
|
||||||
world_Site : math.Vector_3;
|
world_Site : math.Vector_3;
|
||||||
end record;
|
end record;
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ is
|
|||||||
|
|
||||||
|
|
||||||
-------------------------
|
-------------------------
|
||||||
--- Sprite Motion Updates
|
--- Id Motion Updates
|
||||||
--
|
--
|
||||||
|
|
||||||
-- Coarse types to help minimise network use - (TODO: Currently disabled til better quaternion 'coarsen' is ready.)
|
-- Coarse types to help minimise network use - (TODO: Currently disabled til better quaternion 'coarsen' is ready.)
|
||||||
@@ -181,7 +181,7 @@ is
|
|||||||
|
|
||||||
|
|
||||||
------------------------------
|
------------------------------
|
||||||
--- Sprite add and rid events.
|
--- Id add and rid events.
|
||||||
--
|
--
|
||||||
|
|
||||||
type sprite_added_Event is new lace.Event.item with
|
type sprite_added_Event is new lace.Event.item with
|
||||||
@@ -192,7 +192,8 @@ is
|
|||||||
|
|
||||||
type sprite_ridded_Event is new lace.Event.item with
|
type sprite_ridded_Event is new lace.Event.item with
|
||||||
record
|
record
|
||||||
Sprite : gel.sprite_Id;
|
Id : gel.sprite_Id;
|
||||||
|
Name : lace.Text.item_128;
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ with
|
|||||||
|
|
||||||
lace.Response,
|
lace.Response,
|
||||||
lace.Event.utility,
|
lace.Event.utility,
|
||||||
lace.Text,
|
lace.Text.forge,
|
||||||
|
|
||||||
ada.unchecked_Deallocation,
|
ada.unchecked_Deallocation,
|
||||||
ada.Exceptions,
|
ada.Exceptions,
|
||||||
@@ -216,7 +216,7 @@ is
|
|||||||
is
|
is
|
||||||
the_Event : constant remote.World.new_graphics_model_Event := remote.World.new_graphics_model_Event (to_Event);
|
the_Event : constant remote.World.new_graphics_model_Event := remote.World.new_graphics_model_Event (to_Event);
|
||||||
begin
|
begin
|
||||||
log ("gel.world.client ~ new graphics model response ~ model id:" & the_Event.Model.Id'Image);
|
-- log ("gel.world.client ~ new graphics model response ~ model id:" & the_Event.Model.Id'Image);
|
||||||
Self.World.add (new openGL.Model.item'Class' (openGL.Model.item'Class (the_Event.Model.all)));
|
Self.World.add (new openGL.Model.item'Class' (openGL.Model.item'Class (the_Event.Model.all)));
|
||||||
end respond;
|
end respond;
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ is
|
|||||||
is
|
is
|
||||||
the_Event : constant remote.World.new_physics_model_Event := remote.World.new_physics_model_Event (to_Event);
|
the_Event : constant remote.World.new_physics_model_Event := remote.World.new_physics_model_Event (to_Event);
|
||||||
begin
|
begin
|
||||||
log ("gel.world.client ~ new physics model response ~ model id:" & the_Event.Model.Id'Image);
|
-- log ("gel.world.client ~ new physics model response ~ model id:" & the_Event.Model.Id'Image);
|
||||||
Self.World.add (new physics.Model.item'Class' (physics.Model.item'Class (the_Event.Model.all)));
|
Self.World.add (new physics.Model.item'Class' (physics.Model.item'Class (the_Event.Model.all)));
|
||||||
end respond;
|
end respond;
|
||||||
|
|
||||||
@@ -363,14 +363,11 @@ is
|
|||||||
the_Event : constant gel.Events.rid_sprite_Event
|
the_Event : constant gel.Events.rid_sprite_Event
|
||||||
:= gel.events.rid_sprite_Event (to_Event);
|
:= gel.events.rid_sprite_Event (to_Event);
|
||||||
|
|
||||||
-- the_Sprite : constant gel.Sprite.view
|
the_Sprite : constant gel.Sprite.view := Self.World.fetch_Sprite (the_Event.Id);
|
||||||
-- := to_Sprite (the_Event.Pair,
|
|
||||||
-- Self.graphics_Models.all,
|
|
||||||
-- Self.physics_Models.all,
|
|
||||||
-- Self.World);
|
|
||||||
begin
|
begin
|
||||||
Self.World.rid (Self.World.fetch_Sprite (the_Event.Id));
|
Self.World.rid (the_Sprite);
|
||||||
Self.World.emit (remote.world.sprite_ridded_Event' (Sprite => the_Event.Id));
|
Self.World.emit (remote.world.sprite_ridded_Event' (Id => the_Event.Id,
|
||||||
|
Name => lace.Text.forge.to_Text_128 (the_Sprite.Name)));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end respond;
|
end respond;
|
||||||
@@ -429,7 +426,7 @@ is
|
|||||||
to_Kind (remote.World.new_physics_model_Event'Tag),
|
to_Kind (remote.World.new_physics_model_Event'Tag),
|
||||||
from_Subject => of_World.Name);
|
from_Subject => of_World.Name);
|
||||||
|
|
||||||
-- New sprite response.
|
-- New Id response.
|
||||||
--
|
--
|
||||||
define (the_my_new_sprite_Response, World => Self.all'Access,
|
define (the_my_new_sprite_Response, World => Self.all'Access,
|
||||||
Models => Self.graphics_Models'Access,
|
Models => Self.graphics_Models'Access,
|
||||||
@@ -439,7 +436,7 @@ is
|
|||||||
to_Kind (gel.Events.new_sprite_Event'Tag),
|
to_Kind (gel.Events.new_sprite_Event'Tag),
|
||||||
from_Subject => of_World.Name);
|
from_Subject => of_World.Name);
|
||||||
|
|
||||||
-- Rid sprite response.
|
-- Rid Id response.
|
||||||
--
|
--
|
||||||
define (the_my_rid_sprite_Response, World => Self.all'Access,
|
define (the_my_rid_sprite_Response, World => Self.all'Access,
|
||||||
Models => Self.graphics_Models'Access,
|
Models => Self.graphics_Models'Access,
|
||||||
@@ -594,7 +591,7 @@ is
|
|||||||
gel.World.item (Self.all).add (the_Sprite, and_Children); -- Do base class.
|
gel.World.item (Self.all).add (the_Sprite, and_Children); -- Do base class.
|
||||||
-- Self.all_Sprites.Map.add (the_Sprite);
|
-- Self.all_Sprites.Map.add (the_Sprite);
|
||||||
|
|
||||||
-- added_Event.Sprite := the_Sprite.Id;
|
-- added_Event.Id := the_Sprite.Id;
|
||||||
|
|
||||||
-- log ("****** gel.world.client.add " & the_Sprite.Name);
|
-- log ("****** gel.world.client.add " & the_Sprite.Name);
|
||||||
-- if the_Sprite.Id /= 50000000
|
-- if the_Sprite.Id /= 50000000
|
||||||
@@ -685,7 +682,7 @@ is
|
|||||||
Self.respond;
|
Self.respond;
|
||||||
Self.local_Subject_and_deferred_Observer.respond;
|
Self.local_Subject_and_deferred_Observer.respond;
|
||||||
|
|
||||||
-- Interpolate sprite transforms.
|
-- Interpolate Id transforms.
|
||||||
--
|
--
|
||||||
declare
|
declare
|
||||||
use id_Maps_of_sprite;
|
use id_Maps_of_sprite;
|
||||||
@@ -730,7 +727,7 @@ is
|
|||||||
-- exception
|
-- exception
|
||||||
-- when E : others =>
|
-- when E : others =>
|
||||||
-- log (""); log ("");
|
-- log (""); log ("");
|
||||||
-- log ("Error in 'gel.World.client.evolve' sprite response.");
|
-- log ("Error in 'gel.World.client.evolve' Id response.");
|
||||||
-- log ("");
|
-- log ("");
|
||||||
-- log (ada.Exceptions.exception_Information (E));
|
-- log (ada.Exceptions.exception_Information (E));
|
||||||
-- log (""); log ("");
|
-- log (""); log ("");
|
||||||
|
|||||||
Reference in New Issue
Block a user