… | |
… | |
98 | */ |
98 | */ |
99 | mx = ns->mapx; |
99 | mx = ns->mapx; |
100 | my = ns->mapy; |
100 | my = ns->mapy; |
101 | |
101 | |
102 | /* the x and y here are coordinates for the new map, i.e. if we moved |
102 | /* the x and y here are coordinates for the new map, i.e. if we moved |
103 | * (dx,dy), newmap[x][y] = oldmap[x-dx][y-dy]. For this reason, |
103 | * (dx,dy), newmap[x][y] = oldmap[x-dx][y-dy]. For this reason, |
104 | * if the destination x or y coordinate is outside the viewable |
104 | * if the destination x or y coordinate is outside the viewable |
105 | * area, we clear the values - otherwise, the old values |
105 | * area, we clear the values - otherwise, the old values |
106 | * are preserved, and the check_head thinks it needs to clear them. |
106 | * are preserved, and the check_head thinks it needs to clear them. |
107 | */ |
107 | */ |
108 | for (x = 0; x < mx; x++) |
108 | for (x = 0; x < mx; x++) |
109 | { |
|
|
110 | for (y = 0; y < my; y++) |
109 | for (y = 0; y < my; y++) |
111 | { |
|
|
112 | if (x >= ns->mapx || y >= ns->mapy) |
110 | if (x >= ns->mapx || y >= ns->mapy) |
113 | /* clear cells outside the viewable area */ |
111 | /* clear cells outside the viewable area */ |
114 | memset (&newmap.cells[x][y], 0, sizeof (struct MapCell)); |
112 | memset (&newmap.cells[x][y], 0, sizeof (struct MapCell)); |
115 | else if ((x + dx) < 0 || (x + dx) >= ns->mapx || (y + dy) < 0 || (y + dy) >= ns->mapy) |
113 | else if ((x + dx) < 0 || (x + dx) >= ns->mapx || (y + dy) < 0 || (y + dy) >= ns->mapy) |
116 | /* clear newly visible tiles within the viewable area */ |
114 | /* clear newly visible tiles within the viewable area */ |
117 | memset (&(newmap.cells[x][y]), 0, sizeof (struct MapCell)); |
115 | memset (&(newmap.cells[x][y]), 0, sizeof (struct MapCell)); |
118 | else |
116 | else |
119 | memcpy (&(newmap.cells[x][y]), &(ns->lastmap.cells[x + dx][y + dy]), sizeof (struct MapCell)); |
117 | memcpy (&(newmap.cells[x][y]), &(ns->lastmap.cells[x + dx][y + dy]), sizeof (struct MapCell)); |
120 | } |
|
|
121 | } |
|
|
122 | |
118 | |
123 | memcpy (&(ns->lastmap), &newmap, sizeof (struct Map)); |
119 | memcpy (&(ns->lastmap), &newmap, sizeof (struct Map)); |
124 | |
120 | |
125 | /* Make sure that the next "map1" command will be sent (even if it is |
121 | /* Make sure that the next "map1" command will be sent (even if it is |
126 | * empty). |
122 | * empty). |
… | |
… | |
833 | AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); |
829 | AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); |
834 | AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); |
830 | AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); |
835 | AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); |
831 | AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); |
836 | |
832 | |
837 | for (int s = 0; s < NUM_SKILLS; s++) |
833 | for (int s = 0; s < NUM_SKILLS; s++) |
838 | if (object *skill = opl->last_skill_ob[s]) |
834 | if (object *skill = opl->last_skill_ob [s]) |
839 | if (skill->stats.exp != ns->last_skill_exp [s]) |
835 | if (skill->stats.exp != ns->last_skill_exp [s]) |
840 | { |
836 | { |
841 | ns->last_skill_exp [s] = skill->stats.exp; |
837 | ns->last_skill_exp [s] = skill->stats.exp; |
842 | |
838 | |
843 | /* Always send along the level if exp changes. This is only |
839 | /* Always send along the level if exp changes. This is only |
… | |
… | |
912 | << uint32 (pl->ob->face) |
908 | << uint32 (pl->ob->face) |
913 | << data8 (pl->ob->name); |
909 | << data8 (pl->ob->name); |
914 | |
910 | |
915 | pl->ns->last_weight = weight; |
911 | pl->ns->last_weight = weight; |
916 | pl->ns->send_packet (sl); |
912 | pl->ns->send_packet (sl); |
917 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
|
|
918 | } |
913 | } |
919 | |
914 | |
920 | /****************************************************************************** |
915 | /****************************************************************************** |
921 | * |
916 | * |
922 | * Start of map related commands. |
917 | * Start of map related commands. |
… | |
… | |
1040 | { |
1035 | { |
1041 | object *ob = pl->observe; |
1036 | object *ob = pl->observe; |
1042 | if (!ob->active) |
1037 | if (!ob->active) |
1043 | return; |
1038 | return; |
1044 | |
1039 | |
1045 | maptile *plmap = ob->map; |
|
|
1046 | |
|
|
1047 | /* If player is just joining the game, he isn't here yet, so the map |
1040 | /* If player is just joining the game, he isn't here yet, so the map |
1048 | * can get swapped out. If so, don't try to send them a map. All will |
1041 | * can get swapped out. If so, don't try to send them a map. All will |
1049 | * be OK once they really log in. |
1042 | * be OK once they really log in. |
1050 | */ |
1043 | */ |
1051 | if (!plmap || plmap->in_memory != MAP_ACTIVE) |
1044 | if (!ob->map || ob->map->in_memory != MAP_ACTIVE) |
1052 | return; |
1045 | return; |
1053 | |
1046 | |
1054 | int x, y, ax, ay, startlen, max_x, max_y, oldlen; |
1047 | int startlen, oldlen; |
1055 | int estartlen, eoldlen; |
1048 | int estartlen, eoldlen; |
1056 | uint8 eentrysize; |
1049 | uint8 eentrysize; |
1057 | uint16 ewhatstart, ewhatflag; |
1050 | uint16 ewhatstart, ewhatflag; |
1058 | uint8 extendedinfos; |
1051 | uint8 extendedinfos; |
1059 | |
1052 | |
1060 | check_map_change (pl); |
1053 | check_map_change (pl); |
1061 | prefetch_surrounding_maps (pl->ob); |
1054 | prefetch_surrounding_maps (pl->ob); |
1062 | |
1055 | |
1063 | /* do LOS after calls to update_position */ |
1056 | /* do LOS after calls to update_position */ |
1064 | if (ob != pl->ob) |
1057 | /* unfortunately, we need to udpate los when observing, currently */ |
1065 | clear_los (pl); |
1058 | if (pl->do_los || pl->observe != pl->ob) |
1066 | else if (pl->do_los) |
|
|
1067 | { |
1059 | { |
1068 | update_los (ob); |
|
|
1069 | pl->do_los = 0; |
1060 | pl->do_los = 0; |
|
|
1061 | pl->update_los (); |
1070 | } |
1062 | } |
1071 | |
1063 | |
1072 | /** |
1064 | /** |
1073 | * This function uses the new map1 protocol command to send the map |
1065 | * This function uses the new map1 protocol command to send the map |
1074 | * to the client. It is necessary because the old map command supports |
1066 | * to the client. It is necessary because the old map command supports |
… | |
… | |
1116 | << uint8 (eentrysize); |
1108 | << uint8 (eentrysize); |
1117 | |
1109 | |
1118 | estartlen = esl.length (); |
1110 | estartlen = esl.length (); |
1119 | } |
1111 | } |
1120 | |
1112 | |
1121 | /* x,y are the real map locations. ax, ay are viewport relative |
1113 | int hx = socket.mapx / 2; |
1122 | * locations. |
1114 | int hy = socket.mapy / 2; |
1123 | */ |
|
|
1124 | ay = 0; |
|
|
1125 | |
1115 | |
1126 | /* We could do this logic as conditionals in the if statement, |
1116 | ordered_mapwalk_begin (ob, -hx, -hy, hx, hy) |
1127 | * but that started to get a bit messy to look at. |
1117 | int ax = dx + hx; |
1128 | */ |
1118 | int ay = dy + hy; |
1129 | max_x = ob->x + (socket.mapx + 1) / 2; |
|
|
1130 | max_y = ob->y + (socket.mapy + 1) / 2; |
|
|
1131 | |
1119 | |
1132 | for (y = ob->y - socket.mapy / 2; y < max_y; y++, ay++) |
|
|
1133 | { |
|
|
1134 | sint16 nx, ny; |
|
|
1135 | maptile *m = 0; |
|
|
1136 | |
|
|
1137 | ax = 0; |
|
|
1138 | for (x = ob->x - socket.mapx / 2; x < max_x; x++, ax++) |
|
|
1139 | { |
|
|
1140 | // check to see if we can simply go one right quickly |
|
|
1141 | ++nx; |
|
|
1142 | if (m && nx >= m->width) |
|
|
1143 | m = 0; |
|
|
1144 | |
|
|
1145 | if (!m) |
|
|
1146 | { |
|
|
1147 | nx = x; ny = y; m = plmap; |
|
|
1148 | |
|
|
1149 | if (xy_normalise (m, nx, ny)) |
|
|
1150 | m->touch (); |
|
|
1151 | else |
|
|
1152 | m = 0; |
|
|
1153 | } |
|
|
1154 | |
|
|
1155 | int emask, mask; |
1120 | int emask, mask; |
1156 | emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1121 | emask = mask = (ax << 10) | (ay << 4); |
1157 | |
1122 | |
1158 | MapCell &lastcell = socket.lastmap.cells[ax][ay]; |
1123 | MapCell &lastcell = socket.lastmap.cells[ax][ay]; |
1159 | |
1124 | |
1160 | /* If the coordinates are not valid, or it is too dark to see, |
1125 | /* If the coordinates are not valid, or it is too dark to see, |
1161 | * we tell the client as such |
1126 | * we tell the client as such |
1162 | */ |
1127 | */ |
1163 | if (!m) |
1128 | if (!m) |
1164 | { |
1129 | { |
1165 | /* space is out of map. Update space and clear values |
1130 | /* space is out of map. Update space and clear values |
1166 | * if this hasn't already been done. If the space is out |
1131 | * if this hasn't already been done. If the space is out |
1167 | * of the map, it shouldn't have a head |
1132 | * of the map, it shouldn't have a head. |
1168 | */ |
1133 | */ |
1169 | if (lastcell.count != -1) |
1134 | if (lastcell.count != -1) |
|
|
1135 | { |
|
|
1136 | sl << uint16 (mask); |
|
|
1137 | map_clearcell (&lastcell, -1); |
|
|
1138 | } |
|
|
1139 | |
|
|
1140 | continue; |
|
|
1141 | } |
|
|
1142 | |
|
|
1143 | int d = pl->blocked_los_uc (dx, dy); |
|
|
1144 | |
|
|
1145 | if (d > 3) |
|
|
1146 | { |
|
|
1147 | /* This block deals with spaces that are not visible for whatever |
|
|
1148 | * reason. Still may need to send the head for this space. |
|
|
1149 | */ |
|
|
1150 | if (lastcell.count != -1 |
|
|
1151 | || lastcell.faces[0] |
|
|
1152 | || lastcell.faces[1] |
|
|
1153 | || lastcell.faces[2] |
|
|
1154 | || lastcell.stat_hp |
|
|
1155 | || lastcell.flags |
|
|
1156 | || lastcell.player) |
|
|
1157 | sl << uint16 (mask); |
|
|
1158 | |
|
|
1159 | /* properly clear a previously sent big face */ |
|
|
1160 | map_clearcell (&lastcell, -1); |
|
|
1161 | } |
|
|
1162 | else |
|
|
1163 | { |
|
|
1164 | /* In this block, the space is visible. |
|
|
1165 | */ |
|
|
1166 | |
|
|
1167 | /* Rather than try to figure out what everything that we might |
|
|
1168 | * need to send is, then form the packet after that, |
|
|
1169 | * we presume that we will in fact form a packet, and update |
|
|
1170 | * the bits by what we do actually send. If we send nothing, |
|
|
1171 | * we just back out sl.length () to the old value, and no harm |
|
|
1172 | * is done. |
|
|
1173 | * I think this is simpler than doing a bunch of checks to see |
|
|
1174 | * what if anything we need to send, setting the bits, then |
|
|
1175 | * doing those checks again to add the real data. |
|
|
1176 | */ |
|
|
1177 | oldlen = sl.length (); |
|
|
1178 | eoldlen = esl.length (); |
|
|
1179 | |
|
|
1180 | sl << uint16 (mask); |
|
|
1181 | |
|
|
1182 | unsigned char dummy; |
|
|
1183 | unsigned char *last_ext = &dummy; |
|
|
1184 | |
|
|
1185 | /* Darkness changed */ |
|
|
1186 | if (lastcell.count != d && socket.darkness) |
|
|
1187 | { |
|
|
1188 | mask |= 0x8; |
|
|
1189 | |
|
|
1190 | if (socket.extmap) |
|
|
1191 | { |
|
|
1192 | *last_ext |= 0x80; |
|
|
1193 | last_ext = &sl[sl.length ()]; |
|
|
1194 | sl << uint8 (d); |
|
|
1195 | } |
|
|
1196 | else |
|
|
1197 | sl << uint8 (255 - 64 * d); |
|
|
1198 | } |
|
|
1199 | |
|
|
1200 | lastcell.count = d; |
|
|
1201 | |
|
|
1202 | mapspace &ms = m->at (nx, ny); |
|
|
1203 | ms.update (); |
|
|
1204 | |
|
|
1205 | if (expect_true (socket.extmap)) |
|
|
1206 | { |
|
|
1207 | uint8 stat_hp = 0; |
|
|
1208 | uint8 stat_width = 0; |
|
|
1209 | uint8 flags = 0; |
|
|
1210 | tag_t player = 0; |
|
|
1211 | |
|
|
1212 | // send hp information, if applicable |
|
|
1213 | if (object *op = ms.faces_obj [0]) |
|
|
1214 | if (op->is_head () && !op->invisible) |
1170 | { |
1215 | { |
1171 | sl << uint16 (mask); |
1216 | if (op->stats.maxhp > op->stats.hp |
1172 | map_clearcell (&lastcell, -1); |
1217 | && op->stats.maxhp > 0 |
|
|
1218 | && (op->type == PLAYER |
|
|
1219 | || op->type == DOOR // does not work, have maxhp 0 |
|
|
1220 | || QUERY_FLAG (op, FLAG_MONSTER) |
|
|
1221 | || QUERY_FLAG (op, FLAG_ALIVE) |
|
|
1222 | || QUERY_FLAG (op, FLAG_GENERATOR))) |
|
|
1223 | { |
|
|
1224 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
|
|
1225 | stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge |
|
|
1226 | } |
|
|
1227 | |
|
|
1228 | if (expect_false (op->has_dialogue ())) |
|
|
1229 | flags |= 1; |
|
|
1230 | |
|
|
1231 | if (expect_false (op->type == PLAYER)) |
|
|
1232 | player = op == ob ? pl->ob->count |
|
|
1233 | : op == pl->ob ? ob->count |
|
|
1234 | : op->count; |
1173 | } |
1235 | } |
1174 | |
1236 | |
1175 | continue; |
1237 | if (expect_false (lastcell.stat_hp != stat_hp)) |
1176 | } |
|
|
1177 | |
|
|
1178 | int d = pl->blocked_los[ax][ay]; |
|
|
1179 | |
|
|
1180 | if (d > 3) |
|
|
1181 | { |
|
|
1182 | int need_send = 0, count; |
|
|
1183 | |
|
|
1184 | /* This block deals with spaces that are not visible for whatever |
|
|
1185 | * reason. Still may need to send the head for this space. |
|
|
1186 | */ |
|
|
1187 | |
|
|
1188 | oldlen = sl.length (); |
|
|
1189 | |
|
|
1190 | sl << uint16 (mask); |
|
|
1191 | |
|
|
1192 | if (lastcell.count != -1) |
|
|
1193 | need_send = 1; |
|
|
1194 | |
|
|
1195 | count = -1; |
|
|
1196 | |
|
|
1197 | if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2] |
|
|
1198 | || lastcell.stat_hp || lastcell.flags || lastcell.player) |
|
|
1199 | need_send = 1; |
|
|
1200 | |
|
|
1201 | /* properly clear a previously sent big face */ |
|
|
1202 | map_clearcell (&lastcell, count); |
|
|
1203 | |
|
|
1204 | if ((mask & 0xf) || need_send) |
|
|
1205 | sl[oldlen + 1] = mask & 0xff; |
|
|
1206 | else |
|
|
1207 | sl.reset (oldlen); |
|
|
1208 | } |
|
|
1209 | else |
|
|
1210 | { |
|
|
1211 | /* In this block, the space is visible. |
|
|
1212 | */ |
|
|
1213 | |
|
|
1214 | /* Rather than try to figure out what everything that we might |
|
|
1215 | * need to send is, then form the packet after that, |
|
|
1216 | * we presume that we will in fact form a packet, and update |
|
|
1217 | * the bits by what we do actually send. If we send nothing, |
|
|
1218 | * we just back out sl.length () to the old value, and no harm |
|
|
1219 | * is done. |
|
|
1220 | * I think this is simpler than doing a bunch of checks to see |
|
|
1221 | * what if anything we need to send, setting the bits, then |
|
|
1222 | * doing those checks again to add the real data. |
|
|
1223 | */ |
|
|
1224 | oldlen = sl.length (); |
|
|
1225 | eoldlen = esl.length (); |
|
|
1226 | |
|
|
1227 | sl << uint16 (mask); |
|
|
1228 | |
|
|
1229 | unsigned char dummy; |
|
|
1230 | unsigned char *last_ext = &dummy; |
|
|
1231 | |
|
|
1232 | /* Darkness changed */ |
|
|
1233 | if (lastcell.count != d && socket.darkness) |
|
|
1234 | { |
1238 | { |
|
|
1239 | lastcell.stat_hp = stat_hp; |
|
|
1240 | |
1235 | mask |= 0x8; |
1241 | mask |= 0x8; |
|
|
1242 | *last_ext |= 0x80; |
|
|
1243 | last_ext = &sl[sl.length ()]; |
1236 | |
1244 | |
1237 | if (socket.extmap) |
1245 | sl << uint8 (5) << uint8 (stat_hp); |
|
|
1246 | |
|
|
1247 | if (stat_width > 1) |
1238 | { |
1248 | { |
1239 | *last_ext |= 0x80; |
1249 | *last_ext |= 0x80; |
1240 | last_ext = &sl[sl.length ()]; |
1250 | last_ext = &sl[sl.length ()]; |
1241 | sl << uint8 (d); |
|
|
1242 | } |
|
|
1243 | else |
|
|
1244 | sl << uint8 (255 - 64 * d); |
|
|
1245 | } |
|
|
1246 | |
1251 | |
1247 | lastcell.count = d; |
|
|
1248 | |
|
|
1249 | mapspace &ms = m->at (nx, ny); |
|
|
1250 | ms.update (); |
|
|
1251 | |
|
|
1252 | if (socket.extmap) |
|
|
1253 | { |
|
|
1254 | uint8 stat_hp = 0; |
|
|
1255 | uint8 stat_width = 0; |
|
|
1256 | uint8 flags = 0; |
|
|
1257 | tag_t player = 0; |
|
|
1258 | |
|
|
1259 | // send hp information, if applicable |
|
|
1260 | if (object *op = ms.faces_obj [0]) |
|
|
1261 | if (op->is_head () && !op->invisible) |
|
|
1262 | { |
|
|
1263 | if (op->stats.maxhp > op->stats.hp |
|
|
1264 | && op->stats.maxhp > 0 |
|
|
1265 | && (op->type == PLAYER |
|
|
1266 | || op->type == DOOR // does not work, have maxhp 0 |
|
|
1267 | || QUERY_FLAG (op, FLAG_MONSTER) || QUERY_FLAG (op, FLAG_ALIVE) || QUERY_FLAG (op, FLAG_GENERATOR))) |
|
|
1268 | { |
|
|
1269 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
|
|
1270 | stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge |
|
|
1271 | } |
|
|
1272 | |
|
|
1273 | if (op->msg && op->msg[0] == '@') |
|
|
1274 | flags |= 1; |
|
|
1275 | |
|
|
1276 | if (op->type == PLAYER) |
|
|
1277 | player = op->count; |
|
|
1278 | } |
|
|
1279 | |
|
|
1280 | if (lastcell.stat_hp != stat_hp) |
|
|
1281 | { |
|
|
1282 | lastcell.stat_hp = stat_hp; |
|
|
1283 | |
|
|
1284 | mask |= 0x8; |
|
|
1285 | *last_ext |= 0x80; |
|
|
1286 | last_ext = &sl[sl.length ()]; |
|
|
1287 | |
|
|
1288 | sl << uint8 (5) << uint8 (stat_hp); |
|
|
1289 | |
|
|
1290 | if (stat_width > 1) |
|
|
1291 | { |
|
|
1292 | *last_ext |= 0x80; |
|
|
1293 | last_ext = &sl[sl.length ()]; |
|
|
1294 | |
|
|
1295 | sl << uint8 (6) << uint8 (stat_width); |
1252 | sl << uint8 (6) << uint8 (stat_width); |
1296 | } |
|
|
1297 | } |
1253 | } |
1298 | |
|
|
1299 | if (lastcell.player != player) |
|
|
1300 | { |
|
|
1301 | lastcell.player = player; |
|
|
1302 | |
|
|
1303 | mask |= 0x8; |
|
|
1304 | *last_ext |= 0x80; |
|
|
1305 | last_ext = &sl[sl.length ()]; |
|
|
1306 | |
|
|
1307 | sl << uint8 (0x47) << uint8 (4) << (uint32)player; |
|
|
1308 | } |
|
|
1309 | |
|
|
1310 | if (lastcell.flags != flags) |
|
|
1311 | { |
|
|
1312 | lastcell.flags = flags; |
|
|
1313 | |
|
|
1314 | mask |= 0x8; |
|
|
1315 | *last_ext |= 0x80; |
|
|
1316 | last_ext = &sl[sl.length ()]; |
|
|
1317 | |
|
|
1318 | sl << uint8 (8) << uint8 (flags); |
|
|
1319 | } |
|
|
1320 | } |
1254 | } |
1321 | |
1255 | |
1322 | /* Floor face */ |
1256 | if (expect_false (lastcell.player != player)) |
1323 | if (update_space (sl, socket, ms, lastcell, 2)) |
1257 | { |
|
|
1258 | lastcell.player = player; |
|
|
1259 | |
1324 | mask |= 0x4; |
1260 | mask |= 0x8; |
|
|
1261 | *last_ext |= 0x80; |
|
|
1262 | last_ext = &sl[sl.length ()]; |
1325 | |
1263 | |
1326 | /* Middle face */ |
1264 | sl << uint8 (0x47) << uint8 (4) << (uint32)player; |
1327 | if (update_space (sl, socket, ms, lastcell, 1)) |
1265 | } |
|
|
1266 | |
|
|
1267 | if (expect_false (lastcell.flags != flags)) |
|
|
1268 | { |
|
|
1269 | lastcell.flags = flags; |
|
|
1270 | |
1328 | mask |= 0x2; |
1271 | mask |= 0x8; |
|
|
1272 | *last_ext |= 0x80; |
|
|
1273 | last_ext = &sl[sl.length ()]; |
1329 | |
1274 | |
1330 | if (ms.player () == ob |
1275 | sl << uint8 (8) << uint8 (flags); |
1331 | && (ob->invisible & (ob->invisible < 50 ? 1 : 7))) |
|
|
1332 | { |
1276 | } |
|
|
1277 | } |
|
|
1278 | |
|
|
1279 | /* Floor face */ |
|
|
1280 | if (update_space (sl, socket, ms, lastcell, 2)) |
|
|
1281 | mask |= 0x4; |
|
|
1282 | |
|
|
1283 | /* Middle face */ |
|
|
1284 | if (update_space (sl, socket, ms, lastcell, 1)) |
|
|
1285 | mask |= 0x2; |
|
|
1286 | |
|
|
1287 | if (expect_false (ob->invisible) |
|
|
1288 | && ob->invisible & (ob->invisible < 50 ? 1 : 7) |
|
|
1289 | && ms.player () == ob) |
|
|
1290 | { |
1333 | // force player to be visible to himself if invisible |
1291 | // force player to be visible to himself if invisible |
1334 | if (lastcell.faces[0] != ob->face) |
1292 | if (lastcell.faces[0] != ob->face) |
1335 | { |
1293 | { |
1336 | lastcell.faces[0] = ob->face; |
1294 | lastcell.faces[0] = ob->face; |
1337 | |
1295 | |
1338 | mask |= 0x1; |
|
|
1339 | sl << uint16 (ob->face); |
|
|
1340 | |
|
|
1341 | socket.send_faces (ob); |
|
|
1342 | } |
|
|
1343 | } |
|
|
1344 | /* Top face */ |
|
|
1345 | else if (update_space (sl, socket, ms, lastcell, 0)) |
|
|
1346 | mask |= 0x1; |
1296 | mask |= 0x1; |
|
|
1297 | sl << uint16 (ob->face); |
1347 | |
1298 | |
|
|
1299 | socket.send_faces (ob); |
|
|
1300 | } |
|
|
1301 | } |
|
|
1302 | /* Top face */ |
|
|
1303 | else if (update_space (sl, socket, ms, lastcell, 0)) |
|
|
1304 | mask |= 0x1; |
|
|
1305 | |
1348 | /* Check to see if we are in fact sending anything for this |
1306 | /* Check to see if we are in fact sending anything for this |
1349 | * space by checking the mask. If so, update the mask. |
1307 | * space by checking the mask. If so, update the mask. |
1350 | * if not, reset the len to that from before adding the mask |
1308 | * if not, reset the len to that from before adding the mask |
1351 | * value, so we don't send those bits. |
1309 | * value, so we don't send those bits. |
1352 | */ |
1310 | */ |
1353 | if (mask & 0xf) |
1311 | if (mask & 0xf) |
1354 | sl[oldlen + 1] = mask & 0xff; |
1312 | sl[oldlen + 1] = mask & 0xff; |
1355 | else |
1313 | else |
1356 | sl.reset (oldlen); |
1314 | sl.reset (oldlen); |
1357 | |
1315 | |
1358 | if (socket.ext_mapinfos) |
1316 | if (socket.ext_mapinfos) |
1359 | esl << uint16 (emask); |
1317 | esl << uint16 (emask); |
1360 | |
1318 | |
1361 | if (socket.EMI_smooth) |
1319 | if (socket.EMI_smooth) |
|
|
1320 | { |
|
|
1321 | for (int layer = 2+1; layer--; ) |
1362 | { |
1322 | { |
1363 | for (int layer = 2+1; layer--; ) |
|
|
1364 | { |
|
|
1365 | object *ob = ms.faces_obj [layer]; |
1323 | object *ob = ms.faces_obj [layer]; |
1366 | |
1324 | |
1367 | // If there is no object for this space, or if the face for the object |
1325 | // If there is no object for this space, or if the face for the object |
1368 | // is the blank face, set the smoothlevel to zero. |
1326 | // is the blank face, set the smoothlevel to zero. |
1369 | int smoothlevel = ob && ob->face != blank_face ? ob->smoothlevel : 0; |
1327 | int smoothlevel = ob && ob->face != blank_face ? ob->smoothlevel : 0; |
1370 | |
1328 | |
1371 | // We've gotten what face we want to use for the object. Now see if |
1329 | // We've gotten what face we want to use for the object. Now see if |
1372 | // if it has changed since we last sent it to the client. |
1330 | // if it has changed since we last sent it to the client. |
1373 | if (lastcell.smooth[layer] != smoothlevel) |
1331 | if (lastcell.smooth[layer] != smoothlevel) |
1374 | { |
1332 | { |
1375 | lastcell.smooth[layer] = smoothlevel; |
1333 | lastcell.smooth[layer] = smoothlevel; |
1376 | esl << uint8 (smoothlevel); |
1334 | esl << uint8 (smoothlevel); |
1377 | emask |= 1 << layer; |
1335 | emask |= 1 << layer; |
1378 | } |
|
|
1379 | } |
1336 | } |
|
|
1337 | } |
1380 | |
1338 | |
1381 | if (emask & 0xf) |
1339 | if (emask & 0xf) |
1382 | esl[eoldlen + 1] = emask & 0xff; |
1340 | esl[eoldlen + 1] = emask & 0xff; |
1383 | else |
1341 | else |
1384 | esl.reset (eoldlen); |
1342 | esl.reset (eoldlen); |
1385 | } |
1343 | } |
1386 | } /* else this is a viewable space */ |
1344 | } /* else this is a viewable space */ |
1387 | } /* for x loop */ |
1345 | ordered_mapwalk_end |
1388 | } /* for y loop */ |
|
|
1389 | |
1346 | |
1390 | socket.flush_fx (); |
1347 | socket.flush_fx (); |
1391 | |
1348 | |
1392 | /* Verify that we in fact do need to send this */ |
1349 | /* Verify that we in fact do need to send this */ |
1393 | if (socket.ext_mapinfos) |
1350 | if (socket.ext_mapinfos) |
… | |
… | |
1432 | { |
1389 | { |
1433 | packet sl; |
1390 | packet sl; |
1434 | sl << "replyinfo skill_info\n"; |
1391 | sl << "replyinfo skill_info\n"; |
1435 | |
1392 | |
1436 | for (int i = 1; i < NUM_SKILLS; i++) |
1393 | for (int i = 1; i < NUM_SKILLS; i++) |
1437 | sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names[i]); |
1394 | sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names [i]); |
1438 | |
1395 | |
1439 | if (sl.length () > MAXSOCKBUF) |
1396 | if (sl.length () > MAXSOCKBUF) |
1440 | { |
1397 | { |
1441 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
1398 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
1442 | fatal (0); |
1399 | fatal (0); |
… | |
… | |
1560 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1517 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1561 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1518 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1562 | |
1519 | |
1563 | /* figure out which skill it uses, if it uses one */ |
1520 | /* figure out which skill it uses, if it uses one */ |
1564 | if (spell->skill) |
1521 | if (spell->skill) |
1565 | { |
1522 | if (object *tmp = pl->find_skill (spell->skill)) |
1566 | for (i = 1; i < NUM_SKILLS; i++) |
|
|
1567 | if (!strcmp (spell->skill, skill_names[i])) |
|
|
1568 | { |
|
|
1569 | skill = i + CS_STAT_SKILLINFO; |
1523 | skill = tmp->subtype + CS_STAT_SKILLINFO; |
1570 | break; |
|
|
1571 | } |
|
|
1572 | } |
|
|
1573 | |
1524 | |
1574 | // spells better have a face |
1525 | // spells better have a face |
1575 | if (!spell->face) |
1526 | if (!spell->face) |
1576 | { |
1527 | { |
1577 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |
1528 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |