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_;
}