Показать сообщение отдельно
Старый 22-02-2023, 01:07   #3305
CrazyIvan
Bugcatcher
 
Аватар для CrazyIvan
 
Регистрация: Nov 2008
Адрес: Russia Kursk City
Сообщений: 1,017
Cool

Цитата:
Сообщение от CubanFoxtrot Посмотреть сообщение
Great. That was more or less what I had understood then from your previous message.
If I were in your shoes at this point, I'd try to rewrite the whole (exe, not nse) sensor's detect routine in C++ and put it in a DLL.
Takes tons of patience, but maybe it's the safest and most solid solution.
I mean being consistent just through binary patching in such a complex context, umh, I might be wrong, but sounds like a very complicated task to me!
Then try to isolate step by step the entity/sensor/etc. unmatcing input data and feed that reconstructed routine with a shared interface structure that is valid both for AI and player sources (you're gonna fill it before calling the dll code).
Also a common interface to apply the output/results would be needed, probably.
Easier said than done. But just my 2 cents.
Good luck and keep up the good work, as said earlier.

EDIT:
Found some veeery old and never completed notes. Certainly they'll be of no use given your actual understanding, but better sharing for sake of it.

Код:
void OsSensor::Detect(int dt)
{
    if (this->_unk_1c8_ == 0) {
        this->V18_NotifySensorEnabled(0, 1);
        return this->_unk_120_;
    }

    if (this->UpdateIntervalInMsecs_1d8 * 0.001f == 0.0f) {
        return this->_unk_120_;
    }

    this->UpdateAccumTime_1dc += 1;
    this->UpdateDeltaTime_1d4 = dt;

    KinematicData var_f8;
    this->entityObj_1bc->_unk_16c_.motion_28->V018_GetCrsState15cAtDeltaTime(dt, &var_f8, true);
    float var_A8 = this->entityObj_1bc->_unk_16c_.motion_28->V11c_GetOwnSpdAtDeltaTime(dt);

    OsSensor::MountPlatformMotionData var_c8{ var_f8, var_A8 };
    this->Update124FromPlatformMotion(&var_c8);

    if (!this->IsActivatedOrDeployed()) {
        return this->_unk_120_;
    }

    std::int8_t var_150 = INT8_C(0);
    if (this->mastData_1c4 != nullptr)
    {
        float mastDeployTime;
        const auto mastDeployState = this->mastData_1c4->V0c_GetDeployEventState(dt, &mastDeployTime);
        if (mastDeployState == 0) {
            if (mastDeployTime * 0.001f <= 0.0f)
                return this->_unk_120_;
        }
        else if (mastDeployState != 1) {
            return this->_unk_120_;
        }

        this->mastData_1c4->V18_UpdateSensorOffsetWithMastMotion(dt, &this->mountPlatformMotionData_124);
        this->_unk_148_ = GetAltitudeToAbsWorldUnits(this->mountPlatformMotionData_124.z); // ftol

        if (this->mastData_1c4->_unk_5c_) {
            return this->_unk_120_;
        }

        if ((this->flags_14 & DA_THERMALLAYER) && (this->mountPlatformMotionData_124.z < 0.0) && (var_c8.z < this->entityObj_1bc->unk_4a8->draft_0c))
        {
            var_150 = static_cast<std::int8_t>(pow((245.f - std::min(this->mastData_1c4->V10_GetDeployLength(dt), 245.f)) * 0.0040816325f, 2.f) * 30.f);
        }
    }


    if (this->nMinOperationAlt_c4 - 0.5f <= this->mountPlatformMotionData_124.z && this->nMaxOperationAlt_c0 + 0.5f >= this->mountPlatformMotionData_124.z) {        
        auto ent;
        if (this->hullID_1e8 != 0 && (ent = g_entityObjCache.find(this->hullID_1e8)) != nullptr) {
            const auto oldConeAngle1F4 = this->coneAngle_1f4;
            KinematicData var_124;
            ent->motion_194->GetCrsState20(&var_124, true);
            const auto v[2] = {
                var_124.x - this->mountPlatformMotionData_124.x,
                var_124.y - this->mountPlatformMotionData_124.y
            };
                this->UpdateConeAngle1F4AndMountPlatformMotionData124heading(CVector2::GetAngleInDeg(v[0], v[1]) , &var_c8);
                if (this->dbSensor->animPartName_8e[0] != '\0') {
                    const theta = fmod(var_c8.heading_14 + this->coneRotAxisZ_0d0 + 360.f, 360.f);
                    CAngle::Diff(theta, this->coneAngle_1f4) - CAngle::Diff(theta, oldConeAngle1F4);
                    msg->unk00 = 48; // type
                    msg->unk04 = 32; // size                   
                    msg->unk0c = this->entityObj_1bc->_unk_16c_._unk_00; // hullID
                    msg->unk10 = { 60 + this->sensorSlotNum_340, -1, -1, 0x00 }; //short4
                    msg->unk18 = dt;
                    msg->unk1c = 1000;
                    msg->unk20 = decimal_t(CAngle::Diff(var_c8.heading_14, oldConeAngle1F4) * DEG2RAD, 0.f);
                    msg->unk28 = decimal_t(CAngle::Diff(theta, this->coneAngle_1f4) - CAngle::Diff(theta, oldConeAngle1F4) * DEG2RAD, 0.f);
                    sub_62A630(msg, true);
                }
            // TODO
        }
        // TODO
    }

    return this->_unk_120_;
}
Yes, in fact it was difficult, but I almost managed. Now I think that the radar radiation angles should be properly taken into account for the receiving ESM sensor. The horizontal angle of radiation is tracked perfectly. But I had great difficulty with the azimuth angle - when you need to calculate the direction of the beam in the vertical direction.And cut off the signal, if ESM receiver sensor it is not in the emitter cone.


The vertical angle for active interception, was not a big problem. This was resolved very quickly.


I think I'll add a few degrees to the emitter cone, to each side, in the form of spurious emissions.
When the radar of the emitter still does not see the signal from the target platform, but the receiving side will see these stray emissions if the direction of the radar cones, is very close to the bearing to the player's platform.

PS: I'm afraid that this will be a completely different simulator than the simulator from Sonalysts. Since many cheats have been removed (for example, the unequal detection of AI platforms - when a player on his NB sonar sees the 1-st frequency of the target, and the target can only see the 3 - rd frequency of the player, which reduces detection by several times).
Many default scenarios, will simply not run as they did in the default version.


>> if (this->_unk_1c8_ == 0) {

What offset does this code start with? %-(

Your listing, is something unusual.
---------------------------
Along the way, I removed the bug with the contact age update timer. There was a bug where, for example, the radar emitter went beyond the radio-horizon, and the ESM autocommand stopped making marks on the ESM display. When the contact again popup the radio-horizon, the autocommand stopped marking this contact. The age of the contact on the DDI dispay at nav.map was not 0:00, but continued to increase (0:05 ; 0:06 ect) as if the contact was still invisible to the ESM sensor.
__________________
Only the dead have seen the end of the war.

Последний раз редактировалось CrazyIvan; 22-02-2023 в 23:07.
CrazyIvan вне форума   Ответить с цитированием