… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel |
5 | * Copyright (©) 2001,2007 Mark Wedel |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /** |
25 | /** |
… | |
… | |
685 | * Get player's current range attack in obuf. |
686 | * Get player's current range attack in obuf. |
686 | */ |
687 | */ |
687 | static void |
688 | static void |
688 | rangetostring (player *pl, char *obuf) |
689 | rangetostring (player *pl, char *obuf) |
689 | { |
690 | { |
690 | dynbuf_text buf; |
691 | dynbuf_text &buf = msg_dynbuf; buf.clear (); |
691 | |
692 | |
692 | if (pl->ranged_ob) |
693 | if (pl->ranged_ob) |
693 | buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; |
694 | buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; |
694 | |
695 | |
695 | if (pl->combat_ob) |
696 | if (pl->combat_ob) |
… | |
… | |
1081 | /* Darkness changed */ |
1082 | /* Darkness changed */ |
1082 | if (lastcell.count != d) |
1083 | if (lastcell.count != d) |
1083 | { |
1084 | { |
1084 | mask |= 0x8; |
1085 | mask |= 0x8; |
1085 | |
1086 | |
1086 | if (socket.extmap) |
1087 | *last_ext |= 0x80; |
|
|
1088 | last_ext = &sl[sl.length ()]; |
|
|
1089 | sl << uint8 (d); |
|
|
1090 | } |
|
|
1091 | |
|
|
1092 | lastcell.count = d; |
|
|
1093 | |
|
|
1094 | mapspace &ms = m->at (nx, ny); |
|
|
1095 | ms.update (); |
|
|
1096 | |
|
|
1097 | // extmap handling |
|
|
1098 | uint8 stat_hp = 0; |
|
|
1099 | uint8 stat_width = 0; |
|
|
1100 | uint8 flags = 0; |
|
|
1101 | tag_t player = 0; |
|
|
1102 | |
|
|
1103 | // send hp information, if applicable |
|
|
1104 | if (object *op = ms.faces_obj [0]) |
|
|
1105 | if (op->is_head () && !op->invisible) |
|
|
1106 | { |
|
|
1107 | if (op->stats.maxhp > op->stats.hp |
|
|
1108 | && op->stats.maxhp > 0 |
|
|
1109 | && (op->type == PLAYER |
|
|
1110 | || op->type == DOOR // does not work, have maxhp 0 |
|
|
1111 | || QUERY_FLAG (op, FLAG_MONSTER) |
|
|
1112 | || QUERY_FLAG (op, FLAG_ALIVE) |
|
|
1113 | || QUERY_FLAG (op, FLAG_GENERATOR))) |
|
|
1114 | { |
|
|
1115 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
|
|
1116 | stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge |
|
|
1117 | } |
|
|
1118 | |
|
|
1119 | if (expect_false (op->has_dialogue ())) |
|
|
1120 | flags |= 1; |
|
|
1121 | |
|
|
1122 | if (expect_false (op->type == PLAYER)) |
|
|
1123 | player = op == ob ? pl->ob->count |
|
|
1124 | : op == pl->ob ? ob->count |
|
|
1125 | : op->count; |
|
|
1126 | } |
|
|
1127 | |
|
|
1128 | if (expect_false (lastcell.stat_hp != stat_hp)) |
|
|
1129 | { |
|
|
1130 | lastcell.stat_hp = stat_hp; |
|
|
1131 | |
|
|
1132 | mask |= 0x8; |
|
|
1133 | *last_ext |= 0x80; |
|
|
1134 | last_ext = &sl[sl.length ()]; |
|
|
1135 | |
|
|
1136 | sl << uint8 (5) << uint8 (stat_hp); |
|
|
1137 | |
|
|
1138 | if (stat_width > 1) |
1087 | { |
1139 | { |
1088 | *last_ext |= 0x80; |
1140 | *last_ext |= 0x80; |
1089 | last_ext = &sl[sl.length ()]; |
1141 | last_ext = &sl[sl.length ()]; |
1090 | sl << uint8 (d); |
|
|
1091 | } |
|
|
1092 | else |
|
|
1093 | sl << uint8 (255 - 64 * d); |
|
|
1094 | } |
|
|
1095 | |
1142 | |
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); |
1143 | 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 | } |
1144 | } |
1173 | } |
1145 | } |
|
|
1146 | |
|
|
1147 | if (expect_false (lastcell.player != player)) |
|
|
1148 | { |
|
|
1149 | lastcell.player = player; |
|
|
1150 | |
|
|
1151 | mask |= 0x8; |
|
|
1152 | *last_ext |= 0x80; |
|
|
1153 | last_ext = &sl[sl.length ()]; |
|
|
1154 | |
|
|
1155 | sl << uint8 (0x47) << uint8 (4) << (uint32)player; |
|
|
1156 | } |
|
|
1157 | |
|
|
1158 | if (expect_false (lastcell.flags != flags)) |
|
|
1159 | { |
|
|
1160 | lastcell.flags = flags; |
|
|
1161 | |
|
|
1162 | mask |= 0x8; |
|
|
1163 | *last_ext |= 0x80; |
|
|
1164 | last_ext = &sl[sl.length ()]; |
|
|
1165 | |
|
|
1166 | sl << uint8 (8) << uint8 (flags); |
|
|
1167 | } |
|
|
1168 | |
|
|
1169 | // faces |
1174 | |
1170 | |
1175 | /* Floor face */ |
1171 | /* Floor face */ |
1176 | if (update_space (sl, socket, ms, lastcell, 2)) |
1172 | if (update_space (sl, socket, ms, lastcell, 2)) |
1177 | mask |= 0x4; |
1173 | mask |= 0x4; |
1178 | |
1174 | |