Five character slots (AVA2 ENABLE_PLAYER_PER_ACCOUNT5)

PLAYER_PER_ACCOUNT 5: player_index.pid5 in the login/empire/monarch
queries, char_change_empire sized by PLAYER_PER_ACCOUNT, slot check
relaxed; client gate mt20261029. tools/player-slots5 adds pid5.

tools/player-deleted-sync: PLAYER_DELETE copies with SELECT *, so
player_deleted must match player column for column; the conqueror
schema now adds its columns to player_deleted too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-24 20:33:51 +09:00
co-authored by Claude Opus 5.5
parent 31ebae050b
commit 96f8486306
11 changed files with 102 additions and 19 deletions
+4
View File
@@ -11,7 +11,11 @@ enum EMisc
IP_ADDRESS_LENGTH = 15,
LOGIN_MAX_LEN = 30,
PASSWD_MAX_LEN = 16,
#ifdef ENABLE_PLAYER_PER_ACCOUNT5
PLAYER_PER_ACCOUNT = 5,
#else
PLAYER_PER_ACCOUNT = 4,
#endif
ACCOUNT_STATUS_MAX_LEN = 8,
CHARACTER_NAME_MAX_LEN = 24,
#ifdef ENABLE_OFFLINESHOP_SYSTEM
+1
View File
@@ -17,6 +17,7 @@
#define USE_MOB_CLAW_AS_DAGGER
#endif
#define ENABLE_CONQUEROR_LEVEL
#define ENABLE_PLAYER_PER_ACCOUNT5
#define UNLOCK_INVENTORY_WORLDARD
#define ENABLE_OFFLINESHOP_SYSTEM
#ifdef ENABLE_OFFLINESHOP_SYSTEM
+11 -1
View File
@@ -1031,7 +1031,11 @@ void CClientManager::QUERY_EMPIRE_SELECT(CPeer * pkPeer, DWORD dwHandle, TEmpire
sys_log(0, "EmpireSelect: %s", szQuery);
{
snprintf(szQuery, sizeof(szQuery),
"SELECT pid1, pid2, pid3, pid4 FROM player_index%s WHERE id=%u", GetTablePostfix(), p->dwAccountID);
"SELECT pid1, pid2, pid3, pid4"
#ifdef ENABLE_PLAYER_PER_ACCOUNT5
", pid5"
#endif
" FROM player_index%s WHERE id=%u", GetTablePostfix(), p->dwAccountID);
std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
@@ -4291,9 +4295,15 @@ void CClientManager::ChangeMonarchLord(CPeer * peer, DWORD dwHandle, TPacketChan
char szQuery[1024];
snprintf(szQuery, sizeof(szQuery),
"SELECT a.name, NOW() FROM player%s AS a, player_index%s AS b WHERE (a.account_id=b.id AND a.id=%u AND b.empire=%u) AND "
#ifdef ENABLE_PLAYER_PER_ACCOUNT5
"(b.pid1=%u OR b.pid2=%u OR b.pid3=%u OR b.pid4=%u OR b.pid5=%u)",
GetTablePostfix(), GetTablePostfix(), info->dwPID, info->bEmpire,
info->dwPID, info->dwPID, info->dwPID, info->dwPID, info->dwPID);
#else
"(b.pid1=%u OR b.pid2=%u OR b.pid3=%u OR b.pid4=%u)",
GetTablePostfix(), GetTablePostfix(), info->dwPID, info->bEmpire,
info->dwPID, info->dwPID, info->dwPID, info->dwPID);
#endif
SQLMsg * pMsg = CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER);
+12
View File
@@ -157,7 +157,11 @@ void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketG
sys_log(0, "LOGIN_BY_KEY success %s %lu %s", r.login, p->dwLoginKey, info->ip);
char szQuery[QUERY_MAX_LEN];
#ifdef ENABLE_PLAYER_PER_ACCOUNT5
snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, pid5, empire FROM player_index%s WHERE id=%u", GetTablePostfix(), r.id);
#else
snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, empire FROM player_index%s WHERE id=%u", GetTablePostfix(), r.id);
#endif
CDBManager::instance().ReturnQuery(szQuery, QID_LOGIN_BY_KEY, pkPeer->GetHandle(), info);
}
@@ -179,7 +183,11 @@ void CClientManager::RESULT_LOGIN_BY_KEY(CPeer * peer, SQLMsg * msg)
{
DWORD account_id = info->pAccountTable->id;
char szQuery[QUERY_MAX_LEN];
#ifdef ENABLE_PLAYER_PER_ACCOUNT5
snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, pid5, empire FROM player_index%s WHERE id=%u", GetTablePostfix(), account_id);
#else
snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, empire FROM player_index%s WHERE id=%u", GetTablePostfix(), account_id);
#endif
std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER));
sys_log(0, "RESULT_LOGIN_BY_KEY FAIL player_index's NULL : ID:%d", account_id);
@@ -231,7 +239,11 @@ void CClientManager::RESULT_PLAYER_INDEX_CREATE(CPeer * pkPeer, SQLMsg * msg)
ClientHandleInfo * info = (ClientHandleInfo *) qi->pvData;
char szQuery[QUERY_MAX_LEN];
#ifdef ENABLE_PLAYER_PER_ACCOUNT5
snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, pid5, empire FROM player_index%s WHERE id=%u", GetTablePostfix(),
#else
snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, empire FROM player_index%s WHERE id=%u", GetTablePostfix(),
#endif
info->pAccountTable->id);
CDBManager::instance().ReturnQuery(szQuery, QID_LOGIN_BY_KEY, pkPeer->GetHandle(), info);
}
+22 -8
View File
@@ -23,14 +23,19 @@ int CHARACTER::ChangeEmpire(BYTE empire)
char szQuery[1024+1];
DWORD dwAID;
DWORD dwPID[4];
DWORD dwPID[PLAYER_PER_ACCOUNT];
memset(dwPID, 0, sizeof(dwPID));
{
// 1. 내 계정의 모든 pid를 얻어 온다
snprintf(szQuery, sizeof(szQuery),
#ifdef ENABLE_PLAYER_PER_ACCOUNT5
"SELECT id, pid1, pid2, pid3, pid4, pid5 FROM player_index%s WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u OR pid5=%u AND empire=%u",
get_table_postfix(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire());
#else
"SELECT id, pid1, pid2, pid3, pid4 FROM player_index%s WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u AND empire=%u",
get_table_postfix(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire());
#endif
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(szQuery));
@@ -42,19 +47,18 @@ int CHARACTER::ChangeEmpire(BYTE empire)
MYSQL_ROW row = mysql_fetch_row(msg->Get()->pSQLResult);
str_to_number(dwAID, row[0]);
str_to_number(dwPID[0], row[1]);
str_to_number(dwPID[1], row[2]);
str_to_number(dwPID[2], row[3]);
str_to_number(dwPID[3], row[4]);
for (int i = 0; i < PLAYER_PER_ACCOUNT; ++i)
str_to_number(dwPID[i], row[i + 1]);
}
const int loop = 4;
// PORT: AVA2 kept 4 here, skipping the fifth character's guild/marriage check.
const int loop = PLAYER_PER_ACCOUNT;
{
// 2. 각 캐릭터의 길드 정보를 얻어온다.
// 한 캐릭터라도 길드에 가입 되어 있다면, 제국 이동을 할 수 없다.
DWORD dwGuildID[4];
CGuild * pGuild[4];
DWORD dwGuildID[PLAYER_PER_ACCOUNT];
CGuild * pGuild[PLAYER_PER_ACCOUNT];
SQLMsg * pMsg = NULL;
for (int i = 0; i < loop; ++i)
@@ -102,8 +106,13 @@ int CHARACTER::ChangeEmpire(BYTE empire)
{
// 4. db의 제국 정보를 업데이트 한다.
#ifdef ENABLE_PLAYER_PER_ACCOUNT5
snprintf(szQuery, sizeof(szQuery), "UPDATE player_index%s SET empire=%u WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u OR pid5=%u AND empire=%u",
get_table_postfix(), empire, GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire());
#else
snprintf(szQuery, sizeof(szQuery), "UPDATE player_index%s SET empire=%u WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u AND empire=%u",
get_table_postfix(), empire, GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire());
#endif
std::unique_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(szQuery));
@@ -181,8 +190,13 @@ DWORD CHARACTER::GetAID() const
char szQuery[1024+1];
DWORD dwAID = 0;
#ifdef ENABLE_PLAYER_PER_ACCOUNT5
snprintf(szQuery, sizeof(szQuery), "SELECT id FROM player_index%s WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u OR pid5=%u AND empire=%u",
get_table_postfix(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire());
#else
snprintf(szQuery, sizeof(szQuery), "SELECT id FROM player_index%s WHERE pid1=%u OR pid2=%u OR pid3=%u OR pid4=%u AND empire=%u",
get_table_postfix(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetPlayerID(), GetEmpire());
#endif
SQLMsg* pMsg = DBManager::instance().DirectQuery(szQuery);
+2 -2
View File
@@ -571,9 +571,9 @@ typedef struct SPacketGTLogin
void CInputLogin::Entergame(LPDESC d, const char * data)
{
// PORT: wear40 moves dragon-soul/belt cells; older clients must not enter this world.
// PORT: wear40 moves dragon-soul/belt cells; mt20261029 adds the conqueror fields and five slots; older clients must not enter this world.
const char* revision=strstr(d->GetClientVersion(),"mt");
if(!revision || atoi(revision+2)<20261028)
if(!revision || atoi(revision+2)<20261029)
{
if(d->GetCharacter())d->GetCharacter()->ChatPacket(CHAT_TYPE_INFO,"Please update the client before entering the game.");
d->DelayedDisconnect(1);return;
+2
View File
@@ -1034,11 +1034,13 @@ static void __LocaleService_Init_Taiwan()
static void __CheckPlayerSlot(const std::string& service_name)
{
#ifndef ENABLE_PLAYER_PER_ACCOUNT5
if (PLAYER_PER_ACCOUNT != 4)
{
printf("<ERROR> PLAYER_PER_ACCOUNT = %d\n", PLAYER_PER_ACCOUNT);
exit(0);
}
#endif
}
bool LocaleService_Init(const std::string& c_rstServiceName)
+13 -8
View File
@@ -1,11 +1,11 @@
-- AVA2 conqueror (Yohara) level: per-player columns read/written by db ClientManagerLogin/Player.
-- Idempotent: run against the player schema (player / player_sb).
DROP PROCEDURE IF EXISTS mt_conqueror_add_columns;
-- Idempotent: run against the player schema (player / player_sb). Adds the columns to player and player_deleted.
DROP PROCEDURE IF EXISTS mt_conqueror_add_columns_to;
DELIMITER //
CREATE PROCEDURE mt_conqueror_add_columns()
CREATE PROCEDURE mt_conqueror_add_columns_to(tbl VARCHAR(64))
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'player' AND COLUMN_NAME = 'conquerorlevel') THEN
ALTER TABLE player
IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = tbl AND COLUMN_NAME = 'conquerorlevel') THEN
SET @mt_sql = CONCAT('ALTER TABLE ', tbl, '
ADD COLUMN conquerorlevel tinyint(3) unsigned NOT NULL DEFAULT 0,
ADD COLUMN conqueror_level_step tinyint(3) unsigned NOT NULL DEFAULT 0,
ADD COLUMN sungma_str smallint(6) NOT NULL DEFAULT 0,
@@ -13,9 +13,14 @@ BEGIN
ADD COLUMN sungma_move smallint(6) NOT NULL DEFAULT 0,
ADD COLUMN sungma_inmune smallint(6) NOT NULL DEFAULT 0,
ADD COLUMN conqueror_exp int(10) unsigned NOT NULL DEFAULT 0,
ADD COLUMN conqueror_point smallint(6) NOT NULL DEFAULT 0;
ADD COLUMN conqueror_point smallint(6) NOT NULL DEFAULT 0');
PREPARE mt_stmt FROM @mt_sql;
EXECUTE mt_stmt;
DEALLOCATE PREPARE mt_stmt;
END IF;
END //
DELIMITER ;
CALL mt_conqueror_add_columns();
DROP PROCEDURE mt_conqueror_add_columns;
-- player_deleted too: db PLAYER_DELETE copies rows with INSERT INTO player_deleted SELECT * FROM player.
CALL mt_conqueror_add_columns_to('player');
CALL mt_conqueror_add_columns_to('player_deleted');
DROP PROCEDURE mt_conqueror_add_columns_to;
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
# db PLAYER_DELETE copies the row with INSERT INTO player_deleted SELECT * FROM player, so the two tables
# need the same columns in the same order. Appends the player columns player_deleted lacks (columns added
# to player by later schema changes, e.g. HEAD inventory_0..5/shopFlag, conqueror), then checks the order.
# sh sync.sh <player db> e.g. sh sync.sh player_sb
set -e
DB=${1:?player db}
Q="mysql -uroot -N $DB -e"
ALTER=$($Q "SELECT GROUP_CONCAT(CONCAT('ADD COLUMN \`', column_name, '\` ', column_type,
IF(is_nullable='NO', ' NOT NULL', ' NULL'),
IF(column_default IS NULL, '', CONCAT(' DEFAULT ', QUOTE(column_default))))
ORDER BY ordinal_position SEPARATOR ', ')
FROM information_schema.COLUMNS p WHERE table_schema=DATABASE() AND table_name='player'
AND column_name NOT IN (SELECT column_name FROM information_schema.COLUMNS WHERE table_schema=DATABASE() AND table_name='player_deleted')")
if [ "$ALTER" != NULL ]; then
echo "ALTER TABLE player_deleted $ALTER"
$Q "ALTER TABLE player_deleted $ALTER"
fi
BAD=$($Q "SELECT COUNT(*) FROM information_schema.COLUMNS p LEFT JOIN information_schema.COLUMNS d
ON d.table_schema=p.table_schema AND d.table_name='player_deleted' AND d.ordinal_position=p.ordinal_position
WHERE p.table_schema=DATABASE() AND p.table_name='player' AND (d.column_name IS NULL OR d.column_name<>p.column_name)")
[ "$BAD" = 0 ] || { echo "player_deleted column order differs from player in $BAD places" >&2; exit 1; }
echo "player_deleted matches player"
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
# Five character slots: player_index.pid5. Idempotent.
# sh install.sh <player db> e.g. sh install.sh player_sb
# Install before starting a db/game built with ENABLE_PLAYER_PER_ACCOUNT5 (its login queries select pid5).
set -e
DB=${1:?player db}
HERE=$(cd "$(dirname "$0")" && pwd)
HAS=$(mysql -uroot -N "$DB" -e "SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='$DB' AND TABLE_NAME='player_index' AND COLUMN_NAME='pid5'")
[ "$HAS" = 0 ] && mysql -uroot "$DB" < "$HERE/schema.sql"
mysql -uroot "$DB" -e "SHOW COLUMNS FROM player_index LIKE 'pid%'"
+2
View File
@@ -0,0 +1,2 @@
-- Five character slots (ENABLE_PLAYER_PER_ACCOUNT5): player_index gets a fifth pid column.
ALTER TABLE player_index ADD pid5 int(11) NOT NULL DEFAULT 0 AFTER pid4, ADD KEY pid5_key (pid5);