From a4daffa30e1636df56a4a96947670db95ee379bc Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 22 Jul 2023 14:49:56 +0300 Subject: [PATCH] Add proto_copy_proto --- src/proto.cc | 28 ++++++++++++++++++++++++++++ src/proto.h | 1 + 2 files changed, 29 insertions(+) diff --git a/src/proto.cc b/src/proto.cc index 421939e..f1d6aea 100644 --- a/src/proto.cc +++ b/src/proto.cc @@ -828,6 +828,34 @@ int _proto_dude_init(const char* path) return 0; } +// 0x49FE74 +int proto_copy_proto(int srcPid, int dstPid) +{ + int srcType; + int dstType; + Proto* src; + Proto* dst; + + srcType = PID_TYPE(srcPid); + dstType = PID_TYPE(dstPid); + if (srcType != dstType) { + return -1; + } + + if (protoGetProto(srcPid, &src) == -1) { + return -1; + } + + if (protoGetProto(dstPid, &dst) == -1) { + return -1; + } + + memcpy(dst, src, _proto_sizes[srcType]); + dst->pid = dstPid; + + return 0; +} + // 0x49FEDC bool proto_is_subtype(Proto* proto, int subtype) { diff --git a/src/proto.h b/src/proto.h index e68140f..9448a09 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); +int proto_copy_proto(int srcPid, int dstPid); bool proto_is_subtype(Proto* proto, int subtype); int protoGetDataMember(int pid, int member, ProtoDataMemberValue* value); int protoInit();