Esempio n. 1
0
        private string convertPathToPerforceDepotPath(string filepath, P4Interface p4)
        {
            string res = filepath;

            if (filepath.Contains(p4.clientPath))
            {
                res = filepath.Remove(0, gameDirectory.Length);
            }

            return(res);
        }
Esempio n. 2
0
        private static void generateFileListsinternal(object objin)
        {
            List <string> scenariosToProcess = objin as List <string>;

            //if we had some problem launching XFS, die out
            if (!XFSInterface.launchApp())
            {
                return;
            }


            //perforce connections
            P4Interface         perforce = new P4Interface();
            P4PendingChangelist cl       = perforce.createChangeList("openFileLists for archive reordering");


            //wait a bit after game launch to ensure that the game is loaded
            XFSInterface.launchGame();
            System.Threading.Thread.Sleep(10000);



            for (int i = 0; i < scenariosToProcess.Count; i++)
            {
                //Has the user pressed 'cancel' ?
                if (mIsWorking == false)
                {
                    sendStatusMsg("User stopped work");
                    break;
                }

                string launchString      = scenariosToProcess[i].Substring(0, scenariosToProcess[i].LastIndexOf(@"."));
                string scenariodir       = gameDirectory + @"\scenario\" + scenariosToProcess[i].Substring(0, scenariosToProcess[i].LastIndexOf(@"\"));
                string fileOpenLogStr    = scenariodir + @"\FileopenLog.txt";
                bool   addFileToPerforce = true;

                sendStatusMsg("Processing " + scenariosToProcess[i]);

                //there's a bit of logic here that we have to do.
                //considering there's like 800 states that a file can be in wrt perforce...
                if (File.Exists(fileOpenLogStr))
                {
                    P4FileStatus fstat = perforce.getFileStatus(fileOpenLogStr);

                    //is the file checked into perforce?
                    if (!fstat.IsFileInPerforce)
                    {
                        addFileToPerforce = true;
                    }
                    else
                    {
                        addFileToPerforce = false;

                        if (!fstat.IsFileCheckedOutByMe)
                        {
                            //checkout the file
                            //NOTE .txt isn't exclusive, so we don't care if someone else has it checked out.
                            perforce.checkoutFileToChangelist(fileOpenLogStr, cl);
                            sendStatusMsg("..Checking out " + fileOpenLogStr);
                        }
                    }

                    //this is a local delete so we can use the MOVE command;
                    try
                    {
                        File.Delete(fileOpenLogStr);
                    }
                    catch (System.Exception e)
                    {
                        sendStatusMsg("..Error Deleting " + fileOpenLogStr);
                        sendStatusMsg("..Skipping File " + fileOpenLogStr);
                        continue;
                    }
                }


                //do this a couple times to esnure it's actualy being done!
                for (int k = 0; k < 3; k++)
                {
                    XFSInterface.clearOpenFileList();
                    System.Threading.Thread.Sleep(100);
                }

                const int cNumSecondsToWait = 45;
                sendStatusMsg("..Launching " + launchString);
                XFSInterface.launchScenario(launchString);
                System.Threading.Thread.Sleep(cNumSecondsToWait * 1000);

                XFSInterface.safeOpenFileList();
                System.Threading.Thread.Sleep(10000);


                //move the file from work to the directory
                do
                {
                    try
                    {
                        File.Move(gameDirectory + @"\FileopenLog.txt", fileOpenLogStr);
                        break;
                    }
                    catch (System.Exception e)
                    {
                    }
                } while (true);


                //check file back into perforce here.
                if (addFileToPerforce)
                {
                    perforce.addFileToChangelist(fileOpenLogStr, cl);
                    sendStatusMsg("..Adding " + fileOpenLogStr);
                }

                //update our status message on the main form
                sendStatusMsg("..Finished " + scenariosToProcess[i]);

                System.Threading.Thread.Sleep(5000);
            }

            perforce.submitChangelist(cl);
            sendStatusMsg("..Changelist " + cl.Number + " submitted");
            perforce.Disconnect();

            mIsWorking = false;
            sendStatusMsg("!DONE");
        }