forgottenserver icon indicating copy to clipboard operation
forgottenserver copied to clipboard

Move players record to lua

Open ramon-bernardo opened this issue 1 year ago • 3 comments

Pull Request Prelude

Changes Proposed

  • Move players record to lua.
  • Saves the record only when the server save.
  • Remove globalevent onRecord.

Test required

  • I added a ScriptInterface to Game, but I am unsure of its limitations. It’s necessary to check whether what I’ve implemented is correct, including Game::getPlayersRecord()

ramon-bernardo avatar Nov 17 '24 18:11 ramon-bernardo

@MillhioreBT I agree—if only we had a status server in Lua or something like an Http Client, we wouldn’t need to call Lua in Game.cpp.

  • However, I disagree regarding performance. Unlike before, where an UPDATE was performed every time a player joined, now it only occurs when save the game.

  • I didn’t recall Game.getPlayerCount(). I'll make the adjustment!

  • If I’m not mistaken, it’s no longer necessary to call result.free. This is because of the automatic cleanup we perform after every Lua call, using tfs::lua::resetScriptEnv(). However, I can add it explicitly if needed.

I’m not a fan of Game::Game() : scriptInterface("Game Interface"). If anyone has a better idea, im open to suggestions 🫤

ramon-bernardo avatar Nov 28 '24 20:11 ramon-bernardo

Just keep a running counter of players online that increases with a creaturescript of type login and decreases with a logout

ranisalt avatar Nov 28 '24 22:11 ranisalt

Wasn't this already a thing back in like 1.2 1.0 and it got removed?

NRH-AA avatar Feb 06 '25 12:02 NRH-AA