[Scummvm-cvs-logs] CVS: scummvm/queen verb.h,NONE,1.1 defs.h,1.19,1.20 structs.h,1.17,1.18 input.h,1.4,1.5 input.cpp,1.4,1.5 logic.h,1.48,1.49 logic.cpp,1.65,1.66 cutaway.cpp,1.45,1.46 talk.cpp,1.27,1.28 xref.txt,1.24,1.25
Gregory Montoir
cyx at users.sourceforge.net
Thu Oct 30 02:57:09 CET 2003
Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv28031
Modified Files:
defs.h structs.h input.h input.cpp logic.h logic.cpp
cutaway.cpp talk.cpp xref.txt
Added Files:
verb.h
Log Message:
new Verb class
--- NEW FILE: verb.h ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 The ScummVM project
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/scummvm/queen/verb.h,v 1.1 2003/10/30 10:56:38 cyx Exp $
*
*/
#ifndef QUEENVERB_H
#define QUEENVERB_H
enum VerbEnum {
VERB_NONE = 0,
VERB_PANEL_COMMAND_FIRST = 1,
VERB_OPEN = 1,
VERB_CLOSE = 2,
VERB_MOVE = 3,
// no verb 4
VERB_GIVE = 5,
VERB_USE = 6,
VERB_PICK_UP = 7,
VERB_LOOK_AT = 9,
VERB_TALK_TO = 8,
VERB_PANEL_COMMAND_LAST = 9,
VERB_WALK_TO = 10,
VERB_SCROLL_UP = 11,
VERB_SCROLL_DOWN = 12,
VERB_DIGIT_FIRST = 13,
VERB_DIGIT_1 = 13,
VERB_DIGIT_2 = 14,
VERB_DIGIT_3 = 15,
VERB_DIGIT_4 = 16,
VERB_DIGIT_LAST = 16,
VERB_INV_FIRST = VERB_DIGIT_FIRST,
VERB_INV_1 = VERB_DIGIT_1,
VERB_INV_2 = VERB_DIGIT_2,
VERB_INV_3 = VERB_DIGIT_3,
VERB_INV_4 = VERB_DIGIT_4,
VERB_INV_LAST = VERB_DIGIT_LAST,
VERB_USE_JOURNAL = 20,
VERB_SKIP_TEXT = 101,
VERB_PREP_WITH = 11,
VERB_PREP_TO = 12
};
class Verb {
public:
Verb() {
_verb = VERB_NONE;
}
Verb(VerbEnum v) {
_verb = v;
}
//! _verb is open/close/move/give/look at/pick up/talk to
bool isPanelCommand() const {
return
_verb >= VERB_PANEL_COMMAND_FIRST &&
_verb <= VERB_PANEL_COMMAND_LAST;
}
bool isScrollInventory() const {
return
_verb == VERB_SCROLL_UP ||
_verb == VERB_SCROLL_DOWN;
}
bool isInventory() const {
return
_verb >= VERB_INV_FIRST &&
_verb <= VERB_INV_LAST;
}
bool isJournal() const {
return _verb == VERB_USE_JOURNAL;
}
bool isTwoLevelsCommand() const {
return
_verb == VERB_GIVE ||
_verb == VERB_USE;
}
bool isDigit() const {
return
_verb >= VERB_DIGIT_FIRST &&
_verb <= VERB_DIGIT_LAST;
}
bool isSkipText() const {
return _verb == VERB_SKIP_TEXT;
}
VerbEnum value() const {
return _verb;
}
const char* name() const {
if (_verb > 0 && _verb < 13) {
_verbName[_verb];
}
return NULL;
}
bool operator==(const Verb& other) const {
return _verb == other._verb;
}
static void initName(int i, char* name) {
_verbName[i] = name;
}
private:
VerbEnum _verb;
static char* _verbName[13];
};
#endif
Index: defs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/defs.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- defs.h 27 Oct 2003 15:00:25 -0000 1.19
+++ defs.h 30 Oct 2003 10:56:38 -0000 1.20
@@ -90,40 +90,6 @@
};
-enum Verb {
- VERB_NONE = 0,
-
- VERB_PANEL_COMMAND_FIRST = 1,
- VERB_OPEN = 1,
- VERB_CLOSE = 2,
- VERB_MOVE = 3,
- // no verb 4
- VERB_GIVE = 5,
- VERB_USE = 6,
- VERB_PICK_UP = 7,
- VERB_LOOK_AT = 9,
- VERB_TALK_TO = 8,
- VERB_PANEL_COMMAND_LAST = 9,
-
- VERB_WALK_TO = 10,
- VERB_SCROLL_UP = 11,
- VERB_SCROLL_DOWN = 12,
-
- VERB_DIGIT_FIRST = 13,
- VERB_DIGIT_1 = 13,
- VERB_DIGIT_2 = 14,
- VERB_DIGIT_3 = 15,
- VERB_DIGIT_4 = 16,
- VERB_DIGIT_LAST = 16,
-
- VERB_USE_JOURNAL = 20,
- VERB_SKIP_TEXT = 101,
-
- VERB_PREP_WITH = 11,
- VERB_PREP_TO = 12
-};
-
-
enum StateTalk {
STATE_TALK_TALK,
STATE_TALK_MUTE
Index: structs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/structs.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- structs.h 26 Oct 2003 13:54:26 -0000 1.17
+++ structs.h 30 Oct 2003 10:56:38 -0000 1.18
@@ -24,6 +24,8 @@
namespace Queen {
+#include "queen/verb.h"
+
struct Box {
int16 x1, y1, x2, y2;
@@ -365,7 +367,7 @@
int16 specialSection;
void readFrom(byte *&ptr) {
- verb = (Verb)READ_BE_UINT16(ptr); ptr += 2;
+ verb = Verb((VerbEnum)READ_BE_UINT16(ptr)); ptr += 2;
nounObj1 = (int16)READ_BE_UINT16(ptr); ptr += 2;
nounObj2 = (int16)READ_BE_UINT16(ptr); ptr += 2;
song = (int16)READ_BE_UINT16(ptr); ptr += 2;
@@ -377,7 +379,7 @@
specialSection = (int16)READ_BE_UINT16(ptr); ptr += 2;
}
- bool match(Verb v, int16 obj1, int16 obj2) const {
+ bool match(const Verb& v, int16 obj1, int16 obj2) const {
return verb == v && nounObj1 == obj1 && nounObj2 == obj2;
}
};
Index: input.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/input.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- input.h 28 Oct 2003 20:58:46 -0000 1.4
+++ input.h 30 Oct 2003 10:56:38 -0000 1.5
@@ -23,6 +23,7 @@
#define INPUT_H
#include "queen/defs.h"
+#include "queen/verb.h"
#include "common/scummsys.h"
class OSystem;
@@ -56,32 +57,7 @@
void checkKeys();
//! use instead of KEYVERB=0
- void clearKeyVerb() { _keyVerb = VERB_NONE; }
-
- //! _keyVerb is open/close/move/give/look at/pick up/talk to
- bool verbIsPanelCommand() {
- return
- _keyVerb >= VERB_PANEL_COMMAND_FIRST &&
- _keyVerb <= VERB_PANEL_COMMAND_LAST;
- }
-
- //! return _keyVerb if isPanelCommand() is true, otherwise VERB_NONE
- Verb verbPanelCommand();
-
- //! If _keyVerb is VERB_USE_JOURNAL
- bool verbUseJournal() { return _keyVerb == VERB_USE_JOURNAL; }
-
- //! If _keyVerb is VERB_KEY_1 to VERB_KEY_4
- bool verbIsDigit() {
- return
- _keyVerb >= VERB_DIGIT_FIRST &&
- _keyVerb <= VERB_DIGIT_LAST;
- }
-
- //! Returns 1-4 if keyDigit() is true, otherwise -1
- int verbDigit();
-
- bool verbSkipText() { return _keyVerb == VERB_SKIP_TEXT; }
+ void clearKeyVerb() { _keyVerb = Verb(VERB_NONE); }
void canQuit(bool cq) { _canQuit = cq; }
Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/input.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- input.cpp 28 Oct 2003 20:58:46 -0000 1.4
+++ input.cpp 30 Oct 2003 10:56:38 -0000 1.5
@@ -102,31 +102,31 @@
switch (_inKey) {
case KEY_SPACE:
- _keyVerb = VERB_SKIP_TEXT;
+ _keyVerb = Verb(VERB_SKIP_TEXT);
break;
case KEY_COMMA:
- _keyVerb = VERB_SCROLL_UP;
+ _keyVerb = Verb(VERB_SCROLL_UP);
break;
case KEY_DOT:
- _keyVerb = VERB_SCROLL_DOWN;
+ _keyVerb = Verb(VERB_SCROLL_DOWN);
break;
case KEY_DIGIT_1:
- _keyVerb = VERB_DIGIT_1;
+ _keyVerb = Verb(VERB_DIGIT_1);
break;
case KEY_DIGIT_2:
- _keyVerb = VERB_DIGIT_2;
+ _keyVerb = Verb(VERB_DIGIT_2);
break;
case KEY_DIGIT_3:
- _keyVerb = VERB_DIGIT_3;
+ _keyVerb = Verb(VERB_DIGIT_3);
break;
case KEY_DIGIT_4:
- _keyVerb = VERB_DIGIT_4;
+ _keyVerb = Verb(VERB_DIGIT_4);
break;
case KEY_ESCAPE:
@@ -144,12 +144,12 @@
case KEY_F1: // Use Journal
if (_cutawayRunning) {
if (_canQuit) {
- _keyVerb = VERB_USE_JOURNAL;
+ _keyVerb = Verb(VERB_USE_JOURNAL);
_cutawayQuit = _talkQuit = true;
}
}
else {
- _keyVerb = VERB_USE_JOURNAL;
+ _keyVerb = Verb(VERB_USE_JOURNAL);
if (_canQuit)
_talkQuit = true;
}
Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- logic.h 29 Oct 2003 13:06:09 -0000 1.48
+++ logic.h 30 Oct 2003 10:56:38 -0000 1.49
@@ -25,6 +25,7 @@
#include "queen/queen.h"
#include "queen/defs.h"
#include "queen/structs.h"
+#include "queen/verb.h"
namespace Queen {
@@ -271,7 +272,6 @@
uint16 findObjectRoomNumber(uint16 zoneNum) const;
uint16 findObjectGlobalNumber(uint16 zoneNum) const;
- const char *verbName(Verb v) const;
const char *lockedVerbPrefix() const { return _joeResponse[39]; }
void update();
@@ -361,8 +361,6 @@
//! Room name, prefix for data files (PCX, LUM...)
char **_roomName; //ROOM_NAMEstr
- char *_verbName[13]; //VERB_NAMEstr
-
char *_joeResponse[JOE_RESPONSE_MAX + 1]; //JOE_RESPstr
//! Actor animation string
@@ -414,7 +412,7 @@
Walk *_walk;
//! Verbs (in order) available in panel
- static const Verb PANEL_VERBS[];
+ static const VerbEnum PANEL_VERBS[];
};
} // End of namespace Queen
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- logic.cpp 29 Oct 2003 13:06:10 -0000 1.65
+++ logic.cpp 30 Oct 2003 10:56:38 -0000 1.66
@@ -32,7 +32,7 @@
namespace Queen {
-const Verb Logic::PANEL_VERBS[] = {
+const VerbEnum Logic::PANEL_VERBS[] = {
VERB_NONE,
VERB_OPEN,
VERB_CLOSE,
@@ -51,6 +51,8 @@
};
+char* Verb::_verbName[13];
+
Direction State::findDirection(uint16 state) {
// queen.c l.4014-4021
static const Direction sd[] = {
@@ -86,31 +88,31 @@
Verb v;
switch((state >> 4) & 0xF) {
case 1:
- v = VERB_OPEN;
+ v = Verb(VERB_OPEN);
break;
case 3:
- v = VERB_CLOSE;
+ v = Verb(VERB_CLOSE);
break;
case 7:
- v = VERB_MOVE;
+ v = Verb(VERB_MOVE);
break;
case 8:
- v = VERB_GIVE;
+ v = Verb(VERB_GIVE);
break;
case 12:
- v = VERB_USE;
+ v = Verb(VERB_USE);
break;
case 14:
- v = VERB_PICK_UP;
+ v = Verb(VERB_PICK_UP);
break;
case 9:
- v = VERB_TALK_TO;
+ v = Verb(VERB_TALK_TO);
break;
case 6:
- v = VERB_LOOK_AT;
+ v = Verb(VERB_LOOK_AT);
break;
default:
- v = VERB_NONE;
+ v = Verb(VERB_NONE);
break;
}
return v;
@@ -135,7 +137,7 @@
void State::alterDefaultVerb(uint16 *objState, Verb v) {
uint16 val;
- switch (v) {
+ switch (v.value()) {
case VERB_OPEN:
val = 1;
break;
@@ -418,9 +420,9 @@
for (i = 1; i <= _numRooms; i++)
_roomName[i] = _resource->getJAS2Line();
- _verbName[0] = 0;
+ Verb::initName(0, NULL);
for (i = 1; i <= 12; i++)
- _verbName[i] = _resource->getJAS2Line();
+ Verb::initName(i, _resource->getJAS2Line());
_joeResponse[0] = 0;
for (i = 1; i <= JOE_RESPONSE_MAX; i++)
@@ -1751,7 +1753,7 @@
y = objData->y;
}
- if (cmd->action2 == VERB_WALK_TO) {
+ if (cmd->action2.value() == VERB_WALK_TO) {
_entryObj = objData->entryObj;
}
else {
@@ -1760,7 +1762,7 @@
_newRoom = 0;
- if (_entryObj != 0 && cmd->action2 != VERB_CLOSE) {
+ if (_entryObj != 0 && cmd->action2.value() != VERB_CLOSE) {
// because this is an exit object, see if there is
// a walk off point and set (x,y) accordingly
WalkOffData *wod = walkOffPointForObject(k + cmd->noun2);
@@ -1954,7 +1956,7 @@
Verb Logic::findVerbUnderCursor(int16 cursorx, int16 cursory) const {
- return PANEL_VERBS[zoneIn(ZONE_PANEL, cursorx, cursory)];
+ return Verb(PANEL_VERBS[zoneIn(ZONE_PANEL, cursorx, cursory)]);
}
@@ -1989,19 +1991,6 @@
uint16 Logic::findObjectGlobalNumber(uint16 zoneNum) const {
return _roomData[_currentRoom] + findObjectRoomNumber(zoneNum);
-}
-
-
-const char *Logic::verbName(Verb v) const {
-
- // FIXME: rewrite this test with future VerbCommand methods
- if (v != VERB_NONE && v < 13) {
- return _verbName[v];
- }
- else {
- error("Logic::verbName() - Invalid verb %d", v);
- return NULL;
- }
}
Index: cutaway.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/cutaway.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- cutaway.cpp 23 Oct 2003 18:50:46 -0000 1.45
+++ cutaway.cpp 30 Oct 2003 10:56:38 -0000 1.46
@@ -1500,7 +1500,7 @@
if (_input->cutawayQuit())
return;
- if (_input->verbSkipText()) {
+ if (_input->keyVerb().isSkipText()) {
_input->clearKeyVerb();
break;
}
Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- talk.cpp 29 Oct 2003 21:04:12 -0000 1.27
+++ talk.cpp 30 Oct 2003 10:56:38 -0000 1.28
@@ -810,7 +810,7 @@
}
// Skip through text more quickly
- if (_input->verbSkipText()) {
+ if (_input->keyVerb().isSkipText()) {
_input->clearKeyVerb();
break;
}
Index: xref.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/xref.txt,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- xref.txt 28 Oct 2003 20:58:46 -0000 1.24
+++ xref.txt 30 Oct 2003 10:56:38 -0000 1.25
@@ -256,7 +256,7 @@
ROOMTOT Logic::_numRooms
ROOM_DATA Logic::_roomData
ROOM_NAMEstr Logic::_roomName
-VERB_NAMEstr Logic::_verbName
+VERB_NAMEstr Verb::_verbName
WALK_OFF_DATA Logic::_walkOffData
WALK_OFF_MAX Logic::_numWalkOffs
More information about the Scummvm-git-logs
mailing list