Fix: CmdSetAutoReplace didn't validate group type and engine type match (#9950)
[openttd-github.git] / src / newgrf_profiling.h
blobe5b2813f59b3c0d81f5155139075a766e0d0a4ea
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file newgrf_profiling.h Profiling of NewGRF action 2 handling. */
10 #ifndef NEWGRF_PROFILING_H
11 #define NEWGRF_PROFILING_H
13 #include "stdafx.h"
14 #include "date_type.h"
15 #include "newgrf.h"
16 #include "newgrf_callbacks.h"
17 #include "newgrf_spritegroup.h"
19 #include <vector>
20 #include <string>
21 #include <memory>
23 /**
24 * Callback profiler for NewGRF development
26 struct NewGRFProfiler {
27 NewGRFProfiler(const GRFFile *grffile);
28 ~NewGRFProfiler();
30 void BeginResolve(const ResolverObject &resolver);
31 void EndResolve(const SpriteGroup *result);
32 void RecursiveResolve();
34 void Start();
35 uint32 Finish();
36 void Abort();
37 std::string GetOutputFilename() const;
39 static uint32 FinishAll();
41 /** Measurement of a single sprite group resolution */
42 struct Call {
43 uint32 root_sprite; ///< Pseudo-sprite index in GRF file
44 uint32 item; ///< Local ID of item being resolved for
45 uint32 result; ///< Result of callback
46 uint32 subs; ///< Sub-calls to other sprite groups
47 uint32 time; ///< Time taken for resolution (microseconds)
48 uint16 tick; ///< Game tick
49 CallbackID cb; ///< Callback ID
50 GrfSpecFeature feat; ///< GRF feature being resolved for
53 const GRFFile *grffile; ///< Which GRF is being profiled
54 bool active; ///< Is this profiler collecting data
55 uint16 start_tick; ///< Tick number this profiler was started on
56 Call cur_call; ///< Data for current call in progress
57 std::vector<Call> calls; ///< All calls collected so far
60 extern std::vector<NewGRFProfiler> _newgrf_profilers;
61 extern Date _newgrf_profile_end_date;
63 #endif /* NEWGRF_PROFILING_H */