Commit graph

336 commits

Author SHA1 Message Date
Dennis Felsing de5fe64be5 Implement recvmmsg 2018-07-25 16:06:00 +02:00
yangfl 81a39c229b Fix typo 2018-07-10 17:29:02 +08:00
heinrich5991 1b4a16233d Fix warning about incompatible function pointers
This comes at the cost of one allocation per started thread. This should
be okay because we're about to invoke a syscall anyway.
2018-06-20 22:26:43 +02:00
def 920597d48e Revert "Revert "Don't use aio logging to stdout on Windows""
This reverts commit 26b3be58bf.
2018-04-13 20:04:40 +02:00
heinrich5991 26b3be58bf Revert "Don't use aio logging to stdout on Windows"
This reverts commit 8f291ce528.
2018-04-09 15:02:34 +02:00
heinrich5991 f8277267a0 Remove mem_alloc and mem_free, use standard C functions instead
Replace `mem_free` by `free`, and `mem_alloc` by `malloc` or `calloc`
(the latter one being used to allocate a zeroed array of elements,
sometimes, this makes a call to `mem_zero` superfluous).

This results in having to remove `mem_stats` which previously recorded
the number of allocations and their size that the Teeworlds code did
directly.

Remove OOM handling in `src/game/client/components/binds.cpp`.

