Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / sphrase_com.h
blobc38f0cfdfe9d8da643c82a46771fe90488f2aacf
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
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 Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef RY_SPHRASE_H
23 #define RY_SPHRASE_H
25 #include "nel/misc/types_nl.h"
26 #include "nel/misc/sheet_id.h"
27 #include "nel/misc/stream.h"
28 #include "persistent_data.h"
29 #include "persistent_data.h"
30 #include "inventories.h"
33 // ***************************************************************************
34 /**
35 * Description of a Sabrina Phrase. (ie set of brick, and other client side infos)
36 * For communication Client/Server (NB: CSPhrase name already exist...)
37 * \author Lionel Berenguier
38 * \author Nevrax France
39 * \date 2003
41 class CSPhraseCom
43 public:
44 static const CSPhraseCom EmptyPhrase;
46 public:
47 // Start by declaring methods for persistent load/ save operations
48 // The following macro is defined in persistent_data.h
49 // At time of writing it evaluated to:
50 // void store(CPersistentDataRecord &pdr) const;
51 // void apply(CPersistentDataRecord &pdr);
53 DECLARE_PERSISTENCE_METHODS
55 /// Constructor
56 CSPhraseCom(): IconIndex(std::numeric_limits<uint8>::max())
59 // clear out the contents before filling with new data...
60 void clear()
62 Bricks.clear();
63 Name.clear();
64 IconIndex = std::numeric_limits<uint8>::max();
67 // List Of SBricks composing the phrase.
68 std::vector<NLMISC::CSheetId> Bricks;
70 // Name Of the Phrase. Saved on server, read on client.
71 ucstring Name; // FIXME: UTF-8 (serial)
73 // Index into Bricks to use as icon (if out of range, then automatic icon selection)
74 uint8 IconIndex;
76 /// The comparison is made only on Bricks
77 bool operator==(const CSPhraseCom &p) const;
78 bool operator!=(const CSPhraseCom &p) const {return !operator==(p);}
79 bool operator<(const CSPhraseCom &p) const;
81 /// consider empty if Bricks.empty() or if brick 0 is 0.
82 bool empty() const {return Bricks.empty() || Bricks[0].asInt()==0;}
84 /// This serial is made for server->client com. NB: SheetId must be init.
85 void serial(NLMISC::IStream &impulse);
89 // ***************************************************************************
90 /**
91 * Tuple Sabrina / Known Slot.
92 * \author Lionel Berenguier
93 * \author Nevrax France
94 * \date 2003
96 class CSPhraseSlot
98 public:
99 CSPhraseCom Phrase;
100 uint16 KnownSlot;
101 NLMISC::CSheetId PhraseSheetId;
103 /// This serial is made for server->client com.
104 void serial(NLMISC::IStream &impulse);
108 // ***************************************************************************
109 class CSPhraseMemorySlot
111 public:
112 uint8 MemoryLineId;
113 uint8 MemorySlotId;
114 uint16 PhraseId;
116 /// This serial is made for server->client com.
117 void serial(NLMISC::IStream &impulse);
120 // ***************************************************************************
121 class CFaberMsgItem
123 uint8 InvId; // matchs INVENTORIES::EInventory
124 public:
125 uint16 IndexInInv; // index in the inventory
126 uint16 Quantity; // quantity of mp selected
128 void setInvId(INVENTORIES::TInventory invId)
130 InvId = invId;
132 INVENTORIES::TInventory getInvId()
134 return INVENTORIES::TInventory(InvId);
136 /// This serial is made for server->client com.
137 void serial(NLMISC::IStream &impulse);
140 #endif // NL_SPHRASE_H
142 /* End of sphrase_com.h */