Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform gameworld authentication using character ID #4366

Merged
merged 1 commit into from
Apr 5, 2023

Conversation

ranisalt
Copy link
Member

@ranisalt ranisalt commented Apr 2, 2023

Pull Request Prelude

Changes Proposed

Instead of performing gameworld authentication and login using the character name, instead read the character ID as early as possible and use that instead. This reduces the need to pass strings around.

Issues addressed:
Fixes #4359
Closes #4360

@conde2
Copy link
Contributor

conde2 commented Apr 3, 2023

I think this need to be more benchmarked, because having to perform a JOIN is probably worse then passing some strings around.

DBResult_ptr result = db.storeQuery(fmt::format(
	    "SELECT `a`.`id` AS `account_id`, `a`.`password`, `a`.`secret`, `p`.`id` AS `character_id` FROM `accounts` `a` JOIN `players` `p` ON `a`.`id` = `p`.`account_id` WHERE (`a`.`name` = {:s} OR `a`.`email` = {:s}) AND `p`.`name` = {:s} AND `p`.`deletion` = 0",
	    db.escapeString(accountName), db.escapeString(accountName), db.escapeString(characterName)));

@ranisalt
Copy link
Member Author

ranisalt commented Apr 3, 2023

I think this need to be more benchmarked, because having to perform a JOIN is probably worse then passing some strings around.

This is doing a join on indexed columns. It will be equal or faster than running two separate queries.

I did the test anyway, and on my machine the join takes as much time (0.012s) as each of the separate queries (~0.011s each); therefore it halves the running time.

@ranisalt
Copy link
Member Author

ranisalt commented Apr 4, 2023

@ArturKnopik could you check if this also fixes #4359 for you or if #4360 is still required? Working fine but I use Linux

@krecikondexin
Copy link

@ranisalt i will check it today

@ArturKnopik
Copy link
Contributor

Debug build on windows works without issue, i can login to the game server without any problem

@ranisalt ranisalt merged commit 6028b5d into otland:master Apr 5, 2023
@ranisalt
Copy link
Member Author

ranisalt commented Apr 5, 2023

Thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cant login to game when server is built in debug mode
5 participants