modify source code or edit one function (utils::computeStatF)



  • I'm not the author of the source code, but I need to edit one of the functions that makes the program's calculations. (in file utils.cpp)
    The function is called utils :: computestatF. contains old definitions or expressions.

    I want to replace the contents of the function (utils :: computestatf) with the newer multiple formulas.

    source Code: https://github.com/zmarek20/QtNFSWTuningCalculatorLatest

    tValueF utils::ComputeStatF(const tTierF& _Tier, const tValue& _Basis, const tPercent& _Percent)
    {
    	return ( BASE + _Tier * TIERSTEP - _Basis ) * _Percent / PSCALE + _Basis;
    

    These formulas insert into function utils::ComputeStatF
    Utils.cpp
    ...
    #define RATIOCENT 0,01
    #define RATIOFIRST 1
    #define TWOHALFTHREE 0,66666666666666666666666
    ...

    HandlingCent = HandlingPerformancePart*RATIOCENT

    AccelerationCent = AccelerationPerformancePart*RATIOCENT

    TopSpeedCent = TopSpeedPerformancePart*RATIOCENT

    Fragment = RATIOFIRST/(((HandlingCent+AccelerationCent+TopSpeedCent)*TWO HALFTHREE)+RATIOFIRST)

    HandlingFragment = Fragment*TopSpeedCent

    AccelerationFragment = Fragment*AccelerationCent

    TopSpeedFragment = Fragment*HandlingCent

    TopSpeedTotal2 = FLOOR((((RATIOFIRST-HandlingFragment)-AccelerationFragment)-TopSpeedFragment)topspeed+((t_hnd_t1HandlingFrag ment)+(t_acc_t2AccelerationFragment)+(t_tsp_t3To pSpeedFragment));1)

    AccelerationTotal2 = FLOOR((((RATIOFIRST-HandlingFragment)-AccelerationFragment)-TopSpeedFragment)acceleration+((a_hnd_a1Handling Fragment)+(a_acc_a2AccelerationFragment)+(a_tsp_a 3TopSpeedFragment));1)

    HandlingTotal2 = FLOOR((((RATIOFIRST-HandlingFragment)-AccelerationFragment)-TopSpeedFragment)handling+((h_hnd_h1HandlingFrag ment)+(h_acc_h2AccelerationFragment)+(h_tsp_h3To pSpeedFragment));1)

    0_1508065358271_bb45c092-f19b-468a-992f-33c3f0cb6de4-obrázok.png

    topspeed - stock (same CCAR::topspeed() )
    t/hnd/t1 - calculate attributes handling from performancepart
    t/acc/t2 - calculate attributes acceleration from performancepart
    t/tsp/t3 - calculate attributes topspeed from performancepart

    acceleration - stock (same CCAR::acceleration() )
    a/hnd/a1 - calculate attributes handling from performancepart
    a/acc/a2 - calculate attributes acceleration from performancepart
    a/tsp/a3 - calculate attributes topspeed from performancepart

    handling - stock (same CCAR::handling() )
    h/hnd/h1 - calculate attributes handling from performancepart
    h/acc/h2 - calculate attributes acceleration from performancepart
    h/tsp/h3 - calculate attributes topspeed from performancepart

    (Resource) GXR.car
    Brand = GXR
    Type = dragoniac
    Topspeed = 50
    Acceleration = 50
    Handling = 50
    Cost = 0
    ID = 0
    Acquirable = NO
    SpeedAPIBrand = GXR
    SpeedAPIType = dragoniac
    Reworked = 1

    example:
    add new lines:
    Brand = GXR
    Type = dragoniac
    Topspeed = 50
    t_hnd_t1 = 250
    t_acc_t2 = 350
    t_tsp_t3 = 375
    Acceleration = 50
    a_hnd_a1 = 260
    a_acc_a2 = 315
    a_tsp_a3 = 340
    Handling = 50
    h_hnd_h1 = 361
    h_acc_h2 = 411
    h_tsp_h3 = 432
    Cost = 0
    ID = 0
    Acquirable = NO
    SpeedAPIBrand = GXR
    SpeedAPIType = dragoniac
    Reworked = 1


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    So what exactly is your question ?



  • ok the function utils :: computeTopSpeed, utils :: computeAcceleration, utils :: computeHandling want parameters linked with pointers to the header CCar.h and CPart.h ,

    typedefinitions.h (typedef signed int tPercent;
    typedef unsigned char tLevel;
    typedef unsigned short tTier;
    typedef unsigned short tValue;
    typedef float tValueF;
    typedef float tPercentF;
    typedef float tTierF;
    typedef unsigned int tID;
    typedef unsigned int tIGC;)

    in Utils.h

    tValueF ComputeTopSpeed(const tValue& _topspeed(link from Ccar.h via Pointer from Ccar class),const tValue& _tsp1,const tValue& _tsp2,const tValue& _tsp3,const tPercent& _topspeedSum(link from Cpart.h via in Utils.h Pointer from Cpart Class), const tPercent& _accelerationSum,
    const tPercent& _handlingSum);

    tValueF ComputeAcceleration(const tValue& _acceleration,const tValue& _acc1,const tValue& _acc2,const tValue& _acc3,const tPercent& _topspeedSum, const tPercent& _accelerationSum,
    			const tPercent& _handlingSum);
    
    tValueF ComputeHandling(const tValue& _handling,const tValue& _hnd1,const tValue& _hnd2,const tValue& _hnd3,const tPercent& _topspeedSum, const tPercent& _accelerationSum,
    			const tPercent& _handlingSum);
    

    CCar.h
    Class CCar
    private:
    tValue _topspeed;
    tValue _tsp1;
    tValue _tsp2;
    tValue _tsp3;
    tValue _acceleration;
    tValue _acc1;
    tValue _acc2;
    tValue _acc3;
    tValue _handling;
    tValue _hnd1;
    tValue _hnd2;
    tValue _hnd3;

    CPart.h
    Class Cpart
    Private:
    tPercent _topspeedSum;
    tPercent _accelerationSum;
    tPercent _handlingSum;

    The app has some bugs in the code, because not count the value of the cars only show images and some numbers.
    0_1509133229059_00cbf20b-1f43-4652-b5fc-ff8408776c0b-obrázok.png
    0_1509133250621_cf37a0c3-5bdd-400b-beac-e8e200c40622-obrázok.png

    Modified source code with bugs,compiler passed.
    link text
    [0_1509133498385_Compare.xlsx](Uploading 100%)



  • Again to echo @SGaist , what is your Qt related question?
    sorry, but I can't see one :-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.