-
Notifications
You must be signed in to change notification settings - Fork 0
/
level_set.cpp
60 lines (43 loc) · 1.47 KB
/
level_set.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "level_set.h"
#include "file_utils.h"
void init_level_set(Level_Set *set)
{
array_init(&set->level_names);
set->loaded = false;
}
void init_level_set_catalog(Level_Set_Catalog *catalog)
{
// @Fixme: Loading from the folder names 'my_name' for now
catalog->base.my_name = String("level_sets");
array_add(&catalog->base.extensions, String("level_set"));
do_polymorphic_catalog_init(catalog);
}
Level_Set *make_placeholder(Level_Set_Catalog *catalog, String short_name, String full_path)
{
Level_Set *set = New<Level_Set>(false);
init_level_set(set);
set->name = copy_string(short_name);
set->full_path = copy_string(full_path);
return set;
}
// @Cleanup: Duplicate of entity_manager.cpp
#define error(c_agent, handler, ...) \
printf("[%s] Error at line %d: ", c_agent, handler.line_number); \
printf(__VA_ARGS__);
void reload_asset(Level_Set_Catalog *catalog, Level_Set *set)
{
array_reset(&set->level_names);
Text_File_Handler handler;
String agent("level_set:reload_asset");
start_file(&handler, set->full_path, agent);
if (handler.failed) return;
defer { deinit(&handler); };
auto c_agent = temp_c_string(agent);
while (true)
{
auto [line, found] = consume_next_line(&handler);
if (!found) break;
assert(line);
array_add(&set->level_names, copy_string(line));
}
}