Core/Players: Store player creation timestamp and type (normal/npe)

Port From (https://github.com/TrinityCore/TrinityCore/commit/11762273c68b24b332238aa89a73b9ed9ac1d249)
This commit is contained in:
hondacrx
2021-10-02 20:50:59 -04:00
parent 9785c8cb0e
commit 4a97883559
7 changed files with 36 additions and 4 deletions
@@ -784,4 +784,10 @@ namespace Framework.Constants
Contested = 3,
Combat = 4
}
public enum PlayerCreateMode
{
Normal = 0,
NPE = 1
}
}
@@ -81,7 +81,7 @@ namespace Framework.Database
PrepareStatement(CharStatements.INS_BATTLEGROUND_RANDOM, "INSERT INTO character_battleground_random (guid) VALUES (?)");
PrepareStatement(CharStatements.SEL_CHARACTER, "SELECT c.guid, account, name, race, class, gender, level, xp, money, inventorySlots, bankSlots, restState, playerFlags, playerFlagsEx, " +
"position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, " +
"position_x, position_y, position_z, map, orientation, taximask, createTime, createMode, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, " +
"resettalents_time, primarySpecialization, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeonDifficulty, " +
"totalKills, todayKills, yesterdayKills, chosenTitle, watchedFaction, drunk, health, power1, power2, power3, power4, power5, power6, instance_id, activeTalentGroup, lootSpecId, exploredZones, " +
"knownTitles, actionBars, raidDifficulty, legacyRaidDifficulty, fishingSteps, honor, honorLevel, honorRestState, honorRestBonus, numRespecs " +
@@ -472,10 +472,10 @@ namespace Framework.Database
// Player saving
PrepareStatement(CharStatements.INS_CHARACTER, "INSERT INTO characters (guid, account, name, race, class, gender, level, xp, money, inventorySlots, bankSlots, restState, playerFlags, playerFlagsEx, " +
"map, instance_id, dungeonDifficulty, raidDifficulty, legacyRaidDifficulty, position_x, position_y, position_z, orientation, trans_x, trans_y, trans_z, trans_o, transguid, " +
"taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, primarySpecialization, " +
"taximask, createTime, createMode, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, primarySpecialization, " +
"extra_flags, stable_slots, at_login, zone, death_expire_time, taxi_path, totalKills, todayKills, yesterdayKills, chosenTitle, watchedFaction, drunk, health, power1, power2, power3, " +
"power4, power5, power6, latency, activeTalentGroup, lootSpecId, exploredZones, equipmentCache, knownTitles, actionBars, lastLoginBuild) VALUES " +
"(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
"(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
PrepareStatement(CharStatements.UPD_CHARACTER, "UPDATE characters SET name=?,race=?,class=?,gender=?,level=?,xp=?,money=?,inventorySlots=?,bankSlots=?,restState=?,playerFlags=?,playerFlagsEx=?," +
"map=?,instance_id=?,dungeonDifficulty=?,raidDifficulty=?,legacyRaidDifficulty=?,position_x=?,position_y=?,position_z=?,orientation=?,trans_x=?,trans_y=?,trans_z=?,trans_o=?,transguid=?,taximask=?,cinematic=?,totaltime=?,leveltime=?,rest_bonus=?," +
"logout_time=?,is_logout_resting=?,resettalents_cost=?,resettalents_time=?,numRespecs=?,primarySpecialization=?,extra_flags=?,stable_slots=?,at_login=?,zone=?,death_expire_time=?,taxi_path=?," +
+6
View File
@@ -2551,6 +2551,8 @@ namespace Game.Entities
uint mapId = result.Read<ushort>(fieldIndex++);
float orientation = result.Read<float>(fieldIndex++);
string taximask = result.Read<string>(fieldIndex++);
long createTime = result.Read<long>(fieldIndex++);
PlayerCreateMode createMode = (PlayerCreateMode)result.Read<byte>(fieldIndex++);
byte cinematic = result.Read<byte>(fieldIndex++);
uint totaltime = result.Read<uint>(fieldIndex++);
uint leveltime = result.Read<uint>(fieldIndex++);
@@ -3030,6 +3032,8 @@ namespace Game.Entities
SetDrunkValue(newDrunkValue);
m_createTime = createTime;
m_createMode = createMode;
m_cinematic = cinematic;
m_PlayedTimeTotal = totaltime;
m_PlayedTimeLevel = leveltime;
@@ -3385,6 +3389,8 @@ namespace Game.Entities
ss.Append(m_taxi.m_taximask[i] + " ");
stmt.AddValue(index++, ss.ToString());
stmt.AddValue(index++, m_createTime);
stmt.AddValue(index++, (byte)m_createMode);
stmt.AddValue(index++, m_cinematic);
stmt.AddValue(index++, m_PlayedTimeTotal);
stmt.AddValue(index++, m_PlayedTimeLevel);
@@ -196,6 +196,9 @@ namespace Game.Entities
public PlayerData m_playerData;
public ActivePlayerData m_activePlayerData;
long m_createTime;
PlayerCreateMode m_createMode;
uint m_nextSave;
byte m_cinematic;
+1
View File
@@ -194,6 +194,7 @@ namespace Game.Entities
}
SetMap(Global.MapMgr.CreateMap(info.MapId, this));
m_createTime = GameTime.GetGameTime();
UpdatePositionData();
PowerType powertype = cEntry.DisplayPower;
+5 -1
View File
@@ -1806,6 +1806,8 @@ CREATE TABLE `characters` (
`orientation` float NOT NULL DEFAULT '0',
`taximask` text NOT NULL,
`online` tinyint(3) unsigned NOT NULL DEFAULT '0',
`createTime` bigint(20) NOT NULL DEFAULT '0',
`createMode` tinyint(4) NOT NULL DEFAULT '0',
`cinematic` tinyint(3) unsigned NOT NULL DEFAULT '0',
`totaltime` int(10) unsigned NOT NULL DEFAULT '0',
`leveltime` int(10) unsigned NOT NULL DEFAULT '0',
@@ -3718,7 +3720,9 @@ INSERT INTO `updates` VALUES
('2021_05_11_00_characters.sql','C3F0337CE8363F970AB4FDB9D23BBB7C650A0B0E','ARCHIVED','2021-05-11 15:39:26',0),
('2021_07_04_00_characters.sql','E0E7AD664DDB553E96B457DD9ED8976665E94007','ARCHIVED','2021-07-04 22:23:24',0),
('2021_08_11_00_characters.sql','2137A52A45B045104B97D39626CE3C0214625B17','ARCHIVED','2021-08-11 21:48:57',0),
('2021_08_18_00_characters.sql','5BA1326EE8EC907CDE82E6E8BCB38EA2E661F10A','ARCHIVED','2021-08-18 15:14:17',0);
('2021_08_18_00_characters.sql','5BA1326EE8EC907CDE82E6E8BCB38EA2E661F10A','ARCHIVED','2021-08-18 15:14:17',0),
('2021_10_02_00_characters.sql','C6831D3ED03F6BD390A5E5E403FA402D6DC0E95D','RELEASED','2021-10-02 21:21:37',0),
('2021_10_02_01_characters.sql','F97B956F3B5F909294CA399F75B5795A07C4D8EC','RELEASED','2021-10-02 21:47:38',0);
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
UNLOCK TABLES;
@@ -0,0 +1,12 @@
ALTER TABLE `characters`
ADD `createTime` bigint(20) NOT NULL DEFAULT '0' AFTER `online`,
ADD `createMode` tinyint(4) NOT NULL DEFAULT '0' AFTER `createTime`;
-- AT_LOGIN_FIRST: Characters that have never logged in have accurate creation timestamp in `logout_time`
UPDATE `characters` SET `createTime`=`logout_time` WHERE (`at_login` & 0x20) != 0;
-- attempt to find lowest criteria timestamp for characters that have logged in already
UPDATE `characters` SET `createTime`=(SELECT COALESCE(MIN(candidates.`date`), UNIX_TIMESTAMP()) FROM (
SELECT MIN(cap.`date`) `date` FROM `character_achievement_progress` cap WHERE cap.`guid`=`characters`.`guid`
UNION
SELECT MIN(ca.`date`) `date` FROM `character_achievement` ca WHERE ca.`guid`=`characters`.`guid`
) candidates) WHERE (`at_login` & 0x20) = 0;