ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.153 by root, Tue Dec 23 06:58:23 2008 UTC vs.
Revision 1.154 by root, Wed Dec 24 01:37:24 2008 UTC

1023 * postive values make it darker, negative make it brighter 1023 * postive values make it darker, negative make it brighter
1024 */ 1024 */
1025int 1025int
1026maptile::change_map_light (int change) 1026maptile::change_map_light (int change)
1027{ 1027{
1028 int new_level = darkness + change;
1029
1030 /* Nothing to do */ 1028 /* Nothing to do */
1031 if (!change || (new_level <= 0 && darkness == 0) || (new_level >= MAX_DARKNESS && darkness >= MAX_DARKNESS)) 1029 if (!change)
1032 return 0; 1030 return 0;
1033 1031
1034 /* inform all players on the map */ 1032 /* inform all players on the map */
1035 if (change > 0) 1033 if (change > 0)
1036 new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes darker."); 1034 new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes darker.");
1037 else 1035 else
1038 new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes brighter."); 1036 new_info_map (NDI_BLACK | NDI_UNIQUE, this, "It becomes brighter.");
1039 1037
1040 /* Do extra checking. since darkness is a unsigned value, 1038 darkness = clamp (darkness + change, -MAX_DARKNESS, MAX_DARKNESS);
1041 * we need to be extra careful about negative values.
1042 * In general, the checks below are only needed if change
1043 * is not +/-1
1044 */
1045 if (new_level < 0)
1046 darkness = 0;
1047 else if (new_level >= MAX_DARKNESS)
1048 darkness = MAX_DARKNESS;
1049 else
1050 darkness = new_level;
1051 1039
1052 /* All clients need to get re-updated for the change */ 1040 /* All clients need to get re-updated for the change */
1053 update_all_map_los (this); 1041 update_all_map_los (this);
1054 1042
1055 return 1; 1043 return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines