… | |
… | |
208 | else if (socket.current_x != ob->x || socket.current_y != ob->y) |
208 | else if (socket.current_x != ob->x || socket.current_y != ob->y) |
209 | { |
209 | { |
210 | int dx = ob->x - socket.current_x; |
210 | int dx = ob->x - socket.current_x; |
211 | int dy = ob->y - socket.current_y; |
211 | int dy = ob->y - socket.current_y; |
212 | |
212 | |
213 | if (socket.buggy_mapscroll && (abs (dx) > 8 || abs (dy) > 8)) |
|
|
214 | clear_map (pl); // current (<= 1.9.1) clients have unchecked buffer overflows |
|
|
215 | else |
|
|
216 | { |
|
|
217 | socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y); |
213 | socket_map_scroll (&socket, ob->x - socket.current_x, ob->y - socket.current_y); |
218 | socket.floorbox_reset (); |
214 | socket.floorbox_reset (); |
219 | } |
|
|
220 | } |
215 | } |
221 | |
216 | |
222 | socket.current_x = ob->x; |
217 | socket.current_x = ob->x; |
223 | socket.current_y = ob->y; |
218 | socket.current_y = ob->y; |
224 | } |
219 | } |
… | |
… | |
935 | |
930 | |
936 | // prefetch (and touch) all maps within a specific distancd |
931 | // prefetch (and touch) all maps within a specific distancd |
937 | static void |
932 | static void |
938 | prefetch_surrounding_maps (maptile *map, int distance) |
933 | prefetch_surrounding_maps (maptile *map, int distance) |
939 | { |
934 | { |
940 | map->last_access = runtime; |
935 | map->touch (); |
941 | |
936 | |
942 | if (--distance) |
937 | if (--distance) |
943 | for (int dir = 4; --dir; ) |
938 | for (int dir = 4; --dir; ) |
944 | if (const shstr &path = map->tile_path [dir]) |
939 | if (const shstr &path = map->tile_path [dir]) |
945 | if (maptile *&neigh = map->tile_map [dir]) |
940 | if (maptile *&neigh = map->tile_map [dir]) |
… | |
… | |
1082 | |
1077 | |
1083 | unsigned char dummy; |
1078 | unsigned char dummy; |
1084 | unsigned char *last_ext = &dummy; |
1079 | unsigned char *last_ext = &dummy; |
1085 | |
1080 | |
1086 | /* Darkness changed */ |
1081 | /* Darkness changed */ |
1087 | if (lastcell.count != d && socket.darkness) |
1082 | if (lastcell.count != d) |
1088 | { |
1083 | { |
1089 | mask |= 0x8; |
1084 | mask |= 0x8; |
1090 | |
1085 | |
1091 | if (socket.extmap) |
1086 | *last_ext |= 0x80; |
|
|
1087 | last_ext = &sl[sl.length ()]; |
|
|
1088 | sl << uint8 (d); |
|
|
1089 | } |
|
|
1090 | |
|
|
1091 | lastcell.count = d; |
|
|
1092 | |
|
|
1093 | mapspace &ms = m->at (nx, ny); |
|
|
1094 | ms.update (); |
|
|
1095 | |
|
|
1096 | // extmap handling |
|
|
1097 | uint8 stat_hp = 0; |
|
|
1098 | uint8 stat_width = 0; |
|
|
1099 | uint8 flags = 0; |
|
|
1100 | tag_t player = 0; |
|
|
1101 | |
|
|
1102 | // send hp information, if applicable |
|
|
1103 | if (object *op = ms.faces_obj [0]) |
|
|
1104 | if (op->is_head () && !op->invisible) |
|
|
1105 | { |
|
|
1106 | if (op->stats.maxhp > op->stats.hp |
|
|
1107 | && op->stats.maxhp > 0 |
|
|
1108 | && (op->type == PLAYER |
|
|
1109 | || op->type == DOOR // does not work, have maxhp 0 |
|
|
1110 | || QUERY_FLAG (op, FLAG_MONSTER) |
|
|
1111 | || QUERY_FLAG (op, FLAG_ALIVE) |
|
|
1112 | || QUERY_FLAG (op, FLAG_GENERATOR))) |
|
|
1113 | { |
|
|
1114 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
|
|
1115 | stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge |
|
|
1116 | } |
|
|
1117 | |
|
|
1118 | if (expect_false (op->has_dialogue ())) |
|
|
1119 | flags |= 1; |
|
|
1120 | |
|
|
1121 | if (expect_false (op->type == PLAYER)) |
|
|
1122 | player = op == ob ? pl->ob->count |
|
|
1123 | : op == pl->ob ? ob->count |
|
|
1124 | : op->count; |
|
|
1125 | } |
|
|
1126 | |
|
|
1127 | if (expect_false (lastcell.stat_hp != stat_hp)) |
|
|
1128 | { |
|
|
1129 | lastcell.stat_hp = stat_hp; |
|
|
1130 | |
|
|
1131 | mask |= 0x8; |
|
|
1132 | *last_ext |= 0x80; |
|
|
1133 | last_ext = &sl[sl.length ()]; |
|
|
1134 | |
|
|
1135 | sl << uint8 (5) << uint8 (stat_hp); |
|
|
1136 | |
|
|
1137 | if (stat_width > 1) |
1092 | { |
1138 | { |
1093 | *last_ext |= 0x80; |
1139 | *last_ext |= 0x80; |
1094 | last_ext = &sl[sl.length ()]; |
1140 | last_ext = &sl[sl.length ()]; |
1095 | sl << uint8 (d); |
|
|
1096 | } |
|
|
1097 | else |
|
|
1098 | sl << uint8 (255 - 64 * d); |
|
|
1099 | } |
|
|
1100 | |
1141 | |
1101 | lastcell.count = d; |
|
|
1102 | |
|
|
1103 | mapspace &ms = m->at (nx, ny); |
|
|
1104 | ms.update (); |
|
|
1105 | |
|
|
1106 | if (expect_true (socket.extmap)) |
|
|
1107 | { |
|
|
1108 | uint8 stat_hp = 0; |
|
|
1109 | uint8 stat_width = 0; |
|
|
1110 | uint8 flags = 0; |
|
|
1111 | tag_t player = 0; |
|
|
1112 | |
|
|
1113 | // send hp information, if applicable |
|
|
1114 | if (object *op = ms.faces_obj [0]) |
|
|
1115 | if (op->is_head () && !op->invisible) |
|
|
1116 | { |
|
|
1117 | if (op->stats.maxhp > op->stats.hp |
|
|
1118 | && op->stats.maxhp > 0 |
|
|
1119 | && (op->type == PLAYER |
|
|
1120 | || op->type == DOOR // does not work, have maxhp 0 |
|
|
1121 | || QUERY_FLAG (op, FLAG_MONSTER) |
|
|
1122 | || QUERY_FLAG (op, FLAG_ALIVE) |
|
|
1123 | || QUERY_FLAG (op, FLAG_GENERATOR))) |
|
|
1124 | { |
|
|
1125 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
|
|
1126 | stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge |
|
|
1127 | } |
|
|
1128 | |
|
|
1129 | if (expect_false (op->has_dialogue ())) |
|
|
1130 | flags |= 1; |
|
|
1131 | |
|
|
1132 | if (expect_false (op->type == PLAYER)) |
|
|
1133 | player = op == ob ? pl->ob->count |
|
|
1134 | : op == pl->ob ? ob->count |
|
|
1135 | : op->count; |
|
|
1136 | } |
|
|
1137 | |
|
|
1138 | if (expect_false (lastcell.stat_hp != stat_hp)) |
|
|
1139 | { |
|
|
1140 | lastcell.stat_hp = stat_hp; |
|
|
1141 | |
|
|
1142 | mask |= 0x8; |
|
|
1143 | *last_ext |= 0x80; |
|
|
1144 | last_ext = &sl[sl.length ()]; |
|
|
1145 | |
|
|
1146 | sl << uint8 (5) << uint8 (stat_hp); |
|
|
1147 | |
|
|
1148 | if (stat_width > 1) |
|
|
1149 | { |
|
|
1150 | *last_ext |= 0x80; |
|
|
1151 | last_ext = &sl[sl.length ()]; |
|
|
1152 | |
|
|
1153 | sl << uint8 (6) << uint8 (stat_width); |
1142 | sl << uint8 (6) << uint8 (stat_width); |
1154 | } |
|
|
1155 | } |
|
|
1156 | |
|
|
1157 | if (expect_false (lastcell.player != player)) |
|
|
1158 | { |
|
|
1159 | lastcell.player = player; |
|
|
1160 | |
|
|
1161 | mask |= 0x8; |
|
|
1162 | *last_ext |= 0x80; |
|
|
1163 | last_ext = &sl[sl.length ()]; |
|
|
1164 | |
|
|
1165 | sl << uint8 (0x47) << uint8 (4) << (uint32)player; |
|
|
1166 | } |
|
|
1167 | |
|
|
1168 | if (expect_false (lastcell.flags != flags)) |
|
|
1169 | { |
|
|
1170 | lastcell.flags = flags; |
|
|
1171 | |
|
|
1172 | mask |= 0x8; |
|
|
1173 | *last_ext |= 0x80; |
|
|
1174 | last_ext = &sl[sl.length ()]; |
|
|
1175 | |
|
|
1176 | sl << uint8 (8) << uint8 (flags); |
|
|
1177 | } |
1143 | } |
1178 | } |
1144 | } |
|
|
1145 | |
|
|
1146 | if (expect_false (lastcell.player != player)) |
|
|
1147 | { |
|
|
1148 | lastcell.player = player; |
|
|
1149 | |
|
|
1150 | mask |= 0x8; |
|
|
1151 | *last_ext |= 0x80; |
|
|
1152 | last_ext = &sl[sl.length ()]; |
|
|
1153 | |
|
|
1154 | sl << uint8 (0x47) << uint8 (4) << (uint32)player; |
|
|
1155 | } |
|
|
1156 | |
|
|
1157 | if (expect_false (lastcell.flags != flags)) |
|
|
1158 | { |
|
|
1159 | lastcell.flags = flags; |
|
|
1160 | |
|
|
1161 | mask |= 0x8; |
|
|
1162 | *last_ext |= 0x80; |
|
|
1163 | last_ext = &sl[sl.length ()]; |
|
|
1164 | |
|
|
1165 | sl << uint8 (8) << uint8 (flags); |
|
|
1166 | } |
|
|
1167 | |
|
|
1168 | // faces |
1179 | |
1169 | |
1180 | /* Floor face */ |
1170 | /* Floor face */ |
1181 | if (update_space (sl, socket, ms, lastcell, 2)) |
1171 | if (update_space (sl, socket, ms, lastcell, 2)) |
1182 | mask |= 0x4; |
1172 | mask |= 0x4; |
1183 | |
1173 | |