Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
assetstatus.cpp
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include "assetstatus.h"
20#include "hashtemplate.h"
21#include "wwstring.h"
22#include "rawfile.h"
23
24AssetStatusClass AssetStatusClass::Instance;
25
27 "LOAD_ON_DEMAND_ROBJ",
28 "LOAD_ON_DEMAND_HANIM",
29 "LOAD_ON_DEMAND_HTREE",
30 "MISSING_ROBJ",
31 "MISSING_HANIM",
32 "MISSING_HTREE"
33};
34
36 :
37 Reporting (true),
38 LoadOnDemandReporting(false)
39{
40}
41
43{
44#ifdef WWDEBUG
45 if (Reporting) {
46 StringClass report("Load-on-demand and missing assets report\r\n\r\n");
47 for (int i=0;i<REPORT_COUNT;++i) {
48 report+="Category: ";
49 report+=ReportCategoryNames[i];
50 report+="\r\n\r\n";
51
52 HashTemplateIterator<StringClass,int> ite(ReportHashTables[i]);
53 for (ite.First();!ite.Is_Done();ite.Next()) {
54 report+=ite.Peek_Key();
55 int count=ite.Peek_Value();
56 if (count>1) {
57 StringClass tmp(0,true);
58 tmp.Format("\t(reported %d times)",count);
59 report+=tmp;
60 }
61 report+="\r\n";
62 }
63 report+="\r\n";
64 }
65 if (report.Get_Length()) {
66 RawFileClass raw_log_file("asset_report.txt");
67 raw_log_file.Create();
68 raw_log_file.Open(RawFileClass::WRITE);
69 raw_log_file.Write(report,report.Get_Length());
70 raw_log_file.Close();
71 }
72 }
73#endif
74}
75
76void AssetStatusClass::Add_To_Report(int index, const char* name)
77{
78 StringClass lower_case_name(name,true);
79 _strlwr(lower_case_name.Peek_Buffer());
80 // This is a bit slow - two accesses to the same member, but currently there's no better way to do it.
81 int count=ReportHashTables[index].Get(lower_case_name);
82 count++;
83 ReportHashTables[index].Set_Value(lower_case_name,count);
84}
85
87{
88 if (LoadOnDemandReporting) Add_To_Report(REPORT_LOAD_ON_DEMAND_ROBJ,name);
89}
90
92{
93 if (LoadOnDemandReporting) Add_To_Report(REPORT_LOAD_ON_DEMAND_HANIM,name);
94}
95
97{
98 if (LoadOnDemandReporting) Add_To_Report(REPORT_LOAD_ON_DEMAND_HTREE,name);
99}
100
102{
103 Add_To_Report(REPORT_MISSING_ROBJ,name);
104}
105
107{
108 Add_To_Report(REPORT_MISSING_HANIM,name);
109}
110
112{
113 Add_To_Report(REPORT_MISSING_HTREE,name);
114}
115
@ true
Definition bool.h:59
@ false
Definition bool.h:59
const char * ReportCategoryNames[AssetStatusClass::REPORT_COUNT]
void Report_Missing_HTree(const char *name)
void Report_Load_On_Demand_RObj(const char *name)
void Report_Missing_RObj(const char *name)
void Report_Missing_HAnim(const char *name)
void Report_Load_On_Demand_HTree(const char *name)
void Report_Load_On_Demand_HAnim(const char *name)
@ WRITE
Definition WWFILE.H:72
void Set_Value(const KeyType &s, const ValueType &d)
ValueType Get(const KeyType &s) const
ValueType & Peek_Value()
const KeyType & Peek_Key()
virtual int Open(char const *filename, int rights=READ)
Definition rawfile.cpp:356
virtual int Create(void)
Definition rawfile.cpp:919
virtual int Write(void const *buffer, int size)
Definition rawfile.cpp:698
virtual void Close(void)
Definition rawfile.cpp:561
int _cdecl Format(const TCHAR *format,...)
Definition wwstring.cpp:273
int Get_Length(void) const
Definition wwstring.h:664