… | |
… | |
1039 | { |
1039 | { |
1040 | object *ob = pl->observe; |
1040 | object *ob = pl->observe; |
1041 | if (!ob->active) |
1041 | if (!ob->active) |
1042 | return; |
1042 | return; |
1043 | |
1043 | |
1044 | maptile *plmap = ob->map; |
|
|
1045 | |
|
|
1046 | /* 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 |
1047 | * 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 |
1048 | * be OK once they really log in. |
1046 | * be OK once they really log in. |
1049 | */ |
1047 | */ |
1050 | if (!plmap || plmap->in_memory != MAP_ACTIVE) |
1048 | if (!ob->map || ob->map->in_memory != MAP_ACTIVE) |
1051 | return; |
1049 | return; |
1052 | |
1050 | |
1053 | int x, y, ax, ay, startlen, max_x, max_y, oldlen; |
1051 | int startlen, oldlen; |
1054 | int estartlen, eoldlen; |
1052 | int estartlen, eoldlen; |
1055 | uint8 eentrysize; |
1053 | uint8 eentrysize; |
1056 | uint16 ewhatstart, ewhatflag; |
1054 | uint16 ewhatstart, ewhatflag; |
1057 | uint8 extendedinfos; |
1055 | uint8 extendedinfos; |
1058 | |
1056 | |
… | |
… | |
1115 | << uint8 (eentrysize); |
1113 | << uint8 (eentrysize); |
1116 | |
1114 | |
1117 | estartlen = esl.length (); |
1115 | estartlen = esl.length (); |
1118 | } |
1116 | } |
1119 | |
1117 | |
1120 | /* x,y are the real map locations. ax, ay are viewport relative |
|
|
1121 | * locations. |
|
|
1122 | */ |
|
|
1123 | ay = 0; |
|
|
1124 | |
|
|
1125 | /* We could do this logic as conditionals in the if statement, |
1118 | /* We could do this logic as conditionals in the if statement, |
1126 | * but that started to get a bit messy to look at. |
1119 | * but that started to get a bit messy to look at. |
1127 | */ |
1120 | */ |
1128 | max_x = ob->x + (socket.mapx + 1) / 2; |
1121 | int hx = socket.mapx / 2; |
1129 | max_y = ob->y + (socket.mapy + 1) / 2; |
1122 | int hy = socket.mapy / 2; |
1130 | |
1123 | |
1131 | for (y = ob->y - socket.mapy / 2; y < max_y; y++, ay++) |
1124 | for (int dx = -hx; dx <= hx; dx++) |
1132 | { |
1125 | { |
1133 | sint16 nx, ny; |
1126 | sint16 nx, ny; |
1134 | maptile *m = 0; |
1127 | maptile *m = 0; |
1135 | |
1128 | |
1136 | ax = 0; |
1129 | for (int dy = -hy; dy <= hy; dy++) |
1137 | for (x = ob->x - socket.mapx / 2; x < max_x; x++, ax++) |
|
|
1138 | { |
1130 | { |
1139 | // check to see if we can simply go one right quickly |
1131 | // check to see if we can simply go one down quickly |
1140 | ++nx; |
|
|
1141 | if (m && nx >= m->width) |
1132 | if (m && ++ny >= m->height) |
1142 | m = 0; |
1133 | m = 0; |
1143 | |
1134 | |
|
|
1135 | // no, so do it the slow way |
1144 | if (!m) |
1136 | if (!m) |
1145 | { |
1137 | { |
1146 | nx = x; ny = y; m = plmap; |
1138 | nx = ob->x + dx; ny = ob->y + dy; m = ob->map; |
1147 | |
1139 | |
1148 | if (xy_normalise (m, nx, ny)) |
1140 | if (xy_normalise (m, nx, ny)) |
1149 | m->touch (); |
1141 | m->touch (); |
1150 | else |
1142 | else |
1151 | m = 0; |
1143 | m = 0; |
1152 | } |
1144 | } |
1153 | |
1145 | |
|
|
1146 | int ax = dx + hx; |
|
|
1147 | int ay = dy + hy; |
|
|
1148 | |
1154 | int emask, mask; |
1149 | int emask, mask; |
1155 | emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1150 | emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; |
1156 | |
1151 | |
1157 | MapCell &lastcell = socket.lastmap.cells[ax][ay]; |
1152 | MapCell &lastcell = socket.lastmap.cells[ax][ay]; |
1158 | |
1153 | |
1159 | /* 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, |
1160 | * we tell the client as such |
1155 | * we tell the client as such |
1161 | */ |
1156 | */ |
1162 | if (!m) |
1157 | if (!m) |
1163 | { |
1158 | { |
1164 | /* space is out of map. Update space and clear values |
1159 | /* space is out of map. Update space and clear values |
1165 | * 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 |
1166 | * of the map, it shouldn't have a head |
1161 | * of the map, it shouldn't have a head. |
1167 | */ |
1162 | */ |
1168 | if (lastcell.count != -1) |
1163 | if (lastcell.count != -1) |
1169 | { |
1164 | { |
1170 | sl << uint16 (mask); |
1165 | sl << uint16 (mask); |
1171 | map_clearcell (&lastcell, -1); |
1166 | map_clearcell (&lastcell, -1); |
1172 | } |
1167 | } |
1173 | |
1168 | |
1174 | continue; |
1169 | continue; |
1175 | } |
1170 | } |
1176 | |
1171 | |
1177 | int d = pl->blocked_los[ax][ay]; |
1172 | int d = pl->blocked_los_uc (dx, dy); |
1178 | |
1173 | |
1179 | if (d > 3) |
1174 | if (d > 3) |
1180 | { |
1175 | { |
1181 | int need_send = 0, count; |
1176 | int need_send = 0, count; |
1182 | |
1177 | |
… | |
… | |
1328 | |
1323 | |
1329 | /* Middle face */ |
1324 | /* Middle face */ |
1330 | if (update_space (sl, socket, ms, lastcell, 1)) |
1325 | if (update_space (sl, socket, ms, lastcell, 1)) |
1331 | mask |= 0x2; |
1326 | mask |= 0x2; |
1332 | |
1327 | |
|
|
1328 | if (ob->invisible |
|
|
1329 | && ob->invisible & (ob->invisible < 50 ? 1 : 7) |
1333 | if (ms.player () == ob |
1330 | && ms.player () == ob) |
1334 | && (ob->invisible & (ob->invisible < 50 ? 1 : 7))) |
|
|
1335 | { |
1331 | { |
1336 | // force player to be visible to himself if invisible |
1332 | // force player to be visible to himself if invisible |
1337 | if (lastcell.faces[0] != ob->face) |
1333 | if (lastcell.faces[0] != ob->face) |
1338 | { |
1334 | { |
1339 | lastcell.faces[0] = ob->face; |
1335 | lastcell.faces[0] = ob->face; |
… | |
… | |
1435 | { |
1431 | { |
1436 | packet sl; |
1432 | packet sl; |
1437 | sl << "replyinfo skill_info\n"; |
1433 | sl << "replyinfo skill_info\n"; |
1438 | |
1434 | |
1439 | for (int i = 1; i < NUM_SKILLS; i++) |
1435 | for (int i = 1; i < NUM_SKILLS; i++) |
1440 | 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]); |
1441 | |
1437 | |
1442 | if (sl.length () > MAXSOCKBUF) |
1438 | if (sl.length () > MAXSOCKBUF) |
1443 | { |
1439 | { |
1444 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
1440 | LOG (llevError, "Buffer overflow in send_skill_info!\n"); |
1445 | fatal (0); |
1441 | fatal (0); |
… | |
… | |
1563 | 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); |
1564 | 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); |
1565 | |
1561 | |
1566 | /* figure out which skill it uses, if it uses one */ |
1562 | /* figure out which skill it uses, if it uses one */ |
1567 | if (spell->skill) |
1563 | if (spell->skill) |
1568 | { |
1564 | if (object *tmp = pl->find_skill (spell->skill)) |
1569 | for (i = 1; i < NUM_SKILLS; i++) |
|
|
1570 | if (!strcmp (spell->skill, skill_names[i])) |
|
|
1571 | { |
|
|
1572 | skill = i + CS_STAT_SKILLINFO; |
1565 | skill = tmp->subtype + CS_STAT_SKILLINFO; |
1573 | break; |
|
|
1574 | } |
|
|
1575 | } |
|
|
1576 | |
1566 | |
1577 | // spells better have a face |
1567 | // spells better have a face |
1578 | if (!spell->face) |
1568 | if (!spell->face) |
1579 | { |
1569 | { |
1580 | 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); |