2276: Fix segmentation fault when creating sql tables failed r=heinrich5991 a=Zwelf
`GameServer()->OnShutdown(true);` (which would wait on running threads to exit)
wasn't called if an error occured in the server init. Therefore `CServer` was
freed before the init-thread finished executing, causing a use after free from
`CSqlConnector::ms_ppSqlReadServers` pointing to `CServer->m_apSqlReadServers`.
Fixes#2271
Note that the server exits when creating tables failed. Since the tables are created by default, it has to be disabled explicitly (e.g. `add_sqlserver r teeworlds record teeworlds PASSWORD "localhost" 3306 0`) if the servers should start even when the database connection fails.
Co-authored-by: Zwelf <zwelf@strct.cc>
`GameServer()->OnShutdown(true);` (which would wait on running threads to exit)
wasn't called if an error occured in the server init. Therefore `CServer` was
freed before the init-thread finished executing, causing a use after free from
`CSqlConnector::ms_ppSqlReadServers` pointing to `CServer->m_apSqlReadServers`.
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>
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>
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.
Add libnotify support for linux client
Also unify notification management
Make libnotify mandatory for the client. It is installed on 100% of Arch
Linux systems and on 70% of Debian systems. I'd guess the remaining
Debian systems are servers.
Detect dependent libraries of `libnotify` using `pkg-config`. Remove
library-specific code from the game module. Decrement refcount for
libnotify notification object before leaving the function.
2119: Change last render logic, when inactive r=def- a=Jupeyy
Just a small fix to let the client not try to get high fps, when it "thinks" it didn't render for a long time.
(is still affected by the SDL check "if window has input" at the cl_refresh_rate calculation, so not a 100% fix).
Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2069: Move global configuration out of client interface r=heinrich5991 a=ChillerDragon
2076: Allow editing multiple tile layer props r=heinrich5991 a=Learath2
Requested by Ravie on discord
2095: Fix `AntibotDestroy` being called twice r=def- a=heinrich5991
The resource deallocation needs to happen in symmetry with the
allocation, otherwise we get unmatched dealloctions leading to crashes.
Allocations happened in `CAntibot::Init`, but it was not guaranteed that
this was called before the destructor.
Co-authored-by: ChillerDragon <ChillerDragon@gmail.com>
Co-authored-by: Learath <learath2@gmail.com>
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2070: Fix demo recording with broken maps r=heinrich5991 a=Learath2
Apparently there are maps out there with broken headers advertising the wrong map size. This allows demos to be recorded on those.
Example of such a map is `ctf4_old_d668e9fa_2f472051b26b6bffaa4af8990cf882cafd6364e00e1333b77762cb9911e49464.map`
Hosted on `Allround Network`
Reported by teini94 on discord
Co-authored-by: Learath <learath2@gmail.com>
2071: Add an option to only start a new demo when connect while automatically record demos r=def- a=sirius1242
Origin auto demo recording of ddnet will generate lots of demo files especially when playing in mods which have shorter rounds, such as infclass. I added a new option to open a new demo file only when connect to server (include map changing), this is disabled by default, and can use `cl_auto_demo_on_connect 1` to open. It works only when `cl_auto_demo_record` open.
Co-authored-by: sirius <sirius.ustc@gmail.com>
2061: use pid in file names of temporary files r=heinrich5991 a=def-
to prevent race conditions with multiple clients running when saving maps, config on quit, during upgrade
Co-authored-by: def <dennis@felsin9.de>
2050: Fix race condition. Closes#2004 r=def- a=Learath2
I guess a new state is better then a global variable
Co-authored-by: Learath <learath2@gmail.com>
1981: Fix: background colors being set to white r=def- a=Aerll
After changing either of background colors in ddnet tab in settings and reopening the client, both become white.
Co-authored-by: Aerll <31746984+aerll@users.noreply.github.com>
Saves should not be loadable from one to the other.
Requires:
ALTER TABLE record_race ADD COLUMN DDNet7 BOOL DEFAULT FALSE AFTER GameID;
ALTER TABLE record_teamrace ADD COLUMN DDNet7 BOOL DEFAULT FALSE AFTER GameID;
ALTER TABLE record_saves ADD COLUMN DDNet7 BOOL DEFAULT FALSE AFTER Server;
as reported by valgrind --tool=memcheck:
==376722== Conditional jump or move depends on uninitialised value(s)
==376722== at 0x1CDBDB: int maximum<int>(int, int) (math.h:79)
==376722== by 0x216A46: CPlayer::Tick() (player.cpp:174)
==376722== by 0x1FB308: CGameContext::OnTick() (gamecontext.cpp:658)
==376722== by 0x1C60AF: CServer::Run() (server.cpp:2046)
==376722== by 0x1CB099: main (server.cpp:3040)
==376722==
==376722== Conditional jump or move depends on uninitialised value(s)
==376722== at 0x183F27: int minimum<int>(int, int) (math.h:77)
==376722== by 0x216A65: CPlayer::Tick() (player.cpp:175)
==376722== by 0x1FB308: CGameContext::OnTick() (gamecontext.cpp:658)
==376722== by 0x1C60AF: CServer::Run() (server.cpp:2046)
==376722== by 0x1CB099: main (server.cpp:3040)
Fix by @heinrich5991
from the documentation of objc_msgSend in <objc/message.h>
```
/* Basic Messaging Primitives
*
* On some architectures, use objc_msgSend_stret for some struct return types.
* On some architectures, use objc_msgSend_fpret for some float return types.
* On some architectures, use objc_msgSend_fp2ret for some float return types.
*
* These functions must be cast to an appropriate function pointer type
* before being called.
*/
OBJC_EXPORT void
objc_msgSend(void /* id self, SEL op, ... */ )
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
OBJC_EXPORT void
objc_msgSendSuper(void /* struct objc_super *super, SEL op, ... */ )
OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0);
```
1925: Don't bundle libcurl for Linux r=Learath2 a=heinrich5991
It's installed basically everywhere and just increases release size.
They're serious about backward compatibility and haven't had a breaking
change in ages.
1929: Remove space at end of cfg description r=Learath2 a=ChillerDragon
Happy hacktoberfest :octocat:
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
Co-authored-by: ChillerDragon <chillerdragon@gmail.com>
- videorecorder only works for recording demos now
- demoplayer was modified to allow controll over the time that passed
in order to get perfect fps, IVideo controlls how much time passed,
basically every rendercall sets the time to record the next frame
1904: Add tune zone prediction r=heinrich5991 a=trml
Is enabled with cl_predict_ddrace 1.
This will predict tunings loaded from the map the first time tunezones are entered, but will also update the tunes after you receive new tunes while in a tunezone, since it's possible to change them in rcon.
Co-authored-by: trml <trml@users.noreply.github.com>
1878: Add paused and spec to explayerflags r=Learath2 a=Ryozuki
I think client should know about this, maybe we can do something with it in the future.
It also may help with https://github.com/ddnet/ddnet/issues/259 but i didn't figure out yet a way to fix it.
1903: Consistent spacing for getters and setters r=Learath2 a=ChillerDragon
Co-authored-by: Ryozuki <ryo@ryozuki.xyz>
Co-authored-by: ChillerDragon <chillerdragon@gmail.com>
1909: Fix filescore path r=Learath2 a=ChillerDragon
The filescore system did not handle map paths well that were an actual path and not just the mapname.
```
# before fix
$ ./DDNet-Server 'sv_map "DDNetPP-maps/BlmapChill"'
[...]
[2019-09-15 13:29:44][filescore]: opening 'records/DDNetPP-maps-BlmapChill_record.dtb' for reading failed
# after fix
$ ./DDNet-Server 'sv_map "DDNetPP-maps/BlmapChill"'
[...]
[2019-09-15 13:31:05][filescore]: opening 'records/BlmapChill_record.dtb' for reading failed
```
I called ```Server()->``` in a thread so please review thread safety before merge.
Co-authored-by: ChillerDragon <chillerdragon@gmail.com>
I talked to coffee (creator of both mods) and he said it is okay to use zoom on the mods, also: eye emotes work there so the eye wheel is also supported. I have updated both mods to ddnet master so they have all the new stuff
1845: Fix infectionZ gamemode seen as DDNet r=heinrich5991 a=fokkonaut
InfectionZ's gametype is somehow infection, instead of infectionZ
Co-authored-by: fokkonaut <35420825+fokkonaut@users.noreply.github.com>
1837: Don't advertise the reserved slots. Fix#1808 r=heinrich5991 a=Learath2
I think this is also fine for vanilla, but I can't get the vanilla client to work on mac to test it.
Co-authored-by: Learath <learath2@gmail.com>
Co-authored-by: Emir Marincic <learath2@gmail.com>