… | |
… | |
28 | * \file |
28 | * \file |
29 | * Client handling. |
29 | * Client handling. |
30 | * |
30 | * |
31 | * \date 2003-12-02 |
31 | * \date 2003-12-02 |
32 | * |
32 | * |
33 | * This file implements all of the goo on the server side for handling |
33 | * This file implements all of the goo on the server side for handling |
34 | * clients. It's got a bunch of global variables for keeping track of |
34 | * clients. It's got a bunch of global variables for keeping track of |
35 | * each of the clients. |
35 | * each of the clients. |
36 | * |
36 | * |
37 | * Note: All functions that are used to process data from the client |
37 | * Note: All functions that are used to process data from the client |
38 | * have the prototype of (char *data, int datalen, int client_num). This |
38 | * have the prototype of (char *data, int datalen, int client_num). This |
39 | * way, we can use one dispatch table. |
39 | * way, we can use one dispatch table. |
40 | * |
40 | * |
… | |
… | |
940 | { |
940 | { |
941 | /* This block deals with spaces that are not visible for whatever |
941 | /* This block deals with spaces that are not visible for whatever |
942 | * reason. Still may need to send the head for this space. |
942 | * reason. Still may need to send the head for this space. |
943 | */ |
943 | */ |
944 | if (lastcell.count != -1 |
944 | if (lastcell.count != -1 |
945 | || lastcell.faces[0] |
945 | || lastcell.faces[0] |
946 | || lastcell.faces[1] |
946 | || lastcell.faces[1] |
947 | || lastcell.faces[2] |
947 | || lastcell.faces[2] |
948 | || lastcell.stat_hp |
948 | || lastcell.stat_hp |
949 | || lastcell.flags |
949 | || lastcell.flags |
950 | || lastcell.player) |
950 | || lastcell.player) |
951 | sl << uint16 (mask); |
951 | sl << uint16 (mask); |
952 | |
952 | |
953 | /* properly clear a previously sent big face */ |
953 | /* properly clear a previously sent big face */ |
954 | map_clearcell (&lastcell, -1); |
954 | map_clearcell (&lastcell, -1); |
… | |
… | |
1237 | if (pl->ns->monitor_spells < 2) |
1237 | if (pl->ns->monitor_spells < 2) |
1238 | sl << data16 (spell->msg); |
1238 | sl << data16 (spell->msg); |
1239 | } |
1239 | } |
1240 | |
1240 | |
1241 | /** |
1241 | /** |
1242 | * This tells the client to add the spell *ob, if *ob is NULL, then add |
1242 | * This tells the client to add the spell *ob, if *ob is NULL, then add |
1243 | * all spells in the player's inventory. |
1243 | * all spells in the player's inventory. |
1244 | */ |
1244 | */ |
1245 | void |
1245 | void |
1246 | esrv_add_spells (player *pl, object *spell) |
1246 | esrv_add_spells (player *pl, object *spell) |
1247 | { |
1247 | { |
… | |
… | |
1258 | |
1258 | |
1259 | if (!spell) |
1259 | if (!spell) |
1260 | { |
1260 | { |
1261 | for (spell = pl->ob->inv; spell; spell = spell->below) |
1261 | for (spell = pl->ob->inv; spell; spell = spell->below) |
1262 | { |
1262 | { |
1263 | /* were we to simply keep appending data here, we could exceed |
1263 | /* were we to simply keep appending data here, we could exceed |
1264 | * MAXSOCKBUF if the player has enough spells to add, we know that |
1264 | * MAXSOCKBUF if the player has enough spells to add, we know that |
1265 | * append_spells will always append 19 data bytes, plus 4 length |
1265 | * append_spells will always append 19 data bytes, plus 4 length |
1266 | * bytes and 3 strings (because that is the spec) so we need to |
1266 | * bytes and 3 strings (because that is the spec) so we need to |
1267 | * check that the length of those 3 strings, plus the 23 bytes, |
1267 | * check that the length of those 3 strings, plus the 23 bytes, |
1268 | * won't take us over the length limit for the socket, if it does, |
1268 | * won't take us over the length limit for the socket, if it does, |
1269 | * we need to send what we already have, and restart packet formation |
1269 | * we need to send what we already have, and restart packet formation |
1270 | */ |
1270 | */ |
1271 | if (spell->type != SPELL) |
1271 | if (spell->type != SPELL) |
1272 | continue; |
1272 | continue; |
1273 | |
1273 | |
1274 | /* Seeing crashes by overflowed buffers. Quick arithemetic seems |
1274 | /* Seeing crashes by overflowed buffers. Quick arithemetic seems |