From cf66bb33107dd0593e430e0c4e9d88b2b96cf6b2 Mon Sep 17 00:00:00 2001 From: Tr0n Date: Tue, 9 Apr 2024 17:25:39 +0200 Subject: [PATCH] revert name change removal --- src/game/src/questlua_pc.cpp | 59 +++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/src/game/src/questlua_pc.cpp b/src/game/src/questlua_pc.cpp index afb9a65..8d53904 100644 --- a/src/game/src/questlua_pc.cpp +++ b/src/game/src/questlua_pc.cpp @@ -2063,7 +2063,64 @@ teleport_area: // 3: 이미 같은 이름이 사용중 // 4: 성공 // 5: 해당 기능 지원하지 않음 - lua_pushnumber(L, 5); + + LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); + + if ( ch->GetNewName().size() != 0 ) + { + lua_pushnumber(L, 0); + return 1; + } + + if ( lua_isstring(L, 1) != true ) + { + lua_pushnumber(L, 1); + return 1; + } + + const char * szName = lua_tostring(L, 1); + + if ( check_name(szName) == false ) + { + lua_pushnumber(L, 2); + return 1; + } + + char szQuery[1024]; + snprintf(szQuery, sizeof(szQuery), "SELECT COUNT(*) FROM player%s WHERE name='%s'", get_table_postfix(), szName); + std::unique_ptr pmsg(DBManager::instance().DirectQuery(szQuery)); + + if ( pmsg->Get()->uiNumRows > 0 ) + { + MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult); + + int count = 0; + str_to_number(count, row[0]); + + // 이미 해당 이름을 가진 캐릭터가 있음 + if ( count != 0 ) + { + lua_pushnumber(L, 3); + return 1; + } + } + + DWORD pid = ch->GetPlayerID(); + db_clientdesc->DBPacketHeader(HEADER_GD_FLUSH_CACHE, 0, sizeof(DWORD)); + db_clientdesc->Packet(&pid, sizeof(DWORD)); + + /* delete messenger list */ + MessengerManager::instance().RemoveAllList(ch->GetName()); + + /* change_name_log */ + LogManager::instance().ChangeNameLog(pid, ch->GetName(), szName, ch->GetDesc()->GetHostName()); + + snprintf(szQuery, sizeof(szQuery), "UPDATE player%s SET name='%s' WHERE id=%u", get_table_postfix(), szName, pid); + SQLMsg * msg = DBManager::instance().DirectQuery(szQuery); + M2_DELETE(msg); + + ch->SetNewName(szName); + lua_pushnumber(L, 4); return 1; }