… | |
… | |
833 | AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); |
833 | AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); |
834 | AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); |
834 | AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); |
835 | AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); |
835 | AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); |
836 | |
836 | |
837 | for (int s = 0; s < NUM_SKILLS; s++) |
837 | for (int s = 0; s < NUM_SKILLS; s++) |
838 | if (object *skill = opl->last_skill_ob[s]) |
838 | if (object *skill = opl->last_skill_ob [s]) |
839 | if (skill->stats.exp != ns->last_skill_exp [s]) |
839 | if (skill->stats.exp != ns->last_skill_exp [s]) |
840 | { |
840 | { |
841 | ns->last_skill_exp [s] = skill->stats.exp; |
841 | ns->last_skill_exp [s] = skill->stats.exp; |
842 | |
842 | |
843 | /* Always send along the level if exp changes. This is only |
843 | /* Always send along the level if exp changes. This is only |
… | |
… | |
912 | << uint32 (pl->ob->face) |
912 | << uint32 (pl->ob->face) |
913 | << data8 (pl->ob->name); |
913 | << data8 (pl->ob->name); |
914 | |
914 | |
915 | pl->ns->last_weight = weight; |
915 | pl->ns->last_weight = weight; |
916 | pl->ns->send_packet (sl); |
916 | pl->ns->send_packet (sl); |
917 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
|
|
918 | } |
917 | } |
919 | |
918 | |
920 | /****************************************************************************** |
919 | /****************************************************************************** |
921 | * |
920 | * |
922 | * Start of map related commands. |
921 | * Start of map related commands. |
… | |
… | |
1040 | { |
1039 | { |
1041 | object *ob = pl->observe; |
1040 | object *ob = pl->observe; |
1042 | if (!ob->active) |
1041 | if (!ob->active) |
1043 | return; |
1042 | return; |
1044 | |
1043 | |
1045 | maptile *plmap = ob->map; |
|
|
1046 | |
|
|
1047 | /* If player is just joining the game, he isn't here yet, so the map |
1044 | /* 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 |
1045 | * can get swapped out. If so, don't try to send them a map. All will |
1049 | * be OK once they really log in. |
1046 | * be OK once they really log in. |
1050 | */ |
1047 | */ |
1051 | if (!plmap || plmap->in_memory != MAP_ACTIVE) |
1048 | if (!ob->map || ob->map->in_memory != MAP_ACTIVE) |
1052 | return; |
1049 | return; |
1053 | |
1050 | |
1054 | int x, y, ax, ay, startlen, max_x, max_y, oldlen; |
1051 | int startlen, oldlen; |
1055 | int estartlen, eoldlen; |
1052 | int estartlen, eoldlen; |
1056 | uint8 eentrysize; |
1053 | uint8 eentrysize; |
1057 | uint16 ewhatstart, ewhatflag; |
1054 | uint16 ewhatstart, ewhatflag; |
1058 | uint8 extendedinfos; |
1055 | uint8 extendedinfos; |
1059 | |
1056 | |
… | |
… | |
1116 | << uint8 (eentrysize); |
1113 | << uint8 (eentrysize); |
1117 | |
1114 | |
1118 | estartlen = esl.length (); |
1115 | estartlen = esl.length (); |
1119 | } |
1116 | } |
1120 | |
1117 | |
1121 | /* x,y are the real map locations. ax, ay are viewport relative |
|
|
1122 | * locations. |
|
|
1123 | */ |
|
|
1124 | ay = 0; |
|
|
1125 | |
|
|
1126 | /* We could do this logic as conditionals in the if statement, |
1118 | /* We could do this logic as conditionals in the if statement, |
1127 | * but that started to get a bit messy to look at. |
1119 | * but that started to get a bit messy to look at. |
1128 | */ |
1120 | */ |
1129 | max_x = ob->x + (socket.mapx + 1) / 2; |
1121 | int hx = socket.mapx / 2; |
1130 | max_y = ob->y + (socket.mapy + 1) / 2; |
1122 | int hy = socket.mapy / 2; |
1131 | |
1123 | |
1132 | for (y = ob->y - socket.mapy / 2; y < max_y; y++, ay++) |
1124 | for (int dx = -hx; dx <= hx; dx++) |
1133 | { |
1125 | { |
1134 | sint16 nx, ny; |
1126 | sint16 nx, ny; |
1135 | maptile *m = 0; |
1127 | maptile *m = 0; |
1136 | |
1128 | |
1137 | ax = 0; |
1129 | for (int dy = -hy; dy <= hy; dy++) |
1138 | for (x = ob->x - socket.mapx / 2; x < max_x; x++, ax++) |
|
|
1139 | { |
1130 | { |
1140 | // check to see if we can simply go one right quickly |
1131 | // check to see if we can simply go one down quickly |
1141 | ++nx; |
|
|
1142 | if (m && nx >= m->width) |
1132 | if (m && ++ny >= m->height) |
1143 | m = 0; |
1133 | m = 0; |
1144 | |
1134 | |
|
|
1135 | // no, so do it the slow way |
1145 | if (!m) |
1136 | if (!m) |
1146 | { |
1137 | { |
1147 | nx = x; ny = y; m = plmap; |
1138 | nx = ob->x + dx; ny = ob->y + dy; m = ob->map; |
1148 | |
1139 | |
1149 | if (xy_normalise (m, nx, ny)) |
1140 | if (xy_normalise (m, nx, ny)) |
1150 | m->touch (); |
1141 | m->touch (); |
1151 | else |
1142 | else |
1152 | m = 0; |
1143 | m = 0; |
1153 | } |
1144 | } |
1154 | |
1145 | |
|
|
1146 | int ax = dx + hx; |
|
|
1147 | int ay = dy + hy; |
|
|
1148 | |
1155 | int emask, mask; |
1149 | int emask, mask; |
1156 | emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1150 | emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1157 | |
1151 | |
1158 | MapCell &lastcell = socket.lastmap.cells[ax][ay]; |
1152 | MapCell &lastcell = socket.lastmap.cells[ax][ay]; |
1159 | |
1153 | |
1160 | /* If the coordinates are not valid, or it is too dark to see, |
1154 | /* If the coordinates are not valid, or it is too dark to see, |
1161 | * we tell the client as such |
1155 | * we tell the client as such |
1162 | */ |
1156 | */ |
1163 | if (!m) |
1157 | if (!m) |
1164 | { |
1158 | { |
1165 | /* space is out of map. Update space and clear values |
1159 | /* space is out of map. Update space and clear values |
1166 | * if this hasn't already been done. If the space is out |
1160 | * if this hasn't already been done. If the space is out |
1167 | * of the map, it shouldn't have a head |
1161 | * of the map, it shouldn't have a head. |
1168 | */ |
1162 | */ |
1169 | if (lastcell.count != -1) |
1163 | if (lastcell.count != -1) |
1170 | { |
1164 | { |
1171 | sl << uint16 (mask); |
1165 | sl << uint16 (mask); |
1172 | map_clearcell (&lastcell, -1); |
1166 | map_clearcell (&lastcell, -1); |
1173 | } |
1167 | } |
1174 | |
1168 | |
1175 | continue; |
1169 | continue; |
1176 | } |
1170 | } |
1177 | |
1171 | |
1178 | int d = pl->blocked_los[ax][ay]; |
1172 | int d = pl->blocked_los_uc (dx, dy); |
1179 | |
1173 | |
1180 | if (d > 3) |
1174 | if (d > 3) |
1181 | { |
1175 | { |
1182 | int need_send = 0, count; |
1176 | int need_send = 0, count; |
1183 | |
1177 | |
… | |
… | |
1274 | |
1268 | |
1275 | if (op->has_dialogue ()) |
1269 | if (op->has_dialogue ()) |
1276 | flags |= 1; |
1270 | flags |= 1; |
1277 | |
1271 | |
1278 | if (op->type == PLAYER) |
1272 | if (op->type == PLAYER) |
1279 | player = ob == op ? pl->ob->count : op->count; |
1273 | player = op == ob ? pl->ob->count |
|
|
1274 | : op == pl->ob ? ob->count |
|
|
1275 | : op->count; |
1280 | } |
1276 | } |
1281 | |
1277 | |
1282 | if (lastcell.stat_hp != stat_hp) |
1278 | if (lastcell.stat_hp != stat_hp) |
1283 | { |
1279 | { |
1284 | lastcell.stat_hp = stat_hp; |
1280 | lastcell.stat_hp = stat_hp; |
… | |
… | |
1327 | |
1323 | |
1328 | /* Middle face */ |
1324 | /* Middle face */ |
1329 | if (update_space (sl, socket, ms, lastcell, 1)) |
1325 | if (update_space (sl, socket, ms, lastcell, 1)) |
1330 | mask |= 0x2; |
1326 | mask |= 0x2; |
1331 | |
1327 | |
|
|
1328 | if (ob->invisible |
|
|
1329 | && ob->invisible & (ob->invisible < 50 ? 1 : 7) |
1332 | if (ms.player () == ob |
1330 | && ms.player () == ob) |
1333 | && (ob->invisible & (ob->invisible < 50 ? 1 : 7))) |
|
|
1334 | { |
1331 | { |
1335 | // force player to be visible to himself if invisible |
1332 | // force player to be visible to himself if invisible |
1336 | if (lastcell.faces[0] != ob->face) |
1333 | if (lastcell.faces[0] != ob->face) |
1337 | { |
1334 | { |
1338 | lastcell.faces[0] = ob->face; |
1335 | lastcell.faces[0] = ob->face; |
… | |
… | |
1434 | { |
1431 | { |
1435 | packet sl; |
1432 | packet sl; |
1436 | sl << "replyinfo skill_info\n"; |
1433 | sl << "replyinfo skill_info\n"; |
1437 | |
1434 | |
1438 | for (int i = 1; i < NUM_SKILLS; i++) |
1435 | for (int i = 1; i < NUM_SKILLS; i++) |
1439 | sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names[i]); |
1436 | sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names [i]); |
1440 | |
1437 | |
1441 | if (sl.length () > MAXSOCKBUF) |
1438 | if (sl.length () > MAXSOCKBUF) |
1442 | { |
1439 | { |
1443 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
1440 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
1444 | fatal (0); |
1441 | fatal (0); |
… | |
… | |
1562 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1559 | spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); |
1563 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1560 | spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); |
1564 | |
1561 | |
1565 | /* figure out which skill it uses, if it uses one */ |
1562 | /* figure out which skill it uses, if it uses one */ |
1566 | if (spell->skill) |
1563 | if (spell->skill) |
1567 | { |
1564 | if (object *tmp = pl->find_skill (spell->skill)) |
1568 | for (i = 1; i < NUM_SKILLS; i++) |
|
|
1569 | if (!strcmp (spell->skill, skill_names[i])) |
|
|
1570 | { |
|
|
1571 | skill = i + CS_STAT_SKILLINFO; |
1565 | skill = tmp->subtype + CS_STAT_SKILLINFO; |
1572 | break; |
|
|
1573 | } |
|
|
1574 | } |
|
|
1575 | |
1566 | |
1576 | // spells better have a face |
1567 | // spells better have a face |
1577 | if (!spell->face) |
1568 | if (!spell->face) |
1578 | { |
1569 | { |
1579 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |
1570 | LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); |