[Scummvm-git-logs] scummvm master -> bac83e11415a72cf95cba50eef65963c25e6a3b5
sev-
noreply at scummvm.org
Fri Oct 18 22:05:17 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fb7bdcade8 QDENGINE: More compilation fixes in minigames/adv
bac83e1141 QDENGINE: Added minigames/adv/RunTime.cpp to the project`
Commit: fb7bdcade82eb5dec8259aaf70c292ce8c46fd9b
https://github.com/scummvm/scummvm/commit/fb7bdcade82eb5dec8259aaf70c292ce8c46fd9b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-10-18T23:43:41+02:00
Commit Message:
QDENGINE: More compilation fixes in minigames/adv
Changed paths:
engines/qdengine/minigames/adv/RunTime.cpp
diff --git a/engines/qdengine/minigames/adv/RunTime.cpp b/engines/qdengine/minigames/adv/RunTime.cpp
index b8392e51957..bff8941b4b9 100644
--- a/engines/qdengine/minigames/adv/RunTime.cpp
+++ b/engines/qdengine/minigames/adv/RunTime.cpp
@@ -96,19 +96,20 @@ MinigameManager::MinigameManager()
}
MinigameManager::~MinigameManager() {
- xassert(!engine_ && !scene_);
+ assert(!engine_ && !scene_);
- GameInfoMap::iterator it;
- FOR_EACH(gameInfos_, it) {
- //dprintf("free: (%d,%d)\n", it->first.gameLevel_, it->first.gameNum_);
- it->second.free();
+ for (auto &it : (gameInfos_, it) {
+ debugC(5, kDebugMinigames, "~MinigameManager(): free: (%d,%d)", it->first.gameLevel_, it->first.gameNum_);
+ it.second.free();
}
}
bool MinigameManager::init(const qdEngineInterface* engine_interface) {
- dprintf("init game\n");
+ debugC(1, kDebugMinigames, "MinigameManager::init(): init game");
+
+ if (runtime != this)
+ warning("MinigameManager::init(): Attempt to instantiate double minigame");
- xxassert(runtime == this, "ÐопÑÑка одновÑеменного запÑÑка дÑÐ±Ð»Ñ Ð¼Ð¸Ð½Ð¸Ð¸Ð³ÑÑ");
if (runtime != this)
return false;
assert(!engine_ && !scene_);
@@ -143,10 +144,9 @@ bool MinigameManager::createGame() {
screenSize_ = engine_->screen_size();
- #ifdef _DEBUG
+#ifdef _DEBUG
debugMode_ = getParameter("debug_mode", false);
- dprintf("%s", debugMode_ ? "DEBUG MODE\n" : "");
- #endif
+#endif
seed_ = 0;
@@ -154,15 +154,15 @@ bool MinigameManager::createGame() {
return false;
if (currentGameInfo_) {
- dprintf("level: %d, game: %d, index: %d\n", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_, currentGameInfo_->game_.sequenceIndex_);
- dprintf("%s\n", currentGameInfo_->game_.sequenceIndex_ == -1 ? "FIRST TIME PLAY" : "RePlay game");
+ debugC(2, kDebugMinigames, "MinigameManager::createGame(): level: %d, game: %d, index: %d", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_, currentGameInfo_->game_.sequenceIndex_);
+ debugC(2, kDebugMinigames, "MinigameManager::createGame(): %s", currentGameInfo_->game_.sequenceIndex_ == -1 ? "FIRST TIME PLAY" : "RePlay game");
}
int s = getParameter("random_seed", -1);
seed_ = debugMode_ ? 0 : (s >= 0 ? s : seed_);
engine_->rnd_init(seed_);
- dprintf("seed = %d\n", seed_);
+ debugC(2, kDebugMinigames, "MinigameManager::createGame(): seed = %d", seed_);
invertMouseButtons_ = getParameter("invert_mouse_buttons", false);
mouseAdjast_ = getParameter("ajast_mouse", mgVect2f());
@@ -245,7 +245,7 @@ bool MinigameManager::createGame() {
}
bool MinigameManager::finit() {
- dprintf("finit game\n");
+ debugC(2, kDebugMinigames, "MinigameManager::finit(): finit game");
if (!engine_)
return false;
@@ -305,20 +305,18 @@ bool MinigameManager::finit() {
bool MinigameManager::new_game(const qdEngineInterface* engine_interface) {
if (!loadState(false)) {
- dprintf("new game skiped\n");
+ debugC(2, kDebugMinigames, "MinigameManager::new_game(): new game skiped");
return false;
}
- dprintf("new game\n");
+ debugC(2, kDebugMinigames, "MinigameManager::new_game(): new game");
- GameInfoMap::iterator it;
- FOR_EACH(gameInfos_, it) {
- dprintf("clean game data (%d, %d)\n", it->first.gameLevel_, it->first.gameNum_);
- it->second.game_ = MinigameData();
+ for (auto &it : gameInfos_) {
+ debugC(3, kDebugMinigames, "MinigameManager::new_game(): clean game data (%d, %d)", it->first.gameLevel_, it->first.gameNum_);
+ it.second.game_ = MinigameData();
}
saveState(true);
return true;
-
}
class TempValue {
@@ -349,11 +347,11 @@ public:
#define TEMP_SCENE_ENTER() TempValue tempSceneObject(this, engine, const_cast<qdMinigameSceneInterface*>(scene))
int MinigameManager::save_game(const qdEngineInterface* engine, const qdMinigameSceneInterface* scene, char* buffer, int buffer_size) {
- dprintf("save game\n");
+ debugC(2, kDebugMinigames, "MinigameManager::save_game(): save game");
TEMP_SCENE_ENTER();
loadState();
if (currentGameInfo_ && !currentGameInfo_->empty()) {
- dprintf("save game (%d, %d)\n", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_);
+ debugC(2, kDebugMinigames, "MinigameManager::save_game(): save game (%d, %d)", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_);
XBuffer out((void*)buffer, buffer_size);
out.write(GameInfo::version());
out.write(currentGameInfo_->game_);
@@ -366,32 +364,34 @@ int MinigameManager::save_game(const qdEngineInterface* engine, const qdMinigame
int MinigameManager::load_game(const qdEngineInterface* engine, const qdMinigameSceneInterface* scene, const char* buffer, int buffer_size) {
assert(!game_);
if (game_) {
- dprintf("load game skiped\n");
+ debugC(2, kDebugMinigames, "MinigameManager::load_game(): load game skiped");
return buffer_size;
}
- dprintf("load game\n");
+ debugC(2, kDebugMinigames, "MinigameManager::load_game(): load game");
TEMP_SCENE_ENTER();
loadState();
if (currentGameInfo_) {
if (buffer_size > 0) {
- dprintf("load game (%d, %d)\n", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_);
+ debugC(2, kDebugMinigames, "MinigameManager::load_game(): load game (%d, %d)", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_);
XBuffer in((void*)buffer, buffer_size);
int version;
in.read(version);
if (version == GameInfo::version()) {
in.read(currentGameInfo_->game_);
- xxassert(!currentGameInfo_->empty_, "ÐагÑÑзка даннÑÑ
по миниигÑе без даннÑÑ
о ÑÑене. РекомендÑеÑÑÑ ÑдалиÑÑ Ð²Ñе ÑоÑ
ÑанениÑ.");
+
+ if (currentGameInfo_->empty_)
+ warning("MinigameManager::load_game(): Attempt to load minigame without a scene");
if (in.tell() != buffer_size) {
currentGameInfo_->game_ = MinigameData();
- xxassert(0, "Ðе ÑÐ¾Ð²Ð¿Ð°Ð´Ð°ÐµÑ ÑÐ°Ð·Ð¼ÐµÑ Ð´Ð°Ð½Ð½ÑÑ
в ÑоÑ
Ñанении и в миниигÑе.");
+ warning("MinigameManager::load_game(): Data size mismatch");
return 0;
}
} else {
- xxassert(0, "ÐеÑовмеÑÑÐ¸Ð¼Ð°Ñ Ð²ÐµÑÑÐ¸Ñ ÑоÑ
ÑÐ°Ð½ÐµÐ½Ð¸Ñ Ð´Ð»Ñ Ð¼Ð¸Ð½Ð¸Ð¸Ð³ÑÑ.");
+ warning("MinigameManager::load_game(): Incompatible savegame version for minigame");
return 0;
}
} else {
- dprintf("clean game (%d, %d)\n", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_);
+ debugC(2, kDebugMinigames, "MinigameManager::load_game(): clean game (%d, %d)", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_);
currentGameInfo_->game_ = MinigameData();
}
saveState();
@@ -402,10 +402,10 @@ int MinigameManager::load_game(const qdEngineInterface* engine, const qdMinigame
bool MinigameManager::loadState(bool current) {
if (game_) {
- dprintf("load state skiped\n");
+ debugC(2, kDebugMinigames, "MinigameManager::loadState(): load state skiped");
return false;
}
- dprintf("load state\n");
+ debugC(2, kDebugMinigames, "MinigameManager::loadState(): load state");
if (current) {
int gameNumber = getParameter("game_number", -1);
int gameLevel = -1;
@@ -419,27 +419,27 @@ bool MinigameManager::loadState(bool current) {
if (!current || currentGameIndex_.gameNum_ >= 0) {
if (current)
- dprintf("current game: (%d,%d)\n", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_);
+ debugC(2, kDebugMinigames, "MinigameManager::loadState(): current game: (%d,%d)", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_);
XStream file(false);
if (file.open(state_container_name_, XS_IN)) {
int version;
file > version;
if (version != GameInfo::version()) {
- xxassert(0, (XBuffer() < "Ðе ÑÐ¾Ð²Ð¿Ð°Ð´Ð°ÐµÑ Ð²ÐµÑÑÐ¸Ñ ÑоÑ
ÑÐ°Ð½ÐµÐ½Ð¸Ñ ÑоÑÑоÑÐ½Ð¸Ñ Ð¼Ð¸Ð½Ð¸Ð¸Ð³ÑÑ. УдалиÑе " < state_container_name_).c_str());
+ warning("MinigameManager::loadState(): Minigame savestate version mismatch. Remove '%s'", state_container_name_);
return false;
}
file > seed_;
GameInfoIndex index(0, 0);
while (!file.eof()) {
file.read(index);
- xassert(gameInfos_.find(index) == gameInfos_.end());
+ assert(gameInfos_.find(index) == gameInfos_.end());
if (file.eof())
return false;
{
GameInfo data;
file > data;
- dprintf("read game info: (%d,%d), index: %d, game data:%d\n", index.gameLevel_, index.gameNum_, data.game_.sequenceIndex_, data.empty_ ? 0 : 1);
+ debugC(2, kDebugMinigames, "MinigameManager::loadState(): read game info: (%d,%d), index: %d, game data:%d", index.gameLevel_, index.gameNum_, data.game_.sequenceIndex_, data.empty_ ? 0 : 1);
if (data.game_.sequenceIndex_ >= 0)
completeCounters_[index.gameLevel_]++;
gameInfos_[index] = data;
@@ -454,21 +454,23 @@ bool MinigameManager::loadState(bool current) {
extern bool createDirForFile(const char* partialPath);
void MinigameManager::saveState(bool force) {
- dprintf("save state\n");
+ debugC(2, kDebugMinigames, "MinigameManager::save_state(): save state");
if (force || currentGameIndex_.gameNum_ >= 0) {
XStream file(false);
if (createDirForFile(state_container_name_) && file.open(state_container_name_, XS_OUT)) {
file < GameInfo::version();
file < (engine_ ? engine_->rnd(999999) : seed_);
GameInfoMap::const_iterator it;
- FOR_EACH(gameInfos_, it)
- if (!it->second.empty()) {
- dprintf("write game info: (%d,%d), index: %d, game data:%d\n", it->first.gameLevel_, it->first.gameNum_, it->second.game_.sequenceIndex_, it->second.empty_ ? 0 : 1);
- file.write(it->first);
- file < it->second;
+
+ for (auto &it: gameInfos_) {
+ if (!it.second.empty()) {
+ debugC(2, kDebugMinigames, "MinigameManager::save_state(): write game info: (%d,%d), index: %d, game data:%d", it.first.gameLevel_, it.first.gameNum_, it.second.game_.sequenceIndex_, it.second.empty_ ? 0 : 1);
+ file.write(it->first);
+ file < it->second;
+ }
}
} else {
- xxassert(0, (XBuffer() < "Ðе ÑдалоÑÑ ÑоÑ
ÑаниÑÑ Ð¿ÑогÑеÑÑ Ð² Ñайл: \"" < state_container_name_ < "\"").c_str());
+ warning("MinigameManager::saveState(): Failed to save file '%s'", state_container_name_);
}
}
}
@@ -490,7 +492,7 @@ bool MinigameManager::quant(float dt) {
timeManager_->quant(dt);
if (complete_help_miniature_) {
- xassert(complete_help_);
+ assert(complete_help_);
if (complete_help_miniature_.hit(mousePos_))
complete_help_.setState(complete_help_state_name_.c_str());
else
@@ -549,7 +551,7 @@ bool MinigameManager::quant(float dt) {
}
void MinigameManager::setCompleteHelpVariant(int idx) {
- xassert(idx >= 0);
+ assert(idx >= 0);
char buf[32];
buf[31] = 0;
_snprintf(buf, 31, "%02d", idx + 1);
@@ -595,7 +597,7 @@ bool MinigameManager::testAllGamesWin() {
unsigned char ch;
xbuf > ch;
if (ch != ':') {
- xxassert(ch != ':', (XBuffer() < "ÐепÑавилÑнÑй ÑоÑÐ¼Ð°Ñ Ñайла \"" < gameListFileName() < "\"").c_str());
+ warning("MinigameManager::testAllGamesWin(): incorrect file format: '%s'", gameListFileName());
return false;
}
while (xbuf.tell() < xbuf.size()) {
@@ -615,13 +617,13 @@ bool MinigameManager::testAllGamesWin() {
}
void MinigameManager::gameWin() {
- dprintf("Game Win\n");
+ debugC(2, kDebugMinigames, "MinigameManager::gameWin(): Game Win");
state_flag_->set_state("win");
if (debugMode() || !currentGameInfo_)
return;
- xassert(currentGameIndex_.gameNum_ >= 0);
+ assert(currentGameIndex_.gameNum_ >= 0);
effectManager_->start(EFFECT_1);
@@ -636,19 +638,19 @@ void MinigameManager::gameWin() {
if (currentGameInfo_->game_.sequenceIndex_ >= 0) { // ÑÑо пеÑеигÑовка
if (eventManager_->score() > currentGameInfo_->game_.bestScore_) {
- dprintf("ÑÑÑановлен новÑй ÑекоÑд оÑков.\n");
+ debugC(2, kDebugMinigames, "MinigameManager::gameWin(): new high score");
currentGameInfo_->game_.bestScore_ = eventManager_->score();
currentGameInfo_->game_.bestTime_ = gameTime;
}
} else {
- dprintf("добавлÑем оÑки к ÑÑмме пÑоÑ
ождениÑ: %d\n", eventManager_->score());
+ debugC(2, kDebugMinigames, "MinigameManager::gameWin(): adding score to the sum: %d", eventManager_->score());
currentGameInfo_->game_.sequenceIndex_ = completeCounters_[currentGameIndex_.gameLevel_];
currentGameInfo_->game_.bestScore_ = eventManager_->score();
currentGameInfo_->game_.bestTime_ = gameTime;
if (QDCounter all_score = getCounter("all_score")) {
all_score->add_value(eventManager_->score());
if (testAllGamesWin()) {
- dprintf("ÐÑе игÑÑ Ð¿ÑойденÑ, добавлена запиÑÑ Ð² ÑаблиÑÑ ÑекоÑдов: %d\n", all_score->value());
+ debugC(2, kDebugMinigames, "MinigameManager::gameWin(): All games are won, adding record to the score table: %d", all_score->value());
engine_->add_hall_of_fame_entry(all_score->value());
}
release(all_score);
@@ -663,21 +665,31 @@ void MinigameManager::gameWin() {
}
void MinigameManager::gameLose() {
- dprintf("Game Lose\n");
+ debugC(2, kDebugMinigames, "MinigameManager: Game Lose");
state_flag_->set_state("lose");
}
const char *MinigameManager::parameter(const char* name, bool required) const {
- xxassert(scene_, "СÑена не опÑеделена");
+ if (!scene_)
+ error("MinigameManager::parameter(): Scene is undefined");
+
const char *txt = scene_->minigame_parameter(name);
- xxassert(!required || txt, (XBuffer() < "Ðе задан обÑзаÑелÑнÑй паÑамеÑÑ [" < name < "] в ini Ñайле").c_str());
+
+ if (required && !txt)
+ warning("MinigameManager::parameter(): Required parameter '%s' is missing in the ini file", transCyrillic(name));
+
return txt;
}
-const char *MinigameManager::parameter(const char* name, const char* def) const {
- xxassert(def, (XBuffer() < "Ðе задано знаÑение по ÑмолÑÐ°Ð½Ð¸Ñ Ð´Ð»Ñ Ð¿Ð°ÑамеÑÑа [" < name < "]").c_str());
+const char *MinigameManager::parameter(const char *name, const char *def) const {
+ if (!def)
+ warning("MinigameManager::parameter(): Default value for parameter '%s' is missing", transCyrillic(name));
+
const char *txt = scene_->minigame_parameter(name);
- xxassert(def || txt, (XBuffer() < "Ðе задан обÑзаÑелÑнÑй паÑамеÑÑ [" < name < "] в ini Ñайле").c_str());
+
+ if (!required && !txt)
+ warning("MinigameManager::parameter(): Required parameter '%s' is missing in the ini file", transCyrillic(name));
+
return txt ? txt : (def ? def : "");
}
@@ -696,7 +708,7 @@ bool MinigameManager::mouseRightPressed() const {
}
bool MinigameManager::keyPressed(int vKey, bool once) const {
- xassert(vKey >= 0 && vKey <= 255);
+ assert(vKey >= 0 && vKey <= 255);
if (engine_->is_key_pressed(vKey)) {
if (once && lastKeyChecked_[vKey])
return false;
@@ -752,12 +764,16 @@ float MinigameManager::getDepth(const mgVect3f& pos) const {
return scene_->screen_depth(pos);
}
-QDObject MinigameManager::getObject(const char* name) const {
- xxassert(name && *name, "ÐÑлевое Ð¸Ð¼Ñ Ð´Ð»Ñ Ð¿Ð¾Ð»ÑÑение обÑекÑа");
+QDObject MinigameManager::getObject(const char *name) const {
+ if (!name || !*name)
+ warning("MinigameManager::getObject(): null name");
+
if (!name || !*name)
return QDObject::ZERO;
qdMinigameObjectInterface* obj = scene_->object_interface(name);
- xxassert(obj, (XBuffer() < "Ðе найден обÑекÑ: \"" < name < "\"").c_str());
+ if (!obj)
+ warning("MinigameManager::getObject(): Object '%s' not found", transCyrillic(name));
+
if (obj)
return QDObject(obj, name);
return QDObject::ZERO;
@@ -780,12 +796,17 @@ void MinigameManager::release(QDObject& obj) {
QDCounter MinigameManager::getCounter(const char* name) {
qdMinigameCounterInterface* counter = engine_->counter_interface(name);
- xxassert(counter, (XBuffer() < "Ðе найден ÑÑеÑÑик: \"" < name < "\"").c_str());
+
+ if (!counter)
+ warning("MinigameManager::getCounter(): Counter '%s' not found", transCyrillic(name));
+
return counter;
}
void MinigameManager::release(QDCounter& counter) {
- xxassert(counter, "ÐеÑедан нÑлевой ÑÑеÑÑик Ð´Ð»Ñ Ð¾ÑвобождениÑ");
+ if (!counter)
+ warning("MinigameManager::release(): Null counter");
+
engine_->release_counter_interface(counter);
counter = 0;
}
@@ -823,13 +844,14 @@ int MinigameManager::rnd(const vector<float> &prob) const {
if (rnd <= accum)
break;
}
- xassert(idx >= 0 && idx < prob.size());
+ assert(idx >= 0 && idx < prob.size());
#ifdef _DEBUG
float sum = 0.f;
- vector<float>::const_iterator pit;
- FOR_EACH(prob, pit)
- sum += *pit;
- xassert(abs(sum - 1.f) < 0.0001f);
+
+ for (auto &ptr : prob)
+ sum += pit;
+
+ assert(abs(sum - 1.f) < 0.0001f);
#endif
return idx;
}
@@ -844,10 +866,12 @@ bool MinigameManager::processGameData(XBuffer& data) {
if (currentGameInfo_) {
if (currentGameInfo_->empty_) {
currentGameInfo_->empty_ = false;
- xassert(data.tell());
+ assert(data.tell());
currentGameInfo_->write(data.buffer(), data.tell());
} else {
- xxassert(data.tell() == currentGameInfo_->dataSize_, (XBuffer() < "СилÑно ÑÑÑаÑевÑее ÑоÑ
Ñанение ÑоÑÑоÑÐ½Ð¸Ñ Ð¼Ð¸Ð½Ð¸Ð¸Ð³ÑÑ. УдалиÑе " < state_container_name_).c_str());
+ if (data.tell() != currentGameInfo_->dataSize_)
+ warning("MinigameManager::processGameData(): Old minigame save detected. Remove '%s'", state_container_name_);
+
if (data.tell() == currentGameInfo_->dataSize_) {
data.set(0);
data.write(currentGameInfo_->gameData_, currentGameInfo_->dataSize_, true);
@@ -877,8 +901,8 @@ GameInfo::GameInfo() {
void GameInfo::free() {
if (gameData_) {
- xassert(dataSize_ > 0);
- //dprintf("memory free: %#x\n", gameData_);
+ assert(dataSize_ > 0);
+
::free(gameData_);
gameData_ = 0;
}
@@ -891,7 +915,6 @@ void GameInfo::write(void* data, unsigned int size) {
if (size > 0) {
gameData_ = malloc(size);
dataSize_ = size;
- //dprintf("memory alloc: %#x, %d bytes\n", gameData_, size);
}
}
if (dataSize_ > 0)
@@ -959,7 +982,7 @@ TimeManager::TimeManager(HoldData<TimeManagerData> &data) {
if (const char * data = runtime->parameter("time_bar_direction")) {
int dir;
if (sscanf(data, "%d", &dir) == 1) {
- xassert(dir >= 0 && dir <= 3);
+ assert(dir >= 0 && dir <= 3);
direction_ = Direction(dir);
} else
direction_ = DOWN;
@@ -968,7 +991,7 @@ TimeManager::TimeManager(HoldData<TimeManagerData> &data) {
} else
size_ = mgVect2f(-1.f, -1.f);
- xassert(runtime->getTime() == 0.f);
+ assert(runtime->getTime() == 0.f);
lastEventTime_ = 0;
Commit: bac83e11415a72cf95cba50eef65963c25e6a3b5
https://github.com/scummvm/scummvm/commit/bac83e11415a72cf95cba50eef65963c25e6a3b5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-10-19T00:04:44+02:00
Commit Message:
QDENGINE: Added minigames/adv/RunTime.cpp to the project`
Changed paths:
engines/qdengine/minigames/adv/RunTime.cpp
engines/qdengine/minigames/adv/RunTime.h
engines/qdengine/module.mk
diff --git a/engines/qdengine/minigames/adv/RunTime.cpp b/engines/qdengine/minigames/adv/RunTime.cpp
index bff8941b4b9..5016e7c5548 100644
--- a/engines/qdengine/minigames/adv/RunTime.cpp
+++ b/engines/qdengine/minigames/adv/RunTime.cpp
@@ -19,6 +19,9 @@
*
*/
+#include "common/debug.h"
+
+#include "qdengine/qdengine.h"
#include "qdengine/minigames/adv/common.h"
#include "qdengine/minigames/adv/qdMath.h"
#include "qdengine/minigames/adv/RunTime.h"
@@ -98,9 +101,9 @@ MinigameManager::MinigameManager()
MinigameManager::~MinigameManager() {
assert(!engine_ && !scene_);
- for (auto &it : (gameInfos_, it) {
- debugC(5, kDebugMinigames, "~MinigameManager(): free: (%d,%d)", it->first.gameLevel_, it->first.gameNum_);
- it.second.free();
+ for (auto &it : gameInfos_) {
+ debugC(5, kDebugMinigames, "~MinigameManager(): free: (%d,%d)", it._key.gameLevel_, it._key.gameNum_);
+ it._value.free();
}
}
@@ -179,7 +182,7 @@ bool MinigameManager::createGame() {
const char *stateFlagName = parameter("state_flag_name", "state_flag");
- if (state_flag_ = scene_->object_interface(stateFlagName)) {
+ if ((state_flag_ = scene_->object_interface(stateFlagName))) {
if (!state_flag_->has_state("game") || !state_flag_->has_state("win") || !state_flag_->has_state("lose")) {
warning("MinigameManager::createGame(): The object %s must have state: game, win, lose", transCyrillic(stateFlagName));
return false;
@@ -191,7 +194,7 @@ bool MinigameManager::createGame() {
const char *pauseFlagName = parameter("pause_flag_name", "BackHelp");
- if (pause_flag_ = scene_->object_interface(pauseFlagName)) {
+ if ((pause_flag_ = scene_->object_interface(pauseFlagName))) {
if (!pause_flag_->has_state("on")) {
warning("MinigameManager::createGame(): The object %s must have state: on", transCyrillic(pauseFlagName));
return false;
@@ -202,7 +205,7 @@ bool MinigameManager::createGame() {
if (testObject(parameter("complete_help_miniatute", "miniature"))) {
complete_help_miniature_ = getObject(parameter("complete_help_miniatute", "miniature"));
- if (complete_help_ = getObject(parameter("complete_help", "complete"))) {
+ if ((complete_help_ = getObject(parameter("complete_help", "complete")))) {
if (!complete_help_->has_state("off") || !complete_help_->has_state("01")) {
warning("MinigameManager::createGame(): The object for completed game must have state: off, 01");
return false;
@@ -224,7 +227,9 @@ bool MinigameManager::createGame() {
game_help_trigger_.setState(game_help_enabled_ ? "01" : "02");
}
- game_ = ::createGame();
+ warning("STUB: MinigameManager::createGame()");
+ // Here we instantiate the specific game
+ //game_ = ::createGame();
if (currentGameInfo_)
currentGameInfo_->empty_ = false;
@@ -311,8 +316,8 @@ bool MinigameManager::new_game(const qdEngineInterface* engine_interface) {
debugC(2, kDebugMinigames, "MinigameManager::new_game(): new game");
for (auto &it : gameInfos_) {
- debugC(3, kDebugMinigames, "MinigameManager::new_game(): clean game data (%d, %d)", it->first.gameLevel_, it->first.gameNum_);
- it.second.game_ = MinigameData();
+ debugC(3, kDebugMinigames, "MinigameManager::new_game(): clean game data (%d, %d)", it._key.gameLevel_, it._key.gameNum_);
+ it._value.game_ = MinigameData();
}
saveState(true);
@@ -352,10 +357,14 @@ int MinigameManager::save_game(const qdEngineInterface* engine, const qdMinigame
loadState();
if (currentGameInfo_ && !currentGameInfo_->empty()) {
debugC(2, kDebugMinigames, "MinigameManager::save_game(): save game (%d, %d)", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_);
+
+ warning("STUB: MinigameManager::save_game()");
+#if 0
XBuffer out((void*)buffer, buffer_size);
out.write(GameInfo::version());
out.write(currentGameInfo_->game_);
return out.tell();
+#endif
}
return 0;
@@ -370,6 +379,10 @@ int MinigameManager::load_game(const qdEngineInterface* engine, const qdMinigame
debugC(2, kDebugMinigames, "MinigameManager::load_game(): load game");
TEMP_SCENE_ENTER();
loadState();
+
+ warning("STUB: MinigameManager::load_game()");
+
+#if 0
if (currentGameInfo_) {
if (buffer_size > 0) {
debugC(2, kDebugMinigames, "MinigameManager::load_game(): load game (%d, %d)", currentGameIndex_.gameLevel_, currentGameIndex_.gameNum_);
@@ -396,6 +409,7 @@ int MinigameManager::load_game(const qdEngineInterface* engine, const qdMinigame
}
saveState();
}
+#endif
return buffer_size;
}
@@ -416,6 +430,8 @@ bool MinigameManager::loadState(bool current) {
} else
currentGameIndex_ = GameInfoIndex(-1, -1);
+ warning("STUB: MinigameManager::loadState()");
+#if 0
if (!current || currentGameIndex_.gameNum_ >= 0) {
if (current)
@@ -449,30 +465,35 @@ bool MinigameManager::loadState(bool current) {
currentGameInfo_ = current ? &gameInfos_[currentGameIndex_] : 0;
}
+#endif
return true;
}
extern bool createDirForFile(const char* partialPath);
void MinigameManager::saveState(bool force) {
debugC(2, kDebugMinigames, "MinigameManager::save_state(): save state");
+
+ warning("STUB: MinigameManager::saveState()");
+
+#if 0
if (force || currentGameIndex_.gameNum_ >= 0) {
XStream file(false);
if (createDirForFile(state_container_name_) && file.open(state_container_name_, XS_OUT)) {
file < GameInfo::version();
file < (engine_ ? engine_->rnd(999999) : seed_);
- GameInfoMap::const_iterator it;
for (auto &it: gameInfos_) {
- if (!it.second.empty()) {
- debugC(2, kDebugMinigames, "MinigameManager::save_state(): write game info: (%d,%d), index: %d, game data:%d", it.first.gameLevel_, it.first.gameNum_, it.second.game_.sequenceIndex_, it.second.empty_ ? 0 : 1);
- file.write(it->first);
- file < it->second;
+ if (!it._value.empty()) {
+ debugC(2, kDebugMinigames, "MinigameManager::save_state(): write game info: (%d,%d), index: %d, game data: %d", it._key.gameLevel_, it._key.gameNum_, it._value.game_.sequenceIndex_, it._value.empty_ ? 0 : 1);
+ file.write(it._key);
+ file < it._value;
}
}
} else {
warning("MinigameManager::saveState(): Failed to save file '%s'", state_container_name_);
}
}
+#endif
}
bool MinigameManager::quant(float dt) {
@@ -534,6 +555,9 @@ bool MinigameManager::quant(float dt) {
signal(EVENT_GAME_WIN);
gameWin();
break;
+
+ default:
+ break;
}
}
@@ -554,7 +578,7 @@ void MinigameManager::setCompleteHelpVariant(int idx) {
assert(idx >= 0);
char buf[32];
buf[31] = 0;
- _snprintf(buf, 31, "%02d", idx + 1);
+ snprintf(buf, 31, "%02d", idx + 1);
complete_help_state_name_ = buf;
}
@@ -562,7 +586,7 @@ void MinigameManager::setGameHelpVariant(int idx) {
if (idx >= 0) {
char buf[32];
buf[31] = 0;
- _snprintf(buf, 31, "%02d", idx + 1);
+ snprintf(buf, 31, "%02d", idx + 1);
game_help_state_name_ = buf;
} else
game_help_state_name_ = "off";
@@ -579,11 +603,14 @@ void MinigameManager::signal(SystemEvent id) {
const MinigameData *MinigameManager::getScore(int level, int game) const {
GameInfoMap::const_iterator it = gameInfos_.find(GameInfoIndex(game, level));
if (it != gameInfos_.end())
- return &it->second.game_;
+ return &it->_value.game_;
return 0;
}
bool MinigameManager::testAllGamesWin() {
+ warning("STUB: MinigameManager::testAllGamesWin()");
+
+#if 0
XStream file(false);
if (!file.open(gameListFileName(), XS_IN))
return false;
@@ -602,7 +629,7 @@ bool MinigameManager::testAllGamesWin() {
}
while (xbuf.tell() < xbuf.size()) {
xbuf > ch;
- if (isdigit(ch)) {
+ if (Common::isDigit(ch)) {
--xbuf;
int game;
xbuf >= game;
@@ -612,6 +639,7 @@ bool MinigameManager::testAllGamesWin() {
}
}
}
+#endif
return true;
}
@@ -687,7 +715,7 @@ const char *MinigameManager::parameter(const char *name, const char *def) const
const char *txt = scene_->minigame_parameter(name);
- if (!required && !txt)
+ if (!def && !txt)
warning("MinigameManager::parameter(): Required parameter '%s' is missing in the ini file", transCyrillic(name));
return txt ? txt : (def ? def : "");
@@ -818,7 +846,7 @@ void MinigameManager::setText(const char* name, const char* text) const {
void MinigameManager::setText(const char* name, int toText, const char* format) const {
char text[16];
text[15] = 0;
- _snprintf(text, 15, format, toText);
+ snprintf(text, 15, format, toText);
setText(name, text);
}
@@ -834,7 +862,7 @@ int MinigameManager::rnd(int min, int max) const {
return min + round(engine_->fabs_rnd(max - min));
}
-int MinigameManager::rnd(const vector<float> &prob) const {
+int MinigameManager::rnd(const Std::vector<float> &prob) const {
float rnd = runtime->rnd(0.f, .9999f);
float accum = 0.f;
int idx = 0;
@@ -862,7 +890,9 @@ int MinigameManager::rnd(const vector<float> &prob) const {
// еÑли даннÑе еÑе ни ÑÐ°Ð·Ñ Ð½Ðµ ÑоÑ
ÑанÑлиÑÑ - запоминаем
// еÑли Ñже еÑÑÑ Ð·Ð°Ð¿Ð¾Ð¼Ð½ÐµÐ½Ð½Ñе, Ñо заменÑем на ниÑ
-bool MinigameManager::processGameData(XBuffer& data) {
+bool MinigameManager::processGameData(Common::MemoryWriteStream& data) {
+ warning("STUB: MinigameManager::processGameData()");
+#if 0
if (currentGameInfo_) {
if (currentGameInfo_->empty_) {
currentGameInfo_->empty_ = false;
@@ -882,6 +912,7 @@ bool MinigameManager::processGameData(XBuffer& data) {
}
}
data.set(0);
+#endif
return true;
}
@@ -921,6 +952,7 @@ void GameInfo::write(void* data, unsigned int size) {
memcpy(gameData_, data, dataSize_);
}
+#if 0
XStream &operator< (XStream& out, const GameInfo& info) {
out.write(info.game_);
out.write(info.empty_);
@@ -948,13 +980,13 @@ XStream &operator> (XStream& in, GameInfo& info) {
}
return in;
}
-
+#endif
//========================================================================================================================
-TimeManager::TimeManager(HoldData<TimeManagerData> &data) {
- if (const char * data = runtime->parameter("game_time", false)) {
+TimeManager::TimeManager(HoldData<TimeManagerData> &data_) {
+ if (const char *data = runtime->parameter("game_time", false)) {
if (sscanf(data, "%f", &gameTime_) != 1)
gameTime_ = -1.f;
} else
@@ -963,7 +995,7 @@ TimeManager::TimeManager(HoldData<TimeManagerData> &data) {
timeCost_ = 0.f;
if (gameTime_ > 0) {
- if (const char * data = runtime->parameter("time_bar"))
+ if (const char *data = runtime->parameter("time_bar"))
timeBar_ = runtime->getObject(data);
if (const char * data = runtime->parameter("time_cost"))
@@ -974,12 +1006,12 @@ TimeManager::TimeManager(HoldData<TimeManagerData> &data) {
TimeManagerData myData;
myData.crd = runtime->world2game(timeBar_);
- data.process(myData);
+ data_.process(myData);
startPos_ = myData.crd;
size_ = runtime->getSize(timeBar_);
- if (const char * data = runtime->parameter("time_bar_direction")) {
+ if (const char *data = runtime->parameter("time_bar_direction")) {
int dir;
if (sscanf(data, "%d", &dir) == 1) {
assert(dir >= 0 && dir <= 3);
diff --git a/engines/qdengine/minigames/adv/RunTime.h b/engines/qdengine/minigames/adv/RunTime.h
index ce60fd6da60..44ccff4515d 100644
--- a/engines/qdengine/minigames/adv/RunTime.h
+++ b/engines/qdengine/minigames/adv/RunTime.h
@@ -75,10 +75,6 @@ struct GameInfo {
void *gameData_;
};
-class XStream;
-XStream &operator< (XStream& out, const GameInfo& info);
-XStream &operator> (XStream& in, GameInfo& info);
-
class MinigameManager : public qdMiniGameInterface {
friend class TempValue;
public:
diff --git a/engines/qdengine/module.mk b/engines/qdengine/module.mk
index 735fe580422..285f9bb5e14 100644
--- a/engines/qdengine/module.mk
+++ b/engines/qdengine/module.mk
@@ -11,6 +11,7 @@ MODULE_OBJS = \
minigames/adv/FlyObject.o \
minigames/adv/ObjectContainer.o \
minigames/adv/Range.o \
+ minigames/adv/RunTime.o \
minigames/adv/TextManager.o \
parser/qdscr_parser.o \
parser/xml_parser.o \
More information about the Scummvm-git-logs
mailing list