aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2019-10-28 00:39:46 +0100
committerEugene Sandulenko2019-11-13 22:07:08 +0100
commit47e27334693bb5aad09d8ad481c34773438f1004 (patch)
tree0ac410bbb7058dd69a717dbda1ed7ef52e52174a
parentbf94210ad975b9668006fddc4a085b024214817b (diff)
downloadscummvm-rg350-47e27334693bb5aad09d8ad481c34773438f1004.tar.gz
scummvm-rg350-47e27334693bb5aad09d8ad481c34773438f1004.tar.bz2
scummvm-rg350-47e27334693bb5aad09d8ad481c34773438f1004.zip
GRIFFON: Some refactoring
-rw-r--r--engines/griffon/combat.cpp10
-rw-r--r--engines/griffon/config.cpp5
-rw-r--r--engines/griffon/cutscenes.cpp6
-rw-r--r--engines/griffon/dialogs.cpp56
-rw-r--r--engines/griffon/griffon.h1
5 files changed, 31 insertions, 47 deletions
diff --git a/engines/griffon/combat.cpp b/engines/griffon/combat.cpp
index 2ef46c7b63..66f6eb56f4 100644
--- a/engines/griffon/combat.cpp
+++ b/engines/griffon/combat.cpp
@@ -52,9 +52,7 @@ void GriffonEngine::attack() {
if (ly > 0) {
int o2 = 0; // ??
int o = _objectMap[lx][ly - 1];
- if (ly > 1 && _curmap == 58)
- o2 = _objectMap[lx][ly - 2];
- if (ly > 1 && _curmap == 54)
+ if (ly > 1 && (_curmap == 54 || _curmap == 58))
o2 = _objectMap[lx][ly - 2];
// cst
@@ -63,7 +61,7 @@ void GriffonEngine::attack() {
o = 10;
int oscript = _objectInfo[o][5];
- if (oscript == 0 && _player.inventory[kInvFlask] < 9) {
+ if (oscript == kScriptFlask && _player.inventory[kInvFlask] < 9) {
_player.inventory[kInvFlask]++;
addFloatIcon(6, lx * 16, (ly - 1) * 16);
@@ -82,7 +80,7 @@ void GriffonEngine::attack() {
return;
}
- if (oscript == 0 && _player.inventory[kInvFlask] == 9) {
+ if (oscript == kScriptFlask && _player.inventory[kInvFlask] == 9) {
if (config.effects) {
int snd = playSound(_sfx[kSndChest]);
setChannelVolume(snd, config.effectsvol);
@@ -481,7 +479,7 @@ void GriffonEngine::castSpell(int spellnum, float homex, float homey, float enem
spellinfo[i].fireballs[nballs][3] = 0;
spellinfo[i].ballon[nballs] = 1;
- nballs = nballs + 1;
+ ++nballs;
}
}
}
diff --git a/engines/griffon/config.cpp b/engines/griffon/config.cpp
index 09d7e49a00..58ee59d051 100644
--- a/engines/griffon/config.cpp
+++ b/engines/griffon/config.cpp
@@ -43,12 +43,11 @@ CONFIG config;
void config_load(CONFIG *config) {
bool mute = false;
+ config->music = config->effects = false;
+
if (ConfMan.hasKey("mute"))
mute = ConfMan.getBool("mute");
- config->music = mute;
- config->effects = mute;
-
if (!mute) {
config->music = !ConfMan.getBool("music_mute");
config->effects = !ConfMan.getBool("sfx_mute");
diff --git a/engines/griffon/cutscenes.cpp b/engines/griffon/cutscenes.cpp
index ef77c76fdf..719e89f18b 100644
--- a/engines/griffon/cutscenes.cpp
+++ b/engines/griffon/cutscenes.cpp
@@ -252,7 +252,7 @@ void GriffonEngine::intro() {
add = 1;
xofs += add;
if (xofs >= 320)
- xofs = xofs - 320;
+ xofs -= 320;
g_system->getEventManager()->pollEvent(_event);
@@ -391,9 +391,9 @@ void GriffonEngine::endOfGame() {
float add = 0.5 * _fpsr;
if (add > 1)
add = 1;
- xofs = xofs + add;
+ xofs += add;
if (xofs >= 320)
- xofs = xofs - 320;
+ xofs -= 320;
if (_event.type == Common::EVENT_KEYDOWN)
spd = 1.0f;
diff --git a/engines/griffon/dialogs.cpp b/engines/griffon/dialogs.cpp
index 374625d764..7e606f1fd0 100644
--- a/engines/griffon/dialogs.cpp
+++ b/engines/griffon/dialogs.cpp
@@ -227,7 +227,7 @@ void GriffonEngine::title(int mode) {
}
void GriffonEngine::configMenu() {
- static const char *vr[22] = {
+ static const char *optionTitles[22] = {
"", "",
"", "", "", "",
"", "", "",
@@ -236,7 +236,7 @@ void GriffonEngine::configMenu() {
"Music Volume:", "",
"Effects Volume:", "", "", "", ""
};
- static const char *vl[22] = {
+ static const char *optionValues[22] = {
"", "",
"", "", "", "",
"", "", "",
@@ -289,30 +289,27 @@ void GriffonEngine::configMenu() {
for (int i = 0; i <= 21; i++) {
static char line[24];
- if (i == 15 || i == 17) {
+ int destColumn = 3;
+ if (i == 9 && config.music)
+ destColumn = 0;
+ else if (i == 10 && !config.music)
+ destColumn = 0;
+ else if (i == 12 && config.effects)
+ destColumn = 0;
+ else if (i == 13 && !config.effects)
+ destColumn = 0;
+ else if (i == 15 || i == 17) {
int vol = (i == 15 ? config.musicvol : config.effectsvol) * 9 / 255;
vol = CLIP(vol, 0, 9);
strcpy(line, "[----------]");
line[vol + 1] = 'X';
- vl[i] = line;
- }
-
- int cl = 3;
-
- if (i == 9 && config.music)
- cl = 0;
- else if (i == 10 && !config.music)
- cl = 0;
- else if (i == 12 && config.effects)
- cl = 0;
- else if (i == 13 && !config.effects)
- cl = 0;
- else if (i > 18)
- cl = 0;
+ optionValues[i] = line;
+ } else if (i > 18)
+ destColumn = 0;
- drawString(_videobuffer, vr[i], 156 - 8 * strlen(vr[i]), sy + i * 8, 0);
- drawString(_videobuffer, vl[i], 164, sy + i * 8, cl);
+ drawString(_videobuffer, optionTitles[i], 156 - 8 * strlen(optionTitles[i]), sy + i * 8, 0);
+ drawString(_videobuffer, optionValues[i], 164, sy + i * 8, destColumn);
}
int curselt = cursel + 2;
@@ -376,17 +373,11 @@ void GriffonEngine::configMenu() {
if (_event.kbd.keycode == Common::KEYCODE_LEFT) {
if (cursel == 11) {
- config.musicvol -= 25;
- if (config.musicvol < 0)
- config.musicvol = 0;
-
+ config.musicvol = CLIP(config.musicvol - 25, 0, 255);
setChannelVolume(_musicChannel, config.musicvol);
setChannelVolume(_menuChannel, config.musicvol);
} else if (cursel == 12) {
- config.effectsvol -= 25;
- if (config.effectsvol < 0)
- config.effectsvol = 0;
-
+ config.effectsvol = CLIP(config.effectsvol - 25, 0, 255);
setChannelVolume(-1, config.effectsvol);
setChannelVolume(_musicChannel, config.musicvol);
setChannelVolume(_menuChannel, config.musicvol);
@@ -399,16 +390,11 @@ void GriffonEngine::configMenu() {
}
if (_event.kbd.keycode == Common::KEYCODE_RIGHT) {
if (cursel == 11) {
- config.musicvol += 25;
- if (config.musicvol > 255)
- config.musicvol = 255;
-
+ config.musicvol = CLIP(config.musicvol + 25, 0, 255);
setChannelVolume(_musicChannel, config.musicvol);
setChannelVolume(_menuChannel, config.musicvol);
} else if (cursel == 12) {
- config.effectsvol += 25;
- if (config.effectsvol > 255)
- config.effectsvol = 255;
+ config.effectsvol = CLIP(config.effectsvol + 25, 0, 255);
setChannelVolume(-1, config.effectsvol);
setChannelVolume(_musicChannel, config.musicvol);
diff --git a/engines/griffon/griffon.h b/engines/griffon/griffon.h
index af9ef9c6f0..1a830f6f43 100644
--- a/engines/griffon/griffon.h
+++ b/engines/griffon/griffon.h
@@ -92,6 +92,7 @@ enum {
// in game scripts
enum {
+ kScriptFlask = 0, // get flask
kScriptMasterKey = 2, // find master key
kScriptFindCtystal = 3, // find crystal
kScriptFindShield = 4, // find shield - obj 8