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.188 by root, Mon Oct 29 23:55:57 2012 UTC vs.
Revision 1.197 by root, Sat Dec 1 20:22:13 2018 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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001 Mark Wedel 6 * Copyright (©) 2001 Mark Wedel
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * 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 10 * the terms of the Affero GNU General Public License as published by the
28 * \file 29 * \file
29 * Client handling. 30 * Client handling.
30 * 31 *
31 * \date 2003-12-02 32 * \date 2003-12-02
32 * 33 *
33 * This file implements all of the goo on the server side for handling 34 * This file implements all of the goo on the server side for handling
34 * clients. It's got a bunch of global variables for keeping track of 35 * clients. It's got a bunch of global variables for keeping track of
35 * each of the clients. 36 * each of the clients.
36 * 37 *
37 * Note: All functions that are used to process data from the client 38 * Note: All functions that are used to process data from the client
38 * have the prototype of (char *data, int datalen, int client_num). This 39 * have the prototype of (char *data, int datalen, int client_num). This
39 * way, we can use one dispatch table. 40 * way, we can use one dispatch table.
40 * 41 *
194 { 195 {
195 INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region)); 196 INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region));
196 socket.current_region = reg; 197 socket.current_region = reg;
197 } 198 }
198 199
199 // first try to aovid a full newmap on tiled map scrolls 200 // first try to avoid a full newmap on tiled map scrolls
200 if (socket.current_map != ob->map && !socket.force_newmap) 201 if (socket.current_map != ob->map && !socket.force_newmap)
201 { 202 {
202 rv_vector rv; 203 rv_vector rv;
203 204
204 get_rangevector_from_mapcoord (socket.current_map, socket.current_x, socket.current_y, ob, &rv, 0); 205 get_rangevector_from_mapcoord (socket.current_map, socket.current_x, socket.current_y, ob, &rv, 0);
276 277
277/** 278/**
278 * RequestInfo is sort of a meta command. There is some specific 279 * RequestInfo is sort of a meta command. There is some specific
279 * request of information, but we call other functions to provide 280 * request of information, but we call other functions to provide
280 * that information. 281 * that information.
282 * requestinfo is completely deprecated, use resource exti request
283 * and the fxix or http protocols.
281 */ 284 */
282void 285void
283RequestInfo (char *buf, int len, client *ns) 286RequestInfo (char *buf, int len, client *ns)
284{ 287{
285 char *params; 288 char *params;
323//-GPL 326//-GPL
324 327
325void 328void
326client::mapinfo_queue_clear () 329client::mapinfo_queue_clear ()
327{ 330{
328 for (auto (i, mapinfo_queue.begin ()); i != mapinfo_queue.end (); ++i) 331 for (auto &&i : mapinfo_queue)
329 free (*i); 332 free (i);
330 333
331 mapinfo_queue.clear (); 334 mapinfo_queue.clear ();
332} 335}
333 336
334bool 337bool
349 352
350 // due to historical glitches, the mapinfo index and tile index differs 353 // due to historical glitches, the mapinfo index and tile index differs
351 static unsigned char dirmap [] = { TILE_NORTH, TILE_EAST, TILE_SOUTH, TILE_WEST, TILE_UP, TILE_DOWN }; 354 static unsigned char dirmap [] = { TILE_NORTH, TILE_EAST, TILE_SOUTH, TILE_WEST, TILE_UP, TILE_DOWN };
352 355
353 // maybe we should only allow the four flat directions 356 // maybe we should only allow the four flat directions
354 if (IN_RANGE_EXC (dir, 0, array_length (dirmap))) 357 if (IN_RANGE_EXC (dir, 0, ecb_array_length (dirmap)))
355 { 358 {
356 dir = dirmap [dir]; 359 dir = dirmap [dir];
357 360
358 if (!map->tile_path [dir]) 361 if (!map->tile_path [dir])
359 map = 0; 362 map = 0;
494 * Cleaning up the input should probably be done first - all actions 497 * Cleaning up the input should probably be done first - all actions
495 * for the command that issued the count should be done before any other 498 * for the command that issued the count should be done before any other
496 * commands. 499 * commands.
497 */ 500 */
498 pl->count = 0; 501 pl->count = 0;
499}
500
501/**
502 * This handles the general commands from the client (ie, north, fire, cast,
503 * etc.). It is a lot like PlayerCmd above, but is called with the
504 * 'ncom' method which gives more information back to the client so it
505 * can throttle.
506 */
507void
508NewPlayerCmd (char *buf, int len, player *pl)
509{
510 if (len <= 6)
511 {
512 LOG (llevDebug, "%s: corrupt ncom command <%s>: not long enough (%d) - discarding\n", pl->ns->host, buf, len);
513 return;
514 }
515
516 uint16 cmdid = net_uint16 ((uint8 *)buf);
517 sint32 repeat = net_sint32 ((uint8 *)buf + 2);
518
519 /* -1 is special - no repeat, but don't update */
520 if (repeat != -1)
521 pl->count = repeat;
522
523 buf += 6; //len -= 6;
524
525 execute_newserver_command (pl->ob, buf);
526
527 /* Perhaps something better should be done with a left over count.
528 * Cleaning up the input should probably be done first - all actions
529 * for the command that issued the count should be done before any other
530 * commands.
531 */
532 pl->count = 0;
533
534 //TODO: schmorp thinks whatever this calculates, it makes no sense at all
535 int time = pl->ob->has_active_speed ()
536 ? (int) (MAX_TIME / pl->ob->speed)
537 : MAX_TIME * 100;
538
539 /* Send confirmation of command execution now */
540 packet sl ("comc");
541 sl << uint16 (cmdid) << uint32 (time);
542 pl->ns->send_packet (sl);
543} 502}
544 503
545/** This is a reply to a previous query. */ 504/** This is a reply to a previous query. */
546void 505void
547ReplyCmd (char *buf, int len, client *ns) 506ReplyCmd (char *buf, int len, client *ns)
982 { 941 {
983 /* This block deals with spaces that are not visible for whatever 942 /* This block deals with spaces that are not visible for whatever
984 * reason. Still may need to send the head for this space. 943 * reason. Still may need to send the head for this space.
985 */ 944 */
986 if (lastcell.count != -1 945 if (lastcell.count != -1
987 || lastcell.faces[0] 946 || lastcell.faces[0]
988 || lastcell.faces[1] 947 || lastcell.faces[1]
989 || lastcell.faces[2] 948 || lastcell.faces[2]
990 || lastcell.stat_hp 949 || lastcell.stat_hp
991 || lastcell.flags 950 || lastcell.flags
992 || lastcell.player) 951 || lastcell.player)
993 sl << uint16 (mask); 952 sl << uint16 (mask);
994 953
995 /* properly clear a previously sent big face */ 954 /* properly clear a previously sent big face */
996 map_clearcell (&lastcell, -1); 955 map_clearcell (&lastcell, -1);
1272 << uint16 (spell->cached_grace) 1231 << uint16 (spell->cached_grace)
1273 << uint16 (spell->cached_eat) 1232 << uint16 (spell->cached_eat)
1274 << uint8 (skill) 1233 << uint8 (skill)
1275 << uint32 (spell->path_attuned) 1234 << uint32 (spell->path_attuned)
1276 << uint32 (spell->face) 1235 << uint32 (spell->face)
1277 << data8 (spell->name) 1236 << data8 (spell->name);
1237
1238 if (pl->ns->monitor_spells < 2)
1278 << data16 (spell->msg); 1239 sl << data16 (spell->msg);
1279} 1240}
1280 1241
1281/** 1242/**
1282 * This tells the client to add the spell *ob, if *ob is NULL, then add 1243 * This tells the client to add the spell *ob, if *ob is NULL, then add
1283 * all spells in the player's inventory. 1244 * all spells in the player's inventory.
1284 */ 1245 */
1285void 1246void
1286esrv_add_spells (player *pl, object *spell) 1247esrv_add_spells (player *pl, object *spell)
1287{ 1248{
1298 1259
1299 if (!spell) 1260 if (!spell)
1300 { 1261 {
1301 for (spell = pl->ob->inv; spell; spell = spell->below) 1262 for (spell = pl->ob->inv; spell; spell = spell->below)
1302 { 1263 {
1303 /* were we to simply keep appending data here, we could exceed 1264 /* were we to simply keep appending data here, we could exceed
1304 * MAXSOCKBUF if the player has enough spells to add, we know that 1265 * MAXSOCKBUF if the player has enough spells to add, we know that
1305 * append_spells will always append 19 data bytes, plus 4 length 1266 * append_spells will always append 19 data bytes, plus 4 length
1306 * bytes and 3 strings (because that is the spec) so we need to 1267 * bytes and 3 strings (because that is the spec) so we need to
1307 * check that the length of those 3 strings, plus the 23 bytes, 1268 * check that the length of those 3 strings, plus the 23 bytes,
1308 * won't take us over the length limit for the socket, if it does, 1269 * won't take us over the length limit for the socket, if it does,
1309 * we need to send what we already have, and restart packet formation 1270 * we need to send what we already have, and restart packet formation
1310 */ 1271 */
1311 if (spell->type != SPELL) 1272 if (spell->type != SPELL)
1312 continue; 1273 continue;
1313 1274
1314 /* Seeing crashes by overflowed buffers. Quick arithemetic seems 1275 /* Seeing crashes by overflowed buffers. Quick arithemetic seems

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines