diff --git a/GameEngine/Admin/Mods/config_template.php b/GameEngine/Admin/Mods/config_template.php index 2eae36b1..4b0f3d93 100644 --- a/GameEngine/Admin/Mods/config_template.php +++ b/GameEngine/Admin/Mods/config_template.php @@ -340,6 +340,63 @@ if (!function_exists('admin_config_template_path')) { $text = str_replace($placeholder, (string) $value, $text); } + /** + * PLASA DE SIGURANTA: orice placeholder ramas se rezolva din constanta + * pe care o defineste chiar linia lui. + * + * De ce e nevoie: fiecare pagina din panou regenereaza INTREG config.php + * din acelasi sablon, dar rezolva doar setarile ei. O setare noua, + * tratata de un singur modul, ramanea literala cand salvai din alta + * pagina: + * define("NEW_FUNCTIONS_ALLIANCE_BONUSES", %ALLIANCEBONUSES%); + * adica eroare de parsare si 500 pe tot serverul, pana la reparare + * manuala a fisierului. Ni s-a intamplat de trei ori: %GP%, + * %ALLIANCEBONUSES% si %NATARS_WW_START_DELAY%. + * + * Listele de mai sus raman - sunt explicite si mai lizibile. Blocul asta + * prinde ce scapa, ca urmatoarea setare adaugata sa nu mai poata sparge + * serverul. Ruleaza ULTIMUL, deci nu suprascrie nimic rezolvat inainte. + */ + if (preg_match_all('/^\s*define\(\s*["\']([A-Z0-9_]+)["\']\s*,\s*(.*?%[A-Z0-9_]+%.*?)\s*\)\s*;/m', + $text, $leftovers, PREG_SET_ORDER)) { + + foreach ($leftovers as $row) { + $constant = $row[1]; + + if (!preg_match('/%[A-Z0-9_]+%/', $row[2], $ph)) { + continue; + } + + if (!defined($constant)) { + // Constanta nu exista inca (prima instalare, sau setare noua + // adaugata in sablon dar nu si in config-ul curent). Punem o + // valoare neutra, ca fisierul sa ramana PHP valid. + $value = 'false'; + } else { + $current = constant($constant); + + if (is_bool($current)) { + $value = $current ? 'true' : 'false'; + } elseif (is_int($current) || is_float($current)) { + $value = (string) $current; + } else { + // Sir: pastram ghilimelele din sablon daca exista deja, + // altfel le adaugam noi. + $quoted = (strpos($row[2], '"' . $ph[0] . '"') !== false) + || (strpos($row[2], "'" . $ph[0] . "'") !== false); + + $safe = addcslashes((string) $current, "\"\\\$"); + $value = $quoted ? $safe : '"' . $safe . '"'; + } + } + + $text = str_replace($ph[0], $value, $text); + + error_log('[TravianZ] config: placeholder ' . $ph[0] + . ' nerezolvat de niciun modul, completat din ' . $constant); + } + } + return $text; } } diff --git a/GameEngine/HeroItems.php b/GameEngine/HeroItems.php index f3b1ae30..f087cc40 100644 --- a/GameEngine/HeroItems.php +++ b/GameEngine/HeroItems.php @@ -670,6 +670,107 @@ class HeroItems return self::USE_OK; } + /* ---- Bandaje: readuc in viata o parte din trupele ranite ---- */ + if (isset($bonus[HB_HEAL_TROOP])) { + + /** + * Bandajele scot trupe din spital si le pun inapoi in sat. + * + * Un bandaj vindeca un procent din raniti (25% cel mic, 33% cel + * mare). Se aplica pe satul in care e folosit itemul, deci + * jucatorul alege unde conteaza. + * + * Se consuma DOAR daca a avut ce vindeca - altfel itemul s-ar + * pierde degeaba. + */ + global $database; + + $vid = (int) $vid; + + if ($vid <= 0) { + return self::USE_INVALID; + } + + // satul trebuie sa fie al jucatorului + $owner = (int) $database->getVillageField($vid, 'owner'); + + if ($owner !== (int) $uid) { + return self::USE_INVALID; + } + + $wounded = $database->getWounded($vid); + + if (!$wounded) { + return self::USE_INVALID; + } + + $pct = max(1, min(100, (int) $bonus[HB_HEAL_TROOP])); + $units = array(); + $heals = array(); + $total = 0; + + for ($i = 1; $i <= 90; $i++) { + $have = isset($wounded['u' . $i]) ? (int) $wounded['u' . $i] : 0; + + if ($have <= 0) { + continue; + } + + // cel putin unul, daca exista raniti de tipul asta + $heal = max(1, (int) floor($have * $pct / 100)); + $heal = min($heal, $have); + + $units[] = $i; + $heals[] = $heal; + $total += $heal; + } + + if ($total <= 0) { + return self::USE_INVALID; + } + + // scoatem din spital si punem in sat, intr-o tranzactie + mysqli_query($this->db, "START TRANSACTION"); + + $ok = true; + + foreach ($units as $k => $u) { + $q = "UPDATE " . TB_PREFIX . "hospital + SET u" . (int) $u . " = GREATEST(0, u" . (int) $u . " - " . (int) $heals[$k] . ") + WHERE vref = " . $vid . " LIMIT 1"; + + if (!mysqli_query($this->db, $q)) { + $ok = false; + break; + } + + $q2 = "UPDATE " . TB_PREFIX . "units + SET u" . (int) $u . " = u" . (int) $u . " + " . (int) $heals[$k] . " + WHERE vref = " . $vid . " LIMIT 1"; + + if (!mysqli_query($this->db, $q2)) { + $ok = false; + break; + } + } + + if (!$ok) { + mysqli_query($this->db, "ROLLBACK"); + + error_log('[TravianZ] bandaj: vindecarea a esuat: ' + . mysqli_error($this->db)); + + return self::USE_INVALID; + } + + mysqli_query($this->db, "COMMIT"); + + // un bandaj per folosire: procentul se aplica o singura data + $this->removeItem($uid, $rowId, 1); + + return self::USE_OK; + } + /* ---- Scroll: +10 XP each ---- */ if (isset($bonus[HB_SCROLL])) { $hero = $this->getLivingHeroRow($uid); diff --git a/GameEngine/Lang/en.php b/GameEngine/Lang/en.php index 93e01cac..aa10ebcc 100755 --- a/GameEngine/Lang/en.php +++ b/GameEngine/Lang/en.php @@ -4317,7 +4317,7 @@ tz_def('TZ_WS_VS_NATARS', 'Against Natars'); ////////////////////////////////////////////////////////////////////////////////////////////////////// // MESAJ DE SISTEM - previzualizare ////////////////////////////////////////////////////////////////////////////////////////////////////// -tz_def('ADM_PREVIEW', 'Preview'); +tz_def('ADM_PREVIEW', 'Previzualizare'); ////////////////////////////////////////////////////////////////////////////////////////////////////// // REGULI DE INREGISTRARE (Server Configuration) @@ -4328,3 +4328,8 @@ tz_def('CONF_SERV_PW_MIN', 'Minimum password length'); tz_def('CONF_SERV_USRNM_SPECIAL', 'Allow . - _ in usernames'); tz_def('CONF_SERV_USRNM_SPECIAL_TOOLTIP', 'With True, usernames may contain a dot, hyphen or underscore, and single spaces between words. With False, only letters and digits are accepted.'); tz_def('CONF_SERV_REGRULES_TOOLTIP', 'Rules checked when a player registers. Changing them does not affect existing accounts.'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// STATISTICI - sectiunea de alianta +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('PLUSSTATS_ALLIANCE', 'Your alliance'); diff --git a/GameEngine/Lang/fr.php b/GameEngine/Lang/fr.php index f24243ba..a50a378d 100644 --- a/GameEngine/Lang/fr.php +++ b/GameEngine/Lang/fr.php @@ -4271,3 +4271,8 @@ tz_def('CONF_SERV_PW_MIN', 'Longueur minimale du mot de passe'); tz_def('CONF_SERV_USRNM_SPECIAL', 'Autoriser . - _ dans les noms'); tz_def('CONF_SERV_USRNM_SPECIAL_TOOLTIP', 'Avec True, les noms peuvent contenir un point, un tiret ou un underscore, et des espaces simples entre les mots. Avec False, seules les lettres et les chiffres sont acceptes.'); tz_def('CONF_SERV_REGRULES_TOOLTIP', 'Regles verifiees lors de l\'inscription. Les modifier n\'affecte pas les comptes existants.'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// STATISTICI - sectiunea de alianta +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('PLUSSTATS_ALLIANCE', 'Votre alliance'); diff --git a/GameEngine/Lang/ro.php b/GameEngine/Lang/ro.php index dfbee255..be9295d0 100644 --- a/GameEngine/Lang/ro.php +++ b/GameEngine/Lang/ro.php @@ -4068,3 +4068,8 @@ tz_def('CONF_SERV_PW_MIN', 'Lungimea minima a parolei'); tz_def('CONF_SERV_USRNM_SPECIAL', 'Permite . - _ in nume'); tz_def('CONF_SERV_USRNM_SPECIAL_TOOLTIP', 'Cu True, numele pot contine punct, liniuta sau underscore, si spatii simple intre cuvinte. Cu False, se accepta doar litere si cifre.'); tz_def('CONF_SERV_REGRULES_TOOLTIP', 'Reguli verificate la inregistrare. Schimbarea lor nu afecteaza conturile existente.'); + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// STATISTICI - sectiunea de alianta +////////////////////////////////////////////////////////////////////////////////////////////////////// +tz_def('PLUSSTATS_ALLIANCE', 'Alianta ta'); diff --git a/Templates/Ranking/statistics.tpl b/Templates/Ranking/statistics.tpl index 3b5ffb84..f22c87e7 100644 --- a/Templates/Ranking/statistics.tpl +++ b/Templates/Ranking/statistics.tpl @@ -258,6 +258,80 @@ echo '