Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / tools / stats_scan / char_commands.cpp
blob40544cf71115ac707c85348077e6304367dbf45e
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/>.
17 /**
18 * todo:
19 * - charScanScript commands
20 * * path for script files in cfg
21 * - charScanScriptNew <description>
22 * - charScanScriptLoad <file_name>
23 * - charScanScriptSave <file_name>
24 * - charScanScriptListFiles
25 * - charScanScriptListLines
26 * - charScanScriptDeleteLine <line_number>
27 * - charScanScriptAddInputFiles <directory> <wildcards>
28 * - charScanScriptAddInfoExtractor <infoExtractorName> [<args>]
29 * - charScanScriptAddFilter <filterName> [<args>]
30 * - charScanScriptAddPreInclude <include_file_name>
31 * - charScanScriptAddPostInclude <include_file_name>
32 * - charScanScriptSetOutputDirectory <directoryName>
33 * - charScanScriptSetDescription <description>
34 * - charScanScriptRun [-s <file_name>] [-o <output_directory>]
35 * - addJobCharScanScript [-s <file_name>] [-o <output_directory>]
36 * - charScanScriptListOutputFiles [<output_directory>]
37 * - charScanScriptListOutputFileContents <file_name> [<output_directory>]
38 * - charScanScriptTestFileList
39 * - charScanScriptTestOutput <test_input_file_path>
40 * - charScanScriptHelp
41 * - path for generated files (from cfg + override) => managed incrementally with directory numbering
42 * - add incremental update systems
43 * - add tables with a column per day ()
44 * - add tables with a column per week (limited number of weeks)
45 * - add tables with a column per month (limited number of months)
49 bool CCharFilterFactory::beginScanJob(const std::vector<std::string>& files, const std::vector<std::string>& filters)
51 bool noErrors= true;
53 // create a new job
54 NLMISC::CSmartPtr<CCharacterScanJob> job=new CCharacterScanJob;
56 // look after the filters
57 for (uint32 i=0;i<filters.size();++i)
59 // locate the info extractor corresponding to the given name
60 uint32 j=0;
61 for (j=0;j<_Filters.size();++j)
62 if (filters[i]==_Filters[j]->getName())
63 break;
65 // if none found then warn and skip passed
66 if(j>=_Filters.size())
68 nlwarning("Unknown info extractor: %s",filters[i].c_str());
69 noErrors=false;
70 continue;
73 // add the info extractor to the new job
74 job->addFilter(_Filters[j]);
77 // look after the files
78 job->addFiles(files);
80 // add the job to the job manager
81 if (noErrors==true)
82 CJobManager::getInstance()->addJob(&*job);
84 return noErrors;
88 //-----------------------------------------------------------------------------
89 // includes
90 //-----------------------------------------------------------------------------
92 #include "nel/misc/path.h"
93 #include "nel/misc/command.h"
94 #include "nel/misc/variable.h"
95 #include "nel/misc/algo.h"
96 #include "game_share/persistent_data.h"
98 #include "character.h"
99 #include "job_manager.h"
100 #include "char_info_extractor_factory.h"
103 //-----------------------------------------------------------------------------
104 // Namespaces
105 //-----------------------------------------------------------------------------
107 using namespace std;
108 using namespace NLMISC;
110 //-----------------------------------------------------------------------------
111 // Variables
112 //-----------------------------------------------------------------------------
114 CVariable<string> SourceDirectory("variables", "SourceDirectory", "Directory we scan for files", string("."), 0, true);
117 //-----------------------------------------------------------------------------
118 // Commands - misc character related
119 //-----------------------------------------------------------------------------
121 NLMISC_COMMAND(listCharNames,"display the names of the characters int he listed save files","<input file name>")
123 if (args.size()!=1 && args.size()!=0)
124 return false;
126 std::string wildcard="pdr_account*";
127 if (args.size()==1)
128 wildcard=args[0];
130 std::vector<std::string> files;
131 NLMISC::CPath::getPathContent(SourceDirectory.get().c_str(),false,false,true,files);
132 for (uint32 i=(uint32)files.size();i--;)
134 if (!NLMISC::testWildCard(NLMISC::CFile::getFilename(files[i]),wildcard))
136 files[i]=files.back();
137 files.pop_back();
140 std::sort(files.begin(),files.end());
141 for (uint32 i=0;i<files.size();++i)
143 static CPersistentDataRecord pdr;
144 pdr.clear();
145 pdr.readFromFile(files[i]);
147 CStatsScanCharacter c;
148 c.apply(pdr);
150 log.displayNL("%-40s Name: %s ", files[i].c_str(), c.EntityBase._Name.c_str());
153 return true;
156 //-----------------------------------------------------------------------------
157 // Commands - charScanner
158 //-----------------------------------------------------------------------------
160 NLMISC_COMMAND(listCharInfoExtractors,"display the list of info extractors that exist for characters","")
162 if (args.size()!=0)
163 return false;
165 CCharInfoExtractorFactory::getInstance()->displayInfoExtractorList(&log);
167 return true;
170 //-----------------------------------------------------------------------------
171 // Commands - jobsManager
172 //-----------------------------------------------------------------------------
174 NLMISC_COMMAND(jobsPause,"pause execution of jobs","")
176 if (args.size()!=0)
177 return false;
179 CJobManager::getInstance()->pause();
181 return true;
184 NLMISC_COMMAND(jobsResume,"resume execution of jobs","")
186 if (args.size()!=0)
187 return false;
189 CJobManager::getInstance()->resume();
191 return true;
194 NLMISC_COMMAND(jobsPromote,"pause execution of jobs","<jobId>")
196 if (args.size()!=1)
197 return false;
199 uint32 idx;
200 NLMISC::fromString(args[0], idx);
202 if ( (idx==0 && args[0]!="0") )
204 nlwarning("Argument is not a valid job id - should be a number");
205 return false;
208 CJobManager::getInstance()->promoteJob(idx);
209 CJobManager::getInstance()->listJobs(&log);
211 return true;
214 NLMISC_COMMAND(JobUpdatesPerUpdate,"set or display the number of job updates per service update","[<count>]")
216 if (args.size()>1)
217 return false;
219 if (args.size()==1)
221 uint32 count;
222 NLMISC::fromString(args[0], count);
224 if ( (count==0 && args[0]!="0") )
226 nlwarning("Argument is not a valid number");
227 return false;
229 CJobManager::getInstance()->setJobUpdatesPerUpdate(count);
232 nlinfo("JobUpdatesPerUpdate %d",CJobManager::getInstance()->getJobUpdatesPerUpdate());
234 return true;
237 NLMISC_COMMAND(jobsStatus,"display the status of the job manager","")
239 if (args.size()!=0)
240 return false;
242 log.displayNL("%s",CJobManager::getInstance()->getStatus().c_str());
244 return true;
247 NLMISC_COMMAND(jobsList,"display the list of unfinished jobs","")
249 if (args.size()!=0)
250 return false;
252 CJobManager::getInstance()->listJobs(&log);
254 return true;
257 NLMISC_COMMAND(jobsListAll,"display the list of all jobs (unfinished jobs are marked with a '*')","")
259 if (args.size()!=0)
260 return false;
262 CJobManager::getInstance()->listJobHistory(&log);
264 return true;
267 NLMISC_COMMAND(jobsDisplayDetails,"display detailed info for the current job (or a given job)","[<job id>]")
269 switch (args.size())
271 case 0:
272 CJobManager::getInstance()->displayCurrentJob(&log);
273 break;
275 case 1:
277 uint32 idx;
278 NLMISC::fromString(args[0], idx);
280 if ( (idx==0 && args[0]!="0") )
282 nlwarning("Argument is not a valid job id - should be a number");
283 return false;
285 CJobManager::getInstance()->displayJob(idx,&log);
287 break;
290 default:
291 return false;
294 return true;
297 //-----------------------------------------------------------------------------
298 // Commands - charScanScript
299 //-----------------------------------------------------------------------------
302 //-----------------------------------------------------------------------------