OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
waypath.cpp
Go to the documentation of this file.
1
#include "
waypath.h
"
2
3
#include "
game/serialize.h
"
4
#include <cstdint>
5
6
WayPath::WayPath
() {
7
}
8
9
void
WayPath::load
(
Serialize
&fin) {
10
uint32_t sz=0;
11
fin.
read
(sz);
12
dat.resize(sz);
13
14
for
(
auto
& i:dat)
15
fin.
read
(i);
16
}
17
18
void
WayPath::save
(
Serialize
&fout) {
19
fout.
write
(uint32_t(dat.size()));
20
21
for
(
auto
& i:dat)
22
fout.
write
(i);
23
}
24
25
void
WayPath::clear
() {
26
dat.clear();
27
}
28
29
void
WayPath::reverse
() {
30
for
(
size_t
i=0; i<dat.size()/2; ++i) {
31
std::swap(dat[i], dat[dat.size()-i-1]);
32
}
33
}
34
35
const
WayPoint
*
WayPath::pop
() {
36
if
(dat.size()==0)
37
return
nullptr
;
38
auto
ret = dat[dat.size()-1];
39
dat.pop_back();
40
return
ret;
41
}
42
43
const
WayPoint
*
WayPath::first
()
const
{
44
if
(dat.size()==0)
45
return
nullptr
;
46
return
dat[dat.size()-1];
47
}
48
49
const
WayPoint
*
WayPath::last
()
const
{
50
if
(dat.size()==0)
51
return
nullptr
;
52
return
dat[0];
53
}
Serialize
Definition
serialize.h:33
Serialize::write
void write(const Arg &... a)
Definition
serialize.h:76
Serialize::read
void read(Arg &... a)
Definition
serialize.h:81
WayPath::WayPath
WayPath()
Definition
waypath.cpp:6
WayPath::save
void save(Serialize &fout)
Definition
waypath.cpp:18
WayPath::first
const WayPoint * first() const
Definition
waypath.cpp:43
WayPath::last
const WayPoint * last() const
Definition
waypath.cpp:49
WayPath::load
void load(Serialize &fin)
Definition
waypath.cpp:9
WayPath::pop
const WayPoint * pop()
Definition
waypath.cpp:35
WayPath::clear
void clear()
Definition
waypath.cpp:25
WayPath::reverse
void reverse()
Definition
waypath.cpp:29
WayPoint
Definition
waypoint.h:11
serialize.h
waypath.h
game
world
waypath.cpp
Generated by
1.9.8