mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-02 10:34:31 +00:00
Added Milestone On Install
Added Milestone On Install
This commit is contained in:
@@ -70,6 +70,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$NEW_FUNCTIONS_MEDAL_5YEAR = (NEW_FUNCTIONS_MEDAL_5YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MEDAL_10YEAR = (NEW_FUNCTIONS_MEDAL_10YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM = (NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MILESTONES = (NEW_FUNCTIONS_MILESTONES == false ? 'false' : 'true');
|
||||
|
||||
$text = file_get_contents("constant_format.tpl");
|
||||
$text = preg_replace("'%ERRORREPORT%'", $ERRORREPORT, $text);
|
||||
@@ -161,6 +162,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_5YEAR%'", $NEW_FUNCTIONS_MEDAL_5YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_10YEAR%'", $NEW_FUNCTIONS_MEDAL_10YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM%'", $NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MILESTONES%'", $NEW_FUNCTIONS_MILESTONES, $text);
|
||||
|
||||
// PLUS settings need to be kept intact
|
||||
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
|
||||
|
||||
@@ -69,6 +69,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$NEW_FUNCTIONS_MEDAL_5YEAR = (NEW_FUNCTIONS_MEDAL_5YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MEDAL_10YEAR = (NEW_FUNCTIONS_MEDAL_10YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM = (NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MILESTONES = (NEW_FUNCTIONS_MILESTONES == false ? 'false' : 'true');
|
||||
|
||||
$text = file_get_contents("constant_format.tpl");
|
||||
$text = preg_replace("'%ERRORREPORT%'", ERROR_REPORT, $text);
|
||||
@@ -158,6 +159,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_5YEAR%'", $NEW_FUNCTIONS_MEDAL_5YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_10YEAR%'", $NEW_FUNCTIONS_MEDAL_10YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM%'", $NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MILESTONES%'", $NEW_FUNCTIONS_MILESTONES, $text);
|
||||
|
||||
// PLUS settings need to be kept intact
|
||||
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
|
||||
|
||||
@@ -65,6 +65,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$NEW_FUNCTIONS_MEDAL_5YEAR = (NEW_FUNCTIONS_MEDAL_5YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MEDAL_10YEAR = (NEW_FUNCTIONS_MEDAL_10YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM = (NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MILESTONES = (NEW_FUNCTIONS_MILESTONES == false ? 'false' : 'true');
|
||||
|
||||
$text = file_get_contents("constant_format.tpl");
|
||||
$text = preg_replace("'%ERRORREPORT%'", $ERRORREPORT, $text);
|
||||
@@ -158,6 +159,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_5YEAR%'", $NEW_FUNCTIONS_MEDAL_5YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_10YEAR%'", $NEW_FUNCTIONS_MEDAL_10YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM%'", $NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MILESTONES%'", $NEW_FUNCTIONS_MILESTONES, $text);
|
||||
|
||||
// PLUS settings need to be kept intact
|
||||
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
|
||||
|
||||
@@ -127,6 +127,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_5YEAR%'", $_POST['new_functions_medal_5year'], $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_10YEAR%'", $_POST['new_functions_medal_10year'], $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM%'", $_POST['new_functions_special_medals_system'], $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MILESTONES%'", $_POST['new_functions_milestones'], $text);
|
||||
|
||||
// PLUS settings need to be kept intact
|
||||
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
|
||||
|
||||
@@ -71,6 +71,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$NEW_FUNCTIONS_MEDAL_5YEAR = (NEW_FUNCTIONS_MEDAL_5YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MEDAL_10YEAR = (NEW_FUNCTIONS_MEDAL_10YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM = (NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MILESTONES = (NEW_FUNCTIONS_MILESTONES == false ? 'false' : 'true');
|
||||
|
||||
$text = file_get_contents("constant_format.tpl");
|
||||
$text = preg_replace("'%ERRORREPORT%'", $ERRORREPORT, $text);
|
||||
@@ -164,6 +165,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_5YEAR%'", $NEW_FUNCTIONS_MEDAL_5YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_10YEAR%'", $NEW_FUNCTIONS_MEDAL_10YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM%'", $NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MILESTONES%'", $NEW_FUNCTIONS_MILESTONES, $text);
|
||||
|
||||
// PLUS settings need to be kept intact
|
||||
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
|
||||
|
||||
@@ -53,6 +53,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$NEW_FUNCTIONS_MEDAL_5YEAR = (NEW_FUNCTIONS_MEDAL_5YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MEDAL_10YEAR = (NEW_FUNCTIONS_MEDAL_10YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM = (NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MILESTONES = (NEW_FUNCTIONS_MILESTONES == false ? 'false' : 'true');
|
||||
|
||||
// SERVER SETTINGS - we need to keep these intact
|
||||
$text = preg_replace("'%ERRORREPORT%'", ERROR_REPORT, $text);
|
||||
@@ -142,6 +143,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_5YEAR%'", $NEW_FUNCTIONS_MEDAL_5YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_10YEAR%'", $NEW_FUNCTIONS_MEDAL_10YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM%'", $NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MILESTONES%'", $NEW_FUNCTIONS_MILESTONES, $text);
|
||||
|
||||
// PLUS SETTINGS
|
||||
$text = preg_replace("'%PLUS_TIME%'", $_POST['plus_time'], $text);
|
||||
|
||||
@@ -64,6 +64,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$NEW_FUNCTIONS_MEDAL_5YEAR = (NEW_FUNCTIONS_MEDAL_5YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MEDAL_10YEAR = (NEW_FUNCTIONS_MEDAL_10YEAR == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM = (NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM == false ? 'false' : 'true');
|
||||
$NEW_FUNCTIONS_MILESTONES = (NEW_FUNCTIONS_MILESTONES == false ? 'false' : 'true');
|
||||
|
||||
$text = file_get_contents("constant_format.tpl");
|
||||
$text = preg_replace("'%ERRORREPORT%'", $_POST['error'], $text);
|
||||
@@ -153,6 +154,7 @@ $fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: GameEngine\con
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_5YEAR%'", $NEW_FUNCTIONS_MEDAL_5YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MEDAL_10YEAR%'", $NEW_FUNCTIONS_MEDAL_10YEAR, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM%'", $NEW_FUNCTIONS_SPECIAL_MEDALS_SYSTEM, $text);
|
||||
$text = preg_replace("'%NEW_FUNCTIONS_MILESTONES%'", $NEW_FUNCTIONS_MILESTONES, $text);
|
||||
|
||||
// PLUS settings need to be kept intact
|
||||
$text = preg_replace("'%PLUS_TIME%'", PLUS_TIME, $text);
|
||||
|
||||
@@ -403,6 +403,12 @@ class Alliance {
|
||||
}
|
||||
$maxMembers = $bid18[$building->getTypeLevel(18)]['attri'];
|
||||
$aid = $database->createAlliance($tag, $name, $session->uid, $maxMembers);
|
||||
|
||||
// Milestone: first alliance ever founded on the server.
|
||||
if (defined('NEW_FUNCTIONS_MILESTONES') && NEW_FUNCTIONS_MILESTONES) {
|
||||
$database->recordMilestoneIfFirst('first_alliance', $session->uid, 0, $tag . ' - ' . $name);
|
||||
}
|
||||
|
||||
$database->updateUserField($session->uid, "alliance", $aid, 1);
|
||||
$database->procAllyPop($aid);
|
||||
$database->createAlliPermissions($session->uid, $aid, 'Alliance founder', '1', '1', '1', '1', '1', '1', '1', '1');
|
||||
|
||||
@@ -152,6 +152,23 @@ class Automation {
|
||||
$q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
|
||||
mysqli_query($database->dblink, $q);
|
||||
$owner = $database->getVillageField($vid, "owner");
|
||||
|
||||
// Milestone: first player ever to reach 1000 total population,
|
||||
// summed across all their villages. recountPop() is the single
|
||||
// funnel every population-changing event (building, demolishing,
|
||||
// founding/conquering a village) already passes through, so this
|
||||
// is the one place that's guaranteed to catch the threshold being
|
||||
// crossed regardless of which village/action caused it.
|
||||
// Excludes owner 3 (Natars) — see Artifacts::NATARS_UID — same
|
||||
// convention already used elsewhere in this file (e.g. the
|
||||
// "fix natar report by ronix" check a few hundred lines below).
|
||||
if (defined('NEW_FUNCTIONS_MILESTONES') && NEW_FUNCTIONS_MILESTONES && $owner > 0 && $owner != 3) {
|
||||
$totalPop = (int) $database->getVSumField($owner, 'pop', false);
|
||||
if ($totalPop >= 1000) {
|
||||
$database->recordMilestoneIfFirst('population_1000', $owner, $vid);
|
||||
}
|
||||
}
|
||||
|
||||
$this->procClimbers($owner);
|
||||
|
||||
return $popTot;
|
||||
@@ -1304,6 +1321,23 @@ class Automation {
|
||||
}
|
||||
|
||||
$database->setVillageFields($data['to'], ['loyalty', 'owner'], [0, $database->getVillageField($data['from'], 'owner')]);
|
||||
|
||||
// Milestones: first WW village ever conquered, and — separately —
|
||||
// first village ever conquered FROM ANOTHER PLAYER (not from
|
||||
// Natars). $to is this function's own parameter (not re-fetched),
|
||||
// so $to['natar']/$to['owner'] still reflect the village's state
|
||||
// from BEFORE this conquest, which is exactly what we need here.
|
||||
// natar==1 marks one of the 13 pre-built WW conquest targets (see
|
||||
// Artifacts::createWWVillages()) — Natars' capital and artifact/
|
||||
// plan villages are natar=0, so this check cannot misfire on those.
|
||||
if (defined('NEW_FUNCTIONS_MILESTONES') && NEW_FUNCTIONS_MILESTONES) {
|
||||
$newOwner = $database->getVillageField($data['from'], 'owner');
|
||||
if ((int)($to['natar'] ?? 0) === 1) {
|
||||
$database->recordMilestoneIfFirst('first_ww', $newOwner, $data['to']);
|
||||
} elseif ((int)($to['owner'] ?? 0) !== 3) {
|
||||
$database->recordMilestoneIfFirst('first_pvp_conquest', $newOwner, $data['to']);
|
||||
}
|
||||
}
|
||||
|
||||
$database->query("DELETE FROM " . TB_PREFIX . "abdata WHERE vref = " . (int)$data['to']);
|
||||
$database->addABTech($data['to']);
|
||||
@@ -3790,6 +3824,15 @@ class Automation {
|
||||
// Report: new village founded (issue #178)
|
||||
$ncoor = $database->getCoor($data['to']);
|
||||
$database->addNotice($to['owner'], $data['to'], 0, 24, 'New village founded', ($ncoor['x'] ?? 0) . ',' . ($ncoor['y'] ?? 0), time());
|
||||
|
||||
// Milestone: first player ever to settle their 2nd village.
|
||||
// Checked right after the new village row exists, so the
|
||||
// COUNT below already includes it.
|
||||
if (defined('NEW_FUNCTIONS_MILESTONES') && NEW_FUNCTIONS_MILESTONES) {
|
||||
if ($database->countVillages($to['owner']) == 2) {
|
||||
$database->recordMilestoneIfFirst('second_village', $to['owner'], $data['to']);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// here must come movement from returning settlers
|
||||
$types[] = 4;
|
||||
|
||||
+114
-31
@@ -7854,6 +7854,78 @@ References: User ID/Message ID, Mode
|
||||
|
||||
return $cachedData[$vref];
|
||||
}
|
||||
|
||||
/**
|
||||
* =====================================================================
|
||||
* SERVER MILESTONES (NEW_FUNCTIONS_MILESTONES)
|
||||
* =====================================================================
|
||||
* "First player on the server to..." achievements. Each milestone_key
|
||||
* is recorded AT MOST ONCE, ever — the table's UNIQUE KEY on
|
||||
* milestone_key does the actual "first wins" enforcement at the DB
|
||||
* level via INSERT IGNORE, so this is race-condition-safe even if two
|
||||
* players' actions are processed in the same cron batch: only one
|
||||
* INSERT can ever succeed for a given key, no matter how many
|
||||
* processes attempt it concurrently.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Attempts to record a milestone. Only the very first call for a given
|
||||
* $key across the server's lifetime actually stores anything.
|
||||
*
|
||||
* @param string $key Unique milestone identifier, e.g. 'second_village'
|
||||
* @param int $uid The user who achieved it
|
||||
* @param int $vref The village where it happened (0 if not applicable)
|
||||
* @param string $extra Optional free-form context (e.g. alliance name)
|
||||
* @return bool true if THIS call is the one that recorded the milestone
|
||||
*/
|
||||
function recordMilestoneIfFirst($key, $uid, $vref = 0, $extra = '') {
|
||||
list($key, $extra) = $this->escape_input((string) $key, (string) $extra);
|
||||
list($uid, $vref) = [(int) $uid, (int) $vref];
|
||||
|
||||
$time = time();
|
||||
$q = "INSERT IGNORE INTO " . TB_PREFIX . "milestones (milestone_key, uid, vref, extra, achieved_time)
|
||||
VALUES ('$key', $uid, $vref, '$extra', $time)";
|
||||
mysqli_query($this->dblink, $q);
|
||||
|
||||
return mysqli_affected_rows($this->dblink) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array All recorded milestones, keyed by milestone_key, each
|
||||
* row enriched with the achiever's username and (if
|
||||
* applicable) the village name.
|
||||
*/
|
||||
function getMilestones() {
|
||||
$q = "SELECT m.milestone_key, m.uid, m.vref, m.extra, m.achieved_time,
|
||||
u.username, v.name AS village_name
|
||||
FROM " . TB_PREFIX . "milestones m
|
||||
LEFT JOIN " . TB_PREFIX . "users u ON u.id = m.uid
|
||||
LEFT JOIN " . TB_PREFIX . "vdata v ON v.wref = m.vref";
|
||||
$result = mysqli_query($this->dblink, $q);
|
||||
$rows = $this->mysqli_fetch_all($result);
|
||||
|
||||
$byKey = [];
|
||||
foreach ($rows as $row) {
|
||||
$byKey[$row['milestone_key']] = $row;
|
||||
}
|
||||
return $byKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uid
|
||||
* @return int How many villages this user currently owns. Deliberately
|
||||
* uncached (always a fresh COUNT) since it's used right
|
||||
* after a village INSERT to decide a one-time milestone.
|
||||
*/
|
||||
function countVillages($uid) {
|
||||
list($uid) = $this->escape_input((int) $uid);
|
||||
|
||||
$q = "SELECT COUNT(*) AS total FROM " . TB_PREFIX . "vdata WHERE owner = $uid";
|
||||
$result = mysqli_query($this->dblink, $q);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
|
||||
return $row ? (int) $row['total'] : 0;
|
||||
}
|
||||
|
||||
function claimArtefact($vref, $ovref, $id) {
|
||||
list($vref, $ovref, $id) = $this->escape_input((int) $vref, (int) $ovref, (int) $id);
|
||||
@@ -7863,7 +7935,23 @@ References: User ID/Message ID, Mode
|
||||
|
||||
if(mysqli_query($this->dblink, $q))
|
||||
{
|
||||
$artifactID = reset($this->getOwnArtefactInfo($vref, false))['id'];
|
||||
$artifactInfo = reset($this->getOwnArtefactInfo($vref, false));
|
||||
$artifactID = $artifactInfo['id'];
|
||||
|
||||
// Milestones: first artifact EVER captured by any player (any
|
||||
// type, including the WW Building Plan), and — separately —
|
||||
// the first WW Building Plan (artefacts.type == 11) specifically.
|
||||
// claimArtefact() is the single function that transfers artifact
|
||||
// ownership (both the "conquer the artifact's own village" path
|
||||
// and the "hero carries it home" path call this), so hooking
|
||||
// here covers every capture route with no risk of missing one.
|
||||
if (defined('NEW_FUNCTIONS_MILESTONES') && NEW_FUNCTIONS_MILESTONES) {
|
||||
$this->recordMilestoneIfFirst('first_artifact', $id, $vref);
|
||||
if ((int)($artifactInfo['type'] ?? 0) === 11) {
|
||||
$this->recordMilestoneIfFirst('first_ww_plan', $id, $vref);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addArtifactsChronology($artifactID, $id, $vref, $time);
|
||||
}
|
||||
else return false;
|
||||
@@ -8985,39 +9073,34 @@ References: User ID/Message ID, Mode
|
||||
* @return bool Return true if the query was successful, false otherwise
|
||||
*/
|
||||
|
||||
function changeCapital($wref, $mode = 1) {
|
||||
list($wref, $mode) = $this->escape_input($wref, $mode);
|
||||
function changeCapital($wref, $mode = 1){
|
||||
list($wref, $mode) = $this->escape_input($wref, $mode);
|
||||
|
||||
$wref = (int)$wref;
|
||||
$mode = (int)$mode;
|
||||
if ($mode == 1) {
|
||||
// Bug fix: this function only ever did `SET capital = $mode WHERE
|
||||
// wref = $wref` — it set the NEW capital's flag but never cleared
|
||||
// any OTHER village belonging to the same owner that was already
|
||||
// flagged capital = 1. Nothing enforces uniqueness at the schema
|
||||
// level (no UNIQUE key on owner+capital), so after any capital
|
||||
// change that doesn't delete the old village, the owner was left
|
||||
// with two (or more) rows with capital = 1. This was harmless for
|
||||
// years because nothing queried "owner=X AND capital=1" expecting
|
||||
// a single row — until getVillage(..., 3) (added for the Brewery
|
||||
// Mead-Festival empire-wide bonus lookup) started relying on that
|
||||
// invariant, at which point a stale duplicate could be the row
|
||||
// returned (no ORDER BY / LIMIT 1 on an ambiguous match), silently
|
||||
// pointing Brewery's bonus/penalty checks at the wrong village.
|
||||
$owner = $this->getVillageField($wref, 'owner');
|
||||
if ($owner !== false && $owner !== null) {
|
||||
$owner = (int) $owner;
|
||||
$q = "UPDATE " . TB_PREFIX . "vdata SET capital = 0 WHERE owner = $owner AND wref != $wref";
|
||||
mysqli_query($this->dblink, $q);
|
||||
}
|
||||
}
|
||||
|
||||
// We retrieve the owner of the current village.
|
||||
$owner = (int)$this->getVillageField($wref, 'owner');
|
||||
|
||||
if ($owner <= 0) {
|
||||
return false;
|
||||
$q = "UPDATE ".TB_PREFIX."vdata SET capital = ".$mode." WHERE wref = $wref";
|
||||
return mysqli_query($this->dblink, $q);
|
||||
}
|
||||
|
||||
// if we are setting a new capital
|
||||
if ($mode == 1) {
|
||||
|
||||
// 1. We reset ALL capitals of that owner (VERY fast)
|
||||
mysqli_query(
|
||||
$this->dblink,
|
||||
"UPDATE " . TB_PREFIX . "vdata
|
||||
SET capital = 0
|
||||
WHERE owner = $owner"
|
||||
);
|
||||
}
|
||||
|
||||
// 2. we set the new capital
|
||||
return mysqli_query(
|
||||
$this->dblink,
|
||||
"UPDATE " . TB_PREFIX . "vdata
|
||||
SET capital = $mode
|
||||
WHERE wref = $wref"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2315,6 +2315,17 @@ tz_def('TZ_YOUR_VILLAGE_AND_YOUR_NEIGHBOURS', 'Your village and your neighbours'
|
||||
tz_def('TZ_YOU_CAN_UNDO_THE_REGISTRATION_AND', 'You can undo the registration and re-register with a');
|
||||
tz_def('TZ_YOU_CAN_USE_THIS_GOLD_FOR_PLUS_OR', '. You can use this gold for Plus or any gold advantage.');
|
||||
|
||||
// ===== Server Milestones (NEW_FUNCTIONS_MILESTONES) =====
|
||||
tz_def('TZ_SERVER_MILESTONES', 'Server Milestones');
|
||||
tz_def('TZ_MILESTONE_NOT_YET', 'Not yet achieved');
|
||||
tz_def('TZ_MILESTONE_SECOND_VILLAGE', 'First to Settle a 2nd Village');
|
||||
tz_def('TZ_MILESTONE_POPULATION_1000', 'First to reach 1,000 Population');
|
||||
tz_def('TZ_MILESTONE_FIRST_ARTIFACT', 'First to Capture an Artefact');
|
||||
tz_def('TZ_MILESTONE_FIRST_WW', 'First to Conquer a Wonder of the World');
|
||||
tz_def('TZ_MILESTONE_FIRST_WW_PLAN', 'First to Conquer a WW Building Plan');
|
||||
tz_def('TZ_MILESTONE_FIRST_ALLIANCE', 'First Alliance Founded');
|
||||
tz_def('TZ_MILESTONE_FIRST_PVP_CONQUEST', 'First Village Conquered from a Player');
|
||||
|
||||
// ===== i18n etape 2 (lot suivant) =====
|
||||
tz_def('TZ_ACCOUNT_OR_INCREASE_YOUR_RESOURCE', '-Account or increase your resource production.To do so click');
|
||||
tz_def('TZ_ADDITIONALLY_THE_TRAVIAN_TEAM_WILL', 'Additionally, the Travian Team will not provide information concerning bans to any person, other than the account owner.');
|
||||
|
||||
@@ -2604,4 +2604,15 @@ define('MANUAL_NF_D_23', "Médaille décernée aux joueurs utilisant la même ad
|
||||
define('MANUAL_NF_D_24', "Médaille décernée aux joueurs utilisant la même adresse e-mail depuis 5 ans ou plus. Peut être ajoutée à la description du profil. Cette fonction a été présentée dans Travian T4.");
|
||||
define('MANUAL_NF_D_25', "Médaille décernée aux joueurs utilisant la même adresse e-mail depuis 10 ans ou plus. Peut être ajoutée à la description du profil. Cette fonction a été présentée dans Travian T4.");
|
||||
define('MANUAL_NF_D_26', "Médaille décernée aux joueurs utilisant la même adresse e-mail depuis 10 ans ou plus. Peut être ajoutée à la description du profil. Cette fonction a été présentée dans Travian T4.");
|
||||
|
||||
// ===== Server Milestones (NEW_FUNCTIONS_MILESTONES) =====
|
||||
define('TZ_SERVER_MILESTONES', 'Jalons du serveur');
|
||||
define('TZ_MILESTONE_NOT_YET', 'Pas encore atteint');
|
||||
define('TZ_MILESTONE_SECOND_VILLAGE', 'Premier à fonder un 2e village');
|
||||
define('TZ_MILESTONE_POPULATION_1000', 'Premier à atteindre 1 000 population');
|
||||
define('TZ_MILESTONE_FIRST_ARTIFACT', 'Premier à capturer un artefact');
|
||||
define('TZ_MILESTONE_FIRST_WW', 'Premier à conquérir une Merveille du Monde');
|
||||
define('TZ_MILESTONE_FIRST_WW_PLAN', 'Premier à conquérir un Plan de Merveille');
|
||||
define('TZ_MILESTONE_FIRST_ALLIANCE', 'Première alliance fondée');
|
||||
define('TZ_MILESTONE_FIRST_PVP_CONQUEST', 'Premier village conquis sur un joueur');
|
||||
?>
|
||||
|
||||
@@ -2592,3 +2592,14 @@ define('MANUAL_NF_D_23', "Medalie acordată jucătorilor care folosesc aceeași
|
||||
define('MANUAL_NF_D_24', "Medalie acordată jucătorilor care folosesc aceeași adresă de e-mail de 5 ani sau mai mult. Poate fi adăugată la descrierea profilului. Această funcție a fost prezentată în Travian T4.");
|
||||
define('MANUAL_NF_D_25', "Medalie acordată jucătorilor care folosesc aceeași adresă de e-mail de 10 ani sau mai mult. Poate fi adăugată la descrierea profilului. Această funcție a fost prezentată în Travian T4.");
|
||||
define('MANUAL_NF_D_26', "Medalie acordată jucătorilor care folosesc aceeași adresă de e-mail de 10 ani sau mai mult. Poate fi adăugată la descrierea profilului. Această funcție a fost prezentată în Travian T4.");
|
||||
|
||||
// ===== Server Milestones (NEW_FUNCTIONS_MILESTONES) =====
|
||||
define('TZ_SERVER_MILESTONES', 'Recorduri de Server');
|
||||
define('TZ_MILESTONE_NOT_YET', 'Neatins încă');
|
||||
define('TZ_MILESTONE_SECOND_VILLAGE', 'Primul care a fondat al 2-lea sat');
|
||||
define('TZ_MILESTONE_POPULATION_1000', 'Primul care a atins 1.000 populație');
|
||||
define('TZ_MILESTONE_FIRST_ARTIFACT', 'Primul care a capturat un artefact');
|
||||
define('TZ_MILESTONE_FIRST_WW', 'Primul care a cucerit un Wonder of the World');
|
||||
define('TZ_MILESTONE_FIRST_WW_PLAN', 'Primul care a cucerit un Plan WW');
|
||||
define('TZ_MILESTONE_FIRST_ALLIANCE', 'Prima alianță fondată');
|
||||
define('TZ_MILESTONE_FIRST_PVP_CONQUEST', 'Primul sat cucerit de la un jucător');
|
||||
Reference in New Issue
Block a user