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.129 by root, Tue May 6 19:37:01 2008 UTC vs.
Revision 1.137 by root, Sun Aug 31 02:01:41 2008 UTC

141 pl->ns->send_packet ("newmap"); 141 pl->ns->send_packet ("newmap");
142 142
143 pl->ns->floorbox_reset (); 143 pl->ns->floorbox_reset ();
144} 144}
145 145
146static void
147send_map_info (player *pl)
148{
149 client &socket = *pl->ns;
150 object *ob = pl->observe;
151
152 if (socket.mapinfocmd)
153 {
154 if (ob->map && ob->map->path[0])
155 {
156 int flags = 0;
157
158 if (ob->map->tile_path[0]) flags |= 1;
159 if (ob->map->tile_path[1]) flags |= 2;
160 if (ob->map->tile_path[2]) flags |= 4;
161 if (ob->map->tile_path[3]) flags |= 8;
162
163 socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s",
164 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y,
165 ob->map->width, ob->map->height, &ob->map->path);
166 }
167 else
168 socket.send_packet ("mapinfo current");
169 }
170}
171
146/** check for map/region change and send new map data */ 172/** check for map/region change and send new map data */
147static void 173static void
148check_map_change (player *pl) 174check_map_change (player *pl)
149{ 175{
150 client &socket = *pl->ns; 176 client &socket = *pl->ns;
151 object *ob = pl->observe; 177 object *ob = pl->observe;
152 178
179 region *reg = ob->region ();
180 if (socket.current_region != reg)
181 {
182 INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region));
183 socket.current_region = reg;
184 }
185
186 // first try to aovid a full newmap on tiled map scrolls
187 if (socket.current_map != ob->map && !socket.force_newmap)
188 {
189 rv_vector rv;
190
191 get_rangevector_from_mapcoord (socket.current_map, socket.current_x, socket.current_y, ob, &rv, 0);
192
193 // manhattan distance is very handy here
194 if (rv.distance < 8) // 8 works nicely for speed << 70 and buggy gcfclient
195 {
196 socket.current_map = ob->map;
197 socket.current_x = ob->x;
198 socket.current_y = ob->y;
199
200 socket_map_scroll (&socket, rv.distance_x, rv.distance_y);
201 socket.floorbox_reset ();
202 send_map_info (pl);
203 }
204 }
205
153 if (socket.current_map != ob->map || socket.force_newmap) 206 if (socket.current_map != ob->map || socket.force_newmap)
154 { 207 {
155 clear_map (pl); 208 clear_map (pl);
156 socket.current_map = ob->map; 209 socket.current_map = ob->map;
157 210 send_map_info (pl);
158 if (socket.mapinfocmd)
159 {
160 if (ob->map && ob->map->path[0])
161 {
162 int flags = 0;
163
164 if (ob->map->tile_path[0]) flags |= 1;
165 if (ob->map->tile_path[1]) flags |= 2;
166 if (ob->map->tile_path[2]) flags |= 4;
167 if (ob->map->tile_path[3]) flags |= 8;
168
169 socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s",
170 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y,
171 ob->map->width, ob->map->height, &ob->map->path);
172 }
173 else
174 socket.send_packet ("mapinfo current");
175 }
176 } 211 }
177 else if (socket.current_x != ob->x || socket.current_y != ob->y) 212 else if (socket.current_x != ob->x || socket.current_y != ob->y)
178 { 213 {
179 int dx = ob->x - socket.current_x; 214 int dx = ob->x - socket.current_x;
180 int dy = ob->y - socket.current_y; 215 int dy = ob->y - socket.current_y;
188 } 223 }
189 } 224 }
190 225
191 socket.current_x = ob->x; 226 socket.current_x = ob->x;
192 socket.current_y = ob->y; 227 socket.current_y = ob->y;
193
194 region *reg = ob->region ();
195 if (socket.current_region != reg)
196 {
197 INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region));
198 socket.current_region = reg;
199 }
200} 228}
201 229
202/** 230/**
203 * RequestInfo is sort of a meta command. There is some specific 231 * RequestInfo is sort of a meta command. There is some specific
204 * request of information, but we call other functions to provide 232 * request of information, but we call other functions to provide
884 << uint32 (pl->ob->face) 912 << uint32 (pl->ob->face)
885 << data8 (pl->ob->name); 913 << data8 (pl->ob->name);
886 914
887 pl->ns->last_weight = weight; 915 pl->ns->last_weight = weight;
888 pl->ns->send_packet (sl); 916 pl->ns->send_packet (sl);
889 SET_FLAG (pl->ob, FLAG_CLIENT_SENT);
890} 917}
891 918
892/****************************************************************************** 919/******************************************************************************
893 * 920 *
894 * Start of map related commands. 921 * Start of map related commands.
1149 1176
1150 int d = pl->blocked_los[ax][ay]; 1177 int d = pl->blocked_los[ax][ay];
1151 1178
1152 if (d > 3) 1179 if (d > 3)
1153 { 1180 {
1154
1155 int need_send = 0, count; 1181 int need_send = 0, count;
1156 1182
1157 /* This block deals with spaces that are not visible for whatever 1183 /* This block deals with spaces that are not visible for whatever
1158 * reason. Still may need to send the head for this space. 1184 * reason. Still may need to send the head for this space.
1159 */ 1185 */
1165 if (lastcell.count != -1) 1191 if (lastcell.count != -1)
1166 need_send = 1; 1192 need_send = 1;
1167 1193
1168 count = -1; 1194 count = -1;
1169 1195
1170 /* properly clear a previously sent big face */
1171 if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2] 1196 if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2]
1172 || lastcell.stat_hp || lastcell.flags || lastcell.player) 1197 || lastcell.stat_hp || lastcell.flags || lastcell.player)
1173 need_send = 1; 1198 need_send = 1;
1174 1199
1200 /* properly clear a previously sent big face */
1175 map_clearcell (&lastcell, count); 1201 map_clearcell (&lastcell, count);
1176 1202
1177 if ((mask & 0xf) || need_send) 1203 if ((mask & 0xf) || need_send)
1178 sl[oldlen + 1] = mask & 0xff; 1204 sl[oldlen + 1] = mask & 0xff;
1179 else 1205 else
1235 { 1261 {
1236 if (op->stats.maxhp > op->stats.hp 1262 if (op->stats.maxhp > op->stats.hp
1237 && op->stats.maxhp > 0 1263 && op->stats.maxhp > 0
1238 && (op->type == PLAYER 1264 && (op->type == PLAYER
1239 || op->type == DOOR // does not work, have maxhp 0 1265 || op->type == DOOR // does not work, have maxhp 0
1240 || QUERY_FLAG (op, FLAG_MONSTER) || QUERY_FLAG (op, FLAG_ALIVE) || QUERY_FLAG (op, FLAG_GENERATOR))) 1266 || QUERY_FLAG (op, FLAG_MONSTER)
1267 || QUERY_FLAG (op, FLAG_ALIVE)
1268 || QUERY_FLAG (op, FLAG_GENERATOR)))
1241 { 1269 {
1242 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; 1270 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
1243 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge 1271 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge
1244 } 1272 }
1245 1273
1246 if (op->msg && op->msg[0] == '@') 1274 if (op->has_dialogue ())
1247 flags |= 1; 1275 flags |= 1;
1248 1276
1249 if (op->type == PLAYER && op != ob) 1277 if (op->type == PLAYER)
1250 player = op->count; 1278 player = op == ob ? pl->ob->count
1279 : op == pl->ob ? ob->count
1280 : op->count;
1251 } 1281 }
1252 1282
1253 if (lastcell.stat_hp != stat_hp) 1283 if (lastcell.stat_hp != stat_hp)
1254 { 1284 {
1255 lastcell.stat_hp = stat_hp; 1285 lastcell.stat_hp = stat_hp;
1459 if (spell->type == SPELL) 1489 if (spell->type == SPELL)
1460 { 1490 {
1461 int flags = 0; 1491 int flags = 0;
1462 1492
1463 /* check if we need to update it */ 1493 /* check if we need to update it */
1464 if (spell->last_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) 1494 if (spell->cached_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA))
1465 { 1495 {
1466 spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); 1496 spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA);
1467 flags |= UPD_SP_MANA; 1497 flags |= UPD_SP_MANA;
1468 } 1498 }
1469 1499
1470 if (spell->last_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) 1500 if (spell->cached_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE))
1471 { 1501 {
1472 spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); 1502 spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE);
1473 flags |= UPD_SP_GRACE; 1503 flags |= UPD_SP_GRACE;
1474 } 1504 }
1475 1505
1476 if (spell->last_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) 1506 if (spell->cached_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell))
1477 { 1507 {
1478 spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); 1508 spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell);
1479 flags |= UPD_SP_DAMAGE; 1509 flags |= UPD_SP_DAMAGE;
1480 } 1510 }
1481 1511
1482 if (flags) 1512 if (flags)
1483 { 1513 {
1485 1515
1486 sl << "updspell " 1516 sl << "updspell "
1487 << uint8 (flags) 1517 << uint8 (flags)
1488 << uint32 (spell->count); 1518 << uint32 (spell->count);
1489 1519
1490 if (flags & UPD_SP_MANA ) sl << uint16 (spell->last_sp); 1520 if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp);
1491 if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace); 1521 if (flags & UPD_SP_GRACE ) sl << uint16 (spell->cached_grace);
1492 if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat); 1522 if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->cached_eat);
1493 1523
1494 pl->ns->send_packet (sl); 1524 pl->ns->send_packet (sl);
1495 } 1525 }
1496 } 1526 }
1497 } 1527 }
1527 LOG (llevError, "item number %d is a spell with no name.\n", spell->count); 1557 LOG (llevError, "item number %d is a spell with no name.\n", spell->count);
1528 return; 1558 return;
1529 } 1559 }
1530 1560
1531 /* store costs and damage in the object struct, to compare to later */ 1561 /* store costs and damage in the object struct, to compare to later */
1532 spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); 1562 spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA);
1533 spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); 1563 spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE);
1534 spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); 1564 spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell);
1535 1565
1536 /* figure out which skill it uses, if it uses one */ 1566 /* figure out which skill it uses, if it uses one */
1537 if (spell->skill) 1567 if (spell->skill)
1538 { 1568 {
1539 for (i = 1; i < NUM_SKILLS; i++) 1569 for (i = 1; i < NUM_SKILLS; i++)
1555 1585
1556 /* send the current values */ 1586 /* send the current values */
1557 sl << uint32 (spell->count) 1587 sl << uint32 (spell->count)
1558 << uint16 (spell->level) 1588 << uint16 (spell->level)
1559 << uint16 (spell->casting_time) 1589 << uint16 (spell->casting_time)
1560 << uint16 (spell->last_sp) 1590 << uint16 (spell->cached_sp)
1561 << uint16 (spell->last_grace) 1591 << uint16 (spell->cached_grace)
1562 << uint16 (spell->last_eat) 1592 << uint16 (spell->cached_eat)
1563 << uint8 (skill) 1593 << uint8 (skill)
1564 << uint32 (spell->path_attuned) 1594 << uint32 (spell->path_attuned)
1565 << uint32 (spell->face) 1595 << uint32 (spell->face)
1566 << data8 (spell->name) 1596 << data8 (spell->name)
1567 << data16 (spell->msg); 1597 << data16 (spell->msg);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines