Commit graph

47 commits

Author SHA1 Message Date
Andrei Alexeyev
b3025ad921
cli,main,progress: add --unlock-all flag for dev builds
Permanently unlocks all content
2023-05-29 00:48:50 +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
Alice D
491cf9d2ce
In-Game Character Profiles (#327) 2021-12-22 23:52:22 +02:00
Andrei Alexeyev
9b5d515721
Cutscenes (#249)
* WIP cutscenes

* cutscene tweaks

* cutscene: erase background drawing under text

* Make text outlines thicker

* Prepare an interface for adding new cutscenes

* Basic progress tracking for cutscenes

* cutscene: support specifying scene name and BGM

* cutscene: exit with transition after scene ends

* Implement --cutscene ID and --list-cutscenes CLI flags

* fix progress_write_cmd_unlock_cutscenes

* Play intro cutscene before entering main menu for the first time

Also added --intro parameter in dev builds to force playing the intro
cutscene

* Add intro cutscene

* cutscenes: update opening/01 scene

* add Reimu Good End

* remove Bonus Data

* split up a bit of dialogue, revert an image change in intro

* small typo

* most cutscenes complete

* smartquotify

* finish Extra intros

* new cutscenes routed into main game

* fix ENDING_ID

* rough 'mediaroom' menu

* fix cutscene menu crash

* derp

* PR changes

* fixing imports

* more PR fixes

* PR fixes, including updating the script to #255

* add in newlines for readability

Co-authored-by: Alice D <alice@starwitch.productions>
2020-11-28 12:11:10 +02:00
Andrei Alexeyev
40a3f6ead2
Add gameover BGM by RickyRister 2020-06-24 20:51:00 +03:00
Andrei Alexeyev
8692a1a05c
Fix segfault in progress file loader 2020-06-08 02:06:52 +03:00
Andrei Alexeyev
00e4837827
Separate StageInfo-related APIs from game-stage code (#227) 2020-05-16 23:41:54 +03:00
Andrei Alexeyev
54030d17ba
fix clang warnings 2020-04-05 07:41:34 +03:00
Andrei Alexeyev
0cbc86c66e
Add generic type-safe facility for dynamic arrays (#207)
Replace most ad-hoc opencoded dynamic arrays across the codebase
2020-04-05 05:51:00 +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
78edef358b
oops! 2019-03-11 12:43:12 +02:00
Andrei Alexeyev
a63e8f4a69
Add a basic music room 2019-03-11 01:21:43 +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
235e2e0783
allow to skip credits if the game has been cleared at least once
closes #154
2019-01-05 23:40:50 +02: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
ddc15eafc7
format stage ids more consistently 2017-12-31 10:08:07 +02:00
Andrei Alexeyev
e355e57fb5
make the list api require less insane casts all over the place
by sealing the spirit of insanity in its header file, that is
2017-12-24 08:16:25 +02:00
Andrei Alexeyev
29acd5f58a meson: intel intrinsics, various improvements 2017-12-21 03:58:54 +01:00
Andrei Alexeyev
7b53d9e731
redesign list api 2017-11-21 16:45:01 +02:00
Andrei Alexeyev
b61ef0bffc
more strict warnings; fixed some subtle bugs 2017-11-11 19:33:44 +02:00
Andrei Alexeyev
7702257651
wriggle ex spell changes:
* replaced the extra spell with a brand new one
    * replaced the final spell with an adapted version of formerly
    scuttle's acid rain
2017-10-16 15:28:06 +03:00
Andrei Alexeyev
de246906e0
store version info in progress file 2017-10-10 09:13:07 +03:00
Andrei Alexeyev
06a9874898 preserve game settings across restarts
this includes last picked difficulty, character, and shot mode
2017-10-10 08:23:36 +03:00
Andrei "Akari" Alexeyev
7c9e54a71d
update copyright and credits 2017-09-12 04:28:15 +03:00
Andrei "Akari" Alexeyev
12147f4486 Merge branch 'master' into vfs 2017-04-21 02:27:05 +03:00
Andrei "Akari" Alexeyev
e3da5f27f6 more correct and portable printing of size_t and fixed-width integers
previously it didn't work properly on windows
2017-04-21 02:11:53 +03:00
Andrei "Akari" Alexeyev
471f30083e WIP virtual filesystem 2017-04-20 05:02:22 +03:00
Andrei "Akari" Alexeyev
a64ef5391a fix release warnings 2017-04-08 18:38:49 +03:00
Andrei "Akari" Alexeyev
3a7fef4d9c track achieved endings
can be used later for unlockables
2017-04-07 20:34:35 +03:00
Andrei "Akari" Alexeyev
b3032d3712 played/cleared stats for stages (and by extension, spells) 2017-04-06 03:58:57 +03:00
Andrei "Akari" Alexeyev
f3b3e8b16a fix invalid allocation 2017-04-03 21:56:54 +03:00
Andrei "Akari" Alexeyev
9f95b4ce91 progress: preserve unknown commands in the file as-is for forwards compatibility 2017-03-29 23:14:04 +03:00
Andrei "Akari" Alexeyev
8e8abf1db6 Fixed a buffer overflow and prohibited sprintf 2017-03-25 03:41:10 +02:00
Andrei "Akari" Alexeyev
ceb5f6b16b Added "Hi-Score" support 2017-03-20 07:29:22 +02: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
41bf5e5ad0 unload libgl on exit, fix SDL_RWclose in progress_write() 2017-02-28 17:04:24 +02:00
Andrei "Akari" Alexeyev
c5c98d2324 fixed some leaks in progress.c 2017-02-28 16:57:08 +02:00
Andrei "Akari" Alexeyev
f2d385d147 Some stage-related refactoring 2017-02-26 14:17:48 +02:00
Andrei "Akari" Alexeyev
02c0b50bdb progress: add stage/difficulty unlock cmd, improve writing routine 2017-02-19 03:28:00 +01:00
Andrei "Akari" Alexeyev
347f143a54 Unlock spellcards on story mode encounter
But only when not using continues!
2017-02-19 03:28:00 +01:00
Andrei "Akari" Alexeyev
b900263611 StageProgress API 2017-02-19 03:28:00 +01:00
Andrei "Akari" Alexeyev
2643c4df01 Initial support for persistent player progress storage
Only implements unlockable stages for now, but designed to be extensible.
See comments in progress.c for detauls.
2017-02-19 03:28:00 +01:00