|
传奇3冷雨夜登录器源代码老42插件版,登录器主程序源码,适用于传奇3dX7客户端的42魔法插件版本常见的有 1201插件,0706插件,1005插件,0227插件和46魔法0713插件。
[mw_shl_code=delphi,true]unit LyThread;
{$I Ver.Inc}
interface
uses
Classes, StdCtrls, Windows, SysUtils, Controls, IdHTTP, FastIniFile, DateUtils;
type
TExistFile = class(TThread)
private
protected
procedure Execute; override;
public
constructor Create(); reintroduce;
end;
TUpIP = class(TThread)
private
Str: string;
function Get(URL: string): boolean;
function AddList: boolean;
function CheckUpdateInfo: boolean;
function CheckFixFile: boolean;
function GetIni: boolean;
protected
procedure Execute; override;
procedure ShowForm;
procedure ShowLoginUPForm;
procedure ReStartLogin;
procedure GetIniCrcError;
public
constructor Create(const DownUrl: string); reintroduce;
end;
var
TExistFile_Thread : TExistFile; //释放文件线程
TUpIP_Thread : TUpIP; //自动更新线程
implementation
uses Mir3, MAIN, LyyMir3UP, Func;
constructor TExistFile.Create();
begin
FreeOnTerminate := True; // 自动删除
inherited Create(False); // 直接运行
end;
procedure TExistFile.Execute;
begin
try
if not DirectoryExists(FullPath + 'Update\') then ForceDirectories(FullPath + 'Update\');
if not DirectoryExists(FullPath + 'LyyConfig\') then ForceDirectories(FullPath + 'LyyConfig\');
//检测并生成WINRAR解压缩组件
if not FileExists(FullPath + 'LyyConfig\UnzLib.dll') then ExtractRes('exefile', UnRARDLLRes, PChar(FullPath + 'LyyConfig\UnzLib.dll'));
//删除多余文件,加速游戏
DelFile(FullPath + 'Data\CreateChr.dat');
DelFile(FullPath + 'Data\StartGame.dat');
DelFile(FullPath + 'Data\wemade.dat');
ExtractRes('exefile', 'Mir3_RES1', PChar(FullPath + 'BgmList.wwl'));
ExtractRes('exefile', 'Mir3_RES2', PChar(FullPath + 'BgmList145.wwl'));
ExtractRes('exefile', 'Mir3_RES3', PChar(FullPath + 'K3mir3.exe'));
ExtractRes('exefile', 'Mir3_RES4', PChar(FullPath + 'Kingmir3.dll'));
ExtractRes('exefile', 'Mir3_RES5', PChar(FullPath + 'Magic.exp'));
ExtractRes('exefile', 'Mir3_RES6', PChar(FullPath + 'MagicInfo.res'));
ExtractRes('exefile', 'Mir3_RES7', PChar(FullPath + 'motions.res'));
ExtractRes('exefile', 'Mir3_RES8', PChar(FullPath + 'SoundList.wwl'));
ExtractRes('exefile', 'Mir3_RES9', PChar(FullPath + 'SoundList145.wwl'));
except
end;
end;
constructor TUpIP.Create(const DownUrl: string);
begin
Str := DownUrl;
FreeOnTerminate := True; // 自动删除
inherited Create(False); // 直接运行
end;
procedure TUpIP.ReStartLogin;
begin
Form1.suiMessageDialog1.Caption := '需要重启登录器';
Form1.suiMessageDialog1.Text := '登录器配置文件升级成功,必须重新启动登录器后才生效,不重启可能无法正常游戏,是否现在就重新启动登录器!?';
if Form1.suiMessageDialog1.ShowModal = mrok then
begin
_bReStartLogin := True;
Form1.Close;
end;
end;
procedure TUpIP.ShowLoginUPForm;
begin
Form1.TrayIcon1.MinimizeApp;
Form1.Timer1.Enabled := True;
end;
procedure TUpIP.ShowForm;
begin
if _bEnableCue then
begin
Form1.suiMessageDialog1.Caption := '自动更新';
Form1.suiMessageDialog1.Text := '检测到你的客户端有文件需要更新,是否现在更新(不更新可能影响正常游戏)!?';
if Form1.suiMessageDialog1.ShowModal = mrok then
begin
Form_Update.ShowModal;
end;
end
else
begin
Form_Update.ShowModal;
end;
end;
function TUpIP.Get(URL: string): boolean; //获得更新信息
var
sDownUrl : string;
IdHTTP : TIDHttp;
FileStr : TStringList;
ChkStr : string;
begin
try
sDownUrl := URL;
//if copy(sDownUrl, Length(sDownUrl), 1) <> '/' then sDownUrl := sDownUrl + '/';
FileStr := TStringList.Create;
IdHTTP := TIDHttp.Create(nil);
try
Result := False;
IdHTTP.HandleRedirects := True; //必须支持重定向否则可能出错
IdHTTP.ReadTimeout := 30000; //超过这个时间则不再访问
FileStr.Add(IdHTTP.Get(sDownUrl));
//判断是否正确的格式
ChkStr := FileStr.Strings[0];
if Q_PosStr(';;;;;LYY Mir3Login Update File;;;;;', ChkStr) > 0 then
begin
DelFile(sUpInfoini);
FileStr.SaveToFile(sUpInfoini); //保存本地升级信息文件
Result := True;
end
else
begin
Result := False;
end;
finally
FreeAndNil(IdHTTP);
FreeAndNil(FileStr);
end;
except
Result := False;
end;
end;
function TUpIP.CheckFixFile: boolean;
var
NFile : string;
PUDL : PTUpdateList;
SelfPath : string;
SelFileTime : TDateTime;
begin
SelfPath := FullPath;
SelfPath := Copy(SelfPath, 1, Length(SelfPath) - 1);
while (True) do
begin
if UPList.Count = 0 then break;
PUDL := UPList.Items[0];
NFile := SelfPath + PUDL^.FilePath + PUDL^.ToFile;
if not FileExists(NFile) then //文件不存在
begin
//MessageBox(0, PChar(NFile), '文件不存在', MB_OK + MB_ICONSTOP);
Result := True;
Exit;
end;
SelFileTime := GetFileDateTime(NFile, fttLastWrite);
if SecondsBetween(SelFileTime, PUDL^.FileDateTime) > 30 then
begin
//MessageBox(0, PChar(NFile), '文件日期不正确', MB_OK + MB_ICONSTOP);
Result := True;
Exit;
end;
Dispose(PTUpdateList(UPList.Items[0]));
UPList.Delete(0);
end;
Result := False;
end;
function TUpIP.CheckUpdateInfo: boolean;
var
Ini : TFastIniFile;
begin
try
Ini := TFastIniFile.Create(sUpInfoini);
try
try
_bCheckLong := Ini.ReadBoolean('UpdateInfo', 'CheckLong', False);
_sLongURL := Ini.ReadString('UpdateInfo', 'LongURL', '');
_sLongCode := Ini.ReadString('UpdateInfo', 'LongCode', '');
_bCheckIni := Ini.ReadBoolean('UpdateInfo', 'CheckIni', False);
_sIniURL := Ini.ReadString('UpdateInfo', 'IniURL', '');
_sIniCode := Ini.ReadString('UpdateInfo', 'IniCode', '');
_bCheckFix := Ini.ReadBoolean('UpdateInfo', 'CheckFix', False);
_sDefUrl := Ini.ReadString('UpdateInfo', 'DefURL', '');
_bEnableCue := Ini.ReadBoolean('UpdateInfo', 'EnableCue', False);
_sDllURL := Ini.ReadString('UpdateInfo', 'DLLURL', '');
_sDllCode := Ini.ReadString('UpdateInfo', 'DLLCode', '');
if _bCheckLong then _bCheckLong := (_sLongURL <> '') and (_sLongCode <> '');
if _bCheckIni then _bCheckIni := (_sIniURL <> '') and (_sIniCode <> '');
if _bCheckFix then _bCheckFix := _sDefUrl <> '';
Result := _bCheckLong or _bCheckIni or _bCheckFix;
except
Result := False;
end;
finally
FreeAndNil(Ini);
end;
except
Result := False;
end;
end;
function TUpIP.AddList: boolean;
var
Ini : TFastIniFile;
SectionStringList : TStringList;
i : Integer;
SectionName : string;
PUDL : PTUpdateList;
sFromFile, sFilePath, sFileDateTime: string;
FileDateTime : TDateTime;
begin
try
Ini := TFastIniFile.Create(sUpInfoini);
SectionStringList := TStringList.Create;
try
try
Ini.ReadSections(SectionStringList);
for i := 0 to SectionStringList.Count - 1 do
begin
SectionName := SectionStringList.Strings;
if Q_UpperCase(SectionName) <> Q_UpperCase('UpdateInfo') then
begin
try
sFromFile := Ini.ReadString(SectionName, 'FromFile', '');
sFilePath := Ini.ReadString(SectionName, 'FilePath', '');
sFileDateTime := Ini.ReadString(SectionName, 'FileDateTime', '');
if (sFromFile <> '') and (sFilePath <> '') and (sFileDateTime <> '') then
begin
FileDateTime := StrToDateTime(sFileDateTime);
New(PUDL);
PUDL^.FromFile := sFromFile;
PUDL^.ToFile := SectionName;
PUDL^.FilePath := sFilePath;
PUDL^.FileDateTime := FileDateTime;
UPList.Add(PUDL);
end;
except
continue;
end;
end;
end;
//MessageBox(0, PChar(IntToStr(UPList.Count)), '', MB_OK + MB_ICONSTOP);
Result := UPList.Count > 0;
except
Result := False;
end;
finally
FreeAndNil(Ini);
FreeAndNil(SectionStringList);
end;
except
Result := False;
end;
end;
procedure TUpIP.GetIniCrcError;
begin
//MessShow(3, '由于更新中的登录器配置文件校验失败,登录器配置无法更新到最新状态,你可以继续游戏,但是可能不正常,请联系管理员解决!');
Form1.suiMSNPopForm1.Title := '登录器配置文件更新失败';
Form1.suiMSNPopForm1.MessageText := '登录器配置文件更新时校验失败,登录器配置无法更新到最新状态,这可能会影响你正常游戏,请联系管理员解决.';
Form1.suiMSNPopForm1.Popup;
end;
function TUpIP.GetIni: boolean; //下载
var
IdHTTP : TIDHttp;
TempFile : string;
Error32 : WORD;
TempCrc : DWORD;
TStream : TMemoryStream;
begin
try
TempFile := FullPath + 'update\' + ExtractFileName(sUpIPini);
DelFile(TempFile);
TStream := TMemoryStream.Create;
IdHTTP := TIDHttp.Create(nil);
try
IdHTTP.HandleRedirects := True; //必须支持重定向否则可能出错
IdHTTP.ReadTimeout := 30000; //超过这个时间则不再访问
IdHTTP.Get(_sIniURL, TStream);
TStream.SaveToFile(TempFile);
finally
FreeAndNil(IdHTTP);
FreeAndNil(TStream);
end;
//检测CRC
Hex3Kol(TempFile, TempCrc, Error32);
if (Error32 <> 0) or (Q_IntToStr(TempCrc) <> _sIniCode) then //校验失败
begin
Synchronize(GetIniCrcError);
Result := False;
end
else
begin
DelFile(sUpIPini); //删除目标文件
CopyFile(PChar(TempFile), PChar(sUpIPini), False); //复制文件到目标
DelFile(TempFile); //删除update目录中的临时文件
Result := True;
end;
except
Result := False;
end;
end;
procedure TUpIP.Execute;
begin
if Get(Str) then
begin
//检测三选项以及读取选项内容
if FileExists(sUpInfoini) and CheckUpdateInfo then
begin
//是否更新配置文件
if _bCheckIni and (IniCrc <> 0) and (_sIniCode <> Q_IntToStr(IniCrc)) then
begin
if GetIni then //更新成功,提示重启登录器
begin
Synchronize(ReStartLogin);
Exit;
end;
end;
//是否更新登录器
if _bCheckLong and (LongCrc <> 0) and (_sLongCode <> Q_IntToStr(LongCrc)) then
begin
Synchronize(ShowLoginUPForm);
Exit;
end;
//是否更新补丁,并读取更新列表,并检测文件是否需要更新
if _bCheckFix and AddList and CheckFixFile then
begin
Synchronize(ShowForm);
end;
end;
end;
end;
end.
[/mw_shl_code]
|
上一篇:老C插件版Lyy冷雨夜登录器Delphi源码,King1.4下一篇:新火鸟登录器源代码Delphi,lyy冷雨夜代码
|