Skip to content

Commit

Permalink
fix: fix Entity::toPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Aug 6, 2024
1 parent 3cc60c3 commit 183fad6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/legacy/api/EntityAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,12 +899,12 @@ Local<Value> EntityClass::isPlayer(const Arguments& args) {

Local<Value> EntityClass::toPlayer(const Arguments& args) {
try {
Actor* entity = get();
if (!entity || !entity->isType(ActorType::Player)) return Local<Value>();

Player* pl = static_cast<Player*>(entity);
if (!pl) return Local<Value>();
else return PlayerClass::newPlayer(pl);
Player* player = ll::service::getLevel()->getPlayer(id);
if (!player) {
return Local<Value>();
} else {
return PlayerClass::newPlayer(player);
}
}
CATCH("Fail in toPlayer!");
}
Expand All @@ -916,17 +916,17 @@ Local<Value> EntityClass::isItemEntity(const Arguments& args) {

return Boolean::newBoolean(entity->hasCategory(ActorCategory::Item));
}
CATCH("Fail in isPlayer!")
CATCH("Fail in isItemEntity!")
}

Local<Value> EntityClass::toItem(const Arguments& args) {
try {
Actor* entity = get();
if (!entity || !entity->hasCategory(ActorCategory::Item)) return Local<Value>();

ItemActor* it = static_cast<ItemActor*>(entity);
if (!it) return Local<Value>();
else return ItemClass::newItem(&it->item(), false);
if (!entity || !entity->hasCategory(ActorCategory::Item)) {
return Local<Value>();
} else {
return ItemClass::newItem(&((ItemActor*)entity)->item(), false);
}
}
CATCH("Fail in toItem!");
}
Expand Down

0 comments on commit 183fad6

Please sign in to comment.