Quote Originally Posted by fire.tiger
TDC_RCV.pas line 925 - procedure DriveTrainUpdate is strange.
in C code is :

Code:
void DriveTrainUpdate(TDriveTrain* pDTrain, float gas, int gear)
{
	float fActiveRPM;
	static int counter = 0;
	counter += 1;
	float brakeCoef;
	// telemetry
	RCVehicle* pv = (RCVehicle*)pDTrain->pRcv;
	dFloat* ts = pv->fTimeSlice;
	int ofs = 45;

	PrintDebug("-DriveTrainUpdate [%d]-\n", counter);
in Pascal is :
[pascal]
procedure DriveTrainUpdate(var pDTrain: TDriveTrain; gas: single; gear: integer);
var
fActiveRPM: single;
counter: integer;
begin
counter := 0;
counter := counter + 1;

// PrintDebug("-----DriveTrainUpdate [%d] -------\n", counter);[/pascal]


I think there should be :

[pascal]procedure DriveTrainUpdate(var pDTrain: TDriveTrain; gas: single; gear: integer);
var
fActiveRPM: Single;
counter: Integer;
brakeCoef: Single;
pv: RCVehicle;
ts: TFriction;
ofs: Integer;
begin
counter := 0;
Inc(counter);
pv := pDTrain.pRcv;
ts := pv.fTimeSlice;
ofs := 45;[/pascal]


Also from line 1019 it is strange...


there should be in pascal this ( I think you forgot brakeCoef variable in there)

This is just my short look.Maybe I'm wrong.
I'll take deeper look inside...this is just first thing that I've seen...
Unless I am mistaken, this code:
Code:
void DriveTrainUpdate(TDriveTrain* pDTrain, float gas, int gear)
{
	float fActiveRPM;
	static int counter = 0;
	counter += 1;
	float brakeCoef;
	// telemetry
	RCVehicle* pv = (RCVehicle*)pDTrain->pRcv;
	dFloat* ts = pv->fTimeSlice;
	int ofs = 45;

	PrintDebug("-DriveTrainUpdate [%d]-\n", counter);
initialize counter with 0 the very first time it runs (as it is static), and from then on each time it is called counter will be incremented by 1.

With the pascal version below:

[pascal]procedure DriveTrainUpdate(var pDTrain: TDriveTrain; gas: single; gear: integer);
var
fActiveRPM: Single;
counter: Integer;
brakeCoef: Single;
pv: RCVehicle;
ts: TFriction;
ofs: Integer;
begin
counter := 0;
Inc(counter);
pv := pDTrain.pRcv;
ts := pv.fTimeSlice;
ofs := 45;[/pascal]

This will always make counter become equal to +1 each run...

this doesn't sound like the equivalent behavior at all...

perhaps you could try defining counter as (local to the procedure)

[pascal]Const
counter: Integer = 0;
[/pascal]

or

[pascal]Var
counter: Integer = 0;[/pascal]

counter may have to be a global constant/variable instead of local for it to work...you need to try both methods (local to the procedure first, then global) to see if they work for you.

Hope this helps,
cheers,
Paul.