diff options
author | Matthew Hoops | 2011-06-15 12:54:17 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-06-15 12:54:17 -0400 |
commit | 0e78eb00197ae00cabefa02f4df74ce5a5de1e89 (patch) | |
tree | 3001d6b01a7fb5356b55b500ad4cf2cc876122ef | |
parent | a93a7717533045b1dfc7e81eeb5b54b947b3f9ed (diff) | |
download | scummvm-rg350-0e78eb00197ae00cabefa02f4df74ce5a5de1e89.tar.gz scummvm-rg350-0e78eb00197ae00cabefa02f4df74ce5a5de1e89.tar.bz2 scummvm-rg350-0e78eb00197ae00cabefa02f4df74ce5a5de1e89.zip |
PEGASUS: Add the Game Shell CItem class
-rwxr-xr-x | engines/pegasus/Game_Shell/CItem.cpp | 111 | ||||
-rwxr-xr-x | engines/pegasus/Game_Shell/CItem.h | 84 | ||||
-rwxr-xr-x | engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h | 81 | ||||
-rwxr-xr-x | engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h | 80 | ||||
-rw-r--r-- | engines/pegasus/module.mk | 3 |
5 files changed, 358 insertions, 1 deletions
diff --git a/engines/pegasus/Game_Shell/CItem.cpp b/engines/pegasus/Game_Shell/CItem.cpp new file mode 100755 index 0000000000..0816e595da --- /dev/null +++ b/engines/pegasus/Game_Shell/CItem.cpp @@ -0,0 +1,111 @@ +/* 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. + * + * Additional copyright for this file: + * Copyright (C) 1995-1997 Presto Studios + * + * 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/error.h" +#include "common/stream.h" + +#include "pegasus/Game_Shell/CItem.h" +#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h" + +namespace Pegasus { + +CItem::CItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) : MMIDObject(id) { + fItemNeighborhood = neighborhood; + fItemRoom = room; + fItemDirection = direction; + fItemWeight = 1; + fItemOwnerID = kNoActorID; + fItemState = 0; + + // TODO: This line would append this item to the list of all items + //gAllItems.Append(this); +} + +CItem::~CItem() { +} + +Common::Error CItem::WriteToStream(Common::WriteStream *stream) { + stream->writeUint16BE(fItemNeighborhood); + stream->writeUint16BE(fItemRoom); + stream->writeByte(fItemDirection); + stream->writeUint16BE(fItemOwnerID); + stream->writeUint16BE(fItemState); + + if (stream->err()) + return Common::kWritingFailed; + + return Common::kNoError; +} + +Common::Error CItem::ReadFromStream(Common::ReadStream *stream) { + fItemNeighborhood = stream->readUint16BE(); + fItemRoom = stream->readUint16BE(); + fItemDirection = stream->readByte(); + fItemOwnerID = stream->readUint16BE(); + fItemState = stream->readUint16BE(); + + if (stream->err()) + return Common::kReadingFailed; + + return Common::kNoError; +} + +tActorID CItem::GetItemOwner() const { + return fItemOwnerID; +} + +void CItem::SetItemOwner(const tActorID owner) { + fItemOwnerID = owner; +} + +tWeightType CItem::GetItemWeight() { + return fItemWeight; +} + +tItemState CItem::GetItemState() const { + return fItemState; +} + +void CItem::SetItemState(const tItemState state) { + fItemState = state; +} + +void CItem::GetItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const { + neighborhood = fItemNeighborhood; + room = fItemRoom; + direction = fItemDirection; +} + +void CItem::SetItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) { + fItemNeighborhood = neighborhood; + fItemRoom = room; + fItemDirection = direction; +} + +tNeighborhoodID CItem::GetItemNeighborhood() const { + return fItemNeighborhood; +} + +} // End of namespace Pegasus diff --git a/engines/pegasus/Game_Shell/CItem.h b/engines/pegasus/Game_Shell/CItem.h new file mode 100755 index 0000000000..2bef735008 --- /dev/null +++ b/engines/pegasus/Game_Shell/CItem.h @@ -0,0 +1,84 @@ +/* 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. + * + * Additional copyright for this file: + * Copyright (C) 1995-1997 Presto Studios + * + * 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 PEGASUS_GAMESHELL_CITEM_H +#define PEGASUS_GAMESHELL_CITEM_H + +#include "pegasus/MMShell/Utilities/MMIDObject.h" +#include "pegasus/Game_Shell/Headers/Game_Shell_Types.h" + +namespace Common { + class Error; + class ReadStream; + class WriteStream; +} + +namespace Pegasus { + +/* + + CItem is an object which can be picked up and carried around. + CItems have + a location + an ID. + weight + an owner (kNoActorID if no one is carrying the CItem) + +*/ + +class CItem : public MMIDObject { +public: + CItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction); + virtual ~CItem(); + + // WriteToStream writes everything EXCEPT the item's ID. + // It is assumed that the calling function will write and read the ID. + virtual Common::Error WriteToStream(Common::WriteStream *stream); + virtual Common::Error ReadFromStream(Common::ReadStream *stream); + + virtual tActorID GetItemOwner() const; + virtual void SetItemOwner(const tActorID owner); + + void GetItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const; + void SetItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction); + tNeighborhoodID GetItemNeighborhood() const; + + virtual tWeightType GetItemWeight(); + + virtual void SetItemState(const tItemState state); + virtual tItemState GetItemState() const; + +protected: + tNeighborhoodID fItemNeighborhood; + tRoomID fItemRoom; + tDirectionConstant fItemDirection; + tActorID fItemOwnerID; + tWeightType fItemWeight; + tItemState fItemState; +}; + +} // End of namespace Pegasus + +#endif diff --git a/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h b/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h new file mode 100755 index 0000000000..919c0599c0 --- /dev/null +++ b/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h @@ -0,0 +1,81 @@ +/* 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. + * + * Additional copyright for this file: + * Copyright (C) 1995-1997 Presto Studios + * + * 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 PEGASUS_GAMESHELL_HEADERS_GAMESHELLCONSTANTS +#define PEGASUS_GAMESHELL_HEADERS_GAMESHELLCONSTANTS + +#include "engines/pegasus/MMShell/MMConstants.h" +#include "engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h" + +namespace Pegasus { + +const tGameID kGameIDNothing = -1; + +const tActorID kNoActorID = kGameIDNothing; +const tActorID kPlayerID = 0; +const tItemID kNoItemID = kGameIDNothing; +const tRoomID kNoRoomID = kGameIDNothing; +const tExtraID kNoExtraID = 0xFFFFFFFF; +const tNeighborhoodID kNoNeighborhoodID = kGameIDNothing; +const tAlternateID kNoAlternateID = 0; +const tGameMenuCommand kMenuCmdNoCommand = 0; + +const tHotSpotActivationID kActivateHotSpotAlways = 0; +const tHotSpotActivationID kActivateHotSpotNever = -1; + +const tItemState kNoItemState = -1; + +const tDirectionConstant kNoDirection = 0xFF; + +const tTurnDirection kNoTurn = 0xFF; +const tTurnDirection kTurnLeft = 0; +const tTurnDirection kTurnRight = 1; +const tTurnDirection kTurnUp = 2; +const tTurnDirection kTurnDown = 3; +const tTurnDirection kMaxTurns = 4; + +const tGameMode kNoMode = -1; +const tGameMode kModeNavigation = 0; +const tGameMode kLastGameShellMode = kModeNavigation; + +const tCanMoveForwardReason kCanMoveForward = 0; +const tCanMoveForwardReason kCantMoveBlocked = kCanMoveForward + 1; +const tCanMoveForwardReason kCantMoveDoorClosed = kCantMoveBlocked + 1; +const tCanMoveForwardReason kCantMoveDoorLocked = kCantMoveDoorClosed + 1; +const tCanMoveForwardReason kCantMoveLastReason = kCantMoveDoorLocked; + +const tCanTurnReason kCanTurn = 0; +const tCanTurnReason kCantTurnNoTurn = kCanTurn + 1; +const tCanTurnReason kCantTurnLastReason = kCantTurnNoTurn; + +const tCanOpenDoorReason kCanOpenDoor = 0; +const tCanOpenDoorReason kCantOpenNoDoor = kCanOpenDoor + 1; +const tCanOpenDoorReason kCantOpenLocked = kCantOpenNoDoor + 1; +const tCanOpenDoorReason kCantOpenAlreadyOpen = kCantOpenLocked + 1; +const tCanOpenDoorReason kCantOpenLastReason = kCantOpenAlreadyOpen; + +} // End of namespace Pegasus + +#endif diff --git a/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h b/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h new file mode 100755 index 0000000000..1c3b0f374f --- /dev/null +++ b/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h @@ -0,0 +1,80 @@ +/* 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. + * + * Additional copyright for this file: + * Copyright (C) 1995-1997 Presto Studios + * + * 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 PEGASUS_GAMESHELL_HEADERS_GAMESHELLTYPES +#define PEGASUS_GAMESHELL_HEADERS_GAMESHELLTYPES + +#include "pegasus/MMShell/MMTypes.h" + +namespace Pegasus { + +typedef tMM16BitID tGameID; + +typedef tGameID tItemID; +typedef tGameID tActorID; +typedef tGameID tRoomID; +typedef tGameID tNeighborhoodID; +typedef tMM8BitU tAlternateID; +typedef tMM8BitS tHotSpotActivationID; + +typedef tMM16BitS tWeightType; + +typedef tMM8BitU tDirectionConstant; +typedef tMM8BitU tTurnDirection; + +// Meant to be room in low 16 bits and direction in high 16 bits. +typedef tMM32BitU tRoomViewID; + +#define MakeRoomView(room, direction) (((tRoomViewID) (room)) | (((tRoomViewID) (direction)) << 16)) + +typedef tMM32BitU tExtraID; + +typedef tMM16BitS tGameMode; + +typedef tMM16BitS tWeightType; + +typedef tMM16BitS tItemState; + +typedef tMM8BitS tDeathReason; + +typedef tMM32BitS tGameMenuCommand; + +typedef tMM32BitS tGameScoreType; + +typedef long tCanMoveForwardReason; + +typedef long tCanTurnReason; + +typedef long tCanOpenDoorReason; + +enum tInventoryResult { + kInventoryOK, + kTooMuchWeight, + kItemNotInInventory +}; + +} // End of namespace Pegasus + +#endif diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk index 585575022f..923d96a965 100644 --- a/engines/pegasus/module.mk +++ b/engines/pegasus/module.mk @@ -9,7 +9,8 @@ MODULE_OBJS = \ overview.o \ pegasus.o \ sound.o \ - video.o + video.o \ + Game_Shell/CItem.o # This module can be built as a plugin |