--- deliantra/server/server/spell_attack.C 2006/09/14 23:13:49 1.14 +++ deliantra/server/server/spell_attack.C 2006/12/20 09:14:22 1.21 @@ -59,7 +59,7 @@ /*LOG (llevDebug, "DEBUG: arch weighs %d and masses %d (%s,level %d)\n", op->weight,weight_move,op->name,op->level); */ } - for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) + for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) { int num_sections = 1; @@ -119,7 +119,7 @@ { int new_dir = 1; /* direction or -1 for left, +1 for right 0 if no new bolt */ int t_dir; /* stores temporary dir calculation */ - mapstruct *m; + maptile *m; sint16 sx, sy; object *new_bolt; @@ -142,8 +142,7 @@ return; /* OK, we made a fork */ - new_bolt = get_object (); - copy_object (tmp, new_bolt); + new_bolt = tmp->clone (); /* reduce chances of subsequent forking */ new_bolt->stats.Dex -= 10; @@ -172,12 +171,11 @@ object *tmp; int mflags; sint16 x, y; - mapstruct *m; + maptile *m; if (--(op->duration) < 0) { - remove_ob (op); - free_object (op); + op->destroy (); return; } @@ -252,8 +250,8 @@ } else { /* Create a copy of this object and put it ahead */ - tmp = get_object (); - copy_object (op, tmp); + tmp = op->clone (); + tmp->speed_left = -0.1; tmp->x += DIRX (tmp), tmp->y += DIRY (tmp); tmp = insert_ob_in_map (tmp, op->map, op, 0); @@ -312,7 +310,7 @@ if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) SET_ANIMATION (tmp, dir); - set_owner (tmp, op); + tmp->set_owner (op); set_spell_skill (op, caster, spob, tmp); tmp->x = op->x + DIRX (tmp); @@ -322,23 +320,27 @@ mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); if (mflags & P_OUT_OF_MAP) { - free_object (tmp); + tmp->destroy (); return 0; } + if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) { if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) { - free_object (tmp); + tmp->destroy (); return 0; } + tmp->x = op->x; tmp->y = op->y; tmp->direction = absdir (tmp->direction + 4); tmp->map = op->map; } + if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) move_bolt (tmp); + return 1; } @@ -358,15 +360,15 @@ explosion (object *op) { object *tmp; - mapstruct *m = op->map; + maptile *m = op->map; int i; if (--(op->duration) < 0) { - remove_ob (op); - free_object (op); + op->destroy (); return; } + hit_map (op, 0, op->attacktype, 0); if (op->range > 0) @@ -382,8 +384,7 @@ */ if (ok_to_put_more (op->map, dx, dy, op, op->attacktype)) { - tmp = get_object (); - copy_object (op, tmp); + tmp = op->clone (); tmp->state = 0; tmp->speed_left = -0.21; tmp->range--; @@ -409,8 +410,7 @@ if (op->other_arch == NULL) { LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); - remove_ob (op); - free_object (op); + op->destroy (); return; } @@ -422,11 +422,11 @@ if (env->map == NULL || out_of_map (env->map, env->x, env->y)) { LOG (llevError, "BUG: explode_bullet(): env out of map\n"); - remove_ob (op); - free_object (op); + op->destroy (); return; } - remove_ob (op); + + op->remove (); op->x = env->x; op->y = env->y; insert_ob_in_map (op, env->map, op, INS_NO_MERGE | INS_NO_WALK_ON); @@ -434,8 +434,7 @@ else if (out_of_map (op->map, op->x, op->y)) { LOG (llevError, "BUG: explode_bullet(): op out of map\n"); - remove_ob (op); - free_object (op); + op->destroy (); return; } @@ -444,8 +443,7 @@ // bad at the moment that might happen from this. if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) { - remove_ob (op); - free_object (op); + op->destroy (); return; } @@ -459,15 +457,14 @@ /* other_arch contains what this explodes into */ tmp = arch_to_object (op->other_arch); - copy_owner (tmp, op); + tmp->set_owner (op); tmp->skill = op->skill; - owner = get_owner (op); + owner = op->owner; if ((tmp->attacktype & AT_HOLYWORD || tmp->attacktype & AT_GODPOWER) && owner && !tailor_god_spell (tmp, owner)) { - remove_ob (op); - free_object (op); + op->destroy (); return; } @@ -507,8 +504,7 @@ /* remove the firebullet */ if (!op->destroyed ()) { - remove_ob (op); - free_object (op); + op->destroy (); } } @@ -523,7 +519,7 @@ { object *tmp; int dam, mflags; - mapstruct *m; + maptile *m; sint16 sx, sy; mflags = get_map_flags (op->map, &m, op->x, op->y, &sx, &sy); @@ -542,7 +538,7 @@ if (!(mflags & P_IS_ALIVE)) return; - for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) + for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) { if (QUERY_FLAG (tmp, FLAG_ALIVE)) { @@ -551,8 +547,7 @@ { if (!QUERY_FLAG (op, FLAG_REMOVED)) { - remove_ob (op); - free_object (op); + op->destroy (); return; } } @@ -572,7 +567,7 @@ { sint16 new_x, new_y; int mflags; - mapstruct *m; + maptile *m; #if 0 /* We need a better general purpose way to do this */ @@ -591,14 +586,10 @@ if (--op->range <= 0) { if (op->other_arch) - { - explode_bullet (op); - } + explode_bullet (op); else - { - remove_ob (op); - free_object (op); - } + op->destroy (); + return; } @@ -609,26 +600,21 @@ if (mflags & P_OUT_OF_MAP) { - remove_ob (op); - free_object (op); + op->destroy (); return; } if (!op->direction || OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) { if (op->other_arch) - { - explode_bullet (op); - } + explode_bullet (op); else - { - remove_ob (op); - free_object (op); - } + op->destroy (); + return; } - remove_ob (op); + op->remove (); op->x = new_x; op->y = new_y; if ((op = insert_ob_in_map (op, m, op, 0)) == NULL) @@ -687,7 +673,7 @@ if (QUERY_FLAG (tmp, FLAG_IS_TURNABLE)) SET_ANIMATION (tmp, dir); - set_owner (tmp, op); + tmp->set_owner (op); set_spell_skill (op, caster, spob, tmp); tmp->x = op->x + freearr_x[dir]; @@ -697,25 +683,27 @@ mflags = get_map_flags (tmp->map, &tmp->map, tmp->x, tmp->y, &tmp->x, &tmp->y); if (mflags & P_OUT_OF_MAP) { - free_object (tmp); + tmp->destroy (); return 0; } + if (OB_TYPE_MOVE_BLOCK (tmp, GET_MAP_MOVE_BLOCK (tmp->map, tmp->x, tmp->y))) { if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) { - free_object (tmp); + tmp->destroy (); return 0; } + tmp->x = op->x; tmp->y = op->y; tmp->direction = absdir (tmp->direction + 4); tmp->map = op->map; } + if ((tmp = insert_ob_in_map (tmp, tmp->map, op, 0)) != NULL) - { - check_bullet (tmp); - } + check_bullet (tmp); + return 1; } @@ -738,7 +726,7 @@ new_ob->x = op->x; new_ob->y = op->y; new_ob->level = op->level; - set_owner (new_ob, op->owner); + new_ob->set_owner (op->owner); /* preserve skill ownership */ if (op->skill && op->skill != new_ob->skill) @@ -777,10 +765,9 @@ * when their cone dies when they die. */ /* If no owner left, the spell dies out. */ - if (get_owner (op) == NULL) + if (op->owner == NULL) { - remove_ob (op); - free_object (op); + op->destroy (); return; } #endif @@ -799,8 +786,7 @@ if ((op->duration--) < 0) { - remove_ob (op); - free_object (op); + op->destroy (); return; } /* Object has hit maximum range, so don't have it move @@ -819,9 +805,8 @@ if (ok_to_put_more (op->map, x, y, op, op->attacktype)) { - object *tmp = get_object (); + object *tmp = op->clone (); - copy_object (op, tmp); tmp->x = x; tmp->y = y; @@ -849,7 +834,7 @@ { object *tmp; int i, success = 0, range_min = -1, range_max = 1; - mapstruct *m; + maptile *m; sint16 sx, sy; MoveType movetype; @@ -915,7 +900,7 @@ success = 1; tmp = arch_to_object (spell->other_arch); - set_owner (tmp, op); + tmp->set_owner (op); set_spell_skill (op, caster, spell, tmp); tmp->level = caster_level (caster, spell); tmp->x = sx; @@ -1014,7 +999,7 @@ if (env->type == PLAYER) esrv_del_item (env->contr, op->count); - remove_ob (op); + op->remove (); op->x = env->x; op->y = env->y; if ((op = insert_ob_in_map (op, env->map, op, 0)) == NULL) @@ -1026,8 +1011,7 @@ // as bombs can be carried. if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) { - remove_ob (op); - free_object (op); + op->destroy (); return; } @@ -1048,7 +1032,7 @@ tmp->stats.dam = op->stats.dam; tmp->duration = op->duration; tmp->attacktype = op->attacktype; - copy_owner (tmp, op); + tmp->set_owner (op); if (op->skill && op->skill != tmp->skill) { tmp->skill = op->skill; @@ -1072,7 +1056,7 @@ object *tmp; int mflags; sint16 dx = op->x + freearr_x[dir], dy = op->y + freearr_y[dir]; - mapstruct *m; + maptile *m; mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) @@ -1088,7 +1072,7 @@ tmp->duration = spell->duration + SP_level_duration_adjust (caster, spell); tmp->attacktype = spell->attacktype; - set_owner (tmp, op); + tmp->set_owner (op); set_spell_skill (op, caster, spell, tmp); tmp->x = dx; tmp->y = dy; @@ -1118,7 +1102,7 @@ object *target; sint16 x, y; int dist, mflags; - mapstruct *mp; + maptile *mp; if (dir == 0) return NULL; @@ -1141,7 +1125,7 @@ if (mflags & P_IS_ALIVE) { - for (target = get_map_ob (mp, x, y); target; target = target->above) + for (target = GET_MAP_OB (mp, x, y); target; target = target->above) { if (QUERY_FLAG (target->head ? target->head : target, FLAG_MONSTER)) { @@ -1218,8 +1202,7 @@ effect->level = spell->stats.dam + SP_level_dam_adjust (caster, spell); /* casting death spells at undead isn't a good thing */ - if QUERY_FLAG - (target, FLAG_UNDEAD) + if (QUERY_FLAG (target, FLAG_UNDEAD)) { if (random_roll (0, 2, op, PREFER_LOW)) { @@ -1231,7 +1214,7 @@ { new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); target->stats.hp = target->stats.maxhp * 2; - free_object (effect); + effect->destroy (); return 0; } } @@ -1242,7 +1225,7 @@ effect->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); } - set_owner (effect, op); + effect->set_owner (op); set_spell_skill (op, caster, spell, effect); /* ok, tell it where to be, and insert! */ @@ -1268,24 +1251,22 @@ int i, mflags; object *owner; sint16 new_x, new_y; - mapstruct *m; + maptile *m; if (op->range-- <= 0) { - remove_ob (op); - free_object (op); + op->destroy (); return; } - owner = get_owner (op); + owner = op->owner; #if 0 /* It'd make things nastier if this wasn't here - spells cast by * monster that are then killed would continue to survive */ if (owner == NULL) { - remove_ob (op); - free_object (op); + op->destroy (); return; } #endif @@ -1302,23 +1283,23 @@ * we need to remove it if someone hasn't already done so. */ if (!op->destroyed ()) - free_object (op); + op->destroy (); return; } - remove_ob (op); + op->remove (); if (!op->direction || (mflags & P_OUT_OF_MAP)) { - free_object (op); + op->destroy (); return; } op->x = new_x; op->y = new_y; op->map = m; - i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); + i = spell_find_dir (op->map, op->x, op->y, op->owner); if (i > 0 && i != op->direction) { op->direction = i; @@ -1380,7 +1361,7 @@ { int i, j, range, mflags, friendly = 0, dam, dur; sint16 sx, sy; - mapstruct *m; + maptile *m; object *tmp; const char *skill; @@ -1418,7 +1399,7 @@ continue; if (mflags & P_IS_ALIVE) { - for (tmp = get_map_ob (m, sx, sy); tmp; tmp = tmp->above) + for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above) { if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) break; @@ -1572,7 +1553,7 @@ object *tmp, *god, *head; int done_one, range, mflags, level, at, best_at; sint16 x, y, nx, ny; - mapstruct *m; + maptile *m; const char *race; /* We precompute some values here so that we don't have to keep @@ -1612,7 +1593,7 @@ if (!(mflags & P_IS_ALIVE)) continue; - for (tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) + for (tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above) if (QUERY_FLAG (tmp, FLAG_MONSTER)) break; @@ -1710,7 +1691,7 @@ Typical use case is charm, go somwhere, use aggravation to make hostile. This could lead to fun stuff like mice outbreak in bigworld and server crawl. */ CLEAR_FLAG (head, FLAG_GENERATOR); - set_owner (head, op); + head->set_owner (op); set_spell_skill (op, caster, spell, head); add_friendly_object (head); head->attack_movement = PETMOVE; @@ -1746,9 +1727,9 @@ int i, j, dam_save, dir, mflags; sint16 nx, ny, hx, hy; object *owner; - mapstruct *m; + maptile *m; - owner = get_owner (op); + owner = op->owner; /* the following logic makes sure that the ball doesn't move into a wall, * and makes sure that it will move along a wall to try and get at it's @@ -1787,7 +1768,7 @@ m = op->map; } - remove_ob (op); + op->remove (); op->y = ny; op->x = nx; insert_ob_in_map (op, m, op, 0); @@ -1837,7 +1818,7 @@ /* restore to the center location and damage */ op->stats.dam = dam_save; - i = spell_find_dir (op->map, op->x, op->y, get_owner (op)); + i = spell_find_dir (op->map, op->x, op->y, op->owner); if (i >= 0) { /* we have a preferred direction! */ @@ -1868,18 +1849,18 @@ static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; sint16 target_x, target_y, origin_x, origin_y; int adjustdir; - mapstruct *m; + maptile *m; #endif int basedir; object *owner; - owner = get_owner (op); + owner = op->owner; if (op->duration == 0 || owner == NULL) { - remove_ob (op); - free_object (op); + op->destroy (); return; } + op->duration--; basedir = op->direction; @@ -1988,7 +1969,7 @@ tmp = get_archetype (SWARM_SPELL); tmp->x = op->x; tmp->y = op->y; - set_owner (tmp, op); /* needed so that if swarm elements kill, caster gets xp. */ + tmp->set_owner (op); /* needed so that if swarm elements kill, caster gets xp. */ set_spell_skill (op, caster, spell, tmp); tmp->level = caster_level (caster, spell); /*needed later, to get level dep. right. */ @@ -2021,7 +2002,7 @@ object *target = NULL, *tmp = NULL; sint16 x, y; int dam, mflags; - mapstruct *m; + maptile *m; dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); @@ -2045,7 +2026,7 @@ if (mflags & P_IS_ALIVE && spell->attacktype) { - for (target = get_map_ob (m, x, y); target; target = target->above) + for (target = GET_MAP_OB (m, x, y); target; target = target->above) if (QUERY_FLAG (target, FLAG_MONSTER)) { /* oky doky. got a target monster. Lets make a blinding attack */ @@ -2099,7 +2080,7 @@ sint16 x, y; int i, mflags, range, dam_mod, dur_mod; object *walk; - mapstruct *m; + maptile *m; x = op->x; y = op->y; @@ -2137,12 +2118,12 @@ if (mflags & P_IS_ALIVE) { /* search this square for a victim */ - for (walk = get_map_ob (m, x, y); walk; walk = walk->above) + for (walk = GET_MAP_OB (m, x, y); walk; walk = walk->above) if (QUERY_FLAG (walk, FLAG_MONSTER) || (walk->type == PLAYER)) { /* found a victim */ object *disease = arch_to_object (spell->other_arch); - set_owner (disease, op); + disease->set_owner (op); set_spell_skill (op, caster, spell, disease); disease->stats.exp = 0; disease->level = caster_level (caster, spell); @@ -2201,7 +2182,7 @@ new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); - free_object (disease); /* don't need this one anymore */ + disease->destroy (); /* don't need this one anymore */ flash = get_archetype (ARCH_DETECT_MAGIC); flash->x = x; flash->y = y; @@ -2209,7 +2190,8 @@ insert_ob_in_map (flash, walk->map, op, 0); return 1; } - free_object (disease); + + disease->destroy (); } } /* if living creature */ } /* for range of spaces */