diff --git a/src/clock/mumeclock.cpp b/src/clock/mumeclock.cpp index e04b1ab4..0cff01f5 100644 --- a/src/clock/mumeclock.cpp +++ b/src/clock/mumeclock.cpp @@ -411,8 +411,7 @@ MumeClock::DawnDusk MumeClock::getDawnDusk(const int month) return DawnDusk{s_dawnHour.at(m), s_duskHour.at(m)}; } - -const int MumeClock::getMumeMonth(const QString& monthName) +int MumeClock::getMumeMonth(const QString &monthName) { const int month = s_westronMonthNames.keyToValue(monthName.toLatin1().data()); if (month == static_cast(WestronMonthNamesEnum::UnknownWestronMonth)) { diff --git a/src/clock/mumeclock.h b/src/clock/mumeclock.h index 95c213d8..cc6ee841 100644 --- a/src/clock/mumeclock.h +++ b/src/clock/mumeclock.h @@ -140,7 +140,7 @@ public slots: void setPrecision(const MumeClockPrecisionEnum state); void setLastSyncEpoch(int64_t epoch) { m_lastSyncEpoch = epoch; } - const int getMumeMonth(const QString &monthName); + int getMumeMonth(const QString &monthName); protected: void parseMumeTime(const QString &mumeTime, int64_t secsSinceEpoch); diff --git a/src/proxy/AbstractTelnet.cpp b/src/proxy/AbstractTelnet.cpp index 3dc1af73..8bc17cbd 100644 --- a/src/proxy/AbstractTelnet.cpp +++ b/src/proxy/AbstractTelnet.cpp @@ -717,7 +717,6 @@ void AbstractTelnet::processTelnetSubnegotiation(const AppendBuffer &payload) qDebug() << "Received MSSP message" << payload; receiveMudServerStatus(payload); - } break; diff --git a/src/proxy/MudTelnet.cpp b/src/proxy/MudTelnet.cpp index 413d524f..794a3f7b 100644 --- a/src/proxy/MudTelnet.cpp +++ b/src/proxy/MudTelnet.cpp @@ -301,5 +301,4 @@ void MudTelnet::parseMudServerStatus(const QByteArray &data) } catch (const std::exception &) { } // ? - } diff --git a/src/proxy/MudTelnet.h b/src/proxy/MudTelnet.h index 5074470e..e3d9f513 100644 --- a/src/proxy/MudTelnet.h +++ b/src/proxy/MudTelnet.h @@ -35,9 +35,9 @@ public slots: void sig_relayGmcp(const GmcpMessage &); void sig_sendMSSPToUser(const QByteArray &); void sig_sendGameTimeToClock(const int year, - const std::string &month, - const int day, - const int hour); + const std::string &month, + const int day, + const int hour); private: void virt_sendToMapper(const QByteArray &data, bool goAhead) final; diff --git a/src/proxy/proxy.cpp b/src/proxy/proxy.cpp index 6bd2fd73..14c036c0 100644 --- a/src/proxy/proxy.cpp +++ b/src/proxy/proxy.cpp @@ -164,7 +164,8 @@ void Proxy::slot_start() connect(mudTelnet, &MudTelnet::sig_sendToSocket, this, &Proxy::slot_onSendToMudSocket); connect(mudTelnet, &MudTelnet::sig_relayEchoMode, userTelnet, &UserTelnet::slot_onRelayEchoMode); connect(mudTelnet, &MudTelnet::sig_relayGmcp, userTelnet, &UserTelnet::slot_onGmcpToUser); - connect(mudTelnet, &MudTelnet::sig_sendGameTimeToClock, + connect(mudTelnet, + &MudTelnet::sig_sendGameTimeToClock, this, &Proxy::slot_onSendGameTimeToClock); connect(mudTelnet, @@ -575,13 +576,12 @@ bool Proxy::isGmcpModuleEnabled(const GmcpModuleTypeEnum &module) const } void Proxy::slot_onSendGameTimeToClock(const int year, - const std::string &monthStr, - const int day, - const int hour) + const std::string &monthStr, + const int day, + const int hour) { const int month = m_mumeClock.getMumeMonth(::toQStringLatin1(monthStr)); MumeMoment moment(year, month, day, hour, 0); QString mumeTime = m_mumeClock.toMumeTime(moment); m_mumeClock.parseMumeTime(mumeTime); - } diff --git a/tests/testclock.cpp b/tests/testclock.cpp index 79088a19..277f5a10 100644 --- a/tests/testclock.cpp +++ b/tests/testclock.cpp @@ -111,6 +111,60 @@ void TestClock::parseMumeTimeTest() QCOMPARE(clock.toMumeTime(clock.getMumeMoment()), expected6); } +void TestClock::getMumeMonthTest() +{ + GameObserver observer; + MumeClock clock(observer); + + int month0 = clock.getMumeMonth("Narwain"); + int expected0 = 0; + QCOMPARE(month0, expected0); + + int month1 = clock.getMumeMonth("Solmath"); + int expected1 = 1; + QCOMPARE(month1, expected1); + + int month2 = clock.getMumeMonth("Gwaeron"); + int expected2 = 2; + QCOMPARE(month2, expected2); + + int month3 = clock.getMumeMonth("Astron"); + int expected3 = 3; + QCOMPARE(month3, expected3); + + int month4 = clock.getMumeMonth("Lothron"); + int expected4 = 4; + QCOMPARE(month4, expected4); + + int month5 = clock.getMumeMonth("Forelithe"); + int expected5 = 5; + QCOMPARE(month5, expected5); + + int month6 = clock.getMumeMonth("Cerveth"); + int expected6 = 6; + QCOMPARE(month6, expected6); + + int month7 = clock.getMumeMonth("Wedmath"); + int expected7 = 7; + QCOMPARE(month7, expected7); + + int month8 = clock.getMumeMonth("Ivanneth"); + int expected8 = 8; + QCOMPARE(month8, expected8); + + int month9 = clock.getMumeMonth("Winterfilth"); + int expected9 = 9; + QCOMPARE(month9, expected9); + + int month10 = clock.getMumeMonth("Hithui"); + int expected10 = 10; + QCOMPARE(month10, expected10); + + int month11 = clock.getMumeMonth("Foreyule"); + int expected11 = 11; + QCOMPARE(month11, expected11); +} + void TestClock::parseWeatherClockSkewTest() { GameObserver observer; diff --git a/tests/testclock.h b/tests/testclock.h index 733bbfef..a6da82ed 100644 --- a/tests/testclock.h +++ b/tests/testclock.h @@ -16,6 +16,7 @@ private Q_SLOTS: // MumeClock void mumeClockTest(); void parseMumeTimeTest(); + void getMumeMonthTest(); void parseWeatherTest(); void parseWeatherClockSkewTest(); void parseClockTimeTest();