@echo off
title TAI VA CAI DAT GAME MU ONLINE
color 0A

:: 1. Chuyen thu muc lam viec ve dung vi tri chua file bat/exe
cd /d "%~dp0"

echo ======================================================
echo          DANG TIEN HANH TAI TOAN BO DU LIEU GAME
echo ======================================================
echo.

:: Xoa file/folder tam cu neu con sot lai
if exist update.zip del /f /q update.zip
if exist "_temp_patch" rmdir /s /q "_temp_patch"

:: 2. Tai file Freemu.zip tu VPS ve may (luu ten thanh update.zip)
echo [*] Dang tai Game tu may chu (Vui long cho doi)...
curl -# -f -L -o update.zip "http://157.10.198.179/Generator/update/Freemu.zip?v=%RANDOM%%RANDOM%"

if exist update.zip (
    echo.
    echo [*] Dang giai nen va thiet lap du lieu...
    
    :: Giai nen vao thu muc tam _temp_patch
    powershell -Command "Expand-Archive -Path 'update.zip' -DestinationPath '_temp_patch' -Force"
    
    :: Ep chep de toan bo file vao thu muc hien tai
    if exist "_temp_patch" (
        xcopy "_temp_patch\*" ".\" /s /e /y /h /r >nul
        rmdir /s /q "_temp_patch"
    )
    
    del /f /q update.zip
    echo.
    echo [OK] Da cai dat game thanh cong!
) else (
    echo.
    echo [X] LOI: Khong the tai du lieu tu may chu! Vui long kiem tra lai ket noi mang.
)

echo.
echo ======================================================
echo HOAN TAT! HAY MO Launcher HOAC main.exe DE VAO GAME.
echo ======================================================
echo.
pause
exit