… | |
… | |
705 | uint16 smoothface; |
705 | uint16 smoothface; |
706 | |
706 | |
707 | /* If we can't find a face, return and set it so we won't try to send this |
707 | /* If we can't find a face, return and set it so we won't try to send this |
708 | * again. |
708 | * again. |
709 | */ |
709 | */ |
710 | if ((!FindSmooth (face, &smoothface)) && (!FindSmooth (smooth_face->number, &smoothface))) |
710 | if (!FindSmooth (face, &smoothface)) |
711 | { |
711 | { |
712 | |
712 | |
713 | LOG (llevError, "could not findsmooth for %d. Neither default (%s)\n", face, &smooth_face->name); |
713 | LOG (llevError, "could not findsmooth for %d.\n", face); |
714 | ns->faces_sent[face] |= NS_FACESENT_SMOOTH; |
714 | ns->faces_sent[face] |= NS_FACESENT_SMOOTH; |
715 | return; |
715 | return; |
716 | } |
716 | } |
717 | |
717 | |
718 | if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE)) |
718 | if (!(ns->faces_sent[smoothface] & NS_FACESENT_FACE)) |
… | |
… | |
726 | << uint16 (smoothface); |
726 | << uint16 (smoothface); |
727 | |
727 | |
728 | ns->send_packet (sl); |
728 | ns->send_packet (sl); |
729 | } |
729 | } |
730 | |
730 | |
731 | /** |
731 | /** |
732 | * Tells client the picture it has to use |
732 | * Tells client the picture it has to use |
733 | * to smooth a picture number given as argument. |
733 | * to smooth a picture number given as argument. |
734 | */ |
734 | */ |
735 | void |
735 | void |
736 | AskSmooth (char *buf, int len, client *ns) |
736 | AskSmooth (char *buf, int len, client *ns) |
737 | { |
737 | { |
738 | SendSmooth (ns, atoi (buf)); |
738 | SendSmooth (ns, atoi (buf)); |
739 | } |
739 | } |
… | |
… | |
1108 | { |
1108 | { |
1109 | packet sl ("player"); |
1109 | packet sl ("player"); |
1110 | |
1110 | |
1111 | sl << uint32 (pl->ob->count) |
1111 | sl << uint32 (pl->ob->count) |
1112 | << uint32 (weight) |
1112 | << uint32 (weight) |
1113 | << uint32 (pl->ob->face->number) |
1113 | << uint32 (pl->ob->face) |
1114 | << data8 (pl->ob->name); |
1114 | << data8 (pl->ob->name); |
1115 | |
1115 | |
1116 | pl->ns->last_weight = weight; |
1116 | pl->ns->last_weight = weight; |
1117 | pl->ns->send_packet (sl); |
1117 | pl->ns->send_packet (sl); |
1118 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
1118 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
… | |
… | |
1216 | check_head (packet &sl, client &ns, int ax, int ay, int layer) |
1216 | check_head (packet &sl, client &ns, int ax, int ay, int layer) |
1217 | { |
1217 | { |
1218 | short face_num; |
1218 | short face_num; |
1219 | |
1219 | |
1220 | if (heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]) |
1220 | if (heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]) |
1221 | face_num = heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]->face->number; |
1221 | face_num = heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]->face; |
1222 | else |
1222 | else |
1223 | face_num = 0; |
1223 | face_num = 0; |
1224 | |
1224 | |
1225 | if (face_num != ns.lastmap.cells[ax][ay].faces[layer]) |
1225 | if (face_num != ns.lastmap.cells[ax][ay].faces[layer]) |
1226 | { |
1226 | { |
… | |
… | |
1311 | if (!ob || ob->face == blank_face) |
1311 | if (!ob || ob->face == blank_face) |
1312 | face_num = 0; |
1312 | face_num = 0; |
1313 | else if (head) |
1313 | else if (head) |
1314 | { |
1314 | { |
1315 | /* if this is a head that had previously been stored */ |
1315 | /* if this is a head that had previously been stored */ |
1316 | face_num = ob->face->number; |
1316 | face_num = ob->face; |
1317 | } |
1317 | } |
1318 | else |
1318 | else |
1319 | { |
1319 | { |
1320 | /* if the faces for the different parts of a multipart object |
1320 | /* if the faces for the different parts of a multipart object |
1321 | * are the same, we only want to send the bottom right most |
1321 | * are the same, we only want to send the bottom right most |
… | |
… | |
1363 | /* single part object, multipart object with non merged faces, |
1363 | /* single part object, multipart object with non merged faces, |
1364 | * of multipart object already at lower right. |
1364 | * of multipart object already at lower right. |
1365 | */ |
1365 | */ |
1366 | else if (bx == sx && by == sy) |
1366 | else if (bx == sx && by == sy) |
1367 | { |
1367 | { |
1368 | face_num = ob->face->number; |
1368 | face_num = ob->face; |
1369 | |
1369 | |
1370 | /* if this face matches one stored away, clear that one away. |
1370 | /* if this face matches one stored away, clear that one away. |
1371 | * this code relies on the fact that the map1 commands |
1371 | * this code relies on the fact that the map1 commands |
1372 | * goes from 2 down to 0. |
1372 | * goes from 2 down to 0. |
1373 | */ |
1373 | */ |
1374 | for (i = 0; i < MAP_LAYERS; i++) |
1374 | for (i = 0; i < MAP_LAYERS; i++) |
1375 | if (heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + i] && |
1375 | if (heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + i] && |
1376 | heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + i]->face->number == face_num) |
1376 | heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + i]->face == face_num) |
1377 | heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + i] = NULL; |
1377 | heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + i] = NULL; |
1378 | } |
1378 | } |
1379 | else |
1379 | else |
1380 | { |
1380 | { |
1381 | /* If this head is stored away, clear it - otherwise, |
1381 | /* If this head is stored away, clear it - otherwise, |
1382 | * there can be cases where a object is on multiple layers - |
1382 | * there can be cases where a object is on multiple layers - |
1383 | * we only want to send it once. |
1383 | * we only want to send it once. |
1384 | */ |
1384 | */ |
1385 | face_num = head->face->number; |
1385 | face_num = head->face; |
1386 | for (i = 0; i < MAP_LAYERS; i++) |
1386 | for (i = 0; i < MAP_LAYERS; i++) |
1387 | if (heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + i] && |
1387 | if (heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + i] && |
1388 | heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + i]->face->number == face_num) |
1388 | heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + i]->face == face_num) |
1389 | heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + i] = NULL; |
1389 | heads[(by * MAX_HEAD_POS + bx) * MAX_LAYERS + i] = NULL; |
1390 | |
1390 | |
1391 | /* First, try to put the new head on the same layer. If that is used up, |
1391 | /* First, try to put the new head on the same layer. If that is used up, |
1392 | * then find another layer. |
1392 | * then find another layer. |
1393 | */ |
1393 | */ |
… | |
… | |
1410 | else |
1410 | else |
1411 | { |
1411 | { |
1412 | /* In this case, we are already at the lower right or single part object, |
1412 | /* In this case, we are already at the lower right or single part object, |
1413 | * so nothing special |
1413 | * so nothing special |
1414 | */ |
1414 | */ |
1415 | face_num = ob->face->number; |
1415 | face_num = ob->face; |
1416 | |
1416 | |
1417 | /* clear out any head entries that have the same face as this one */ |
1417 | /* clear out any head entries that have the same face as this one */ |
1418 | for (bx = 0; bx < layer; bx++) |
1418 | for (bx = 0; bx < layer; bx++) |
1419 | if (heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + bx] && |
1419 | if (heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + bx] && |
1420 | heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + bx]->face->number == face_num) |
1420 | heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + bx]->face == face_num) |
1421 | heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + bx] = NULL; |
1421 | heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + bx] = NULL; |
1422 | } |
1422 | } |
1423 | } /* else not already head object or blank face */ |
1423 | } /* else not already head object or blank face */ |
1424 | |
1424 | |
1425 | /* This is a real hack. Basically, if we have nothing to send for this layer, |
1425 | /* This is a real hack. Basically, if we have nothing to send for this layer, |
… | |
… | |
1429 | * of the same type, what happens then is it doesn't think it needs to send |
1429 | * of the same type, what happens then is it doesn't think it needs to send |
1430 | * This tends to make stacking also work/look better. |
1430 | * This tends to make stacking also work/look better. |
1431 | */ |
1431 | */ |
1432 | if (!face_num && layer > 0 && heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + layer - 1]) |
1432 | if (!face_num && layer > 0 && heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + layer - 1]) |
1433 | { |
1433 | { |
1434 | face_num = heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + layer - 1]->face->number; |
1434 | face_num = heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + layer - 1]->face; |
1435 | heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + layer - 1] = NULL; |
1435 | heads[(sy * MAX_HEAD_POS + sx) * MAX_LAYERS + layer - 1] = NULL; |
1436 | } |
1436 | } |
1437 | |
1437 | |
1438 | /* Another hack - because of heads and whatnot, this face may match one |
1438 | /* Another hack - because of heads and whatnot, this face may match one |
1439 | * we already sent for a lower layer. In that case, don't send |
1439 | * we already sent for a lower layer. In that case, don't send |
… | |
… | |
1492 | if (!ob || ob->face == blank_face) |
1492 | if (!ob || ob->face == blank_face) |
1493 | smoothlevel = 0; |
1493 | smoothlevel = 0; |
1494 | else |
1494 | else |
1495 | { |
1495 | { |
1496 | smoothlevel = ob->smoothlevel; |
1496 | smoothlevel = ob->smoothlevel; |
1497 | if (smoothlevel && !(ns.faces_sent[ob->face->number] & NS_FACESENT_SMOOTH)) |
1497 | if (smoothlevel && !(ns.faces_sent[ob->face] & NS_FACESENT_SMOOTH)) |
1498 | SendSmooth (&ns, ob->face->number); |
1498 | SendSmooth (&ns, ob->face); |
1499 | } /* else not already head object or blank face */ |
1499 | } /* else not already head object or blank face */ |
1500 | |
1500 | |
1501 | /* We've gotten what face we want to use for the object. Now see if |
1501 | /* We've gotten what face we want to use for the object. Now see if |
1502 | * if it has changed since we last sent it to the client. |
1502 | * if it has changed since we last sent it to the client. |
1503 | */ |
1503 | */ |
… | |
… | |
1903 | if (update_smooth (esl, socket, m, nx, ny, ax, ay, 1)) |
1903 | if (update_smooth (esl, socket, m, nx, ny, ax, ay, 1)) |
1904 | emask |= 0x2; |
1904 | emask |= 0x2; |
1905 | |
1905 | |
1906 | if (nx == pl->x && ny == pl->y && pl->invisible & (pl->invisible < 50 ? 4 : 1)) |
1906 | if (nx == pl->x && ny == pl->y && pl->invisible & (pl->invisible < 50 ? 4 : 1)) |
1907 | { |
1907 | { |
1908 | if (lastcell.faces[0] != pl->face->number) |
1908 | if (lastcell.faces[0] != pl->face) |
1909 | { |
1909 | { |
1910 | lastcell.faces[0] = pl->face->number; |
1910 | lastcell.faces[0] = pl->face; |
1911 | mask |= 0x1; |
1911 | mask |= 0x1; |
1912 | |
1912 | |
1913 | if (!(socket.faces_sent[pl->face->number] & NS_FACESENT_FACE)) |
1913 | if (!(socket.faces_sent[pl->face] & NS_FACESENT_FACE)) |
1914 | esrv_send_face (&socket, pl->face->number, 0); |
1914 | esrv_send_face (&socket, pl->face, 0); |
1915 | |
1915 | |
1916 | sl << uint16 (pl->face->number); |
1916 | sl << uint16 (pl->face); |
1917 | } |
1917 | } |
1918 | } |
1918 | } |
1919 | else |
1919 | else |
1920 | { |
1920 | { |
1921 | /* Top face */ |
1921 | /* Top face */ |
… | |
… | |
2189 | skill = i + CS_STAT_SKILLINFO; |
2189 | skill = i + CS_STAT_SKILLINFO; |
2190 | break; |
2190 | break; |
2191 | } |
2191 | } |
2192 | } |
2192 | } |
2193 | |
2193 | |
|
|
2194 | // spells better have a face |
|
|
2195 | if (!spell->face) |
|
|
2196 | { |
|
|
2197 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |
|
|
2198 | spell->face = face_find ("burnout.x11", blank_face); |
|
|
2199 | } |
|
|
2200 | |
2194 | /* send the current values */ |
2201 | /* send the current values */ |
2195 | sl << uint32 (spell->count) |
2202 | sl << uint32 (spell->count) |
2196 | << uint16 (spell->level) |
2203 | << uint16 (spell->level) |
2197 | << uint16 (spell->casting_time) |
2204 | << uint16 (spell->casting_time) |
2198 | << uint16 (spell->last_sp) |
2205 | << uint16 (spell->last_sp) |
2199 | << uint16 (spell->last_grace) |
2206 | << uint16 (spell->last_grace) |
2200 | << uint16 (spell->last_eat) |
2207 | << uint16 (spell->last_eat) |
2201 | << uint8 (skill) |
2208 | << uint8 (skill) |
2202 | << uint32 (spell->path_attuned) |
2209 | << uint32 (spell->path_attuned) |
2203 | << uint32 (spell->face ? spell->face->number : 0) |
2210 | << uint32 (spell->face) |
2204 | << data8 (spell->name) |
2211 | << data8 (spell->name) |
2205 | << data16 (spell->msg); |
2212 | << data16 (spell->msg); |
2206 | } |
2213 | } |
2207 | |
2214 | |
2208 | /** |
2215 | /** |
… | |
… | |
2223 | |
2230 | |
2224 | packet sl ("addspell"); |
2231 | packet sl ("addspell"); |
2225 | |
2232 | |
2226 | if (!spell) |
2233 | if (!spell) |
2227 | { |
2234 | { |
2228 | for (spell = pl->ob->inv; spell != NULL; spell = spell->below) |
2235 | for (spell = pl->ob->inv; spell; spell = spell->below) |
2229 | { |
2236 | { |
2230 | /* were we to simply keep appending data here, we could exceed |
2237 | /* were we to simply keep appending data here, we could exceed |
2231 | * MAXSOCKBUF if the player has enough spells to add, we know that |
2238 | * MAXSOCKBUF if the player has enough spells to add, we know that |
2232 | * append_spells will always append 19 data bytes, plus 4 length |
2239 | * append_spells will always append 19 data bytes, plus 4 length |
2233 | * bytes and 3 strings (because that is the spec) so we need to |
2240 | * bytes and 3 strings (because that is the spec) so we need to |