This change necessitated include guards on newdb.h.
#include <stdbool.h>
#include "common.h"
+#include "newdb.h"
#define LINESIZE 100
#define NDWARVES 6 /* number of dwarves */
long fixed[NOBJECTS + 1];
long link[NOBJECTS * 2 + 1];
long place[NOBJECTS + 1];
- long hinted[HNTSIZ + 1];
- long hintlc[HNTSIZ + 1];
+ long hinted[HINT_COUNT];
+ long hintlc[HINT_COUNT];
long prop[NOBJECTS + 1];
};
#define LOCSIZ 185
#define NOBJECTS 100
-#define HNTSIZ 20
extern const char advent_to_ascii[128];
extern const char ascii_to_advent[128];
#define TRVSIZ 885
#define TOKLEN 5
#define HINTLEN 5
+#define HNTSIZ 20
#include <stdio.h>
#include <stdlib.h>
* whether the abbreviated description is printed. Counts modulo 5
* unless "LOOK" is used. */
-static void write_0d(FILE* header_file, long single, const char* varname)
-{
- fprintf(header_file, "LOCATION long %s INITIALIZE(= %ld);\n", varname, single);
-}
-
static void write_1d(FILE* header_file, long array[], long dim, const char* varname)
{
fprintf(header_file, "LOCATION long %s[] INITIALIZE(= {\n", varname);
fprintf(header_file, "\n");
// content variables
- write_0d(header_file, HNTMAX, "HNTMAX");
write_1d(header_file, OBJSND, NOBJECTS + 1, "OBJSND");
write_1d(header_file, OBJTXT, NOBJECTS + 1, "OBJTXT");
write_1d(header_file, COND, LOCSIZ + 1, "COND");
#include "advent.h"
#include "database.h"
-#include "newdb.h"
/*
* Initialisation
/* Clear the hint stuff. game.hintlc[i] is how long he's been at LOC
* with cond bit i. game.hinted[i] is true iff hint i has been
* used. */
- for (int i = 1; i <= HNTMAX; i++) {
+ for (int i = 1; i <= HINT_COUNT; i++) {
game.hinted[i] = false;
game.hintlc[i] = 0;
}
static void checkhints(void)
{
if (COND[game.loc] >= game.conds) {
- for (int hint = 1; hint <= HNTMAX; hint++) {
+ for (int hint = 1; hint <= HINT_COUNT; hint++) {
if (game.hinted[hint])
continue;
if (!CNDBIT(game.loc, hint + HBASE))
c_name = "newdb.c"
h_template = """/* Generated from adventure.yaml - do not hand-hack! */
+#ifndef NEWDB_H
+#define NEWDB_H
#include <stdio.h>
extern const size_t CLSSES;
extern const int maximum_deaths;
extern const int turn_threshold_count;
+#define HINT_COUNT {}
enum arbitrary_messages_refs {{
{}
{}
}};
-/* end */
+#endif /* end NEWDB_H */
"""
c_template = """/* Generated from adventure.yaml - do not hand-hack! */
db = yaml.load(f)
h = h_template.format(
+ len(db["hints"]),
get_refs(db["arbitrary_messages"]),
get_refs(db["locations"]),
get_refs(db["object_descriptions"]),
mxscor += 2;
/* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */
- for (long i = 1; i <= HNTMAX; i++) {
+ for (long i = 1; i <= HINT_COUNT; i++) {
if (game.hinted[i])
score = score - hints[i-1].penalty;
}