Cleanup: Eliminate warnings and hints
[d2df-editor.git] / src / editor / f_mapcheck.pas
blobbcb8ecf9cdfba7c230262dcdcbf7de771e6c30bc
1 unit f_mapcheck;
3 {$INCLUDE ../shared/a_modes.inc}
5 interface
7 uses
8 LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
9 Dialogs, StdCtrls, ExtCtrls, g_basic;
11 type
12 TMapCheckForm = class (TForm)
13 PanelResults: TPanel;
14 lbErrorList: TListBox;
15 mErrorDescription: TMemo;
16 bCheckMap: TButton;
17 bClose: TButton;
19 procedure bCloseClick(Sender: TObject);
20 procedure bCheckMapClick(Sender: TObject);
21 procedure lbErrorListClick(Sender: TObject);
23 private
24 { Private declarations }
25 public
26 { Public declarations }
27 end;
29 var
30 MapCheckForm: TMapCheckForm;
31 ErrorsNum: Array of Byte;
33 implementation
35 uses
36 f_main, g_map, MAPDEF, g_language;
38 {$R *.lfm}
40 procedure TMapCheckForm.bCloseClick(Sender: TObject);
41 begin
42 Close();
43 end;
45 procedure TMapCheckForm.bCheckMapClick(Sender: TObject);
46 var
47 a: Integer;
48 b, bb, bbb: Integer;
49 c: Boolean;
51 begin
52 lbErrorList.Clear();
53 mErrorDescription.Clear();
54 ErrorsNum := nil;
56 // Проверяем пересечение точек появления с картой:
57 if gAreas <> nil then
58 for a := 0 to High(gAreas) do
59 begin
60 if gAreas[a].AreaType in [AREA_PLAYERPOINT1, AREA_PLAYERPOINT2,
61 AREA_DMPOINT, AREA_REDTEAMPOINT,
62 AREA_BLUETEAMPOINT] then
63 with gAreas[a] do
64 begin
65 c := False;
66 if gPanels <> nil then
67 for b := 0 to High(gPanels) do
68 if gPanels[b].PanelType = PANEL_CLOSEDOOR then
69 if ObjectCollide(OBJECT_AREA, a,
70 gPanels[b].X, gPanels[b].Y,
71 gPanels[b].Width, gPanels[b].Height) then
72 begin
73 c := True;
74 Break;
75 end;
77 if c or ObjectCollideLevel(a, OBJECT_AREA, 0, 0) then
78 begin
79 lbErrorList.Items.Add(Format(_lc[I_TEST_AREA_WALL_STR], [a, X, Y]));
80 SetLength(ErrorsNum, Length(ErrorsNum)+1);
81 ErrorsNum[High(ErrorsNum)] := 1;
82 end;
83 end;
84 end;
86 // Проверяем пересечение монстров с картой:
87 if gMonsters <> nil then
88 for a := 0 to High(gMonsters) do
89 if gMonsters[a].MonsterType <> MONSTER_NONE then
90 begin
91 with gMonsters[a] do
92 begin
93 c := False;
94 if gPanels <> nil then
95 for b := 0 to High(gPanels) do
96 if gPanels[b].PanelType = PANEL_CLOSEDOOR then
97 if ObjectCollide(OBJECT_MONSTER, a,
98 gPanels[b].X, gPanels[b].Y,
99 gPanels[b].Width, gPanels[b].Height) then
100 begin
101 c := True;
102 Break;
103 end;
105 if c or ObjectCollideLevel(a, OBJECT_MONSTER, 0, 0) then
106 begin
107 lbErrorList.Items.Add(Format(_lc[I_TEST_MONSTER_WALL_STR], [a, X, Y]));
108 SetLength(ErrorsNum, Length(ErrorsNum)+1);
109 ErrorsNum[High(ErrorsNum)] := 5;
110 end;
111 end;
112 end;
114 b := 0;
115 bb := 0;
116 bbb := 0;
118 if gAreas <> nil then
119 for a := 0 to High(gAreas) do
120 case gAreas[a].AreaType of
121 AREA_PLAYERPOINT1: Inc(b);
122 AREA_PLAYERPOINT2: Inc(bb);
123 AREA_DMPOINT, AREA_REDTEAMPOINT,
124 AREA_BLUETEAMPOINT: Inc(bbb);
125 end;
127 if b > 1 then
128 begin
129 lbErrorList.Items.Add(_lc[I_TEST_SPAWNS_1]);
130 SetLength(ErrorsNum, Length(ErrorsNum)+1);
131 ErrorsNum[High(ErrorsNum)] := 2;
132 end;
134 if bb > 1 then
135 begin
136 lbErrorList.Items.Add(_lc[I_TEST_SPAWNS_2]);
137 SetLength(ErrorsNum, Length(ErrorsNum)+1);
138 ErrorsNum[High(ErrorsNum)] := 3;
139 end;
141 if bbb = 0 then
142 begin
143 lbErrorList.Items.Add(_lc[I_TEST_NO_DM]);
144 SetLength(ErrorsNum, Length(ErrorsNum)+1);
145 ErrorsNum[High(ErrorsNum)] := 4;
146 end;
147 end;
149 procedure TMapCheckForm.lbErrorListClick(Sender: TObject);
150 begin
151 if lbErrorList.ItemIndex <> -1 then
152 case ErrorsNum[lbErrorList.ItemIndex] of
153 1: mErrorDescription.Text := _lc[I_TEST_AREA_WALL];
154 2, 3: mErrorDescription.Text := _lc[I_TEST_SPAWNS];
155 4: mErrorDescription.Text := _lc[I_TEST_NO_DM_EX];
156 5: mErrorDescription.Text := _lc[I_TEST_MONSTER_WALL];
157 end;
158 end;
160 end.