Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
SerializedPathfinder.h
Go to the documentation of this file.
1/* Copyright (C) 2020 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_SERIALIZATION_PATHFINDER
19#define INCLUDED_SERIALIZATION_PATHFINDER
20
22
23template<>
25{
26 void operator()(ISerializer& serialize, const char* UNUSED(name), const Waypoint& value)
27 {
28 serialize.NumberFixed_Unbounded("waypoint x", value.x);
29 serialize.NumberFixed_Unbounded("waypoint z", value.z);
30 }
31
32 void operator()(IDeserializer& deserialize, const char* UNUSED(name), Waypoint& value)
33 {
34 deserialize.NumberFixed_Unbounded("waypoint x", value.x);
35 deserialize.NumberFixed_Unbounded("waypoint z", value.z);
36 }
37};
38
39template<>
41{
42 template<typename S>
43 void operator()(S& serialize, const char* UNUSED(name), Serialize::qualify<S, PathGoal> value)
44 {
45 Serializer(serialize, "type", value.type, PathGoal::INVERTED_SQUARE);
46 serialize.NumberFixed_Unbounded("goal x", value.x);
47 serialize.NumberFixed_Unbounded("goal z", value.z);
48 serialize.NumberFixed_Unbounded("goal u x", value.u.X);
49 serialize.NumberFixed_Unbounded("goal u z", value.u.Y);
50 serialize.NumberFixed_Unbounded("goal v x", value.v.X);
51 serialize.NumberFixed_Unbounded("goal v z", value.v.Y);
52 serialize.NumberFixed_Unbounded("goal hw", value.hw);
53 serialize.NumberFixed_Unbounded("goal hh", value.hh);
54 serialize.NumberFixed_Unbounded("maxdist", value.maxdist);
55 }
56};
57
58#endif // INCLUDED_SERIALIZATION_PATHFINDER
Helper templates definitions for serializing/deserializing common objects.
void Serializer(S &serialize, const char *name, Args &&... args)
Definition: SerializeTemplates.h:51
Deserialization interface; see serialization overview.
Definition: IDeserializer.h:35
virtual void NumberFixed_Unbounded(const char *name, fixed &out)
Definition: IDeserializer.cpp:148
Serialization interface; see serialization overview.
Definition: ISerializer.h:121
void NumberFixed_Unbounded(const char *name, fixed value)
Serialize a number.
Definition: ISerializer.h:191
Pathfinder goal.
Definition: PathGoal.h:33
@ INVERTED_SQUARE
Definition: PathGoal.h:40
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning.
Definition: code_annotation.h:40
std::conditional_t< std::is_same_v< S, ISerializer & >, const T &, T & > qualify
Definition: SerializeTemplates.h:66
void operator()(S &serialize, const char *name, Serialize::qualify< S, PathGoal > value)
Definition: SerializedPathfinder.h:43
void operator()(ISerializer &serialize, const char *name, const Waypoint &value)
Definition: SerializedPathfinder.h:26
void operator()(IDeserializer &deserialize, const char *name, Waypoint &value)
Definition: SerializedPathfinder.h:32
Definition: SerializeTemplates.h:42
Definition: Pathfinding.h:58
entity_pos_t x
Definition: Pathfinding.h:59
entity_pos_t z
Definition: Pathfinding.h:59