mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-18 17:55:27 +00:00
Live kept the total before the running session in <char time> and the session's seconds in <char stime>; both changed at a login, together with llog (time 262486 and stime 7344 became time 269830 at the next login). The client reads both (LWOCharacterComponent::LoadFromSaveData 0x00ca4910) and shows their sum (SendMessage 0x00d34330, GetTimePlayed). The server wrote everything into time and no stime. Now time + stime is read (a missing stime is 0, so a save from before keeps its total) and time and stime are written as live had them. A session starts when the character is picked on the character list: charinfo.last_login is loaded with the character, a save whose llog is another login has its stime moved into time, and llog is written as the session's login. Without a known login the session goes on. GetTotalTimePlayed is still every second played. The dashboard's save check knows stime as a number. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
68 lines
2.2 KiB
C++
68 lines
2.2 KiB
C++
#ifndef __ICHARINFO__H__
|
|
#define __ICHARINFO__H__
|
|
|
|
#include <cstdint>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
#include "ePermissionMap.h"
|
|
#include "json.hpp"
|
|
|
|
class ICharInfo {
|
|
public:
|
|
struct Info {
|
|
std::string name;
|
|
std::string pendingName;
|
|
LWOOBJID id{};
|
|
uint32_t accountId{};
|
|
bool needsRename{};
|
|
LWOCLONEID cloneId{};
|
|
ePermissionMap permissionMap{};
|
|
// charinfo.last_login: when the character was last picked on the character list (unix seconds)
|
|
uint64_t lastLogin{};
|
|
};
|
|
|
|
// Get the approved names of all characters.
|
|
virtual std::vector<std::string> GetApprovedCharacterNames() = 0;
|
|
|
|
// Get the id and name of every character in one query
|
|
virtual std::vector<std::pair<LWOOBJID, std::string>> GetCharacterIdsAndNames() = 0;
|
|
|
|
// Get characters with a pending name change, in DataTables format
|
|
virtual nlohmann::json GetPendingNamesTable(const uint32_t start, const uint32_t length) = 0;
|
|
|
|
virtual void SetCharacterPermissionMap(const LWOOBJID characterId, const uint64_t permissionMap) = 0;
|
|
|
|
// Get the character info for the given character id.
|
|
virtual std::optional<ICharInfo::Info> GetCharacterInfo(const LWOOBJID charId) = 0;
|
|
|
|
// Get the character info for the given character name.
|
|
virtual std::optional<ICharInfo::Info> GetCharacterInfo(const std::string_view name) = 0;
|
|
|
|
// Get the character ids for the given account.
|
|
virtual std::vector<LWOOBJID> GetAccountCharacterIds(const LWOOBJID accountId) = 0;
|
|
|
|
// Get the total number of characters in the database.
|
|
virtual uint32_t GetCharacterCount() = 0;
|
|
|
|
// Insert a new character into the database.
|
|
virtual void InsertNewCharacter(const ICharInfo::Info info) = 0;
|
|
|
|
// Set the name of the given character.
|
|
virtual void SetCharacterName(const LWOOBJID characterId, const std::string_view name) = 0;
|
|
|
|
// Set the pending name of the given character.
|
|
virtual void SetPendingCharacterName(const LWOOBJID characterId, const std::string_view name) = 0;
|
|
|
|
// Updates the given character ids last login to be right now.
|
|
virtual void UpdateLastLoggedInCharacter(const LWOOBJID characterId) = 0;
|
|
|
|
virtual bool IsNameInUse(const std::string_view name) = 0;
|
|
|
|
virtual nlohmann::json GetCharacterById(const LWOOBJID charId) = 0;
|
|
};
|
|
|
|
#endif //!__ICHARINFO__H__
|