Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Core): Allow localized motd #20542

Merged
merged 36 commits into from
Dec 15, 2024
Merged

Conversation

Exitare
Copy link
Member

@Exitare Exitare commented Nov 13, 2024

Changes Proposed:

This PR proposes changes to:

  • Core (units, players, creatures, game systems).
  • Scripts (bosses, spell scripts, creature scripts).
  • Database (SAI, creatures, etc).

Issues Addressed:

SOURCE:

The changes have been validated through:

  • Live research (checked on live servers, e.g Classic WotLK, Retail, etc.)
  • Sniffs (remember to share them with the open source community!)
  • Video evidence, knowledge databases or other public sources (e.g forums, Wowhead, etc.)
  • The changes promoted by this pull request come partially or entirely from another project (cherry-pick). Cherry-picks must be committed using the proper --author tag in order to be accepted, thus crediting the original authors, unless otherwise unable to be found

Tests Performed:

This PR has been:

  • Tested in-game by the author.
  • Tested in-game by other community members/someone else other than the author/has been live on production servers.
  • This pull request requires further testing and may have edge cases to be tested.

How to Test the Changes:

  • This pull request can be tested by following the reproduction steps provided in the linked issue
  • This pull request requires further testing. Provide steps to test your changes. If it requires any specific setup e.g multiple players please specify it as well.
  1. Apply the sql that adjusts the motd table
  2. Prefill table with new localized motds and check motd by either logging in / reloading the table / running the ingame command .server motd

Known Issues and TODO List:

  • Default server command is currently only updating enUS locale
  • Questions remain about how to handle missing locale data. Fallback to just enUS. What if there is no enUS locale available?
  • Additionally, how should OnMotdChange be handled? Technically the updated motd can be propagated, but without any further knowledge that could be any locale. I´d argue that the OnMotdChange function should be adjusted to also provide the locale.

How to Test AzerothCore PRs

When a PR is ready to be tested, it will be marked as [WAITING TO BE TESTED].

You can help by testing PRs and writing your feedback here on the PR's page on GitHub. Follow the instructions here:

http://www.azerothcore.org/wiki/How-to-test-a-PR

REMEMBER: when testing a PR that changes something generic (i.e. a part of code that handles more than one specific thing), the tester should not only check that the PR does its job (e.g. fixing spell XXX) but especially check that the PR does not cause any regression (i.e. introducing new bugs).

For example: if a PR fixes spell X by changing a part of code that handles spells X, Y, and Z, we should not only test X, but we should test Y and Z as well.

@github-actions github-actions bot added DB related to the SQL database CORE Related to the core Script file-cpp Used to trigger the matrix build labels Nov 13, 2024
@Exitare Exitare changed the title Feature (Core): Allow localized motds Feature (Core): Allow localized motd Nov 13, 2024
@Nyeriah
Copy link
Member

Nyeriah commented Nov 14, 2024

New table implementations need to be designed in order to comply with database normalization rules https://www.w3schools.in/dbms/database-normalization

@Nyeriah
Copy link
Member

Nyeriah commented Nov 14, 2024

Quick copilot review:

The provided SQL script modifies the motd table by adding several language-specific columns and migrating the existing text column data to the enUS column. Let's analyze this for database normalization compliance:

  1. Adding Columns: The script adds columns for various languages (enUS, koKR, frFR, deDE, zhCN, zhTW, esES, esMX, ruRU).

  2. Data Migration: It moves data from the text column to the enUS column.

  3. Dropping Column: The text column is then dropped.

To ensure compliance with database normalization rules, especially the Third Normal Form (3NF), the following considerations should be made:

  • 1NF (First Normal Form): Each table should have atomic columns. Adding multiple language-specific columns may violate this as it introduces redundancy.
  • 2NF (Second Normal Form): All non-key attributes must be fully functional dependent on the primary key. The current structure may lead to partial dependencies if the table's primary key is not composite.
  • 3NF (Third Normal Form): Non-key attributes should not have transitive dependencies. Adding multiple language columns can lead to transitive dependencies.

Recommendations

  • Normalization: Consider creating a separate table for localized messages to avoid redundancy and ensure proper normalization. For example:

    CREATE TABLE `motd` (
      `id` INT PRIMARY KEY,
      `default_text` LONGTEXT
    );
    
    CREATE TABLE `motd_localized` (
      `motd_id` INT,
      `locale` VARCHAR(5),
      `localized_text` LONGTEXT,
      PRIMARY KEY (`motd_id`, `locale`),
      FOREIGN KEY (`motd_id`) REFERENCES `motd`(`id`)
    );

