Crossfire Server, Trunk
expand2x.c File Reference
#include <stdlib.h>
#include <expand2x.h>
+ Include dependency graph for expand2x.c:

Go to the source code of this file.

Functions

static int calc_pattern (char ch, char **layout, int i, int j, int xsize, int ysize)
 
char ** expand2x (char **layout, int xsize, int ysize)
 
static void expand_door (char **newlayout, int i, int j, char **layout, int xsize, int ysize)
 
static void expand_misc (char **newlayout, int i, int j, char **layout)
 
static void expand_wall (char **newlayout, int i, int j, char **layout, int xsize, int ysize)
 

Detailed Description

Expands a layout by 2x in each dimension.

H. S. Teoh

Definition in file expand2x.c.

Function Documentation

◆ calc_pattern()

static int calc_pattern ( char  ch,
char **  layout,
int  i,
int  j,
int  xsize,
int  ysize 
)
static

Returns a bitmap that represents which squares on the right and bottom edges of a square (i,j) match the given character.

Parameters
chcharacter to look for.
layoutmap.
i
jspot where to look.
xsize
ysizelayout size.
Returns
combination of the following values:
  • 1 means match on (i+1, j).
  • 2 means match on (i, j+1).
  • 4 means match on (i+1, j+1).

Definition at line 121 of file expand2x.c.

Referenced by expand_door(), and expand_wall().

+ Here is the caller graph for this function:

◆ expand2x()

char** expand2x ( char **  layout,
int  xsize,
int  ysize 
)

Expands the layout be a factor 2. Doors and walls are taken care of.

Parameters
layoutlayout to expand. Memory is free()d at the end, so pointer becomes invalid.
xsize
ysizelayout size.
Returns
new layout. Must be free()d by caller.

Definition at line 43 of file expand2x.c.

References expand_door(), expand_misc(), and expand_wall().

Referenced by layoutgen().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expand_door()

static void expand_door ( char **  newlayout,
int  i,
int  j,
char **  layout,
int  xsize,
int  ysize 
)
static

Expand a door. This function will try to sensibly connect doors so that they meet up with adjacent walls. Note that it will also presumptuously delete (ignore) doors that it doesn't know how to correctly expand.

Parameters
newlayoutexpanded layout.
i
jcoordinates of door to expand in non expanded layout.
layoutnon expanded layout.
xsize
ysizesize of non expanded layout.

Definition at line 199 of file expand2x.c.

References calc_pattern().

Referenced by expand2x().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expand_misc()

static void expand_misc ( char **  newlayout,
int  i,
int  j,
char **  layout 
)
static

Copy the old tile X into the new one at location (i*2, j*2) and fill up the rest of the 2x2 result with 0: X —> X 0 0 0

Parameters
newlayoutmap layout.
i
jspot to expand.
layoutmap layout.

Definition at line 94 of file expand2x.c.

Referenced by expand2x().

+ Here is the caller graph for this function:

◆ expand_wall()

static void expand_wall ( char **  newlayout,
int  i,
int  j,
char **  layout,
int  xsize,
int  ysize 
)
static

Expand a wall. This function will try to sensibly connect the resulting wall to adjacent wall squares, so that the result won't have disconnected walls.

Parameters
newlayoutmap layout.
i
jcoordinates of wall to expand in non expanded layout.
layoutcurrent (non expanded) layout.
xsize
ysizesizes of layout.

Definition at line 156 of file expand2x.c.

References calc_pattern().

Referenced by expand2x().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: