forked from diasurgical/devilution
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.cpp
More file actions
166 lines (147 loc) · 4.17 KB
/
error.cpp
File metadata and controls
166 lines (147 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/**
* @file error.cpp
*
* Implementation of in-game message functions.
*/
#include "all.h"
char msgtable[MAX_SEND_STR_LEN];
char msgdelay;
char msgflag;
char msgcnt;
/** Maps from error_id to error message. */
const char *const MsgStrings[] = {
"",
"No automap available in town",
"No multiplayer functions in demo",
"Direct Sound Creation Failed",
"Not available in shareware version",
"Not enough space to save",
"No Pause in town",
"Copying to a hard disk is recommended",
"Multiplayer sync problem",
"No pause in multiplayer",
"Loading...",
"Saving...",
"Some are weakened as one grows strong",
"New strength is forged through destruction",
"Those who defend seldom attack",
"The sword of justice is swift and sharp",
"While the spirit is vigilant the body thrives",
"The powers of mana refocused renews",
"Time cannot diminish the power of steel",
"Magic is not always what it seems to be",
"What once was opened now is closed",
"Intensity comes at the cost of wisdom",
"Arcane power brings destruction",
"That which cannot be held cannot be harmed",
"Crimson and Azure become as the sun",
"Knowledge and wisdom at the cost of self",
"Drink and be refreshed",
"Wherever you go, there you are",
"Energy comes at the cost of wisdom",
"Riches abound when least expected",
"Where avarice fails, patience gains reward",
"Blessed by a benevolent companion!",
"The hands of men may be guided by fate",
"Strength is bolstered by heavenly faith",
"The essence of life flows from within",
"The way is made clear when viewed from above",
"Salvation comes at the cost of wisdom",
"Mysteries are revealed in the light of reason",
"Those who are last may yet be first",
"Generosity brings its own rewards",
"You must be at least level 8 to use this.",
"You must be at least level 13 to use this.",
"You must be at least level 17 to use this.",
"Arcane knowledge gained!",
#ifdef HELLFIRE
"That which does not kill you...",
"Knowledge is power.",
"Give and you shall receive.",
"Some experience is gained by touch.",
"There's no place like home.",
"Spirtual energy is restored.",
"You feel more agile.",
"You feel stronger.",
"You feel wiser.",
"You feel refreshed.",
"That which can break will.",
#endif
};
void InitDiabloMsg(char e)
{
int i;
for (i = 0; i < msgcnt; i++) {
if (msgtable[i] == e)
return;
}
msgtable[msgcnt] = e; // BUGFIX: missing out-of-bounds check
if (msgcnt < (BYTE)sizeof(msgtable))
msgcnt++;
msgflag = msgtable[0];
msgdelay = 70;
}
void ClrDiabloMsg()
{
int i;
for (i = 0; i < sizeof(msgtable); i++)
msgtable[i] = 0;
msgflag = 0;
msgcnt = 0;
}
void DrawDiabloMsg()
{
int i, len, off, width, sx, sy;
BYTE c;
CelDraw(PANEL_X + 101, DIALOG_Y, pSTextSlidCels, 1, 12);
CelDraw(PANEL_X + 527, DIALOG_Y, pSTextSlidCels, 4, 12);
CelDraw(PANEL_X + 101, DIALOG_Y + 48, pSTextSlidCels, 2, 12);
CelDraw(PANEL_X + 527, DIALOG_Y + 48, pSTextSlidCels, 3, 12);
sx = PANEL_X + 109;
for (i = 0; i < 35; i++) {
CelDraw(sx, DIALOG_Y, pSTextSlidCels, 5, 12);
CelDraw(sx, DIALOG_Y + 48, pSTextSlidCels, 7, 12);
sx += 12;
}
sy = DIALOG_Y + 12;
for (i = 0; i < 3; i++) {
CelDraw(PANEL_X + 101, sy, pSTextSlidCels, 6, 12);
CelDraw(PANEL_X + 527, sy, pSTextSlidCels, 8, 12);
sy += 12;
}
assert(gpBuffer);
#define TRANS_RECT_X (PANEL_LEFT + 104)
#define TRANS_RECT_Y (DIALOG_TOP - 8)
#define TRANS_RECT_WIDTH 432
#define TRANS_RECT_HEIGHT 54
#include "asm_trans_rect.inc"
strcpy(tempstr, MsgStrings[msgflag]);
off = PANEL_X + 101 + PitchTbl[DIALOG_Y + 24];
len = strlen(tempstr);
width = 0;
for (i = 0; i < len; i++) {
width += fontkern[fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]] + 1;
}
if (width < 442) {
off += (442 - width) >> 1;
}
for (i = 0; i < len; i++) {
c = fontframe[gbFontTransTbl[(BYTE)tempstr[i]]];
if (c != '\0') {
PrintChar(off, c, COL_GOLD);
}
off += fontkern[c] + 1;
}
if (msgdelay > 0) {
msgdelay--;
}
if (msgdelay == 0) {
msgcnt--;
msgdelay = 70;
if (msgcnt == 0) {
msgflag = 0;
} else {
msgflag = msgtable[msgcnt];
}
}
}