EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
KeeperService.cpp
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Zhur
24  Updates: Allan
25 */
26 
27 /* Dungeon Logging
28  * DUNG__ERROR
29  * DUNG__WARNING
30  * DUNG__INFO
31  * DUNG__MESSAGE
32  * DUNG__TRACE
33  * DUNG__CALL
34  * DUNG__CALL_DUMP
35  * DUNG__RSP_DUMP
36  * DUNG__DB_ERROR
37  * DUNG__DB_WARNING
38  * DUNG__DB_INFO
39  * DUNG__DB_MESSAGE
40  */
41 
42 #include "eve-server.h"
43 
44 #include "PyBoundObject.h"
45 #include "PyServiceCD.h"
46 #include "system/KeeperService.h"
47 #include "system/SystemManager.h"
48 
50 : public PyBoundObject
51 {
52 public:
54 
56  : PyBoundObject(mgr),
57  m_db(db),
58  m_dispatch(new Dispatcher(this))
59  {
61 
62  m_strBoundObjectName = "KeeperBound";
63 
64  PyCallable_REG_CALL(KeeperBound, EditDungeon);
65  PyCallable_REG_CALL(KeeperBound, PlayDungeon);
67  PyCallable_REG_CALL(KeeperBound, GotoRoom); //(int room)
68  PyCallable_REG_CALL(KeeperBound, GetCurrentlyEditedRoomID);
69 
70  }
71  virtual ~KeeperBound() { delete m_dispatch; }
72  virtual void Release() {
73  //I hate this statement
74  delete this;
75  }
76 
77  PyCallable_DECL_CALL(EditDungeon);
78  PyCallable_DECL_CALL(PlayDungeon);
79  PyCallable_DECL_CALL(Reset);
80  PyCallable_DECL_CALL(GotoRoom);
81  PyCallable_DECL_CALL(GetCurrentlyEditedRoomID);
82 
83 protected:
84  SystemDB *const m_db;
85  Dispatcher *const m_dispatch; //we own this
86 };
87 
88 
90 
92 : PyService(mgr, "keeper"),
93  m_dispatch(new Dispatcher(this))
94 {
95  _SetCallDispatcher(m_dispatch);
96 
97  PyCallable_REG_CALL(KeeperService, GetLevelEditor);
98  PyCallable_REG_CALL(KeeperService, ActivateAccelerationGate);
99  PyCallable_REG_CALL(KeeperService, CanWarpToPathPlex);
100 
101  //sm.RemoteSvc('keeper').ClientBSDRevisionChange(action, schemaName, tableName, rowKeys, columnValues, reverting)
102 }
103 
105  delete m_dispatch;
106 }
107 
109  _log(DUNG__TRACE, "KeeperService bind request for:");
110  bind_args->Dump(DUNG__TRACE, " ");
111 
112  return new KeeperBound(m_manager, &m_db);
113 }
114 
115 PyResult KeeperService::Handle_GetLevelEditor(PyCallArgs &call)
116 {
117  // self.ed = sm.RemoteSvc('keeper').GetLevelEditor() (this is to bind new editor object)
118  _log(DUNG__CALL, "KeeperService::Handle_GetLevelEditor size: %u", call.tuple->size());
119  call.Dump(DUNG__CALL_DUMP);
120 
121  KeeperBound *ib = new KeeperBound(m_manager, &m_db);
122 
123  return m_manager->BindObject(call.client, ib);
124 }
125 
126 PyResult KeeperService::Handle_CanWarpToPathPlex(PyCallArgs &call) {
127  /*
128  resp = sm.RemoteSvc('keeper').CanWarpToPathPlex(node.rec.instanceID)
129  if resp:
130  if resp is True:
131  m.append((uiutil.MenuLabel('UI/Inflight/WarpToBookmark'), self.WarpToHiddenDungeon, (node.id, node)))
132  else:
133  mickey = sm.StartService('michelle')
134  me = mickey.GetBall(eve.session.shipid)
135  dist = (foo.Vector3(resp) - foo.Vector3(me.x, me.y, me.z)).Length()
136 
137  */
138  _log(DUNG__CALL, "KeeperService::Handle_CanWarpToPathPlex size: %u", call.tuple->size());
139  call.Dump(DUNG__CALL_DUMP);
140 
141  return nullptr;
142 }
143 
146 PyResult KeeperService::Handle_ActivateAccelerationGate(PyCallArgs &call) {
147  _log(DUNG__CALL, "KeeperService::Handle_ActivateAccelerationGate size: %u", call.tuple->size());
148  call.Dump(DUNG__CALL_DUMP);
149 
150  Call_SingleIntegerArg args;
151  if (!args.Decode(&call.tuple)) {
152  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
153  return nullptr;
154  }
155 
156  Client *pClient(call.client);
157 
159  //pClient->GetShipSE()->DestinyMgr()->SendSpecialEffect10(args.arg, 0, "effects.WarpGateEffect", 0, 1, 0);
160 
161  double distance = MakeRandomFloat(5, 25) * ONE_AU_IN_METERS;
162  GPoint currentPosition(pClient->GetShipSE()->GetPosition());
163  GPoint deltaPosition;
164  deltaPosition.x = MakeRandomFloat(-1.0, 1.0) * distance;
165  deltaPosition.y = MakeRandomFloat(-1.0, 1.0) * distance;
166  deltaPosition.z = MakeRandomFloat(-2.0, 2.0) * ONE_AU_IN_METERS;
167  GPoint warpToPoint(currentPosition+deltaPosition); // Make a warp-in point variable
168  GVector vectorToDestination(currentPosition, warpToPoint);
169  double distanceToDestination = vectorToDestination.length();
170  pClient->GetShipSE()->DestinyMgr()->WarpTo(warpToPoint, distanceToDestination);
171 
172  /* return error msg from this call, if applicable, else nodeid and timestamp */
173  return new PyLong(Win32TimeNow());
174 }
175 
176 
177 
178 PyResult KeeperBound::Handle_EditDungeon(PyCallArgs &call)
179 {
180  //ed.EditDungeon(dungeonID, roomID=roomID)
181  _log(DUNG__CALL, "KeeperBound::Handle_EditDungeon size: %u", call.tuple->size());
182  call.Dump(DUNG__CALL_DUMP);
183 
184  return nullptr;
185 }
186 
187 PyResult KeeperBound::Handle_PlayDungeon(PyCallArgs &call)
188 {
189  //ed.PlayDungeon(dungeonID, roomID=roomID, godmode=godmode)
190  _log(DUNG__CALL, "KeeperBound::Handle_PlayDungeon size: %u", call.tuple->size());
191  call.Dump(DUNG__CALL_DUMP);
192 
193  return nullptr;
194 }
195 
196 PyResult KeeperBound::Handle_Reset(PyCallArgs &call)
197 {
198  _log(DUNG__CALL, "KeeperBound::Handle_Reset size: %u", call.tuple->size());
199  call.Dump(DUNG__CALL_DUMP);
200 
201  return nullptr;
202 }
203 
204 PyResult KeeperBound::Handle_GotoRoom(PyCallArgs &call)
205 {
206  _log(DUNG__CALL, "KeeperBound::Handle_GotoRoom size: %u", call.tuple->size());
207  call.Dump(DUNG__CALL_DUMP);
208 
209  return nullptr;
210 }
211 
212 PyResult KeeperBound::Handle_GetCurrentlyEditedRoomID(PyCallArgs &call)
213 {
214 //return sm.RemoteSvc('keeper').GetLevelEditor().GetCurrentlyEditedRoomID()
215  _log(DUNG__CALL, "KeeperBound::Handle_GetCurrentlyEditedRoomID size: %u", call.tuple->size());
216  call.Dump(DUNG__CALL_DUMP);
217 
218  return nullptr;
219 }
220 
Base Python wire object.
Definition: PyRep.h:66
Dispatcher *const m_dispatch
SystemDB *const m_db
#define _log(type, fmt,...)
Definition: logsys.h:124
Dispatcher *const m_dispatch
Definition: KeeperService.h:41
Dispatcher *const m_dispatch
size_t size() const
Definition: PyRep.h:591
virtual ~KeeperBound()
double MakeRandomFloat(double low, double high)
Generates random real from interval [low; high].
Definition: misc.cpp:114
PyCallable_DECL_CALL(EditDungeon)
std::string m_strBoundObjectName
Definition: PyBoundObject.h:54
const char * GetName() const
Definition: PyService.h:54
GaFloat x
Definition: GaTypes.h:207
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
virtual ~KeeperService()
void _SetCallDispatcher(CallDispatcher *d)
Definition: PyCallable.h:87
* args
virtual void Release()
Definition: gpoint.h:33
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyCallable_Make_InnerDispatcher(KeeperService) KeeperService
PyServiceMgr *const m_manager
Definition: PyService.h:91
int64 Win32TimeNow()
Definition: utils_time.cpp:70
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
Definition: Client.h:66
PySubStruct * BindObject(Client *pClient, PyBoundObject *pObj, PyDict *dict=nullptr, PyDict *oid=nullptr)
void Dump(LogType type) const
Definition: PyCallable.cpp:81
PyCallable_Make_Dispatcher(KeeperBound) KeeperBound(PyServiceMgr *mgr
virtual PyBoundObject * CreateBoundObject(Client *pClient, const PyRep *bind_args)
Definition: gpoint.h:70
SystemDB * db
static const int64 ONE_AU_IN_METERS
Definition: EVE_Consts.h:40
Python long integer.
Definition: PyRep.h:261
PyTuple * tuple
Definition: PyCallable.h:50