mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-12 20:18:00 +01:00
character: allow creating characters with NULL name
Useful for shared characters that are going to be swapped between their archetypes.
This commit is contained in:
parent
a7d2ed55c0
commit
a74aa55409
1 changed files with 7 additions and 3 deletions
|
@ -307,9 +307,11 @@ SYMBOL_EXPORT void RegisterSpritesheet(struct Game* game, struct Character* char
|
|||
}
|
||||
|
||||
SYMBOL_EXPORT struct Character* CreateCharacter(struct Game* game, char* name) {
|
||||
PrintConsole(game, "Creating character %s...", name);
|
||||
if (name) {
|
||||
PrintConsole(game, "Creating character %s...", name);
|
||||
}
|
||||
struct Character* character = malloc(sizeof(struct Character));
|
||||
character->name = strdup(name);
|
||||
character->name = name ? strdup(name) : NULL;
|
||||
character->frame = NULL;
|
||||
character->spritesheet = NULL;
|
||||
character->spritesheets = NULL;
|
||||
|
@ -396,7 +398,9 @@ SYMBOL_EXPORT void DestroyCharacter(struct Game* game, struct Character* charact
|
|||
if (character->predecessor) {
|
||||
free(character->predecessor);
|
||||
}
|
||||
free(character->name);
|
||||
if (character->name) {
|
||||
free(character->name);
|
||||
}
|
||||
free(character);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue