--- deliantra/server/socket/request.C 2006/09/10 13:43:33 1.16 +++ deliantra/server/socket/request.C 2006/09/19 10:12:50 1.22 @@ -1,9 +1,3 @@ - -/* - * static char *rcsid_init_c = - * "$Id: request.C,v 1.16 2006/09/10 13:43:33 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows @@ -24,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - The author can be reached via e-mail to crossfire-devel@real-time.com + The author can be reached via e-mail to */ /** @@ -52,8 +46,6 @@ * esrv_map_doneredraw finishes the map update, and ships across the * map updates. * - * esrv_map_scroll tells the client to scroll the map, and does similarily - * for the locally cached copy. */ #include @@ -268,7 +260,7 @@ buf += 8; // initial map and its origin - mapstruct *map = pl->ob->map; + maptile *map = pl->ob->map; sint16 dx, dy; int mapx = pl->socket.mapx / 2 - pl->ob->x; int mapy = pl->socket.mapy / 2 - pl->ob->y; @@ -583,39 +575,46 @@ cmdback[0] = '\0'; nextinfo = 0; + while (1) { /* 1. Extract an info */ info = nextinfo; + while ((info < len) && (buf[info] == ' ')) info++; + if (info >= len) break; + nextinfo = info + 1; + while ((nextinfo < len) && (buf[nextinfo] != ' ')) nextinfo++; + if (nextinfo - info >= 49) /*Erroneous info asked */ continue; + strncpy (command, &(buf[info]), nextinfo - info); - command[nextinfo - info] = '\0'; + /* 2. Interpret info */ if (!strcmp ("smooth", command)) - { - /* Toggle smoothing */ - ns->EMI_smooth = !ns->EMI_smooth; - } + /* Toggle smoothing */ + ns->EMI_smooth = !ns->EMI_smooth; else - { - /*bad value */ - } + /*bad value */; + /*3. Next info */ } + strcpy (cmdback, "ExtendedInfoSet"); + if (ns->EMI_smooth) { strcat (cmdback, " "); strcat (cmdback, "smoothing"); } + Write_String_To_Socket (ns, cmdback, strlen (cmdback)); } @@ -637,30 +636,40 @@ int info, nextinfo, i, flag; cmdback[0] = '\0'; + nextinfo = 0; while (1) { /* 1. Extract an info */ info = nextinfo; + while ((info < len) && (buf[info] == ' ')) info++; + if (info >= len) break; + nextinfo = info + 1; + while ((nextinfo < len) && (buf[nextinfo] != ' ')) nextinfo++; + if (nextinfo - info >= 49) /*Erroneous info asked */ continue; + strncpy (command, &(buf[info]), nextinfo - info); command[nextinfo - info] = '\0'; /* 2. Interpret info */ i = sscanf (command, "%d", &flag); + if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) ns->supported_readables |= (1 << flag); /*3. Next info */ } + /* Send resulting state */ strcpy (cmdback, "ExtendedTextSet"); + for (i = 0; i <= MSG_TYPE_LAST; i++) if (ns->supported_readables & (1 << i)) { @@ -668,6 +677,7 @@ snprintf (temp, sizeof (temp), "%d", i); strcat (cmdback, temp); } + Write_String_To_Socket (ns, cmdback, strlen (cmdback)); } @@ -1123,6 +1133,7 @@ AddIfShort (pl->last_stats.Con, pl->ob->stats.Con, CS_STAT_CON); AddIfShort (pl->last_stats.Cha, pl->ob->stats.Cha, CS_STAT_CHA); } + if (pl->socket.exp64) { uint8 s; @@ -1142,14 +1153,12 @@ } } } + if (pl->socket.exp64) - { - AddIfInt64 (pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP64); - } + AddIfInt64 (pl->last_stats.exp, pl->ob->stats.exp, CS_STAT_EXP64); else - { - AddIfInt (pl->last_stats.exp, (int) pl->ob->stats.exp, CS_STAT_EXP); - } + AddIfInt (pl->last_stats.exp, (int) pl->ob->stats.exp, CS_STAT_EXP); + AddIfShort (pl->last_level, (char) pl->ob->level, CS_STAT_LEVEL); AddIfShort (pl->last_stats.wc, pl->ob->stats.wc, CS_STAT_WC); AddIfShort (pl->last_stats.ac, pl->ob->stats.ac, CS_STAT_AC); @@ -1159,16 +1168,17 @@ AddIfFloat (pl->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP); AddIfInt (pl->last_weight_limit, (sint32) weight_limit[pl->ob->stats.Str], CS_STAT_WEIGHT_LIM); flags = 0; + if (pl->fire_on) flags |= SF_FIREON; + if (pl->run_on) flags |= SF_RUNON; AddIfShort (pl->last_flags, flags, CS_STAT_FLAGS); + if (pl->socket.sc_version < 1025) - { - AddIfShort (pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR); - } + AddIfShort (pl->last_resist[ATNR_PHYSICAL], pl->ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR); else { int i; @@ -1181,12 +1191,14 @@ AddIfShort (pl->last_resist[i], pl->ob->resist[i], (char) atnr_cs_stat[i]); } } + if (pl->socket.monitor_spells) { AddIfInt (pl->last_path_attuned, pl->ob->path_attuned, CS_STAT_SPELL_ATTUNE); AddIfInt (pl->last_path_repelled, pl->ob->path_repelled, CS_STAT_SPELL_REPEL); AddIfInt (pl->last_path_denied, pl->ob->path_denied, CS_STAT_SPELL_DENY); } + rangetostring (pl->ob, buf); /* we want use the new fire & run system in new client */ AddIfString (pl->socket.stats.range, buf, CS_STAT_RANGE); set_title (pl->ob, buf); @@ -1428,9 +1440,8 @@ { /* All of this is just accounting stuff */ if (tframes > 100) - { - tframes = tbytes = 0; - } + tframes = tbytes = 0; + tframes++; frames++; tbytes += sl.len; @@ -1439,6 +1450,7 @@ Send_With_Handling (ns, &sl); ns->sent_scroll = 0; } + free (sl.buf); } @@ -1533,7 +1545,7 @@ */ static int -update_space (SockList * sl, NewSocket * ns, mapstruct *mp, int mx, int my, int sx, int sy, int layer) +update_space (SockList * sl, NewSocket * ns, maptile *mp, int mx, int my, int sx, int sy, int layer) { object *ob, *head; uint16 face_num; @@ -1757,7 +1769,7 @@ */ static inline int -update_smooth (SockList * sl, NewSocket * ns, mapstruct *mp, int mx, int my, int sx, int sy, int layer) +update_smooth (SockList * sl, NewSocket * ns, maptile *mp, int mx, int my, int sx, int sy, int layer) { object *ob; int smoothlevel; /* old face_num; */ @@ -1845,7 +1857,7 @@ uint8 eentrysize; uint16 ewhatstart, ewhatflag; uint8 extendedinfos; - mapstruct *m; + maptile *m; NewSocket & socket = pl->contr->socket; @@ -2118,7 +2130,7 @@ } } - if (lastcell.player !=player) + if (lastcell.player != player) { lastcell.player = player; @@ -2205,17 +2217,19 @@ ewhatflag &= (~EMI_NOREDRAW); esl.buf[ewhatstart + 1] = ewhatflag & 0xff; } + if (esl.len > estartlen) - { - Send_With_Handling (&socket, &esl); - } + Send_With_Handling (&socket, &esl); + free (esl.buf); } + if (sl.len > startlen || socket.sent_scroll) { Send_With_Handling (&socket, &sl); socket.sent_scroll = 0; } + free (sl.buf); } @@ -2231,7 +2245,7 @@ New_Face *floor2; int d, mflags; struct Map newmap; - mapstruct *m, *pm; + maptile *m, *pm; if (pl->type != PLAYER) {