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

Command manager #5

Merged
merged 846 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
846 commits
Select commit Hold shift + click to select a range
027faf9
Merge https://github.com/supertuxkart/stk-code (at 3b043b7) into comm…
kimden Jul 24, 2023
a47e69d
Add animated by step texture matrix for kart model
Benau Jul 27, 2023
1ff9008
Fix start button clearing m_available_kts if no tracks are available …
kimden Aug 6, 2023
a03a99c
Show full command line in case a local/not implemented command is inv…
kimden Aug 6, 2023
885fe4a
Allow sorting output of /everypas by any column
kimden Aug 6, 2023
e00a81a
Fix broken ProgressBarMessage after 8f596e29b3a4ae249018c98054e64d429…
Benau Aug 15, 2023
9516a44
Fix /record command listing quit times and force it to print only tim…
kimden Aug 23, 2023
f5cc8b4
Small fixes in android build script
deveee Sep 30, 2023
f6c766c
Fix shuffle in TrackFilter that wasn't uniform
kimden Nov 8, 2023
491c3de
Fix updateAndTestFinished to use time2ticks
Alayan-stk-2 Nov 10, 2023
6c2dd48
Changelog update
Alayan-stk-2 Nov 10, 2023
f4fd914
Mostly revert #4632 and properly fix #4609
Alayan-stk-2 Nov 11, 2023
0eb64d0
Fix #4922 by enforcing the bounds
Alayan-stk-2 Nov 11, 2023
7ecdc3e
Update macOS building instructions
Benau Nov 12, 2023
1ba1e7e
Use high precision for time2Ticks
Benau Nov 12, 2023
bd245e1
Fix #4895 (#4896)
CodingJellyfish Nov 12, 2023
8cd6a23
Enable AppleMomentumScrollSupported on macOS
Benau Nov 12, 2023
858ed6b
Fix #4926
Alayan-stk-2 Nov 12, 2023
8048f98
Allow tournament referees to change what maps the server considers to…
kimden Nov 15, 2023
40511b2
Fix #4938
Alayan-stk-2 Nov 17, 2023
e744fd3
More audio improvements
Alayan-stk-2 Nov 17, 2023
2a90327
Fix #4844
Alayan-stk-2 Nov 24, 2023
bf88954
Fix #4944
Alayan-stk-2 Nov 24, 2023
a57ac41
Fix #3578
Alayan-stk-2 Nov 24, 2023
cf4e5b7
Update results table creation query with new fields
kimden Nov 25, 2023
5bb5f5e
Fix #4951
Alayan-stk-2 Nov 29, 2023
4ca872f
Make the unsupported replay version warning more compact
Alayan-stk-2 Nov 29, 2023
6d38bfe
Fix 'Replay with UID of lu' error
Alayan-stk-2 Dec 6, 2023
f8db600
Fix #4965
Alayan-stk-2 Dec 14, 2023
bba568d
Use theme color for textbox cursor and fix #4947
Alayan-stk-2 Dec 14, 2023
65ee612
Fix #3754 (#4966)
CodingJellyfish Dec 14, 2023
c11a723
Drop support for the DirectX9 renderer
Alayan-stk-2 Dec 16, 2023
4525411
Remove DX9 leftovers
Alayan-stk-2 Dec 16, 2023
5a4020b
Revert "Remove DX9 leftovers"
Benau Dec 18, 2023
caf6a1b
Revert "Drop support for the DirectX9 renderer"
Benau Dec 18, 2023
42d4eaa
Fix switch build
Benau Dec 18, 2023
b35cd18
Fix #4969 (#4985)
CodingJellyfish Jan 6, 2024
3928a49
Fix #4923 (#4981)
CodingJellyfish Jan 6, 2024
2e89eee
Fix #3471 v2 (#4989)
CodingJellyfish Jan 7, 2024
fab7915
Minor fix on coding styles.
xiaoxq Jan 7, 2024
6573ebe
Fix #4960 (#5003)
S0nter Jan 17, 2024
ec83629
Fix #4984 & #4995 (#4998)
CodingJellyfish Jan 17, 2024
e1454a0
Fix memory corruption when vector being resized
Benau Jan 25, 2024
4617ff1
Put temporary teams in a separate unit utils/team_utils.*
kimden Feb 7, 2024
a254c7a
make loopback checking more readable (#5016)
imnotpoz Feb 7, 2024
15c67f5
Allow server to kick players for inactivity while there's no game (wi…
kimden Feb 8, 2024
b8d6300
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden Feb 8, 2024
11e2b26
Initial implementation of cyclic map queue [big description]
kimden Feb 19, 2024
1a8dbbd
Fix #5024
Benau Feb 23, 2024
b5eeb68
Add kart queue (regular + cyclic), currently only for standard karts
kimden Feb 28, 2024
a582102
Bugfixes for kart queue + canRace is not invoked at 300 Hz now
kimden Feb 28, 2024
3f217b0
More bug fixes for kart queue + AI choose standard karts only on the …
kimden Feb 29, 2024
4aed434
Prevent kart placeholders from null pointer dereferencing when settin…
kimden Mar 1, 2024
e18cd66
Avoid nullptr usage by not checking the number of players on FFA aren…
kimden Mar 1, 2024
979077a
Update Cantarell font
oldherl Mar 20, 2024
9e499d8
Don't (mistakenly) reset kart data upon loading the world
kimden Mar 26, 2024
4ee7c51
Fix random choice of several equal votes in handleAllVotes
kimden Apr 1, 2024
c520c44
Don't pick first vote if vote majority is achieved but no vote coinci…
kimden Apr 1, 2024
31bdb52
Make sure handleAllVotes returns true at least once
kimden Apr 1, 2024
180a207
Merge https://github.com/supertuxkart/stk-code (as of 31bdb52) into c…
kimden Apr 2, 2024
dcfe18d
Don't invoke canRace from checkPeersReady after selection has started
kimden Apr 3, 2024
e359adc
Try to remove a compilation error and a few warnings in server_lobby.cpp
kimden Apr 3, 2024
e232bcf
improve MinGW build
ognevny Apr 8, 2024
581ba79
Update readme and fork changes to reflect latest commits and branches
kimden Apr 9, 2024
6cf094a
Add new setting values for increased view distances
Alayan-stk-2 Apr 14, 2024
8577408
LOD improvements (#5038)
CodingJellyfish Apr 15, 2024
797dcff
Allow to forbid playing based on fraction of official assets
kimden Apr 15, 2024
a6cecd2
First steps for a benchmark mode
Alayan-stk-2 Apr 16, 2024
6be521f
Fix #5054 (#5055)
CodingJellyfish Apr 17, 2024
667f2c4
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden Apr 17, 2024
754a110
Update gradle and android build script
deveee Apr 18, 2024
78c6f16
Fixed a crash when entering story mode
deveee Apr 18, 2024
2f87966
Add basic code for widget and screen resize
CodingJellyfish Apr 19, 2024
913a082
Keep multiplayer in kart selection screen after reloading
CodingJellyfish Apr 19, 2024
f70c2ab
Remove unneeded header file includes in online screens
CodingJellyfish Apr 19, 2024
52edb85
Remove the remaining unneeded header file includes
CodingJellyfish Apr 19, 2024
0cea06d
Add resizing code for icon button widget
CodingJellyfish Apr 19, 2024
3641183
Add resizing code for ribbon widget
CodingJellyfish Apr 20, 2024
2a60d65
Add resizing code for list widget
CodingJellyfish Apr 21, 2024
af1238d
Backport irrlicht changes to CGUISTKListBox
CodingJellyfish Apr 21, 2024
0d2fd6f
Recalculate glyph layouts when list box resized
CodingJellyfish Apr 21, 2024
34119e1
Remove unneeded if in Widget::resize
CodingJellyfish Apr 21, 2024
f683699
Use a better setOverrideFont in ribbon widget
CodingJellyfish Apr 22, 2024
85e52de
Add more resizing code to CGUISTKListBox
CodingJellyfish Apr 22, 2024
1319c98
Remove list header properly
CodingJellyfish Apr 23, 2024
db2cc69
Refactor sprite scaling in STKModifiedSpriteBank
CodingJellyfish Apr 23, 2024
171ac3c
Adapt the pause menu in benchmark mode
Alayan-stk-2 Apr 24, 2024
893c5a7
Move help and option files in subfolders
Alayan-stk-2 Apr 24, 2024
6e3ae05
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden Apr 24, 2024
e0be4cf
Reset coordinates before they are updated by layout manager
CodingJellyfish Apr 24, 2024
0dffd11
Remove unneeded hacks
CodingJellyfish Apr 24, 2024
5adbb3f
Add resizing code for spinner widget
CodingJellyfish Apr 25, 2024
8e5304d
Fix icon button widget crash
CodingJellyfish Apr 26, 2024
26b24a6
Add onResize for options screen video
CodingJellyfish Apr 26, 2024
e68acaa
Add resizing code for dynamic ribbon widget
CodingJellyfish Apr 26, 2024
62d0281
Adapt the end screen in benchmark mode (part 1)
Alayan-stk-2 Apr 26, 2024
792c1e0
Compute new performance metrics and improve saving of profiler data
Alayan-stk-2 Apr 26, 2024
543ee92
Confirm the performance report saving to the user
Alayan-stk-2 Apr 26, 2024
10b6c4b
Fix focus bug when multiplayer handling is not needed
CodingJellyfish Apr 26, 2024
e16c456
Add map voting method "pick random from all votes", allow to change i…
kimden Apr 26, 2024
97ca195
Fix dynamic ribbon widget being shown above a dialog after resized
CodingJellyfish Apr 27, 2024
17aa396
Add /whyhourglass to check if hourglass is caused by slots number or not
kimden Apr 27, 2024
f694997
Add resizing code for label widget
CodingJellyfish Apr 28, 2024
18094c5
Add resizing code for networking lobby
CodingJellyfish Apr 28, 2024
9206b92
Use xmlDecode for news
CodingJellyfish Apr 28, 2024
01d62be
Fix crashing when turning the modern renderer on or off before benchm…
Alayan-stk-2 Apr 28, 2024
e64e2d8
Fix #4931
Alayan-stk-2 Apr 28, 2024
5ff449d
Remove an unneeded method
CodingJellyfish Apr 29, 2024
3f8b78d
Add resizing code for CGUIEditBox
CodingJellyfish Apr 29, 2024
32a5382
Fix #5063
Alayan-stk-2 Apr 29, 2024
95c8f45
Update the LoD distance factors
Alayan-stk-2 Apr 29, 2024
ec4f406
Enable a higher maximum shadow resolution in the video settings
Alayan-stk-2 Apr 29, 2024
0716965
Improve Auto-LoD
Alayan-stk-2 Apr 29, 2024
c9d4473
Add resizing code for bubble widget
CodingJellyfish Apr 30, 2024
ff18633
Use proper method to shrink text in bubble widget to fix #3432
CodingJellyfish May 1, 2024
f8a43b8
Fix server only build
CodingJellyfish May 1, 2024
f73e56c
Add resizing code for dialog and screen keyboard
CodingJellyfish May 2, 2024
3123961
Add resizing code for add device dialog
CodingJellyfish May 3, 2024
e52b2fa
Add resizing code for soccer setup screen
CodingJellyfish May 3, 2024
26aa328
Add resizing code for credits
CodingJellyfish May 3, 2024
a14b9fd
Update linux build script
deveee May 3, 2024
0266b03
Add minimum resizing code for race result screen
CodingJellyfish May 4, 2024
3a0a2ea
Add resizing code for kart selection
CodingJellyfish May 4, 2024
7a75f9e
Clean up the Race Result GUI code
Alayan-stk-2 May 4, 2024
8fd0a0a
Split the displaySoccerResults function
Alayan-stk-2 May 4, 2024
0969a17
Fix #5069
Alayan-stk-2 May 4, 2024
7d02e57
Avoid resetting FOV which caused issue after resizing cutscene
CodingJellyfish May 5, 2024
6e2d528
Remove static variable in cutscenes
CodingJellyfish May 5, 2024
aba99c2
Enable new screen resizing code
CodingJellyfish May 5, 2024
7ad4040
Add a new 'Display' option tab
Alayan-stk-2 May 5, 2024
2fc05e9
Miscellaneous improvements to the options screens
Alayan-stk-2 May 5, 2024
ad02608
Remove code duplication in the options screens
Alayan-stk-2 May 5, 2024
fa421b4
Move the splitscreen split orientation in the display settings
Alayan-stk-2 May 5, 2024
7859157
Remove code duplication in the help screens
Alayan-stk-2 May 5, 2024
dae5c49
Add the label widget to common options includes
Alayan-stk-2 May 5, 2024
e47958f
Fix #5053 (bool vector -> uint8_t vector) (#5073)
Nomagno May 5, 2024
df803c1
Various adjustments to auto-LOD
Alayan-stk-2 May 6, 2024
553595f
Prevent geometry level from removing objects
Alayan-stk-2 May 6, 2024
e505d9c
Show a lower LoD level instead of having a detailled level pop up whe…
Alayan-stk-2 May 6, 2024
e83fdc9
Display a basic summary of benchmark results
Alayan-stk-2 May 7, 2024
8dbf0a9
Add geometry detail to the graphics presets
Alayan-stk-2 May 7, 2024
99868d5
Fix #5026
Alayan-stk-2 May 8, 2024
e9a75f6
Fix #3678
Alayan-stk-2 May 8, 2024
8e49634
Move the new quality switch logic to autoComputeLevel
Alayan-stk-2 May 8, 2024
6d01f8c
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden May 9, 2024
0542e6b
Fix #3671 and fix #4254
CodingJellyfish May 10, 2024
185772c
Fix a strict-aliasing violation
Alayan-stk-2 May 10, 2024
5883a27
Update credits
Alayan-stk-2 May 10, 2024
27ae455
Update the changelog
Alayan-stk-2 May 10, 2024
f2b6182
Allow changing splitscreen layout in race
Benau May 11, 2024
1c58f01
Add graphics settings to the perf report
Alayan-stk-2 May 11, 2024
3ec2b9a
Fix #4166
Alayan-stk-2 May 11, 2024
53b6267
Fix #5076
Alayan-stk-2 May 12, 2024
ad10bda
Add a 7th graphical level preset
Alayan-stk-2 May 12, 2024
68d9fd2
Fix #5067 (#5071)
CodingJellyfish May 12, 2024
e2c245c
Fix #4574 (#5080)
CodingJellyfish May 12, 2024
0f719d0
Fix #5072 (#5082)
Nomagno May 12, 2024
10943ac
New auto-LoD formula
Alayan-stk-2 May 13, 2024
91d3bce
Ensure the LOD multiplier is applied before the quality limiter
Alayan-stk-2 May 13, 2024
37e024f
Make the minimum distance for a LoD transition depend on the object's…
Alayan-stk-2 May 13, 2024
14c002c
Rewrite getSplitscreenWindow to fully occupy the remaining pixels
Benau May 17, 2024
02e540b
Rename variables to match the coding style
Benau May 17, 2024
fcd8cea
Remove hardcoded 1 pixel
Benau May 17, 2024
deff598
Prepare the GUI to recommend video settings
Alayan-stk-2 May 19, 2024
61f6f59
Fix #5075
Alayan-stk-2 May 19, 2024
fb3596f
Fix #3510
Alayan-stk-2 May 19, 2024
dca91a6
Move the start benchmark function to the profiler
Alayan-stk-2 May 20, 2024
97faf4a
Move the camera files in a subfolder
Alayan-stk-2 May 20, 2024
cbbc86b
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden May 20, 2024
48764a6
Update Wiiuse to 0.15.6
Alayan-stk-2 May 21, 2024
7d4e843
Require Cmake 3.6 or higher
Alayan-stk-2 May 21, 2024
7df170b
Fix dialog titles clashing with dialog borders
Alayan-stk-2 May 21, 2024
5bfb9aa
Fix an error detected by CI
Alayan-stk-2 May 21, 2024
e165a56
Fix #4742
Alayan-stk-2 May 21, 2024
2923a86
Minor fixes
Alayan-stk-2 May 21, 2024
c086a67
Misc. improvements
Alayan-stk-2 May 22, 2024
af18315
Clean up repetitive CTF code
Alayan-stk-2 May 22, 2024
57a80c2
Fix possibly missed dynamic spm buffer rendering
Benau May 23, 2024
3d86d93
Use forward enum declaration
Benau May 23, 2024
6906ca2
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden May 26, 2024
8b47411
Add new Desert skin
Alayan-stk-2 May 27, 2024
fa0bb71
Add new variants of the cartoon skin
Alayan-stk-2 May 27, 2024
d79cca3
Add a SKIN_MAKING.md file
Alayan-stk-2 May 27, 2024
06d503a
Use two distinct spinners to select skins
Alayan-stk-2 May 27, 2024
9271c26
Minor code cleanup
Alayan-stk-2 May 27, 2024
d459d45
When changing base theme, keep the theme variant if possible
Alayan-stk-2 May 27, 2024
66a85d8
Update the Cartoon Coal skin
Alayan-stk-2 May 27, 2024
8f3d732
Update AppData file
AsciiWolf May 28, 2024
08b8624
Auth command changes: rename tags, remove exp, add online id
kimden May 28, 2024
7320f2e
Fix a crash in debug mode
Alayan-stk-2 May 28, 2024
84dff44
Guarantee 2048 bones
CodingJellyfish May 29, 2024
c9c25de
Fix infinite loop in case user chooses to not fix typos
kimden Jun 7, 2024
7226423
Avoid using m_user_last_correct_argument map value as (0, 0) when it'…
kimden Jun 8, 2024
149512d
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden Jun 25, 2024
f0af5ed
Add an option for -fsanitize=undefined
kimden Jun 25, 2024
319d0fc
Merge pull request #5117 from kimden/add-usan
CodingJellyfish Jun 25, 2024
d978972
Merge pull request #5047 from ognevny/improve-mingw-build
CodingJellyfish Jun 25, 2024
118cde2
Revert #5047
CodingJellyfish Jun 25, 2024
41a7b80
Fix exit crash when built for GLES2 on Linux (#5118)
Icenowy Jun 26, 2024
6933f1c
Add a network console command to close the server if it's empty
kimden Jun 28, 2024
e50a06a
Fix #5116
kimden Jun 29, 2024
afbb58e
Merge pull request #5122 from kimden/fix5116
CodingJellyfish Jul 1, 2024
a17a2d5
Separate SQL functions from server lobby
kimden Jul 1, 2024
9fb7448
Get rid of repeated code, add comments
kimden Jul 3, 2024
ffa49dd
Don't build stk-editor in linux builder as its data files are already…
deveee Jul 3, 2024
372fdc4
Fix #5125
Alayan-stk-2 Jul 5, 2024
374e756
Fix selection square theming for new cartoon skins
Alayan-stk-2 Jul 5, 2024
69abdb0
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden Jul 5, 2024
9dbe576
Display the main graphical settings in the benchmark result screen
Alayan-stk-2 Jul 5, 2024
8ded85a
Use relative path for MacOS workflow
tobbi Jul 6, 2024
c157a1c
Merge pull request #5130 from tobbi/macos_workflows_test
CodingJellyfish Jul 7, 2024
9f20add
Merge branch 'cleanup-1' + rewrite all database-related parts
kimden Jul 8, 2024
896da7c
Upgrade SIMDe to version 0.8.2
mr-c Jul 9, 2024
94ab1de
Fix views being ineligible for getBestResult()
kimden Jul 9, 2024
d64edf2
Center-align Goal and Progress columns on profile page
Nstelt Jul 13, 2024
9e9d1fb
Try build
CodingJellyfish Jul 14, 2024
4d6d7ba
Merge pull request #5131 from mr-c/simde_v0.8.2
CodingJellyfish Jul 19, 2024
355d7cd
Merge pull request #5124 from kimden/cleanup-1
CodingJellyfish Jul 19, 2024
5527a11
Merge pull request #5133 from Nstelt/center_align_profile_cols
CodingJellyfish Jul 19, 2024
b7c98f2
Fix #5134
CodingJellyfish Jul 25, 2024
54722c4
Update gradle and avoid building with too new sdk
deveee Jul 28, 2024
0c6a4a7
Add hint to allow only landscape orientation on android.
deveee Jul 28, 2024
0704f25
Fix #5127
CodingJellyfish Jul 29, 2024
4a9e5f0
Fix remaining #5127
CodingJellyfish Jul 29, 2024
ef64ea2
[Database] Huge update for all modes
kimden Aug 3, 2024
0099336
Fix an incorrect link in doc/fork/Database specifications.md
kimden Aug 3, 2024
e6d0df3
Merge pull request #5104 from AsciiWolf/patch-1
CodingJellyfish Aug 4, 2024
bf62de8
Groundwork for a favorite-tracks system
Alayan-stk-2 Aug 7, 2024
ca80a1c
Add an UI to edit favorite tracks
Alayan-stk-2 Aug 8, 2024
c61ab02
Improve the UI display of favorite tracks
Alayan-stk-2 Aug 8, 2024
7f78b5b
Rewrite favorite system
CodingJellyfish Aug 9, 2024
02e60fc
Fix typo & Add easter egg badge
CodingJellyfish Aug 10, 2024
683a1b1
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden Aug 10, 2024
5fe2e9e
Fix #4997 (#5149)
kimden Aug 11, 2024
427455a
Fix #5085 and #5152
Alayan-stk-2 Aug 11, 2024
386ac8f
Fix some compiler warnings in irrlicht (#5144)
nyllet Aug 11, 2024
a65655d
Improve contrast in the coal themes
Alayan-stk-2 Aug 11, 2024
e7dd96a
Improve things for #5115
Alayan-stk-2 Aug 11, 2024
9f1b54d
Fix #5138 (#5154)
kimden Aug 13, 2024
2d98578
Add a display options cartoon icon
Alayan-stk-2 Aug 15, 2024
88cd5cf
Fix #5086
Alayan-stk-2 Aug 15, 2024
12efb28
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden Aug 19, 2024
f0dfa7b
Get rid of some typos and warnings
kimden Aug 20, 2024
e55659c
Synchronize KartTeam and 'temporary teams', add a few spectate modes
kimden Aug 22, 2024
467ba89
Update upload artifavt version (#5168)
CodingJellyfish Sep 10, 2024
fa59810
Add STK blog news list to online screen (#5165)
CodingJellyfish Sep 10, 2024
5a0b15a
Change skin font reload logic
CodingJellyfish Sep 10, 2024
3ae9e97
Allow using a different / 1-level nested command file
kimden Sep 15, 2024
6f3c5b6
Make /randomteams votable if the server config allows
kimden Sep 16, 2024
f60dc75
Merge https://github.com/supertuxkart/stk-code into command-manager-p…
kimden Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,228 changes: 2,228 additions & 0 deletions src/network/protocols/command_manager.cpp

Large diffs are not rendered by default.

213 changes: 213 additions & 0 deletions src/network/protocols/command_manager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2021 kimden
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#ifndef COMMAND_MANAGER_HPP
#define COMMAND_MANAGER_HPP

#include "irrString.h"

#include <algorithm>
#include <array>
#include <atomic>
#include <functional>
#include <map>
#include <memory>
#include <mutex>
#include <set>
#include <deque>
#include <vector>
#include <queue>


#ifdef ENABLE_SQLITE3
#include <sqlite3.h>
#endif

#include "network/protocols/command_voting.hpp"
#include "utils/set_typo_fixer.hpp"

class ServerLobby;
class Event;
class STKPeer;

class CommandManager
{
enum CommandScope: int {
CS_ALWAYS = 1,
CS_SOCCER_TOURNAMENT = 2
// add more powers of two if needed
};

struct Context
{
Event* m_event;

std::shared_ptr<STKPeer> m_peer;

std::vector<std::string> m_argv;

std::string m_cmd;

int m_user_permissions;

bool m_voting;

Context(Event* event, std::shared_ptr<STKPeer> peer,
std::vector<std::string>& argv, std::string& cmd,
int user_permissions, bool voting):
m_event(event), m_peer(peer), m_argv(argv),
m_cmd(cmd), m_user_permissions(user_permissions), m_voting(voting) {}
};

struct Command
{
std::string m_name;

int m_permissions;

void (CommandManager::*m_action)(Context& context);

int m_scope;

std::string m_usage;

std::string m_description;

std::string m_verbose_permissions;

Command() {}

Command(std::string name,
void (CommandManager::*f)(Context& context), int permissions, int scope = CS_ALWAYS,
std::string usage = "", std::string verbose_permissions = "", std::string description = ""):
m_name(name), m_permissions(permissions), m_action(f), m_scope(scope),
m_usage(usage), m_description(description),
m_verbose_permissions(verbose_permissions) {}

std::string getUsage() { return "Usage: " + m_usage; }

std::string getHelp() { return "Usage: " + m_usage + "\nAvailable to: " + m_verbose_permissions + "\n" + m_description; }
};

private:

ServerLobby* m_lobby;

std::vector<Command> m_commands;

std::map<std::string, Command> m_name_to_command;

std::multiset<std::string> m_users;

std::map<std::string, std::string> m_text_response;

std::map<std::string, CommandVoting> m_votables;

std::queue<std::string> m_triggered_votables;

std::map<std::string, std::vector<std::string>> m_user_command_replacements;

SetTypoFixer m_stf_command_names;

SetTypoFixer m_stf_present_users;

SetTypoFixer m_stf_maps;

void initCommands();

int getCurrentScope();

bool isAvailable(const Command& c);

void vote(Context& context, std::string category, std::string value);
void update();
void error(Context& context);

void process_help(Context& context);
void process_text(Context& context);
void process_commands(Context& context);
void process_replay(Context& context);
void process_start(Context& context);
void process_config(Context& context);
void process_spectate(Context& context);
void process_addons(Context& context);
void process_lsa(Context& context);
void process_pha(Context& context);
void process_kick(Context& context);
void process_unban(Context& context);
void process_ban(Context& context);
void process_pas(Context& context);
void process_sha(Context& context);
void process_mute(Context& context);
void process_unmute(Context& context);
void process_listmute(Context& context);
void process_gnu(Context& context);
void process_tell(Context& context);
void process_standings(Context& context);
void process_teamchat(Context& context);
void process_to(Context& context);
void process_public(Context& context);
void process_record(Context& context);
void process_power(Context& context);
void process_length(Context& context);
void process_queue(Context& context);
void process_adminstart(Context& context);
void process_shuffle(Context& context);
void process_timeout(Context& context);
void process_team(Context& context);
void process_cat(Context& context);
void process_troll(Context& context);
void process_hitmsg(Context& context);
void process_teamhit(Context& context);
void process_register(Context& context);
#ifdef ENABLE_WEB_SUPPORT
void process_token(Context& context);
#endif
// soccer tournament commands
void process_muteall(Context& context);
void process_game(Context& context);
void process_role(Context& context);
void process_stop(Context& context);
void process_go(Context& context);
void process_lobby(Context& context);
void process_init(Context& context);
void process_mimiz(Context& context);
void process_test(Context& context);
void process_slots(Context& context);
void special(Context& context);

public:

CommandManager(ServerLobby* lobby = nullptr);

void handleCommand(Event* event, std::shared_ptr<STKPeer> peer);

bool isInitialized() { return m_lobby != nullptr; }

template<typename T>
void addTextResponse(std::string key, T&& value)
{ m_text_response[key] = value; }

void addUser(std::string& s);

void deleteUser(std::string& s);

static void restoreCmdByArgv(std::string& cmd, std::vector<std::string>& argv, char c, char d, char e, char f);
};

#endif // COMMAND_MANAGER_HPP
36 changes: 36 additions & 0 deletions src/network/protocols/command_permissions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2021 kimden
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#ifndef COMMAND_PERMISSIONS_HPP
#define COMMAND_PERMISSIONS_HPP

enum CommandPermissions : unsigned int
{
PE_NONE = 0,
PE_USUAL = 1,
PE_VOTED = 2,
PE_CROWNED = 4,
PE_SINGLE = 8,
PE_HAMMER = 16,
UP_HAMMER = PE_HAMMER,
UP_SINGLE = UP_HAMMER | PE_SINGLE,
UP_CROWNED = UP_SINGLE | PE_CROWNED,
UP_EVERYONE = UP_CROWNED | PE_USUAL
};

#endif // COMMAND_PERMISSIONS_HPP
141 changes: 141 additions & 0 deletions src/network/protocols/command_voting.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2021 kimden
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "network/protocols/command_voting.hpp"
#include "utils/random_generator.hpp"

CommandVoting::CommandVoting(double threshold): m_threshold(threshold)
{

} // CommandVoting
// ========================================================================

void CommandVoting::castVote(std::string player, std::string category, std::string vote)
{
uncastVote(player, category);
m_votes_by_player[player][category] = vote;
m_votes_by_poll[category][vote].insert(player);
m_need_check = true;
m_selected_category = category;
m_selected_option = vote;
} // castVote
// ========================================================================

void CommandVoting::uncastVote(std::string player, std::string category)
{
auto it = m_votes_by_player[player].find(category);
if (it != m_votes_by_player[player].end())
{
std::string previous_vote = it->second;
m_votes_by_poll[category][previous_vote].erase(player);
}
m_need_check = true;
m_selected_category = "";
m_selected_option = "";
} // uncastVote
// ========================================================================

std::pair<int, std::map<std::string, std::string>> CommandVoting::process(std::multiset<std::string>& all_users)
{
std::map<std::string, std::string> result;
int num_votes = 0;
int required_number;
for (const auto& p: m_votes_by_poll)
{
std::string category = p.first;
double category_threshold = m_threshold;
auto it = m_custom_thresholds.find(category);
if (it != m_custom_thresholds.end())
category_threshold = it->second;
required_number = std::max<int>(1, (int)ceil((double)all_users.size() * category_threshold));
std::map<std::string, int> category_results;
for (const std::string& user: all_users)
{
auto it = m_votes_by_player.find(user);
if (it == m_votes_by_player.end())
continue;
auto it2 = it->second.find(category);
if (it2 == it->second.end())
continue;
++category_results[it2->second];
}
for (const auto& q: category_results)
{
if (category == m_selected_category && q.first == m_selected_option)
num_votes = q.second;
if (q.second >= required_number)
{
result[category] = q.first;
break;
}
}
}
m_need_check = false;
m_selected_category = "";
m_selected_option = "";
for (const auto& p: result)
{
std::string category = p.first;
reset(category);
}
return make_pair(num_votes, result);
} // process
// ========================================================================

std::string CommandVoting::getAnyBest(std::string category)
{
int best = 0;
std::vector<std::string> best_options;
for (auto& vote_to_set: m_votes_by_poll[category])
{
unsigned int count = vote_to_set.second.size();
std::string option = vote_to_set.first;
if (count > best)
{
best_options.clear();
best_options.push_back(option);
}
else if (count == best)
{
best_options.push_back(option);
}
}
if (best_options.empty())
return ""; // shouldn't happen mainly
RandomGenerator rg;
std::vector<std::string>::iterator it = best_options.begin();
std::advance(it, rg.get((int)best_options.size()));
return *it;
} // getAnyBest
// ========================================================================

void CommandVoting::reset(std::string category)
{
for (auto& vote_to_set: m_votes_by_poll[category])
{
std::string vote = vote_to_set.first;
auto& players = vote_to_set.second;
for (const std::string& player: players)
{
m_votes_by_player[player].erase(category);
}
}
m_votes_by_poll[category].clear();
} // reset
// ========================================================================

Loading