1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2008 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
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.
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/>.
18 #ifndef SERVICE_EMPTY_SERVICE_H
19 #define SERVICE_EMPTY_SERVICE_H
21 // This include is mandatory to use NeL. It include NeL types.
22 #include <nel/misc/types_nl.h>
24 // Some other NeL structures that can be used.
25 #include <nel/misc/vector.h>
26 #include <nel/misc/vectord.h>
27 #include <nel/misc/time_nl.h>
29 // The stuff from PACS
30 #include <nel/pacs/u_retriever_bank.h>
31 #include <nel/pacs/u_global_retriever.h>
32 #include <nel/pacs/u_move_container.h>
33 #include <nel/pacs/u_move_primitive.h>
35 // And we're also using the NeL Service framework, layer 5.
36 #include <nel/net/service.h>
40 class CCollisionService
: public NLNET::IService
45 CEntity() : OldClientPosition(), NewClientPosition(), MovePrimitive(NULL
), Distance(0.0f
), Moving(false), Retry(false) { }
46 NLMISC::CVector OldClientPosition
;
47 NLMISC::CVector NewClientPosition
;
48 NLPACS::UMovePrimitive
*MovePrimitive
; // ServerPosition
53 typedef std::map
<uint32
, CEntity
> CEntityMap
;
54 typedef std::map
<uint16
, CEntityMap
> CClientMap
;
55 typedef std::vector
<NLPACS::UMovePrimitive
*> CMovePrimitiveVector
;
58 // The list of registered services, their entities, and their move primitive
59 static CClientMap _Clients
;
60 // The retriever bank used in the world
61 static NLPACS::URetrieverBank
*_RetrieverBank
;
62 // The global retriever used for pacs
63 static NLPACS::UGlobalRetriever
*_GlobalRetriever
;
64 // The move container used for dynamic collisions
65 static NLPACS::UMoveContainer
*_MoveContainer
;
66 // The collision primitive for the static entities
67 static CMovePrimitiveVector _StaticMovePrimitives
;
69 static NLMISC::TTime _LastTime
, _NewTime
, _DiffTime
;
70 static double _DiffTimeSeconds
;
71 static float _DiffTimeFloat
;
74 virtual void commandStart();
76 virtual bool update();
77 virtual void release();
79 static void sendMessage(NLNET::CMessage
&msgout
);
81 static void msgUpdate();
82 static void msgPosition(uint32 id
, NLMISC::CVector position
);
84 static void cbAdd(NLNET::CMessage
&msgin
, const std::string
&serviceName
, NLNET::TServiceId sid
);
85 static void cbMove(NLNET::CMessage
&msgin
, const std::string
&serviceName
, NLNET::TServiceId sid
);
86 static void cbRemove(NLNET::CMessage
&msgin
, const std::string
&serviceName
, NLNET::TServiceId sid
);
87 static void cbRegister(NLNET::CMessage
&msgin
, const std::string
&serviceName
, NLNET::TServiceId sid
);
89 static void cbDown(const std::string
&serviceName
, NLNET::TServiceId sid
, void *arg
);
94 #endif /* SERVICE_EMPTY_SERVICE_H */