diff --git a/build-linux/MorriCraft b/build-linux/MorriCraft index e22b489..a407ab2 100755 Binary files a/build-linux/MorriCraft and b/build-linux/MorriCraft differ diff --git a/build-linux/assets/version.txt b/build-linux/assets/version.txt new file mode 100644 index 0000000..ba1e8bf --- /dev/null +++ b/build-linux/assets/version.txt @@ -0,0 +1 @@ +v1.9.1 diff --git a/build-windows/MorriCraft.exe b/build-windows/MorriCraft.exe index c9e7310..3f4b3c6 100755 Binary files a/build-windows/MorriCraft.exe and b/build-windows/MorriCraft.exe differ diff --git a/build-windows/assets/version.txt b/build-windows/assets/version.txt new file mode 100644 index 0000000..ba1e8bf --- /dev/null +++ b/build-windows/assets/version.txt @@ -0,0 +1 @@ +v1.9.1 diff --git a/src/main.cpp b/src/main.cpp index 41bf46b..629dece 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -94,6 +94,7 @@ void GenerateChunk(int cx, int cz); void SetBlock(int x, int y, int z, int type); void SaveConfig(); void LoadConfig(); +std::string GetRemoteVersion(); // ---- Inventory System ---- struct InventorySlot { @@ -241,6 +242,23 @@ void SetBlock(int x, int y, int z, int type) { } } +std::string GetRemoteVersion() { + std::string url = "https://git.linology.tech/michael/MorriCraft/raw/branch/master/version.txt"; + char buffer[128]; + std::string result = ""; + std::string cmd = "curl -s -m 5 " + url; // 5 second timeout + FILE* pipe = popen(cmd.c_str(), "r"); + if (!pipe) return "error"; + while (fgets(buffer, sizeof(buffer), pipe) != NULL) { + result += buffer; + } + pclose(pipe); + // Trim result + size_t last = result.find_last_not_of(" \n\r\t"); + if (last != std::string::npos) result = result.substr(0, last + 1); + return result; +} + void SaveConfig() { std::ofstream file("config.cfg"); if (file.is_open()) { @@ -724,7 +742,15 @@ int main(void) bool updateReady = false; float updateTimer = 0.0f; float downloadProgress = 0.0f; - std::string updateNotes = ""; + std::string latestVersion = ""; + std::string localVersion = "v1.9.0"; // Default fallback + + // Read local version + std::ifstream vfile("assets/version.txt"); + if (vfile.is_open()) { + std::getline(vfile, localVersion); + vfile.close(); + } InventorySlot mouseHeldItem(AIR, 0); float gameTime = 75.0f; // Start at 6:00 AM @@ -1200,11 +1226,15 @@ int main(void) DrawRectangle(0, 0, currentWidth, currentHeight, (Color){ 20, 20, 20, 255 }); DrawTextEx(customFont, "CHECKING FOR UPDATES...", (Vector2){ (float)currentWidth/2 - 150, (float)currentHeight/2 - 20 }, 24, 1.0f, WHITE); - // Simulate check (2 seconds) + // Perform real check after 1 second + if (updateTimer > 1.0f && latestVersion == "") { + latestVersion = GetRemoteVersion(); + if (latestVersion != "error" && latestVersion != localVersion) { + updateReady = true; + } + } + if (updateTimer > 2.0f) { - // Update check logic: Only show if remote version > local version - // For now, we are at v1.9.1, so we set to false. - updateReady = false; if (updateReady) currentState = UPDATE_FOUND; else currentState = MAIN_MENU; } @@ -1216,7 +1246,8 @@ int main(void) DrawRectangleLinesEx(pBox, 4.0f, GREEN); DrawTextEx(customFont, "NEW VERSION AVAILABLE!", (Vector2){ pBox.x + 40, pBox.y + 30 }, 24, 1.0f, GREEN); - DrawTextEx(customFont, "v1.9.1 is now ready for download.", (Vector2){ pBox.x + 40, pBox.y + 70 }, 18, 1.0f, LIGHTGRAY); + std::string updMsg = latestVersion + " is now ready for download."; + DrawTextEx(customFont, updMsg.c_str(), (Vector2){ pBox.x + 40, pBox.y + 70 }, 18, 1.0f, LIGHTGRAY); // Update Button Rectangle updBtn = { pBox.x + 40, pBox.y + 120, 370, 40 }; diff --git a/version.txt b/version.txt index 295e37c..ba1e8bf 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v1.9.0 +v1.9.1