Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRIVATE: New engine for Private Eye #2771

Merged
merged 147 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
be490b9
PRIVATE: private-eye skeleton engine
Dec 24, 2020
515d156
PRIVATE: some code to decode videos
Dec 24, 2020
1a15db6
PRIVATE: fixed palette
Dec 24, 2020
3de3627
PRIVATE: fixes
Dec 24, 2020
d8ac303
PRIVATE: improved detection
Dec 28, 2020
e3d7ac4
PRIVATE: added flex/bison grammar
Dec 28, 2020
cd741f1
PRIVATE: grammar fixes
Dec 28, 2020
dd7161d
PRIVATE: removed old grammar code
Dec 30, 2020
59c7a61
PRIVATE: new prototype for code generation using hoc
Dec 30, 2020
323e6ec
PRIVATE: more code
Dec 30, 2020
4f38de8
PRIVATE: moved more files to c++
Dec 30, 2020
b3c220a
PRIVATE: fixed linking
Dec 30, 2020
d84111f
PRIVATE: use Private namespace
Dec 30, 2020
cd08481
PRIVATE: allocate a new stack for every setting
Dec 30, 2020
9b38b8e
PRIVATE: code to compare expr
Dec 31, 2020
56d12ed
PRIVATE: reorganized lexer and grammar code
Dec 31, 2020
fa8d357
PRIVATE: handled all defines
Jan 1, 2021
91dda64
PRIVATE: more code
Jan 2, 2021
c0b6b6a
PRIVATE: fixes + more functiions
Jan 2, 2021
3f79e9f
PRIVATE: some more functions implemented
Jan 2, 2021
e0f38c5
PRIVATE: fixed pallete colors with a hack
Jan 2, 2021
cd23483
PRIVATE: simplified grammar and added some code for conditional handling
Jan 3, 2021
3ba38a1
PRIVATE: more functions and fixes
Jan 4, 2021
73c866e
PRIVATE: improved data structures
Jan 6, 2021
4cdb0b8
PRIVATE: grammar fixes
Jan 6, 2021
1ccbe0a
PRIVATE: some fixes and added debug functions
Jan 7, 2021
24625b4
PRIVATE: added some data structure to hold exit information
Jan 8, 2021
da385bd
PRIVATE: clean-up
Jan 8, 2021
348a073
PRIVATE: used astyle to improve code formatting
Jan 8, 2021
6863ad4
PRIVATE: more code
Jan 9, 2021
ed24934
PRIVATE: more code
Jan 9, 2021
55ae9d9
PRIVATE: remove stuff from the event loop
Jan 9, 2021
bdf6ff7
PRIVATE: astyled the code again
Jan 9, 2021
7b3e139
PRIVATE: clean-up
Jan 10, 2021
863f44b
PRIVATE: implemented original cursors
Jan 10, 2021
eb9b6e2
PRIVATE: more stuff
Jan 10, 2021
6ada072
PRIVATE: more functions
Jan 10, 2021
ab8efcc
PRIVATE: fixed detection from assets without installing
Jan 10, 2021
6dedb06
PRIVATE: added lex/bison generated files
Jan 10, 2021
c69807b
PRIVATE: astyled the code again
Jan 10, 2021
ad1db2b
PRIVATE: clean up and reorganization
Jan 10, 2021
ccf72d0
PRIVATE: basic save game support
Jan 12, 2021
664fd62
PRIVTE: more fixes
Jan 13, 2021
bff2238
PRIVATE: more fixes
Jan 14, 2021
4500a00
PRIVATE: more fixes
Jan 14, 2021
0ed506d
PRIVATE: adjusted origin point
Jan 14, 2021
94a0cdb
PRIVATE: more code
Jan 16, 2021
2199851
PRIVATE: phone calls + fixes
Jan 17, 2021
7775b64
PRIVATE: improved save/load
Jan 17, 2021
a690fbe
PRIVATE: fixes + astyle
Jan 18, 2021
2fa96ea
PRIVATE: more astyle
Jan 18, 2021
06c1afa
PRIVATE: better detection tables + fixes
Jan 20, 2021
a812821
PRIVATE: fixed frame memory leak
Jan 21, 2021
06b3749
PRIVATE: more fixes
Jan 23, 2021
cf94db5
PRIVATE: started to implement police bust
Jan 23, 2021
db34100
PRIVATE: police bust changes
Jan 29, 2021
1391a1b
PRIVATE: partial dossier browsing implementation
Jan 30, 2021
c2b2211
PRIVATE: new features
Jan 31, 2021
6cc5626
PRIVATE: fixes in sounds and memory management
Feb 1, 2021
57bf748
PRIVATE: fixes and new stuff
Feb 7, 2021
e03889e
PRIVATE: implemented NoStopSounds
Feb 7, 2021
d2427b9
PRIVATE: astyle
Feb 7, 2021
028c747
PRIVATE: fixes and new stuff
Feb 9, 2021
b27b69d
PRIVATE: fixes
Feb 12, 2021
3b4f7d3
PRIVATE: more fixes
Feb 13, 2021
7bb3c0c
PRIVATE: astyle
Feb 13, 2021
97052b9
PRIVATE: fixes
Feb 13, 2021
ad5235b
PRIVATE: missing snprinft
Feb 13, 2021
62978b2
PRIVATE: added copyright headers
Feb 13, 2021
ba5dd8a
PRIVATE: fixes and renamed installer_archive
Feb 13, 2021
2c3602f
PRIVATE: optimized use of screen
Feb 13, 2021
dd963e8
PRIVATE: fixes
Feb 13, 2021
003a205
PRIVATE: fixes
Feb 13, 2021
b5d04b4
PRIVATE: removed tabs
Feb 13, 2021
076bbff
PRIVATE: fixed code convetions
Feb 13, 2021
4223c04
PRIVATE: added proper debug channels and fixed type assertions
Feb 14, 2021
a1792e7
PRIVATE: removed old debug code
Feb 14, 2021
99f4d30
PRIVATE: explicit conversion to bool
Feb 14, 2021
d088344
PRIVATE: clean up grammar.l to remove unused code and imports
Feb 14, 2021
683034e
PRIVATE: reorganized bison and yacc files and removed tabs from them
Feb 14, 2021
d248318
PRIVATE: change detection tables to use PVTEYE.Z
Feb 14, 2021
1550232
PRIVATE: avoid name collisions using a prefix in the lexer and grammar
Feb 14, 2021
137bd46
PRIVATE: code convention on type casting
Feb 15, 2021
1da6ffe
PRIVATE: code convention on type casting
Feb 15, 2021
2506fb1
PRIVATE: avoid global constructors in initCursors
Feb 15, 2021
b430445
PRIVATE: code convention on type casting
Feb 15, 2021
b3e4f33
PRIVATE: fixed in formating of module.mk
Feb 15, 2021
da994a8
PRIVATE: avoid confusion in nested if
Feb 15, 2021
08bec7b
PRIVATE: code convention on type casting
Feb 15, 2021
f045503
PRIVATE: code convention on function names
Feb 15, 2021
d38348d
PRIVATE: removed useless empty lines
Feb 15, 2021
948162a
PRIVATE: removed useless empty lines
Feb 15, 2021
fd1994c
PRIVATE: arithmetic code refactor
Feb 15, 2021
6b4861b
PRIVATE: removed unused variables and refactor
Feb 15, 2021
3a7c8c0
PRIVATE: optimize screen drawing
Feb 15, 2021
6b47b14
PRIVATE: refactor to avoid global constructors
Feb 15, 2021
3fbccd5
PRIVATE: code convention fixes
Feb 16, 2021
558f959
PRIVATE: missing line at the end
Feb 16, 2021
efaa7e2
PRIVATE: removed old file
Feb 16, 2021
418a724
PRIVATE: code convention fixes
Feb 16, 2021
12709df
PRIVATE: fixed load game code to avoid leaking memory
Feb 16, 2021
7995500
PRIVATE: refactor sound handling to avoid leaking memory
Feb 16, 2021
2594e38
PRIVATE: refactor sound handling to avoid leaking memory
Feb 16, 2021
9e4c747
PRIVATE: refactor sound handling to avoid leaking memory
Feb 16, 2021
3880cba
PRIVATE: removed console
Feb 16, 2021
f1760a7
PRIVATE: simplified code
Feb 16, 2021
1aac477
PRIVATE: use const string in getRandomPhoneClip
Feb 16, 2021
85c5c0e
PRIVATE: refactor _diaryLocPrefix
Feb 16, 2021
1571b3c
PRIVATE: refactoring to avoid global constructors
Feb 16, 2021
bb39b4b
PRIVATE: refactor string cmp handling to avoid leaking memory
Feb 16, 2021
d210fc9
PRIVATE: refactor string cmp handling to avoid leaking memory
Feb 16, 2021
ff58407
PRIVATE: missing new line
Feb 16, 2021
cb6556e
PRIVATE: refactor mask handling to avoid leaking memory
Feb 16, 2021
9eca28f
PRIVATE: refactor headers
Feb 16, 2021
1d38768
PRIVATE: refactor headers
Feb 16, 2021
78d1b5f
PRIVATE: added makefile rule to build lexer/grammar
Feb 16, 2021
5a67755
PRIVATE: correct detection thanks to @sev
Feb 16, 2021
5de9d92
PRIVATE: code convention fixes
Feb 17, 2021
eae8cd3
PRIVATE: added hoc copyright
Feb 17, 2021
faaf9e0
PRIVATE: removed policeVideoIndex
Feb 17, 2021
e40c19b
PRIVATE: refactored more strings code
Feb 17, 2021
b020cc8
PRIVATE: documented some code
Feb 17, 2021
b1613ff
PRIVATE: first step to use classes and avoid external
Feb 17, 2021
2020ead
PRIVATE: second step to use classes and avoid external
Feb 17, 2021
2c78103
PRIVATE: removed more extern
Feb 17, 2021
1ba2d64
PRIVATE: use more classes and avoid external
Feb 17, 2021
b9c13bc
PRIVATE: fix memory leaks
Feb 19, 2021
c8293a9
PRIVATE: fix memory leaks
Feb 19, 2021
112b7bd
PRIVATE: stop all sounds when a game is loaded
Feb 19, 2021
ff4d84b
PRIVATE: code convention fixes
Feb 19, 2021
c1001f9
PRIVATE: fix memory leaks and added more stuff into the main class
Feb 19, 2021
4e2220d
PRIVATE: remove pointers
Feb 20, 2021
1710ea9
PRIVATE: remove pointers
Feb 20, 2021
b3ad4c3
PRIVATE: remove pointers
Feb 20, 2021
7d48545
PRIVATE: remove pointers
Feb 20, 2021
d42fe36
PRIVATE: remove more pointers
Feb 20, 2021
fcbc635
PRIVATE: fixes
Feb 20, 2021
8ba27e4
PRIVATE: remove more pointers
Feb 20, 2021
e7d24a9
COMMON: moved include guard to the top
Feb 20, 2021
d1a79f5
PRIVATE: removed screen locking
Feb 20, 2021
65e27bc
PRIVATE: code convention fixes
Feb 20, 2021
ebb80bb
PRIVATE: remove more pointers
Feb 20, 2021
4adb596
PRIVATE: class re-organization
Feb 22, 2021
1ae19a6
PRIVATE: class re-organization
Feb 23, 2021
d8d8ffa
COMMON: renamed include guard in installshieldv3
Feb 26, 2021
1b23dc1
PRIVATE: fixes
Feb 26, 2021
6a3f966
PRIVATE: added more detection rules
Feb 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions common/installshieldv3_archive.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program 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; either version 2
* of the License, or (at your option) any later version.
*
* This program 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "common/installshieldv3_archive.h"

