QTfrontend/net/hwmapoptimizer.cpp
author Wuzzy <Wuzzy2@mail.ru>
Sat, 06 Jun 2020 15:40:51 +0200
changeset 15597 6e72bd61002e
parent 14599 b86e6e4f3c58
permissions -rw-r--r--
Disable gfMoreWind for land objects on turn end only after a fixed-time delay 15s sounds much, but it's the average amount for gfMineStrike mines to settle naturally. And it would be very confusing to see falling mines suddenly not caring about gfMoreWind for no apparent reason. Note this whole thing is a giant hack anyway, to prevent a turn being blocked by infinitely bouncing mines. The better solution would be to help gfMoreWind-affected land objects settle naturally more reliably even under extreme wind. But this commit is "good enough" for now. If you don't like the delay, you can always tweak the constant.

#include "hwmapoptimizer.h"
#include "hwconsts.h"

HWMapOptimizer::HWMapOptimizer(QObject *parent) :
    TCPBase(false, false, parent)
{
}

bool HWMapOptimizer::couldBeRemoved()
{
    return !m_hasStarted;
}

void HWMapOptimizer::optimizeMap(const Paths &paths)
{
    m_paths = paths;

    Start(true);
}

QStringList HWMapOptimizer::getArguments()
{
    QStringList arguments;
    arguments << "--internal";
    arguments << "--port";
    arguments << QString("%1").arg(ipc_port);
    arguments << "--user-prefix";
    arguments << cfgdir->absolutePath();
    arguments << "--prefix";
    arguments << datadir->absolutePath();
    arguments << "--landpreview";
    return arguments;
}

void HWMapOptimizer::onClientDisconnect()
{

}

void HWMapOptimizer::SendToClientFirst()
{
    SendIPC("e$mapgen 4");

    /*QByteArray data = m_drawMapData;
    while(data.size() > 0)
    {
        QByteArray tmp = data;
        tmp.truncate(200);
        SendIPC("edraw " + tmp);
        data.remove(0, 200);
    }

    SendIPC("!");*/
}