ScummVM API documentation
resource_patcher.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef SCI_RESOURCE_RESOURCE_PATCHER_H
23#define SCI_RESOURCE_RESOURCE_PATCHER_H
24
25#include "common/language.h"
26#include "sci/sci.h"
27#include "sci/resource/resource.h"
28#include "sci/resource/resource_intern.h"
29
30namespace Sci {
31
32enum ResourcePatchOp {
33 // Using high bytes to make it less likely that accidental raw data will be
34 // treated like an operator instead of an error
35 kSkipBytes = 0xF0,
36 kReplaceBytes,
37 kInsertBytes,
38 kReplaceNumber,
39 kAdjustNumber,
40 kInsertNumber,
41 kReplaceFill,
42 kInsertFill,
43 kEndOfPatch
44};
45
46enum SciMedia : uint;
47
52 SciGameId gameId;
53
57 SciMedia media;
58
64
68 ResourceType resourceType;
69
74
78 const byte *patchData;
79
85};
86
91public:
92 ResourcePatcher(const SciGameId gameId, const bool isCD, const Common::Platform platform, const Common::Language gameLanguage);
93
94 ~ResourcePatcher() override {}
95
101 bool applyPatch(Resource &resource) const;
102
108 void scanSource(ResourceManager *resMan) override;
109
115 void loadResource(ResourceManager *resMan, Resource *res) override {}
116
117private:
118 struct PatchSizes {
122 uint32 expected;
123
128 int32 delta;
129 };
130
131 typedef Common::Array<GameResourcePatch> PatchList;
132
136 PatchList _patches;
137
142 void patchResource(Resource &resource, const GameResourcePatch &patch) const;
143
147 PatchSizes calculatePatchSizes(const byte *patchData) const;
148
153 int32 readBlockSize(const byte * &patchData) const;
154};
155} // End of namespace Sci
156
157#endif // SCI_RESOURCE_RESOURCE_PATCHER_H
Definition: resource.h:256
Definition: resource.h:327
Definition: resource_patcher.h:90
bool applyPatch(Resource &resource) const
void loadResource(ResourceManager *resMan, Resource *res) override
Definition: resource_patcher.h:115
void scanSource(ResourceManager *resMan) override
Definition: resource_intern.h:48
Language
Definition: language.h:45
Platform
Definition: platform.h:93
Definition: console.h:28
Definition: resource_patcher.h:48
const byte * patchData
Definition: resource_patcher.h:78
SciMedia media
Definition: resource_patcher.h:57
uint16 resourceNumber
Definition: resource_patcher.h:73
bool isNewResource
Definition: resource_patcher.h:84
SciGameId gameId
Definition: resource_patcher.h:52
ResourceType resourceType
Definition: resource_patcher.h:68
Common::Language gameLanguage
Definition: resource_patcher.h:63