EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TutorialDB.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, Allan
24 */
25 
26 #include "eve-server.h"
27 
28 #include "account/TutorialDB.h"
29 
31  DBQueryResult res;
32 
33  if(!sDatabase.RunQuery(res,
34  "SELECT pageID, criteriaID"
35  " FROM tutorial_pages"
36  " JOIN tutorial_page_criteria USING (pageID)"
37  " WHERE tutorialID=%u", tutorialID))
38  {
39  codelog(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
40  return nullptr;
41  }
42 
43  return DBResultToRowset(res);
44 }
45 
47  DBQueryResult res;
48 
49  if(!sDatabase.RunQuery(res,
50  "SELECT pageID, pageNumber, pageName, text, imagePath, audioPath, 0 AS dataID"
51  " FROM tutorial_pages"
52  " WHERE tutorialID=%u"
53  " ORDER BY pageNumber", tutorialID))
54  {
55  codelog(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
56  return nullptr;
57  }
58 
59  return DBResultToRowset(res);
60 }
61 
63  DBQueryResult res;
64 
65  if(!sDatabase.RunQuery(res,
66  "SELECT tutorialID, tutorialName, nextTutorialID, 0 AS dataID"
67  " FROM tutorials"
68  " WHERE tutorialID=%u", tutorialID))
69  {
70  codelog(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
71  return nullptr;
72  }
73 
74  return DBResultToRowset(res);
75 }
76 
78  DBQueryResult res;
79 
80  if(!sDatabase.RunQuery(res,
81  "SELECT criteriaID"
82  " FROM tutorials_criterias"
83  " WHERE tutorialID=%u", tutorialID))
84  {
85  codelog(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
86  return nullptr;
87  }
88 
89  return DBResultToRowset(res);
90 }
91 
93  /* this is wrong...our db is incomplete */
94  DBQueryResult res;
95 
96  if(!sDatabase.RunQuery(res,
97  "SELECT tutorialID, tutorialName, nextTutorialID, categoryID, 0 AS dataID"
98  " FROM tutorials"))
99  {
100  codelog(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
101  return nullptr;
102  }
103 
104  return DBResultToRowset(res);
105 }
106 
108  DBQueryResult res;
109 
110  if(!sDatabase.RunQuery(res,
111  "SELECT criteriaID, criteriaName, messageText, audioPath, 0 AS dataID"
112  " FROM tutorial_criteria"))
113  {
114  codelog(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
115  return nullptr;
116  }
117 
118  return DBResultToRowset(res);
119 }
120 
122  DBQueryResult res;
123 
124  if(!sDatabase.RunQuery(res,
125  "SELECT"
126  " categoryID, categoryName, description, 0 AS dataID"
127  " FROM tutorial_categories"))
128  {
129  codelog(DATABASE__ERROR, "Error in query: %s", res.error.c_str());
130  return nullptr;
131  }
132 
133  return DBResultToRowset(res);
134 }
135 
137  DBQueryResult res;
138  sDatabase.RunQuery(res, "SELECT tutorialID, %u AS raceID, nextTutorialID FROM tutorials", raceID);
139  /*
140  DBQueryResult res;
141  if(!sDatabase.RunQuery(res, "SELECT `tutorialID`, `tutorialName`, `categoryID`, `dataID`, `tutorialNameID` FROM `tutorialsvc_tutorials`")) {
142  sLog.Error("TutorialService","GetTutorialsAndConnections query1 error: %s", res.error.c_str());
143  return nullptr;
144  }
145  PyObjectEx *tutorials = DBResultToCRowset(res);
146 
147  res.Reset();
148  if(!sDatabase.RunQuery(res, "SELECT `tutorialID`, `raceID`, `nextTutorialID`, `dataID` FROM `tutorialsvc_connections`")) {
149  sLog.Error("TutorialService","GetTutorialsAndConnections query2 error: %s", res.error.c_str());
150  return nullptr;
151  }
152  DBRowDescriptor
153  PyObjectEx *connections = DBResultToCRowset(res);
154  PyList *rtn = new PyList(2);
155  rtn->SetItem(0, tutorials);
156  rtn->SetItem(1, connections);
157  rtn->Dump(stdout, "GTAC: ");
158  return rtn; */
159  return DBResultToRowset(res);
160 }
161 
Base Python wire object.
Definition: PyRep.h:66
unsigned __int8 uint8
Definition: eve-compat.h:46
#define sDatabase
Definition: dbcore.h:199
PyRep * GetPages(uint32 tutorialID)
Definition: TutorialDB.cpp:46
PyRep * GetTutorialsAndConnections(uint8 raceID)
Definition: TutorialDB.cpp:136
PyRep * GetAllCriterias()
Definition: TutorialDB.cpp:107
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyObject * DBResultToRowset(DBQueryResult &result)
Definition: EVEDBUtils.cpp:81
PyRep * GetPageCriterias(uint32 tutorialID)
Definition: TutorialDB.cpp:30
PyRep * GetTutorial(uint32 tutorialID)
Definition: TutorialDB.cpp:62
unsigned __int32 uint32
Definition: eve-compat.h:50
PyRep * GetTutorialCriterias(uint32 tutorialID)
Definition: TutorialDB.cpp:77
DBerror error
Definition: dbcore.h:69
PyRep * GetAllTutorials()
Definition: TutorialDB.cpp:92
PyRep * GetCategories()
Definition: TutorialDB.cpp:121