Skip to content

Commit

Permalink
* Save sender name instead of id
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Jan 1, 2025
1 parent f35f397 commit 3cab8a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions data/migrations/47.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ function onUpdateDatabase()
db.query([[
CREATE TABLE IF NOT EXISTS `player_statements`(
`id` INT NOT NULL AUTO_INCREMENT,
`player_id` INT NOT NULL,
`receiver` TEXT NOT NULL,
`sender` VARCHAR (255) NOT NULL,
`receiver` VARCHAR (255) NOT NULL,
`channel_id` INT NOT NULL DEFAULT 0,
`text` VARCHAR (255) NOT NULL,
`date` BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`), KEY (`player_id`), KEY (`channel_id`),
FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
PRIMARY KEY (`id`),
KEY (`channel_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
]])
return true
Expand Down
8 changes: 4 additions & 4 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,13 @@ CREATE TABLE IF NOT EXISTS `player_charms` (
-- Table structure `player_statements`
CREATE TABLE IF NOT EXISTS `player_statements` (
`id` INT NOT NULL AUTO_INCREMENT,
`player_id` INT NOT NULL,
`receiver` TEXT NOT NULL,
`sender` VARCHAR (255) NOT NULL,
`receiver` VARCHAR (255) NOT NULL,
`channel_id` INT NOT NULL DEFAULT 0,
`text` VARCHAR (255) NOT NULL,
`date` BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`), KEY (`player_id`), KEY (`channel_id`),
FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE
PRIMARY KEY (`id`),
KEY (`channel_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Table structure `player_deaths`
Expand Down
4 changes: 2 additions & 2 deletions src/io/functions/iologindata_save_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,8 @@ bool IOLoginDataSave::savePlayerStatement(const std::shared_ptr<Player> &player,
Database &db = Database::getInstance();
std::ostringstream query;

query << "INSERT INTO `player_statements` (`player_id`, `receiver`, `channel_id`, `text`, `date`) VALUES ("
<< player->getGUID() << ", " << db.escapeString(receiver) << ", " << channelId << ", "
query << "INSERT INTO `player_statements` (`sender`, `receiver`, `channel_id`, `text`, `date`) VALUES ("
<< db.escapeString(player->getName()) << ", " << db.escapeString(receiver) << ", " << channelId << ", "
<< db.escapeString(text) << ", " << time(nullptr) << ")";

if (!db.executeQuery(query.str())) {
Expand Down

0 comments on commit 3cab8a6

Please sign in to comment.