Devilution
Diablo devolved - magic behind the 1996 computer game
cursor.cpp
Go to the documentation of this file.
1 
6 #include "all.h"
7 
9 
10 int cursH;
12 int cursW;
13 int pcursmonst = -1;
15 BYTE *pCursCels;
16 int icursH;
17 
20 int icursW;
21 char pcursitem;
22 char pcursobj;
23 char pcursplr;
24 int cursmx;
25 int cursmy;
27 int pcurs;
28 
29 /* rdata */
31 const int InvItemWidth[180] = {
32  // Cursors
33  0, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 23,
34  // Items
35  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
36  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
37  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
38  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
39  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
40  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
41  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
42  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
43  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
44  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
45  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
46  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
47  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
48  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
49  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
50  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
51  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28
52 };
53 
55 const int InvItemHeight[180] = {
56  // Cursors
57  0, 29, 32, 32, 32, 32, 32, 32, 32, 32, 32, 35,
58  // Items
59  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
60  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
61  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
62  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
63  1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28,
64  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
65  3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
66  3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
67  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
68  2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
69  3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
70  3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
71  3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
72  3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
73  3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
74  3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
75  3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28
76 };
77 
78 void InitCursor()
79 {
81  pCursCels = LoadFileInMem("Data\\Inv\\Objcurs.CEL", NULL);
82  ClearCursor();
83 }
84 
85 void FreeCursor()
86 {
88  ClearCursor();
89 }
90 
91 void SetICursor(int i)
92 {
93  icursW = InvItemWidth[i];
94  icursH = InvItemHeight[i];
95  icursW28 = icursW / 28;
96  icursH28 = icursH / 28;
97 }
98 
99 void SetCursor_(int i)
100 {
101  pcurs = i;
102  cursW = InvItemWidth[i];
103  cursH = InvItemHeight[i];
104  SetICursor(i);
105 }
106 
107 void NewCursor(int i)
108 {
109  SetCursor_(i);
110 }
111 
113 {
115  cursmx = ViewX;
116  cursmy = ViewY;
117  pcurstemp = -1;
118  pcursmonst = -1;
119  pcursobj = -1;
120  pcursitem = -1;
121  pcursplr = -1;
122  ClearCursor();
123 }
124 
125 void CheckTown()
126 {
127  int i, mx;
128 
129  for (i = 0; i < nummissiles; i++) {
130  mx = missileactive[i];
131  if (missile[mx]._mitype == MIS_TOWN) {
132  if (cursmx == missile[mx]._mix - 1 && cursmy == missile[mx]._miy
133  || cursmx == missile[mx]._mix && cursmy == missile[mx]._miy - 1
134  || cursmx == missile[mx]._mix - 1 && cursmy == missile[mx]._miy - 1
135  || cursmx == missile[mx]._mix - 2 && cursmy == missile[mx]._miy - 1
136  || cursmx == missile[mx]._mix - 2 && cursmy == missile[mx]._miy - 2
137  || cursmx == missile[mx]._mix - 1 && cursmy == missile[mx]._miy - 2
138  || cursmx == missile[mx]._mix && cursmy == missile[mx]._miy) {
139  trigflag = TRUE;
140  ClearPanel();
141  strcpy(infostr, "Town Portal");
142  sprintf(tempstr, "from %s", plr[missile[mx]._misource]._pName);
143  AddPanelString(tempstr, TRUE);
144  cursmx = missile[mx]._mix;
145  cursmy = missile[mx]._miy;
146  }
147  }
148  }
149 }
150 
152 {
153  int i, mx;
154 
155  for (i = 0; i < nummissiles; i++) {
156  mx = missileactive[i];
157  if (missile[mx]._mitype == MIS_RPORTAL) {
158  if (cursmx == missile[mx]._mix - 1 && cursmy == missile[mx]._miy
159  || cursmx == missile[mx]._mix && cursmy == missile[mx]._miy - 1
160  || cursmx == missile[mx]._mix - 1 && cursmy == missile[mx]._miy - 1
161  || cursmx == missile[mx]._mix - 2 && cursmy == missile[mx]._miy - 1
162  || cursmx == missile[mx]._mix - 2 && cursmy == missile[mx]._miy - 2
163  || cursmx == missile[mx]._mix - 1 && cursmy == missile[mx]._miy - 2
164  || cursmx == missile[mx]._mix && cursmy == missile[mx]._miy) {
165  trigflag = TRUE;
166  ClearPanel();
167  strcpy(infostr, "Portal to");
168  if (!setlevel)
169  strcpy(tempstr, "The Unholy Altar");
170  else
171  strcpy(tempstr, "level 15");
172  AddPanelString(tempstr, TRUE);
173  cursmx = missile[mx]._mix;
174  cursmy = missile[mx]._miy;
175  }
176  }
177  }
178 }
179 
181 {
182  int i, sx, sy, fx, fy, mx, my, tx, ty, px, py, xx, yy, mi;
183  char bv;
184  BOOL flipflag, flipx, flipy;
185 
186  sx = MouseX;
187  sy = MouseY;
188 
189 
190  if (PANELS_COVER) {
191  if (chrflag || questlog) {
192  if (sx >= 160) {
193  sx -= 160;
194  } else {
195  sx = 0;
196  }
197  } else if (invflag || sbookflag) {
198  if (sx <= 320) {
199  sx += 160;
200  } else {
201  sx = 0;
202  }
203  }
204  }
205  if (sy > PANEL_TOP - 1 && track_isscrolling()) {
206  sy = PANEL_TOP - 1;
207  }
208  sx -= (SCREEN_WIDTH % 64) / 2;
209  sy -= (VIEWPORT_HEIGHT % 32) / 2;
210  if (!zoomflag) {
211  sx >>= 1;
212  sy >>= 1;
213  }
214 
215  sx -= ScrollInfo._sxoff;
216  sy -= ScrollInfo._syoff;
217 
218  fx = plr[myplr]._pVar6 / 256;
219  fy = plr[myplr]._pVar7 / 256;
220  fx -= (plr[myplr]._pVar6 + plr[myplr]._pxvel) / 256;
221  fy -= (plr[myplr]._pVar7 + plr[myplr]._pyvel) / 256;
222 
223  if (ScrollInfo._sdir != SDIR_NONE) {
224  sx -= fx;
225  sy -= fy;
226  }
227 
228  if (sx < 0) {
229  sx = 0;
230  }
231  if (sx >= SCREEN_WIDTH) {
232  sx = SCREEN_WIDTH;
233  }
234  if (sy < 0) {
235  sy = 0;
236  }
237  if (sy >= SCREEN_HEIGHT) {
238  sy = SCREEN_HEIGHT;
239  }
240 
241  tx = sx >> 6; // sx / 64
242  ty = sy >> 5; // sy / 32
243  px = sx & 0x3F; // sx % 64
244  py = sy & 0x1F; // sx % 32
245  mx = ViewX + tx + ty - (zoomflag ? (SCREEN_WIDTH / 64) : (SCREEN_WIDTH / 2 / 64));
246  my = ViewY + ty - tx;
247 
248  flipy = py < (px >> 1);
249  if (flipy) {
250  my--;
251  }
252  flipx = py >= 32 - (px >> 1);
253  if (flipx) {
254  mx++;
255  }
256 
257  if (mx < 0) {
258  mx = 0;
259  }
260  if (mx >= MAXDUNX) {
261  mx = MAXDUNX - 1;
262  }
263  if (my < 0) {
264  my = 0;
265  }
266  if (my >= MAXDUNY) {
267  my = MAXDUNY - 1;
268  }
269 
270  flipflag = flipy && flipx || (flipy || flipx) && px < 32;
271 
273  pcursmonst = -1;
274  pcursobj = -1;
275  pcursitem = -1;
276  if (pcursinvitem != -1) {
277  drawsbarflag = TRUE;
278  }
279  pcursinvitem = -1;
280  pcursplr = -1;
281  uitemflag = FALSE;
282  panelflag = FALSE;
283  trigflag = FALSE;
284 
285  if (plr[myplr]._pInvincible) {
286  return;
287  }
288  if (pcurs >= CURSOR_FIRSTITEM || spselflag) {
289  cursmx = mx;
290  cursmy = my;
291  return;
292  }
294  CheckPanelInfo();
295  return;
296  }
297  if (doomflag) {
298  return;
299  }
300  if (invflag && MouseX > RIGHT_PANEL && MouseY <= SPANEL_HEIGHT) {
302  return;
303  }
305  return;
306  }
307  if ((chrflag || questlog) && MouseX < SPANEL_WIDTH && MouseY <= SPANEL_HEIGHT) {
308  return;
309  }
310 
311  if (leveltype != DTYPE_TOWN) {
312  if (pcurstemp != -1) {
313  if (!flipflag && dMonster[mx + 2][my + 1] != 0 && dFlags[mx + 2][my + 1] & BFLAG_LIT) {
314  mi = dMonster[mx + 2][my + 1] > 0 ? dMonster[mx + 2][my + 1] - 1 : -(dMonster[mx + 2][my + 1] + 1);
315  if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
316  cursmx = mx + 1;
317  cursmy = my + 2;
318  pcursmonst = mi;
319  }
320  }
321  if (flipflag && dMonster[mx + 1][my + 2] != 0 && dFlags[mx + 1][my + 2] & BFLAG_LIT) {
322  mi = dMonster[mx + 1][my + 2] > 0 ? dMonster[mx + 1][my + 2] - 1 : -(dMonster[mx + 1][my + 2] + 1);
323  if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
324  cursmx = mx + 1;
325  cursmy = my + 2;
326  pcursmonst = mi;
327  }
328  }
329  if (dMonster[mx + 2][my + 2] != 0 && dFlags[mx + 2][my + 2] & BFLAG_LIT) {
330  mi = dMonster[mx + 2][my + 2] > 0 ? dMonster[mx + 2][my + 2] - 1 : -(dMonster[mx + 2][my + 2] + 1);
331  if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
332  cursmx = mx + 2;
333  cursmy = my + 2;
334  pcursmonst = mi;
335  }
336  }
337  if (!flipflag && dMonster[mx + 1][my] != 0 && dFlags[mx + 1][my] & BFLAG_LIT) {
338  mi = dMonster[mx + 1][my] > 0 ? dMonster[mx + 1][my] - 1 : -(dMonster[mx + 1][my] + 1);
339  if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
340  cursmx = mx + 1;
341  cursmy = my;
342  pcursmonst = mi;
343  }
344  }
345  if (flipflag && dMonster[mx][my + 1] != 0 && dFlags[mx][my + 1] & BFLAG_LIT) {
346  mi = dMonster[mx][my + 1] > 0 ? dMonster[mx][my + 1] - 1 : -(dMonster[mx][my + 1] + 1);
347  if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
348  cursmx = mx;
349  cursmy = my + 1;
350  pcursmonst = mi;
351  }
352  }
353  if (dMonster[mx][my] != 0 && dFlags[mx][my] & BFLAG_LIT) {
354  mi = dMonster[mx][my] > 0 ? dMonster[mx][my] - 1 : -(dMonster[mx][my] + 1);
355  if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 1) {
356  cursmx = mx;
357  cursmy = my;
358  pcursmonst = mi;
359  }
360  }
361  if (dMonster[mx + 1][my + 1] != 0 && dFlags[mx + 1][my + 1] & BFLAG_LIT) {
362  mi = dMonster[mx + 1][my + 1] > 0 ? dMonster[mx + 1][my + 1] - 1 : -(dMonster[mx + 1][my + 1] + 1);
363  if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
364  cursmx = mx + 1;
365  cursmy = my + 1;
366  pcursmonst = mi;
367  }
368  }
369  if (pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_HIDDEN) {
370  pcursmonst = -1;
371  cursmx = mx;
372  cursmy = my;
373  }
374  if (pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_GOLEM) {
375  pcursmonst = -1;
376  }
377  if (pcursmonst != -1) {
378  return;
379  }
380  }
381  if (!flipflag && dMonster[mx + 2][my + 1] != 0 && dFlags[mx + 2][my + 1] & BFLAG_LIT) {
382  mi = dMonster[mx + 2][my + 1] > 0 ? dMonster[mx + 2][my + 1] - 1 : -(dMonster[mx + 2][my + 1] + 1);
383  if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
384  cursmx = mx + 2;
385  cursmy = my + 1;
386  pcursmonst = mi;
387  }
388  }
389  if (flipflag && dMonster[mx + 1][my + 2] != 0 && dFlags[mx + 1][my + 2] & BFLAG_LIT) {
390  mi = dMonster[mx + 1][my + 2] > 0 ? dMonster[mx + 1][my + 2] - 1 : -(dMonster[mx + 1][my + 2] + 1);
391  if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
392  cursmx = mx + 1;
393  cursmy = my + 2;
394  pcursmonst = mi;
395  }
396  }
397  if (dMonster[mx + 2][my + 2] != 0 && dFlags[mx + 2][my + 2] & BFLAG_LIT) {
398  mi = dMonster[mx + 2][my + 2] > 0 ? dMonster[mx + 2][my + 2] - 1 : -(dMonster[mx + 2][my + 2] + 1);
399  if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
400  cursmx = mx + 2;
401  cursmy = my + 2;
402  pcursmonst = mi;
403  }
404  }
405  if (!flipflag && dMonster[mx + 1][my] != 0 && dFlags[mx + 1][my] & BFLAG_LIT) {
406  mi = dMonster[mx + 1][my] > 0 ? dMonster[mx + 1][my] - 1 : -(dMonster[mx + 1][my] + 1);
407  if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
408  cursmx = mx + 1;
409  cursmy = my;
410  pcursmonst = mi;
411  }
412  }
413  if (flipflag && dMonster[mx][my + 1] != 0 && dFlags[mx][my + 1] & BFLAG_LIT) {
414  mi = dMonster[mx][my + 1] > 0 ? dMonster[mx][my + 1] - 1 : -(dMonster[mx][my + 1] + 1);
415  if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
416  cursmx = mx;
417  cursmy = my + 1;
418  pcursmonst = mi;
419  }
420  }
421  if (dMonster[mx][my] != 0 && dFlags[mx][my] & BFLAG_LIT) {
422  mi = dMonster[mx][my] > 0 ? dMonster[mx][my] - 1 : -(dMonster[mx][my] + 1);
423  if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 1) {
424  cursmx = mx;
425  cursmy = my;
426  pcursmonst = mi;
427  }
428  }
429  if (dMonster[mx + 1][my + 1] != 0 && dFlags[mx + 1][my + 1] & BFLAG_LIT) {
430  mi = dMonster[mx + 1][my + 1] > 0 ? dMonster[mx + 1][my + 1] - 1 : -(dMonster[mx + 1][my + 1] + 1);
431  if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
432  cursmx = mx + 1;
433  cursmy = my + 1;
434  pcursmonst = mi;
435  }
436  }
437  if (pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_HIDDEN) {
438  pcursmonst = -1;
439  cursmx = mx;
440  cursmy = my;
441  }
442  if (pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_GOLEM) {
443  pcursmonst = -1;
444  }
445  } else {
446  if (!flipflag && dMonster[mx + 1][my] > 0) {
447  pcursmonst = dMonster[mx + 1][my] - 1;
448  cursmx = mx + 1;
449  cursmy = my;
450  }
451  if (flipflag && dMonster[mx][my + 1] > 0) {
452  pcursmonst = dMonster[mx][my + 1] - 1;
453  cursmx = mx;
454  cursmy = my + 1;
455  }
456  if (dMonster[mx][my] > 0) {
457  pcursmonst = dMonster[mx][my] - 1;
458  cursmx = mx;
459  cursmy = my;
460  }
461  if (dMonster[mx + 1][my + 1] > 0) {
462  pcursmonst = dMonster[mx + 1][my + 1] - 1;
463  cursmx = mx + 1;
464  cursmy = my + 1;
465  }
466  if (pcursmonst != -1 && !towner[pcursmonst]._tSelFlag) {
467  pcursmonst = -1;
468  }
469  }
470 
471  if (pcursmonst == -1) {
472  if (!flipflag && dPlayer[mx + 1][my] != 0) {
473  bv = dPlayer[mx + 1][my] > 0 ? dPlayer[mx + 1][my] - 1 : -(dPlayer[mx + 1][my] + 1);
474  if (bv != myplr && plr[bv]._pHitPoints != 0) {
475  cursmx = mx + 1;
476  cursmy = my;
477  pcursplr = bv;
478  }
479  }
480  if (flipflag && dPlayer[mx][my + 1] != 0) {
481  bv = dPlayer[mx][my + 1] > 0 ? dPlayer[mx][my + 1] - 1 : -(dPlayer[mx][my + 1] + 1);
482  if (bv != myplr && plr[bv]._pHitPoints != 0) {
483  cursmx = mx;
484  cursmy = my + 1;
485  pcursplr = bv;
486  }
487  }
488  if (dPlayer[mx][my] != 0) {
489  bv = dPlayer[mx][my] > 0 ? dPlayer[mx][my] - 1 : -(dPlayer[mx][my] + 1);
490  if (bv != myplr) {
491  cursmx = mx;
492  cursmy = my;
493  pcursplr = bv;
494  }
495  }
496  if (dFlags[mx][my] & BFLAG_DEAD_PLAYER) {
497  for (i = 0; i < MAX_PLRS; i++) {
498  if (plr[i].WorldX == mx && plr[i].WorldY == my && i != myplr) {
499  cursmx = mx;
500  cursmy = my;
501  pcursplr = i;
502  }
503  }
504  }
505  if (pcurs == CURSOR_RESURRECT) {
506  for (xx = -1; xx < 2; xx++) {
507  for (yy = -1; yy < 2; yy++) {
508  if (dFlags[mx + xx][my + yy] & BFLAG_DEAD_PLAYER) {
509  for (i = 0; i < MAX_PLRS; i++) {
510  if (plr[i].WorldX == mx + xx && plr[i].WorldY == my + yy && i != myplr) {
511  cursmx = mx + xx;
512  cursmy = my + yy;
513  pcursplr = i;
514  }
515  }
516  }
517  }
518  }
519  }
520  if (dPlayer[mx + 1][my + 1] != 0) {
521  bv = dPlayer[mx + 1][my + 1] > 0 ? dPlayer[mx + 1][my + 1] - 1 : -(dPlayer[mx + 1][my + 1] + 1);
522  if (bv != myplr && plr[bv]._pHitPoints != 0) {
523  cursmx = mx + 1;
524  cursmy = my + 1;
525  pcursplr = bv;
526  }
527  }
528  }
529  if (pcursmonst == -1 && pcursplr == -1) {
530  if (!flipflag && dObject[mx + 1][my] != 0) {
531  bv = dObject[mx + 1][my] > 0 ? dObject[mx + 1][my] - 1 : -(dObject[mx + 1][my] + 1);
532  if (object[bv]._oSelFlag >= 2) {
533  cursmx = mx + 1;
534  cursmy = my;
535  pcursobj = bv;
536  }
537  }
538  if (flipflag && dObject[mx][my + 1] != 0) {
539  bv = dObject[mx][my + 1] > 0 ? dObject[mx][my + 1] - 1 : -(dObject[mx][my + 1] + 1);
540  if (object[bv]._oSelFlag >= 2) {
541  cursmx = mx;
542  cursmy = my + 1;
543  pcursobj = bv;
544  }
545  }
546  if (dObject[mx][my] != 0) {
547  bv = dObject[mx][my] > 0 ? dObject[mx][my] - 1 : -(dObject[mx][my] + 1);
548  if (object[bv]._oSelFlag == 1 || object[bv]._oSelFlag == 3) {
549  cursmx = mx;
550  cursmy = my;
551  pcursobj = bv;
552  }
553  }
554  if (dObject[mx + 1][my + 1] != 0) {
555  bv = dObject[mx + 1][my + 1] > 0 ? dObject[mx + 1][my + 1] - 1 : -(dObject[mx + 1][my + 1] + 1);
556  if (object[bv]._oSelFlag >= 2) {
557  cursmx = mx + 1;
558  cursmy = my + 1;
559  pcursobj = bv;
560  }
561  }
562  }
563  if (pcursplr == -1 && pcursobj == -1 && pcursmonst == -1) {
564  if (!flipflag && dItem[mx + 1][my] > 0) {
565  bv = dItem[mx + 1][my] - 1;
566  if (item[bv]._iSelFlag >= 2) {
567  cursmx = mx + 1;
568  cursmy = my;
569  pcursitem = bv;
570  }
571  }
572  if (flipflag && dItem[mx][my + 1] > 0) {
573  bv = dItem[mx][my + 1] - 1;
574  if (item[bv]._iSelFlag >= 2) {
575  cursmx = mx;
576  cursmy = my + 1;
577  pcursitem = bv;
578  }
579  }
580  if (dItem[mx][my] > 0) {
581  bv = dItem[mx][my] - 1;
582  if (item[bv]._iSelFlag == 1 || item[bv]._iSelFlag == 3) {
583  cursmx = mx;
584  cursmy = my;
585  pcursitem = bv;
586  }
587  }
588  if (dItem[mx + 1][my + 1] > 0) {
589  bv = dItem[mx + 1][my + 1] - 1;
590  if (item[bv]._iSelFlag >= 2) {
591  cursmx = mx + 1;
592  cursmy = my + 1;
593  pcursitem = bv;
594  }
595  }
596  if (pcursitem == -1) {
597  cursmx = mx;
598  cursmy = my;
599  CheckTrigForce();
600  CheckTown();
601  CheckRportal();
602  }
603  }
604 
605  if (pcurs == CURSOR_IDENTIFY) {
606  pcursobj = -1;
607  pcursmonst = -1;
608  pcursitem = -1;
609  cursmx = mx;
610  cursmy = my;
611  }
612  if (pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_GOLEM) {
613  pcursmonst = -1;
614  }
615 }
616 
cursmx
int cursmx
Definition: cursor.cpp:24
MIS_RPORTAL
@ MIS_RPORTAL
Definition: enums.h:1259
MouseY
int MouseY
Definition: diablo.cpp:17
ScrollStruct::_sdir
int _sdir
Definition: structs.h:1110
SetCursor_
void SetCursor_(int i)
Definition: cursor.cpp:99
doomflag
BOOL doomflag
Definition: doom.cpp:13
CheckTrigForce
void CheckTrigForce()
Definition: trigs.cpp:598
MAX_PLRS
#define MAX_PLRS
Definition: defs.h:16
zoomflag
BOOL zoomflag
Definition: diablo.cpp:24
pcursinvitem
char pcursinvitem
inv_item value
Definition: cursor.cpp:19
cursH
DEVILUTION_BEGIN_NAMESPACE int cursH
Definition: cursor.cpp:10
CURSOR_HAND
@ CURSOR_HAND
Definition: enums.h:2067
MAXDUNX
#define MAXDUNX
Definition: defs.h:25
pcursplr
char pcursplr
Definition: cursor.cpp:23
InitCursor
void InitCursor()
Definition: cursor.cpp:78
item
ItemStruct item[MAXITEMS+1]
Definition: items.cpp:15
MIS_TOWN
@ MIS_TOWN
Definition: enums.h:1204
questlog
BOOL questlog
Definition: quests.cpp:6
ViewX
int ViewX
Definition: gendung.cpp:73
missile
MissileStruct missile[MAXMISSILES]
Definition: missiles.cpp:12
trigflag
BOOL trigflag
Definition: trigs.cpp:6
VIEWPORT_HEIGHT
#define VIEWPORT_HEIGHT
Definition: defs.h:149
MemFreeDbg
#define MemFreeDbg(p)
Definition: defs.h:157
towner
TownerStruct towner[16]
Definition: towners.cpp:13
CheckTown
void CheckTown()
Definition: cursor.cpp:125
all.h
ViewY
int ViewY
Definition: gendung.cpp:74
MissileStruct::_miy
int _miy
Definition: structs.h:410
dObject
char dObject[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:19
infostr
char infostr[256]
Definition: control.cpp:52
SCREEN_WIDTH
#define SCREEN_WIDTH
Definition: defs.h:105
RIGHT_PANEL
#define RIGHT_PANEL
Definition: defs.h:143
MAXDUNY
#define MAXDUNY
Definition: defs.h:26
InitLevelCursor
void InitLevelCursor()
Definition: cursor.cpp:112
BFLAG_LIT
@ BFLAG_LIT
Definition: enums.h:1883
sbookflag
BOOL sbookflag
Definition: control.cpp:48
ClearPanel
void ClearPanel()
Definition: control.cpp:559
SetICursor
void SetICursor(int i)
Definition: cursor.cpp:91
FreeCursor
void FreeCursor()
Definition: cursor.cpp:85
CURSOR_FIRSTITEM
@ CURSOR_FIRSTITEM
Definition: enums.h:2078
CheckCursMove
void CheckCursMove()
Definition: cursor.cpp:180
uitemflag
BOOL uitemflag
Definition: items.cpp:11
DEVILUTION_END_NAMESPACE
#define DEVILUTION_END_NAMESPACE
Definition: types.h:10
monster
MonsterStruct monster[MAXMONSTERS]
Definition: monster.cpp:19
InvItemWidth
const int InvItemWidth[180]
Maps from objcurs.cel frame number to frame width.
Definition: cursor.cpp:31
CheckRportal
void CheckRportal()
Definition: cursor.cpp:151
AddPanelString
void AddPanelString(char *str, BOOL just)
Definition: control.cpp:550
PlayerStruct::_pVar6
int _pVar6
Definition: structs.h:282
LoadFileInMem
BYTE * LoadFileInMem(char *pszName, DWORD *pdwFileLen)
Load a file in to a buffer.
Definition: engine.cpp:801
PANEL_WIDTH
#define PANEL_WIDTH
Definition: defs.h:132
drawsbarflag
BOOL drawsbarflag
Definition: inv.cpp:12
dItem
char dItem[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:57
PlayerStruct::_pxvel
int _pxvel
Definition: structs.h:200
NewCursor
void NewCursor(int i)
Definition: cursor.cpp:107
BFLAG_DEAD_PLAYER
@ BFLAG_DEAD_PLAYER
Definition: enums.h:1879
missileactive
DEVILUTION_BEGIN_NAMESPACE int missileactive[MAXMISSILES]
Definition: missiles.cpp:10
MissileStruct::_mix
int _mix
Definition: structs.h:409
MFLAG_GOLEM
@ MFLAG_GOLEM
Definition: enums.h:1508
CheckPanelInfo
void CheckPanelInfo()
Checks the mouse cursor position within the control panel and sets information strings if needed.
Definition: control.cpp:978
SPANEL_WIDTH
#define SPANEL_WIDTH
Definition: defs.h:139
setlevel
BOOLEAN setlevel
Definition: gendung.cpp:65
pcursmonst
int pcursmonst
Definition: cursor.cpp:13
PANELS_COVER
#define PANELS_COVER
Definition: defs.h:141
pcursobj
char pcursobj
Definition: cursor.cpp:22
DTYPE_TOWN
@ DTYPE_TOWN
Definition: enums.h:1868
spselflag
BOOL spselflag
Definition: control.cpp:62
icursH
int icursH
Definition: cursor.cpp:16
tempstr
char tempstr[256]
Definition: control.cpp:41
invflag
DEVILUTION_BEGIN_NAMESPACE BOOL invflag
Definition: inv.cpp:10
SPANEL_HEIGHT
#define SPANEL_HEIGHT
Definition: defs.h:140
CURSOR_RESURRECT
@ CURSOR_RESURRECT
Definition: enums.h:2074
pcurstemp
int pcurstemp
Definition: cursor.cpp:26
chrflag
BOOL chrflag
Definition: control.cpp:49
CheckInvHLight
char CheckInvHLight()
Definition: inv.cpp:1918
icursW
int icursW
Definition: cursor.cpp:20
pcursitem
char pcursitem
Definition: cursor.cpp:21
myplr
int myplr
Definition: player.cpp:9
cursmy
int cursmy
Definition: cursor.cpp:25
nummissiles
int nummissiles
Definition: missiles.cpp:13
PlayerStruct::_pVar7
int _pVar7
Definition: structs.h:283
icursW28
int icursW28
Definition: cursor.cpp:14
pcurs
int pcurs
Definition: cursor.cpp:27
dMonster
int dMonster[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:17
DEVILUTION_BEGIN_NAMESPACE
Definition: sha.cpp:10
PANEL_TOP
#define PANEL_TOP
Definition: defs.h:134
pCursCels
BYTE * pCursCels
Definition: cursor.cpp:15
PANEL_LEFT
#define PANEL_LEFT
Definition: defs.h:135
panelflag
BOOL panelflag
Definition: control.cpp:56
dPlayer
char dPlayer[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:49
dFlags
char dFlags[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:56
ScrollInfo
ScrollStruct ScrollInfo
Definition: gendung.cpp:46
ScrollStruct::_syoff
int _syoff
Definition: structs.h:1107
track_isscrolling
BOOL track_isscrolling()
Definition: track.cpp:46
MFLAG_HIDDEN
@ MFLAG_HIDDEN
Definition: enums.h:1503
ScrollStruct::_sxoff
int _sxoff
Definition: structs.h:1106
SCREEN_HEIGHT
#define SCREEN_HEIGHT
Definition: defs.h:106
leveltype
BYTE leveltype
Definition: gendung.cpp:39
plr
PlayerStruct plr[MAX_PLRS]
Definition: player.cpp:10
CURSOR_IDENTIFY
@ CURSOR_IDENTIFY
Definition: enums.h:2068
PlayerStruct::_pyvel
int _pyvel
Definition: structs.h:201
MouseX
int MouseX
Definition: diablo.cpp:18
icursH28
int icursH28
Definition: cursor.cpp:11
InvItemHeight
const int InvItemHeight[180]
Maps from objcurs.cel frame number to frame height.
Definition: cursor.cpp:55
cursW
int cursW
Definition: cursor.cpp:12
SDIR_NONE
@ SDIR_NONE
Definition: enums.h:2094
ClearCursor
void ClearCursor()
Clear cursor state.
Definition: scrollrt.cpp:96