… | |
… | |
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 | |