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.130 by root, Tue May 20 03:14:19 2008 UTC vs.
Revision 1.136 by root, Sun Aug 10 16:31:18 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
153 // first try to aovid a full newmap on tiled map scrolls 186 // first try to aovid a full newmap on tiled map scrolls
154 if (socket.current_map != ob->map) 187 if (socket.current_map != ob->map && !socket.force_newmap)
155 { 188 {
156 rv_vector rv; 189 rv_vector rv;
157 190
158 get_rangevector_from_mapcoord (socket.current_map, socket.current_x, socket.current_y, ob, &rv, 0); 191 get_rangevector_from_mapcoord (socket.current_map, socket.current_x, socket.current_y, ob, &rv, 0);
159 192
164 socket.current_x = ob->x; 197 socket.current_x = ob->x;
165 socket.current_y = ob->y; 198 socket.current_y = ob->y;
166 199
167 socket_map_scroll (&socket, rv.distance_x, rv.distance_y); 200 socket_map_scroll (&socket, rv.distance_x, rv.distance_y);
168 socket.floorbox_reset (); 201 socket.floorbox_reset ();
202 send_map_info (pl);
169 } 203 }
170 } 204 }
171 205
172 if (socket.current_map != ob->map || socket.force_newmap) 206 if (socket.current_map != ob->map || socket.force_newmap)
173 { 207 {
174 clear_map (pl); 208 clear_map (pl);
175 socket.current_map = ob->map; 209 socket.current_map = ob->map;
176 210 send_map_info (pl);
177 if (socket.mapinfocmd)
178 {
179 if (ob->map && ob->map->path[0])
180 {
181 int flags = 0;
182
183 if (ob->map->tile_path[0]) flags |= 1;
184 if (ob->map->tile_path[1]) flags |= 2;
185 if (ob->map->tile_path[2]) flags |= 4;
186 if (ob->map->tile_path[3]) flags |= 8;
187
188 socket.send_packet_printf ("mapinfo - spatial %d %d %d %d %d %s",
189 flags, socket.mapx / 2 - ob->x, socket.mapy / 2 - ob->y,
190 ob->map->width, ob->map->height, &ob->map->path);
191 }
192 else
193 socket.send_packet ("mapinfo current");
194 }
195 } 211 }
196 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)
197 { 213 {
198 int dx = ob->x - socket.current_x; 214 int dx = ob->x - socket.current_x;
199 int dy = ob->y - socket.current_y; 215 int dy = ob->y - socket.current_y;
207 } 223 }
208 } 224 }
209 225
210 socket.current_x = ob->x; 226 socket.current_x = ob->x;
211 socket.current_y = ob->y; 227 socket.current_y = ob->y;
212
213 region *reg = ob->region ();
214 if (socket.current_region != reg)
215 {
216 INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region));
217 socket.current_region = reg;
218 }
219} 228}
220 229
221/** 230/**
222 * RequestInfo is sort of a meta command. There is some specific 231 * RequestInfo is sort of a meta command. There is some specific
223 * request of information, but we call other functions to provide 232 * request of information, but we call other functions to provide
1168 1177
1169 int d = pl->blocked_los[ax][ay]; 1178 int d = pl->blocked_los[ax][ay];
1170 1179
1171 if (d > 3) 1180 if (d > 3)
1172 { 1181 {
1173
1174 int need_send = 0, count; 1182 int need_send = 0, count;
1175 1183
1176 /* This block deals with spaces that are not visible for whatever 1184 /* This block deals with spaces that are not visible for whatever
1177 * reason. Still may need to send the head for this space. 1185 * reason. Still may need to send the head for this space.
1178 */ 1186 */
1184 if (lastcell.count != -1) 1192 if (lastcell.count != -1)
1185 need_send = 1; 1193 need_send = 1;
1186 1194
1187 count = -1; 1195 count = -1;
1188 1196
1189 /* properly clear a previously sent big face */
1190 if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2] 1197 if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2]
1191 || lastcell.stat_hp || lastcell.flags || lastcell.player) 1198 || lastcell.stat_hp || lastcell.flags || lastcell.player)
1192 need_send = 1; 1199 need_send = 1;
1193 1200
1201 /* properly clear a previously sent big face */
1194 map_clearcell (&lastcell, count); 1202 map_clearcell (&lastcell, count);
1195 1203
1196 if ((mask & 0xf) || need_send) 1204 if ((mask & 0xf) || need_send)
1197 sl[oldlen + 1] = mask & 0xff; 1205 sl[oldlen + 1] = mask & 0xff;
1198 else 1206 else
1254 { 1262 {
1255 if (op->stats.maxhp > op->stats.hp 1263 if (op->stats.maxhp > op->stats.hp
1256 && op->stats.maxhp > 0 1264 && op->stats.maxhp > 0
1257 && (op->type == PLAYER 1265 && (op->type == PLAYER
1258 || op->type == DOOR // does not work, have maxhp 0 1266 || op->type == DOOR // does not work, have maxhp 0
1259 || QUERY_FLAG (op, FLAG_MONSTER) || QUERY_FLAG (op, FLAG_ALIVE) || QUERY_FLAG (op, FLAG_GENERATOR))) 1267 || QUERY_FLAG (op, FLAG_MONSTER)
1268 || QUERY_FLAG (op, FLAG_ALIVE)
1269 || QUERY_FLAG (op, FLAG_GENERATOR)))
1260 { 1270 {
1261 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; 1271 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
1262 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge 1272 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge
1263 } 1273 }
1264 1274
1265 if (op->msg && op->msg[0] == '@') 1275 if (op->has_dialogue ())
1266 flags |= 1; 1276 flags |= 1;
1267 1277
1268 if (op->type == PLAYER && op != ob) 1278 if (op->type == PLAYER)
1269 player = op->count; 1279 player = op == ob ? pl->ob->count
1280 : op == pl->ob ? ob->count
1281 : op->count;
1270 } 1282 }
1271 1283
1272 if (lastcell.stat_hp != stat_hp) 1284 if (lastcell.stat_hp != stat_hp)
1273 { 1285 {
1274 lastcell.stat_hp = stat_hp; 1286 lastcell.stat_hp = stat_hp;
1478 if (spell->type == SPELL) 1490 if (spell->type == SPELL)
1479 { 1491 {
1480 int flags = 0; 1492 int flags = 0;
1481 1493
1482 /* check if we need to update it */ 1494 /* check if we need to update it */
1483 if (spell->last_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) 1495 if (spell->cached_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA))
1484 { 1496 {
1485 spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); 1497 spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA);
1486 flags |= UPD_SP_MANA; 1498 flags |= UPD_SP_MANA;
1487 } 1499 }
1488 1500
1489 if (spell->last_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) 1501 if (spell->cached_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE))
1490 { 1502 {
1491 spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); 1503 spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE);
1492 flags |= UPD_SP_GRACE; 1504 flags |= UPD_SP_GRACE;
1493 } 1505 }
1494 1506
1495 if (spell->last_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) 1507 if (spell->cached_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell))
1496 { 1508 {
1497 spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); 1509 spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell);
1498 flags |= UPD_SP_DAMAGE; 1510 flags |= UPD_SP_DAMAGE;
1499 } 1511 }
1500 1512
1501 if (flags) 1513 if (flags)
1502 { 1514 {
1504 1516
1505 sl << "updspell " 1517 sl << "updspell "
1506 << uint8 (flags) 1518 << uint8 (flags)
1507 << uint32 (spell->count); 1519 << uint32 (spell->count);
1508 1520
1509 if (flags & UPD_SP_MANA ) sl << uint16 (spell->last_sp); 1521 if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp);
1510 if (flags & UPD_SP_GRACE ) sl << uint16 (spell->last_grace); 1522 if (flags & UPD_SP_GRACE ) sl << uint16 (spell->cached_grace);
1511 if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->last_eat); 1523 if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->cached_eat);
1512 1524
1513 pl->ns->send_packet (sl); 1525 pl->ns->send_packet (sl);
1514 } 1526 }
1515 } 1527 }
1516 } 1528 }
1546 LOG (llevError, "item number %d is a spell with no name.\n", spell->count); 1558 LOG (llevError, "item number %d is a spell with no name.\n", spell->count);
1547 return; 1559 return;
1548 } 1560 }
1549 1561
1550 /* store costs and damage in the object struct, to compare to later */ 1562 /* store costs and damage in the object struct, to compare to later */
1551 spell->last_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); 1563 spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA);
1552 spell->last_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); 1564 spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE);
1553 spell->last_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); 1565 spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell);
1554 1566
1555 /* figure out which skill it uses, if it uses one */ 1567 /* figure out which skill it uses, if it uses one */
1556 if (spell->skill) 1568 if (spell->skill)
1557 { 1569 {
1558 for (i = 1; i < NUM_SKILLS; i++) 1570 for (i = 1; i < NUM_SKILLS; i++)
1574 1586
1575 /* send the current values */ 1587 /* send the current values */
1576 sl << uint32 (spell->count) 1588 sl << uint32 (spell->count)
1577 << uint16 (spell->level) 1589 << uint16 (spell->level)
1578 << uint16 (spell->casting_time) 1590 << uint16 (spell->casting_time)
1579 << uint16 (spell->last_sp) 1591 << uint16 (spell->cached_sp)
1580 << uint16 (spell->last_grace) 1592 << uint16 (spell->cached_grace)
1581 << uint16 (spell->last_eat) 1593 << uint16 (spell->cached_eat)
1582 << uint8 (skill) 1594 << uint8 (skill)
1583 << uint32 (spell->path_attuned) 1595 << uint32 (spell->path_attuned)
1584 << uint32 (spell->face) 1596 << uint32 (spell->face)
1585 << data8 (spell->name) 1597 << data8 (spell->name)
1586 << data16 (spell->msg); 1598 << data16 (spell->msg);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines