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.132 by elmex, Sun Jun 15 19:34:31 2008 UTC vs.
Revision 1.141 by root, Fri Dec 19 22:47:30 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
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
1183 int need_send = 0, count; 1176 int need_send = 0, count;
1184 1177
1185 /* This block deals with spaces that are not visible for whatever 1178 /* This block deals with spaces that are not visible for whatever
1186 * reason. Still may need to send the head for this space. 1179 * reason. Still may need to send the head for this space.
1187 */ 1180 */
1193 if (lastcell.count != -1) 1186 if (lastcell.count != -1)
1194 need_send = 1; 1187 need_send = 1;
1195 1188
1196 count = -1; 1189 count = -1;
1197 1190
1198 /* properly clear a previously sent big face */
1199 if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2] 1191 if (lastcell.faces[0] || lastcell.faces[1] || lastcell.faces[2]
1200 || lastcell.stat_hp || lastcell.flags || lastcell.player) 1192 || lastcell.stat_hp || lastcell.flags || lastcell.player)
1201 need_send = 1; 1193 need_send = 1;
1202 1194
1195 /* properly clear a previously sent big face */
1203 map_clearcell (&lastcell, count); 1196 map_clearcell (&lastcell, count);
1204 1197
1205 if ((mask & 0xf) || need_send) 1198 if ((mask & 0xf) || need_send)
1206 sl[oldlen + 1] = mask & 0xff; 1199 sl[oldlen + 1] = mask & 0xff;
1207 else 1200 else
1263 { 1256 {
1264 if (op->stats.maxhp > op->stats.hp 1257 if (op->stats.maxhp > op->stats.hp
1265 && op->stats.maxhp > 0 1258 && op->stats.maxhp > 0
1266 && (op->type == PLAYER 1259 && (op->type == PLAYER
1267 || op->type == DOOR // does not work, have maxhp 0 1260 || op->type == DOOR // does not work, have maxhp 0
1268 || 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)))
1269 { 1264 {
1270 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp; 1265 stat_hp = 255 - (op->stats.hp * 255 + 254) / op->stats.maxhp;
1271 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
1272 } 1267 }
1273 1268
1274 if (op->msg && op->msg[0] == '@') 1269 if (op->has_dialogue ())
1275 flags |= 1; 1270 flags |= 1;
1276 1271
1277 if (op->type == PLAYER && op != ob) 1272 if (op->type == PLAYER)
1278 player = op->count; 1273 player = op == ob ? pl->ob->count
1274 : op == pl->ob ? ob->count
1275 : op->count;
1279 } 1276 }
1280 1277
1281 if (lastcell.stat_hp != stat_hp) 1278 if (lastcell.stat_hp != stat_hp)
1282 { 1279 {
1283 lastcell.stat_hp = stat_hp; 1280 lastcell.stat_hp = stat_hp;
1326 1323
1327 /* Middle face */ 1324 /* Middle face */
1328 if (update_space (sl, socket, ms, lastcell, 1)) 1325 if (update_space (sl, socket, ms, lastcell, 1))
1329 mask |= 0x2; 1326 mask |= 0x2;
1330 1327
1328 if (ob->invisible
1329 && ob->invisible & (ob->invisible < 50 ? 1 : 7)
1331 if (ms.player () == ob 1330 && ms.player () == ob)
1332 && (ob->invisible & (ob->invisible < 50 ? 1 : 7)))
1333 { 1331 {
1334 // force player to be visible to himself if invisible 1332 // force player to be visible to himself if invisible
1335 if (lastcell.faces[0] != ob->face) 1333 if (lastcell.faces[0] != ob->face)
1336 { 1334 {
1337 lastcell.faces[0] = ob->face; 1335 lastcell.faces[0] = ob->face;
1433{ 1431{
1434 packet sl; 1432 packet sl;
1435 sl << "replyinfo skill_info\n"; 1433 sl << "replyinfo skill_info\n";
1436 1434
1437 for (int i = 1; i < NUM_SKILLS; i++) 1435 for (int i = 1; i < NUM_SKILLS; i++)
1438 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]);
1439 1437
1440 if (sl.length () > MAXSOCKBUF) 1438 if (sl.length () > MAXSOCKBUF)
1441 { 1439 {
1442 LOG (llevError, "Buffer overflow in send_skill_info!\n"); 1440 LOG (llevError, "Buffer overflow in send_skill_info!\n");
1443 fatal (0); 1441 fatal (0);
1561 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);
1562 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);
1563 1561
1564 /* figure out which skill it uses, if it uses one */ 1562 /* figure out which skill it uses, if it uses one */
1565 if (spell->skill) 1563 if (spell->skill)
1566 { 1564 if (object *tmp = pl->find_skill (spell->skill))
1567 for (i = 1; i < NUM_SKILLS; i++)
1568 if (!strcmp (spell->skill, skill_names[i]))
1569 {
1570 skill = i + CS_STAT_SKILLINFO; 1565 skill = tmp->subtype + CS_STAT_SKILLINFO;
1571 break;
1572 }
1573 }
1574 1566
1575 // spells better have a face 1567 // spells better have a face
1576 if (!spell->face) 1568 if (!spell->face)
1577 { 1569 {
1578 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