eco2d/code/apps/server/source/main.c

45 lines
1.2 KiB
C
Raw Normal View History

2021-01-11 13:47:14 +00:00
#define ZPL_IMPL
#include "zpl.h"
2021-01-10 16:42:01 +00:00
#define LIBRG_IMPL
2021-01-11 13:47:14 +00:00
#define LIBRG_CUSTOM_ZPL
2021-01-10 16:42:01 +00:00
#include "librg.h"
2021-01-11 13:47:14 +00:00
#include "system.h"
#include "options.h"
#define DEFAULT_WORLD_SEED 302097
int main(int argc, char** argv) {
zpl_opts opts={0};
zpl_opts_init(&opts, zpl_heap(), argv[0]);
zpl_opts_add(&opts, "?", "help", "the HELP section", ZPL_OPTS_FLAG);
zpl_opts_add(&opts, "p", "preview-map", "draw world preview", ZPL_OPTS_FLAG);
zpl_opts_add(&opts, "s", "seed", "world seed", ZPL_OPTS_INT);
2021-01-11 18:10:56 +00:00
zpl_opts_add(&opts, "r", "random-seed", "generate random world seed", ZPL_OPTS_FLAG);
2021-01-11 13:47:14 +00:00
uint32_t ok = zpl_opts_compile(&opts, argc, argv);
if (!ok) {
zpl_opts_print_errors(&opts);
zpl_opts_print_help(&opts);
return -1;
}
int32_t seed = zpl_opts_integer(&opts, "seed", DEFAULT_WORLD_SEED);
2021-01-11 18:10:56 +00:00
if (zpl_opts_has_arg(&opts, "random-seed")) {
zpl_random rnd={0};
zpl_random_init(&rnd);
seed = zpl_random_gen_u32(&rnd);
2021-01-11 18:28:57 +00:00
zpl_printf("Seed: %lld\n", seed);
2021-01-11 18:10:56 +00:00
}
2021-01-11 13:47:14 +00:00
if (zpl_opts_has_arg(&opts, "preview-map")) {
generate_minimap(seed);
return 0;
}
2021-01-10 16:42:01 +00:00
printf("hello world\n");
return 0;
}