Skip to content

Commit

Permalink
Merge tag 'dev/15.0-dev789' into rc
Browse files Browse the repository at this point in the history
  • Loading branch information
emcifuntik committed Oct 20, 2023
2 parents 776fa46 + f6abb79 commit 2b826f7
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3 deletions.
10 changes: 10 additions & 0 deletions server/src/bindings/ConnectionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,18 @@ static void GetCloudIDGetter(v8::Local<v8::String>, const v8::PropertyCallbackIn
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_GET_THIS_BASE_OBJECT(con, alt::IConnectionInfo);

V8_RETURN_STRING(con->GetCloudID());
}

static void CloudAuthResultGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT_RESOURCE();
V8_GET_THIS_BASE_OBJECT(con, alt::IConnectionInfo);

V8_RETURN_UINT(con->GetCloudAuthResult());
}

extern V8Class v8BaseObject;
extern V8Class v8ConnectionInfo("ConnectionInfo",
v8BaseObject,
Expand Down Expand Up @@ -214,5 +223,6 @@ extern V8Class v8ConnectionInfo("ConnectionInfo",
V8Helpers::SetAccessor(isolate, tpl, "socialClubName", &SocialClubNameGetter);
V8Helpers::SetAccessor(isolate, tpl, "id", &ConnectionIDGetter);
V8Helpers::SetAccessor(isolate, tpl, "cloudID", &GetCloudIDGetter);
V8Helpers::SetAccessor(isolate, tpl, "cloudAuthResult", &CloudAuthResultGetter);
V8Helpers::SetAccessor(isolate, tpl, "text", &GetText, &SetText);
});
23 changes: 23 additions & 0 deletions server/src/bindings/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,16 @@ static void RestartResource(const v8::FunctionCallbackInfo<v8::Value>& info)
alt::ICore::Instance().RestartResource(name);
}

static void AddClientConfigKey(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_CHECK_ARGS_LEN(1);

V8_ARG_TO_STRING(1, key);

alt::ICore::Instance().AddClientConfigKey(key);
}

static void HashServerPassword(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
Expand Down Expand Up @@ -821,6 +831,16 @@ static void GetLoadedVehicleModels(const v8::FunctionCallbackInfo<v8::Value>& in
V8_RETURN(modelArray);
}

static void HasBenefit(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_CHECK_ARGS_LEN(1);

V8_ARG_TO_UINT(1, benefit);

V8_RETURN_BOOLEAN(alt::ICore::Instance().HasBenefit((alt::Benefit)benefit));
}

extern V8Class v8Player, v8Vehicle, v8Blip, v8AreaBlip, v8RadiusBlip, v8PointBlip, v8Checkpoint, v8VoiceChannel, v8Colshape, v8ColshapeCylinder, v8ColshapeSphere, v8ColshapeCircle,
v8ColshapeCuboid, v8ColshapeRectangle, v8ColshapePolygon, v8Ped, v8Object, v8VirtualEntity, v8VirtualEntityGroup, v8Marker, v8ConnectionInfo;

Expand All @@ -840,6 +860,8 @@ extern V8Module
V8Helpers::RegisterFunc(exports, "stopResource", &StopResource);
V8Helpers::RegisterFunc(exports, "restartResource", &RestartResource);

V8Helpers::RegisterFunc(exports, "addClientConfigKey", &AddClientConfigKey);

V8Helpers::RegisterFunc(exports, "onClient", &OnClient);
V8Helpers::RegisterFunc(exports, "onceClient", &OnceClient);
V8Helpers::RegisterFunc(exports, "offClient", &OffClient);
Expand Down Expand Up @@ -911,6 +933,7 @@ extern V8Module

V8Helpers::RegisterFunc(exports, "getMigrationDistance", &GetMigrationDistance);
V8Helpers::RegisterFunc(exports, "setMigrationDistance", &SetMigrationDistance);
V8Helpers::RegisterFunc(exports, "hasBenefit", &HasBenefit);

V8_OBJECT_SET_STRING(exports, "rootDir", alt::ICore::Instance().GetRootDirectory());
});
35 changes: 34 additions & 1 deletion server/src/bindings/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,34 @@ static void GetLocalMetaDataKeys(const v8::FunctionCallbackInfo<v8::Value>& info
V8_RETURN(arr);
}

static void DiscordIDGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
static void GetCloudAuthResultGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE();
V8_GET_THIS_BASE_OBJECT(_this, IPlayer);

V8_RETURN_UINT(_this->GetCloudAuthResult());
}

static void GetBloodDamageBase64(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE();
V8_GET_THIS_BASE_OBJECT(_this, IPlayer);

V8_RETURN_STRING(_this->GetBloodDamageBase64());
}

static void SetBloodDamageBase64(const v8::FunctionCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE_CONTEXT();
V8_GET_THIS_BASE_OBJECT(_this, IPlayer);
V8_CHECK_ARGS_LEN(1);

V8_ARG_TO_STRING(1, base64);

_this->SetBloodDamageBase64(base64);
}

static void DiscordIDGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
V8_GET_ISOLATE();
V8_GET_THIS_BASE_OBJECT(_this, IPlayer);
Expand Down Expand Up @@ -1399,7 +1426,13 @@ extern V8Class v8Player("Player",
V8Helpers::SetMethod(isolate, tpl, "getLocalMetaKeys", &GetLocalMetaDataKeys);

V8Helpers::SetAccessor<IPlayer, uint32_t, &IPlayer::GetPing>(isolate, tpl, "ping");

V8Helpers::SetAccessor<IPlayer, std::string, &IPlayer::GetCloudID>(isolate, tpl, "cloudID");
V8Helpers::SetAccessor(isolate, tpl, "cloudAuthResult", &GetCloudAuthResultGetter);

V8Helpers::SetMethod(isolate, tpl, "getBloodDamageBase64", &GetBloodDamageBase64);
V8Helpers::SetMethod(isolate, tpl, "setBloodDamageBase64", &SetBloodDamageBase64);

V8Helpers::SetAccessor<IPlayer, std::string, &IPlayer::GetIP>(isolate, tpl, "ip");
V8Helpers::SetAccessor<IPlayer, std::string, &IPlayer::GetName>(isolate, tpl, "name");
V8Helpers::SetAccessor<IPlayer, IVehicle*, &IPlayer::GetVehicle>(isolate, tpl, "vehicle");
Expand Down
1 change: 0 additions & 1 deletion shared/bindings/BindingsMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ extern V8Module
V8Helpers::RegisterFunc(exports, "stringToSHA256", &StringToSHA256);

V8Helpers::RegisterFunc(exports, "getVoiceConnectionState", &GetVoiceConnectionState);

V8Helpers::RegisterFunc(exports, "getNetTime", &GetNetTime);

V8_OBJECT_SET_STRING(exports, "version", alt::ICore::Instance().GetVersion());
Expand Down
2 changes: 1 addition & 1 deletion shared/deps/cpp-sdk

0 comments on commit 2b826f7

Please sign in to comment.