Skip to content

Commit

Permalink
shared: Add invalid raw value type
Browse files Browse the repository at this point in the history
Former-commit-id: 457f39e
  • Loading branch information
LeonMrBonnie committed Nov 13, 2021
1 parent d77ffa9 commit 7e852ab
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion shared/V8Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ enum class RawValueType : uint8_t
ENTITY,
VECTOR3,
VECTOR2,
RGBA
RGBA,
INVALID
};

extern V8Class v8Entity;
Expand All @@ -373,6 +374,7 @@ static inline RawValueType GetValueType(v8::Local<v8::Context> ctx, v8::Local<v8
if(resource->IsVector3(val)) return RawValueType::VECTOR3;
if(resource->IsVector2(val)) return RawValueType::VECTOR2;
if(resource->IsRGBA(val)) return RawValueType::RGBA;
if(val->IsSharedArrayBuffer() || val->IsFunction()) return RawValueType::INVALID;
else
return RawValueType::GENERIC;
}
Expand All @@ -385,6 +387,7 @@ alt::MValueByteArray V8Helpers::V8ToRawBytes(v8::Local<v8::Value> val)
std::vector<uint8_t> bytes;

RawValueType type = GetValueType(ctx, val);
if(type == RawValueType::INVALID) return alt::MValueByteArray();

v8::ValueSerializer serializer(isolate);
serializer.WriteHeader();
Expand Down

0 comments on commit 7e852ab

Please sign in to comment.