mp3 support for playing background music

This commit is contained in:
Ondřej Novák 2025-06-15 12:56:18 +02:00
parent 73a4187f79
commit dd23d8c989
24 changed files with 2245 additions and 252 deletions

View file

@ -14,10 +14,11 @@ void show_help(const char *arg0) {
"\n"
"Usage:"
);
printf("%s [-f <file>] [-a <file>] [-l <lang>] [-s <dir>] [-h]\n\n", arg0);
printf("%s [-f <file>] [-a <file>] [-p <file> ] [-l <lang>] [-s <dir>] [-h]\n\n", arg0);
printf("-f <file> path to configuration file\n"
"-a <adv> path for adventure file (.adv)\n"
"-p <file> patch data with custom DDL\n"
"-l <lang> set language (cz|en)\n"
"-s <directory> generate string-tables (for localization) and exit\n"
"-h this help\n");
@ -33,12 +34,14 @@ int main(int argc, char **argv) {
std::string config_name = SKELDALINI;
std::string adv_config_file;
std::string gen_stringtable_path;
std::string patch;
std::string lang;
for (int optchr = -1; (optchr = getopt(argc, argv, "hf:a:s:l:")) != -1; ) {
for (int optchr = -1; (optchr = getopt(argc, argv, "hf:a:s:l:p:")) != -1; ) {
switch (optchr) {
case 'f': config_name = optarg;break;
case 'a': adv_config_file = optarg;break;
case 'h': show_help(argv[0]);break;
case 'p': patch = optarg; break;
case 'l': lang = optarg;break;
case 's': gen_stringtable_path = optarg;break;
default: show_help_short();
@ -54,6 +57,7 @@ int main(int argc, char **argv) {
cfg.adventure_path = adv_config_file.empty()?NULL:adv_config_file.c_str();
cfg.config_path = config_name.c_str();
cfg.lang_path = lang.empty()?NULL:lang.c_str();
cfg.patch_file = patch.empty()?NULL:patch.c_str();
try {
if (!gen_stringtable_path.empty()) {

View file

@ -13,7 +13,7 @@
#include <errno.h>
// Funkce pro mapování souboru do paměti
void* map_file_to_memory(const char *name, size_t *sz) {
const void* map_file_to_memory(const char *name, size_t *sz) {
if (!name || !sz) {
return NULL;
}
@ -49,13 +49,13 @@ void* map_file_to_memory(const char *name, size_t *sz) {
}
// Funkce pro zrušení mapování
void unmap_file(void *ptr, size_t sz) {
void unmap_file(const void *ptr, size_t sz) {
if (!ptr || sz == 0) {
return;
}
// Zrušení mapování
if (munmap(ptr, sz) == -1) {
perror("Chyba při rušení mapování");
if (munmap((void *)ptr, sz) == -1) {
perror("Failed to unmap file");
}
}

View file

@ -5,8 +5,8 @@
extern "C" {
#endif
void *map_file_to_memory(const char *name, size_t *sz);
void unmap_file(void *ptr, size_t sz);
const void *map_file_to_memory(const char *name, size_t *sz);
void unmap_file(const void *ptr, size_t sz);
#ifdef __cplusplus
}