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.133 by root, Sun Jul 13 11:57:25 2008 UTC vs.
Revision 1.142 by root, Sat Dec 20 02:32:31 2008 UTC

833 AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS); 833 AddIfShort (ns->last_stats.Wis, ob->stats.Wis, CS_STAT_WIS);
834 AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW); 834 AddIfShort (ns->last_stats.Pow, ob->stats.Pow, CS_STAT_POW);
835 AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA); 835 AddIfShort (ns->last_stats.Cha, ob->stats.Cha, CS_STAT_CHA);
836 836
837 for (int s = 0; s < NUM_SKILLS; s++) 837 for (int s = 0; s < NUM_SKILLS; s++)
838 if (object *skill = opl->last_skill_ob[s]) 838 if (object *skill = opl->last_skill_ob [s])
839 if (skill->stats.exp != ns->last_skill_exp [s]) 839 if (skill->stats.exp != ns->last_skill_exp [s])
840 { 840 {
841 ns->last_skill_exp [s] = skill->stats.exp; 841 ns->last_skill_exp [s] = skill->stats.exp;
842 842
843 /* Always send along the level if exp changes. This is only 843 /* Always send along the level if exp changes. This is only
912 << uint32 (pl->ob->face) 912 << uint32 (pl->ob->face)
913 << data8 (pl->ob->name); 913 << data8 (pl->ob->name);
914 914
915 pl->ns->last_weight = weight; 915 pl->ns->last_weight = weight;
916 pl->ns->send_packet (sl); 916 pl->ns->send_packet (sl);
917 SET_FLAG (pl->ob, FLAG_CLIENT_SENT);
918} 917}
919 918
920/****************************************************************************** 919/******************************************************************************
921 * 920 *
922 * Start of map related commands. 921 * Start of map related commands.
1040{ 1039{
1041 object *ob = pl->observe; 1040 object *ob = pl->observe;
1042 if (!ob->active) 1041 if (!ob->active)
1043 return; 1042 return;
1044 1043
1045 maptile *plmap = ob->map;
1046
1047 /* If player is just joining the game, he isn't here yet, so the map 1044 /* If player is just joining the game, he isn't here yet, so the map
1048 * can get swapped out. If so, don't try to send them a map. All will 1045 * can get swapped out. If so, don't try to send them a map. All will
1049 * be OK once they really log in. 1046 * be OK once they really log in.
1050 */ 1047 */
1051 if (!plmap || plmap->in_memory != MAP_ACTIVE) 1048 if (!ob->map || ob->map->in_memory != MAP_ACTIVE)
1052 return; 1049 return;
1053 1050
1054 int x, y, ax, ay, startlen, max_x, max_y, oldlen; 1051 int startlen, oldlen;
1055 int estartlen, eoldlen; 1052 int estartlen, eoldlen;
1056 uint8 eentrysize; 1053 uint8 eentrysize;
1057 uint16 ewhatstart, ewhatflag; 1054 uint16 ewhatstart, ewhatflag;
1058 uint8 extendedinfos; 1055 uint8 extendedinfos;
1059 1056
1060 check_map_change (pl); 1057 check_map_change (pl);
1061 prefetch_surrounding_maps (pl->ob); 1058 prefetch_surrounding_maps (pl->ob);
1062 1059
1063 /* do LOS after calls to update_position */ 1060 /* do LOS after calls to update_position */
1064 if (ob != pl->ob) 1061 if (ob != pl->ob)
1065 clear_los (pl); 1062 pl->clear_los (0);
1066 else if (pl->do_los) 1063 else if (pl->do_los)
1067 { 1064 {
1068 update_los (ob); 1065 update_los (ob);
1069 pl->do_los = 0; 1066 pl->do_los = 0;
1070 } 1067 }
1116 << uint8 (eentrysize); 1113 << uint8 (eentrysize);
1117 1114
1118 estartlen = esl.length (); 1115 estartlen = esl.length ();
1119 } 1116 }
1120 1117
1121 /* x,y are the real map locations. ax, ay are viewport relative
1122 * locations.
1123 */
1124 ay = 0;
1125
1126 /* We could do this logic as conditionals in the if statement, 1118 /* We could do this logic as conditionals in the if statement,
1127 * but that started to get a bit messy to look at. 1119 * but that started to get a bit messy to look at.
1128 */ 1120 */
1129 max_x = ob->x + (socket.mapx + 1) / 2; 1121 int hx = socket.mapx / 2;
1130 max_y = ob->y + (socket.mapy + 1) / 2; 1122 int hy = socket.mapy / 2;
1131 1123
1132 for (y = ob->y - socket.mapy / 2; y < max_y; y++, ay++) 1124 for (int dx = -hx; dx <= hx; dx++)
1133 { 1125 {
1134 sint16 nx, ny; 1126 sint16 nx, ny;
1135 maptile *m = 0; 1127 maptile *m = 0;
1136 1128
1137 ax = 0; 1129 for (int dy = -hy; dy <= hy; dy++)
1138 for (x = ob->x - socket.mapx / 2; x < max_x; x++, ax++)
1139 { 1130 {
1140 // check to see if we can simply go one right quickly 1131 // check to see if we can simply go one down quickly
1141 ++nx;
1142 if (m && nx >= m->width) 1132 if (m && ++ny >= m->height)
1143 m = 0; 1133 m = 0;
1144 1134
1135 // no, so do it the slow way
1145 if (!m) 1136 if (!m)
1146 { 1137 {
1147 nx = x; ny = y; m = plmap; 1138 nx = ob->x + dx; ny = ob->y + dy; m = ob->map;
1148 1139
1149 if (xy_normalise (m, nx, ny)) 1140 if (xy_normalise (m, nx, ny))
1150 m->touch (); 1141 m->touch ();
1151 else 1142 else
1152 m = 0; 1143 m = 0;
1153 } 1144 }
1154 1145
1146 int ax = dx + hx;
1147 int ay = dy + hy;
1148
1155 int emask, mask; 1149 int emask, mask;
1156 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4; 1150 emask = mask = (ax & 0x3f) << 10 | (ay & 0x3f) << 4;
1157 1151
1158 MapCell &lastcell = socket.lastmap.cells[ax][ay]; 1152 MapCell &lastcell = socket.lastmap.cells[ax][ay];
1159 1153
1160 /* If the coordinates are not valid, or it is too dark to see, 1154 /* If the coordinates are not valid, or it is too dark to see,
1161 * we tell the client as such 1155 * we tell the client as such
1162 */ 1156 */
1163 if (!m) 1157 if (!m)
1164 { 1158 {
1165 /* space is out of map. Update space and clear values 1159 /* space is out of map. Update space and clear values
1166 * if this hasn't already been done. If the space is out 1160 * if this hasn't already been done. If the space is out
1167 * of the map, it shouldn't have a head 1161 * of the map, it shouldn't have a head.
1168 */ 1162 */
1169 if (lastcell.count != -1) 1163 if (lastcell.count != -1)
1170 { 1164 {
1171 sl << uint16 (mask); 1165 sl << uint16 (mask);
1172 map_clearcell (&lastcell, -1); 1166 map_clearcell (&lastcell, -1);
1173 } 1167 }
1174 1168
1175 continue; 1169 continue;
1176 } 1170 }
1177 1171
1178 int d = pl->blocked_los[ax][ay]; 1172 int d = pl->blocked_los_uc (dx, dy);
1179 1173
1180 if (d > 3) 1174 if (d > 3)
1181 { 1175 {
1182 int need_send = 0, count; 1176 int need_send = 0, count;
1183 1177
1262 { 1256 {
1263 if (op->stats.maxhp > op->stats.hp 1257 if (op->stats.maxhp > op->stats.hp
1264 && op->stats.maxhp > 0 1258 && op->stats.maxhp > 0
1265 && (op->type == PLAYER 1259 && (op->type == PLAYER
1266 || op->type == DOOR // does not work, have maxhp 0 1260 || op->type == DOOR // does not work, have maxhp 0
1267 || QUERY_FLAG (op, FLAG_MONSTER) || QUERY_FLAG (op, FLAG_ALIVE) || QUERY_FLAG (op, FLAG_GENERATOR))) 1261 || QUERY_FLAG (op, FLAG_MONSTER)
1262 || QUERY_FLAG (op, FLAG_ALIVE)
1263 || QUERY_FLAG (op, FLAG_GENERATOR)))
1268 { 1264 {
1269 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; 1265 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
1270 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge 1266 stat_width = op->arch->max_x - op->arch->x; //TODO: should be upper-left edge
1271 } 1267 }
1272 1268
1273 if (op->msg && op->msg[0] == '@') 1269 if (op->has_dialogue ())
1274 flags |= 1; 1270 flags |= 1;
1275 1271
1276 if (op->type == PLAYER) 1272 if (op->type == PLAYER)
1277 player = op->count; 1273 player = op == ob ? pl->ob->count
1274 : op == pl->ob ? ob->count
1275 : op->count;
1278 } 1276 }
1279 1277
1280 if (lastcell.stat_hp != stat_hp) 1278 if (lastcell.stat_hp != stat_hp)
1281 { 1279 {
1282 lastcell.stat_hp = stat_hp; 1280 lastcell.stat_hp = stat_hp;
1325 1323
1326 /* Middle face */ 1324 /* Middle face */
1327 if (update_space (sl, socket, ms, lastcell, 1)) 1325 if (update_space (sl, socket, ms, lastcell, 1))
1328 mask |= 0x2; 1326 mask |= 0x2;
1329 1327
1328 if (ob->invisible
1329 && ob->invisible & (ob->invisible < 50 ? 1 : 7)
1330 if (ms.player () == ob 1330 && ms.player () == ob)
1331 && (ob->invisible & (ob->invisible < 50 ? 1 : 7)))
1332 { 1331 {
1333 // force player to be visible to himself if invisible 1332 // force player to be visible to himself if invisible
1334 if (lastcell.faces[0] != ob->face) 1333 if (lastcell.faces[0] != ob->face)
1335 { 1334 {
1336 lastcell.faces[0] = ob->face; 1335 lastcell.faces[0] = ob->face;
1432{ 1431{
1433 packet sl; 1432 packet sl;
1434 sl << "replyinfo skill_info\n"; 1433 sl << "replyinfo skill_info\n";
1435 1434
1436 for (int i = 1; i < NUM_SKILLS; i++) 1435 for (int i = 1; i < NUM_SKILLS; i++)
1437 sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names[i]); 1436 sl.printf ("%d:%s\n", i + CS_STAT_SKILLINFO, &skill_names [i]);
1438 1437
1439 if (sl.length () > MAXSOCKBUF) 1438 if (sl.length () > MAXSOCKBUF)
1440 { 1439 {
1441 LOG (llevError, "Buffer overflow in send_skill_info!\n"); 1440 LOG (llevError, "Buffer overflow in send_skill_info!\n");
1442 fatal (0); 1441 fatal (0);
1560 spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); 1559 spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE);
1561 spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); 1560 spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell);
1562 1561
1563 /* figure out which skill it uses, if it uses one */ 1562 /* figure out which skill it uses, if it uses one */
1564 if (spell->skill) 1563 if (spell->skill)
1565 { 1564 if (object *tmp = pl->find_skill (spell->skill))
1566 for (i = 1; i < NUM_SKILLS; i++)
1567 if (!strcmp (spell->skill, skill_names[i]))
1568 {
1569 skill = i + CS_STAT_SKILLINFO; 1565 skill = tmp->subtype + CS_STAT_SKILLINFO;
1570 break;
1571 }
1572 }
1573 1566
1574 // spells better have a face 1567 // spells better have a face
1575 if (!spell->face) 1568 if (!spell->face)
1576 { 1569 {
1577 LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); 1570 LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines