Commit Graph

760 Commits

Author SHA1 Message Date
Ferywir 827354a622 feat(admin): add transparent debug error-log mode
Add an admin-controlled debug mode that captures PHP errors of all
players into var/log/debug-players.log, to hunt remaining PHP 8.3 bugs
from real play sessions. Fully transparent to players: no redirect, no
gameplay change, errors are never displayed.

- DB: new debug_log table (one row), mirroring the maintenance pattern.
- Database: getDebugMode()/setDebugMode()/setDebugSettings(), defensive
  when the table is absent (no blank page).
- Session: register a custom error + shutdown handler when enabled; the
  handler runs even when php.ini error_reporting masks warnings/notices,
  so capture is complete without a Docker rebuild. Auto-disables after a
  configurable window.
- DebugErrorLogger: size-capped file with a single .log.1 rotation,
  honours the @ operator, never throws.
- Admin: new "Debug Error Log" page (levels, size cap, auto-off, on-page
  viewer, clear, download) + debugLog action mod.
- Menu: admin-only quick on/off widget (TZ_DEBUG_ON/OFF, EN/FR/RO).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 17:18:39 +03:00
Ferywir 63c94fa961 feat(preferences): apply time preference (timezone + date format) [#198]
Implement the "Time Preference" section of the player preferences (issue
#198), which until now was stored in DB but never applied in-game.

procMtime() — the central date/time formatter used across reports, messages,
notices and troop movements — now honours the per-user settings:
  - timezone: the stored value is mapped to a DateTimeZone, either a named
    DST-aware region (Europe, UK, Turkey, Kolkata, Bangkok, New York,
    Chicago, New Zealand) or a fixed UTC offset (general zones); timestamps
    are converted before formatting.
  - tformat: drives the date layout and 12h/24h clock (0=EU dd.mm.yy 24h,
    1=US mm/dd/yy 12h, 2=UK dd/mm/yy 12h, 3=ISO yy/mm/dd 24h). tformat 0
    keeps the previous EU output unchanged.

The today/yesterday sentinels are preserved (callers compare them) and are
computed in the player's timezone. The time-only path (mode 9) stays 24h
H:i:s because it feeds the live JS clock counters (unx.js), which parse
"H:i:s" by splitting on ":". A few alliance/report/farm-list rows that
combined procMtime's day part with a raw date('H:i') now take the time from
the same procMtime result, to avoid mixing timezones.

A second "local time" clock is shown next to the server-time one: a small
vanilla-JS snippet emitted once from menu.tpl finds the visible #tp1 clock
and appends a row ticking in the player's timezone (Date.now() + UTC offset),
independent of the browser timezone and of the unx.js counters. It aligns the
value under the server time, is skipped when the player's timezone matches
the server's, and lets the clock box grow so the extra row fits the frame.

Adds the LOCAL_TIME string (EN/FR/RO). When no player session is available
(admin / pre-login) procMtime falls back to the server timezone and EU
layout, i.e. the previous behaviour. Removes the last "not coded yet" tag
from the preferences form.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 16:46:33 +03:00
Ferywir 6030727a0d fix(php8): silence warnings raised by the attack/report flow [#203]
PHP 8.x turned several long-standing implicit accesses into runtime
warnings that flooded the error log during attacks and report viewing:

- Battle.report (Templates/Notice/1.tpl): the prisoner check ran
  array_sum() over slots that may hold non-numeric text (the
  "Information" line can shift indices), raising
  "Addition is not supported on type string". Sum int-cast values.
- Database::getUnitsNumber(): movement/reinforcement arrays can be null
  or miss tribe-specific unit keys, raising "Undefined array key" and
  "Trying to access array offset on null". Null-coalesce to 0.
- Automation (combat resolver): $scout was only defined for scouting
  attacks (type 1) yet always passed to buildCombatReport(), raising
  "Undefined variable $scout". Initialize it for every attack type.
- Automation: the destroy-village check read $to['natar'] which is not
  always set, raising "Undefined array key". Use empty().

Pure null-safety / behaviour-preserving changes; no gameplay logic
altered.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 16:35:50 +03:00
Ferywir 6d57cd7fe1 feat(preferences): apply auto-completion (village name suggestions) [#198]
Honour the per-user auto-completion checkboxes on the rally point and the
marketplace, where the target village is typed by name (dname field):
  - v1: own villages
  - v2: villages in the surroundings of the active village
  - v3: villages of the player's alliance members

A new Database::getAutoCompleteVillages() builds the bounded, de-duplicated
name list from the enabled categories (system accounts excluded). A shared
Templates/villageAutocomplete.tpl renders a native <datalist> consumed by
the dname input via list="dnameSuggest"; nothing is emitted when every box
is unchecked, keeping the previous behaviour. Removes the "not coded yet"
tag from the auto-completion section in the preferences form.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 09:28:20 +02:00
Ferywir 8d46fc78ae feat(preferences): apply report filter (suppress merchant-transfer reports) [#198]
Honour the per-user report-filter checkboxes in marketComplete():
  - v4: recipient gets no report for transfers between own villages
  - v6: recipient gets no report for transfers from foreign villages
  - v5: sender gets no report for transfers to foreign villages

The user row is already fully loaded by getUserFields(), so the prefs
are read without extra queries. Removes the "not coded yet" tag from
the report-filter section in the preferences form.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 06:31:13 +03:00
Ferywir 08bb464540 feat(preferences): apply "Large map" preference (extra window) [#198]
The `map` user preference ("Show the large map in an extra window") was
saved to users.map but never applied in-game. When enabled, the large-map
button on the map now opens karte2.php in a separate browser window
instead of the in-page iframe overlay (default behaviour kept when the
preference is off).

Also drop the "(not coded yet)" marker from the Large map section of the
preferences page and wire its title to the existing LARGE_MAP constant.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 18:41:04 +03:00
Ferywir 524b9e7edd fix(i18n): localize statistics page and troops Hero label [#197]
On a fresh install several strings were still hardcoded in English
(reported on the live server, RO locale):

- statistiken.php: the page <title>, the <h1> and the tab bar
  (Player / Alliances / Villages / Heroes / General) were literal English.
- Templates/Ranking/ranksearch.tpl: the "back | forward" pagination links.
- Templates/troops.tpl: the "Hero" troop-row label.

Wire them to language constants. Reuse existing ones
(STATISTICS, PLAYER, PLAYERS, VILLAGES, BACK, FORWARD, U0) and add three
new constants (ALLIANCES, HEROES, GENERAL) to en/fr/ro. WW is kept as-is
(universal acronym).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 18:37:22 +03:00
TravianZ Patcher eb64bba1e7 fix(quest): grant no-tasks shipment reward atomically [#129]
The "no tasks" quest mode delivers a Plus + gold shipment on claim
(case '91', and the final case '97'). The reward was granted with a
non-atomic read-modify-write:

    $gold = getUserField('gold'); $gold += 15; updateUserField('gold', $gold);

and the quest pointer / timer were advanced unconditionally. Under the
many concurrent ajax requests the game fires, a request that read gold/
plus before the claim and wrote the user row back after it would clobber
the freshly granted reward. The quest_time write (a literal value) still
survived, so the UI advanced to the next shipment countdown while the
player received neither Plus nor gold -- exactly the sporadic symptom in
the report.

Fix: gate the grant on an atomic conditional advance
(UPDATE ... SET quest = 91 WHERE quest = 90) and apply the reward with
in-place SQL increments (gold = gold + 15, plus = IF(plus > now, ...)),
matching the idiom already used in Templates/Plus/*.tpl. This makes the
claim idempotent (duplicate/concurrent requests grant nothing extra) and
immune to the lost-update race. Also fixes a latent case where an expired
Plus timestamp was extended in the past instead of reset to now.

Applied to both quest_core.tpl and quest_core25.tpl.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 18:32:01 +03:00
TravianZ Patcher c91ae5e486 feat(l10n): translate manual new-features pages (FR/RO)
Localize the 17 "new features" manual pages (Templates/Manual/1111-1126.tpl
and the 1331.tpl index, typ=11/13) so they render in the player's language
instead of hardcoded English.

- Replace hardcoded page titles, descriptions and nav tooltips with constants.
- The 1331 index reuses the per-page title constants and gains
  MANUAL_NF_ENABLED / MANUAL_NF_DISABLED for the on/off status labels.
- Add 33 constants each to GameEngine/Lang/{en,fr,ro}.php
  (2 status labels + 15 page titles + 16 descriptions).
- en.php uses tz_def() as the English fallback; fr/ro use define().
- Reuse existing constants where they already exist: VACATION_MODE (page 19),
  NEW_FEATURES, FORWARD, BACK, OVERVIEW.

it/zh fall back to English. RO strings pending native review.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:45:47 +03:00
TravianZ Patcher 48dde68baa feat(l10n): translate manual unit pages (FR/RO)
Localize the 51 in-game manual unit detail pages (Templates/Manual/1*.tpl,
typ=1) so they render in the player's language instead of English, continuing
the manual l10n started in the building pages PR.

What changed:
- 51 unit pages (Romans/Teutons/Gauls/Nature/Natars) now use translation
  constants for every hardcoded string: tribe tags -> TRIBE1..5, the stat
  labels (attack value, defence vs infantry/cavalry, Velocity, fields/hour,
  Can carry, Duration of training), the unit descriptions, the NPC reference
  notes and the "forward" nav.
- 48 new constants added to en/fr/ro:
  * 7 shared stat labels (MANUAL_ATTACK_VALUE, MANUAL_DEF_INFANTRY,
    MANUAL_DEF_CAVALRY, MANUAL_VELOCITY, MANUAL_FIELDS_HOUR, MANUAL_CAN_CARRY,
    MANUAL_TRAINING_DURATION)
  * 2 NPC reference notes (MANUAL_NPC_NATARS, MANUAL_NPC_NATURE)
  * 1 templated Nature-animal blurb (MANUAL_UDESC_ANIMAL_EXP, used via
    printf with the animal name + xp value, so the 10 animal pages share it)
  * 38 unit descriptions (MANUAL_UDESC_*). Identical descriptions are shared:
    settlers (110/120/130) and rams (117/127) reuse one constant each.
- Reuses constants already present upstream and in the building pages branch:
  TRIBE1..5, LEVEL, FORWARD, CROP_CONSUMPTION, PREREQUISITES, UPKEEP, DURATION,
  RESOURCES, U1..U50.

English render is unchanged: the English constant values are the existing page
text extracted verbatim (whitespace-collapsed). it/zh are intentionally left to
fall back to English via the en.php fallback wired up earlier.

Scope note: this builds on the manual building-pages l10n branch (reuses
CROP_CONSUMPTION). The 17 "new features" pages (typ=11/13) are out of scope and
will be a follow-up PR. RO strings are functional but would benefit from a
native review.
2026-06-10 13:48:02 +02:00
Ferywir 66a07c6819 feat(l10n): translate manual building pages (FR/RO) (#192) 2026-06-09 19:00:08 +03:00
Ferywir e498563555 fix: blank in-game help + untranslated profile after l10n (#189) (#191) 2026-06-09 17:48:16 +03:00
Ferywir dad574be1a feat: reports for settling - new village founded & valley occupied (#178) (#190) 2026-06-09 16:47:29 +03:00
Ferywir 5d366284e6 l10n: full interface translation (FR/RO/IT/ZH) + EN fallback hardening (#186) 2026-06-09 10:28:59 +03:00
novgorodschi catalin 4eecf575a1 Fix some lang problems
Fix some lang problems & added in admin panel
2026-06-04 13:54:15 +03:00
novgorodschi catalin 33b7261b4b Change some file
Change some file
2026-06-04 13:39:59 +03:00
novgorodschi catalin 1a4014218c Fix something broken
Fix something broken
2026-06-04 12:35:53 +03:00
novgorodschi catalin 208f4bc31c Update menu.tpl 2026-06-04 10:18:09 +03:00
novgorodschi catalin 6e139a1b61 Fix
fix
2026-06-02 14:20:21 +03:00
novgorodschi catalin b495dcb559 Some fix
Some fix
2026-06-02 12:58:20 +03:00
novgorodschi catalin 547e164143 Edit some access for MH user and recreate mass messaage
Edit some access for MH user and recreate mass message and new maintenance system view for admins
2026-06-02 10:59:35 +03:00
novgorodschi catalin 1d1f1dc72a Fix + Redesign
Fix some error programing code and redesign special medals, tribe medals, mh medals, taskmaster medals, natars medals, nature medals, protection medals, etc. Add some language code in Profile.php and preference.tpl. Change some description in struct database for Nature and Taskmaster
2026-05-28 12:25:28 +03:00
novgorodschi catalin 31c475e644 Fix + Credits + Start Language Coding
Fix Artefacts + Credits + Start Language Coding
2026-05-27 12:26:24 +03:00
novgorodschi catalin 1b119d2a35 Fix special medals
Fix special medals
2026-05-26 14:42:19 +03:00
novgorodschi catalin fe19587c90 Redesign install system & New Medal System
Redesign install system & New Medal System

Artefact Holder			[#ARTEFACT]
WW Builder			[#WWBUILDER]
Great Store			[#GREATSTORE]
Wall Master			[#WALLMASTER]
Hero 99+			[#HERO100]
2026-05-26 10:42:28 +03:00
novgorodschi catalin 29b8e91968 Last incremental refactor for Template/a2b
Last incremental refactor for Template/a2b
2026-05-21 14:46:43 +03:00
novgorodschi catalin dd64b1e6c7 Refactor GoldClub
Refactor GoldClub
2026-05-21 13:41:48 +03:00
novgorodschi catalin 05bfde9063 Remove some unused code and some fix
Remove some unused code and some fix
2026-05-21 13:12:21 +03:00
novgorodschi catalin e6a3bb7db7 Update log system gold
Update log system gold
2026-05-20 11:55:18 +03:00
novgorodschi catalin 0934806e8d Refactor all PLUS System
Refactor PLUS System + Fix some bugs
2026-05-20 10:57:02 +03:00
novgorodschi catalin 3f32e21333 Fix bug in General Stats
Fix bug in General Stats - now troops appear !
2026-05-20 07:47:02 +03:00
novgorodschi catalin 55e6dd60b5 Refactor + BugFix
1. Fix a bug in Admin Panel that you can edit by yourself your rank, now you cannot edit your rank anymore.

2. Now Alliance Leader can edit his own Position

3. Fix negative value on Demolition Building, now in database at lvl is appear new level not -1

4. Refactor Ajax map, now all is alligned (Ajax folder and Map folder)

5. Fix bug from Palace (when change capital now Automation recount population automaticaly on old capital and new capital)
2026-05-18 09:18:35 +03:00
Catalin Novgorodschi 850a46ae2d Some fixes & improovements
1. Fix ban access, 2. Fix profile ('"") , 3. Add on vacation Admin/MH and exclude rat from reinforcement.
2026-05-15 12:13:01 +03:00
Catalin Novgorodschi ed0fc6be2c Incremental refactor Building and Ranking
Incremental refactor Building and Ranking
2026-05-12 11:35:15 +03:00
Catalin Novgorodschi 27e9a9a7b5 Full refactor of Battle
Full refactor of Battle
2026-05-08 13:06:53 +03:00
Catalin Novgorodschi 8cf5c93995 Change some 404 error
Change some 404 error
2026-05-08 08:21:38 +03:00
Catalin Novgorodschi a91f2a8c96 Incremental Refactor Templates 5
Incremental Refactor Templates 5
2026-05-07 15:24:54 +03:00
Catalin Novgorodschi 39acea80a8 Incremental Refactor Templates 4
Incremental Refactor Templates 4 + Notice bugfix
2026-05-07 12:34:31 +03:00
Catalin Novgorodschi 60c2ed2f60 Incremental Refactor Templates 3
Incremental Refactor Templates 2
2026-05-07 11:20:05 +03:00
Catalin Novgorodschi 8901c36c06 Incremental Refactor Templates 2
Incremental Refactor Templates 2
2026-05-07 08:24:40 +03:00
Catalin Novgorodschi a02be51969 Incremental Refactor Templates
Incremental Refactor Templates
2026-05-06 13:16:54 +03:00
Catalin Novgorodschi adf796f42a Restore some broken code
Restore some broken code
2026-04-29 13:21:12 +03:00
Catalin Novgorodschi 2c591eb1e9 OnClick medal
OnClick medal
2026-04-28 08:35:29 +03:00
Catalin Novgorodschi ebbf5165aa Code for preference (just logic not operational)
Code for preference (just logic not operational)
2026-04-27 15:04:44 +03:00
Catalin Novgorodschi e998dde06b Code requirements for vacation
Code requirements for vacation

Vacation function is fully functional
2026-04-27 13:26:39 +03:00
Catalin Novgorodschi c3049f7f1a Fix alliance Assign to position and Changepos
Code and Fix alliance Assign to position and Changepos
2026-04-22 12:24:26 +03:00
Catalin Novgorodschi befaa62d10 Merge branch 'master' of https://github.com/Shadowss/TravianZ 2026-04-22 10:15:52 +03:00
Catalin Novgorodschi ca541d2204 Fix alliance possition in overview
Fix alliance possition in overview
2026-04-22 10:15:49 +03:00
Catalin Novgorodschi 92f7eb23ce Merge pull request #156 from hdmaniak2/fix/hero-bonus-race-condition
Fix hero bonus race condition using atomic SQL
2026-04-09 08:53:32 +03:00
Catalin Novgorodschi 7c0d1079f9 Update footer.tpl 2026-04-02 14:47:34 +03:00