📄 gmain.pas
字号:
var
IniGameConf:TIniFile;
sIniFile:String;
SaveList:TStringList;
begin
sIniFile:=g_sGameDirectory + g_sSelGate_Directory;
if not DirectoryExists(sIniFile) then begin
CreateDir(sIniFile);
end;
IniGameConf:=TIniFile.Create(sIniFile + g_sSelGate_ConfigFile);
IniGameConf.WriteString('SelGate','Title',g_sGameName);
IniGameConf.WriteString('SelGate','ServerAddr',g_sSelGate_ServerAddr);
IniGameConf.WriteInteger('SelGate','ServerPort',g_nDBServer_Config_GatePort{g_nSelGate_ServerPort});
IniGameConf.WriteString('SelGate','GateAddr',g_sSelGate_GateAddr);
IniGameConf.WriteInteger('SelGate','GatePort',g_nSelGate_GatePort);
IniGameConf.WriteInteger('SelGate','ShowLogLevel',g_nSelGate_ShowLogLevel);
IniGameConf.WriteInteger('SelGate','MaxConnOfIPaddr',g_nSelGate_MaxConnOfIPaddr);
IniGameConf.WriteInteger('SelGate','BlockMethod',g_nSelGate_BlockMethod);
IniGameConf.WriteInteger('SelGate','KeepConnectTimeOut',g_nSelGate_KeepConnectTimeOut);
IniGameConf.Free;
end;
procedure TfrmMain.GenMutSelGateConfig(nIndex: Integer);
var
IniGameConf:TIniFile;
sIniFile:String;
SaveList:TStringList;
sGateAddr:String;
nGatePort:Integer;
sServerAddr:String;
begin
sIniFile:=g_sGameDirectory + g_sSelGate_Directory;
if not DirectoryExists(sIniFile) then begin
CreateDir(sIniFile);
end;
case nIndex of //
0: begin
sGateAddr:=g_sSelGate_GateAddr;
nGatePort:=g_nSelGate_GatePort;
sServerAddr:=g_sLocalIPaddr;
end;
1: begin
sGateAddr:=g_sSelGate_GateAddr1;
nGatePort:=g_nSelGate_GatePort1;
sServerAddr:=g_sExtIPaddr;
end;
end;
IniGameConf:=TIniFile.Create(sIniFile + g_sSelGate_ConfigFile);
IniGameConf.WriteString('SelGate','Title',g_sGameName);
IniGameConf.WriteString('SelGate','ServerAddr',sServerAddr{g_sSelGate_ServerAddr});
IniGameConf.WriteInteger('SelGate','ServerPort',g_nSelGate_ServerPort);
IniGameConf.WriteString('SelGate','GateAddr',sGateAddr);
IniGameConf.WriteInteger('SelGate','GatePort',nGatePort);
IniGameConf.WriteInteger('SelGate','ShowLogLevel',g_nSelGate_ShowLogLevel);
IniGameConf.WriteInteger('SelGate','MaxConnOfIPaddr',g_nSelGate_MaxConnOfIPaddr);
IniGameConf.WriteInteger('SelGate','BlockMethod',g_nSelGate_BlockMethod);
IniGameConf.WriteInteger('SelGate','KeepConnectTimeOut',g_nSelGate_KeepConnectTimeOut);
IniGameConf.Free;
end;
procedure TfrmMain.GenRunGateConfig;
var
IniGameConf:TIniFile;
sIniFile:String;
SaveList:TStringList;
begin
sIniFile:=g_sGameDirectory + g_sRunGate_Directory;
if not DirectoryExists(sIniFile) then begin
CreateDir(sIniFile);
end;
IniGameConf:=TIniFile.Create(sIniFile + g_sRunGate_ConfigFile);
IniGameConf.WriteString('server','Title',g_sGameName + '(' + IntToStr(g_nRunGate_GatePort) + ')');
IniGameConf.WriteString('server','Server1',g_sRunGate_ServerAddr);
IniGameConf.WriteInteger('server','ServerPort',g_nM2Server_GatePort{g_nRunGate_ServerPort});
IniGameConf.WriteString('server','GateAddr',g_sRunGate_GateAddr);
IniGameConf.WriteInteger('server','GatePort',g_nRunGate_GatePort);
IniGameConf.WriteString('Reg','RegKey',g_sRunGate_RegKey);
IniGameConf.WriteString('Reg','ServerAddr',g_sRunGate_Config_RegServerAddr);
IniGameConf.WriteInteger('Reg','ServerPort',g_nRunGate_Config_RegServerPort);
IniGameConf.Free;
end;
procedure TfrmMain.RefGameConsole;
begin
m_boOpen:=False;
EditM2ServerProgram.Text:=g_sGameDirectory + g_sM2Server_Directory + g_sM2Server_ProgramFile;
EditDBServerProgram.Text:=g_sGameDirectory + g_sDBServer_Directory + g_sDBServer_ProgramFile;
EditDBServerGatePort.Text:=IntToStr(g_nDBServer_Config_GatePort);
EditDBServerServerPort.Text:=IntToStr(g_nDBServer_Config_ServerPort);
CheckBoxDBServerGetStart.Checked:=g_boDBServer_GetStart;
EditLoginSrvProgram.Text:=g_sGameDirectory + g_sLoginServer_Directory + g_sLoginServer_ProgramFile;
EditLogServerProgram.Text:=g_sGameDirectory + g_sLogServer_Directory + g_sLogServer_ProgramFile;
EditLoginGateProgram.Text:=g_sGameDirectory + g_sLoginGate_Directory + g_sLoginGate_ProgramFile;
EditSelGateProgram.Text:=g_sGameDirectory + g_sSelGate_Directory + g_sSelGate_ProgramFile;
EditRunGateProgram.Text:=g_sGameDirectory + g_sRunGate_Directory + g_sRunGate_ProgramFile;
EditRunGate1Program.Text:=g_sGameDirectory + g_sRunGate_Directory + g_sRunGate_ProgramFile;
EditRunGate2Program.Text:=g_sGameDirectory + g_sRunGate_Directory + g_sRunGate_ProgramFile;
CheckBoxM2Server.Checked:=g_boM2Server_GetStart;
CheckBoxM2Server.Hint:=format('程序所在位置: %s%s%s',[g_sGameDirectory,g_sDBServer_Directory,g_sM2Server_ProgramFile]);
CheckBoxDBServer.Checked:=g_boDBServer_GetStart;
CheckBoxDBServer.Hint:=format('程序所在位置: %s%s%s',[g_sGameDirectory,g_sDBServer_Directory,g_sDBServer_ProgramFile]);
CheckBoxLoginServer.Checked:=g_boLoginServer_GetStart;
CheckBoxLoginServer.Hint:=format('程序所在位置: %s%s%s',[g_sGameDirectory,g_sDBServer_Directory,g_sLoginServer_ProgramFile]);
CheckBoxLogServer.Checked:=g_boLogServer_GetStart;
CheckBoxLogServer.Hint:=format('程序所在位置: %s%s%s',[g_sGameDirectory,g_sDBServer_Directory,g_sLogServer_ProgramFile]);
CheckBoxLoginGate.Checked:=g_boLoginGate_GetStart;
CheckBoxLoginGate.Hint:=format('程序所在位置: %s%s%s',[g_sGameDirectory,g_sDBServer_Directory,g_sLoginGate_ProgramFile]);
CheckBoxSelGate.Checked:=g_boSelGate_GetStart;
CheckBoxSelGate.Hint:=format('程序所在位置: %s%s%s',[g_sGameDirectory,g_sDBServer_Directory,g_sSelGate_ProgramFile]);
CheckBoxRunGate.Checked:=g_boRunGate_GetStart;
CheckBoxRunGate.Hint:=format('程序所在位置: %s%s%s',[g_sGameDirectory,g_sDBServer_Directory,g_sRunGate_ProgramFile]);
CheckBoxRunGate1.Checked:=g_boRunGate1_GetStart;
CheckBoxRunGate1.Hint:=format('程序所在位置: %s%s%s',[g_sGameDirectory,g_sDBServer_Directory,g_sRunGate_ProgramFile]);
CheckBoxRunGate2.Checked:=g_boRunGate2_GetStart;
CheckBoxRunGate2.Hint:=format('程序所在位置: %s%s%s',[g_sGameDirectory,g_sDBServer_Directory,g_sRunGate_ProgramFile]);
EditGameDir.Text:=g_sGameDirectory;
EditHeroDB.Text:=g_sHeroDBName;
EditGameName.Text:=g_sGameName;
EditGameExtIPaddr.Text:=g_sExtIPaddr;
CheckBoxDynamicIPMode.Checked:=g_boDynamicIPMode;
EditGameExtIPaddr.Enabled:=not g_boDynamicIPMode;
EditM2ServerRegKey.Text:=g_sM2Server_Regkey;
EditRunGateRegKey.Text:=g_sRunGate_RegKey;
EditDBServerRegKey.Text:=g_sDBServer_Config_RegKey;
EditLoginGate_MainFormX.Value:=g_nLoginGate_MainFormX;
EditLoginGate_MainFormY.Value:=g_nLoginGate_MainFormY;
CheckBoxboLoginGate_GetStart.Checked:=g_boLoginGate_GetStart;
EditLoginGate_GatePort.Text:=IntToStr(g_nLoginGate_GatePort);
EditSelGate_MainFormX.Value:=g_nSelGate_MainFormX;
EditSelGate_MainFormY.Value:=g_nSelGate_MainFormY;
CheckBoxboSelGate_GetStart.Checked:=g_boSelGate_GetStart;
EditSelGate_GatePort.Text:=IntToStr(g_nSelGate_GatePort);
EditSelGate_GatePort1.Text:=IntToStr(g_nSelGate_GatePort1);
EditRunGate_Connt.Value:=g_nRunGate_Count;
EditRunGate_GatePort1.Text:=IntToStr(g_nRunGate_GatePort);
EditRunGate_GatePort2.Text:=IntToStr(g_nRunGate1_GatePort);
EditRunGate_GatePort3.Text:=IntToStr(g_nRunGate2_GatePort);
EditRunGate_GatePort4.Text:=IntToStr(g_nRunGate3_GatePort);
EditRunGate_GatePort5.Text:=IntToStr(g_nRunGate4_GatePort);
EditRunGate_GatePort6.Text:=IntToStr(g_nRunGate5_GatePort);
EditRunGate_GatePort7.Text:=IntToStr(g_nRunGate6_GatePort);
EditRunGate_GatePort8.Text:=IntToStr(g_nRunGate7_GatePort);
EditLoginServer_MainFormX.Value:=g_nLoginServer_MainFormX;
EditLoginServer_MainFormY.Value:=g_nLoginServer_MainFormY;
EditLoginServerGatePort.Text:=IntToStr(g_nLoginServer_GatePort);
EditLoginServerServerPort.Text:=IntToStr(g_nLoginServer_ServerPort);
CheckBoxboLoginServer_GetStart.Checked:=g_boLoginServer_GetStart;
EditDBServer_MainFormX.Value:=g_nDBServer_MainFormX;
EditDBServer_MainFormY.Value:=g_nDBServer_MainFormY;
CheckBoxAutoBackupHumData.Checked:=g_boDBServer_AutoBackup;
EditBackupTime.Value:=g_dwDBServer_BackupTime div (60 * 1000);
EditLogServer_MainFormX.Value:=g_nLogServer_MainFormX;
EditLogServer_MainFormY.Value:=g_nLogServer_MainFormY;
EditLogServerPort.Text:=IntToStr(g_nLogServer_Port);
CheckBoxLogServerGetStart.Checked:=g_boLogServer_GetStart;
EditM2Server_MainFormX.Value:=g_nM2Server_MainFormX;
EditM2Server_MainFormY.Value:=g_nM2Server_MainFormY;
EditM2Server_TestLevel.Value:=g_nM2Server_TestLevel;
EditM2Server_TestGold.Value:=g_nM2Server_TestGold;
EditM2ServerGatePort.Text:=IntToStr(g_nM2Server_GatePort);
EditM2ServerMsgSrvPort.Text:=IntToStr(g_nM2Server_MsgSrvPort);
CheckBoxM2ServerGetStart.Checked:=g_boM2Server_GetStart;
m_boOpen:=True;
end;
procedure TfrmMain.CheckBoxDBServerClick(Sender: TObject);
begin
g_boDBServer_GetStart:=CheckBoxDBServer.Checked;
end;
procedure TfrmMain.CheckBoxLoginServerClick(Sender: TObject);
begin
g_boLoginServer_GetStart:=CheckBoxLoginServer.Checked;
end;
procedure TfrmMain.CheckBoxM2ServerClick(Sender: TObject);
begin
g_boM2Server_GetStart:=CheckBoxM2Server.Checked;
end;
procedure TfrmMain.CheckBoxLogServerClick(Sender: TObject);
begin
g_boLogServer_GetStart:=CheckBoxLogServer.Checked;
end;
procedure TfrmMain.CheckBoxLoginGateClick(Sender: TObject);
begin
g_boLoginGate_GetStart:=CheckBoxLoginGate.Checked;
end;
procedure TfrmMain.CheckBoxSelGateClick(Sender: TObject);
begin
g_boSelGate_GetStart:=CheckBoxSelGate.Checked;
end;
procedure TfrmMain.CheckBoxRunGateClick(Sender: TObject);
begin
g_boRunGate_GetStart:=CheckBoxRunGate.Checked;
end;
procedure TfrmMain.CheckBoxRunGate1Click(Sender: TObject);
begin
g_boRunGate1_GetStart:=CheckBoxRunGate1.Checked;
end;
procedure TfrmMain.CheckBoxRunGate2Click(Sender: TObject);
begin
g_boRunGate2_GetStart:=CheckBoxRunGate2.Checked;
end;
procedure TfrmMain.ButtonStartGameClick(Sender: TObject);
begin
SetWindowPos(Self.Handle,Self.Handle,Self.Left,Self.Top,Self.Width,Self.Height,$40);
case m_nStartStatus of
0: begin
if Application.MessageBox('是否确认启动游戏服务器 ?','确认信息',MB_YESNO + MB_ICONQUESTION) = mrYes then begin
StartGame();
end;
end;
1: begin
if Application.MessageBox('是否确认中止启动游戏服务器 ?','确认信息',MB_YESNO + MB_ICONQUESTION) = mrYes then begin
TimerStartGame.Enabled:=False;
m_nStartStatus:=2;
ButtonStartGame.Caption:=g_sButtonStopGame;
end;
end;
2: begin
if Application.MessageBox('是否确认停止游戏服务器 ?','确认信息',MB_YESNO + MB_ICONQUESTION) = mrYes then begin
StopGame();
end;
end;
3: begin
if Application.MessageBox('是否确认中止启动游戏服务器 ?','确认信息',MB_YESNO + MB_ICONQUESTION) = mrYes then begin
TimerStopGame.Enabled:=False;
m_nStartStatus:=2;
ButtonStartGame.Caption:=g_sButtonStopGame;
end;
end;
end;
{
if CreateProcess(nil,
PChar(sProgamFile),
nil,
nil,
False,
IDLE_PRIORITY_CLASS,
nil,
nil,
StartUpInfo,
ProcessInfo) then begin
}
end;
procedure TfrmMain.StartGame;
var
nRetCode:Integer;
begin
FillChar(DBServer,SizeOf(TProgram),#0);
DBServer.boGetStart:=g_boDBServer_GetStart;
DBServer.boReStart:=True;
DBServer.sDirectory:=g_sGameDirectory + g_sDBServer_Directory;
DBServer.sProgramFile:=g_sDBServer_ProgramFile;
DBServer.nMainFormX:=g_nDBServer_MainFormX;
DBServer.nMainFormY:=g_nDBServer_MainFormY;
FillChar(LoginServer,SizeOf(TProgram),#0);
LoginServer.boGetStart:=g_boLoginServer_GetStart;
LoginServer.boReStart:=True;
LoginServer.sDirectory:=g_sGameDirectory + g_sLoginServer_Directory;
LoginServer.sProgramFile:=g_sLoginServer_ProgramFile;
LoginServer.nMainFormX:=g_nLoginServer_MainFormX;
LoginServer.nMainFormY:=g_nLoginServer_MainFormY;
FillChar(LogServer,SizeOf(TProgram),#0);
LogServer.boGetStart:=g_boLogServer_GetStart;
LogServer.boReStart:=True;
LogServer.sDirectory:=g_sGameDirectory + g_sLogServer_Directory;
LogServer.sProgramFile:=g_sLogServer_ProgramFile;
LogServer.nMainFormX:=g_nLogServer_MainFormX;
LogServer.nMainFormY:=g_nLogServer_MainFormY;
FillChar(M2Server,SizeOf(TProgram),#0);
M2Server.boGetStart:=g_boM2Server_GetStart;
M2Server.boReStart:=True;
M2Server.sDirectory:=g_sGameDirectory + g_sM2Server_Directory;
M2Server.sProgramFile:=g_sM2Server_ProgramFile;
M2Server.nMainFormX:=g_nM2Server_MainFormX;
M2Server.nMainFormY:=g_nM2Server_MainFormY;
FillChar(RunGate,SizeOf(TProgram),#0);
RunGate.boGetStart:=g_boRunGate_GetStart;
RunGate.boReStart:=True;
RunGate.sDirectory:=g_sGameDirectory + g_sRunGate_Directory;
RunGate.sProgramFile:=g_sRunGate_ProgramFile;
FillChar(RunGate1,SizeOf(TProgram),#0);
RunGate1.boGetStart:=g_boRunGate1_GetStart;
RunGate1.boReStart:=True;
RunGate1.sDirectory:=g_sGameDirectory + g_sRunGate_Directory;
RunGate1.sProgramFile:=g_sRunGate_ProgramFile;
FillChar(RunGate2,SizeOf(TProgram),#0);
RunG
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -