SCI: Fix the console's hexgrep command
This commit is contained in:
parent
87e832809b
commit
15b3bffb7f
1 changed files with 10 additions and 10 deletions
|
@ -773,17 +773,16 @@ bool Console::cmdResourceTypes(int argc, const char **argv) {
|
|||
|
||||
bool Console::cmdHexgrep(int argc, const char **argv) {
|
||||
if (argc < 4) {
|
||||
DebugPrintf("Searches some resources for a particular sequence of bytes, represented as hexadecimal numbers.\n");
|
||||
DebugPrintf("Searches some resources for a particular sequence of bytes, represented as decimal or hexadecimal numbers.\n");
|
||||
DebugPrintf("Usage: %s <resource type> <resource number> <search string>\n", argv[0]);
|
||||
DebugPrintf("<resource number> can be a specific resource number, or \"all\" for all of the resources of the specified type\n");
|
||||
DebugPrintf("EXAMPLES:\n hexgrep script all e8 03 c8 00\n hexgrep pic 042 fe");
|
||||
DebugPrintf("EXAMPLES:\n hexgrep script all 0xe8 0x03 0xc8 0x00\n hexgrep pic 0x42 0xfe\n");
|
||||
cmdResourceTypes(argc, argv);
|
||||
return true;
|
||||
}
|
||||
|
||||
ResourceType restype = parseResourceType(argv[1]);
|
||||
int resNumber = 0, resMax = 0;
|
||||
char seekString[500];
|
||||
Resource *script = NULL;
|
||||
|
||||
if (restype == kResourceTypeInvalid) {
|
||||
|
@ -798,12 +797,13 @@ bool Console::cmdHexgrep(int argc, const char **argv) {
|
|||
resNumber = resMax = atoi(argv[2]);
|
||||
}
|
||||
|
||||
strcpy(seekString, argv[3]);
|
||||
// Convert the bytes
|
||||
Common::Array<int> byteString;
|
||||
byteString.resize(argc - 3);
|
||||
|
||||
// Construct the seek string
|
||||
for (int i = 4; i < argc; i++) {
|
||||
strcat(seekString, argv[i]);
|
||||
}
|
||||
for (uint i = 0; i < byteString.size(); i++)
|
||||
if (!parseInteger(argv[i + 3], byteString[i]))
|
||||
return true;
|
||||
|
||||
for (; resNumber <= resMax; resNumber++) {
|
||||
script = _engine->getResMan()->findResource(ResourceId(restype, resNumber), 0);
|
||||
|
@ -813,13 +813,13 @@ bool Console::cmdHexgrep(int argc, const char **argv) {
|
|||
int output_script_name = 0;
|
||||
|
||||
while (seeker < script->size) {
|
||||
if (script->data[seeker] == seekString[comppos]) {
|
||||
if (script->data[seeker] == byteString[comppos]) {
|
||||
if (comppos == 0)
|
||||
seekerold = seeker;
|
||||
|
||||
comppos++;
|
||||
|
||||
if (comppos == strlen(seekString)) {
|
||||
if (comppos == byteString.size()) {
|
||||
comppos = 0;
|
||||
seeker = seekerold + 1;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue