Devilution
Diablo devolved - magic behind the 1996 computer game
error.cpp
Go to the documentation of this file.
1 
6 #include "all.h"
7 
9 
11 DWORD msgdelay;
12 char msgflag;
13 char msgcnt;
14 
16 char *MsgStrings[44] = {
17  "",
18  "No automap available in town",
19  "No multiplayer functions in demo",
20  "Direct Sound Creation Failed",
21  "Not available in shareware version",
22  "Not enough space to save",
23  "No Pause in town",
24  "Copying to a hard disk is recommended",
25  "Multiplayer sync problem",
26  "No pause in multiplayer",
27  "Loading...",
28  "Saving...",
29  "Some are weakened as one grows strong",
30  "New strength is forged through destruction",
31  "Those who defend seldom attack",
32  "The sword of justice is swift and sharp",
33  "While the spirit is vigilant the body thrives",
34  "The powers of mana refocused renews",
35  "Time cannot diminish the power of steel",
36  "Magic is not always what it seems to be",
37  "What once was opened now is closed",
38  "Intensity comes at the cost of wisdom",
39  "Arcane power brings destruction",
40  "That which cannot be held cannot be harmed",
41  "Crimson and Azure become as the sun",
42  "Knowledge and wisdom at the cost of self",
43  "Drink and be refreshed",
44  "Wherever you go, there you are",
45  "Energy comes at the cost of wisdom",
46  "Riches abound when least expected",
47  "Where avarice fails, patience gains reward",
48  "Blessed by a benevolent companion!",
49  "The hands of men may be guided by fate",
50  "Strength is bolstered by heavenly faith",
51  "The essence of life flows from within",
52  "The way is made clear when viewed from above",
53  "Salvation comes at the cost of wisdom",
54  "Mysteries are revealed in the light of reason",
55  "Those who are last may yet be first",
56  "Generosity brings its own rewards",
57  "You must be at least level 8 to use this.",
58  "You must be at least level 13 to use this.",
59  "You must be at least level 17 to use this.",
60  "Arcane knowledge gained!"
61 };
62 
63 void InitDiabloMsg(char e)
64 {
65  int i;
66 
67  if (msgcnt >= sizeof(msgtable))
68  return;
69 
70  for (i = 0; i < msgcnt; i++) {
71  if (msgtable[i] == e)
72  return;
73  }
74 
75  msgtable[msgcnt] = e;
76  msgcnt++;
77 
78  msgflag = msgtable[0];
79  msgdelay = SDL_GetTicks();
80 }
81 
83 {
84  int i;
85 
86  for (i = 0; i < sizeof(msgtable); i++)
87  msgtable[i] = 0;
88 
89  msgflag = 0;
90  msgcnt = 0;
91 }
92 
94 {
95  int i, len, width, sx, sy;
96  BYTE c;
97 
98  CelDraw(PANEL_X + 101, DIALOG_Y, pSTextSlidCels, 1, 12);
99  CelDraw(PANEL_X + 527, DIALOG_Y, pSTextSlidCels, 4, 12);
100  CelDraw(PANEL_X + 101, DIALOG_Y + 48, pSTextSlidCels, 2, 12);
101  CelDraw(PANEL_X + 527, DIALOG_Y + 48, pSTextSlidCels, 3, 12);
102 
103  sx = PANEL_X + 109;
104  for (i = 0; i < 35; i++) {
105  CelDraw(sx, DIALOG_Y, pSTextSlidCels, 5, 12);
106  CelDraw(sx, DIALOG_Y + 48, pSTextSlidCels, 7, 12);
107  sx += 12;
108  }
109  sy = DIALOG_Y + 12;
110  for (i = 0; i < 3; i++) {
111  CelDraw(PANEL_X + 101, sy, pSTextSlidCels, 6, 12);
112  CelDraw(PANEL_X + 527, sy, pSTextSlidCels, 8, 12);
113  sy += 12;
114  }
115 
117 
118  trans_rect(PANEL_LEFT + 104, DIALOG_TOP - 8, 432, 54);
119 
120  strcpy(tempstr, MsgStrings[msgflag]);
121  sx = PANEL_X + 101;
122  sy = DIALOG_Y + 24;
123  len = strlen(tempstr);
124  width = 0;
125 
126  for (i = 0; i < len; i++) {
127  width += fontkern[fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]] + 1;
128  }
129 
130  if (width < 442) {
131  sx += (442 - width) >> 1;
132  }
133 
134  for (i = 0; i < len; i++) {
135  c = fontframe[gbFontTransTbl[(BYTE)tempstr[i]]];
136  if (c != '\0') {
137  PrintChar(sx, sy, c, COL_GOLD);
138  }
139  sx += fontkern[c] + 1;
140  }
141 
142  if (msgdelay > 0 && msgdelay <= SDL_GetTicks() - 3500) {
143  msgdelay = 0;
144  }
145  if (msgdelay == 0) {
146  msgcnt--;
147  if (msgcnt == 0) {
148  msgflag = 0;
149  } else {
151  msgdelay = SDL_GetTicks();
152  }
153  }
154 }
155 
trans_rect
void trans_rect(int sx, int sy, int width, int height)
Draws a half-transparent rectangle by blacking out odd pixels on odd lines, even pixels on even lines...
Definition: render.cpp:342
PANEL_X
#define PANEL_X
Definition: defs.h:136
COL_GOLD
@ COL_GOLD
Definition: enums.h:1996
msgdelay
DWORD msgdelay
Definition: error.cpp:11
all.h
msgtable
DEVILUTION_BEGIN_NAMESPACE char msgtable[MAX_SEND_STR_LEN]
Definition: error.cpp:10
DEVILUTION_END_NAMESPACE
#define DEVILUTION_END_NAMESPACE
Definition: types.h:10
MsgStrings
char * MsgStrings[44]
Maps from error_id to error message.
Definition: error.cpp:16
pSTextSlidCels
BYTE * pSTextSlidCels
Definition: stores.cpp:26
CelDraw
void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
Blit CEL sprite to the back buffer at the given coordinates.
Definition: engine.cpp:47
msgcnt
char msgcnt
Definition: error.cpp:13
ClrDiabloMsg
void ClrDiabloMsg()
Definition: error.cpp:82
fontkern
const BYTE fontkern[68]
Maps from smaltext.cel frame number to character width.
Definition: control.cpp:81
DIALOG_TOP
#define DIALOG_TOP
Definition: defs.h:152
tempstr
char tempstr[256]
Definition: control.cpp:41
msgflag
char msgflag
Definition: error.cpp:12
MAX_SEND_STR_LEN
#define MAX_SEND_STR_LEN
Definition: defs.h:21
DIALOG_Y
#define DIALOG_Y
Definition: defs.h:153
InitDiabloMsg
void InitDiabloMsg(char e)
Definition: error.cpp:63
DEVILUTION_BEGIN_NAMESPACE
Definition: sha.cpp:10
PANEL_LEFT
#define PANEL_LEFT
Definition: defs.h:135
PrintChar
void PrintChar(int sx, int sy, int nCel, char col)
Print letter to the back buffer.
Definition: control.cpp:504
fontframe
const BYTE fontframe[128]
Maps from font index to smaltext.cel frame number.
Definition: control.cpp:65
gbFontTransTbl
const BYTE gbFontTransTbl[256]
Maps ASCII character code to font index, as used by the small, medium and large sized fonts; which co...
Definition: control.cpp:106
DrawDiabloMsg
void DrawDiabloMsg()
Definition: error.cpp:93