Commit graph

2625 commits

Author SHA1 Message Date
def b3d22204c3 Update credits 2020-06-17 23:23:27 +02:00
bors[bot] 98b448ebcc
Merge #2247
2247: Thread safe SQL interaction r=def- a=Zwelf

This PR intends to make the database interaction thread safe and optimizes some SQL queries. This is still a WIP, but since it is a rather big PR I wanted to get feedback early on.

Benefits:

* remove race conditions leading to undefined behavior and potential crashes
* logging game related database results in teehistorian would be possible

Behavior change:

* /top5team prints ranks in reverse order when passing a negative number (like /top5, /top5points)
* Optimize SQL statements for /rank /teamrank /top5 /top5team /points /top5points
* /load without parameters doesn't pass the SQL error to the user (as most other functions)
* Simplify IScore interface
* Add UUID to /save table (update of database schema necessary):
  ```
  ALTER TABLE record_saves ADD SaveID varchar(64);
  ```
* /save immediately kills team and loads it again if the database insert fails.

still TBD:
* [x] saving (team) score when finishing
* [x] loading team save
* [x] loading initial time and birthday check
* [x] /map and random map votes
* [x] RFC: generate a passphrase (2-3 word) if save-code exists or no save-code is given making /save failures much more rare and save-codes more secure
* [x] clean up code (removing now unused structs, ordering of functions in IScore)

Co-authored-by: Zwelf <zwelf@strct.cc>
2020-06-17 19:35:45 +00:00
Zwelf f1b2ff086c Clean up thread safe SQL refactor 2020-06-17 21:15:07 +02:00
Zwelf 9f15acdbee Thread safe random_unfinished_map and modified sql statement 2020-06-15 11:14:15 +02:00
Zwelf afe96ed69c Thread safe random_map 2020-06-15 11:14:15 +02:00
Zwelf 7f4dc2bb4e Thread safe /map 2020-06-15 11:14:15 +02:00
Zwelf ea31171873 Generate passphrase for save-code
* when none is given
* if the given save-code already exist
* if the database connection fails therefore it can't be checked if the save-code already exists

Using the short word list from eff:
https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases
2020-06-15 11:14:15 +02:00
Zwelf 528ca377ed Thread safe saving of team score 2020-06-15 11:14:15 +02:00
Zwelf 13c80fdc56 Thread safe saving of score 2020-06-15 11:14:15 +02:00
Zwelf 5dcb6f3b0d Thread save Init 2020-06-15 11:14:15 +02:00
Zwelf c278d8dbc3 Read SaveID from database on /load 2020-06-15 11:14:15 +02:00
Zwelf dbf6ac88f6 Thread save loading of player time and birthday 2020-06-15 11:14:15 +02:00
Zwelf e9242f45f1 Thread safe /load 2020-06-15 11:14:15 +02:00
Zwelf 031ac52320 Thread safe /save 2020-06-15 11:14:15 +02:00
Zwelf f5ebbf59b6 Thread safe /load without paramters 2020-06-15 11:14:15 +02:00
Zwelf 7514e93a8a Optimize /top5points SQL query 2020-06-15 11:14:15 +02:00
Zwelf fa8972deb6 Thread safe /top5points 2020-06-15 11:14:15 +02:00
Zwelf 62f3f40c00 Optimize /points database query 2020-06-15 11:14:15 +02:00
Zwelf 0f3f845a7f Thread safe /points 2020-06-15 11:14:15 +02:00
Zwelf e37cf5f3cb Thread safe /times 2020-06-15 11:14:15 +02:00
Zwelf 8fc81e7eca Reworked PlayerResult to signal finished with use_count == 1
Therefore if the sql thread crashes, the result is deleted automatically
2020-06-15 11:14:15 +02:00
Zwelf 1d7289c8f0 Thread safe /top5team and optimize database query 2020-06-15 11:14:15 +02:00
Zwelf 83fbee5f81 Optimize /teamrank database query 2020-06-15 11:14:15 +02:00
Zwelf a92509a5df Simplify /top5 SQL statement 2020-06-15 11:14:15 +02:00
Zwelf 9cf28354d7 Thread safe /top5 command 2020-06-15 11:14:15 +02:00
Zwelf fd44b1dc5b Reduce boilerplate code needed to start player info requesting thread 2020-06-15 11:14:15 +02:00
Zwelf f18daa949c Thread safe /teamrank 2020-06-15 11:14:15 +02:00
Zwelf e311c39151 Remove unused parameters from IScore interface 2020-06-15 11:14:15 +02:00
Zwelf 68aa157c11 Simplify /rank sql request 2020-06-15 11:14:15 +02:00
Zwelf eda0bab4bb Thread safe /rank 2020-06-15 11:14:15 +02:00
Zwelf 91e286f54d Fix parsing responses from player 2020-06-15 11:14:15 +02:00
Zwelf 76c227a542 Reimplement /mapinfo command 2020-06-15 11:14:15 +02:00
Zwelf 9add354367 Use Template for SqlResult 2020-06-15 11:14:15 +02:00
Zwelf 873f478a82 Rename Debut to Offset 2020-06-15 11:14:15 +02:00
Zwelf 4ee08dcc5c Remove unused arguments from IScore 2020-06-15 11:14:15 +02:00
Zwelf 69cf72dae4 Adjust file based ShowRank, ShowTeamRank, ShowPoints consistent functions to sql 2020-06-15 11:14:15 +02:00
Zwelf 3d25953036 Ordered functions 2020-06-15 11:14:14 +02:00
Zwelf a990acc512 Remove existing CRandomMapResult to simplify IScore interface 2020-06-15 11:12:57 +02:00
Zwelf 3af18f5f60 Create shared pointer on demand 2020-06-15 10:59:59 +02:00
Zwelf 0891a0fd51 Remove some unnecessary header includes 2020-06-15 10:59:59 +02:00
Zwelf 8a22cce031 Start of sql refractor
* Use atomic integer in thread count for thread safety
2020-06-15 10:59:46 +02:00
Zwelf add4fab645 Disallow team join while save command is active 2020-06-15 10:59:46 +02:00
Zwelf 7146eb572b Save error handling clean up 2020-06-15 10:59:46 +02:00
Zwelf 2d7886bf33 Small cleanup 2020-06-15 10:59:46 +02:00
12pm 01092a30c1 add sv_tele_others_auth_level 2020-06-14 19:21:12 +03:00
bors[bot] 3cd35de942
Merge #2236
2236: Fix team rejoin logic for sv_team 3 r=Learath2 a=def-



