mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-06 09:48:39 +00:00
CHEWY: Fixed first variation of objekt::load
This commit is contained in:
parent
7482a64ed0
commit
a7fee5e2ec
@ -31,6 +31,7 @@ MODULE_OBJS = \
|
||||
metaengine.o \
|
||||
movclass.o \
|
||||
ngstypes.o \
|
||||
objekt.o \
|
||||
objekte.o \
|
||||
r_event.o \
|
||||
room.o \
|
||||
|
65
engines/chewy/objekt.cpp
Normal file
65
engines/chewy/objekt.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
/* 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 "chewy/objekt.h"
|
||||
|
||||
namespace Chewy {
|
||||
|
||||
bool RoomMovObjekt::load(Common::SeekableReadStream *src) {
|
||||
RoomNr = src->readSint16LE();
|
||||
|
||||
X = src->readSint16LE();
|
||||
Y = src->readSint16LE();
|
||||
XOff = src->readByte();
|
||||
YOff = src->readByte();
|
||||
TxtNr = src->readSint16LE();
|
||||
NeuObj = src->readSint16LE();
|
||||
ActionObj = src->readSint16LE();
|
||||
ZustandAk = src->readByte();
|
||||
ZustandOff = src->readByte();
|
||||
ZustandFlipFlop = src->readByte();
|
||||
AutoMov = src->readByte();
|
||||
AniFlag = src->readByte();
|
||||
Del = src->readByte();
|
||||
Attribut = src->readByte();
|
||||
HeldHide = src->readByte();
|
||||
ZEbene = src->readSint16LE();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IibDateiHeader::load(Common::SeekableReadStream *src) {
|
||||
src->read(Id, 4);
|
||||
src->read(Tafname, 14);
|
||||
Size = src->readUint32LE();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SibDateiHeader::load(Common::SeekableReadStream *src) {
|
||||
src->read(Id, 4);
|
||||
Anz = src->readUint16LE();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Chewy
|
@ -23,6 +23,8 @@
|
||||
#ifndef CHEWY_OBJEKT_H
|
||||
#define CHEWY_OBJEKT_H
|
||||
|
||||
#include "common/stream.h"
|
||||
|
||||
namespace Chewy {
|
||||
|
||||
struct RoomMovObjekt {
|
||||
@ -33,34 +35,28 @@ struct RoomMovObjekt {
|
||||
uint8 XOff;
|
||||
uint8 YOff;
|
||||
int16 TxtNr;
|
||||
|
||||
int16 NeuObj;
|
||||
|
||||
int16 ActionObj;
|
||||
|
||||
uint8 ZustandAk;
|
||||
|
||||
uint8 ZustandOff;
|
||||
|
||||
uint8 ZustandFlipFlop;
|
||||
|
||||
uint8 AutoMov;
|
||||
|
||||
uint8 AniFlag;
|
||||
|
||||
uint8 Del;
|
||||
|
||||
uint8 Attribut;
|
||||
|
||||
uint8 HeldHide;
|
||||
|
||||
int16 ZEbene;
|
||||
|
||||
bool load(Common::SeekableReadStream *src);
|
||||
static size_t size() { return 24; }
|
||||
};
|
||||
|
||||
struct IibDateiHeader {
|
||||
char Id[4];
|
||||
char Tafname[14];
|
||||
uint32 Size;
|
||||
|
||||
bool load(Common::SeekableReadStream *src);
|
||||
};
|
||||
|
||||
struct RoomStaticInventar {
|
||||
@ -96,6 +92,8 @@ struct RoomStaticInventar {
|
||||
struct SibDateiHeader {
|
||||
char Id[4];
|
||||
int16 Anz;
|
||||
|
||||
bool load(Common::SeekableReadStream *src);
|
||||
};
|
||||
|
||||
struct RoomExit {
|
||||
|
@ -90,19 +90,27 @@ objekt::~objekt() {
|
||||
}
|
||||
|
||||
int16 objekt::load(const char *fname_, RoomMovObjekt *rmo) {
|
||||
Stream *handle;
|
||||
handle = chewy_fopen(fname_, "rb");
|
||||
if (handle) {
|
||||
if (!chewy_fread(&iib_datei_header, sizeof(IibDateiHeader), 1, handle)) {
|
||||
Common::File f;
|
||||
bool valid = true;
|
||||
|
||||
if (f.open(fname_)) {
|
||||
if (!iib_datei_header.load(&f)) {
|
||||
fcode = READFEHLER;
|
||||
modul = DATEI;
|
||||
} else if (!scumm_strnicmp(iib_datei_header.Id, "IIB", 3)) {
|
||||
if (iib_datei_header.Size) {
|
||||
if (!chewy_fread(rmo, (size_t)iib_datei_header.Size, 1, handle)) {
|
||||
assert(iib_datei_header.Size % RoomMovObjekt::size() == 0);
|
||||
|
||||
for (int i = 0; i < iib_datei_header.Size / RoomMovObjekt::size() && valid;
|
||||
++i, ++rmo) {
|
||||
valid = rmo->load(&f);
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
fcode = READFEHLER;
|
||||
modul = DATEI;
|
||||
} else {
|
||||
max_inventar_obj = (int16) iib_datei_header.Size / sizeof(RoomMovObjekt);
|
||||
max_inventar_obj = (int16)iib_datei_header.Size / RoomMovObjekt::size();
|
||||
}
|
||||
} else
|
||||
max_inventar_obj = 0;
|
||||
@ -110,25 +118,26 @@ int16 objekt::load(const char *fname_, RoomMovObjekt *rmo) {
|
||||
fcode = READFEHLER;
|
||||
modul = DATEI;
|
||||
}
|
||||
chewy_fclose(handle);
|
||||
|
||||
f.close();
|
||||
} else {
|
||||
fcode = OPENFEHLER;
|
||||
modul = DATEI;
|
||||
}
|
||||
return (max_inventar_obj);
|
||||
|
||||
return max_inventar_obj;
|
||||
}
|
||||
|
||||
int16 objekt::load(const char *fname_, RoomStaticInventar *rsi) {
|
||||
Stream *handle;
|
||||
handle = chewy_fopen(fname_, "rb");
|
||||
if (handle) {
|
||||
Common::File f;
|
||||
|
||||
if (!chewy_fread(&sib_datei_header, sizeof(SibDateiHeader), 1, handle)) {
|
||||
if (f.open(fname_)) {
|
||||
if (!chewy_fread(&sib_datei_header, sizeof(SibDateiHeader), 1, &f)) {
|
||||
fcode = READFEHLER;
|
||||
modul = DATEI;
|
||||
} else if (!scumm_strnicmp(sib_datei_header.Id, "SIB", 3)) {
|
||||
if (sib_datei_header.Anz) {
|
||||
if (!chewy_fread(rsi, (size_t)(sib_datei_header.Anz * sizeof(RoomStaticInventar)), 1, handle)) {
|
||||
if (!chewy_fread(rsi, (size_t)(sib_datei_header.Anz * sizeof(RoomStaticInventar)), 1, &f)) {
|
||||
fcode = READFEHLER;
|
||||
modul = DATEI;
|
||||
} else {
|
||||
@ -140,25 +149,26 @@ int16 objekt::load(const char *fname_, RoomStaticInventar *rsi) {
|
||||
fcode = READFEHLER;
|
||||
modul = DATEI;
|
||||
}
|
||||
chewy_fclose(handle);
|
||||
|
||||
f.close();
|
||||
} else {
|
||||
fcode = OPENFEHLER;
|
||||
modul = DATEI;
|
||||
}
|
||||
return (max_static_inventar);
|
||||
|
||||
return max_static_inventar;
|
||||
}
|
||||
|
||||
int16 objekt::load(const char *fname_, RoomExit *RoomEx) {
|
||||
Stream *handle;
|
||||
handle = chewy_fopen(fname_, "rb");
|
||||
if (handle) {
|
||||
Common::File f;
|
||||
|
||||
if (!chewy_fread(&eib_datei_header, sizeof(EibDateiHeader), 1, handle)) {
|
||||
if (f.open(fname_)) {
|
||||
if (!chewy_fread(&eib_datei_header, sizeof(EibDateiHeader), 1, &f)) {
|
||||
fcode = READFEHLER;
|
||||
modul = DATEI;
|
||||
} else if (!scumm_strnicmp(eib_datei_header.Id, "EIB", 3)) {
|
||||
if (sib_datei_header.Anz) {
|
||||
if (!chewy_fread(RoomEx, (size_t)(eib_datei_header.Anz * sizeof(RoomExit)), 1, handle)) {
|
||||
if (!chewy_fread(RoomEx, (size_t)(eib_datei_header.Anz * sizeof(RoomExit)), 1, &f)) {
|
||||
fcode = READFEHLER;
|
||||
modul = DATEI;
|
||||
} else {
|
||||
@ -170,12 +180,14 @@ int16 objekt::load(const char *fname_, RoomExit *RoomEx) {
|
||||
fcode = READFEHLER;
|
||||
modul = DATEI;
|
||||
}
|
||||
chewy_fclose(handle);
|
||||
|
||||
f.close();
|
||||
} else {
|
||||
fcode = OPENFEHLER;
|
||||
modul = DATEI;
|
||||
}
|
||||
return (max_exit);
|
||||
|
||||
return max_exit;
|
||||
}
|
||||
|
||||
void objekt::sort() {
|
||||
|
Loading…
Reference in New Issue
Block a user