Dungeonator  1.0.0
a dungeon generator library
Data Structures | Macros | Typedefs | Functions
connectors.h File Reference

file for connections between regions (doors) More...

#include <stdbool.h>
#include "grid.h"
#include "direction.h"
#include "util.h"

Go to the source code of this file.

Data Structures

struct  Connectors
 

Macros

#define CONNECTOR_ALLOC_SIZE   50
 

Typedefs

typedef struct Connectors Connector
 

Functions

ConnectorgetConnectors (Grid *grid, regions_t regions, size_t *num_connectors)
 
int * mapMergedRegions (Connector *connector, int *merged, int *num_regions)
 

Detailed Description

file for connections between regions (doors)

Macro Definition Documentation

◆ CONNECTOR_ALLOC_SIZE

#define CONNECTOR_ALLOC_SIZE   50

the default size to expand the connector array by each time. can be overrided by the user by defining it themselves

Typedef Documentation

◆ Connector

typedef struct Connectors Connector

A struct to represent a connection between 2 regions

Function Documentation

◆ getConnectors()

Connector* getConnectors ( Grid grid,
regions_t  regions,
size_t *  num_connectors 
)

given a grid (for size information) and a list of the various regions, get the potential connectors between them

Parameters
[in]grida pointer to a grid to get width and height info
[in]regionsthe 2d regions array to determine which region a tile is in
[out]num_connectorsthe number of connectors found - make sure to use this to avoid undefined behavior
Returns
a pointer the the malloced array of connectors (remember to free it!)

◆ mapMergedRegions()

int* mapMergedRegions ( Connector connector,
int *  merged,
int *  num_regions 
)

take the region for a connector and use a mapping array to process potential merging it's regions also deduplicates array, so each region will only be included once

Parameters
[in]connectora pointer to the connector to map the regions of
[in]mergedan array that will be used to map the various regions
[out]num_regionsthe number of regions in the ouput array
Returns
a pointer to the array of mapped regions
Note
similar to the connector, the returned array actually has an allocated length of NUM_DIRECTIONS, and is static. this was done to avoid extra mallocs, but does mean that if you call this twice and assign to two pointers, they will actually both point to the result of the second call. Just be wary of that.