Crossfire Server, Branch 1.12  R12190
Functions
build_map.c File Reference

This file handles all ingame construction functions: builders, destroyers, building materials. More...

#include <global.h>
#include <living.h>
#include <spells.h>
#include <skills.h>
#include <tod.h>
#include <sproto.h>
Include dependency graph for build_map.c:

Go to the source code of this file.

Functions

static int adjust_sign_msg (object *pl, short x, short y, object *tmp)
 Make the built object inherit the msg of books that are used with it.
static int apply_builder_floor (object *pl, object *new_floor, short x, short y)
 Floor building function.
static int apply_builder_item (object *pl, object *new_item, short x, short y)
 Generic item builder.
void apply_builder_remove (object *pl, int dir)
 Item remover.
static int apply_builder_wall (object *pl, object *new_wall, short x, short y)
 Wall building function.
static int apply_builder_window (object *pl, object *new_wall_win, short x, short y)
 Window building function.
void apply_map_builder (object *pl, int dir)
 Global building function.
static int can_build_over (struct mapdef *map, object *new_item, short x, short y)
 Check if objects on a square interfere with building.
static int find_or_create_connection_for_map (object *pl, short x, short y, object *rune)
 Helper function for door/button/connected item building.
static int find_unused_connected_value (struct mapdef *map)
 Returns an unused value for 'connected'.
static void fix_walls (struct mapdef *map, int x, int y)
 Fixes walls around specified spot.
static object * get_connection_rune (object *pl, short x, short y)
 Returns the marking rune on the square, for purposes of building connections.
static object * get_msg_book (object *pl, short x, short y)
 Returns the book/scroll on the current square, for purposes of building.
static object * get_wall (struct mapdef *map, int x, int y)
 Returns first item of type WALL.
static void remove_marking_runes (struct mapdef *map, short x, short y)
 Erases all marking runes at specified location (before building a wall)

Detailed Description

This file handles all ingame construction functions: builders, destroyers, building materials.

Basically, those enable a player to alter in real-time a map.

Todo:
document building, forces used to store connection values, ...

Definition in file build_map.c.


Function Documentation

static int adjust_sign_msg ( object *  pl,
short  x,
short  y,
object *  tmp 
) [static]

Make the built object inherit the msg of books that are used with it.

For objects already invisible (i.e. magic mouths & ears), also make it it inherit the face and the name with "talking " prepended.

The book is removed during the operation.

Parameters:
plplayer building.
x
ybuilding coordinates.
tmpobject that is being built.
Returns:
-1 if no text found, 0 if ok to build.

Definition at line 202 of file build_map.c.

