Implement real update check and sync version v1.9.1

This commit is contained in:
Michael Howard 2026-04-23 16:58:47 -05:00
parent ba136f5784
commit a96e983ef8
6 changed files with 40 additions and 7 deletions

Binary file not shown.

View File

@ -0,0 +1 @@
v1.9.1

Binary file not shown.

View File

@ -0,0 +1 @@
v1.9.1

View File

@ -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 };

View File

@ -1 +1 @@
v1.9.0
v1.9.1