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.164 by root, Fri Mar 26 00:59:22 2010 UTC vs.
Revision 1.171 by root, Sun Apr 11 00:34:07 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001 Mark Wedel 5 * Copyright (©) 2001 Mark Wedel
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
44 44
45#include <global.h> 45#include <global.h>
46#include <sproto.h> 46#include <sproto.h>
47 47
48#include <living.h> 48#include <living.h>
49#include <commands.h>
50 49
51/* This block is basically taken from socket.c - I assume if it works there, 50/* This block is basically taken from socket.c - I assume if it works there,
52 * it should work here. 51 * it should work here.
53 */ 52 */
54#include <sys/types.h> 53#include <sys/types.h>
447 INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len)); 446 INVOKE_CLIENT (ADDME, ns, ARG_DATA (buf, len));
448} 447}
449 448
450//+GPL 449//+GPL
451 450
452/*
453#define MSG_TYPE_BOOK 1
454#define MSG_TYPE_CARD 2
455#define MSG_TYPE_PAPER 3
456#define MSG_TYPE_SIGN 4
457#define MSG_TYPE_MONUMENT 5
458#define MSG_TYPE_SCRIPTED_DIALOG 6*/
459
460/** Reply to ExtendedInfos command */
461void
462ToggleExtendedText (char *buf, int len, client * ns)
463{
464 char cmdback[MAX_BUF];
465 char temp[10];
466 char command[50];
467 int info, nextinfo, i, flag;
468
469 cmdback[0] = '\0';
470
471 nextinfo = 0;
472 while (1)
473 {
474 /* 1. Extract an info */
475 info = nextinfo;
476
477 while ((info < len) && (buf [info] == ' '))
478 info++;
479
480 if (info >= len)
481 break;
482
483 nextinfo = info + 1;
484
485 while ((nextinfo < len) && (buf [nextinfo] != ' '))
486 nextinfo++;
487
488 if (nextinfo - info >= 49) /*Erroneous info asked */
489 continue;
490
491 memcpy (command, buf + info, nextinfo - info);
492 command [nextinfo - info] = 0;
493
494 /* 2. Interpret info */
495 i = sscanf (command, "%d", &flag);
496
497 if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST))
498 ns->supported_readables |= (1 << flag);
499 /*3. Next info */
500 }
501
502 /* Send resulting state */
503 strcpy (cmdback, "ExtendedTextSet");
504
505 for (i = 0; i <= MSG_TYPE_LAST; i++)
506 if (ns->supported_readables & (1 << i))
507 {
508 strcat (cmdback, " ");
509 snprintf (temp, sizeof (temp), "%d", i);
510 strcat (cmdback, temp);
511 }
512
513 ns->send_packet (cmdback);
514}
515
516/** 451/**
517 * This handles the general commands from the client (ie, north, fire, cast, 452 * This handles the general commands from the client (ie, north, fire, cast,
518 * etc.) 453 * etc.)
519 */ 454 */
520void 455void
630 LOG (llevError, "Unknown input state: %d\n", ns->state); 565 LOG (llevError, "Unknown input state: %d\n", ns->state);
631 } 566 }
632} 567}
633 568
634/** 569/**
635 * Client tells its version. If there is a mismatch, we close the 570 * Client tells its version info.
636 * socket. In real life, all we should care about is the client having
637 * something older than the server. If we assume the client will be
638 * backwards compatible, having it be a later version should not be a
639 * problem.
640 */ 571 */
641void 572void
642VersionCmd (char *buf, int len, client * ns) 573VersionCmd (char *buf, int len, client *ns)
643{ 574{
644 if (!buf) 575 INVOKE_CLIENT (VERSION, ns, ARG_DATA (buf, len));
645 {
646 LOG (llevError, "CS: received corrupted version command\n");
647 return;
648 }
649
650 ns->cs_version = atoi (buf);
651 ns->sc_version = ns->cs_version;
652
653 LOG (llevDebug, "connection from client <%s>\n", buf);
654
655 //TODO: should log here just for statistics
656
657 //if (VERSION_CS != ns->cs_version)
658 // unchecked;
659
660 char *cp = strchr (buf + 1, ' ');
661 if (!cp)
662 return;
663
664 ns->sc_version = atoi (cp);
665
666 //if (VERSION_SC != ns->sc_version)
667 // unchecked;
668
669 cp = strchr (cp + 1, ' ');
670
671 if (cp)
672 {
673 ns->version = cp + 1;
674
675 if (ns->sc_version < 1026)
676 ns->send_packet_printf ("drawinfo %d %s", NDI_RED,
677 "**** VERSION WARNING ****\n**** CLIENT IS TOO OLD!! UPDATE THE CLIENT!! ****");
678 }
679} 576}
680 577
681/** sound related functions. */ 578/** sound related functions. */
682void 579void
683SetSound (char *buf, int len, client * ns) 580SetSound (char *buf, int len, client * ns)
735 */ 632 */
736static void 633static void
737rangetostring (player *pl, char *obuf) 634rangetostring (player *pl, char *obuf)
738{ 635{
739 dynbuf_text &buf = msg_dynbuf; buf.clear (); 636 dynbuf_text &buf = msg_dynbuf; buf.clear ();
637
638#if 0
639 // print ranged/chosen_skill etc. objects every call
640 printf ("%s %s => %s (%s)\n",
641 pl->ranged_ob ? &pl->ranged_ob->name : "-",
642 pl->combat_ob ? &pl->combat_ob->name : "-",
643 pl->ob->current_weapon ? &pl->ob->current_weapon->name : "-",
644 pl->ob->chosen_skill ? &pl->ob->chosen_skill->name : "-"
645 );
646#endif
740 647
741 if (pl->ranged_ob) 648 if (pl->ranged_ob)
742 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; 649 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name;
743 650
744 if (pl->combat_ob) 651 if (pl->combat_ob)
1155 { 1062 {
1156 if (op->stats.maxhp > op->stats.hp 1063 if (op->stats.maxhp > op->stats.hp
1157 && op->stats.maxhp > 0 1064 && op->stats.maxhp > 0
1158 && (op->type == PLAYER 1065 && (op->type == PLAYER
1159 || op->type == DOOR // does not work, have maxhp 0 1066 || op->type == DOOR // does not work, have maxhp 0
1160 || QUERY_FLAG (op, FLAG_MONSTER) 1067 || op->flag [FLAG_MONSTER]
1161 || QUERY_FLAG (op, FLAG_ALIVE) 1068 || op->flag [FLAG_ALIVE]
1162 || QUERY_FLAG (op, FLAG_GENERATOR))) 1069 || op->flag [FLAG_GENERATOR]))
1163 { 1070 {
1164 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; 1071 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
1165 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge 1072 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge
1166 } 1073 }
1167 1074

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines