Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / action_sync.h
blob794050d97800820df92b15b4e426aedb766f1195
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program 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 Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef NL_ACTION_SYNC_H
20 #define NL_ACTION_SYNC_H
22 #include "nel/misc/types_nl.h"
23 #include "nel/misc/time_nl.h"
25 #include "action.h"
26 //#include "../frontend_service/fe_types.h"
29 namespace CLFECOMMON {
31 /**
32 * <Class description>
33 * \author Benjamin Legros
34 * \author Nevrax France
35 * \date 2001
37 class CActionSync : public CAction
39 public:
40 /** This function creates initializes its fields using the buffer.
41 * \param buffer pointer to the buffer where the data are
42 * \size size of the buffer
44 virtual void unpack (NLMISC::CBitMemStream &message) { message.serial(Sync); message.serial(BKEntityId); }
46 /// This functions is used when you want to transform an action into an IStream.
47 virtual void serial (NLMISC::IStream &f) { f.serial(Sync); f.serial(BKEntityId); }
49 /** Returns the size of this action when it will be send to the UDP connection:
50 * the size is IN BITS, not in bytes (the actual size is this one plus the header size)
52 virtual uint32 size () { return 8*sizeof(Sync)+64; }
54 /// Sets the value of the action
55 virtual void setValue(const TValue &value) { Sync = (NLMISC::TGameCycle)value; }
57 /// Sets the value of the action
58 virtual TValue getValue() const { return CAction::TValue((sint64)Sync); }
60 /// Returns true if the property is continuous
61 virtual bool isContinuous() const { return false; }
63 static CAction *create () { return new CActionSync; }
65 public:
66 /// The sync value
67 NLMISC::TGameCycle Sync;
69 /// obsolete
70 NLMISC::CEntityId BKEntityId;
72 protected:
74 /** This function transform the internal field and transform them into a buffer for the UDP connection.
75 * \param buffer pointer to the buffer where the data will be written
76 * \size size of the buffer
78 virtual void pack (NLMISC::CBitMemStream &message) { message.serial(Sync); message.serial(BKEntityId); }
80 virtual void reset() { Sync = 0; }
82 friend class CActionFactory;
87 #endif // NL_ACTION_SYNC_H
89 /* End of action_sync.h */