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

WIP: Add server nickname #310

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bin/config_sample/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ port=27016
; The server description that will appear on the master server.
server_description=This is a placeholder server description. Tell the world of AO who you are here!

; The server's name. This appears both on the master server, and in messages sent to users by the server.
; The server's name. This appears on the master server.
server_name=An Unnamed Server

; The server's nickname. This appears in messages sent to users by the server.
server_nick=NickName

; The server's Message of the Day. This will be sent in OOC to joining users.
motd=MOTD is not set.

Expand Down
5 changes: 4 additions & 1 deletion bin_tests/config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ port=27016
; The server description that will appear on the master server.
server_description=This is a placeholder server description. Tell the world of AO who you are here!

; The server's name. This appears both on the master server, and in messages sent to users by the server.
; The server's name. This appears on the master server.
server_name=An Unnamed Server

; The server's nickname. This appears in messages sent to users by the server.
server_nick=NickName

; The server's Message of the Day. This will be sent in OOC to joining users.
motd=MOTD is not set.

Expand Down
7 changes: 7 additions & 0 deletions core/include/config_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ class ConfigManager
*/
static QString serverName();

/**
* @brief Returns the server nickname.
*
* @return See short description.
*/
static QString serverNick();

/**
* @brief Returns the server's Message of the Day.
*
Expand Down
6 changes: 3 additions & 3 deletions core/src/aoclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,17 +433,17 @@ void AOClient::calculateIpid()

void AOClient::sendServerMessage(QString message)
{
sendPacket("CT", {ConfigManager::serverName(), message, "1"});
sendPacket("CT", {ConfigManager::serverNick(), message, "1"});
}

void AOClient::sendServerMessageArea(QString message)
{
server->broadcast(AOPacket("CT", {ConfigManager::serverName(), message, "1"}), m_current_area);
server->broadcast(AOPacket("CT", {ConfigManager::serverNick(), message, "1"}), m_current_area);
}

void AOClient::sendServerBroadcast(QString message)
{
server->broadcast(AOPacket("CT", {ConfigManager::serverName(), message, "1"}));
server->broadcast(AOPacket("CT", {ConfigManager::serverNick(), message, "1"}));
}

bool AOClient::checkPermission(ACLRole::Permission f_permission) const
Expand Down
5 changes: 5 additions & 0 deletions core/src/config_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ QString ConfigManager::serverName()
return m_settings->value("Options/server_name", "An Unnamed Server").toString();
}

QString ConfigManager::serverNick()
{
return m_settings->value("Options/server_nick", "").toString();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return m_settings->value("Options/server_nick", "").toString();
return m_settings->value("Options/server_nick", "NickName").toString();

If the key is missing we don't want an empty value, as that would look very silly when viewed in client.

}

QString ConfigManager::motd()
{
return m_settings->value("Options/motd", "MOTD not set").toString();
Expand Down