version 1.5 | | version 1.6 |
---|
| | |
/* | | /* |
* static char *rcsid_build_map = | | * static char *rcsid_build_map = |
* "$Id: build_map.c,v 1.5 2005/08/16 05:23:13 qal21 Exp $"; | | * "$Id: build_map.c,v 1.6 2005/08/17 18:38:34 qal21 Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
#include <tod.h> | | #include <tod.h> |
#include <sproto.h> | | #include <sproto.h> |
| | |
static object* get_connection_rune( object* pl, short x, short y ); | | |
static object* get_msg_book( object* pl, short x, short y ); | | |
static int adjust_sign_msg( object* pl, short x, short y, object* tmp ); | | |
| | |
/** | | /** |
* Check if objects on a square interfere with building | | * Check if objects on a square interfere with building |
*/ | | */ |
| | |
if ( ob->type != BOOK ) { | | if ( ob->type != BOOK ) { |
return 0; } | | return 0; } |
break; | | break; |
| | case BUTTON: |
| | case DETECTOR: |
| | case PEDESTAL: |
| | case CF_HANDLE: |
| | /* Allow buttons and levers to be built under gates */ |
| | if ( ob->type != GATE && ob->type != DOOR ) { |
| | return 0; } |
| | break; |
default: | | default: |
return 0; | | return 0; |
} | | } |
| | |
* If found, returns the connection value associated | | * If found, returns the connection value associated |
* else searches a new connection value, and adds the force to the player. | | * else searches a new connection value, and adds the force to the player. |
*/ | | */ |
int find_or_create_connection_for_map( object* pl, short x, short y ) | | int find_or_create_connection_for_map( object* pl, short x, short y, object* rune ) |
{ | | { |
object* rune; | | |
object* force; | | object* force; |
int connected; | | int connected; |
| | |
| | if ( !rune ) |
rune = get_connection_rune( pl, x, y ); | | rune = get_connection_rune( pl, x, y ); |
| | |
if ( !rune ) | | if ( !rune ) |
| | |
/** | | /** |
* Returns the marking rune on the square, for purposes of building connections | | * Returns the marking rune on the square, for purposes of building connections |
*/ | | */ |
static object* get_connection_rune( object* pl, short x, short y ) | | object* get_connection_rune( object* pl, short x, short y ) |
{ | | { |
object* rune; | | object* rune; |
| | |
| | |
/** | | /** |
* Returns the book/scroll on the current square, for purposes of building | | * Returns the book/scroll on the current square, for purposes of building |
*/ | | */ |
static object* get_msg_book( object* pl, short x, short y ) | | object* get_msg_book( object* pl, short x, short y ) |
{ | | { |
object* book; | | object* book; |
| | |
| | |
struct archt* arch; | | struct archt* arch; |
int insert_flag; | | int insert_flag; |
object* floor; | | object* floor; |
| | object* con_rune; |
int connected; | | int connected; |
| | |
/* Find floor */ | | /* Find floor */ |
| | |
case MAGIC_EAR: | | case MAGIC_EAR: |
case SIGN: | | case SIGN: |
/* Signs don't need a connection, but but magic mouths do. */ | | /* Signs don't need a connection, but but magic mouths do. */ |
if (get_connection_rune( pl, x, y ) && (tmp->type != SIGN || | | if (tmp->type == SIGN && strcmp( tmp->arch->name, "magic_mouth" )) |
!strcmp( tmp->arch->name, "magic_mouth" ))) | | break; |
{ | | con_rune = get_connection_rune( pl, x, y ); |
connected = find_or_create_connection_for_map( pl, x, y ); | | connected = find_or_create_connection_for_map( pl, x, y, con_rune ); |
if ( connected == -1 ) | | if ( connected == -1 ) |
{ | | { |
/* Player already informed of failure by the previous function */ | | /* Player already informed of failure by the previous function */ |
| | |
return; | | return; |
} | | } |
/* Remove marking rune */ | | /* Remove marking rune */ |
remove_marking_runes( pl->map, x, y ); | | remove_ob( con_rune ); |
} | | free_object( con_rune ); |
} | | } |
| | |
/* For magic mouths/ears, and signs, take the msg from a book of scroll */ | | /* For magic mouths/ears, and signs, take the msg from a book of scroll */ |
| | |
* For objects already invisible (i.e. magic mouths & ears), also make it | | * For objects already invisible (i.e. magic mouths & ears), also make it |
* it inherit the face and the name with "talking " prepended. | | * it inherit the face and the name with "talking " prepended. |
*/ | | */ |
static int adjust_sign_msg( object* pl, short x, short y, object* tmp ) | | int adjust_sign_msg( object* pl, short x, short y, object* tmp ) |
{ | | { |
object* book; | | object* book; |
char buf[MAX_BUF]; | | char buf[MAX_BUF]; |
| | char buf2[MAX_BUF]; |
int namelen; | | int namelen; |
| | |
book = get_msg_book( pl, x, y ); | | book = get_msg_book( pl, x, y ); |
| | |
free_string( tmp->name ); | | free_string( tmp->name ); |
tmp->name = add_string( buf ); | | tmp->name = add_string( buf ); |
| | |
| | if(book->name_pl != NULL) |
| | { |
| | snprintf(buf2, sizeof(buf2), "talking %s", book->name_pl); |
| | if ( tmp->name_pl ) |
| | free_string( tmp->name_pl ); |
| | tmp->name_pl = add_string( buf2 ); |
| | } |
| | |
tmp->face = book->face; | | tmp->face = book->face; |
tmp->invisible = 0; | | tmp->invisible = 0; |
} | | } |