Commit graph

24 commits

Author SHA1 Message Date
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
Martin Herkt
685b1b947d Replace CMake build system with Meson
No I will not try and keep both systems working. CMake should GTFO.
2017-12-21 03:58:54 +01:00
Martin Herkt
119535eda4
Fix symbol clashes
Happens to remove some duplicate code as well.
2017-11-12 04:51:04 +01:00
Andrei Alexeyev
3413bd92e7
many vfs improvements
* There's no distinction between "temp" and "perm" nodes anymore.
    All nodes are allocated with 1 reference belonging to the
    vfs_alloc() caller.

    * VFSNode pointers retrieved by any API that returns one (most
    notably vfs_locate) are guaranteed to have exactly one reference
    belonging to the caller. What this means is that you must always
    decref them when you're done using them.

    If you're implementing such an API (e.g. a custom locate), remember
    to incref any persistent nodes you return.

    * Passing a VFSNode* to anything that successfully consumes one (for
    example, vfs_mount) transfers ownership of the reference to the
    consumer. In other words, consumers do not incref your nodes, but
    they will decref them once they don't need them anymore. If you want
    to keep the node around, then you must incref it first.

    * Bunch of other stuff.

"Ownership" is an abstract concept in this context. Basically it just
means "cleanup responsibility".
2017-11-10 21:49:54 +02:00
makise-homura
2b35177cb4 Removed excess and added missing newlines at end of files 2017-10-10 21:10:35 +03:00
makise-homura
5c82b2124c Made ZIP support optional; dropped requirements for CMake from 3.3 to 3.0.2 and libzip from required to optional >=1.0 2017-10-10 20:59:51 +03:00
Andrei Alexeyev
2038d3b201
Revert "merge pull request #86"
This reverts commit e9c4979eb9.
2017-10-09 00:33:45 +03:00
Igor Molchanov
e9c4979eb9 merge pull request #86
* Made ZIP support optional; dropped requirements for CMake from 3.3 to 3.0.2 and libzip from required to optional >=1.0

* Forgot to add PARENT_SCOPE

* LTO support made optional (by the way, corrected a typo in CheckAndSetFlags cmake file)

* Added RELEASE_BUILD check; -flto now used in RELEASE_BUILDs rather that NOT DEBUG_BUILDs.

* Changed STATUS to WARNING if no cmake or libzip suitable for compressing data found. Old cmake now disables only packaging, not ZIP support at all.

* Clarified some README things about BGM placement

* Added words about user-specific bgm directories
2017-10-08 14:46:29 +03:00
Andrei Alexeyev
0d1eff8591
rwops_segment: fix false assertion failure 2017-09-30 03:55:30 +03:00
laochailan
03a2426012
update to use #pragma once 2017-09-27 14:14:53 +02:00
Andrei "Akari" Alexeyev
7c9e54a71d
update copyright and credits 2017-09-12 04:28:15 +03:00
Andrei "Akari" Alexeyev
30db0de273
rwops autobuf: fix data corruption after realloc
In particular, this fixes corrupted metadata in compressed multi-stage
replays.

Also added a dummy rwops wrapper for debugging.
2017-09-12 03:04:06 +03:00
Andrei "Akari" Alexeyev
faa70794b2 vfs: transparent support for zip files + other improvements and fixes 2017-04-28 00:24:04 +03:00
Andrei "Akari" Alexeyev
455039edb4 Implemented a custom assert() that uses the log system if possible
Bonus: no need to include assert.h
2017-03-15 11:21:39 +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
9728ac9e72 Workaround to make playing replays from non-seekable streams work again
That is, so you can curl ... | taisei replay /dev/stdin
2017-02-27 21:14:20 +02:00
Andrei "Akari" Alexeyev
a8537f6e69 rwops_zlib: reorganized the private ZData struct a bit 2017-02-23 17:15:47 +02:00
Andrei "Akari" Alexeyev
b0abd177ac Removed redundant null checks before free() calls
free(NULL) is guaranteed to be a no-op by the C standard, so let's not
clutter the code with those.
2017-02-23 16:05:55 +02:00
Andrei "Akari" Alexeyev
397719a2a2 Switched from GNU C99 to Standard C11. Enabled pedantic warnings.
Fixed all warnings and compile errors.
Confirmed successful compilation without warnings for linux (gcc,
clang), windows (gcc-mingw), osx (clang-osxcross).
2017-02-23 13:16:52 +02:00
Andrei "Akari" Alexeyev
b7f1d2f2d3 autoclose parameter for the RWops wrappers 2017-02-23 06:04:42 +02:00
Andrei "Akari" Alexeyev
9687a65549 Added SDL_RWGetZStream 2017-02-23 05:47:03 +02:00
Andrei "Akari" Alexeyev
db0cfa43bc "straightforward" my ass 2017-02-22 22:52:25 +02:00