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.158 by root, Fri Nov 6 13:11:28 2009 UTC vs.
Revision 1.167 by root, Sat Apr 3 22:30:21 2010 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,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001,2007 Mark Wedel 5 * Copyright (©) 2001 Mark Wedel
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
576 * commands. 576 * commands.
577 */ 577 */
578 pl->count = 0; 578 pl->count = 0;
579 579
580 //TODO: schmorp thinks whatever this calculates, it makes no sense at all 580 //TODO: schmorp thinks whatever this calculates, it makes no sense at all
581 int time = fabs (pl->ob->speed) < 0.001 581 int time = pl->ob->has_active_speed ()
582 ? time = MAX_TIME * 100
583 : time = (int) (MAX_TIME / fabs (pl->ob->speed)); 582 ? (int) (MAX_TIME / pl->ob->speed)
583 : MAX_TIME * 100;
584 584
585 /* Send confirmation of command execution now */ 585 /* Send confirmation of command execution now */
586 packet sl ("comc"); 586 packet sl ("comc");
587 sl << uint16 (cmdid) << uint32 (time); 587 sl << uint16 (cmdid) << uint32 (time);
588 pl->ns->send_packet (sl); 588 pl->ns->send_packet (sl);
735 */ 735 */
736static void 736static void
737rangetostring (player *pl, char *obuf) 737rangetostring (player *pl, char *obuf)
738{ 738{
739 dynbuf_text &buf = msg_dynbuf; buf.clear (); 739 dynbuf_text &buf = msg_dynbuf; buf.clear ();
740
741#if 0
742 // print ranged/chosen_skill etc. objects every call
743 printf ("%s %s => %s (%s)\n",
744 pl->ranged_ob ? &pl->ranged_ob->name : "-",
745 pl->combat_ob ? &pl->combat_ob->name : "-",
746 pl->ob->current_weapon ? &pl->ob->current_weapon->name : "-",
747 pl->ob->chosen_skill ? &pl->ob->chosen_skill->name : "-"
748 );
749#endif
740 750
741 if (pl->ranged_ob) 751 if (pl->ranged_ob)
742 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; 752 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name;
743 753
744 if (pl->combat_ob) 754 if (pl->combat_ob)
838 AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); 848 AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64);
839 AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL); 849 AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL);
840 AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC); 850 AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC);
841 AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC); 851 AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC);
842 AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM); 852 AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM);
843 AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f/TICK); 853 AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f / TICK);
844 AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); 854 AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD);
845 AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f/TICK); 855 AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f / TICK);
846 AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); 856 AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM);
847 857
848 flags = 0; 858 flags = 0;
849 859
850 if (opl->fire_on) 860 if (opl->fire_on)
853 if (opl->run_on) 863 if (opl->run_on)
854 flags |= SF_RUNON; 864 flags |= SF_RUNON;
855 865
856 AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS); 866 AddIfShort (ns->last_flags, flags, CS_STAT_FLAGS);
857 867
858 if (ns->sc_version < 1025)
859 { AddIfShort (ns->last_resist[ATNR_PHYSICAL], ob->resist[ATNR_PHYSICAL], CS_STAT_ARMOUR) }
860 else
861 for (int i = 0; i < NROFATTACKS; i++) 868 for (int i = 0; i < NROFATTACKS; i++)
862 { 869 {
863 /* Skip ones we won't send */ 870 /* Skip ones we won't send */
864 if (atnr_cs_stat[i] == -1) 871 if (atnr_cs_stat[i] == -1)
865 continue; 872 continue;
866 873
867 AddIfShort (ns->last_resist[i], ob->resist[i], atnr_cs_stat[i]); 874 AddIfShort (ns->last_resist[i], ob->resist[i], atnr_cs_stat[i]);
868 } 875 }
869 876
870 if (pl->ns->monitor_spells) 877 if (pl->ns->monitor_spells)
871 { 878 {
872 AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); 879 AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE);
873 AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL); 880 AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL);
984prefetch_surrounding_maps (maptile *map, int distance) 991prefetch_surrounding_maps (maptile *map, int distance)
985{ 992{
986 map->touch (); 993 map->touch ();
987 994
988 if (--distance) 995 if (--distance)
989 for (int dir = 4; --dir; ) 996 for (int dir = 4; dir--; )
990 if (const shstr &path = map->tile_path [dir]) 997 if (const shstr &path = map->tile_path [dir])
991 if (maptile *&neigh = map->tile_map [dir]) 998 if (maptile *&neigh = map->tile_map [dir])
992 prefetch_surrounding_maps (neigh, distance); 999 prefetch_surrounding_maps (neigh, distance);
993 else 1000 else
994 neigh = maptile::find_async (path, map); 1001 neigh = maptile::find_async (path, map);
1087 map_clearcell (&lastcell, -1); 1094 map_clearcell (&lastcell, -1);
1088 } 1095 }
1089 1096
1090 continue; 1097 continue;
1091 } 1098 }
1092 1099
1093 int d = pl->blocked_los_uc (dx, dy); 1100 int d = pl->blocked_los_uc (dx, dy);
1094 1101
1095 if (d > 3) 1102 if (d > 3)
1096 { 1103 {
1097 /* This block deals with spaces that are not visible for whatever 1104 /* This block deals with spaces that are not visible for whatever
1276esrv_update_spells (player *pl) 1283esrv_update_spells (player *pl)
1277{ 1284{
1278 if (!pl->ns) 1285 if (!pl->ns)
1279 return; 1286 return;
1280 1287
1288 pl->ns->update_spells = false;
1289
1281 if (!pl->ns->monitor_spells) 1290 if (!pl->ns->monitor_spells)
1282 return; 1291 return;
1283 1292
1284 for (object *spell = pl->ob->inv; spell; spell = spell->below) 1293 for (object *spell = pl->ob->inv; spell; spell = spell->below)
1285 {
1286 if (spell->type == SPELL) 1294 if (spell->type == SPELL)
1287 { 1295 {
1288 int flags = 0; 1296 int flags = 0;
1297 int val;
1289 1298
1290 /* check if we need to update it */ 1299 /* check if we need to update it */
1291 if (spell->cached_sp != SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA)) 1300 val = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA);
1301 if (spell->cached_sp != val)
1292 { 1302 {
1293 spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); 1303 spell->cached_sp = val;
1294 flags |= UPD_SP_MANA; 1304 flags |= UPD_SP_MANA;
1295 } 1305 }
1296 1306
1297 if (spell->cached_grace != SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE)) 1307 val = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE);
1308 if (spell->cached_grace != val)
1298 { 1309 {
1299 spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); 1310 spell->cached_grace = val;
1300 flags |= UPD_SP_GRACE; 1311 flags |= UPD_SP_GRACE;
1301 } 1312 }
1302 1313
1303 if (spell->cached_eat != spell->stats.dam + SP_level_dam_adjust (pl->ob, spell)) 1314 val = casting_level (pl->ob, spell);
1315 if (spell->cached_eat != val)
1304 { 1316 {
1305 spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); 1317 spell->cached_eat = val;
1306 flags |= UPD_SP_DAMAGE; 1318 flags |= UPD_SP_LEVEL;
1307 } 1319 }
1308 1320
1309 if (flags) 1321 if (flags)
1310 { 1322 {
1311 packet sl; 1323 packet sl;
1312 1324
1313 sl << "updspell " 1325 sl << "updspell "
1314 << uint8 (flags) 1326 << uint8 (flags)
1315 << uint32 (spell->count); 1327 << uint32 (spell->count);
1316 1328
1317 if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp); 1329 if (flags & UPD_SP_MANA ) sl << uint16 (spell->cached_sp);
1318 if (flags & UPD_SP_GRACE ) sl << uint16 (spell->cached_grace); 1330 if (flags & UPD_SP_GRACE) sl << uint16 (spell->cached_grace);
1319 if (flags & UPD_SP_DAMAGE) sl << uint16 (spell->cached_eat); 1331 if (flags & UPD_SP_LEVEL) sl << uint16 (spell->cached_eat);
1320 1332
1321 pl->ns->send_packet (sl); 1333 pl->ns->send_packet (sl);
1322 } 1334 }
1323 } 1335 }
1324 }
1325} 1336}
1326 1337
1327void 1338void
1328esrv_remove_spell (player *pl, object *spell) 1339esrv_remove_spell (player *pl, object *spell)
1329{ 1340{
1356 } 1367 }
1357 1368
1358 /* store costs and damage in the object struct, to compare to later */ 1369 /* store costs and damage in the object struct, to compare to later */
1359 spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA); 1370 spell->cached_sp = SP_level_spellpoint_cost (pl->ob, spell, SPELL_MANA);
1360 spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE); 1371 spell->cached_grace = SP_level_spellpoint_cost (pl->ob, spell, SPELL_GRACE);
1361 spell->cached_eat = spell->stats.dam + SP_level_dam_adjust (pl->ob, spell); 1372 spell->cached_eat = casting_level (pl->ob, spell);
1362 1373
1363 /* figure out which skill it uses, if it uses one */ 1374 /* figure out which skill it uses, if it uses one */
1364 if (spell->skill) 1375 if (spell->skill)
1365 if (object *tmp = pl->find_skill (spell->skill)) 1376 if (object *tmp = pl->find_skill (spell->skill))
1366 skill = tmp->subtype + CS_STAT_SKILLINFO; 1377 skill = tmp->subtype + CS_STAT_SKILLINFO;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines