The online racing simulator
[help] Delphi programming (half-source code)
hy!
i get version and more.. then how to get rpm?

unit init;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdUDPServer, IdBaseComponent, IdComponent, IdUDPBase,
IdUDPClient, IdSocketHandle;

type
THead = record
Size: Byte;
ISP_: Byte;
Reql: Byte;
Data: Byte;
end;
TInit = record
Size: Byte;
ISP_: Byte;
ReqI: Byte;
Data: Byte;
UDPPort: Word ;
Flags: Word;
Sp0: Byte;
Prefix: Byte;
Interval: Byte;
Admin: array[0..15] of char;
PName: array[0..15] of char;
end;
TVer = record
Version: array[0..7] of char;
Product: array[0..5] of char;
InSimVer: Word;
end;
TForm1 = class(TForm)
IdUDPClient1: TIdUDPClient;
IdUDPServer1: TIdUDPServer;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure IdUDPServer1UDPRead(Sender: TObject; AData: TStream; ABinding: TIdSocketHandle);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Head: THead;
Ver: TVer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var Init: TInit;
begin
Init.Size:=44;
Init.ISP_:=1;
Init.ReqI:=1;
Init.Data:=0;
Init.UDPPort:=30000;
Init.Flags:=0;
Init.Sp0:=0;
Init.Prefix:=0;
Init.Interval:=1;
Init.Admin:='';
Init.PName:=' InSim Demo';
IdUDPClient1.SendBuffer(Init, SizeOf(Init));
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Head.Size:=4;
Head.ISP_:=3;
Head.Reql:=0;
Head.Data:=2;
IdUDPClient1.SendBuffer(Head, SizeOf(Head));
end;

procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
begin
Application.ProcessMessages;
Adata.Read(Head, sizeof(Head));
if (Head.Size = Adata.Size) and (Head.ISP_ = 3) and (Head.Data = 0) then
begin
Head.Size:=4;
Head.ISP_:=3;
Head.Reql:=0;
Head.Data:=0;
IdUDPClient1.SendBuffer(Head, SizeOf(Head));
end;
if (Head.Size = Adata.Size) and (Head.ISP_ = 2) and (Head.Data = 0) then
begin
Adata.Read(Ver, sizeof(Ver));
Memo1.Lines.Add('Version: '+Ver.Version);
Memo1.Lines.Add('Product: '+Ver.Product);
Memo1.Lines.Add('InSimVer: '+IntToStr(Ver.InSimVer));

end;
end;

end.

#2 - Ian.H
Hi Gegry..

Unfortunately, I don't know the answer to your question but was wondering whether you'd considered (or would for the future) in creating a VCL component for InSim?

I haven't got my head around InSim with C++ yet, but it seems that Borland is lacking in following of coders around LFS and it'd be great to have a component (set?) for it

I kinda started previously by coding a couple of components to handle LFS replays, although these were written in C++ (unfortunately, I don't really know Delphi.. only enough to follow and port (a fair bit, but not all) to C++ and to use Object Pascal within the InnoSetup installer. I have tried coding a couple of things in Delphi, but more often than not, failed miserably ).

Anyways, thought I'd ask as by the look of your 'Uses' includes, the Indy components used are compatible with version 9 meaning I could compile a Delphi component to generate C++ headers as Indy v10 doesn't work in C++ (seems to be the encryption (SSL etc) components that fail as IdHTTP / IdWhois etc all seem to work, but IdFTP for example won't as it depends on encryption components).

Again sorry I can't be more help to your actual query.



Regards,

Ian
i use idUDP

unfortunately here hungary the delphi he has future (sry my bad english)
#4 - Ian.H
Quote from Gegry1992 :i use idUDP

unfortunately here hungary the delphi he has future (sry my bad english)

I just tried porting your code above to C++. Seems there's a difference between my IdUDPServer as rather than having a TStream to play with, I have a TBytes, but it throws a 'E2303 Type name expected' error

My (auto-generated) declaration for the UDPRead event looks like:

void __fastcall UDPServerUDPRead(TObject *Sender, TBytes AData, TIdSocketHandle *ABinding);

And it won't compile.. bah. Looks like I'll need to look into doing it the "hard way"

Anyways, I won't hijack your thread any longer, sorry.. and hope you get your answer



Regards,

Ian


PS: Your English is far better than my Hungarian
Delphi outgauge
Thank You man!
You're welcome

FGED GREDG RDFGDR GSFDG