1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_init_c = |
|
|
4 | * "$Id: request.C,v 1.16 2006/09/10 13:43:33 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. |
… | |
… | |
50 | * operations |
44 | * operations |
51 | * |
45 | * |
52 | * esrv_map_doneredraw finishes the map update, and ships across the |
46 | * esrv_map_doneredraw finishes the map update, and ships across the |
53 | * map updates. |
47 | * map updates. |
54 | * |
48 | * |
55 | * esrv_map_scroll tells the client to scroll the map, and does similarily |
|
|
56 | * for the locally cached copy. |
|
|
57 | */ |
49 | */ |
58 | |
50 | |
59 | #include <global.h> |
51 | #include <global.h> |
60 | #include <sproto.h> |
52 | #include <sproto.h> |
61 | |
53 | |
… | |
… | |
266 | if (!strncmp (buf, "spatial ", 8)) |
258 | if (!strncmp (buf, "spatial ", 8)) |
267 | { |
259 | { |
268 | buf += 8; |
260 | buf += 8; |
269 | |
261 | |
270 | // initial map and its origin |
262 | // initial map and its origin |
271 | mapstruct *map = pl->ob->map; |
263 | maptile *map = pl->ob->map; |
272 | sint16 dx, dy; |
264 | sint16 dx, dy; |
273 | int mapx = pl->socket.mapx / 2 - pl->ob->x; |
265 | int mapx = pl->socket.mapx / 2 - pl->ob->x; |
274 | int mapy = pl->socket.mapy / 2 - pl->ob->y; |
266 | int mapy = pl->socket.mapy / 2 - pl->ob->y; |
275 | int max_distance = 8; // limit maximum path length to something generous |
267 | int max_distance = 8; // limit maximum path length to something generous |
276 | |
268 | |
… | |
… | |
581 | char command[50]; |
573 | char command[50]; |
582 | int info, nextinfo; |
574 | int info, nextinfo; |
583 | |
575 | |
584 | cmdback[0] = '\0'; |
576 | cmdback[0] = '\0'; |
585 | nextinfo = 0; |
577 | nextinfo = 0; |
|
|
578 | |
586 | while (1) |
579 | while (1) |
587 | { |
580 | { |
588 | /* 1. Extract an info */ |
581 | /* 1. Extract an info */ |
589 | info = nextinfo; |
582 | info = nextinfo; |
|
|
583 | |
590 | while ((info < len) && (buf[info] == ' ')) |
584 | while ((info < len) && (buf[info] == ' ')) |
591 | info++; |
585 | info++; |
|
|
586 | |
592 | if (info >= len) |
587 | if (info >= len) |
593 | break; |
588 | break; |
|
|
589 | |
594 | nextinfo = info + 1; |
590 | nextinfo = info + 1; |
|
|
591 | |
595 | while ((nextinfo < len) && (buf[nextinfo] != ' ')) |
592 | while ((nextinfo < len) && (buf[nextinfo] != ' ')) |
596 | nextinfo++; |
593 | nextinfo++; |
|
|
594 | |
597 | if (nextinfo - info >= 49) /*Erroneous info asked */ |
595 | if (nextinfo - info >= 49) /*Erroneous info asked */ |
598 | continue; |
596 | continue; |
|
|
597 | |
599 | strncpy (command, &(buf[info]), nextinfo - info); |
598 | strncpy (command, &(buf[info]), nextinfo - info); |
600 | command[nextinfo - info] = '\0'; |
599 | |
601 | /* 2. Interpret info */ |
600 | /* 2. Interpret info */ |
602 | if (!strcmp ("smooth", command)) |
601 | if (!strcmp ("smooth", command)) |
603 | { |
|
|
604 | /* Toggle smoothing */ |
602 | /* Toggle smoothing */ |
605 | ns->EMI_smooth = !ns->EMI_smooth; |
603 | ns->EMI_smooth = !ns->EMI_smooth; |
606 | } |
|
|
607 | else |
604 | else |
608 | { |
|
|
609 | /*bad value */ |
605 | /*bad value */; |
610 | } |
606 | |
611 | /*3. Next info */ |
607 | /*3. Next info */ |
612 | } |
608 | } |
|
|
609 | |
613 | strcpy (cmdback, "ExtendedInfoSet"); |
610 | strcpy (cmdback, "ExtendedInfoSet"); |
|
|
611 | |
614 | if (ns->EMI_smooth) |
612 | if (ns->EMI_smooth) |
615 | { |
613 | { |
616 | strcat (cmdback, " "); |
614 | strcat (cmdback, " "); |
617 | strcat (cmdback, "smoothing"); |
615 | strcat (cmdback, "smoothing"); |
618 | } |
616 | } |
|
|
617 | |
619 | Write_String_To_Socket (ns, cmdback, strlen (cmdback)); |
618 | Write_String_To_Socket (ns, cmdback, strlen (cmdback)); |
620 | } |
619 | } |
621 | |
620 | |
622 | /* |
621 | /* |
623 | #define MSG_TYPE_BOOK 1 |
622 | #define MSG_TYPE_BOOK 1 |
… | |
… | |
635 | char temp[10]; |
634 | char temp[10]; |
636 | char command[50]; |
635 | char command[50]; |
637 | int info, nextinfo, i, flag; |
636 | int info, nextinfo, i, flag; |
638 | |
637 | |
639 | cmdback[0] = '\0'; |
638 | cmdback[0] = '\0'; |
|
|
639 | |
640 | nextinfo = 0; |
640 | nextinfo = 0; |
641 | while (1) |
641 | while (1) |
642 | { |
642 | { |
643 | /* 1. Extract an info */ |
643 | /* 1. Extract an info */ |
644 | info = nextinfo; |
644 | info = nextinfo; |
|
|
645 | |
645 | while ((info < len) && (buf[info] == ' ')) |
646 | while ((info < len) && (buf[info] == ' ')) |
646 | info++; |
647 | info++; |
|
|
648 | |
647 | if (info >= len) |
649 | if (info >= len) |
648 | break; |
650 | break; |
|
|
651 | |
649 | nextinfo = info + 1; |
652 | nextinfo = info + 1; |
|
|
653 | |
650 | while ((nextinfo < len) && (buf[nextinfo] != ' ')) |
654 | while ((nextinfo < len) && (buf[nextinfo] != ' ')) |
651 | nextinfo++; |
655 | nextinfo++; |
|
|
656 | |
652 | if (nextinfo - info >= 49) /*Erroneous info asked */ |
657 | if (nextinfo - info >= 49) /*Erroneous info asked */ |
653 | continue; |
658 | continue; |
|
|
659 | |
654 | strncpy (command, &(buf[info]), nextinfo - info); |
660 | strncpy (command, &(buf[info]), nextinfo - info); |
655 | command[nextinfo - info] = '\0'; |
661 | command[nextinfo - info] = '\0'; |
656 | /* 2. Interpret info */ |
662 | /* 2. Interpret info */ |
657 | i = sscanf (command, "%d", &flag); |
663 | i = sscanf (command, "%d", &flag); |
|
|
664 | |
658 | if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) |
665 | if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) |
659 | ns->supported_readables |= (1 << flag); |
666 | ns->supported_readables |= (1 << flag); |
660 | /*3. Next info */ |
667 | /*3. Next info */ |
661 | } |
668 | } |
|
|
669 | |
662 | /* Send resulting state */ |
670 | /* Send resulting state */ |
663 | strcpy (cmdback, "ExtendedTextSet"); |
671 | strcpy (cmdback, "ExtendedTextSet"); |
|
|
672 | |
664 | for (i = 0; i <= MSG_TYPE_LAST; i++) |
673 | for (i = 0; i <= MSG_TYPE_LAST; i++) |
665 | if (ns->supported_readables & (1 << i)) |
674 | if (ns->supported_readables & (1 << i)) |
666 | { |
675 | { |
667 | strcat (cmdback, " "); |
676 | strcat (cmdback, " "); |
668 | snprintf (temp, sizeof (temp), "%d", i); |
677 | snprintf (temp, sizeof (temp), "%d", i); |
669 | strcat (cmdback, temp); |
678 | strcat (cmdback, temp); |
670 | } |
679 | } |
|
|
680 | |
671 | Write_String_To_Socket (ns, cmdback, strlen (cmdback)); |
681 | Write_String_To_Socket (ns, cmdback, strlen (cmdback)); |
672 | } |
682 | } |
673 | |
683 | |
674 | /** |
684 | /** |
675 | * A lot like the old AskSmooth (in fact, now called by AskSmooth). |
685 | * A lot like the old AskSmooth (in fact, now called by AskSmooth). |
… | |
… | |
1121 | 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); |
1122 | 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); |
1123 | 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); |
1124 | 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); |
1125 | } |
1135 | } |
|
|
1136 | |
1126 | if (pl->socket.exp64) |
1137 | if (pl->socket.exp64) |
1127 | { |
1138 | { |
1128 | uint8 s; |
1139 | uint8 s; |
1129 | |
1140 | |
1130 | for (s = 0; s < NUM_SKILLS; s++) |
1141 | for (s = 0; s < NUM_SKILLS; s++) |
… | |
… | |
1140 | SockList_AddInt64 (&sl, pl->last_skill_ob[s]->stats.exp); |
1151 | SockList_AddInt64 (&sl, pl->last_skill_ob[s]->stats.exp); |
1141 | 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; |
1142 | } |
1153 | } |
1143 | } |
1154 | } |
1144 | } |
1155 | } |
|
|
1156 | |
1145 | if (pl->socket.exp64) |
1157 | if (pl->socket.exp64) |
1146 | { |
|
|
1147 | 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) } |
1148 | } |
|
|
1149 | else |
1159 | else |
1150 | { |
|
|
1151 | 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) } |
1152 | } |
1161 | |
1153 | AddIfShort (pl->last_level, (char) pl->ob->level, CS_STAT_LEVEL); |
1162 | AddIfShort (pl->last_level, (char) pl->ob->level, CS_STAT_LEVEL); |
1154 | 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); |
1155 | 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); |
1156 | 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); |
1157 | AddIfFloat (pl->last_speed, pl->ob->speed, CS_STAT_SPEED); |
1166 | AddIfFloat (pl->last_speed, pl->ob->speed, CS_STAT_SPEED); |
1158 | 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); |
1159 | 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); |
1160 | 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); |
1161 | flags = 0; |
1170 | flags = 0; |
|
|
1171 | |
1162 | if (pl->fire_on) |
1172 | if (pl->fire_on) |
1163 | flags |= SF_FIREON; |
1173 | flags |= SF_FIREON; |
|
|
1174 | |
1164 | if (pl->run_on) |
1175 | if (pl->run_on) |
1165 | flags |= SF_RUNON; |
1176 | flags |= SF_RUNON; |
1166 | |
1177 | |
1167 | AddIfShort (pl->last_flags, flags, CS_STAT_FLAGS); |
1178 | AddIfShort (pl->last_flags, flags, CS_STAT_FLAGS); |
|
|
1179 | |
1168 | if (pl->socket.sc_version < 1025) |
1180 | if (pl->socket.sc_version < 1025) |
1169 | { |
|
|
1170 | 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) } |
1171 | } |
|
|
1172 | else |
1182 | else |
1173 | { |
1183 | { |
1174 | int i; |
1184 | int i; |
1175 | |
1185 | |
1176 | for (i = 0; i < NROFATTACKS; i++) |
1186 | for (i = 0; i < NROFATTACKS; i++) |
1177 | { |
1187 | { |
1178 | /* Skip ones we won't send */ |
1188 | /* Skip ones we won't send */ |
1179 | if (atnr_cs_stat[i] == -1) |
1189 | if (atnr_cs_stat[i] == -1) |
1180 | continue; |
1190 | continue; |
|
|
1191 | |
1181 | 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]); |
1182 | } |
1193 | } |
1183 | } |
1194 | } |
|
|
1195 | |
1184 | if (pl->socket.monitor_spells) |
1196 | if (pl->socket.monitor_spells) |
1185 | { |
1197 | { |
1186 | 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); |
1187 | 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); |
1188 | 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); |
1189 | } |
1201 | } |
|
|
1202 | |
1190 | 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 */ |
1191 | AddIfString (pl->socket.stats.range, buf, CS_STAT_RANGE); |
1204 | AddIfString (pl->socket.stats.range, buf, CS_STAT_RANGE); |
1192 | set_title (pl->ob, buf); |
1205 | set_title (pl->ob, buf); |
1193 | AddIfString (pl->socket.stats.title, buf, CS_STAT_TITLE); |
1206 | AddIfString (pl->socket.stats.title, buf, CS_STAT_TITLE); |
1194 | |
1207 | |
… | |
… | |
1198 | #ifdef ESRV_DEBUG |
1211 | #ifdef ESRV_DEBUG |
1199 | LOG (llevDebug, "Sending stats command, %d bytes long.\n", sl.len); |
1212 | LOG (llevDebug, "Sending stats command, %d bytes long.\n", sl.len); |
1200 | #endif |
1213 | #endif |
1201 | Send_With_Handling (&pl->socket, &sl); |
1214 | Send_With_Handling (&pl->socket, &sl); |
1202 | } |
1215 | } |
|
|
1216 | |
1203 | free (sl.buf); |
1217 | free (sl.buf); |
1204 | } |
1218 | } |
1205 | |
|
|
1206 | |
1219 | |
1207 | /** |
1220 | /** |
1208 | * 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. |
1209 | */ |
1222 | */ |
1210 | void |
1223 | void |
… | |
… | |
1228 | |
1241 | |
1229 | Send_With_Handling (&pl->socket, &sl); |
1242 | Send_With_Handling (&pl->socket, &sl); |
1230 | free (sl.buf); |
1243 | free (sl.buf); |
1231 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
1244 | SET_FLAG (pl->ob, FLAG_CLIENT_SENT); |
1232 | } |
1245 | } |
1233 | |
|
|
1234 | |
1246 | |
1235 | /** |
1247 | /** |
1236 | * Need to send an animation sequence to the client. |
1248 | * Need to send an animation sequence to the client. |
1237 | * 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 |
1238 | * 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 |
… | |
… | |
1426 | |
1438 | |
1427 | if (sl.len > (int) strlen ("map ") || ns->sent_scroll) |
1439 | if (sl.len > (int) strlen ("map ") || ns->sent_scroll) |
1428 | { |
1440 | { |
1429 | /* All of this is just accounting stuff */ |
1441 | /* All of this is just accounting stuff */ |
1430 | if (tframes > 100) |
1442 | if (tframes > 100) |
1431 | { |
|
|
1432 | tframes = tbytes = 0; |
1443 | tframes = tbytes = 0; |
1433 | } |
1444 | |
1434 | tframes++; |
1445 | tframes++; |
1435 | frames++; |
1446 | frames++; |
1436 | tbytes += sl.len; |
1447 | tbytes += sl.len; |
1437 | bytes += sl.len; |
1448 | bytes += sl.len; |
1438 | memcpy (&ns->lastmap, newmap, sizeof (struct Map)); |
1449 | memcpy (&ns->lastmap, newmap, sizeof (struct Map)); |
1439 | Send_With_Handling (ns, &sl); |
1450 | Send_With_Handling (ns, &sl); |
1440 | ns->sent_scroll = 0; |
1451 | ns->sent_scroll = 0; |
1441 | } |
1452 | } |
|
|
1453 | |
1442 | free (sl.buf); |
1454 | free (sl.buf); |
1443 | } |
1455 | } |
1444 | |
1456 | |
1445 | |
1457 | |
1446 | /** Clears a map cell */ |
1458 | /** Clears a map cell */ |
… | |
… | |
1531 | * 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 |
1532 | * actually match. |
1544 | * actually match. |
1533 | */ |
1545 | */ |
1534 | |
1546 | |
1535 | static int |
1547 | static int |
1536 | 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) |
1537 | { |
1549 | { |
1538 | object *ob, *head; |
1550 | object *ob, *head; |
1539 | uint16 face_num; |
1551 | uint16 face_num; |
1540 | int bx, by, i; |
1552 | int bx, by, i; |
1541 | |
1553 | |
… | |
… | |
1755 | * 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 |
1756 | * take. |
1768 | * take. |
1757 | */ |
1769 | */ |
1758 | |
1770 | |
1759 | static inline int |
1771 | static inline int |
1760 | 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) |
1761 | { |
1773 | { |
1762 | object *ob; |
1774 | object *ob; |
1763 | int smoothlevel; /* old face_num; */ |
1775 | int smoothlevel; /* old face_num; */ |
1764 | |
1776 | |
1765 | ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); |
1777 | ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); |
… | |
… | |
1843 | SockList esl; /*For extended Map info */ |
1855 | SockList esl; /*For extended Map info */ |
1844 | uint16 mask, emask; |
1856 | uint16 mask, emask; |
1845 | uint8 eentrysize; |
1857 | uint8 eentrysize; |
1846 | uint16 ewhatstart, ewhatflag; |
1858 | uint16 ewhatstart, ewhatflag; |
1847 | uint8 extendedinfos; |
1859 | uint8 extendedinfos; |
1848 | mapstruct *m; |
1860 | maptile *m; |
1849 | |
1861 | |
1850 | NewSocket & socket = pl->contr->socket; |
1862 | NewSocket & socket = pl->contr->socket; |
1851 | |
1863 | |
1852 | check_map_change (pl->contr); |
1864 | check_map_change (pl->contr); |
1853 | |
1865 | |
… | |
… | |
2076 | |
2088 | |
2077 | if (socket.extmap) |
2089 | if (socket.extmap) |
2078 | { |
2090 | { |
2079 | uint8 stat_hp = 0; |
2091 | uint8 stat_hp = 0; |
2080 | uint8 stat_width = 0; |
2092 | uint8 stat_width = 0; |
|
|
2093 | uint8 flags = 0; |
2081 | tag_t player = 0; |
2094 | tag_t player = 0; |
2082 | |
2095 | |
2083 | // send hp information, if applicable |
2096 | // send hp information, if applicable |
2084 | if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) |
2097 | if (object *op = GET_MAP_FACE_OBJ (m, nx, ny, 0)) |
2085 | { |
2098 | { |
… | |
… | |
2093 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
2106 | stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; |
2094 | stat_width = op->arch->tail_x; |
2107 | stat_width = op->arch->tail_x; |
2095 | } |
2108 | } |
2096 | } |
2109 | } |
2097 | |
2110 | |
|
|
2111 | if (op->msg && op->msg[0] == '@') |
|
|
2112 | flags |= 1; |
|
|
2113 | |
2098 | if (op->type == PLAYER && op != pl) |
2114 | if (op->type == PLAYER && op != pl) |
2099 | player = op->count; |
2115 | player = op->count; |
2100 | } |
2116 | } |
2101 | |
2117 | |
2102 | if (lastcell.stat_hp != stat_hp) |
2118 | if (lastcell.stat_hp != stat_hp) |
… | |
… | |
2116 | SockList_AddChar (&sl, 6); |
2132 | SockList_AddChar (&sl, 6); |
2117 | SockList_AddChar (&sl, stat_width); |
2133 | SockList_AddChar (&sl, stat_width); |
2118 | } |
2134 | } |
2119 | } |
2135 | } |
2120 | |
2136 | |
2121 | if (lastcell.player !=player) |
2137 | if (lastcell.player != player) |
2122 | { |
2138 | { |
2123 | lastcell.player = player; |
2139 | lastcell.player = player; |
2124 | |
2140 | |
2125 | mask |= 0x8; |
2141 | mask |= 0x8; |
2126 | *last_ext |= 0x80; |
2142 | *last_ext |= 0x80; |
2127 | last_ext = sl.buf + sl.len; |
2143 | last_ext = sl.buf + sl.len; |
2128 | SockList_AddChar (&sl, 0x47); |
2144 | SockList_AddChar (&sl, 0x47); |
2129 | SockList_AddChar (&sl, 4); |
2145 | SockList_AddChar (&sl, 4); |
2130 | SockList_AddInt (&sl, player); |
2146 | SockList_AddInt (&sl, player); |
|
|
2147 | } |
|
|
2148 | |
|
|
2149 | if (lastcell.flags != flags) |
|
|
2150 | { |
|
|
2151 | lastcell.flags = flags; |
|
|
2152 | |
|
|
2153 | mask |= 0x8; |
|
|
2154 | *last_ext |= 0x80; |
|
|
2155 | last_ext = sl.buf + sl.len; |
|
|
2156 | SockList_AddChar (&sl, 8); |
|
|
2157 | SockList_AddChar (&sl, flags); |
2131 | } |
2158 | } |
2132 | } |
2159 | } |
2133 | |
2160 | |
2134 | /* Floor face */ |
2161 | /* Floor face */ |
2135 | if (update_space (&sl, &socket, m, nx, ny, ax, ay, 2)) |
2162 | if (update_space (&sl, &socket, m, nx, ny, ax, ay, 2)) |
… | |
… | |
2203 | * it doesn't need draw! |
2230 | * it doesn't need draw! |
2204 | */ |
2231 | */ |
2205 | ewhatflag &= (~EMI_NOREDRAW); |
2232 | ewhatflag &= (~EMI_NOREDRAW); |
2206 | esl.buf[ewhatstart + 1] = ewhatflag & 0xff; |
2233 | esl.buf[ewhatstart + 1] = ewhatflag & 0xff; |
2207 | } |
2234 | } |
|
|
2235 | |
2208 | if (esl.len > estartlen) |
2236 | if (esl.len > estartlen) |
2209 | { |
|
|
2210 | Send_With_Handling (&socket, &esl); |
2237 | Send_With_Handling (&socket, &esl); |
2211 | } |
2238 | |
2212 | free (esl.buf); |
2239 | free (esl.buf); |
2213 | } |
2240 | } |
|
|
2241 | |
2214 | if (sl.len > startlen || socket.sent_scroll) |
2242 | if (sl.len > startlen || socket.sent_scroll) |
2215 | { |
2243 | { |
2216 | Send_With_Handling (&socket, &sl); |
2244 | Send_With_Handling (&socket, &sl); |
2217 | socket.sent_scroll = 0; |
2245 | socket.sent_scroll = 0; |
2218 | } |
2246 | } |
|
|
2247 | |
2219 | free (sl.buf); |
2248 | free (sl.buf); |
2220 | } |
2249 | } |
2221 | |
2250 | |
2222 | /** |
2251 | /** |
2223 | * Draws client map. |
2252 | * Draws client map. |
… | |
… | |
2229 | sint16 ax, ay, nx, ny; /* ax and ay goes from 0 to max-size of arrays */ |
2258 | sint16 ax, ay, nx, ny; /* ax and ay goes from 0 to max-size of arrays */ |
2230 | New_Face *face, *floor; |
2259 | New_Face *face, *floor; |
2231 | New_Face *floor2; |
2260 | New_Face *floor2; |
2232 | int d, mflags; |
2261 | int d, mflags; |
2233 | struct Map newmap; |
2262 | struct Map newmap; |
2234 | mapstruct *m, *pm; |
2263 | maptile *m, *pm; |
2235 | |
2264 | |
2236 | if (pl->type != PLAYER) |
2265 | if (pl->type != PLAYER) |
2237 | { |
2266 | { |
2238 | LOG (llevError, "draw_client_map called with non player/non eric-server\n"); |
2267 | LOG (llevError, "draw_client_map called with non player/non eric-server\n"); |
2239 | return; |
2268 | return; |