version 1.37 | | version 1.38 |
---|
| | |
/* | | /* |
* static char *rcsid_map_c = | | * static char *rcsid_map_c = |
* "$Id: map.c,v 1.37 2002/06/07 07:00:41 mwedel Exp $"; | | * "$Id: map.c,v 1.38 2002/07/25 06:57:14 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
/* Map is good to go, so just return it */ | | /* Map is good to go, so just return it */ |
if (m && (m->in_memory == MAP_LOADING || m->in_memory == MAP_IN_MEMORY)) { | | if (m && (m->in_memory == MAP_LOADING || m->in_memory == MAP_IN_MEMORY)) { |
(*set_darkness_map_func)(m); | | |
return m; | | return m; |
} | | } |
| | |
| | |
decay_objects(m); /* start the decay */ | | decay_objects(m); /* start the decay */ |
/* In case other objects press some buttons down */ | | /* In case other objects press some buttons down */ |
update_buttons(m); | | update_buttons(m); |
| | if (m->outdoor) |
(*set_darkness_map_func)(m); | | (*set_darkness_map_func)(m); |
return m; | | return m; |
} | | } |
| | |
} | | } |
| | |
/* change_map_light() - used to change map light level (darkness) | | /* change_map_light() - used to change map light level (darkness) |
* up or down by *1*. This fctn is not designed to change by | | * up or down. Returns true if successful. It should now be |
* more than that! Returns true if successful. -b.t. | | * possible to change a value by more than 1. |
* Move this from los.c to map.c since this is more related | | * Move this from los.c to map.c since this is more related |
* to maps than los. | | * to maps than los. |
*/ | | */ |
| | |
int change_map_light(mapstruct *m, int change) { | | int change_map_light(mapstruct *m, int change) { |
int new_level = m->darkness + change; | | int new_level = m->darkness + change; |
| | |
if(new_level<=0) { | | /* Nothing to do */ |
m->darkness = 0; | | if(!change || (new_level <= 0 && m->darkness == 0) || |
| | (new_level >= MAX_DARKNESS && m->darkness >=MAX_DARKNESS)) { |
return 0; | | return 0; |
} | | } |
| | |
if(new_level>MAX_DARKNESS) return 0; | | |
| | |
if(change) { | | |
/* inform all players on the map */ | | /* inform all players on the map */ |
if (change>0) | | if (change>0) |
(info_map_func)(NDI_BLACK, m,"It becomes darker."); | | (info_map_func)(NDI_BLACK, m,"It becomes darker."); |
else | | else |
(info_map_func)(NDI_BLACK, m,"It becomes brighter."); | | (info_map_func)(NDI_BLACK, m,"It becomes brighter."); |
| | |
m->darkness=new_level; | | /* Do extra checking. since m->darkness is a unsigned value, |
| | * we need to be extra careful about negative values. |
| | * In general, the checks below are only needed if change |
| | * is not +/-1 |
| | */ |
| | if (new_level < 0) m->darkness = 0; |
| | else if (new_level >=MAX_DARKNESS) m->darkness = MAX_DARKNESS; |
| | else m->darkness=new_level; |
| | |
/* All clients need to get re-updated for the change */ | | /* All clients need to get re-updated for the change */ |
update_all_map_los(m); | | update_all_map_los(m); |
return 1; | | return 1; |
} | | } |
return 0; | | |
} | | |
| | |
| | |
/* | | /* |