Remove needless copying in the CSV code in
`src/game/client/components/statboard.cpp`.
2018-04-09 11:56:39 +02:00
Jupeyy a83a89703e change position of mutex lock 2018-04-05 04:42:03 +02:00
Jupeyy 1208bcc562 Make mem_alloc, mem_free thread safe (fixes #1087) 2018-04-05 04:17:21 +02:00
bors[bot] c65ffeb4ae Merge #1082
1082: Fix a bug with name bans r=Learath2 a=heinrich5991

Overlong nick names could be used to circumvent name bans.
2018-03-14 02:00:42 +00:00
heinrich5991 d7f6cf2892 Fix some system.c insanity
`str_utf8_isspace` now returns true if the passed code point renders as
a space, instead of when not.

Add `str_utf8_trim_right`, use this function and
`str_utf8_skip_whitespaces` in the server.

Add tests for the three functions
2018-03-14 02:27:15 +01:00
bors[bot] cc6449bcd6 Merge #1055
1055: Keep track of lost frames and update time r=heinrich5991 a=Jupeyy

The problem a friend was occuring was, that on a fresh Windows install settings like cl_refresh_rate are set to 480.
Since the render calls take longer time than no render calls, it happened that client was sleeping on one update cycle and then took to long in another, where it called the render functions, leeding to less FPS than the cl_refresh_rate. this caused mouse lags and rarely frame drops.

another thing is, that select on Windows is non microsecond accurate, or just often returns too early, which caused that the refresh rate is much too high, or even ignored, (probably windows can only sleep on milliseconds, or again, is extremly inaccurate).

Another things on windows is that time_freq might be a "very odd" number ^^
i mean like on unix it's one microsecond (1,000,000 = 1s), but on windows the time_freq depends on the CPU leading to inaccurate calculation of the sleep time and render time.
This wasn't insanly huge issue, but probably skipped a few microseconds here and there.

This fix should stabilize the frames. I'd like to hear your opinion on this tho.
2018-03-13 19:41:38 +00:00
Jupeyy 3858a930a9 merge mac and linux impl into one 2018-03-12 17:10:11 +01:00
Jupeyy 72c38bca0c devide by the time_freq 2018-03-12 16:41:02 +01:00
Jupeyy c6a9aadbb0 add missing return statement 2018-03-12 16:21:21 +01:00
Jupeyy e0b8ecabe4 move time fetch to time_get_impl 2018-03-12 16:12:06 +01:00
Jupeyy 5e1bee2760 clean up a bit to and descripe it better 2018-03-12 15:10:49 +01:00
heinrich5991 31a3e8d4c0 Add possibility to ban players by name
This uses the Unicode confusable data together with judging how close
two strings are by using the Levenshtein distance.

Adds the commands `name_ban`, `name_unban` and `name_bans`. Kicks
players who join using a banned name and doesn't allow ingame players to
change their names to the banned ones.
2018-03-09 20:30:27 +01:00
heinrich5991 8f291ce528 Don't use aio logging to stdout on Windows
This should fix #964.
2018-01-13 20:43:41 +01:00
heinrich5991 a5ab0faee7 Simplify aio stuff a little
This hopefully gets rid of the uninitialized writes CI and I sometimes
see.

Fixes #914.
2018-01-13 19:17:33 +01:00
bors[bot] c15f52bf5f Merge #957
957: Add manual locking to `ASYNCIO` for transacted writes r=Learath2 a=heinrich5991

Previously, e. g. it was possible that newlines are separated from the
printed line in `logger_file`.
2018-01-02 15:31:09 +00:00
heinrich5991 eb31a52b83 Add very basic test for Unix sockets 2017-12-20 16:56:44 +01:00
heinrich5991 1a236dbefc Send connection information to external server 2017-12-20 16:56:34 +01:00
heinrich5991 8d47638a29 Add manual locking to ASYNCIO for transacted writes
Previously, e. g. it was possible that newlines are separated from the
printed line in `logger_file`.
2017-11-27 01:04:55 +01:00
heinrich5991 f0c647dba5 Change os_compare_version to os_is_winxp_or_lower
This stops leaking OS details in non-`system.c` files.
2017-11-23 03:10:15 +01:00
bors[bot] 5528cde5f6 Merge #869
869: Complete rework of the ghost and race recorder r=Learath2 a=Redix

This PR fixes a lot of issues with the ghost and race recorder, introduces a new ghost file format and implements some pretty useful features.

**A quick overview:**
 - When you cross the start line multiple times, both (ghost and recorder) will only restart if it is a non-solo server
 - If available, both will use the race timer to recognize the start instead of searching for the start line
 - Fastcap support for both
 - The recorder immediately starts when the Tee spawns, so the preparation steps (which are quite important for speedruns) will be included in the demo. If you do not cross the start-line within 20 seconds, it will stop the demo until you really start.
 - Better ghost menu (colors, reloading, deleting and saving ghosts)
 - The ghosts are more resistant against lags (old ones were sometimes completely useless due to small lags)
 - New ghosts files are significantly smaller
 - Cleanup, bugfixes..


**About the new ghost format (version 4/5):**
This format is used by Teerace for over a year now. The code for handling the binary files was moved to the engine. It includes an auto updater which creates a backup of all ghosts and converts them to the new format afterwards. The major differences from the format used by DDNet right now (version 2), are the ability to store multiple types of data, the usage of delta-encoding and a more portable header.

For whatever reason, the ghost stores values for every predicted tick, but without tick information, so lost snapshots can make them unusable. The new code uses the original values from the snapshots including ticks but it can also handle the old ones without. Since hardly any server uses the high bandwidth option this practically reduces the file size.

Like the demo recorder the ghost recorder directly stores the data to a file (every 50 snapshots) instead of writing the whole file at the end of the race. Indeed this can be changed with only a few lines if the old behavior is preferred.

The updater can handle version 2 (DDNet) and 3 (old teerace format, only slightly different from version 2) files. The updating already happens when the files are scanned for generating the list in the menu and not only when you activate them. The change from version 4 to 5 was only needed due to a bug in the implementation, the ghost loader can read both.

Some numbers about the file size: (map: hotrun, both about 30 seconds)

 - Old ghost: 30.4 kB (converted: 10.7 kB)
 - New ghost: 5.4 kB


**One thing about the race recorder:**
The old implementation compared the new file only with the first file it found for the particular map. The new one compares with all related demos and deletes them possibly, so that only the best demo is left. Since DDNet can also store the demos without name, this might also delete demos from other players, that you might have in your directory.
To prevent this I at least check whether the demo contains the player name if `cl_demo_name` is on. 
In my opinion the better solution would be to remove `cl_demo_name` and always use the player name.
2017-10-30 20:27:10 +00:00
ChillerDragon 86f4deef8c fixed boardcast 2017-10-24 13:40:35 +02:00
heinrich5991 b463197348 Add CTestInfo class, add test for create-close-remove process 2017-10-23 00:13:53 +02:00
heinrich5991 c654d82fd2 Fix -Wtypedef-redefinition for struct ASYNCIO
Fixes #912.
2017-10-20 11:24:45 +02:00
heinrich5991 e989ffad78 Rename async_* to aio_* and add test for nondivisible buffer lengths 2017-10-13 02:48:42 +02:00
heinrich5991 8e778cd9ab Address pull request comments 2017-10-13 02:29:18 +02:00
heinrich5991 13f0655cba Don't reset ASYNCIO_CLOSE flag on async_wait 2017-10-12 00:53:12 +02:00
heinrich5991 2fc018aac3 Add asynchronous file output, port dbg_msg()s to that system
Also add tests.
2017-10-10 04:11:14 +02:00
heinrich5991 7de42a1414 Couple of thread fixes 2017-10-10 00:08:24 +02:00
Redix a3a82b6571 Move filename clearing function to base lib 2017-09-28 16:02:01 +02:00
Redix e8d3469465 Fix fs_rename on windows 2017-09-28 16:01:56 +02:00
def fe208fb631 Cleaner logger 2017-08-31 20:07:43 +02:00
def 31ecbc3cf1 Don't skip items when logging 2017-08-31 19:51:58 +02:00
def 705349f2e5 Clean up and fix semaphores and threading 2017-08-31 19:18:07 +02:00
Learath2 cd386488e2 Rename semaphore_* to sphore_*
Previous naming conflicted with Mach kernel definitions.
2017-08-31 19:18:07 +02:00
Learath2 abb9891947 Use the pointer address to ensure uniqueness 2017-08-31 19:18:07 +02:00
Learath2 573b75b1b2 Forgot the / for semaphore name 2017-08-31 19:18:07 +02:00
Learath2 fd17477f06 Enable threaded logging on OSX 2017-08-31 19:18:07 +02:00
Learath2 a8e19205dc Fix conceptual mistakes 2017-08-31 19:18:07 +02:00
Learath2 153c6871c8 Try (ab)using named semaphores on OSX 2017-08-31 19:18:07 +02:00
def 5d8a0ddc1e Add time in console 2017-08-04 22:38:22 +02:00
def d6143cb26f How come no one notices that we're missing the day in our logs?... 2017-07-30 15:40:37 +02:00
def 3eb079bd64 Correct type in printf 2017-07-30 12:43:54 +02:00
def d6deb707c8 no pragmas in functions 2017-07-30 12:35:54 +02:00
Learath2 4622ab4cb6 Merge pull request #814 from heinrich5991/pr_ddnet_fix_cmake_mac
Fix the CMake Mac build
2017-07-30 11:38:12 +02:00
heinrich5991 6247aa0c7f Enable -Wextra and -Wformat=2
Also annotate `dbg_msg`, `str_format` and `str_timestamp_ex` so that the
compiler can determine whether the format strings are correct.

Fix the compiler warnings generated by these extra warnings -- some of
them were security issues.
2017-07-27 20:38:17 +02:00
heinrich5991 ed0949cb2e Remove unused function gui_messagebox
The Mac implementation was causing problems and it wasn't used anywhere.
2017-07-26 11:38:26 +02:00
def 34c8b047ea Oldschool C please 2017-07-22 21:20:15 +02:00
def 53565aa937 fixes 2017-07-09 14:56:57 +02:00
heinrich5991 409bc0e019 Ensure null-termination in str_escape
This also fixes a couple of potential buffer overflows. The affected
code is still buggy (doesn't do the right thing on potential buffer
overflow), but at least it won't result in crashes/out of bound writes
anymore.
2017-07-08 13:06:03 +02:00
def 36d5c8d608 string toggling supports escaped strings; also some code cleanup 2017-07-08 11:03:51 +02:00
def 7a83af4d1b Fix Mac build 2017-06-02 22:10:58 +02:00
def fe89b65368 Stupid C90 2017-06-02 20:31:37 +02:00
def a6e144ea72 Let's not crash the client and server on dbg_assert 2017-06-02 20:12:20 +02:00
def 9b48e902f0 Prevent data race when initializing loggers 2017-06-02 18:47:26 +02:00
Dennis Felsing 63ca2f8749 Show nr of skipped log messages 2017-04-21 10:50:16 +02:00
def d84911618a Don't block when logging queue is full, instead ignore message 2017-04-20 21:25:20 +02:00
heinrich5991 d98abf35db Rename WEBSOCKETS to CONF_WEBSOCKETS 2017-03-07 13:03:37 +01:00
heinrich5991 c201d7959c Enable -Wdeclaration-after-statement for compat with MSVC 2017-03-07 13:02:37 +01:00
heinrich5991 6302e4d7e0 Fix some style issues and a > to >= 2017-03-06 20:11:23 +01:00
Learath2 8c79f28802 Fix a crash on malformed input 2017-03-06 15:18:52 +01:00
Learath2 3c6a21ace2 dbg_assert felt more appropriate 2017-03-06 12:58:49 +01:00
Learath2 939a7f0d3f This time actually add error checking to str_hex_decode 2017-03-06 12:33:29 +01:00
Learath2 ed5824589c Make str_hex_decode a little more friendly 2017-03-04 23:06:07 +03:00
Learath2 b7cbaedea0 New auth system for rcon 2017-03-02 18:16:29 +03:00
heinrich5991 cd3b0ae855 Implement the confusable algorithm from Unicode more closely
See UTS#39 "Unicode Security Mechanisms":
http://www.unicode.org/reports/tr39/

This means that characters with accents or other things around them are
now considered the confusable with the base character.

Fixes #557. Fixes #575.
2016-10-30 13:45:55 +01:00
east 3b8c17d9d6 fixed VS compilation 2016-10-06 13:03:48 +02:00
heinrich5991 89b6d0c3da Fix C89 compilation and a copy&paste mistake 2016-10-03 12:31:11 +02:00
heinrich5991 e950351346 Put the password generation into base 2016-10-01 23:04:16 +02:00
def 28f50e4440 Revert "Implement comma in search and exclude queries to separate search terms"
This reverts commit 3341e18d13.
2016-08-07 00:52:00 +02:00
def 5b19be992d C89 fix 2016-08-03 00:24:58 +02:00
def 3341e18d13 Implement comma in search and exclude queries to separate search terms 2016-08-02 22:16:02 +02:00
H-M-H a4a841c0f9 fix timer on macOS 2016-07-10 16:07:21 +02:00
heinrich5991 d8e27027f8 Use the monotonic clock on OS X 2016-07-03 12:56:29 +02:00
def 071822d281 Use clock_gettime(CLOCK_MONOTONIC) instead of gettimeofday().
Seems to work fine. (The initial bugs I had with this were caused by my
system's clock being wrong)
2016-06-28 23:30:35 +02:00
H-M-H c9e65c7931 Merge branch 'master' into sqlmasters 2016-05-03 23:07:24 +02:00
def 61e47422f6 Clean up debug messages a bit (lower case, no useless errors) 2016-05-02 21:35:32 +02:00
def c683703df0 Fix system.c for C89 2016-05-01 19:35:21 +02:00
def ab13a0086d Updater: Support downloading files into new directories 2016-05-01 14:20:55 +02:00
H-M-H 88ed7391da handle exceptions from sql properly
- write failed sqlinserts to a file
- improved structure
2016-02-20 15:33:35 +01:00
heinrich5991 a1923b154b Only ignore messages on invalid UTF-8, don't kick players 2016-01-27 01:48:19 +01:00
east 5267dfa9ac secure_rand: range [0, RAND_MAX] 2016-01-02 15:51:21 +01:00
east f3f33904f7 secure_rand() as replacement for client source port generation 2016-01-02 15:37:44 +01:00
heinrich5991 41a9760d79 Fix a constant in the UTF-8 decoder
(I can't read. Constant is described in
https://encoding.spec.whatwg.org/#utf-8-decoder step 3 second case.)
2015-09-08 11:44:57 +01:00
def 96f2a380f6 Get rid of warning 2015-09-05 04:52:18 +02:00
def 7487923774 Fix Windows thread handle leak 2015-09-05 04:49:22 +02:00
east 675c6eb1e0 Demo browser column listbox added 2015-08-27 15:05:24 +02:00
def a4a48255bc Minor indentation fix 2015-08-26 15:44:25 +02:00
def 6c0bac7508 Remove useless comparison 2015-08-26 04:02:52 +02:00
Chairn 33c421b428 Made fs_getmtime works for window. 2015-08-22 21:29:34 +02:00
def c033ad6828 Fix compilation on windows, needs implementation of fs_getmtime on Windows 2015-08-22 20:32:02 +02:00
def 08ac551e0e Add fs_getmtime as preparation for sorting by timestamp of file in demo view 2015-08-22 17:57:58 +02:00
BeaR ff3c4f22b4 Add hex value edit field for quad point color 2015-08-20 12:51:30 +02:00
def 74391e63b9 Hopefully fix moving config file on save on Windows by allowing overwrite 2015-07-28 02:12:05 +02:00
def 77c1442499 IPV6 fix by east 2015-07-12 03:08:58 +02:00
def 6d68e22cd1 Hopefully fix string fuzzying for unicode 2015-07-11 19:26:57 +02:00
def 6e8ada1ac8 Fix whitespaces a bit 2015-07-09 02:12:35 +02:00
def a9690bb484 Show all recorders in scoreboard (fixes #227) 2015-07-09 02:00:40 +02:00
heinrich5991 8ccfd0188d Error out on overlong UTF-8 sequences
This not only makes `str_utf8_decode` a compliant parser, but also fixes an
issue where overlong encodings led to undetected line breaks.

Implemented as per https://encoding.spec.whatwg.org/#utf-8-decoder.

Audited the following files, checking whether the new semantics work with the
existing code:
- src/base/system.c
- src/engine/client/text.cpp
- src/game/client/components/chat.cpp
- src/game/server/gamecontext.cpp

They all check whether the string is at its end separately.
2015-06-30 21:15:10 +02:00
heinrich5991 71548fc0d6 If no rcon password is set, generate one
After the generation (using the OS random number generator), the password is
displayed to the user on stdout.
2015-06-21 19:56:35 +02:00
def 85795b3331 Fix typo 2015-06-16 21:39:22 +02:00
east d9cc5a7458 allow reuse of tcp addr on restart 2015-06-13 11:49:35 +02:00
def 0ffa79671b Get rid of all GCC warnings 2015-04-18 21:33:51 +02:00
def aead2631b6 Fix os_compare_version a bit 2015-04-18 16:23:43 +02:00
Learath Lea df57a981de Add os_compare_version. Check for WinXP. 2015-04-18 15:53:11 +03:00
def 3992b1346b Hopefully fix compilation on new OS X systems
Names collided with some new OS X defined names, fixes #189
2015-04-07 19:07:38 +02:00
def 9b27da8e4a Try to fix secure RNG on Windows 2015-03-15 12:11:44 +01:00
Learath Lea b1044647f9 Winapi MoveFile allows moving the client. 2015-03-14 18:49:18 +02:00
def f893ed6ec4 Fix and clean up autoupdater 2015-03-13 15:14:00 +01:00
heinrich5991 fa0708b99d Make the secure random stuff platform-independent 2015-03-06 01:35:08 +01:00
Learath Lea 8d7251be4a Add shell_execute. 2015-02-23 20:24:48 +02:00
timgame 758c4b1c4d added 'NOINDEX' and 'OR' to automapper 2015-02-19 22:54:47 +01:00
eeeee 56c42c3c31 websockets support in server 2015-02-08 19:11:34 -08:00
def 27ac37a9f0 Oops 2015-01-19 22:14:49 +01:00
def b4f7321dd6 Revert "Add unicode support for console output on windows"
This reverts commit 92cdb15679.

Conflicts:
	src/base/system.c
2015-01-19 22:14:49 +01:00
eeeee 073a552b82 fix mac os build 2015-01-19 22:14:49 +01:00
def 55bfd2cf01 Always call freeaddrinfo 2014-12-28 01:40:15 +01:00
def 8b108a2311 Clean up gametype determination 2014-12-10 03:39:15 +01:00
BeaR 0b00f17627 Fix visual studio build (C89-compatibility) 2014-12-08 18:44:01 +01:00
def 9d488d7a28 No one cares about the TOS value but shouldn't hurt to set it 2014-12-07 14:19:03 +01:00
def 9e1ed24c53 Fuzzable server 2014-12-06 19:19:39 +01:00
def 771eb1a625 Disregard whitespaces in confusable name comparison 2014-11-26 02:05:40 +01:00
heinrich5991 1651c2ea35 Only use WriteConsoleW if the intended output is the console
Conflicts:
	src/base/system.c
2014-11-25 19:49:31 +01:00
heinrich5991 d2d4423655 Fix compilation on windows
const int wasn't detected as compile-time constant.
2014-11-25 19:49:19 +01:00
heinrich5991 92cdb15679 Add unicode support for console output on windows
Hints regarding the unicode support were taken from the libuv project, which
really helped.

Conflicts:
	src/base/system.c
2014-11-25 19:48:53 +01:00
def 92e4a5c7f1 Add ASCII confusable detection in names 2014-11-24 17:09:01 +01:00
def a08ed87cc4 Initial work on confusable utf8 name detection 2014-11-24 16:22:00 +01:00
def 140173311e Uncached time_get by default 2014-11-18 18:21:30 +01:00
def 808f889c00 Improve server wakeup timing 2014-11-11 13:00:02 +01:00
BeaR 29b5b92827 Fix C89-compatibility compiler error 2014-11-10 14:09:42 +01:00
def 4e9b6ea336 Ugly fix for client (TODO: improve) 2014-11-10 00:17:31 +01:00
def aede6df2ca Cache get_time calls 2014-11-10 00:08:50 +01:00
def bc9d632103 Clean up whitespace detection a bit and add BRAILLE PATTERN BLANK (U+2800) 2014-11-08 20:14:12 +01:00
def a36358190b Mac OS X compilation 2014-09-11 21:38:23 +02:00
def 1c8ca264c7 Use semaphores instead of locks 2014-09-11 21:12:18 +02:00
def dcfe0a7295 Fix Visual Studio compile 2014-09-11 18:23:59 +02:00
def 49682f4a8d Threaded logger output 2014-09-09 23:02:05 +02:00
def 60f0ae8607 Case insensitive filenames on Windows (fixes #20) 2014-08-26 22:37:59 +02:00
def 3c4bf96b8c Recording with multiple clients working 2014-08-22 14:18:16 +02:00
def 7875c2ec36 Android support (by Pelya) 2014-06-16 13:29:18 +02:00
def 948197b598 Only wake up server once every second if noone is connected anyway 2014-01-15 16:52:22 +01:00
Patrick Rathje 5114570794 Hotfix for Refresh 2014-01-08 07:46:24 +01:00
def 3eaad43b6b Merge remote-tracking branch 'upstream-teeworlds/0.6' into DDRace
Conflicts:
	bam.lua
	data/languages/index.txt
	src/engine/server/server.cpp
	src/engine/shared/network_server.cpp
	src/game/client/components/chat.cpp
	src/game/client/components/menus_settings.cpp
	src/game/server/entities/character.cpp
	src/game/server/gamecontext.cpp
	src/game/version.h
2013-12-26 18:02:22 +01:00
def 33566a626c Try to fix memory leaks 2013-08-08 01:47:49 +02:00
def c42e9f1399 Add /points and /toppoints using points.cfg file 2013-07-21 04:52:23 +02:00
oy fd5fe8b6ae fixed a warning 2013-04-26 17:10:05 +02:00