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.147 by root, Sat Dec 27 08:41:44 2008 UTC vs.
Revision 1.152 by root, Tue Oct 20 07:18:11 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/**
424 while (1) 425 while (1)
425 { 426 {
426 /* 1. Extract an info */ 427 /* 1. Extract an info */
427 info = nextinfo; 428 info = nextinfo;
428 429
429 while ((info < len) && (buf[info] == ' ')) 430 while ((info < len) && (buf [info] == ' '))
430 info++; 431 info++;
431 432
432 if (info >= len) 433 if (info >= len)
433 break; 434 break;
434 435
435 nextinfo = info + 1; 436 nextinfo = info + 1;
436 437
437 while ((nextinfo < len) && (buf[nextinfo] != ' ')) 438 while ((nextinfo < len) && (buf [nextinfo] != ' '))
438 nextinfo++; 439 nextinfo++;
439 440
440 if (nextinfo - info >= 49) /*Erroneous info asked */ 441 if (nextinfo - info >= 49) /*Erroneous info asked */
441 continue; 442 continue;
442 443
443 strncpy (command, &(buf[info]), nextinfo - info); 444 memcpy (command, buf + info, nextinfo - info);
444 command[nextinfo - info] = '\0'; 445 command [nextinfo - info] = 0;
446
445 /* 2. Interpret info */ 447 /* 2. Interpret info */
446 i = sscanf (command, "%d", &flag); 448 i = sscanf (command, "%d", &flag);
447 449
448 if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) 450 if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST))
449 ns->supported_readables |= (1 << flag); 451 ns->supported_readables |= (1 << flag);
483 return; 485 return;
484 486
485 buf++; 487 buf++;
486 } 488 }
487 489
488 execute_newserver_command (pl->ob, (char *) buf); 490 execute_newserver_command (pl->ob, (char *)buf);
489 491
490 /* Perhaps something better should be done with a left over count. 492 /* Perhaps something better should be done with a left over count.
491 * Cleaning up the input should probably be done first - all actions 493 * 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 494 * for the command that issued the count should be done before any other
493 * commands. 495 * commands.
685 * Get player's current range attack in obuf. 687 * Get player's current range attack in obuf.
686 */ 688 */
687static void 689static void
688rangetostring (player *pl, char *obuf) 690rangetostring (player *pl, char *obuf)
689{ 691{
690 dynbuf_text buf; 692 dynbuf_text &buf = msg_dynbuf; buf.clear ();
691 693
692 if (pl->ranged_ob) 694 if (pl->ranged_ob)
693 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; 695 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name;
694 696
695 if (pl->combat_ob) 697 if (pl->combat_ob)
1081 /* Darkness changed */ 1083 /* Darkness changed */
1082 if (lastcell.count != d) 1084 if (lastcell.count != d)
1083 { 1085 {
1084 mask |= 0x8; 1086 mask |= 0x8;
1085 1087
1086 if (socket.extmap) 1088 *last_ext |= 0x80;
1089 last_ext = &sl[sl.length ()];
1090 sl << uint8 (d);
1091 }
1092
1093 lastcell.count = d;
1094
1095 mapspace &ms = m->at (nx, ny);
1096 ms.update ();
1097
1098 // extmap handling
1099 uint8 stat_hp = 0;
1100 uint8 stat_width = 0;
1101 uint8 flags = 0;
1102 tag_t player = 0;
1103
1104 // send hp information, if applicable
1105 if (object *op = ms.faces_obj [0])
1106 if (op->is_head () && !op->invisible)
1107 {
1108 if (op->stats.maxhp > op->stats.hp
1109 && op->stats.maxhp > 0
1110 && (op->type == PLAYER
1111 || op->type == DOOR // does not work, have maxhp 0
1112 || QUERY_FLAG (op, FLAG_MONSTER)
1113 || QUERY_FLAG (op, FLAG_ALIVE)
1114 || QUERY_FLAG (op, FLAG_GENERATOR)))
1115 {
1116 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
1117 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge
1118 }
1119
1120 if (expect_false (op->has_dialogue ()))
1121 flags |= 1;
1122
1123 if (expect_false (op->type == PLAYER))
1124 player = op == ob ? pl->ob->count
1125 : op == pl->ob ? ob->count
1126 : op->count;
1127 }
1128
1129 if (expect_false (lastcell.stat_hp != stat_hp))
1130 {
1131 lastcell.stat_hp = stat_hp;
1132
1133 mask |= 0x8;
1134 *last_ext |= 0x80;
1135 last_ext = &sl[sl.length ()];
1136
1137 sl << uint8 (5) << uint8 (stat_hp);
1138
1139 if (stat_width > 1)
1087 { 1140 {
1088 *last_ext |= 0x80; 1141 *last_ext |= 0x80;
1089 last_ext = &sl[sl.length ()]; 1142 last_ext = &sl[sl.length ()];
1090 sl << uint8 (d);
1091 }
1092 else
1093 sl << uint8 (255 - 64 * d);
1094 }
1095 1143
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); 1144 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 } 1145 }
1173 } 1146 }
1147
1148 if (expect_false (lastcell.player != player))
1149 {
1150 lastcell.player = player;
1151
1152 mask |= 0x8;
1153 *last_ext |= 0x80;
1154 last_ext = &sl[sl.length ()];
1155
1156 sl << uint8 (0x47) << uint8 (4) << (uint32)player;
1157 }
1158
1159 if (expect_false (lastcell.flags != flags))
1160 {
1161 lastcell.flags = flags;
1162
1163 mask |= 0x8;
1164 *last_ext |= 0x80;
1165 last_ext = &sl[sl.length ()];
1166
1167 sl << uint8 (8) << uint8 (flags);
1168 }
1169
1170 // faces
1174 1171
1175 /* Floor face */ 1172 /* Floor face */
1176 if (update_space (sl, socket, ms, lastcell, 2)) 1173 if (update_space (sl, socket, ms, lastcell, 2))
1177 mask |= 0x4; 1174 mask |= 0x4;
1178 1175

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines