Commit graph

40 commits

Author SHA1 Message Date
Andrei Alexeyev
8b37d1cbf2
src: the great #include massacre of 2024 2024-05-17 14:11:48 +02:00
Andrei Alexeyev
be7905d6a3
src: run upkeep 2024-05-17 04:58:47 +02:00
Andrei Alexeyev
ccc8f018ac
random: remove old API 2023-02-24 18:13:08 +01:00
Andrei Alexeyev
3ec14a7726
random: fix ubsan complaint 2021-12-17 14:40:28 +02:00
Andrei Alexeyev
8c78c5e08c
fix non-developer build with assertions 2020-03-08 14:17:26 +02:00
Andrei Alexeyev
5c6b7671ef
fixup some post-rebase chaos 2020-03-04 22:26:45 +02:00
Andrei Alexeyev
23636c4ace
pimp up stage1 background 2020-03-04 22:26:44 +02:00
Andrei Alexeyev
b685379245
ignore -Wdeprecated-declarations in impl. of deprecated RNG api 2020-03-04 22:26:43 +02:00
Andrei Alexeyev
3725e3184a
fix error: initializer element is not a compile-time constant 2020-03-04 22:26:42 +02:00
Andrei Alexeyev
1f1db18076
New RNG API, with crude semi-automatic misuse detection 2020-03-04 22:26:42 +02:00
Andrei Alexeyev
35c1a90912
RNG improvements (replay-breaking) 2020-03-04 22:26:41 +02:00
Andrei Alexeyev
5a23fb95fc
make upkeep script preserve existing copyrights 2019-08-03 20:44:22 +03:00
Andrei Alexeyev
3055901998
update my email 2019-07-03 21:00:56 +03:00
Andrei Alexeyev
c7ff531a63
fixup includes 2019-03-18 06:41:12 +02:00
Andrei Alexeyev
fc41ebf89c
Replace RNG with xoshiro256+; update replay format
Support for writing older replay versions has been removed.
2019-03-09 18:19:42 +02:00
Andrei Alexeyev
b91b85c42a
Logging: colors, non-fatal error level, alt. format for log file
Also removed traceback support entirely as it never produced useful
output.
2019-02-15 01:58:40 +02:00
Andrei Alexeyev
4159ea1249
'upkeep' target for maintenance tasks; back to include guards; happy new year! 2019-01-23 22:10:43 +02:00
Andrei Alexeyev
aefc398883
remove outdated/broken tests 2018-04-18 18:23:24 +03:00
Andrei Alexeyev
59cf8f6300
Rendering system rewrite, tons of refactoring, optimizations, and other cool stuff (#116) 2018-04-12 17:08:48 +03:00
Andrei Alexeyev
513d613387
Consistent indentation: indent with tabs, align with spaces (#104)
I would've preferred to just go with 4-spaces for indent and no tabs,
but lao is a bit conservative about it. :^)

Still, this is a ton better than mixing different styles all over the
place, especially within the same file.
2018-01-12 20:26:07 +02:00
Andrei Alexeyev
485c9a8ed6
Happy New Year! 2018-01-04 19:14:31 +02:00
Andrei Alexeyev
29acd5f58a meson: intel intrinsics, various improvements 2017-12-21 03:58:54 +01:00
Andrei Alexeyev
52cbceacd6
use a better RNG algorithm (CMWC) 2017-12-04 05:26:27 +02:00
Andrei "Akari" Alexeyev
7c9e54a71d
update copyright and credits 2017-09-12 04:28:15 +03:00
Andrei "Akari" Alexeyev
3d5344de3b Renamed log_err to log_fatal 2017-03-13 18:03:51 +02:00
Andrei "Akari" Alexeyev
45da155cb2 Implemented a simple and consistent logging subsystem
The goal of this change is mainly to clean up Taisei's codebase and
improve its console output. I've been frustrated by files littered with
inconsistent printf/fprintf/warnx/errx calls for a long time, and now I
actually did something about it.

All the above functions are now considered deprecated and result in a
compile-time warning when used. Instead, the following macros should be
used:

    log_debug(format, ...)
    log_info(format, ...)
    log_warn(format, ...)
    log_err(format, ...)

As you can see, all of them have the same printf-like interface. But
they have different functionality and purpose:

    log_debug is intended for very verbose and specific information. It
    does nothing in release builds, much like assert(), so don't use
    expressions with side-effects in its arguments.

    log_info is for various status updates that are expected during
    normal operation of the program.

    log_warn is for non-critical failures or other things that may be
    worth investigating, but don't inherently render the program
    non-functional.

    log_err is for when the only choice is to give up. Like errx, it
    also terminates the program. Unlike errx, it actually calls abort(),
    which means the cleanup functions are not ran -- but on the other
    hand, you get a debuggable backtrace. However, if you're trying to
    catch programming errors, consider using assert() instead.

All of them produce output that contains a timestamp, the log level
identifier, the calling function's name, and the formatted message.

The newline at the end of the format string is not required -- no, it is
actually *prohibited*. The logging system will take care of the line
breaks by itself, don't litter the code with that shit.

Internally, the logging system is based on the SDL_RWops abstraction,
and may have multiple, configurable destinations. This makes it easily
extensible. Currently, log_debug and log_info are set to write to
stdout, log_warn and log_err to stderr, and all of them also to the file
log.txt in the Taisei config directory.

Consequently, the nasty freopen hacks we used to make Taisei write to
log files on Windows are no longer needed -- which is a very good thing,
considering they probably would break if the configdir path contains
UTF-8 characters. SDL_RWFromFile does not suffer this limitation.

As an added bonus, it's also thread-safe.

Note about printf and fprintf: in very few cases, the logging system is
not a good substitute for these functions. That is, when you care about
writing exactly to stdout/stderr and about exactly how the output looks.

However, I insist on keeping the deprecation warnings on them to not
tempt anyone to use them for logging/debugging out of habit and/or
laziness.

For this reason, I've added a tsfprintf function to util.c. It is
functionally identical to fprintf, except it returns void. Yes, the name
is deliberately ugly. Avoid using it if possible, but if you must, only
use it to write to stdout or stderr. Do not write to actual files with
it, use SDL_RWops.
2017-03-13 07:45:01 +02:00
Andrei "Akari" Alexeyev
9a7a874783 Use the standard bool type instead of that stupid enum
Also removed all of the annoying trailing tabs/whitespaces
2017-02-11 05:56:47 +02:00
Andrei "Akari" Alexeyev
a87169bcd6 Replaced uint with unsigned int for portability
uint is non-standard and my win64 crosscompiler doesn't recognize it
2017-02-07 00:37:42 +02:00
laochailan
26143e6f36 Added random generator testing script 2017-02-06 07:59:39 +01:00
Andrei "Akari" Alexeyev
0af7aad20a typo 2017-02-06 02:10:45 +02:00
Andrei "Akari" Alexeyev
b38e41e681 Added extra checks to prevent and help debug incorrect usage of some tsrand functions 2017-02-05 22:16:50 +02:00
Andrew "Akari" Alexeyew
0f78b1a7eb Got rid of inline prototypes 2012-08-10 22:27:46 +03:00
laochailan
3835fe7a6e fixed one wrong afrand 2012-08-09 16:38:37 +02:00
Andrew "Akari" Alexeyew
adb7ddb89a added a sanity check 2012-08-04 04:30:40 +03:00
Andrew "Akari" Alexeyew
5313e309bc cleaned stage3 2012-08-04 03:56:51 +03:00
Andrew "Akari" Alexeyew
a7c6ad15d3 array system for tsrand; cleaned the first stage 2012-08-04 03:49:12 +03:00
Andrew "Akari" Alexeyew
769c240e03 Merge remote-tracking branch 'upstream/master' into stage3
Conflicts:
	src/global.c
	src/global.h
2012-07-27 21:59:24 +03:00
Andrew "Akari" Alexeyew
0eb4b93d92 stupyd error 2012-07-27 21:06:01 +03:00
Andrew "Akari" Alexeyew
6060548e65 inline frand 2012-07-27 20:14:11 +03:00
Andrew "Akari" Alexeyew
5a7f17a240 Added a custom random generator 2012-07-27 20:11:45 +03:00