#include "common/dcl.h"
#include "common/debug.h"

namespace Common {

InstallShieldV3::InstallShieldV3() : Common::Archive() {
_stream = nullptr;
}

InstallShieldV3::~InstallShieldV3() {
close();
}

bool InstallShieldV3::open(const Common::String &filename) {
close();

_stream = SearchMan.createReadStreamForMember(filename);

if (!_stream)
return false;

// Check for the magic uint32
// No idea what it means, but it's how "file" recognizes them
if (_stream->readUint32BE() != 0x135D658C) {
close();
return false;
}

// Let's pull some relevant data from the header
_stream->seek(41);
uint32 directoryTableOffset = _stream->readUint32LE();
/* uint32 directoryTableSize = */ _stream->readUint32LE();
uint16 directoryCount = _stream->readUint16LE();
uint32 fileTableOffset = _stream->readUint32LE();
/* uint32 fileTableSize = */ _stream->readUint32LE();

// We need to have at least one directory in order for the archive to be valid
if (directoryCount == 0) {
close();
return false;
}

// TODO: Currently, we only support getting files from the first directory
// To that end, get the number of files from that entry
_stream->seek(directoryTableOffset);
uint16 fileCount = _stream->readUint16LE();
debug(2, "File count = %d", fileCount);

// Following the directory table is the file table with files stored recursively
// by directory. Since we're only using the first directory, we can just go
// right to that one.
_stream->seek(fileTableOffset);

for (uint16 i = 0; i < fileCount; i++) {
FileEntry entry;

_stream->skip(3); // Unknown

entry.uncompressedSize = _stream->readUint32LE();
entry.compressedSize = _stream->readUint32LE();
entry.offset = _stream->readUint32LE();

_stream->skip(14); // Unknown

byte nameLength = _stream->readByte();
Common::String name;
while (nameLength--)
name += _stream->readByte();

_stream->skip(13); // Unknown

_map[name] = entry;

debug(3, "Found file '%s' at 0x%08x (Comp: 0x%08x, Uncomp: 0x%08x)", name.c_str(),
entry.offset, entry.compressedSize, entry.uncompressedSize);
}

return true;
}

void InstallShieldV3::close() {
delete _stream; _stream = nullptr;
_map.clear();
}

bool InstallShieldV3::hasFile(const Common::String &name) const {
return _map.contains(name);
}

int InstallShieldV3::listMembers(Common::ArchiveMemberList &list) const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HashMap::size() return uint, thus, it makes sense to return uint here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was an exact copy from the one in Riven but I will change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it seems it overrides a specific class function:

./common/installshieldv3_archive.h:47:7: error: conflicting return type specified for 'virtual uint Common::InstallShieldV3::listMembers(Common::ArchiveMemberList&) const'
   47 |  uint listMembers(Common::ArchiveMemberList &list) const override;
      |       ^~~~~~~~~~~
In file included from ./common/fs.h:27,
                 from ./base/plugins.h:27,
                 from ./engines/metaengine.h:34,
                 from ./engines/advancedDetector.h:26,
                 from ./engines/private/private.h:28,
                 from engines/private/code.cpp:29:
./common/archive.h:126:14: note: overridden function is 'virtual int Common::Archive::listMembers(Common::ArchiveMemberList&) const'
  126 |  virtual int listMembers(ArchiveMemberList &list) const = 0;

for (FileMap::const_iterator it = _map.begin(); it != _map.end(); it++)
list.push_back(getMember(it->_key));

return _map.size();
}

