From edd67db458188a76934b963e6a40f7b681f86b3d Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 12 Oct 2013 18:41:40 -0700 Subject: Disallow unchecked being casts Despite the fact that that's what the code always did, it was sometimes wrong. --- src/map/magic-expr.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/map/magic-expr.cpp') diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp index 8f4a5eb..aff4412 100644 --- a/src/map/magic-expr.cpp +++ b/src/map/magic-expr.cpp @@ -97,16 +97,16 @@ FString show_entity(dumb_ptr entity) switch (entity->bl_type) { case BL::PC: - return entity->as_player()->status.name.to__actual(); + return entity->is_player()->status.name.to__actual(); case BL::NPC: - return entity->as_npc()->name; + return entity->is_npc()->name; case BL::MOB: - return entity->as_mob()->name; + return entity->is_mob()->name; case BL::ITEM: assert (0 && "There is no way this code did what it was supposed to do!"); /* Sorry about this one... */ // WTF? item_data is a struct item, not a struct item_data - // return ((struct item_data *) (&entity->as_item()->item_data))->name; + // return ((struct item_data *) (&entity->is_item()->item_data))->name; abort(); case BL::SPELL: return {"%invocation(ERROR:this-should-not-be-an-entity)"}; @@ -168,7 +168,7 @@ void stringify(val_t *v, int within_op) { dumb_ptr invocation_ = within_op ? v->v.v_invocation - : map_id2bl(v->v.v_int)->as_spell(); + : map_id2bl(v->v.v_int)->is_spell(); buf = invocation_->spell->name; } break; @@ -606,7 +606,7 @@ int fun_skill(dumb_ptr, val_t *result, const_array args) } static -int fun_has_shroud(dumb_ptr, val_t *result, const_array args) +int fun_his_shroud(dumb_ptr, val_t *result, const_array args) { RESULTINT = (ENTITY_TYPE(0) == BL::PC && ARGPC(0)->state.shroud_active); return 0; @@ -1009,7 +1009,7 @@ int fun_read_script_int(dumb_ptr, val_t *result, const_array args) if (subject_p->bl_type != BL::PC) return 1; - RESULTINT = pc_readglobalreg(subject_p->as_player(), var_name); + RESULTINT = pc_readglobalreg(subject_p->is_player(), var_name); return 0; } @@ -1286,7 +1286,7 @@ std::map functions = MAGIC_FUNCTION1(status_option, "ei", 'i'), MAGIC_FUNCTION1(element, "e", 'i'), MAGIC_FUNCTION1(element_level, "e", 'i'), - MAGIC_FUNCTION1(has_shroud, "e", 'i'), + MAGIC_FUNCTION1(his_shroud, "e", 'i'), MAGIC_FUNCTION1(is_equipped, "e.", 'i'), MAGIC_FUNCTION1(is_exterior, "l", 'i'), MAGIC_FUNCTION1(contains_string, "ss", 'i'), @@ -1500,7 +1500,7 @@ int magic_signature_check(ZString opname, ZString funname, ZString signature, } else if (ty == TYPE::INVOCATION) { - arg->v.v_invocation = map_id2bl(arg->v.v_int)->as_spell(); + arg->v.v_invocation = map_id2bl(arg->v.v_int)->is_spell(); if (!arg->v.v_entity) ty = arg->ty = TYPE::FAIL; } @@ -1635,7 +1635,7 @@ void magic_eval(dumb_ptr env, val_t *dest, dumb_ptr expr) if (v.ty == TYPE::INVOCATION) { - dumb_ptr t = map_id2bl(v.v.v_int)->as_spell(); + dumb_ptr t = map_id2bl(v.v.v_int)->is_spell(); if (!t) dest->ty = TYPE::UNDEF; -- cgit v1.2.3-60-g2f50