private void CopyRequiredFiles(ServerInfo theServer)
{
//copy the files require to run the game
if (PatchStepFired != null)
{
PatchStepFired(this, new PatchingEventArgs(myVariables.CreatingDirectory + " " + SWGANHPAth + theServer.SafeFolderName, true));
}
//make the directory
if (!Directory.Exists(SWGANHPAth + theServer.SafeFolderName))
{
Directory.CreateDirectory(SWGANHPAth + theServer.SafeFolderName);
}
if (PatchStepFired != null)
{
PatchStepFired(this, new PatchingEventArgs(myVariables.Created, false));
PatchStepFired(this, new PatchingEventArgs(myVariables.CopyingSoundSystem, true));
}
//copy the miles directory across
Directory.CreateDirectory(SWGANHPAth + theServer.SafeFolderName + "\\miles");
if (Directory.Exists(SWGANHPAth + "\\miles"))
{
foreach (string theFileName in Directory.GetFiles(SWGANHPAth + "\\miles"))
{
File.Copy(theFileName, SWGANHPAth + theServer.SafeFolderName + "\\miles\\" + Path.GetFileName(theFileName));
}
}
if (PatchStepFired != null)
{
PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
PatchStepFired(this, new PatchingEventArgs(myVariables.CopyingBinaries, true));
}
//copy the raw files in there
//main executable
File.Copy(SWGANHPAth + "swganh.exe", SWGANHPAth + theServer.SafeFolderName + "\\swganh.exe");
//related DLLS
File.Copy(SWGANHPAth + "dpvs.dll", SWGANHPAth + theServer.SafeFolderName + "\\dpvs.dll");
File.Copy(SWGANHPAth + "Mss32.dll", SWGANHPAth + theServer.SafeFolderName + "\\Mss32.dll");
File.Copy(SWGANHPAth + "s205_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s205_r.dll");
File.Copy(SWGANHPAth + "s206_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s206_r.dll");
File.Copy(SWGANHPAth + "s207_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s207_r.dll");
if (PatchStepFired != null)
{
PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
PatchStepFired(this, new PatchingEventArgs(myVariables.CopyConfigFiles, true));
}
try
{
if (File.Exists(SWGANHPAth + "swg2uu_machineoptions.iff"))
{
//one IFF
File.Copy(SWGANHPAth + "swg2uu_machineoptions.iff", SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_machineoptions.iff");
}
//the pre-load CFG
//File.Copy(SWGANHPAth + "preload.cfg", SWGANHPAth + theServer.ServerId.ToString() + "\\preload.cfg");
//craft the login one to match
File.Copy(SWGANHPAth + "swg2uu_login.cfg", SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_login.cfg");
if (PatchStepFired != null)
{
PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
PatchStepFired(this, new PatchingEventArgs(myVariables.SettingServerAddress, true));
}
IniFiles myFiles = new IniFiles(SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_login.cfg");
myFiles.WriteValue("ClientGame", "loginServerPort0", theServer.Port);
myFiles.WriteValue("ClientGame", "loginServerAddress0", theServer.Address);
if (PatchStepFired != null)
{
PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
PatchStepFired(this, new PatchingEventArgs(myVariables.SetupLocalConfig, true));
}
//and make a main cfg which points to the central config files
//and our local login
TextWriter twOut = new StreamWriter(SWGANHPAth + theServer.SafeFolderName + "\\swg2uu.cfg");
twOut.WriteLine(".include \"swg2uu_login.cfg\"");
twOut.WriteLine(".include \"..\\swg2uu_live.cfg\"");
twOut.WriteLine(".include \"..\\swg2uu_preload.cfg\"");
twOut.WriteLine(".include \"..\\swg2uu_opt.cfg\"");
twOut.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
if (PatchStepFired != null)
{
PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
}
}