Co-authored-by: def <dennis@felsin9.de>
2020-06-02 10:27:13 +00:00
d3fault b9844ea6ec Save active weapon with /rescue 2020-05-31 22:39:28 -07:00
d3fault 65906070b6 clarified /practice voting instructions 2020-05-30 20:58:01 -07:00
def 88b65b6def Newly joined player should not immediately be subtracted from team 0 2020-05-31 00:34:29 +02:00
def d3b6df97f8 Fix team rejoin logic for sv_team 3 2020-05-30 14:47:34 +02:00
Learath 6d019204f1 No point locking if teams are disabled 2020-05-30 14:07:30 +03:00
def 4cc1bc0cf8 Kill player when /practice is on and they get kicked out of team 2020-05-28 21:50:35 +02:00
bors[bot] 0cd40c61c3
Merge #2218
2218: Practice mode fixes & improvements r=Learath2 a=def-

Thanks to NANAMAR for report.

Update: tested, works.

Co-authored-by: def <dennis@felsin9.de>
2020-05-28 16:21:01 +00:00
def d17e74ee7d Add sv_practice (fixes #2227) 2020-05-28 13:28:10 +02:00
def b25c75b558 Allow rescuing while falling down even when not frozen 2020-05-28 12:59:45 +02:00
def cacf17bd96 Save weapons as well with /rescue (fixes #2225) 2020-05-28 12:59:40 +02:00
def c00759a0ed Turn off practice mode and reset practice wishes when locked team dies 2020-05-28 12:59:31 +02:00
def 68132350b9 No cheating through noob filter with practice and then leaving team (fixes #2224) 2020-05-28 12:06:56 +02:00
def fb90990d6d Allow /rescue mid-flight
Thanks to Skeith for the suggestion
2020-05-27 23:48:17 +02:00
def 3cbd75b840 Make /rescue work in deepfreeze
Thanks to NANAMAR for report
2020-05-27 23:27:30 +02:00
heinrich5991 941d3aa8a0 Some formatting 2020-05-27 20:03:11 +02:00
heinrich5991 209726552b Remove unused Sv_PlayerTime game message 2020-05-27 20:03:11 +02:00
bors[bot] 92fc95d742
Merge #2202
2202: Send DDNet version early in the connection process r=Learath2 a=heinrich5991

This gets rid of the problem that we don't know whether we should send
full snapshots to clients because they haven't told us about them being
DDNet yet.

Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2020-05-27 17:49:31 +00:00
bors[bot] 438dc519d6
Merge #2212
2212: Use a consistent PRNG on all platforms r=Learath2 a=heinrich5991

I just used glibc's because that is what we use on all the servers. Based on https://www.mscs.dal.ca/~selinger/random/.

Behavior change: The PRNG is actually seeded now.

Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2020-05-27 16:14:09 +00:00
def 6b95bc2636 Fix team save practice reset 2020-05-27 17:58:08 +02:00
def e1849ad1bb Implement /practice for teams
As discussed on Discord today, can be enabled inside of teams on the fly
during each run on any server. Finishes don't count. I haven't tested
save/load yet, would do that live on the server if this can be merged.
2020-05-27 17:33:26 +02:00
Zwelf fab1cde94e Rename variables for consistency
The following member variables:

* m_name to m_aName
* m_String to m_aString
* m_CpCurrent to m_aCpCurrent
* m_Switchers to m_pSwitchers
* SavedTees to m_pSavedTees
2020-05-26 21:49:58 +02:00
heinrich5991 c9c7f947b5 Use the PCG-XSH-RR PRNG instead
This came from a long discussion comparing PCG-* against xoroshiro*. Do
not generate integers without bias because it doesn't affect us very
much and it is easier to reimplement with modulo.
2020-05-26 10:59:49 +02:00
heinrich5991 b488be018f Actually seed the PRNG on each round 2020-05-25 15:19:29 +02:00
heinrich5991 2692f3c758 Use a consistent PRNG on all platforms 2020-05-25 15:19:29 +02:00
bors[bot] 64f78fced9
Merge #2205
2205: Implement /unlock & clarify the /help lock text r=heinrich5991 a=def-



Co-authored-by: def <dennis@felsin9.de>
2020-05-24 20:24:02 +00:00
bors[bot] f18c42c5ba
Merge #2208
2208: Implement /load without params to show some info r=Learath2 a=def-

about your existing saves. Not the code of course, but only how many saves you have and when you last saved on this map.

Co-authored-by: def <dennis@felsin9.de>
2020-05-23 20:20:12 +00:00
bors[bot] 5cddef7efe
Merge #2209
2209: singular player in team start message r=Learath2 a=def-



Co-authored-by: def <dennis@felsin9.de>
2020-05-23 20:12:36 +00:00
def a412773e5a Fix name schema for char-arrays 2020-05-23 21:55:22 +02:00
def 7c966bebc3 singular player in team start message 2020-05-23 21:53:12 +02:00
def c45995a010 Implement /load without params to show some info
about your existing saves. Not the code of course, but only how many
saves you have and when you last saved on this map.
2020-05-23 19:46:12 +02:00
def 37e0a33da2 Also introduce /unlock as an alias of /lock 0 2020-05-23 17:55:56 +02:00
def d4452dd6e0 Clarify the /help lock text 2020-05-23 17:15:04 +02:00
heinrich5991 0d7872c79e Send DDNet version early in the connection process
This gets rid of the problem that we don't know whether we should send
full snapshots to clients because they haven't told us about them being
DDNet yet.
2020-05-22 17:58:41 +02:00
Zwelf 8bdf41c1b5 Break save/load string into multiple lines 2020-05-21 18:04:15 +02:00
Zwelf 71b687cbd6 Remove unused ConSaveTeam, ConLoadTeam declarations 2020-05-21 00:44:30 +02:00
Zwelf 61787168a6 Rename aGameUuid to m_aGameUuid for consistency 2020-05-20 22:22:02 +02:00
Zwelf cd015c5e37 Fix storing incomplete game uuid on /save
Previously the formatted game uuid was cut off after 15 bytes.
Therefore only 52 out of 128 bit of the uuid were stored.

introduced in 69fd7f1767
2020-05-20 22:18:14 +02:00
heinrich5991 044aee2846 Fix compilation with mysql enabled
Caused by #2171's 850f8e3f27.
2020-05-18 00:29:15 +02:00
Dennis Felsing 898b4ce4b9
Merge pull request #2171 from Chairn/pr_loadsaveprintname
Print name of requester when saving or loading team
2020-05-16 17:41:34 +02:00
Chairn 850f8e3f27 Store client name in CSqlTeamSave/Load to ensure correctness of requester's name 2020-05-16 16:36:16 +02:00
Learath eacc56059b Keep ticks going 2020-05-15 19:29:34 +03:00
Learath 5e02bb5a23 Extend antibot interface
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2020-05-13 23:39:40 +03:00
Dennis Felsing 7aa69188b5
Merge pull request #2172 from fokkonaut/master
Fix #2162
2020-05-10 10:13:38 +02:00
fokkonaut 92927444d7
Fix #2162 2020-05-09 23:33:12 +02:00
Chairn fdb275b2f9 Print name of requester when saving or loading team 2020-05-09 19:33:40 +02:00
def 7ae8988dd0 Don't load m_Ammo to fix loads (following #2086)
As reported by Konsti, thanks to heinrich5991 for remembering #2086
2020-05-01 23:51:01 +02:00
bors[bot] bd3b72e493
Merge #2152
2152: Fix whispering to players with quotes (fixes #2151) r=heinrich5991 a=def-



Co-authored-by: def <dennis@felsin9.de>
2020-04-30 10:57:29 +00:00
Dennis Felsing 5e213a2619
Merge pull request #2086 from fokkonaut/master
Remove setting ammo for freeze to 0
2020-04-30 12:44:40 +02:00
fokkonaut d460470265
Move comment aswell 2020-04-30 11:49:04 +02:00
def 65a4eb775b Fix whispering to players with quotes (fixes #2151) 2020-04-28 08:54:24 +02:00
def d50b59b6b0 Add trafilaw to credits 2020-04-07 07:22:38 +02:00
trafilaw b6c25273f8 Fix compiling error 2020-03-31 03:29:45 +02:00
trafilaw 44cc0e29a4 Remove No reason given 2020-03-31 00:20:25 +02:00
trafilaw dc0e77f8e2 fix 2020-03-31 00:16:42 +02:00