const Common::ArchiveMemberPtr InstallShieldV3::getMember(const Common::String &name) const {
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
}

Common::SeekableReadStream *InstallShieldV3::createReadStreamForMember(const Common::String &name) const {
if (!_stream || !_map.contains(name))
return nullptr;

const FileEntry &entry = _map[name];

// Seek to our offset and then send it off to the decompressor
_stream->seek(entry.offset);
return Common::decompressDCL(_stream, entry.compressedSize, entry.uncompressedSize);
}

} // End of namespace Common
66 changes: 66 additions & 0 deletions common/installshieldv3_archive.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program 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; either version 2
* of the License, or (at your option) any later version.
*
* This program 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#ifndef COMMON_INSTALLSHIELDV3_ARCHIVE_H
#define COMMON_INSTALLSHIELDV3_ARCHIVE_H

#include "common/archive.h"
#include "common/scummsys.h"
#include "common/endian.h"
#include "common/file.h"
#include "common/hash-str.h"
#include "common/hashmap.h"
#include "common/str.h"

namespace Common {

class InstallShieldV3 : public Common::Archive {
public:
InstallShieldV3();
~InstallShieldV3() override;

bool open(const Common::String &filename);
void close();
bool isOpen() const { return _stream != nullptr; }

// Common::Archive API implementation
bool hasFile(const Common::String &name) const override;
int listMembers(Common::ArchiveMemberList &list) const override;
const Common::ArchiveMemberPtr getMember(const Common::String &name) const override;
Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const override;

private:
struct FileEntry {
uint32 uncompressedSize;
uint32 compressedSize;
uint32 offset;
};

Common::SeekableReadStream *_stream;

typedef Common::HashMap<Common::String, FileEntry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
FileMap _map;
};

} // End of namespace Common

#endif
1 change: 1 addition & 0 deletions common/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ MODULE_OBJS := \
iff_container.o \
ini-file.o \
installshield_cab.o \
installshieldv3_archive.o \
json.o \
language.o \
localization.o \
Expand Down
Loading