References add_refcount(), add_string(), draw_ext_info(), free_object(), free_string(), get_msg_book(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, NDI_UNIQUE, remove_ob(), and snprintf().

Referenced by apply_builder_item().

Here is the call graph for this function:

Here is the caller graph for this function:

static int apply_builder_floor ( object *  pl,
object *  new_floor,
short  x,
short  y 
) [static]

Floor building function.

Floors can be built:

  • on existing floors, with or without a detector/button
  • on an existing wall, with or without a floor under it
Note:
this function will inconditionally change squares around (x, y) so don't call it with x == 0 for instance!
Parameters:
plplayer building.
new_floornew floor object
x
ywhere to build.
Returns:
1 if the floor was built

Definition at line 519 of file build_map.c.

References arch_to_object(), draw_ext_info(), fix_walls(), FLAG_IS_BUILDABLE, FLAG_IS_FLOOR, FLAG_UNIQUE, FLOOR, free_object(), freearr_x, freearr_y, GET_MAP_OB, insert_ob_in_map_at(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, NDI_UNIQUE, OUT_OF_REAL_MAP, QUERY_FLAG, remove_ob(), SET_FLAG, snprintf(), and WALL.

Referenced by apply_map_builder().

Here is the call graph for this function:

Here is the caller graph for this function:

static int apply_builder_item ( object *  pl,
object *  new_item,
short  x,
short  y 
) [static]

Generic item builder.

Item must be put on a square with a floor, you can have something under.

Type of inserted item is tested for specific cases (doors & such).

Item is inserted above the floor.

Note that it is the responsability of the caller to check whether the space is buildable or not.

Parameters:
plplayer building.
new_itemnew item being built
x
ywhere to build.
Returns:
1 if the item was built

Definition at line 814 of file build_map.c.

References add_button_link(), adjust_sign_msg(), BUTTON, CF_HANDLE, DETECTOR, DOOR, draw_ext_info(), draw_ext_info_format(), find_or_create_connection_for_map(), FLAG_IS_FLOOR, FLAG_NO_PICK, FLOOR, free_object(), GATE, get_connection_rune(), GET_MAP_OB, insert_ob_in_map_at(), MAGIC_EAR, MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, NDI_UNIQUE, PEDESTAL, QUERY_FLAG, query_name(), remove_ob(), SET_FLAG, SIGN, and TIMED_GATE.

Referenced by apply_map_builder().

Here is the call graph for this function:

Here is the caller graph for this function:

void apply_builder_remove ( object *  pl,
int  dir 
)

Item remover.

Removes first buildable item, either under or above the floor

Parameters:
plplayer removing an item.
dirdirection the player is trying to remove.

Definition at line 907 of file build_map.c.

References BUTTON, CF_HANDLE, DETECTOR, DOOR, draw_ext_info(), draw_ext_info_format(), FLAG_IS_FLOOR, FLAG_IS_LINKED, FLOOR, free_object(), freearr_x, freearr_y, GATE, GET_MAP_OB, llevError, LOG(), MAGIC_EAR, MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, NDI_UNIQUE, PEDESTAL, QUERY_FLAG, query_name(), remove_button_link(), remove_ob(), SIGN, TIMED_GATE, and WALL.

Referenced by apply_map_builder().

Here is the call graph for this function:

Here is the caller graph for this function:

static int apply_builder_wall ( object *  pl,
object *  new_wall,
short  x,
short  y 
) [static]

Wall building function.

Walls can be built:

  • on a floor without anything else
  • on an existing wall, with or without a floor
Parameters:
plplayer building.
new_wallnew wall object
x
ywhere to build.
Returns:
1 if the wall was built

Definition at line 644 of file build_map.c.

References draw_ext_info(), fix_walls(), free_object(), get_wall(), insert_ob_in_map_at(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, NDI_UNIQUE, OUT_OF_REAL_MAP, remove_marking_runes(), remove_ob(), snprintf(), and WALL.

Referenced by apply_map_builder().

Here is the call graph for this function:

Here is the caller graph for this function:

static int apply_builder_window ( object *  pl,
object *  new_wall_win,
short  x,
short  y 
) [static]

Window building function.

Windows can be built only on top of existing vertical or horizontal walls (*wall_2_1_1 or *wall_2_1_2).

Parameters:
plplayer building.
new_wall_winnew windowed wall object
x
ywhere to build.
Returns:
1 if the window was built

Definition at line 724 of file build_map.c.

References arch_to_object(), draw_ext_info(), find_archetype(), free_object(), get_wall(), insert_ob_in_map_at(), MAX_BUF, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, NDI_UNIQUE, remove_ob(), and WALL.

Referenced by apply_map_builder().

Here is the call graph for this function:

Here is the caller graph for this function:

void apply_map_builder ( object *  pl,
int  dir 
)

Global building function.

This is the general map building function. Called when the player 'fires' a builder or remover object.

Parameters:
plplayer building or removing.
dirbuilding direction.

Definition at line 978 of file build_map.c.

References apply_builder_floor(), apply_builder_item(), apply_builder_remove(), apply_builder_wall(), apply_builder_window(), can_build_over(), decrease_ob, draw_ext_info(), find_archetype(), find_marked_object(), FLAG_IS_BUILDABLE, freearr_x, freearr_y, GET_MAP_OB, llevError, LOG(), MAP_HEIGHT, MAP_WIDTH, MATERIAL, MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, NDI_UNIQUE, object_create_arch(), PLAYER, QUERY_FLAG, range_builder, SET_FLAG, SIGN, ST_BD_BUILD, ST_BD_REMOVE, ST_MAT_FLOOR, ST_MAT_ITEM, ST_MAT_WALL, and ST_MAT_WINDOW.

Referenced by fire().

Here is the call graph for this function:

Here is the caller graph for this function:

static int can_build_over ( struct mapdef map,
object *  new_item,
short  x,
short  y 
) [static]

Check if objects on a square interfere with building.

Parameters:
mapmap we're building on.
new_itemitem the player is trying to build.
x
ycoordinates where to build.
Returns:
0 if tmp can't be built on the spot, 1 if it can be built.

Definition at line 57 of file build_map.c.

References BOOK, BUTTON, CF_HANDLE, DETECTOR, DOOR, FLAG_IS_BUILDABLE, GATE, GET_MAP_OB, MAGIC_EAR, PEDESTAL, QUERY_FLAG, and SIGN.

Referenced by apply_map_builder().

Here is the caller graph for this function:

static int find_or_create_connection_for_map ( object *  pl,
short  x,
short  y,
object *  rune 
) [static]

Helper function for door/button/connected item building.

Will search the specified spot for a marking rune. If not found, returns -1 Else, searches a force in op's inventory matching the map's name and the rune's text. If found, returns the connection value associated else searches a new connection value, and adds the force to the player.

Parameters:
plplayer building.
x
ycoordinates where to build.
runerune used to indicate the connection value. If NULL, building is searched for one.
Returns:
-1 for failure, else connection value.

Definition at line 290 of file build_map.c.

References add_string(), create_archetype(), draw_ext_info(), find_unused_connected_value(), FORCE, FORCE_NAME, get_connection_rune(), insert_ob_in_ob(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_BUILD, NDI_UNIQUE, and update_ob_speed().

Referenced by apply_builder_item().

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_unused_connected_value ( struct mapdef map) [static]

Returns an unused value for 'connected'.

Tries 1000 random values, then returns -1.

Parameters:
mapmap for which to find a value
Returns:
'connected' value with no item, or -1 if failure.

Definition at line 252 of file build_map.c.

References mapdef::buttons.

Referenced by find_or_create_connection_for_map().

Here is the caller graph for this function:

static void fix_walls ( struct mapdef map,
int  x,
int  y 
) [static]

Fixes walls around specified spot.

Basically it ensures the correct wall is put where needed.

Note:
x & y must be valid map coordinates.
Parameters:
map
x
yposition to fix.
Todo:
investigate possible merge with retrofit_joined_wall() used for random maps

Definition at line 348 of file build_map.c.

References arch_to_object(), find_archetype(), free_object(), get_wall(), insert_ob_in_map_at(), MAP_HEIGHT, MAP_WIDTH, MAX_BUF, remove_ob(), and WALL.

Referenced by apply_builder_floor(), and apply_builder_wall().

Here is the call graph for this function:

Here is the caller graph for this function:

static object* get_connection_rune ( object *  pl,
short  x,
short  y 
) [static]

Returns the marking rune on the square, for purposes of building connections.

Parameters:
plplayer trying to build.
x
ycoordinates to search.
Returns:
marking rune, NULL if none found.

Definition at line 111 of file build_map.c.

References GET_MAP_OB, and SIGN.

Referenced by apply_builder_item(), and find_or_create_connection_for_map().

Here is the caller graph for this function:

static object* get_msg_book ( object *  pl,
short  x,
short  y 
) [static]

Returns the book/scroll on the current square, for purposes of building.

Parameters:
plplayer trying to build.
x
ycoordinates to search.
Returns:
book, NULL if none found.

Definition at line 131 of file build_map.c.

References BOOK, and GET_MAP_OB.

Referenced by adjust_sign_msg().

Here is the caller graph for this function:

static object* get_wall ( struct mapdef map,
int  x,
int  y 
) [static]

Returns first item of type WALL.

Parameters:
map
x
ywhere to search.
Returns:
wall, or NULL if none found.
Todo:
isn't there a similar function somewhere? put this in a common library? investigate possible merge with retrofit_joined_wall() used for random maps

Definition at line 152 of file build_map.c.

References GET_MAP_OB, and WALL.

Referenced by apply_builder_wall(), apply_builder_window(), and fix_walls().

Here is the caller graph for this function:

static void remove_marking_runes ( struct mapdef map,
short  x,
short  y 
) [static]

Erases all marking runes at specified location (before building a wall)

Parameters:
map
x
ycoordinates to erase runes at.

Definition at line 170 of file build_map.c.

References free_object(), GET_MAP_OB, remove_ob(), and SIGN.

Referenced by apply_builder_wall().

Here is the call graph for this function:

Here is the caller graph for this function: