ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/request.C
(Generate patch)

Comparing deliantra/server/socket/request.C (file contents):
Revision 1.146 by root, Sat Dec 27 01:25:00 2008 UTC vs.
Revision 1.153 by root, Wed Nov 4 13:46:37 2009 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001,2007 Mark Wedel 5 * Copyright (©) 2001,2007 Mark Wedel
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 23 */
23 24
24/** 25/**
236 { 237 {
237 *params++ = 0; 238 *params++ = 0;
238 break; 239 break;
239 } 240 }
240 241
241 if (!strcmp (buf, "image_info"))
242 send_image_info (ns, params);
243 else if (!strcmp (buf, "image_sums"))
244 send_image_sums (ns, params);
245 else if (!strcmp (buf, "skill_info")) 242 if (!strcmp (buf, "skill_info"))
246 send_skill_info (ns, params); 243 send_skill_info (ns, params);
247 else if (!strcmp (buf, "spell_paths")) 244 else if (!strcmp (buf, "spell_paths"))
248 send_spell_paths (ns, params); 245 send_spell_paths (ns, params);
249 else 246 else
250 { 247 {
424 while (1) 421 while (1)
425 { 422 {
426 /* 1. Extract an info */ 423 /* 1. Extract an info */
427 info = nextinfo; 424 info = nextinfo;
428 425
429 while ((info < len) && (buf[info] == ' ')) 426 while ((info < len) && (buf [info] == ' '))
430 info++; 427 info++;
431 428
432 if (info >= len) 429 if (info >= len)
433 break; 430 break;
434 431
435 nextinfo = info + 1; 432 nextinfo = info + 1;
436 433
437 while ((nextinfo < len) && (buf[nextinfo] != ' ')) 434 while ((nextinfo < len) && (buf [nextinfo] != ' '))
438 nextinfo++; 435 nextinfo++;
439 436
440 if (nextinfo - info >= 49) /*Erroneous info asked */ 437 if (nextinfo - info >= 49) /*Erroneous info asked */
441 continue; 438 continue;
442 439
443 strncpy (command, &(buf[info]), nextinfo - info); 440 memcpy (command, buf + info, nextinfo - info);
444 command[nextinfo - info] = '\0'; 441 command [nextinfo - info] = 0;
442
445 /* 2. Interpret info */ 443 /* 2. Interpret info */
446 i = sscanf (command, "%d", &flag); 444 i = sscanf (command, "%d", &flag);
447 445
448 if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) 446 if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST))
449 ns->supported_readables |= (1 << flag); 447 ns->supported_readables |= (1 << flag);
483 return; 481 return;
484 482
485 buf++; 483 buf++;
486 } 484 }
487 485
488 execute_newserver_command (pl->ob, (char *) buf); 486 execute_newserver_command (pl->ob, (char *)buf);
489 487
490 /* Perhaps something better should be done with a left over count. 488 /* Perhaps something better should be done with a left over count.
491 * Cleaning up the input should probably be done first - all actions 489 * Cleaning up the input should probably be done first - all actions
492 * for the command that issued the count should be done before any other 490 * for the command that issued the count should be done before any other
493 * commands. 491 * commands.
685 * Get player's current range attack in obuf. 683 * Get player's current range attack in obuf.
686 */ 684 */
687static void 685static void
688rangetostring (player *pl, char *obuf) 686rangetostring (player *pl, char *obuf)
689{ 687{
690 dynbuf_text buf; 688 dynbuf_text &buf = msg_dynbuf; buf.clear ();
691 689
692 if (pl->ranged_ob) 690 if (pl->ranged_ob)
693 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; 691 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name;
694 692
695 if (pl->combat_ob) 693 if (pl->combat_ob)
930 928
931// prefetch (and touch) all maps within a specific distancd 929// prefetch (and touch) all maps within a specific distancd
932static void 930static void
933prefetch_surrounding_maps (maptile *map, int distance) 931prefetch_surrounding_maps (maptile *map, int distance)
934{ 932{
935 map->last_access = runtime; 933 map->touch ();
936 934
937 if (--distance) 935 if (--distance)
938 for (int dir = 4; --dir; ) 936 for (int dir = 4; --dir; )
939 if (const shstr &path = map->tile_path [dir]) 937 if (const shstr &path = map->tile_path [dir])
940 if (maptile *&neigh = map->tile_map [dir]) 938 if (maptile *&neigh = map->tile_map [dir])
1081 /* Darkness changed */ 1079 /* Darkness changed */
1082 if (lastcell.count != d) 1080 if (lastcell.count != d)
1083 { 1081 {
1084 mask |= 0x8; 1082 mask |= 0x8;
1085 1083
1086 if (socket.extmap) 1084 *last_ext |= 0x80;
1085 last_ext = &sl[sl.length ()];
1086 sl << uint8 (d);
1087 }
1088
1089 lastcell.count = d;
1090
1091 mapspace &ms = m->at (nx, ny);
1092 ms.update ();
1093
1094 // extmap handling
1095 uint8 stat_hp = 0;
1096 uint8 stat_width = 0;
1097 uint8 flags = 0;
1098 tag_t player = 0;
1099
1100 // send hp information, if applicable
1101 if (object *op = ms.faces_obj [0])
1102 if (op->is_head () && !op->invisible)
1103 {
1104 if (op->stats.maxhp > op->stats.hp
1105 && op->stats.maxhp > 0
1106 && (op->type == PLAYER
1107 || op->type == DOOR // does not work, have maxhp 0
1108 || QUERY_FLAG (op, FLAG_MONSTER)
1109 || QUERY_FLAG (op, FLAG_ALIVE)
1110 || QUERY_FLAG (op, FLAG_GENERATOR)))
1111 {
1112 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
1113 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge
1114 }
1115
1116 if (expect_false (op->has_dialogue ()))
1117 flags |= 1;
1118
1119 if (expect_false (op->type == PLAYER))
1120 player = op == ob ? pl->ob->count
1121 : op == pl->ob ? ob->count
1122 : op->count;
1123 }
1124
1125 if (expect_false (lastcell.stat_hp != stat_hp))
1126 {
1127 lastcell.stat_hp = stat_hp;
1128
1129 mask |= 0x8;
1130 *last_ext |= 0x80;
1131 last_ext = &sl[sl.length ()];
1132
1133 sl << uint8 (5) << uint8 (stat_hp);
1134
1135 if (stat_width > 1)
1087 { 1136 {
1088 *last_ext |= 0x80; 1137 *last_ext |= 0x80;
1089 last_ext = &sl[sl.length ()]; 1138 last_ext = &sl[sl.length ()];
1090 sl << uint8 (d);
1091 }
1092 else
1093 sl << uint8 (255 - 64 * d);
1094 }
1095 1139
1096 lastcell.count = d;
1097
1098 mapspace &ms = m->at (nx, ny);
1099 ms.update ();
1100
1101 if (expect_true (socket.extmap))
1102 {
1103 uint8 stat_hp = 0;
1104 uint8 stat_width = 0;
1105 uint8 flags = 0;
1106 tag_t player = 0;
1107
1108 // send hp information, if applicable
1109 if (object *op = ms.faces_obj [0])
1110 if (op->is_head () && !op->invisible)
1111 {
1112 if (op->stats.maxhp > op->stats.hp
1113 && op->stats.maxhp > 0
1114 && (op->type == PLAYER
1115 || op->type == DOOR // does not work, have maxhp 0
1116 || QUERY_FLAG (op, FLAG_MONSTER)
1117 || QUERY_FLAG (op, FLAG_ALIVE)
1118 || QUERY_FLAG (op, FLAG_GENERATOR)))
1119 {
1120 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
1121 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge
1122 }
1123
1124 if (expect_false (op->has_dialogue ()))
1125 flags |= 1;
1126
1127 if (expect_false (op->type == PLAYER))
1128 player = op == ob ? pl->ob->count
1129 : op == pl->ob ? ob->count
1130 : op->count;
1131 }
1132
1133 if (expect_false (lastcell.stat_hp != stat_hp))
1134 {
1135 lastcell.stat_hp = stat_hp;
1136
1137 mask |= 0x8;
1138 *last_ext |= 0x80;
1139 last_ext = &sl[sl.length ()];
1140
1141 sl << uint8 (5) << uint8 (stat_hp);
1142
1143 if (stat_width > 1)
1144 {
1145 *last_ext |= 0x80;
1146 last_ext = &sl[sl.length ()];
1147
1148 sl << uint8 (6) << uint8 (stat_width); 1140 sl << uint8 (6) << uint8 (stat_width);
1149 }
1150 }
1151
1152 if (expect_false (lastcell.player != player))
1153 {
1154 lastcell.player = player;
1155
1156 mask |= 0x8;
1157 *last_ext |= 0x80;
1158 last_ext = &sl[sl.length ()];
1159
1160 sl << uint8 (0x47) << uint8 (4) << (uint32)player;
1161 }
1162
1163 if (expect_false (lastcell.flags != flags))
1164 {
1165 lastcell.flags = flags;
1166
1167 mask |= 0x8;
1168 *last_ext |= 0x80;
1169 last_ext = &sl[sl.length ()];
1170
1171 sl << uint8 (8) << uint8 (flags);
1172 } 1141 }
1173 } 1142 }
1143
1144 if (expect_false (lastcell.player != player))
1145 {
1146 lastcell.player = player;
1147
1148 mask |= 0x8;
1149 *last_ext |= 0x80;
1150 last_ext = &sl[sl.length ()];
1151
1152 sl << uint8 (0x47) << uint8 (4) << (uint32)player;
1153 }
1154
1155 if (expect_false (lastcell.flags != flags))
1156 {
1157 lastcell.flags = flags;
1158
1159 mask |= 0x8;
1160 *last_ext |= 0x80;
1161 last_ext = &sl[sl.length ()];
1162
1163 sl << uint8 (8) << uint8 (flags);
1164 }
1165
1166 // faces
1174 1167
1175 /* Floor face */ 1168 /* Floor face */
1176 if (update_space (sl, socket, ms, lastcell, 2)) 1169 if (update_space (sl, socket, ms, lastcell, 2))
1177 mask |= 0x4; 1170 mask |= 0x4;
1178 1171

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines