X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_items.pas;h=8d476efe76e6fa3fc1c27f98644e2def961704b4;hb=4ead372f76709eb9dfeb4ebd9e190d9d5fdfcc83;hp=64ffe3e62697d8ac162de5f236987561ca2068c5;hpb=ce76cc68a2b2daeb019a21940d9802610a55a281;p=d2df-sdl.git diff --git a/src/game/g_items.pas b/src/game/g_items.pas index 64ffe3e..8d476ef 100644 --- a/src/game/g_items.pas +++ b/src/game/g_items.pas @@ -2,8 +2,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -84,7 +83,6 @@ function g_Items_ForEachAlive (cb: TItemEachAliveCB; backwards: Boolean=false): var gItemsTexturesID: Array [1..ITEM_MAX] of DWORD; gMaxDist: Integer = 1; // for sounds - ITEM_RESPAWNTIME: Integer = 60 * 36; implementation @@ -455,7 +453,6 @@ begin it.ItemType := ItemType; it.Respawnable := Respawnable; - if g_Game_IsServer and (ITEM_RESPAWNTIME = 0) then it.Respawnable := False; it.InitX := X; it.InitY := Y; it.RespawnTime := 0; @@ -509,14 +506,18 @@ var i, j, k: Integer; ID: DWord; Anim: TAnimation; - m: Word; + m, ItemRespawnTime: Word; r, nxt: Boolean; begin if (ggItems = nil) then exit; + // respawn items in 15 seconds regardless of settings during warmup + ItemRespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15); + for i := 0 to High(ggItems) do begin if (ggItems[i].ItemType = ITEM_NONE) then continue; + if not ggItems[i].slotIsUsed then continue; // just in case with ggItems[i] do begin @@ -577,7 +578,10 @@ begin // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòüñÿ ñ äðóãèì èãðîêîì if r then begin - if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i); + if not (Respawnable and (ItemRespawnTime > 0)) then + g_Items_Remove(i) + else + g_Items_Pick(i); if g_Game_IsNet then MH_SEND_ItemDestroy(False, i); nxt := True; break; @@ -634,6 +638,7 @@ begin for i := 0 to High(ggItems) do begin it := @ggItems[i]; + if (not it.slotIsUsed) or (it.ItemType = ITEM_NONE) then continue; // just in case if not it.alive then continue; if (it.dropped <> dropflag) then continue; @@ -689,7 +694,7 @@ begin if (ID < Length(ggItems)) then begin ggItems[ID].alive := false; - ggItems[ID].RespawnTime := ITEM_RESPAWNTIME; + ggItems[ID].RespawnTime := IfThen(gLMSRespawn = LMS_RESPAWN_NONE, gGameSettings.ItemRespawnTime, 15) * 36; end; end; @@ -701,9 +706,9 @@ var begin if not g_Items_ValidId(ID) then begin - //raise Exception.Create('g_Items_Remove: invalid item id'); - writeln('g_Items_Remove: invalid item id: ', ID); - exit; + //writeln('g_Items_Remove: invalid item id: ', ID); + raise Exception.Create('g_Items_Remove: invalid item id'); + //exit; end; it := @ggItems[ID]; @@ -724,7 +729,7 @@ var begin // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ ïðåäìåòîâ count := 0; - for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) then Inc(count); + for i := 0 to High(ggItems) do if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then Inc(count); // Êîëè÷åñòâî ïðåäìåòîâ utils.writeInt(st, LongInt(count)); @@ -732,7 +737,7 @@ begin for i := 0 to High(ggItems) do begin - if (ggItems[i].ItemType <> ITEM_NONE) then + if (ggItems[i].ItemType <> ITEM_NONE) and (ggItems[i].slotIsUsed) then begin // Ñèãíàòóðà ïðåäìåòà utils.writeSign(st, 'ITEM'); @@ -812,7 +817,8 @@ begin for i := 0 to High(ggItems) do begin it := @ggItems[i]; - if it.Respawnable then + if not it.slotIsUsed then continue; + if it.Respawnable and (it.ItemType <> ITEM_NONE) then begin it.QuietRespawn := True; it.RespawnTime := 0; @@ -837,7 +843,7 @@ begin begin for idx := High(ggItems) downto 0 do begin - if ggItems[idx].alive then + if ggItems[idx].alive and ggItems[idx].slotIsUsed then begin result := cb(@ggItems[idx]); if result then exit; @@ -848,7 +854,7 @@ begin begin for idx := 0 to High(ggItems) do begin - if ggItems[idx].alive then + if ggItems[idx].alive and ggItems[idx].slotIsUsed then begin result := cb(@ggItems[idx]); if result then exit;