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.170 by root, Sun Nov 8 15:11:22 2009 UTC vs.
Revision 1.171 by root, Sun Nov 8 16:13:45 2009 UTC

1028 */ 1028 */
1029void 1029void
1030mapspace::update_ () 1030mapspace::update_ ()
1031{ 1031{
1032 object *last = 0; 1032 object *last = 0;
1033 uint8 flags = P_UPTODATE, anywhere = 0; 1033 uint8 flags = P_UPTODATE;
1034 sint8 light = 0; 1034 sint8 light = 0;
1035 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; 1036 uint64_t volume = 0;
1037 uint32_t nrof = 0; 1037 uint32_t nrof = 0;
1038 object *anywhere = 0;
1038 1039
1039 //object *middle = 0; 1040 //object *middle = 0;
1040 //object *top = 0; 1041 //object *top = 0;
1041 //object *floor = 0; 1042 //object *floor = 0;
1042 // this seems to generate better code than using locals, above 1043 // this seems to generate better code than using locals, above
1043 object *&top = faces_obj[0] = 0; 1044 object *&top = faces_obj[0] = 0;
1044 object *&middle = faces_obj[1] = 0; 1045 object *&middle = faces_obj[1] = 0;
1045 object *&floor = faces_obj[2] = 0; 1046 object *&floor = faces_obj[2] = 0;
1046 1047
1048 object::flags_t allflags; // all flags of all objects or'ed together
1049
1047 for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above) 1050 for (object *tmp = bot; tmp; last = tmp, tmp = tmp->above)
1048 { 1051 {
1049 ++nrof;
1050
1051 // Lights are additive, up to MAX_LIGHT_RADIUS, see los.C) 1052 // Lights are additive, up to MAX_LIGHT_RADIUS, see los.C)
1052 light += tmp->glow_radius; 1053 light += tmp->glow_radius;
1053 1054
1054 /* This call is needed in order to update objects the player 1055 /* This call is needed in order to update objects the player
1055 * is standing in that have animations (ie, grass, fire, etc). 1056 * is standing in that have animations (ie, grass, fire, etc).
1057 * 3 times each time the player moves, because many of the 1058 * 3 times each time the player moves, because many of the
1058 * functions the move_player calls eventualy call this. 1059 * functions the move_player calls eventualy call this.
1059 * 1060 *
1060 * Always put the player down for drawing. 1061 * Always put the player down for drawing.
1061 */ 1062 */
1062 if (!tmp->invisible) 1063 if (expect_true (!tmp->invisible))
1063 { 1064 {
1064 if (tmp->type == PLAYER || tmp->flag [FLAG_MONSTER]) 1065 if (tmp->type == PLAYER || tmp->flag [FLAG_MONSTER])
1065 top = tmp; 1066 top = tmp;
1066 else 1067 else
1067 { 1068 {
1068 if (tmp->flag [FLAG_IS_FLOOR]) 1069 if (expect_false (tmp->flag [FLAG_IS_FLOOR]))
1069 { 1070 {
1070 /* If we got a floor, that means middle and top were below it, 1071 /* If we got a floor, that means middle and top were below it,
1071 * so should not be visible, so we clear them. 1072 * so should not be visible, so we clear them.
1072 */ 1073 */
1073 middle = 0; 1074 middle = 0;
1074 top = 0; 1075 top = 0;
1075 floor = tmp; 1076 floor = tmp;
1077 volume = 0;
1078 nrof = 0;
1076 } 1079 }
1077 else 1080 else
1078 { 1081 {
1079 if (!tmp->flag [FLAG_NO_PICK]) 1082 if (expect_true (!tmp->flag [FLAG_NO_PICK]))
1083 {
1084 ++nrof;
1080 volume += tmp->volume (); 1085 volume += tmp->volume ();
1086 }
1081 1087
1082 /* Flag anywhere have high priority */ 1088 /* Flag anywhere have high priority */
1083 if (tmp->flag [FLAG_SEE_ANYWHERE]) 1089 if (expect_false (tmp->flag [FLAG_SEE_ANYWHERE]))
1084 {
1085 middle = tmp;
1086 anywhere = 1; 1090 anywhere = tmp;
1087 }
1088 /* Find the highest visible face around. If equal 1091 /* Find the highest visible face around. If equal
1089 * visibilities, we still want the one nearer to the 1092 * visibilities, we still want the one nearer to the
1090 * top 1093 * top
1091 */ 1094 */
1092 else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility && !anywhere)) 1095 else if (!middle || (::faces [tmp->face].visibility > ::faces [middle->face].visibility))
1093 middle = tmp; 1096 middle = tmp;
1094 } 1097 }
1095 } 1098 }
1096 } 1099 }
1097 1100
1099 move_block |= tmp->move_block; 1102 move_block |= tmp->move_block;
1100 move_on |= tmp->move_on; 1103 move_on |= tmp->move_on;
1101 move_off |= tmp->move_off; 1104 move_off |= tmp->move_off;
1102 move_allow |= tmp->move_allow; 1105 move_allow |= tmp->move_allow;
1103 1106
1104 if (QUERY_FLAG (tmp, FLAG_BLOCKSVIEW)) flags |= P_BLOCKSVIEW; 1107 allflags |= tmp->flag;
1105 if (QUERY_FLAG (tmp, FLAG_NO_MAGIC)) flags |= P_NO_MAGIC; 1108
1106 if (tmp->type == PLAYER) flags |= P_PLAYER; 1109 if (tmp->type == PLAYER) flags |= P_PLAYER;
1107 if (tmp->type == SAFE_GROUND) flags |= P_SAFE; 1110 if (tmp->type == SAFE_GROUND) flags |= P_SAFE;
1108 if (QUERY_FLAG (tmp, FLAG_ALIVE)) flags |= P_IS_ALIVE;
1109 if (QUERY_FLAG (tmp, FLAG_DAMNED)) flags |= P_NO_CLERIC;
1110 } 1111 }
1112
1113 // FLAG_SEE_ANYWHERE takes precedence
1114 if (anywhere)
1115 middle = anywhere;
1116
1117 // ORing all flags together and checking them here is much faster
1118 if (allflags [FLAG_BLOCKSVIEW]) flags |= P_BLOCKSVIEW;
1119 if (allflags [FLAG_NO_MAGIC] ) flags |= P_NO_MAGIC;
1120 if (allflags [FLAG_ALIVE] ) flags |= P_IS_ALIVE;
1121 if (allflags [FLAG_DAMNED] ) flags |= P_NO_CLERIC;
1111 1122
1112 this->light = min (light, MAX_LIGHT_RADIUS); 1123 this->light = min (light, MAX_LIGHT_RADIUS);
1113 this->flags_ = flags; 1124 this->flags_ = flags;
1114 this->move_block = move_block & ~move_allow; 1125 this->move_block = move_block & ~move_allow;
1115 this->move_on = move_on; 1126 this->move_on = move_on;
1116 this->move_off = move_off; 1127 this->move_off = move_off;
1117 this->move_slow = move_slow; 1128 this->move_slow = move_slow;
1118 this->volume_ = volume / 1024; 1129 this->volume_ = volume / 1024;
1119 this->nrof_ = min (65535, nrof); 1130 this->nrof_ = upos_min (nrof, 65535); // assume nrof <= 2**31
1120 1131
1121 /* At this point, we have a floor face (if there is a floor), 1132 /* At this point, we have a floor face (if there is a floor),
1122 * and the floor is set - we are not going to touch it at 1133 * and the floor is set - we are not going to touch it at
1123 * this point. 1134 * this point.
1124 * middle contains the highest visibility face. 1135 * middle contains the highest visibility face.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines