EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DevToolsProviderService.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: Ubiquitatis
24 */
25 
26 #include "eve-server.h"
27 
28 #include "PyServiceCD.h"
30 
32 
34 : PyService(mgr, "devToolsProvider"),
35  m_dispatch(new Dispatcher(this))
36 {
37  _SetCallDispatcher(m_dispatch);
38 
40  PyCallable_REG_CALL(DevToolsProviderService, ExceptionFluentExample);
41 }
42 
44 {
45  delete m_dispatch;
46 }
47 
48 PyResult DevToolsProviderService::Handle_GetLoader(PyCallArgs& call)
49 {
50  FILE *pFile;
51  if(pFile = fopen(EVEMU_ROOT"/etc/devtools.raw", "rb"))
52  {
53  fseek(pFile, 0, SEEK_END);
54  int size = ftell(pFile);
55  char * buf = new char[size];
56  fseek(pFile, 0, SEEK_SET);
57  fread(buf, 1, size, pFile);
58  fclose(pFile);
59  return new PyString(buf, size);
60  }
61  return PyStatic.NewNone();
62 }
63 
64 PyResult DevToolsProviderService::Handle_ExceptionFluentExample (PyCallArgs& call)
65 {
66  Call_SingleIntegerArg arg;
67 
68  if (arg.Decode (call.tuple) == false)
69  {
70  codelog(SERVICE__ERROR, "%s: Failed to decode bind args.", GetName());
71  return nullptr;
72  }
73 
74  switch (arg.arg)
75  {
76  case 0:
77  throw UserError ("SalvagingTooComplex").AddTypeName ("type", EVEItemTypeID::itemTypeTrit);
78  case 1:
79  throw UserError ("SalvagingTooComplex").AddOwnerName ("type", call.client->GetCharID ());
80  case 2:
81  throw UserError ("SalvagingTooComplex").AddDate ("type", Win32TimeNow());
82  case 3:
83  throw UserError ("SalvagingTooComplex").AddDateTime ("type", Win32TimeNow());
84  case 4:
85  throw UserError ("SalvagingTooComplex").AddTime ("type", Win32TimeNow());
86  case 5:
87  throw UserError ("SalvagingTooComplex").AddTimeShort ("type", Win32Time_Hour + (Win32Time_Minute * 5));
88  case 6:
89  throw UserError ("SalvagingTooComplex").AddISK ("type", 160.52);
90  case 7:
91  throw UserError ("SalvagingTooComplex").AddAmount ("type", 150000);
92  case 8:
93  throw UserError ("SalvagingTooComplex").AddTypeDescription ("type", EVEItemTypeID::itemTypeTrit);
94  case 9:
95  throw UserError ("SalvagingTooComplex").AddGroupName ("type", EVEItemGroups::Clone);
96  case 10:
97  throw UserError ("SalvagingTooComplex").AddA ("type", "HELLO!");
98  case 11:
99  throw UserError ("SalvagingTooComplex").AddThe ("type", "hello world");
100  case 12:
101  throw UserError ("SalvagingTooComplex").AddBlueprintTypeName ("type", 681);
102  case 13:
103  throw UserError ("SalvagingTooComplex").AddCategoryName ("type", 1);
104  case 14:
105  throw UserError ("SalvagingTooComplex").AddCategoryDescription ("type", 1);
106  case 15:
107  throw UserError ("SalvagingTooComplex").AddAUR ("type", 1500.00);
108  case 16:
109  throw UserError ("SalvagingTooComplex").AddDistance ("type", 150000);
110  case 17:
111  throw UserError ("SalvagingTooComplex").AddLocationName ("type", call.client->GetStationID ());
112  case 18:
113  throw UserError ("SalvagingTooComplex").AddOwnerNick ("type", call.client->GetCharID ());
114  case 19:
115  throw UserError ("SalvagingTooComplex").AddTypeDescription ("type", 658);
116  case 20:
117  {
118  PyList* list = new PyList (2);
119 
120  list->SetItem (0, new PyInt (35));
121  list->SetItem (1, new PyInt (34));
122 
123  throw UserError ("SalvagingTooComplex").AddTypeList ("type", list);
124  }
125  case 21:
126  throw UserError ("SalvagingTooComplex").AddTypeIDAndQuantity ("type", 35, 1500);
127  case 22:
128  throw UserError ("SalvagingTooComplex").AddUELocalization ("type", "UI/Commands/ShowInfo", nullptr);
129  case 23:
130  throw CustomError ("This is a custom error, arguments: %s, %d", "Hello world!", 500);
131  default:
132  throw UserError ("SalvagingTooComplex").AddGroupDescription ("type", EVEItemGroups::Clone);
133  }
134 }
Dispatcher *const m_dispatch
UserError & AddTimeShort(const char *name, time_t time)
Shorthand method for adding the given time as a time string in the message (without minutes) ...
Python string.
Definition: PyRep.h:430
UserError & AddThe(const char *name, const char *value)
Shorthand method for adding "the" before the beginning of the value.
UserError & AddCategoryName(const char *name, uint32 categoryID)
Shorthand method for adding a category's name.
UserError & AddTypeIDAndQuantity(const char *name, uint32 typeID, int quantity)
Shorthand method for adding type ID and quantity.
UserError & AddTypeName(const char *name, uint32 typeID)
Shorthand method for adding a type's name.
UserError & AddGroupDescription(const char *name, uint32 groupID)
Shorthand method for adding a group's description.
UserError & AddDistance(const char *name, double distance)
Shorthand method for adding distance in a easy to read unit.
const char * GetName() const
Definition: PyService.h:54
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
UserError & AddOwnerNick(const char *name, uint32 ownerID)
Shorthand method for adding an owner's nick (first name without surname)
UserError & AddISK(const char *name, double isk)
Shorthand method for adding an ISK amount.
UserError & AddTime(const char *name, time_t time)
Shorthand method for adding the given date time as a time string in the message.
UserError & AddGroupName(const char *name, uint32 groupID)
Shorthand method for adding a group's name.
UserError & AddAmount(const char *name, int quantity)
Shorthand method for adding a quantity value.
const int64 Win32Time_Hour
Definition: utils_time.cpp:40
#define codelog(type, fmt,...)
Definition: logsys.h:128
UserError & AddTypeDescription(const char *name, uint32 typeID)
Shorthand method for adding a type's description.
UserError & AddOwnerName(const char *name, uint32 ownerID)
Shorthand method for adding an owner's name.
Python integer.
Definition: PyRep.h:231
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:682
UserError & AddAUR(const char *name, double aur)
Shorthand method for adding an AUR amount.
UserError & AddUELocalization(const char *name, const char *strKey, PyDict *args=nullptr)
Shorthand method for adding a string in the client's translations.
UserError & AddA(const char *name, const char *value)
Shorthand method for adding "a" before the beginning of the value.
#define PyStatic
Definition: PyRep.h:1209
int64 Win32TimeNow()
Definition: utils_time.cpp:70
uint32 GetCharID()
Definition: Client.h:166
Client *const client
Definition: PyCallable.h:49
Python object "ccp_exceptions.UserError".
Definition: PyExceptions.h:121
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
UserError & AddDateTime(const char *name, time_t date)
Shorthand method for adding the given date-time as a datetime string in the message.
UserError & AddCategoryDescription(const char *name, uint32 categoryID)
Shorthand method for adding a category's description.
UserError & AddTypeList(const char *name, PyList *typeIDs)
Shorthand method for adding a list of types' names.
const int64 Win32Time_Minute
Definition: utils_time.cpp:39
int32 GetStationID() const
Definition: Client.h:114
UserError & AddBlueprintTypeName(const char *name, uint32 bpTypeID)
Shorthand method for adding a blueprint's type name.
PyCallable_Make_InnerDispatcher(DevToolsProviderService) DevToolsProviderService
Python list.
Definition: PyRep.h:639
UserError & AddLocationName(const char *name, uint32 locationID)
Shorthand method for adding a location's name.
UserError & AddDate(const char *name, time_t date)
Shorthand method for adding the given date time as a date string in the message.
PyTuple * tuple
Definition: PyCallable.h:50