From d2a3fb3aa739d2e0adf8e9bb52ae5d832a893d46 Mon Sep 17 00:00:00 2001 From: hdmaniak Date: Fri, 27 Mar 2026 10:45:31 +0100 Subject: [PATCH 1/5] Fix hero bonus race condition using atomic SQL --- Templates/Build/37_hero.tpl | 88 ++++++++++++++----------------------- 1 file changed, 33 insertions(+), 55 deletions(-) diff --git a/Templates/Build/37_hero.tpl b/Templates/Build/37_hero.tpl index e1604786..bf0580b8 100644 --- a/Templates/Build/37_hero.tpl +++ b/Templates/Build/37_hero.tpl @@ -125,60 +125,38 @@ if (isset($_POST['name']) && !empty($_POST['name'])) { dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = '".(($hero_info['level']*5)+5)."' WHERE `heroid` = " . $hero_info['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attack` = '0' WHERE `heroid` = " . $hero_info['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defence` = '0' WHERE `heroid` = " . $hero_info['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = '0' WHERE `heroid` = " . $hero_info['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = '0' WHERE `heroid` = " . $hero_info['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `regeneration` = '0' WHERE `heroid` = " . $hero_info['heroid']); + if(isset($_GET['add'])) { + if($_GET['add'] == "reset") { + if($hero_info['level'] <= 3){ + mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = (`level` * 5) + 5, `attack` = 0, `defence` = 0, `attackbonus` = 0, `defencebonus` = 0, `regeneration` = 0 WHERE `heroid` = " . $hero_info['heroid'] . " AND `level` <= 3 AND (`attack` != 0 OR `defence` != 0 OR `attackbonus` != 0 OR `defencebonus` != 0 OR `regeneration` != 0)"); header("Location: build.php?id=".$id.""); - exit; - } - } - } - if($_GET['add'] == "off" && $hero_info['attack'] < 100) { - if($hero_info['points'] > 0) { - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attack` = `attack` + 1 WHERE `heroid` = " . $hero_info['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']); - header("Location: build.php?id=".$id.""); - exit; - } - } - if($_GET['add'] == "deff" && $hero_info['defence'] < 100) { - if($hero_info['points'] > 0) { - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defence` = `defence` + 1 WHERE `heroid` = " . $hero_info['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']); - header("Location: build.php?id=".$id.""); - exit; - } - } - if($_GET['add'] == "obonus" && $hero_info['attackbonus'] < 100) { - if($hero_info['points'] > 0) { - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = `attackbonus` + 1 WHERE `heroid` = " . $hero_info['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']); - header("Location: build.php?id=".$id.""); - exit; - } - } - if($_GET['add'] == "dbonus" && $hero_info['defencebonus'] < 100) { - if($hero_info['points'] > 0) { - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = `defencebonus` + 1 WHERE `heroid` = " . $hero_info['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']); - header("Location: build.php?id=".$id.""); - exit; - } - } - if($_GET['add'] == "reg" && $hero_info['regeneration'] < 100) { - if($hero_info['points'] > 0) { - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `regeneration` = `regeneration` + 1 WHERE `heroid` = " . $hero_info['heroid']); - mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']); - header("Location: build.php?id=".$id.""); - exit; - } - } - } + exit; + } + } + if($_GET['add'] == "off") { + mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attack` = `attack` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `attack` < 100"); + header("Location: build.php?id=".$id.""); + exit; + } + if($_GET['add'] == "deff") { + mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defence` = `defence` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `defence` < 100"); + header("Location: build.php?id=".$id.""); + exit; + } + if($_GET['add'] == "obonus") { + mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = `attackbonus` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `attackbonus` < 100"); + header("Location: build.php?id=".$id.""); + exit; + } + if($_GET['add'] == "dbonus") { + mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = `defencebonus` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `defencebonus` < 100"); + header("Location: build.php?id=".$id.""); + exit; + } + if($_GET['add'] == "reg") { + mysqli_query($database->dblink,"UPDATE " . TB_PREFIX . "hero SET `regeneration` = `regeneration` + 1, `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid'] . " AND `points` > 0 AND `regeneration` < 100"); + header("Location: build.php?id=".$id.""); + exit; + } + } ?> From f1cacbc5c363e95204cd919e6adcd46a07cbff6d Mon Sep 17 00:00:00 2001 From: Catalin Novgorodschi <1140613+Shadowss@users.noreply.github.com> Date: Thu, 2 Apr 2026 14:25:35 +0300 Subject: [PATCH 2/5] Update version.tpl --- Templates/version.tpl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Templates/version.tpl b/Templates/version.tpl index 9c427f68..ba39d9e3 100644 --- a/Templates/version.tpl +++ b/Templates/version.tpl @@ -1,10 +1,3 @@
-

©️ Credits & Acknowledgements

-

Standing on the shoulders of giants.

-

- Our project is a continuation and adaptation of a classic game emulator. - We owe immense gratitude to the original developers who paved the way. - Their foundational work has been invaluable in creating this experience. -

From 20389b84aab6dde909a069d69e5f7aadbd30b6ca Mon Sep 17 00:00:00 2001 From: Catalin Novgorodschi <1140613+Shadowss@users.noreply.github.com> Date: Thu, 2 Apr 2026 14:33:49 +0300 Subject: [PATCH 3/5] Update version.php --- version.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/version.php b/version.php index 1e677a0e..33213c08 100644 --- a/version.php +++ b/version.php @@ -78,10 +78,10 @@ else $building->procBuild($_GET); "> Date: Thu, 2 Apr 2026 14:47:34 +0300 Subject: [PATCH 4/5] Update footer.tpl --- Templates/footer.tpl | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Templates/footer.tpl b/Templates/footer.tpl index db54b8e7..1f8d94c0 100644 --- a/Templates/footer.tpl +++ b/Templates/footer.tpl @@ -11,21 +11,22 @@ ## License: TravianZ Project ## ## Copyright: TravianZ (c) 2010-2014. All rights reserved. ## ## URLs: http://travian.shadowss.ro ## -## Source code: http://github.com/Shadowss/TravianZ-by-Shadow/ ## +## Source code: http://github.com/Shadowss/TravianZ/ ## ## ## ################################################################################# ?> From 93e8abc3659fdbb91a8c6f47937c345174351499 Mon Sep 17 00:00:00 2001 From: Catalin Novgorodschi <1140613+Shadowss@users.noreply.github.com> Date: Thu, 2 Apr 2026 15:00:29 +0300 Subject: [PATCH 5/5] Update version.php --- version.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/version.php b/version.php index 33213c08..4ce3b202 100644 --- a/version.php +++ b/version.php @@ -117,7 +117,8 @@ $developers = [ ["AL-Kateb", "Alumni Developer"], ["hdmaniak2", " Active Developer"], ["newtcv", " Active Developer"], - ["AlinV2V", " Active Developer"] + ["AlinV2V", " Active Developer"], + ["lietuvis10", " Active Developer"] ]; // Primele 9 carduri normale