DEADSOFTWARE

net: sync moving items and flags
[d2df-sdl.git] / src / game / g_items.pas
index 88a9cba1c433057f3ede53d4bf118ad43aecbc9c..0aa9d560ab9b00cd002fbca4ac994b9f80a76ede 100644 (file)
@@ -41,6 +41,7 @@ Type
     Obj: TObj;
     Animation: TAnimation;
     dropped: Boolean; // dropped from the monster? drops should be rendered after corpses, so zombie corpse will not obscure ammo container, for example
+    NeedSend: Boolean;
 
     procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
 
@@ -133,6 +134,7 @@ end;
 // ////////////////////////////////////////////////////////////////////////// //
 procedure TItem.positionChanged ();
 begin
+  NeedSend := NeedSend or (Obj.X <> Obj.oldX) or (Obj.Y <> Obj.oldY);
 end;
 
 
@@ -348,6 +350,7 @@ begin
   it.alive := False;
   it.SpawnTrigger := -1;
   it.ItemType := ITEM_NONE;
+  it.NeedSend := false;
   freeIds.release(LongWord(idx));
 end;
 
@@ -371,6 +374,7 @@ begin
     it.alive := false;
     it.SpawnTrigger := -1;
     it.Respawnable := false;
+    it.NeedSend := false;
     //if not freeIds.hasFree[LongWord(i)] then raise Exception.Create('internal error in item idx manager');
   end;
 end;
@@ -461,10 +465,9 @@ begin
   it.alive := True;
   it.QuietRespawn := False;
   it.dropped := false;
+  it.NeedSend := false;
 
   g_Obj_Init(@it.Obj);
-  it.Obj.oldX := X;
-  it.Obj.oldY := Y;
   it.Obj.X := X;
   it.Obj.Y := Y;
   it.Obj.Rect.Width := ITEMSIZE[ItemType][0];
@@ -485,6 +488,9 @@ begin
     end;
   end;
 
+  it.Obj.oldX := it.Obj.X;
+  it.Obj.oldY := it.Obj.Y;
+
   // Óñòàíîâêà àíèìàöèè
   case it.ItemType of
     ITEM_ARMOR_GREEN: if g_Frames_Get(ID, 'FRAMES_ITEM_ARMORGREEN') then it.Animation := TAnimation.Create(ID, True, 20);