From ccabbd76888b61f42399d89d500160b089c4f32d Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 22 Jul 2023 14:46:51 +0300 Subject: [PATCH] Add proto_is_subtype --- src/proto.cc | 17 +++++++++++++++++ src/proto.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/proto.cc b/src/proto.cc index efb05b0..421939e 100644 --- a/src/proto.cc +++ b/src/proto.cc @@ -828,6 +828,23 @@ int _proto_dude_init(const char* path) return 0; } +// 0x49FEDC +bool proto_is_subtype(Proto* proto, int subtype) +{ + if (subtype == -1) { + return true; + } + + switch (PID_TYPE(proto->pid)) { + case OBJ_TYPE_ITEM: + return proto->item.type == subtype; + case OBJ_TYPE_SCENERY: + return proto->scenery.type == subtype; + } + + return false; +} + // proto_data_member // 0x49FFD8 int protoGetDataMember(int pid, int member, ProtoDataMemberValue* value) diff --git a/src/proto.h b/src/proto.h index d6f13e6..e68140f 100644 --- a/src/proto.h +++ b/src/proto.h @@ -118,6 +118,7 @@ int objectDataWrite(Object* obj, File* stream); int _proto_update_init(Object* obj); int _proto_dude_update_gender(); int _proto_dude_init(const char* path); +bool proto_is_subtype(Proto* proto, int subtype); int protoGetDataMember(int pid, int member, ProtoDataMemberValue* value); int protoInit(); void protoReset();