This structure will ensure that the database is normalized and follows best practices for managing localized content.

@Exitare
Copy link
Member Author

Exitare commented Nov 14, 2024

@Nyeriah , any suggestions regarding the commands affected by this PR or the OnMotdChange() script

@Nyeriah
Copy link
Member

Nyeriah commented Nov 14, 2024

Yes, they will crash if used from console. Handler in the command context is not guaranteed to be a player or have a valid session, so this needs to be checked

@Exitare
Copy link
Member Author

Exitare commented Nov 14, 2024

Thank you for this insight.
I meant to ask about to the command .server set motd [optional realm id] [message].
and the sScriptMgr->OnMotdChange(motdMessage);

My thoughts would be:

  1. The command should be adjusted to also include the locale as an optional
  2. The OnMotdChange() should also include the locale that got changed. As a results the function call would use 2 params instead of one.

@Nyeriah
Copy link
Member

Nyeriah commented Nov 14, 2024

Sure, it can be added as an optional, and it should default to english

@Exitare Exitare marked this pull request as ready for review November 16, 2024 03:17
@Nyeriah
Copy link
Member

Nyeriah commented Dec 12, 2024

Please keep the MOTD encoding, it's an AC thing to difficult it being removed
Also please check for redundant comments, self-explanatory code doesn't need to be commented (e.g avoid rewriting in English what the code already clearly does)

Copy link
Member

@Kitzunu Kitzunu left a comment

Choose a reason for hiding this comment

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

I think this is good to go if you address these small things

src/server/apps/worldserver/RemoteAccess/RASession.cpp Outdated Show resolved Hide resolved
src/server/scripts/Commands/cs_server.cpp Outdated Show resolved Hide resolved
src/server/scripts/Commands/cs_server.cpp Outdated Show resolved Hide resolved
src/server/scripts/Commands/cs_server.cpp Outdated Show resolved Hide resolved
@Exitare
Copy link
Member Author

Exitare commented Dec 14, 2024

Code adjusted. Should be good to go.

@Kitzunu
Copy link
Member

Kitzunu commented Dec 14, 2024

Did you test this after the changes were made? If so we can merge

@Exitare
Copy link
Member Author

Exitare commented Dec 14, 2024

Yes, its tested and working. I had to fix the server command, but now everything is good to go.

@Kitzunu
Copy link
Member

Kitzunu commented Dec 14, 2024

Awesome. We can merge after DB Squash.

Great job :D

@Kitzunu
Copy link
Member

Kitzunu commented Dec 14, 2024

CI failing

@Exitare
Copy link
Member Author

Exitare commented Dec 14, 2024

Already on it ;)

@Kitzunu
Copy link
Member

Kitzunu commented Dec 14, 2024

Are you in the discord?

@Exitare
Copy link
Member Author

Exitare commented Dec 14, 2024

Yes. I am the japanese named avatar you responded earlier with the spell dbc in the dev-core channel ;)

@Kitzunu
Copy link
Member

Kitzunu commented Dec 14, 2024

I see I see

@Kitzunu Kitzunu merged commit 7fd8b04 into azerothcore:master Dec 15, 2024
14 checks passed
@Exitare Exitare deleted the localized_motd branch December 15, 2024 19:11
xpdemon pushed a commit to xpdemon/azerothcore-wotlk that referenced this pull request Dec 25, 2024
* Initial commit for localized motd

* Rename function that created world packages

* Update to satisfy code check

* Update code to accomodate localized motd

* Update command to support multiple optionales & adjusted db

* Code cleanup

* Update sql name

* Fix codestyle issues

* Remove hardcoded schema

* Add check for valid player in reload command

* Update to better code style

* Add missing include

* Fix redundant code usage

* Add missing include

* Remove sql files and create new rev sql files

* Address minor code reviews

* Fix code style

* Update code to address code revisions.

- Remove two unused functions
- Remove map
- Use available function to resolve LocaleConstant

* Fix code style

* Add check for base motd and update locale to DEFAULT_LOCALE

* Code docs

* Removed some docs, readd defaultd motd formatting

* Fix oversight in variable declaration

* Code style fix

* Update code based on code review

* ready for merge

* Fix set motd command due to changes to DEFAULT_LOCALE

* Fix CI

* Fix trailing whitespace

---------

Co-authored-by: Kitzunu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CORE Related to the core DB related to the SQL database file-cpp Used to trigger the matrix build Ready to be Reviewed Script Waiting to be Tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Allow localized MOTD
3 participants