1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_init_c = |
|
|
4 | * "$Id: request.C,v 1.18 2006/09/14 19:08:41 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2001 Mark Wedel |
4 | Copyright (C) 2001 Mark Wedel |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
22 | |
16 | |
23 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
20 | |
27 | The author can be reached via e-mail to crossfire-devel@real-time.com |
21 | The author can be reached via e-mail to <crossfire@schmorp.de> |
28 | */ |
22 | */ |
29 | |
23 | |
30 | /** |
24 | /** |
31 | * \file |
25 | * \file |
32 | * Client handling. |
26 | * Client handling. |
… | |
… | |
264 | if (!strncmp (buf, "spatial ", 8)) |
258 | if (!strncmp (buf, "spatial ", 8)) |
265 | { |
259 | { |
266 | buf += 8; |
260 | buf += 8; |
267 | |
261 | |
268 | // initial map and its origin |
262 | // initial map and its origin |
269 | mapstruct *map = pl->ob->map; |
263 | maptile *map = pl->ob->map; |
270 | sint16 dx, dy; |
264 | sint16 dx, dy; |
271 | int mapx = pl->socket.mapx / 2 - pl->ob->x; |
265 | int mapx = pl->socket.mapx / 2 - pl->ob->x; |
272 | int mapy = pl->socket.mapy / 2 - pl->ob->y; |
266 | int mapy = pl->socket.mapy / 2 - pl->ob->y; |
273 | int max_distance = 8; // limit maximum path length to something generous |
267 | int max_distance = 8; // limit maximum path length to something generous |
274 | |
268 | |
… | |
… | |
1137 | AddIfShort (pl->last_stats.Wis, pl->ob->stats.Wis, CS_STAT_WIS); |
1131 | AddIfShort (pl->last_stats.Wis, pl->ob->stats.Wis, CS_STAT_WIS); |
1138 | AddIfShort (pl->last_stats.Dex, pl->ob->stats.Dex, CS_STAT_DEX); |
1132 | AddIfShort (pl->last_stats.Dex, pl->ob->stats.Dex, CS_STAT_DEX); |
1139 | AddIfShort (pl->last_stats.Con, pl->ob->stats.Con, CS_STAT_CON); |
1133 | AddIfShort (pl->last_stats.Con, pl->ob->stats.Con, CS_STAT_CON); |
1140 | AddIfShort (pl->last_stats.Cha, pl->ob->stats.Cha, CS_STAT_CHA); |
1134 | AddIfShort (pl->last_stats.Cha, pl->ob->stats.Cha, CS_STAT_CHA); |
1141 | } |
1135 | } |
|
|
1136 | |
1142 | if (pl->socket.exp64) |
1137 | if (pl->socket.exp64) |
1143 | { |
1138 | { |
1144 | uint8 s; |
1139 | uint8 s; |
1145 | |
1140 | |
1146 | for (s = 0; s < NUM_SKILLS; s++) |
1141 | for (s = 0; s < NUM_SKILLS; s++) |
… | |
… | |
1156 | SockList_AddInt64 (&sl, pl->last_skill_ob[s]->stats.exp); |
1151 | SockList_AddInt64 (&sl, pl->last_skill_ob[s]->stats.exp); |
1157 | pl->last_skill_exp[s] = pl->last_skill_ob[s]->stats.exp; |
1152 | pl->last_skill_exp[s] = pl->last_skill_ob[s]->stats.exp; |
1158 | } |
1153 | } |
1159 | } |
1154 | } |
1160 | } |
1155 | } |
|
|
1156 | |
1161 | if (pl->socket.exp64) |
1157 | if (pl->socket.exp64) |
1162 | { |
|
|
1163 | AddIfInt64 (pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP64); |
1158 | { AddIfInt64 (pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP64) } |
1164 | } |
|
|
1165 | else |
1159 | else |
1166 | { |
|
|
1167 | AddIfInt (pl->last_stats.exp, (int) pl->ob->stats.exp, CS_STAT_EXP); |
1160 | { AddIfInt (pl->last_stats.exp, (int) pl->ob->stats.exp, CS_STAT_EXP) } |
1168 | } |
1161 | |
1169 | AddIfShort (pl->last_level, (char) pl->ob->level, CS_STAT_LEVEL); |
1162 | AddIfShort (pl->last_level, (char) pl->ob->level, CS_STAT_LEVEL); |
1170 | AddIfShort (pl->last_stats.wc, pl->ob->stats.wc, CS_STAT_WC); |
1163 | AddIfShort (pl->last_stats.wc, pl->ob->stats.wc, CS_STAT_WC); |
1171 | AddIfShort (pl->last_stats.ac, pl->ob->stats.ac, CS_STAT_AC); |
1164 | AddIfShort (pl->last_stats.ac, pl->ob->stats.ac, CS_STAT_AC); |
1172 | AddIfShort (pl->last_stats.dam, pl->ob->stats.dam, CS_STAT_DAM); |
1165 | AddIfShort (pl->last_stats.dam, pl->ob->stats.dam, CS_STAT_DAM); |
1173 | AddIfFloat (pl->last_speed, pl->ob->speed, CS_STAT_SPEED); |
1166 | AddIfFloat (pl->last_speed, pl->ob->speed, CS_STAT_SPEED); |
1174 | AddIfShort (pl->last_stats.food, pl->ob->stats.food, CS_STAT_FOOD); |
1167 | AddIfShort (pl->last_stats.food, pl->ob->stats.food, CS_STAT_FOOD); |
1175 | AddIfFloat (pl->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP); |
1168 | AddIfFloat (pl->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP); |
1176 | AddIfInt (pl->last_weight_limit, (sint32) weight_limit[pl->ob->stats.Str], CS_STAT_WEIGHT_LIM); |
1169 | AddIfInt (pl->last_weight_limit, (sint32) weight_limit[pl->ob->stats.Str], CS_STAT_WEIGHT_LIM); |
1177 | flags = 0; |
1170 | flags = 0; |
|
|
1171 | |
1178 | if (pl->fire_on) |
1172 | if (pl->fire_on) |
1179 | flags |= SF_FIREON; |
1173 | flags |= SF_FIREON; |
|
|
1174 | |
1180 | if (pl->run_on) |
1175 | if (pl->run_on) |
1181 | flags |= SF_RUNON; |
1176 | flags |= SF_RUNON; |
1182 | |
1177 | |
1183 | AddIfShort (pl->last_flags, flags, CS_STAT_FLAGS); |
1178 | AddIfShort (pl->last_flags, flags, CS_STAT_FLAGS); |
|
|
1179 | |
1184 | if (pl->socket.sc_version < 1025) |
1180 | if (pl->socket.sc_version < 1025) |
1185 | { |
|
|
1186 | AddIfShort (pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR); |
1181 | { AddIfShort (pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR) } |
1187 | } |
|
|
1188 | else |
1182 | else |
1189 | { |
1183 | { |
1190 | int i; |
1184 | int i; |
1191 | |
1185 | |
1192 | for (i = 0; i < NROFATTACKS; i++) |
1186 | for (i = 0; i < NROFATTACKS; i++) |
1193 | { |
1187 | { |
1194 | /* Skip ones we won't send */ |
1188 | /* Skip ones we won't send */ |
1195 | if (atnr_cs_stat[i] == -1) |
1189 | if (atnr_cs_stat[i] == -1) |
1196 | continue; |
1190 | continue; |
|
|
1191 | |
1197 | AddIfShort (pl->last_resist[i], pl->ob->resist[i], (char) atnr_cs_stat[i]); |
1192 | AddIfShort (pl->last_resist[i], pl->ob->resist[i], (char) atnr_cs_stat[i]); |
1198 | } |
1193 | } |
1199 | } |
1194 | } |
|
|
1195 | |
1200 | if (pl->socket.monitor_spells) |
1196 | if (pl->socket.monitor_spells) |
1201 | { |
1197 | { |
1202 | AddIfInt (pl->last_path_attuned, pl->ob->path_attuned, CS_STAT_SPELL_ATTUNE); |
1198 | AddIfInt (pl->last_path_attuned, pl->ob->path_attuned, CS_STAT_SPELL_ATTUNE); |
1203 | AddIfInt (pl->last_path_repelled, pl->ob->path_repelled, CS_STAT_SPELL_REPEL); |
1199 | AddIfInt (pl->last_path_repelled, pl->ob->path_repelled, CS_STAT_SPELL_REPEL); |
1204 | AddIfInt (pl->last_path_denied, pl->ob->path_denied, CS_STAT_SPELL_DENY); |
1200 | AddIfInt (pl->last_path_denied, pl->ob->path_denied, CS_STAT_SPELL_DENY); |
1205 | } |
1201 | } |
|
|
1202 | |
1206 | rangetostring (pl->ob, buf); /* we want use the new fire & run system in new client */ |
1203 | rangetostring (pl->ob, buf); /* we want use the new fire & run system in new client */ |
1207 | AddIfString (pl->socket.stats.range, buf, CS_STAT_RANGE); |
1204 | AddIfString (pl->socket.stats.range, buf, CS_STAT_RANGE); |
1208 | set_title (pl->ob, buf); |
1205 | set_title (pl->ob, buf); |
1209 | AddIfString (pl->socket.stats.title, buf, CS_STAT_TITLE); |
1206 | AddIfString (pl->socket.stats.title, buf, CS_STAT_TITLE); |
1210 | |
1207 | |
… | |
… | |
1214 | #ifdef ESRV_DEBUG |
1211 | #ifdef ESRV_DEBUG |
1215 | LOG (llevDebug, "Sending stats command, %d bytes long.\n", sl.len); |
1212 | LOG (llevDebug, "Sending stats command, %d bytes long.\n", sl.len); |
1216 | #endif |
1213 | #endif |
1217 | Send_With_Handling (&pl->socket, &sl); |
1214 | Send_With_Handling (&pl->socket, &sl); |
1218 | } |
1215 | } |
|
|
1216 | |
1219 | free (sl.buf); |
1217 | free (sl.buf); |
1220 | } |
1218 | } |
1221 | |
|
|
1222 | |
1219 | |
1223 | /** |
1220 | /** |
1224 | * Tells the client that here is a player it should start using. |
1221 | * Tells the client that here is a player it should start using. |
1225 | */ |
1222 | */ |
1226 | void |
1223 | void |
… | |
… | |
1244 | |
1241 | |
1245 | Send_With_Handling (&pl->socket, &sl); |
1242 | Send_With_Handling (&pl->socket, &sl); |
1246 | free (sl.buf); |
1243 | free (sl.buf); |
1247 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
1244 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
1248 | } |
1245 | } |
1249 | |
|
|
1250 | |
1246 | |
1251 | /** |
1247 | /** |
1252 | * Need to send an animation sequence to the client. |
1248 | * Need to send an animation sequence to the client. |
1253 | * We will send appropriate face commands to the client if we haven't |
1249 | * We will send appropriate face commands to the client if we haven't |
1254 | * sent them the face yet (this can become quite costly in terms of |
1250 | * sent them the face yet (this can become quite costly in terms of |
… | |
… | |
1547 | * the case, it seems to make more sense to have these layer values |
1543 | * the case, it seems to make more sense to have these layer values |
1548 | * actually match. |
1544 | * actually match. |
1549 | */ |
1545 | */ |
1550 | |
1546 | |
1551 | static int |
1547 | static int |
1552 | update_space (SockList * sl, NewSocket * ns, mapstruct *mp, int mx, int my, int sx, int sy, int layer) |
1548 | update_space (SockList * sl, NewSocket * ns, maptile *mp, int mx, int my, int sx, int sy, int layer) |
1553 | { |
1549 | { |
1554 | object *ob, *head; |
1550 | object *ob, *head; |
1555 | uint16 face_num; |
1551 | uint16 face_num; |
1556 | int bx, by, i; |
1552 | int bx, by, i; |
1557 | |
1553 | |
… | |
… | |
1771 | * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ |
1767 | * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ |
1772 | * take. |
1768 | * take. |
1773 | */ |
1769 | */ |
1774 | |
1770 | |
1775 | static inline int |
1771 | static inline int |
1776 | update_smooth (SockList * sl, NewSocket * ns, mapstruct *mp, int mx, int my, int sx, int sy, int layer) |
1772 | update_smooth (SockList * sl, NewSocket * ns, maptile *mp, int mx, int my, int sx, int sy, int layer) |
1777 | { |
1773 | { |
1778 | object *ob; |
1774 | object *ob; |
1779 | int smoothlevel; /* old face_num; */ |
1775 | int smoothlevel; /* old face_num; */ |
1780 | |
1776 | |
1781 | ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); |
1777 | ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); |
… | |
… | |
1859 | SockList esl; /*For extended Map info */ |
1855 | SockList esl; /*For extended Map info */ |
1860 | uint16 mask, emask; |
1856 | uint16 mask, emask; |
1861 | uint8 eentrysize; |
1857 | uint8 eentrysize; |
1862 | uint16 ewhatstart, ewhatflag; |
1858 | uint16 ewhatstart, ewhatflag; |
1863 | uint8 extendedinfos; |
1859 | uint8 extendedinfos; |
1864 | mapstruct *m; |
1860 | maptile *m; |
1865 | |
1861 | |
1866 | NewSocket & socket = pl->contr->socket; |
1862 | NewSocket & socket = pl->contr->socket; |
1867 | |
1863 | |
1868 | check_map_change (pl->contr); |
1864 | check_map_change (pl->contr); |
1869 | |
1865 | |
… | |
… | |
2132 | SockList_AddChar (&sl, 6); |
2128 | SockList_AddChar (&sl, 6); |
2133 | SockList_AddChar (&sl, stat_width); |
2129 | SockList_AddChar (&sl, stat_width); |
2134 | } |
2130 | } |
2135 | } |
2131 | } |
2136 | |
2132 | |
2137 | if (lastcell.player !=player) |
2133 | if (lastcell.player != player) |
2138 | { |
2134 | { |
2139 | lastcell.player = player; |
2135 | lastcell.player = player; |
2140 | |
2136 | |
2141 | mask |= 0x8; |
2137 | mask |= 0x8; |
2142 | *last_ext |= 0x80; |
2138 | *last_ext |= 0x80; |
… | |
… | |
2247 | sint16 ax, ay, nx, ny; /* ax and ay goes from 0 to max-size of arrays */ |
2243 | sint16 ax, ay, nx, ny; /* ax and ay goes from 0 to max-size of arrays */ |
2248 | New_Face *face, *floor; |
2244 | New_Face *face, *floor; |
2249 | New_Face *floor2; |
2245 | New_Face *floor2; |
2250 | int d, mflags; |
2246 | int d, mflags; |
2251 | struct Map newmap; |
2247 | struct Map newmap; |
2252 | mapstruct *m, *pm; |
2248 | maptile *m, *pm; |
2253 | |
2249 | |
2254 | if (pl->type != PLAYER) |
2250 | if (pl->type != PLAYER) |
2255 | { |
2251 | { |
2256 | LOG (llevError, "draw_client_map called with non player/non eric-server\n"); |
2252 | LOG (llevError, "draw_client_map called with non player/non eric-server\n"); |
2257 | return; |
2253 | return; |