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
b6978178b1
memory: use custom memory allocation wrappers
Introduces wrappers around memory allocation functions in `memory.h`
that should be used instead of the standard C ones.

These never return NULL and, with the exception of `mem_realloc()`,
zero-initialize the allocated memory like `calloc()` does.

All allocations made with the memory.h API must be deallocated with
`mem_free()`. Although standard `free()` will work on some platforms,
it's not portable (currently it won't work on Windows). Likewise,
`mem_free()` must not be used to free foreign allocations.

The standard C allocation functions are now diagnosed as deprecated.
They are, however, available with the `libc_` prefix in case interfacing
with foreign APIs is required. So far they are only used to implement
`memory.h`.

Perhaps the most important change is the introduction of the `ALLOC()`,
`ALLOC_ARRAY()`, and `ALLOC_FLEX()` macros. They take a type as a
parameter, and allocate enough memory with the correct alignment for
that type. That includes overaligned types as well. In most
circumstances you should prefer to use these macros. See the `memory.h`
header for some usage examples.
2023-01-18 13:23:22 +01:00
Andrei Alexeyev
b902e90229
Add alist_merge_tail to efficiently merge two lists
Empties the "source" list, moving its contents to the tail of the
"destination" list.
2020-03-31 22:16:10 +03: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
14f0a170c8
WIP: accelerate build with precompiled headers
Also got rid of rwops_pipe; we don't use it and PCHs make passing the
required feature macro for the posix implementation too complicated.
2019-02-09 12:29:54 +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
83a8961df6
use "anchored" lists for most game objects
these have a pointer to the last element, thus appending is fast
2018-06-01 21:40:18 +03:00
Andrei Alexeyev
8ef5ffd32c
Flexible draw order; entity "base class" for all game objects 2018-04-15 09:43:11 +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
d73f8d28a3
add head version of list_insert_at_priority, use it for proj_insert_colorprio (slightly faster) 2018-01-09 21:54:03 +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
abbc62b49c
object pools 2017-12-13 21:08:23 +02:00
Andrei Alexeyev
db8dd8ad7c
desperate optimizations
i even used a profiler
2017-11-23 18:23:30 +02:00
Andrei Alexeyev
7b53d9e731
redesign list api 2017-11-21 16:45:01 +02:00
Andrei Alexeyev
586af9a6b0
huge projectile API changes and optimizations (#93) 2017-11-10 22:49:16 +02:00
laochailan
c2b3747d95
Animation player manager Pro (tm) 2k17 2017-10-03 17:25:38 +02:00
Andrei Alexeyev
ef67a16867
WIP event system rewrite. text input missing 2017-10-01 00:43:18 +03:00
Andrei "Akari" Alexeyev
7c9e54a71d
update copyright and credits 2017-09-12 04:28:15 +03: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
ca16c30966 large refactoring WIP
windows & osx untested
bgm untested
too many changes to comment on
2017-03-05 00:39:17 +02:00
Andrei "Akari" Alexeyev
fdd4633e19 Implemented a simple general-purpose hashtable 2017-02-28 19:28:15 +02:00
Andrei "Akari" Alexeyev
4acfc71887 Clean up all refs when a stage ends, print a warning if some leaked 2017-02-28 16:38:02 +02:00
Andrei "Akari" Alexeyev
e4bcf929f9 Ensured newline at the end of files 2017-02-23 12:43:45 +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
laochailan
2d4e7c60a1 ordered bullets by texture area 2012-08-17 16:20:05 +02:00
laochailan
52d7c8cf06 made create_element really work for any position 2012-08-17 15:59:31 +02:00
laochailan
1cc70f1dc7 made create_element work for any list position 2012-08-17 15:37:09 +02:00
laochailan
d04475591c create_element() was stupidish
so was youmu_homing()
2011-07-14 12:00:22 +02:00
laochailan
b0dbe755f9 Improved youmu homing
also:
+ master spark sound
* only one of a sound per frame
* references are more efficient
2011-07-07 14:34:30 +02:00
laochailan
91b3b7d65e reference system
added some kind of reference system (see list.h) to ensure particles/projectiles/enemies storing pointers to each other that they will not access a borked address.
2011-05-13 19:03:02 +02:00
laochailan
d9fdc2aa0e Dialogs! conversational~
fun fact: taisei might build with -Wall -Werror now.
2011-05-08 13:48:25 +02:00
laochailan
3f2885e185 fix: memleaks
there were some memleaks I left out of laziness. fixed.
2011-04-26 22:39:50 +02:00
Lukas Weber
f35130ad1c openth becomes seiyou
After this short break, I have to announce that this project is no longer called openth. The name was stereotypical and conflicted with Open Theme Hospital. Thus, gentlemen, we are now working on Seiyou (西洋). Thanks to lachs0r for this wonderful suggestion.

Also the lincense has changed. Farewell, gnutardedness, hello MIT. I feel somehow relieved now after freeing the project of nearly one thousand lines.
2011-03-05 13:44:21 +01:00
Lukas Weber
efe53bb47b Bugfixes & more fancyness
Second commit today. Things from earlier were made even fancier and there are some minor bugfixes. Try focussing. :)
2010-11-28 12:54:13 +01:00
Lukas Weber
bdfceda7b9 Power! and fonts
I built some font support (new dependency: SDL_ttf). The Biolinum font of the Libertine project was included as the new ingame font.

Shot at fairies and you will get power. The system is pretty dumb currently, i guess i'll improve it somwhen. If you get a power level >= 2 you get a better shot. anyway, just testing. the player projectiles are somewhat uncomfortable to look at. to do.
2010-11-14 13:24:56 +01:00
Lukas Weber
a4a2d9a1a1 killed list double code
yay. look, i cut some of that annoying list code repetitions you always have with linked lists in C. let's just pretend C had templates, put some void-pointers in, add the necessary (void *) casts to show that you are really serious about this and wazaah, you created another funny piece of (C++)--
2010-10-27 19:51:49 +02:00