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.123 by root, Thu Nov 8 19:43:30 2007 UTC vs.
Revision 1.130 by root, Tue May 20 03:14:19 2008 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 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
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
148check_map_change (player *pl) 148check_map_change (player *pl)
149{ 149{
150 client &socket = *pl->ns; 150 client &socket = *pl->ns;
151 object *ob = pl->observe; 151 object *ob = pl->observe;
152 152
153 // first try to aovid a full newmap on tiled map scrolls
154 if (socket.current_map != ob->map)
155 {
156 rv_vector rv;
157
158 get_rangevector_from_mapcoord (socket.current_map, socket.current_x, socket.current_y, ob, &rv, 0);
159
160 // manhattan distance is very handy here
161 if (rv.distance < 8) // 8 works nicely for speed << 70 and buggy gcfclient
162 {
163 socket.current_map = ob->map;
164 socket.current_x = ob->x;
165 socket.current_y = ob->y;
166
167 socket_map_scroll (&socket, rv.distance_x, rv.distance_y);
168 socket.floorbox_reset ();
169 }
170 }
171
153 if (socket.current_map != ob->map || socket.force_newmap) 172 if (socket.current_map != ob->map || socket.force_newmap)
154 { 173 {
155 clear_map (pl); 174 clear_map (pl);
156 socket.current_map = ob->map; 175 socket.current_map = ob->map;
157 176
686 * syntax is: move (to) (tag) (nrof) 705 * syntax is: move (to) (tag) (nrof)
687 */ 706 */
688void 707void
689MoveCmd (char *buf, int len, player *pl) 708MoveCmd (char *buf, int len, player *pl)
690{ 709{
691 int vals[3], i; 710 int to, tag, nrof;
692 711
693 /* A little funky here. We only cycle for 2 records, because 712 if (3 != sscanf (buf, "%d %d %d", &to, &tag, &nrof))
694 * we obviously are not going to find a space after the third
695 * record. Perhaps we should just replace this with a
696 * sscanf?
697 */
698 for (i = 0; i < 2; i++)
699 { 713 {
700 vals[i] = atoi (buf);
701
702 if (!(buf = strchr (buf, ' ')))
703 {
704 LOG (llevError, "Incomplete move command: %s\n", buf); 714 LOG (llevError, "Incomplete move command: %s\n", buf);
705 return; 715 return;
706 }
707
708 buf++;
709 } 716 }
710 717
711 vals[2] = atoi (buf); 718 esrv_move_object (pl->ob, to, tag, nrof);
712
713/* LOG(llevDebug,"Move item %d (nrof=%d) to %d.\n", vals[1], vals[2], vals[0]);*/
714 esrv_move_object (pl->ob, vals[0], vals[1], vals[2]);
715} 719}
716 720
717/****************************************************************************** 721/******************************************************************************
718 * 722 *
719 * Start of commands the server sends to the client. 723 * Start of commands the server sends to the client.
886 890
887/** 891/**
888 * Tells the client that here is a player it should start using. 892 * Tells the client that here is a player it should start using.
889 */ 893 */
890void 894void
891esrv_new_player (player *pl, uint32 weight) 895esrv_new_player (player *pl)
892{ 896{
897 sint32 weight = pl->ob->client_weight ();
898
893 packet sl ("player"); 899 packet sl ("player");
894 900
895 sl << uint32 (pl->ob->count) 901 sl << uint32 (pl->ob->count)
896 << uint32 (weight) 902 << uint32 (weight)
897 << uint32 (pl->ob->face) 903 << uint32 (pl->ob->face)
1031 1037
1032 /* If player is just joining the game, he isn't here yet, so the map 1038 /* If player is just joining the game, he isn't here yet, so the map
1033 * can get swapped out. If so, don't try to send them a map. All will 1039 * can get swapped out. If so, don't try to send them a map. All will
1034 * be OK once they really log in. 1040 * be OK once they really log in.
1035 */ 1041 */
1036 if (!plmap || plmap->in_memory != MAP_IN_MEMORY) 1042 if (!plmap || plmap->in_memory != MAP_ACTIVE)
1037 return; 1043 return;
1038 1044
1039 int x, y, ax, ay, startlen, max_x, max_y, oldlen; 1045 int x, y, ax, ay, startlen, max_x, max_y, oldlen;
1040 int estartlen, eoldlen; 1046 int estartlen, eoldlen;
1041 uint8 eentrysize; 1047 uint8 eentrysize;
1242 uint8 flags = 0; 1248 uint8 flags = 0;
1243 tag_t player = 0; 1249 tag_t player = 0;
1244 1250
1245 // send hp information, if applicable 1251 // send hp information, if applicable
1246 if (object *op = ms.faces_obj [0]) 1252 if (object *op = ms.faces_obj [0])
1253 if (op->is_head () && !op->invisible)
1247 { 1254 {
1248 if (op->head || op->invisible) 1255 if (op->stats.maxhp > op->stats.hp
1249 ; // do not show 1256 && op->stats.maxhp > 0
1250 else if (op->type == PLAYER 1257 && (op->type == PLAYER
1258 || op->type == DOOR // does not work, have maxhp 0
1251 || QUERY_FLAG (op, FLAG_MONSTER) || QUERY_FLAG (op, FLAG_ALIVE) || QUERY_FLAG (op, FLAG_GENERATOR)) 1259 || QUERY_FLAG (op, FLAG_MONSTER) || QUERY_FLAG (op, FLAG_ALIVE) || QUERY_FLAG (op, FLAG_GENERATOR)))
1252 {
1253 if (op->stats.maxhp > 0 && (unsigned) op->stats.maxhp > (unsigned) op->stats.hp)
1254 { 1260 {
1255 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; 1261 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
1256 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge 1262 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge
1257 } 1263 }
1258 }
1259 1264
1260 if (op->msg && op->msg[0] == '@') 1265 if (op->msg && op->msg[0] == '@')
1261 flags |= 1; 1266 flags |= 1;
1262 1267
1263 if (op->type == PLAYER && op != ob) 1268 if (op->type == PLAYER && op != ob)
1264 player = op->count; 1269 player = op->count;
1265 } 1270 }
1266 1271
1267 if (lastcell.stat_hp != stat_hp) 1272 if (lastcell.stat_hp != stat_hp)
1268 { 1273 {
1269 lastcell.stat_hp = stat_hp; 1274 lastcell.stat_hp = stat_hp;
1270 1275

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines