Skip to content

feat: implement character and property reputation system#1964

Draft
aronwk-aaron wants to merge 9 commits intomainfrom
issue-636
Draft

feat: implement character and property reputation system#1964
aronwk-aaron wants to merge 9 commits intomainfrom
issue-636

Conversation

@aronwk-aaron
Copy link
Copy Markdown
Member

@aronwk-aaron aronwk-aaron commented Apr 5, 2026

Implements a database-backed reputation system for characters and property activity, including schema migrations and a one-time migration of legacy reputation stored in character XML.

Changes Made

  • Added new DB tables and accessors for character reputation and per-property daily contribution tracking (MySQL + SQLite).
  • Updated gameplay components to load/persist character reputation and to award/decay property reputation based on player activity.
  • Added a migration runner hook to migrate existing XML-stored character reputation into the new DB table.
  • Fixed GetCharacterReputation and SetCharacterReputation calls to use Character::GetID() (raw DB id) instead of Character::GetObjectID() (runtime object id with CHARACTER bit set) so read/write paths use the same DB key.
  • Fixed %llu format specifier for LWOOBJID (int64_t) in CharacterReputationMigration.cpp by casting to uint64_t to avoid undefined behavior on some platforms.

Tests

Added PropertyReputationTests.cpp with focused unit tests covering:

  • CharacterComponent::SetReputation stores at Character::GetID(), not GetObjectID() (regression guard for the id-key bug).
  • CharacterComponent reputation round-trip and load-from-DB on construction.
  • DB id and object id treated as distinct keys.
  • UpdatePropertyReputation / GetPropertyReputation round-trip via TestSQLDatabase.
  • UpdatePropertyReputationContribution upsert behavior, date isolation, and multi-player contribution scenarios.

TestSQLDatabase property reputation and contribution stubs are now backed by real in-memory storage to support these and future tests.

- Added ICharacterReputation and IPropertyReputationContribution interfaces for managing character and property reputations.
- Implemented MySQL and SQLite database methods for getting and setting character reputations.
- Created migration scripts for character and property reputation tables in both MySQL and SQLite.
- Updated CharacterComponent to retrieve and set character reputation.
- Enhanced PropertyManagementComponent to manage property reputation and contributions.
- Added methods for handling reputation contributions and decay.
- Introduced CharacterReputationMigration to migrate existing character reputations from XML to the database.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a database-backed reputation system for characters and property activity, including schema migrations and a one-time migration of legacy reputation stored in character XML.

Changes:

  • Added new DB tables + accessors for character reputation and per-property daily contribution tracking (MySQL + SQLite).
  • Updated gameplay components to load/persist character reputation and to award/decay property reputation based on player activity.
  • Added a migration runner hook to migrate existing XML-stored character reputation into the new DB table.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
migrations/dlu/sqlite/10_character_reputation.sql Adds SQLite character_reputation table.
migrations/dlu/sqlite/11_property_reputation.sql Adds SQLite property_reputation_contribution table.
migrations/dlu/mysql/27_character_reputation.sql Adds MySQL character_reputation table.
migrations/dlu/mysql/28_property_reputation.sql Adds MySQL property_reputation_contribution table.
dGame/dMission/Mission.cpp Stops sending UpdateReputation directly (now sent via CharacterComponent::SetReputation).
dGame/dComponents/PropertyManagementComponent.h Adds per-player activity tracking + timers/config for property reputation.
dGame/dComponents/PropertyManagementComponent.cpp Implements property reputation accrual/decay, DB persistence, and position-update observer wiring.
dGame/dComponents/CharacterComponent.h Moves SetReputation to out-of-line implementation.
dGame/dComponents/CharacterComponent.cpp Loads/saves reputation from DB and sends UpdateReputation when changed.
dDatabase/MigrationRunner.cpp Detects character reputation migration SQL and triggers XML→DB data migration pass.
dDatabase/GameDatabase/TestSQL/TestSQLDatabase.h Adds in-memory stubs for character reputation methods used by tests/migration.
dDatabase/GameDatabase/SQLite/Tables/PropertyReputationContribution.cpp SQLite queries/upserts for property reputation contribution + property reputation update.
dDatabase/GameDatabase/SQLite/Tables/CMakeLists.txt Builds new SQLite table source files.
dDatabase/GameDatabase/SQLite/Tables/CharInfo.cpp Adds GetAllCharacterIds() for migration.
dDatabase/GameDatabase/SQLite/Tables/CharacterReputation.cpp SQLite get/set for character reputation.
dDatabase/GameDatabase/SQLite/SQLiteDatabase.h Exposes new reputation-related DB APIs for SQLite implementation.
dDatabase/GameDatabase/MySQL/Tables/PropertyReputationContribution.cpp MySQL queries/upserts for property reputation contribution + property reputation update.
dDatabase/GameDatabase/MySQL/Tables/CMakeLists.txt Builds new MySQL table source files.
dDatabase/GameDatabase/MySQL/Tables/CharInfo.cpp Adds GetAllCharacterIds() for migration.
dDatabase/GameDatabase/MySQL/Tables/CharacterReputation.cpp MySQL get/set for character reputation.
dDatabase/GameDatabase/MySQL/MySQLDatabase.h Exposes new reputation-related DB APIs for MySQL implementation.
dDatabase/GameDatabase/ITables/IPropertyReputationContribution.h New interface for property contribution + property reputation update.
dDatabase/GameDatabase/ITables/ICharInfo.h Adds GetAllCharacterIds() to support migration.
dDatabase/GameDatabase/ITables/ICharacterReputation.h New interface for character reputation get/set.
dDatabase/GameDatabase/GameDatabase.h Wires new reputation interfaces into the GameDatabase base.
dDatabase/CMakeLists.txt Adds CharacterReputationMigration to the dDatabase build.
dDatabase/CharacterReputationMigration.h Declares XML→DB reputation migration.
dDatabase/CharacterReputationMigration.cpp Implements XML attribute rpt extraction and DB write-back.
dCommon/GeneralUtils.h Adds GeneralUtils::GetCurrentUTCDate() utility for daily tracking.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
aronwk-aaron and others added 3 commits April 5, 2026 03:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ReputationMigration

Agent-Logs-Url: https://github.com/DarkflameUniverse/DarkflameServer/sessions/63bf6fda-1e52-4ad7-a08c-3535f744ae5d

Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
aronwk-aaron and others added 2 commits April 5, 2026 03:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants