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.150 by root, Mon Oct 12 14:00:59 2009 UTC vs.
Revision 1.154 by root, Wed Nov 4 17:24:00 2009 UTC

142 142
143static void 143static void
144send_map_info (player *pl) 144send_map_info (player *pl)
145{ 145{
146 client &socket = *pl->ns; 146 client &socket = *pl->ns;
147 object *ob = pl->observe; 147 object *ob = pl->viewpoint;
148 148
149 if (socket.mapinfocmd) 149 if (socket.mapinfocmd)
150 { 150 {
151 if (ob->map && ob->map->path[0]) 151 if (ob->map && ob->map->path[0])
152 { 152 {
169/** check for map/region change and send new map data */ 169/** check for map/region change and send new map data */
170static void 170static void
171check_map_change (player *pl) 171check_map_change (player *pl)
172{ 172{
173 client &socket = *pl->ns; 173 client &socket = *pl->ns;
174 object *ob = pl->observe; 174 object *ob = pl->viewpoint;
175 175
176 region *reg = ob->region (); 176 region *reg = ob->region ();
177 if (socket.current_region != reg) 177 if (socket.current_region != reg)
178 { 178 {
179 INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region)); 179 INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region));
237 { 237 {
238 *params++ = 0; 238 *params++ = 0;
239 break; 239 break;
240 } 240 }
241 241
242 if (!strcmp (buf, "image_info"))
243 send_image_info (ns, params);
244 else if (!strcmp (buf, "image_sums"))
245 send_image_sums (ns, params);
246 else if (!strcmp (buf, "skill_info")) 242 if (!strcmp (buf, "skill_info"))
247 send_skill_info (ns, params); 243 send_skill_info (ns, params);
248 else if (!strcmp (buf, "spell_paths")) 244 else if (!strcmp (buf, "spell_paths"))
249 send_spell_paths (ns, params); 245 send_spell_paths (ns, params);
250 else 246 else
251 { 247 {
283{ 279{
284 char *token = buf; 280 char *token = buf;
285 buf += strlen (buf) + 9; 281 buf += strlen (buf) + 9;
286 282
287 // initial map and its origin 283 // initial map and its origin
288 maptile *map = pl->observe->map; 284 maptile *map = pl->viewpoint->map;
289 int mapx = pl->ns->mapx / 2 - pl->observe->x; 285 int mapx = pl->ns->mapx / 2 - pl->viewpoint->x;
290 int mapy = pl->ns->mapy / 2 - pl->observe->y; 286 int mapy = pl->ns->mapy / 2 - pl->viewpoint->y;
291 int max_distance = 8; // limit maximum path length to something generous 287 int max_distance = 8; // limit maximum path length to something generous
292 288
293 while (*buf && map && max_distance) 289 while (*buf && map && max_distance)
294 { 290 {
295 int dir = *buf++ - '1'; 291 int dir = *buf++ - '1';
425 while (1) 421 while (1)
426 { 422 {
427 /* 1. Extract an info */ 423 /* 1. Extract an info */
428 info = nextinfo; 424 info = nextinfo;
429 425
430 while ((info < len) && (buf[info] == ' ')) 426 while ((info < len) && (buf [info] == ' '))
431 info++; 427 info++;
432 428
433 if (info >= len) 429 if (info >= len)
434 break; 430 break;
435 431
436 nextinfo = info + 1; 432 nextinfo = info + 1;
437 433
438 while ((nextinfo < len) && (buf[nextinfo] != ' ')) 434 while ((nextinfo < len) && (buf [nextinfo] != ' '))
439 nextinfo++; 435 nextinfo++;
440 436
441 if (nextinfo - info >= 49) /*Erroneous info asked */ 437 if (nextinfo - info >= 49) /*Erroneous info asked */
442 continue; 438 continue;
443 439
444 strncpy (command, &(buf[info]), nextinfo - info); 440 memcpy (command, buf + info, nextinfo - info);
445 command[nextinfo - info] = '\0'; 441 command [nextinfo - info] = 0;
442
446 /* 2. Interpret info */ 443 /* 2. Interpret info */
447 i = sscanf (command, "%d", &flag); 444 i = sscanf (command, "%d", &flag);
448 445
449 if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) 446 if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST))
450 ns->supported_readables |= (1 << flag); 447 ns->supported_readables |= (1 << flag);
484 return; 481 return;
485 482
486 buf++; 483 buf++;
487 } 484 }
488 485
489 execute_newserver_command (pl->ob, (char *) buf); 486 execute_newserver_command (pl->ob, (char *)buf);
490 487
491 /* Perhaps something better should be done with a left over count. 488 /* Perhaps something better should be done with a left over count.
492 * Cleaning up the input should probably be done first - all actions 489 * Cleaning up the input should probably be done first - all actions
493 * 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
494 * commands. 491 * commands.
955 * Draws client map. 952 * Draws client map.
956 */ 953 */
957void 954void
958draw_client_map (player *pl) 955draw_client_map (player *pl)
959{ 956{
960 object *ob = pl->observe; 957 object *ob = pl->viewpoint;
961 if (!ob->active) 958 if (!pl->observe->active)
962 return; 959 return;
963 960
964 /* If player is just joining the game, he isn't here yet, so the map 961 /* If player is just joining the game, he isn't here yet, so the map
965 * can get swapped out. If so, don't try to send them a map. All will 962 * can get swapped out. If so, don't try to send them a map. All will
966 * be OK once they really log in. 963 * be OK once they really log in.
973 check_map_change (pl); 970 check_map_change (pl);
974 prefetch_surrounding_maps (pl->ob); 971 prefetch_surrounding_maps (pl->ob);
975 972
976 /* do LOS after calls to update_position */ 973 /* do LOS after calls to update_position */
977 /* unfortunately, we need to udpate los when observing, currently */ 974 /* unfortunately, we need to udpate los when observing, currently */
978 if (pl->do_los || pl->observe != pl->ob) 975 if (pl->do_los || pl->viewpoint != pl->ob)
979 { 976 {
980 pl->do_los = 0; 977 pl->do_los = 0;
981 pl->update_los (); 978 pl->update_los ();
982 } 979 }
983 980

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines