Jump to content

You're browsing the 2004-2023 VATSIM Forums archive. All content is preserved in a read-only fashion.
For the latest forum posts, please visit https://forum.vatsim.net.

Need to find something? Use the Google search below.

AmendFlightPlan() kicks out of network after a few minutes


Ricardo Sousa
 Share

Recommended Posts

Ricardo Sousa
Posted
Posted

I am updating the fpl remarks with GetFlightPlanData().SetRemarks() followed by GetFlightPlanData().AmendFlightPlan(), and this works fine for a couple of minutes but then kicks me out of the networks, both with 50 aircraft or just 1 aircraft, live or sweatbox server, whats going on? If I don't call AmendFlightPlan() I don't get kicked, but the fpl doesn't seem to register it was updated either, so what am I supposed to do here?

Link to comment
Share on other sites

Jonas Kuster
Posted
Posted

So you are saying the flight plan is effectively not amended at all? Then I would suspect an issue with the instance of the flight plan data object you are using, maybe a use or reference outside the block you are querying?

I don't know about a general issue in this regard otherwise.

What version of ES are you using?

Jonas Kuster
Network Supervisor
Leader Operation vACC Switzerland | vacc.ch @vaccswitzerland
GNG Support Team | gng.aero-nav.com
ES Plugin Developer | CCAMS

Link to comment
Share on other sites

Ricardo Sousa
Posted
Posted

This is on beta 25

Without calling AmendFlightPlan() this happens, notice the DOF/ in the flightstrip and the one in the flight plan window

image.png.e39ba33e4f26f7179f2ecc3ff343a8e7.png

 

If I call AmendFlightPlan() then it gets updated but kicks me out a few minutes later.

 

It's all being done in the same block, to my knowledge at least. This is called on OnGetTagItem():

void ACDMPlugin::CheckEtd(CFlightPlan FlightPlan)
{

    const std::regex dof_regex("DOF\\/\\d\\d\\d\\d\\d\\d");
    

    std::string cs = FlightPlan.GetCallsign();    
    std::string rmk = FlightPlan.GetFlightPlanData().GetRemarks();
    
    std::string sDof = "DOF/990101";
    std::string dofY;
    std::string dofM;
    std::string dofD;

    time_t now = time(0);

    struct tm* tmEtd = gmtime(&now);

    std::string etd = FlightPlan.GetFlightPlanData().GetEstimatedDepartureTime();
    etd = std::string(4 - etd.length(), '0') + etd;

    std::string sEtdH = etd.substr(0, 2);
    std::string sEtdM = etd.substr(2);

    tmEtd->tm_hour = std::stoi(sEtdH);
    tmEtd->tm_min = std::stoi(sEtdM);

    int dofPos = 0;
    std::smatch base_match;

    if (std::regex_search(rmk, base_match, dof_regex)) {
       dofPos = base_match.position(0);
       sDof = base_match[0].str();
    }


    dofY = sDof.substr(4, 2);
    dofM = sDof.substr(6, 2);
    dofD = sDof.substr(8, 2);

    tmEtd->tm_year = std::stoi("20" + dofY) - 1900;
    tmEtd->tm_mon = std::stoi(dofM) - 1;
    tmEtd->tm_mday = std::stoi(dofD);


    time_t ttEtd = mktime(tmEtd);

    time_t etdP = ttEtd + 1800;
    time_t etdM = ttEtd - 1800;

    if (now <= etdM || now >= etdP) {
        now += 1800;
        struct tm* nowTm = gmtime(&now);

        std::string delayH = std::to_string(nowTm->tm_hour);
        std::string delayM = std::to_string(nowTm->tm_min);

        delayH = std::string(2 - delayH.length(), '0') + delayH;
        delayM = std::string(2 - delayM.length(), '0') + delayM;

        std::string newDofY = std::to_string(nowTm->tm_year + 1900 - 2000);
        std::string newDofM = std::to_string(nowTm->tm_mon + 1);
        std::string newDofD = std::to_string(nowTm->tm_mday);

        newDofY = std::string(2 - newDofY.length(), '0') + newDofY;
        newDofM = std::string(2 - newDofM.length(), '0') + newDofM;
        newDofD = std::string(2 - newDofD.length(), '0') + newDofD;

        std::string newDof = "DOF/" + newDofY + newDofM + newDofD;

        std::string finalRmk = rmk.substr(0, dofPos) + newDof + rmk.substr((dofPos + 10));

        FlightPlan.GetFlightPlanData().SetEstimatedDepartureTime( (delayH + delayM).c_str() );
        FlightPlan.GetFlightPlanData().SetRemarks(finalRmk.c_str() );
        //FlightPlan.GetFlightPlanData().AmendFlightPlan();
    }
}

 

Link to comment
Share on other sites

  • 2 weeks later...
Jan Fries
Posted
Posted

Hi,

I haven't read too much into what exactly happens in your code, but it seems that AmendFlightPlan() is called every time the if criteria above are met. So potentially this would be called every second or so (how often GetTagItem() is called) thus flooding the server with "AmendFlightPlan". So I think what happens is that the Vatsim-Server is seeing an attack on their servers and thus kicking you out. You might want to add if (FlightPlan.GetFlightPlanData().IsAmended()) above the AmendFlightplan, since a flightplan can only be amended once anyway. So it only gets called once and it should work fine.

  • Like 1
Link to comment
Share on other sites

 Share