otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.55k stars 1.04k forks source link

Remove Account class and account.h file #4730

Closed ranisalt closed 1 week ago

ranisalt commented 1 month ago

Pull Request Prelude

Changes Proposed

The Account class serves just as a temporary storage for database queries and is not really necessary, since it's never used to pass data between functions. The loadAccount function is only used once and can be inlined and some columns can be omitted from it.

EvilHero90 commented 1 month ago

Need to remove the dependencies of the vs Project File

Erza commented 1 month ago

To be honest I'd much rather see Account becoming a metatable, there's been a couple times where that would have been nice. For example you could then do something like

local account = player:getAccount()
local guid = account:getId()
local email = account:getEmail()

account:addCoins(50)

function Player.addCoins(amount)
    self:getAccount():addCoins(amount)
end

player:addCoins(50)

account:addPremiumDays(7)
account:setType(ACCOUNT_TYPE_GOD)

local accountType = account:getType()

...
ranisalt commented 2 weeks ago

To be honest I'd much rather see Account becoming a metatable, there's been a couple times where that would have been nice

Agreed, but it can be done in Lua, doesn't need the C++ overhead :P