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