@@ -69,26 +69,70 @@ void Update()
6969 } ;
7070 if ( Application . platform == RuntimePlatform . WindowsPlayer )
7171 {
72+ string batchPath = Path . Combine ( Plugin . BASE_PATH , "update.bat" ) ;
73+ File . WriteAllText ( batchPath , $@ "
74+ @echo off
75+ echo Waiting for Polytopia.exe to exit...
76+ :waitloop
77+ tasklist | findstr /I ""Polytopia.exe"" >nul
78+ if not errorlevel 1 (
79+ timeout /T 1 >nul
80+ goto waitloop
81+ )
82+
83+ echo Updating...
84+ robocopy ""New"" . /E /MOVE /NFL /NDL /NJH /NJS /NP >nul
85+ rmdir /S /Q ""New""
86+ del /F /Q ""BepInEx\plugins\PolyMod.dll""
87+ move /Y ""PolyMod.new.dll"" ""BepInEx\plugins\PolyMod.dll""
88+
89+ echo Launching game...
90+ start steam://rungameid/874390
91+ timeout /T 3 /NOBREAK >nul
92+ exit
93+ " ) ;
7294 info . FileName = "cmd.exe" ;
73- info . Arguments = "/C " +
74- ":waitloop & " +
75- "tasklist | findstr /I \" Polytopia.exe\" >nul && (timeout /T 1 >nul & goto waitloop) & " +
76- "robocopy \" New\" . /E /MOVE /NFL /NDL /NJH /NJS /NP >nul & " +
77- "rmdir /S /Q \" New\" & " +
78- "del /F /Q \" BepInEx\\ plugins\\ PolyMod.dll\" & " +
79- "move /Y \" PolyMod.new.dll\" \" BepInEx\\ plugins\\ PolyMod.dll\" & " +
80- "start steam://rungameid/874390" ;
95+ info . Arguments = $ "/C start \" \" \" { batchPath } \" ";
96+ info . WorkingDirectory = Plugin . BASE_PATH ;
97+ info . CreateNoWindow = true ;
98+ info . UseShellExecute = false ;
8199 }
82100 if ( Application . platform == RuntimePlatform . LinuxPlayer || Application . platform == RuntimePlatform . OSXPlayer )
83101 {
102+ string bashPath = Path . Combine ( Plugin . BASE_PATH , "update.sh" ) ;
103+ File . WriteAllText ( bashPath , $@ "
104+ #!/bin/bash
105+
106+ echo ""Waiting for Polytopia to exit...""
107+ while pgrep -x ""Polytopia"" > /dev/null; do
108+ sleep 1
109+ done
110+
111+ echo ""Updating...""
112+ mv New/* . && rm -rf New
113+ rm -f BepInEx/plugins/PolyMod.dll
114+ mv -f PolyMod.new.dll BepInEx/plugins/PolyMod.dll
115+
116+ echo ""Launching game...""
117+ xdg-open steam://rungameid/874390 &
118+
119+ sleep 3
120+ exit 0
121+ " ) ;
122+
123+ System . Diagnostics . Process chmod = new System . Diagnostics . Process ( ) ;
124+ chmod . StartInfo . FileName = "chmod" ;
125+ chmod . StartInfo . Arguments = $ "+x \" { bashPath } \" ";
126+ chmod . StartInfo . UseShellExecute = false ;
127+ chmod . StartInfo . CreateNoWindow = true ;
128+ chmod . Start ( ) ;
129+ chmod . WaitForExit ( ) ;
130+
84131 info . FileName = "/bin/bash" ;
85- info . Arguments = "-c \" " +
86- "while pgrep -x Polytopia > /dev/null; do sleep 1; done && " +
87- "mv New/* . && rm -rf New && " +
88- "rm -f BepInEx/plugins/PolyMod.dll && " +
89- "mv PolyMod.new.dll BepInEx/plugins/PolyMod.dll && " +
90- "steam steam://rungameid/874390" +
91- "\" " ;
132+ info . Arguments = $ "\" { bashPath } \" ";
133+ info . WorkingDirectory = Plugin . BASE_PATH ;
134+ info . CreateNoWindow = true ;
135+ info . UseShellExecute = false ;
92136 }
93137 Process . Start ( info ) ;
94138 Application . Quit ( ) ;
0 commit comments