ScummVM API documentation
utils.h
1
/* ScummVM - Graphic Adventure Engine
2
*
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*
20
*/
21
22
#ifndef ULTIMA4_CORE_UTILS_H
23
#define ULTIMA4_CORE_UTILS_H
24
25
#include "ultima/ultima4/ultima4.h"
26
#include "common/savefile.h"
27
#include "common/hash-str.h"
28
29
namespace
Ultima {
30
namespace
Ultima4 {
31
32
extern
void
assertMsg(
bool
exp,
const
char
*desc, ...);
33
34
/* The AdjustValue functions used to be #define'd macros, but these are
35
* evil for several reasons, *especially* when they contain multiple
36
* statements, and have if statements in them. The macros did both.
37
* See https://isocpp.org/wiki/faq/inline-functions#inline-vs-macros
38
* for more information.
39
*/
40
inline
void
AdjustValueMax(
int
&v,
int
val,
int
max) {
41
v += val;
42
if
(v > max) v = max;
43
}
44
inline
void
AdjustValueMin(
int
&v,
int
val,
int
min) {
45
v += val;
46
if
(v < min) v = min;
47
}
48
inline
void
AdjustValue(
int
&v,
int
val,
int
max,
int
min) {
49
v += val;
50
if
(v > max) v = max;
51
if
(v < min) v = min;
52
}
53
54
inline
void
AdjustValueMax(
short
&v,
int
val,
int
max) {
55
v += val;
56
if
(v > max) v = max;
57
}
58
inline
void
AdjustValueMin(
short
&v,
int
val,
int
min) {
59
v += val;
60
if
(v < min) v = min;
61
}
62
inline
void
AdjustValue(
short
&v,
int
val,
int
max,
int
min) {
63
v += val;
64
if
(v > max) v = max;
65
if
(v < min) v = min;
66
}
67
68
inline
void
AdjustValueMax(
unsigned
short
&v,
int
val,
int
max) {
69
v += val;
70
if
(v > max) v = max;
71
}
72
inline
void
AdjustValueMin(
unsigned
short
&v,
int
val,
int
min) {
73
v += val;
74
if
(v < min) v = min;
75
}
76
inline
void
AdjustValue(
unsigned
short
&v,
int
val,
int
max,
int
min) {
77
v += val;
78
if
(v > max) v = max;
79
if
(v < min) v = min;
80
}
81
85
void
xu4_srandom();
86
90
int
xu4_random(
int
upperval);
91
97
Common::String
&trim(
Common::String
&val,
const
Common::String
&chars_to_trim =
"\t\013\014 \n\r"
);
98
102
Common::String
&lowercase(
Common::String
&val);
103
107
Common::String
&uppercase(
Common::String
&val);
108
112
Common::String
xu4_to_string(
int
val);
113
118
Common::Array<Common::String>
split(
const
Common::String
&s,
const
Common::String
&separators);
119
120
}
// End of namespace Ultima4
121
}
// End of namespace Ultima
122
123
#endif
Common::Array< Common::String >
Common::String
Definition:
str.h:59
engines
ultima
ultima4
core
utils.h
Generated on Sat Oct 24 2026 09:22:06 for ScummVM API documentation by
1.9.4