# HG changeset patch # User unC0Rr # Date 1542890458 -3600 # Node ID 645e4591361f789e678e8a8d90dac1145b70504a # Parent 3152d9fdb499bef7b900a2e17c9a630dc13aca67 Send seed to engine to receive random map previews diff -r 3152d9fdb499 -r 645e4591361f qmlfrontend/game_config.cpp --- a/qmlfrontend/game_config.cpp Thu Nov 22 13:39:51 2018 +0100 +++ b/qmlfrontend/game_config.cpp Thu Nov 22 13:40:58 2018 +0100 @@ -1,6 +1,6 @@ #include "game_config.h" -GameConfig::GameConfig() : m_isPreview(true) { setPreview(m_isPreview); } +GameConfig::GameConfig() {} const char** GameConfig::argv() const { m_argv.resize(m_arguments.size()); @@ -53,25 +53,6 @@ cfgAppend("eammstore"); } -bool GameConfig::isPreview() const { return m_isPreview; } - -void GameConfig::setPreview(bool isPreview) { - m_isPreview = isPreview; - - m_arguments.clear(); - - if (m_isPreview) { - m_arguments << "" - << "--internal" - << "--landpreview"; - - } else { - m_arguments << "" - << "--internal" - << "--nomusic"; - } -} - void GameConfig::cfgAppend(const QByteArray& cmd) { Q_ASSERT(cmd.size() < 256); diff -r 3152d9fdb499 -r 645e4591361f qmlfrontend/game_config.h --- a/qmlfrontend/game_config.h Thu Nov 22 13:39:51 2018 +0100 +++ b/qmlfrontend/game_config.h Thu Nov 22 13:40:58 2018 +0100 @@ -20,15 +20,11 @@ void cmdMapgen(int mapgen); void cmdTeam(const Team& team); - bool isPreview() const; - void setPreview(bool isPreview); - private: mutable QVector m_argv; QList m_arguments; QList m_cfg; QList m_teams; - bool m_isPreview; void cfgAppend(const QByteArray& cmd); }; diff -r 3152d9fdb499 -r 645e4591361f qmlfrontend/hwengine.cpp --- a/qmlfrontend/hwengine.cpp Thu Nov 22 13:39:51 2018 +0100 +++ b/qmlfrontend/hwengine.cpp Thu Nov 22 13:40:58 2018 +0100 @@ -34,9 +34,10 @@ } void HWEngine::getPreview() { - m_seed = QUuid::createUuid().toByteArray(); - m_gameConfig.cmdSeed(m_seed); - m_gameConfig.setPreview(true); + emit previewIsRendering(); + + m_gameConfig = GameConfig(); + m_gameConfig.cmdSeed(QUuid::createUuid().toByteArray()); EngineInstance engine; engine.sendConfig(m_gameConfig); @@ -47,7 +48,8 @@ colorTable.resize(256); for (int i = 0; i < 256; ++i) colorTable[i] = qRgba(255, 255, 0, i); - QImage previewImage(preview.land, preview.width, preview.height, + QImage previewImage(preview.land, static_cast(preview.width), + static_cast(preview.height), QImage::Format_Indexed8); previewImage.setColorTable(colorTable); previewImage.detach(); @@ -59,7 +61,6 @@ } void HWEngine::runQuickGame() { - m_gameConfig.cmdSeed(m_seed); m_gameConfig.cmdTheme("Nature"); Team team1; team1.name = "team1"; @@ -68,7 +69,6 @@ team2.color = "7654321"; m_gameConfig.cmdTeam(team1); m_gameConfig.cmdTeam(team2); - m_gameConfig.setPreview(false); // m_runQueue->queue(m_gameConfig); } diff -r 3152d9fdb499 -r 645e4591361f qmlfrontend/hwengine.h --- a/qmlfrontend/hwengine.h Thu Nov 22 13:39:51 2018 +0100 +++ b/qmlfrontend/hwengine.h Thu Nov 22 13:40:58 2018 +0100 @@ -38,7 +38,6 @@ QQmlEngine* m_engine; PreviewImageProvider* m_previewProvider; GameConfig m_gameConfig; - QByteArray m_seed; int m_previewHedgehogsCount; }; diff -r 3152d9fdb499 -r 645e4591361f rust/hedgewars-engine-messages/src/parser.rs --- a/rust/hedgewars-engine-messages/src/parser.rs Thu Nov 22 13:39:51 2018 +0100 +++ b/rust/hedgewars-engine-messages/src/parser.rs Thu Nov 22 13:40:58 2018 +0100 @@ -69,7 +69,7 @@ named!(unordered_message<&[u8], UnorderedEngineMessage>, alt!( do_parse!(tag!("?") >> ( Ping )) - | do_parse!(tag!("!") >> ( Ping )) + | do_parse!(tag!("!") >> ( Pong )) | do_parse!(tag!("E") >> s: string_tail >> ( UnorderedEngineMessage::Error(s)) ) | do_parse!(tag!("W") >> s: string_tail >> ( Warning(s)) ) | do_parse!(tag!("s") >> s: string_tail >> ( ChatMessage(s)) ) @@ -81,6 +81,7 @@ named!(config_message<&[u8], ConfigEngineMessage>, alt!( do_parse!(tag!("C") >> (ConfigRequest)) + | do_parse!(tag!("eseed ") >> s: string_tail >> ( SetSeed(s)) ) )); named!(timestamped_message<&[u8], (SyncedEngineMessage, u16)>,