view src/libmaputils.h @ 2833:d0e186348cb2 default tip

Add mention of soft level limitation to 'Eightleg woods'.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 26 May 2024 20:33:53 +0300
parents b294c2efea35
children
line wrap: on
line source

/*
 * libmaputils - Generic functions/tables for maputils package
 * Programmed by Matti 'ccr' Hämäläinen <ccr@tnsp.org>
 * (C) Copyright 2006-2022 Tecnic Software productions (TNSP)
 */
#ifndef LIBMAPUTILS_H
#define LIBMAPUTILS_H

#include "libutil.h"
#include <stdio.h>
#include <stdarg.h>


/* Map diff format header and version
 */
#define DIFF_MAGIC      "MAPDIFF"
#define DIFF_VERSION    2

#define BLOCK_SCAN_ALIGN	8


/* Typedefs
 */
typedef struct
{
    char symbol;
    char *desc;
    int  cr, cg, cb;
    int  color;
    char oldSymbol;
} MapPiece;


typedef struct
{
    unsigned char *data;
    int width, height, scansize, size;
    int xc, yc;
    bool mark;
} MapBlock;


typedef struct
{
    int cr, cg, cb;
    int ansi;
    int ansiAttr;
    bool bold;
} MapColor;


enum
{
    ANSI_OFF           = 0,
    ANSI_BOLD          = 1,
    ANSI_UNDERSCORE    = 4,
    ANSI_BLINK         = 5,
    ANSI_REVERSE       = 7,
    ANSI_CONCEALED     = 8
};


enum
{
    col_black = 0,
    col_blue,
    col_red,
    col_yellow,
    col_green,
    col_white,
    col_cyan,
    col_magenta,

    col_light_black,
    col_light_blue,
    col_light_red,
    col_light_yellow,
    col_light_green,
    col_light_white,
    col_light_cyan,
    col_light_magenta,

    col_very_light_red,
    col_very_dark_gray,
};


/* Some global tables
 */
extern const MapColor mapColors[];
extern const int nmapColors;

extern const MapPiece mapPieces[];
extern const int nmapPieces;


/* Misc functions
 */
int         fputse(const char *str, FILE *outFile);
int         fprintve(FILE *outFile, const char *fmt, va_list ap);
int         fprintfe(FILE *outFile, const char *fmt, ...);

int         fprintvesc1(FILE *outFile, const char *fmt, va_list ap);
int         fprintfesc1(FILE *outFile, const char *fmt, ...);
int         fputsesc1(const char *str, FILE *f);
int         fputsesc2(const char *str, FILE *f);
int         fputsesc3(const char *str, FILE *f);

int         muGetMapPieceIndex(int symbol, bool getOld, bool getCity);
int         muGetMapPieceColor(int symbol, bool getOld, bool getCity);
void        muPrintHTMLhead(FILE *outFile, const char *title, bool html5);
void        muPrintHTMLcolors(FILE *outFile, const char *tagName, const char *propName, const char *extra);
char *      muColorToCSSColor(char *buf, const size_t len, const int c);
int         muCopyFileToStream(FILE *outFile, const char *filename);
bool        muStrChr(const unsigned char *symbols, const size_t nsymbols, const unsigned char ch);


/* Mapblock handling
 */
MapBlock *  mapBlockAlloc(int width, int height);
MapBlock *  mapBlockCopy(const MapBlock *block);
void        mapBlockFree(MapBlock *block);
MapBlock *  mapBlockParseStream(const char *filename, FILE *fh, bool isDiff);
MapBlock *  mapBlockParseFile(const char *filename, bool isDiff);
void        mapBlockPrint(FILE *fh, const MapBlock *block);
int         mapBlockPutDo(MapBlock *map, const MapBlock *src, const int ox, const int oy);
int         mapBlockPut(MapBlock **pmap, const MapBlock *src, const int ox, const int oy);
void        mapBlockClean(MapBlock *block, const unsigned char *symbols, const size_t nsymbols);
void        mapBlockPrintRaw(FILE *fh, const MapBlock *block);


#endif