equal
deleted
inserted
replaced
20 |
20 |
21 unit uLandPainted; |
21 unit uLandPainted; |
22 |
22 |
23 interface |
23 interface |
24 |
24 |
25 procedure LoadFromFile(fileName: shortstring); |
|
26 procedure Draw; |
25 procedure Draw; |
27 procedure initModule; |
26 procedure initModule; |
28 |
27 |
29 implementation |
28 implementation |
30 uses uLandGraphics, uConsts, uUtils, SDLh, uCommands; |
29 uses uLandGraphics, uConsts, uUtils, SDLh, uCommands, uDebug; |
31 |
30 |
32 type PointRec = packed record |
31 type PointRec = packed record |
33 X, Y: SmallInt; |
32 X, Y: SmallInt; |
34 flags: byte; |
33 flags: byte; |
35 end; |
34 end; |
104 if (len mod 4) = 0 then FillRoundInLand(X, Y, 34, lfBasic) |
103 if (len mod 4) = 0 then FillRoundInLand(X, Y, 34, lfBasic) |
105 end |
104 end |
106 end |
105 end |
107 end; |
106 end; |
108 |
107 |
109 |
|
110 procedure LoadFromFile(fileName: shortstring); |
|
111 var |
|
112 f: file of PointRec; |
|
113 rec, prevRec: PointRec; |
|
114 begin |
|
115 fileMode:= 0; |
|
116 |
|
117 assignFile(f, fileName); |
|
118 reset(f); |
|
119 |
|
120 while not eof(f) do |
|
121 begin |
|
122 read(f, rec); |
|
123 rec.X:= SDLNet_Read16(@rec.X); |
|
124 rec.Y:= SDLNet_Read16(@rec.Y); |
|
125 |
|
126 // FIXME: handle single point |
|
127 if eof(f) or (rec.flags and $80 <> 0) then |
|
128 else |
|
129 DrawLineOnLand(prevRec.X, prevRec.Y, rec.X, rec.Y); |
|
130 |
|
131 prevRec:= rec; |
|
132 end; |
|
133 |
|
134 closeFile(f); |
|
135 end; |
|
136 |
|
137 procedure chDraw(var s: shortstring); |
108 procedure chDraw(var s: shortstring); |
138 var rec: PointRec; |
109 var rec: PointRec; |
139 prec: ^PointRec; |
110 prec: ^PointRec; |
140 pe: PPointEntry; |
111 pe: PPointEntry; |
141 i, l: byte; |
112 i, l: byte; |
165 |
136 |
166 procedure Draw; |
137 procedure Draw; |
167 var pe: PPointEntry; |
138 var pe: PPointEntry; |
168 prevPoint: PointRec; |
139 prevPoint: PointRec; |
169 begin |
140 begin |
|
141 // shutup compiler |
|
142 prevPoint.X:= 0; |
|
143 prevPoint.Y:= 0; |
|
144 |
170 pe:= pointsListHead; |
145 pe:= pointsListHead; |
|
146 TryDo((pe = nil) or (pe^.point.flags and $80 <> 0), 'Corrupted draw data', true); |
171 |
147 |
172 while(pe <> nil) do |
148 while(pe <> nil) do |
173 begin |
149 begin |
174 if (pe^.point.flags and $80 <> 0) then |
150 if (pe^.point.flags and $80 <> 0) then |
175 FillRoundInLand(pe^.point.X, pe^.point.Y, 34, lfBasic) |
151 FillRoundInLand(pe^.point.X, pe^.point.Y, 34, lfBasic) |
176 else |
152 else |
177 DrawLineOnLand(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y); |
153 DrawLineOnLand(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y); |
178 |
154 |
179 prevPoint:= pe^.point; |
155 prevPoint:= pe^.point; |
180 pe:= pe^.next; |
156 pe:= pe^.next; |
181 end; |
157 end; |
182 end; |
158 end; |
183 |
159 |
184 procedure initModule; |
160 procedure initModule; |
185 begin |
161 begin |