Add SDL2_mixer support.
[runemen.git] / src / game.c
blob95b40a4cc6a6d1862a6fb5478be7ad616327f190
1 #include "game.h"
2 #include "mana.h"
4 int level_w;
5 int level_h;
7 int turns = 0;
9 unit_t units[MAX_UNITS];
10 house_t houses[MAX_HOUSES];
11 int num_houses = 0;
12 int num_units = 0;
14 pool_t pools[MAX_POOLS];
15 int num_pools = 0;
17 faction_t factions[8];
18 faction_t *your;
20 /*** ***/
21 const char housetabs_names[MAX_HOUSETABS][80] = {
22 "Info", "Items", "Visitors", "Research", "Upgrade", "Home"
24 const char unittabs_names[MAX_UNITTABS][80] = {
25 "Info", "Stats", "Skills", "Items", "Runes", "Home"
28 const char desire_names[MAX_DESIRES][80] = {
29 "None", "Rune", "Gold", "Power", "Love", "Protect", "Destroy", "Killall", "Helpall",
31 const char start_names[MAX_STRATEGIES][80] = {
32 "None", "Work", "Hunt", "Kill", "Heal", "Hide"
34 const char tact_names[MAX_TACTICS][80] = {
35 "None", "Mine", "Build", "Repair", "Train", "Buy", "Charm", "Attack", "Hide", "Run"
37 const char modus_names[MAX_MODUS][80] = {
38 "",
41 const char stat_names[MAX_STAT][80] = {
42 "STR", "DEX", "CON", "INT", "MET", "CHR",
45 const char stat_long_names[MAX_STAT][80] = {
46 "Strength", "Dexterity", "Constitution", "Intelligence",
47 "Metablosim", "Charisma"
50 const char stat_descriptions[MAX_STAT][1024] = {
51 /* STR */ "",
52 /* DEX */ "",
53 /* CON */ "",
54 /* INT */ "Improves magic ability,\nmemory and wits.",
55 /* MET */ "",
56 /* CHR */ "",
59 const char state_names[4][80] = {
60 "Free Man", "Devotee", "Vector", "Rune Lord"
63 Uint8 scent_human[LEVEL_H][LEVEL_W];
65 Uint8 fog[LEVEL_H][LEVEL_W] = { { 1 } }; /* could be condensed to 1-bpp */
67 int flag_grid_i[LEVEL_H][LEVEL_W];
68 int unit_grid_i[LEVEL_H][LEVEL_W];
69 int house_grid_i[LEVEL_H][LEVEL_W];
71 unit_t* unit_grid[LEVEL_H][LEVEL_W];
72 house_t* house_grid[LEVEL_H][LEVEL_W];
75 /* Logging */
76 log_t gamelog;
78 void log_reset(log_t *log) {
80 memset(log, 0, sizeof(log_t));
84 void log_add(log_t *log, const char *buf) {
86 int i;
88 //TODO: make a circular buffer
89 if (log->num >= LOG_MESSAGE_MAX - 1) {
90 for (i = 1; i < log->num; i++) {
91 memcpy(log->message[i - 1], log->message[i], 256);
93 log->num--;
96 i = log->num;
98 strncpy(log->message[i], buf, sizeof(log->message[i]));
100 log->num++;
101 //log->tail++;
105 void log_addf(log_t *log, char *fmt, ...) {
106 char buffer[1024];
108 va_list argptr;
109 va_start(argptr, fmt);
111 vsnprintf(buffer, sizeof(buffer), fmt, argptr);
113 va_end(argptr);
115 log_add(log, buffer);
117 return;