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.169 by root, Sat Nov 7 18:30:05 2009 UTC vs.
Revision 1.170 by root, Sun Nov 8 15:11:22 2009 UTC

449 */ 449 */
450 width = 16; 450 width = 16;
451 height = 16; 451 height = 16;
452 timeout = 300; 452 timeout = 300;
453 max_nrof = 1000; // 1000 items of anything 453 max_nrof = 1000; // 1000 items of anything
454 max_items = 25;
454 max_volume = 2000000; // 2m³ 455 max_volume = 2000000; // 2m³
455} 456}
456 457
457maptile::maptile (int w, int h) 458maptile::maptile (int w, int h)
458{ 459{
1030{ 1031{
1031 object *last = 0; 1032 object *last = 0;
1032 uint8 flags = P_UPTODATE, anywhere = 0; 1033 uint8 flags = P_UPTODATE, anywhere = 0;
1033 sint8 light = 0; 1034 sint8 light = 0;
1034 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; 1035 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0;
1036 uint64_t volume = 0;
1037 uint32_t nrof = 0;
1035 1038
1036 //object *middle = 0; 1039 //object *middle = 0;
1037 //object *top = 0; 1040 //object *top = 0;
1038 //object *floor = 0; 1041 //object *floor = 0;
1039 // this seems to generate better code than using locals, above 1042 // this seems to generate better code than using locals, above
1041 object *&middle = faces_obj[1] = 0; 1044 object *&middle = faces_obj[1] = 0;
1042 object *&floor = faces_obj[2] = 0; 1045 object *&floor = faces_obj[2] = 0;
1043 1046
1044 for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above) 1047 for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above)
1045 { 1048 {
1049 ++nrof;
1050
1046 // Lights are additive, up to MAX_LIGHT_RADIUS, see los.C) 1051 // Lights are additive, up to MAX_LIGHT_RADIUS, see los.C)
1047 light += tmp->glow_radius; 1052 light += tmp->glow_radius;
1048 1053
1049 /* This call is needed in order to update objects the player 1054 /* This call is needed in order to update objects the player
1050 * is standing in that have animations (ie, grass, fire, etc). 1055 * is standing in that have animations (ie, grass, fire, etc).
1054 * 1059 *
1055 * Always put the player down for drawing. 1060 * Always put the player down for drawing.
1056 */ 1061 */
1057 if (!tmp->invisible) 1062 if (!tmp->invisible)
1058 { 1063 {
1059 if ((tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER))) 1064 if (tmp->type == PLAYER || tmp->flag [FLAG_MONSTER])
1060 top = tmp; 1065 top = tmp;
1061 else if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1066 else
1062 { 1067 {
1068 if (tmp->flag [FLAG_IS_FLOOR])
1069 {
1063 /* If we got a floor, that means middle and top were below it, 1070 /* If we got a floor, that means middle and top were below it,
1064 * so should not be visible, so we clear them. 1071 * so should not be visible, so we clear them.
1065 */ 1072 */
1066 middle = 0; 1073 middle = 0;
1067 top = 0; 1074 top = 0;
1068 floor = tmp; 1075 floor = tmp;
1076 }
1077 else
1078 {
1079 if (!tmp->flag [FLAG_NO_PICK])
1080 volume += tmp->volume ();
1081
1082 /* Flag anywhere have high priority */
1083 if (tmp->flag [FLAG_SEE_ANYWHERE])
1084 {
1085 middle = tmp;
1086 anywhere = 1;
1087 }
1088 /* Find the highest visible face around. If equal
1089 * visibilities, we still want the one nearer to the
1090 * top
1091 */
1092 else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere))
1093 middle = tmp;
1094 }
1069 } 1095 }
1070 /* Flag anywhere have high priority */
1071 else if (QUERY_FLAG (tmp, FLAG_SEE_ANYWHERE))
1072 {
1073 middle = tmp;
1074 anywhere = 1;
1075 }
1076
1077 /* Find the highest visible face around. If equal
1078 * visibilities, we still want the one nearer to the
1079 * top
1080 */
1081 else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere))
1082 middle = tmp;
1083 }
1084
1085 if (tmp == tmp->above)
1086 {
1087 LOG (llevError, "Error in structure of map\n");
1088 exit (-1);
1089 } 1096 }
1090 1097
1091 move_slow |= tmp->move_slow; 1098 move_slow |= tmp->move_slow;
1092 move_block |= tmp->move_block; 1099 move_block |= tmp->move_block;
1093 move_on |= tmp->move_on; 1100 move_on |= tmp->move_on;
1106 this->flags_ = flags; 1113 this->flags_ = flags;
1107 this->move_block = move_block & ~move_allow; 1114 this->move_block = move_block & ~move_allow;
1108 this->move_on = move_on; 1115 this->move_on = move_on;
1109 this->move_off = move_off; 1116 this->move_off = move_off;
1110 this->move_slow = move_slow; 1117 this->move_slow = move_slow;
1118 this->volume_ = volume / 1024;
1119 this->nrof_ = min (65535, nrof);
1111 1120
1112 /* At this point, we have a floor face (if there is a floor), 1121 /* At this point, we have a floor face (if there is a floor),
1113 * and the floor is set - we are not going to touch it at 1122 * and the floor is set - we are not going to touch it at
1114 * this point. 1123 * this point.
1115 * middle contains the highest visibility face. 1124 * middle contains the highest visibility face.
1181 faces_obj [1] = middle; 1190 faces_obj [1] = middle;
1182 faces_obj [2] = floor; 1191 faces_obj [2] = floor;
1183#endif 1192#endif
1184} 1193}
1185 1194
1186uint64
1187mapspace::volume () const
1188{
1189 uint64 vol = 0;
1190
1191 for (object *op = top; op && !op->flag [FLAG_NO_PICK]; op = op->below)
1192 vol += op->volume ();
1193
1194 return vol;
1195}
1196
1197maptile * 1195maptile *
1198maptile::tile_available (int dir, bool load) 1196maptile::tile_available (int dir, bool load)
1199{ 1197{
1200 if (tile_path[dir]) 1198 if (tile_path[dir])
1201 { 1199 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines