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
Rankings rewrite #474
Rankings rewrite #474
Conversation
The forward won't be used at all and I don't plan on rewriting it, as point recalculation will happens upon command/map change.
Considering I've added OnUserCmdPre this can be decent to help others see that autobhop is enabled. Added this because I was REALLY surprised that people don't seem to realize you can hold the spacebar, and there are just so many of them.. it's insane.
This is what happens when I only test with USP :/.
It looks much better tbh.
Is there a default tier, if so is it set through a cvar? If not are maps just unranked by default or not playable? |
@strafe the default tier is 1. I decided to make the default tier 1 instead of anything higher because maps like bhop_freedompuppies are often forgotten and will award lots of points. Players will usually not report such issues to server admins as they benefit from the map being tiered high. |
@Lime18 my apologies for taking 18 days to investigate, but it should work now! :) |
@shavitush It works, thanks :) |
Could you add a command for scoring points all the maps? It's not very convenient to use sm_recalcmap on every map, when the maps are more than 200 :( |
@Lime18 will do! |
Use the command (run as ROOT) to retroactively calculate points for all maps, styles and tracks with tiers assigned.
@Lime18 |
@shavitush Thank you so much :) |
Thanks to DoNotMiss from YOURGAME bhop server.
Default value of 'shavit_core_velocityteleport' has been changed to 0. Change it manually in the config file of shavit-core for the changes to apply.
Added `bool manual` to `Shavit_OnStyleChanged`.
I hope this won't be a bad solution, but I commented the code with a solution just in-case!
Just wrote this for MySQL/MariaDB: this is a stored procedure that should replace SourceMod sending 1 query per ranked player. It works! However, the query takes over 50 seconds on my database with 10k~ users and 25k~ times, it's definitely not acceptable.. DROP PROCEDURE IF EXISTS UpdateAllPoints;
DELIMITER ;;
CREATE PROCEDURE UpdateAllPoints()
BEGIN
DECLARE authid VARCHAR(32);
DECLARE done INT DEFAULT 0;
DECLARE cur CURSOR FOR (SELECT auth FROM playertimes WHERE points > 0.0 GROUP BY auth);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cur;
ranks: LOOP
FETCH cur INTO authid;
IF done THEN
LEAVE ranks;
END IF;
UPDATE users u JOIN (SELECT SUM((points * (@f := 0.975 * @f) / 0.975)) total FROM playertimes t
CROSS JOIN (SELECT @f := 1.0) params WHERE points > 0.0 AND auth = authid ORDER BY points DESC) temp
SET u.points = temp.total WHERE auth = authid;
END LOOP;
CLOSE cur;
END;;
DELIMITER ;
CALL UpdateAllPoints(); |
Got rid of a JOIN by directly setting the value. I'm still looking for a way to optimize this further, and this pull request sadly won't be merged until I do.
Well.. using the procedure above, I decided to do some optimization with indexes/data types in my server's database. By doing that, I cut the execution time from 58.656 seconds to 5.750!
I believe it can be optimized even further, but I'm not an SQL expert unfortunately so it's hard on me. I'll push a commit that adds the indexes and changes |
BIG optimization.
Are you happy to merge this now @shavitush or still wanting to optimise it further? |
I'll implement the procedure into the code itself, and then I'll merge this pull request. Then I'll work on the other things in this to-do in another pull request. |
Ugly workaround but we can't use multiple queries in the same line in SourceMod.
Fixes #465.
Note: This version of rankings doesn't support SQLite, I'm sorry but I can't wrap my head around getting
UpdateAllPoints
,UpdatePlayerPoints
andRecalculateMap
to work on SQLite. If you can do it, please send a pull request or post a patch here.Differences:
shavit-chat
after release. I don't have too much time for that right now unfortunately..sm_top
.Shavit_OnRankUpdated
because it has no real use.Extras:
{rand}
in CS:GO chat processing.weapon_glock
ammo not refilling.To-do before merging:
[shavit-rankings.smx] Transaction query (0): Column 'points' cannot be null
.workshop/
will never show in map names.Shavit_GetDB
(make itShavit_GetDatabase
).sm_stats
from opening before the menu is fully loaded.To be done sometime:
GetSteamAccountID
?) rather than the current SteamID. This will allow faster indexes and database I/O.After installing, set the map's tier with
sm_settier
and then runsm_recalcall
(ROOT command) once to apply all the points retroactively. When you add new tiers for maps, the points for them will adjust accordingly.I've tested this in a rather small server (10 users in the database) and everything was fine. Let me know if there are any issues. I'll merge when I'm done with implementing the last to-dos if there are no issues reported.