ScummVM API documentation
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
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 "ultima/shared/std/containers.h"
27
#include "common/savefile.h"
28
#include "common/hash-str.h"
29
30
namespace
Ultima
{
31
namespace
Ultima4 {
32
33
extern
void
assertMsg(
bool
exp,
const
char
*desc, ...);
34
35
/* The AdjustValue functions used to be #define'd macros, but these are
36
* evil for several reasons, *especially* when they contain multiple
37
* statements, and have if statements in them. The macros did both.
38
* See https://isocpp.org/wiki/faq/inline-functions#inline-vs-macros
39
* for more information.
40
*/
41
inline
void
AdjustValueMax(
int
&v,
int
val,
int
max) {
42
v += val;
43
if
(v > max) v = max;
44
}
45
inline
void
AdjustValueMin(
int
&v,
int
val,
int
min) {
46
v += val;
47
if
(v < min) v = min;
48
}
49
inline
void
AdjustValue(
int
&v,
int
val,
int
max,
int
min) {
50
v += val;
51
if
(v > max) v = max;
52
if
(v < min) v = min;
53
}
54
55
inline
void
AdjustValueMax(
short
&v,
int
val,
int
max) {
56
v += val;
57
if
(v > max) v = max;
58
}
59
inline
void
AdjustValueMin(
short
&v,
int
val,
int
min) {
60
v += val;
61
if
(v < min) v = min;
62
}
63
inline
void
AdjustValue(
short
&v,
int
val,
int
max,
int
min) {
64
v += val;
65
if
(v > max) v = max;
66
if
(v < min) v = min;
67
}
68
69
inline
void
AdjustValueMax(
unsigned
short
&v,
int
val,
int
max) {
70
v += val;
71
if
(v > max) v = max;
72
}
73
inline
void
AdjustValueMin(
unsigned
short
&v,
int
val,
int
min) {
74
v += val;
75
if
(v < min) v = min;
76
}
77
inline
void
AdjustValue(
unsigned
short
&v,
int
val,
int
max,
int
min) {
78
v += val;
79
if
(v > max) v = max;
80
if
(v < min) v = min;
81
}
82
86
void
xu4_srandom();
87
91
int
xu4_random(
int
upperval);
92
98
Common::String
&trim(
Common::String
&val,
const
Common::String
&chars_to_trim =
"\t\013\014 \n\r"
);
99
103
Common::String
&lowercase(
Common::String
&val);
104
108
Common::String
&uppercase(
Common::String
&val);
109
113
Common::String
xu4_to_string(
int
val);
114
119
Std::vector<Common::String>
split(
const
Common::String
&s,
const
Common::String
&separators);
120
121
}
// End of namespace Ultima4
122
}
// End of namespace Ultima
123
124
#endif
Std::vector< Common::String >
Common::String
Definition:
str.h:59
Ultima
Definition:
detection.h:27
engines
ultima
ultima4
core
utils.h
Generated on Tue Apr 15 2025 09:18:02 for ScummVM API documentation by
1.8.13