-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
333 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "TexlFile.h" | ||
|
||
TexlFile::TexlFile(QIODevice *io) : | ||
_io(io) | ||
{ | ||
} | ||
|
||
bool TexlFile::seekTexture(quint8 id) | ||
{ | ||
return _io->seek(id * TEXLFILE_TEXTURE_SIZE); | ||
} | ||
|
||
bool TexlFile::readTexture(TimFile &tim) | ||
{ | ||
QByteArray data = _io->read(TEXLFILE_TEXTURE_SIZE); | ||
|
||
return tim.open(data); | ||
} | ||
|
||
bool TexlFile::readTextures(Map &map) | ||
{ | ||
QList<TimFile> textures; | ||
|
||
_io->reset(); | ||
|
||
for (int i = 0; i < TEXLFILE_TEXTURE_COUNT; ++i) { | ||
TimFile tim; | ||
if (!readTexture(tim)) { | ||
qDebug() << "TexlFile::readTextures cannot read texture"; | ||
return false; | ||
} | ||
|
||
textures.append(tim); | ||
} | ||
|
||
map.setTextures(textures); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef TEXLFILE_H | ||
#define TEXLFILE_H | ||
|
||
#include <QtCore> | ||
#include "game/worldmap/Map.h" | ||
#include "files/TimFile.h" | ||
|
||
#define TEXLFILE_TEXTURE_SIZE 0x12800 | ||
#define TEXLFILE_TEXTURE_COUNT 20 | ||
|
||
class TexlFile | ||
{ | ||
public: | ||
explicit TexlFile(QIODevice *io = Q_NULLPTR); | ||
inline void setDevice(QIODevice *device) { | ||
_io = device; | ||
} | ||
|
||
bool readTextures(Map &map); | ||
|
||
private: | ||
bool seekTexture(quint8 id); | ||
bool readTexture(TimFile &tim); | ||
|
||
QIODevice *_io; | ||
}; | ||
|
||
#endif // TEXLFILE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#include "WmArchive.h" | ||
#include "game/worldmap/WmsetFile.h" | ||
#include "game/worldmap/WmxFile.h" | ||
#include "game/worldmap/TexlFile.h" | ||
|
||
WmArchive::WmArchive() : | ||
_isOpen(false) | ||
{ | ||
} | ||
|
||
bool WmArchive::open(const QString &filename, Map &map, ArchiveObserver *progress) | ||
{ | ||
if (progress) { | ||
progress->setObserverMaximum(3); | ||
} | ||
|
||
QString archivePath = filename; | ||
archivePath.chop(1); | ||
|
||
if (!_fsArchive.open(archivePath)) { | ||
_errorString = QObject::tr("Impossible d'ouvrir l'archive."); | ||
return false; | ||
} | ||
|
||
if (!_fsArchive.fileExists("*world\\dat\\wmx.obj")) { | ||
_errorString = QObject::tr("Pas une archive mappemonde."); | ||
return false; | ||
} | ||
|
||
_isOpen = false; | ||
|
||
WmxFile wmx; | ||
WmsetFile wmset; | ||
TexlFile texl; | ||
|
||
QByteArray wmxData = _fsArchive.fileData("*world\\dat\\wmx.obj"); | ||
QBuffer wmxBuffer(&wmxData); | ||
wmxBuffer.open(QIODevice::ReadOnly); | ||
wmx.setDevice(&wmxBuffer); | ||
|
||
if(!wmx.readSegments(map, 768)) { | ||
_errorString = QObject::tr("Impossible de lire la mappemonde (1)."); | ||
return false; | ||
} | ||
|
||
wmxData.clear(); | ||
|
||
if (progress) { | ||
progress->setObserverValue(1); | ||
} | ||
|
||
QByteArray wmsetData = _fsArchive.fileData("*world\\dat\\wmsetfr.obj"); | ||
QBuffer wmsetBuffer(&wmsetData); | ||
wmsetBuffer.open(QIODevice::ReadOnly); | ||
wmset.setDevice(&wmsetBuffer); | ||
|
||
if (!wmset.readEncounterRegions(map)) { | ||
_errorString = QObject::tr("Impossible de lire la mappemonde (2)."); | ||
return false; | ||
} | ||
|
||
if (!wmset.readEncounters(map)) { | ||
_errorString = QObject::tr("Impossible de lire la mappemonde (3)."); | ||
return false; | ||
} | ||
|
||
wmsetData.clear(); | ||
|
||
if (progress) { | ||
progress->setObserverValue(2); | ||
} | ||
|
||
QByteArray texlData = _fsArchive.fileData("*world\\dat\\texl.obj"); | ||
QBuffer texlBuffer(&texlData); | ||
texlBuffer.open(QIODevice::ReadOnly); | ||
texl.setDevice(&texlBuffer); | ||
|
||
if (!texl.readTextures(map)) { | ||
_errorString = QObject::tr("Impossible de lire la mappemonde (4)."); | ||
return false; | ||
} | ||
|
||
if (progress) { | ||
progress->setObserverValue(3); | ||
} | ||
|
||
_isOpen = true; | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef WMARCHIVE_H | ||
#define WMARCHIVE_H | ||
|
||
#include "game/worldmap/Map.h" | ||
#include "ArchiveObserver.h" | ||
#include "FsArchive.h" | ||
|
||
class WmArchive | ||
{ | ||
public: | ||
WmArchive(); | ||
bool open(const QString &filename, Map &map, ArchiveObserver *progress); | ||
inline const QString &errorString() const { | ||
return _errorString; | ||
} | ||
private: | ||
bool _isOpen; | ||
QString _errorString; | ||
FsArchive _fsArchive; | ||
}; | ||
|
||
#endif // WMARCHIVE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.