Skip to content

Commit

Permalink
server: fix build
Browse files Browse the repository at this point in the history
Former-commit-id: e6d434c
  • Loading branch information
C0kkie committed Jan 8, 2022
1 parent 7087bd6 commit 9b6d7f4
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 223 deletions.
7 changes: 4 additions & 3 deletions server/src/bindings/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static void SetSyncedMeta(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_GET_ISOLATE_CONTEXT();
V8_CHECK_ARGS_LEN(2);

V8_ARG_TO_STRING(1, key);
V8_ARG_TO_STD_STRING(1, key);
V8_ARG_TO_MVALUE(2, value);

alt::ICore::Instance().SetSyncedMetaData(key, value);
Expand All @@ -213,7 +213,7 @@ static void DeleteSyncedMeta(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_GET_ISOLATE_CONTEXT();
V8_CHECK_ARGS_LEN(1);

V8_ARG_TO_STRING(1, key);
V8_ARG_TO_STD_STRING(1, key);

alt::ICore::Instance().DeleteSyncedMetaData(key);
}
Expand Down Expand Up @@ -387,7 +387,8 @@ extern V8Module v8Alt("alt",
v8ColshapeCircle,
v8ColshapeCuboid,
v8ColshapeRectangle },
[](v8::Local<v8::Context> ctx, v8::Local<v8::Object> exports) {
[](v8::Local<v8::Context> ctx, v8::Local<v8::Object> exports)
{
v8::Isolate* isolate = ctx->GetIsolate();

V8Helpers::RegisterFunc(exports, "getResourceMain", &GetResourceMain);
Expand Down
232 changes: 118 additions & 114 deletions server/src/bindings/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ static void HasLocalMeta(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_CHECK_ARGS_LEN_MIN(1);
V8_GET_THIS_BASE_OBJECT(player, alt::IPlayer);

V8_ARG_TO_STRING(1, key);
V8_ARG_TO_STD_STRING(1, key);

V8_RETURN(player->HasLocalMetaData(key));
}
Expand All @@ -703,7 +703,7 @@ static void SetLocalMeta(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_CHECK_ARGS_LEN_MIN(1);
V8_GET_THIS_BASE_OBJECT(player, alt::IPlayer);

V8_ARG_TO_STRING(1, key);
V8_ARG_TO_STD_STRING(1, key);
V8_ARG_TO_MVALUE(2, value);
player->SetLocalMetaData(key, value);
}
Expand All @@ -714,7 +714,7 @@ static void GetLocalMeta(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_CHECK_ARGS_LEN_MIN(1);
V8_GET_THIS_BASE_OBJECT(player, alt::IPlayer);

V8_ARG_TO_STRING(1, key);
V8_ARG_TO_STD_STRING(1, key);

V8_RETURN_MVALUE(player->GetLocalMetaData(key));
}
Expand All @@ -725,119 +725,123 @@ static void DeleteLocalMeta(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_CHECK_ARGS_LEN_MIN(1);
V8_GET_THIS_BASE_OBJECT(player, alt::IPlayer);

V8_ARG_TO_STRING(1, key);
V8_ARG_TO_STD_STRING(1, key);

player->DeleteLocalMetaData(key);
}

extern V8Class v8Entity;
extern V8Class v8Player("Player", v8Entity, nullptr, [](v8::Local<v8::FunctionTemplate> tpl) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();

v8::Local<v8::ObjectTemplate> proto = tpl->PrototypeTemplate();

V8Helpers::SetStaticMethod(isolate, tpl, "getByID", &StaticGetByID);
V8Helpers::SetStaticAccessor(isolate, tpl, "all", &AllGetter);

V8Helpers::SetMethod(isolate, tpl, "emit", &Emit);
V8Helpers::SetMethod(isolate, tpl, "emitRaw", &EmitRaw);

V8Helpers::SetMethod(isolate, tpl, "hasLocalMeta", &HasLocalMeta);
V8Helpers::SetMethod(isolate, tpl, "setLocalMeta", &SetLocalMeta);
V8Helpers::SetMethod(isolate, tpl, "getLocalMeta", &GetLocalMeta);
V8Helpers::SetMethod(isolate, tpl, "deleteLocalMeta", &DeleteLocalMeta);

V8Helpers::SetAccessor<IPlayer, uint32_t, &IPlayer::GetPing>(isolate, tpl, "ping");
V8Helpers::SetAccessor<IPlayer, StringView, &IPlayer::GetIP>(isolate, tpl, "ip");
V8Helpers::SetAccessor<IPlayer, StringView, &IPlayer::GetName>(isolate, tpl, "name");
V8Helpers::SetAccessor<IPlayer, Ref<IVehicle>, &IPlayer::GetVehicle>(isolate, tpl, "vehicle");
V8Helpers::SetAccessor<IPlayer, uint8_t, &IPlayer::GetSeat>(isolate, tpl, "seat");
V8Helpers::SetAccessor<IPlayer, uint16_t, &IPlayer::GetHealth, &IPlayer::SetHealth>(isolate, tpl, "health");
V8Helpers::SetAccessor<IPlayer, uint16_t, &IPlayer::GetMaxHealth, &IPlayer::SetMaxHealth>(isolate, tpl, "maxHealth");
V8Helpers::SetAccessor<IPlayer, uint16_t, &IPlayer::GetArmour, &IPlayer::SetArmour>(isolate, tpl, "armour");
V8Helpers::SetAccessor<IPlayer, uint16_t, &IPlayer::GetMaxArmour, &IPlayer::SetMaxArmour>(isolate, tpl, "maxArmour");
V8Helpers::SetAccessor(isolate, tpl, "weapons", &GetWeapons);
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsDead>(isolate, tpl, "isDead");
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsInRagdoll>(isolate, tpl, "isInRagdoll");
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsAiming>(isolate, tpl, "isAiming");
// V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsJumping>(isolate, tpl, "isJumping");
// V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsShooting>(isolate, tpl, "isShooting");
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsReloading>(isolate, tpl, "isReloading");
V8Helpers::SetAccessor<IPlayer, Position, &IPlayer::GetAimPos>(isolate, tpl, "aimPos");
V8Helpers::SetAccessor<IPlayer, Rotation, &IPlayer::GetHeadRotation>(isolate, tpl, "headRot");

V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsSuperJumpEnabled>(isolate, tpl, "isSuperJumpEnabled");
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsCrouching>(isolate, tpl, "isCrouching");
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsStealthy>(isolate, tpl, "isStealthy");

V8Helpers::SetAccessor<IPlayer, Ref<IEntity>, &IPlayer::GetEntityAimingAt>(isolate, tpl, "entityAimingAt");
V8Helpers::SetAccessor<IPlayer, Position, &IPlayer::GetEntityAimOffset>(isolate, tpl, "entityAimOffset");

V8Helpers::SetAccessor<IPlayer, uint32_t, &IPlayer::GetCurrentWeapon, &IPlayer::SetCurrentWeapon>(isolate, tpl, "currentWeapon");
V8Helpers::SetAccessor(isolate, tpl, "currentWeaponComponents", &CurrentWeaponComponentsGetter);
V8Helpers::SetAccessor<IPlayer, uint8_t, &IPlayer::GetCurrentWeaponTintIndex>(isolate, tpl, "currentWeaponTintIndex");

V8Helpers::SetAccessor(isolate, tpl, "socialID", &SocialIDGetter);
V8Helpers::SetAccessor(isolate, tpl, "hwidHash", &HwidHashGetter);
V8Helpers::SetAccessor(isolate, tpl, "hwidExHash", &HwidExHashGetter);

V8Helpers::SetAccessor<IPlayer, StringView, &IPlayer::GetAuthToken>(isolate, tpl, "authToken");

V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsFlashlightActive>(isolate, tpl, "flashlightActive");

V8Helpers::SetAccessor<IPlayer, float, &IPlayer::GetMoveSpeed>(isolate, tpl, "moveSpeed");

V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::GetInvincible, &IPlayer::SetInvincible>(isolate, tpl, "invincible");

V8Helpers::SetMethod(isolate, tpl, "spawn", &Spawn);
V8Helpers::SetMethod(isolate, tpl, "setDateTime", &SetDateTime);
V8Helpers::SetMethod(isolate, tpl, "setWeather", &SetWeather);

V8Helpers::SetMethod<IPlayer, &IPlayer::ClearBloodDamage>(isolate, tpl, "clearBloodDamage");
V8Helpers::SetMethod(isolate, tpl, "giveWeapon", &GiveWeapon);
V8Helpers::SetMethod(isolate, tpl, "removeWeapon", &RemoveWeapon);
V8Helpers::SetMethod<IPlayer, &IPlayer::RemoveAllWeapons>(isolate, tpl, "removeAllWeapons");

V8Helpers::SetMethod(isolate, tpl, "addWeaponComponent", &AddWeaponComponent);
V8Helpers::SetMethod(isolate, tpl, "removeWeaponComponent", &RemoveWeaponComponent);

V8Helpers::SetMethod(isolate, tpl, "setWeaponTintIndex", &SetWeaponTintIndex);

V8Helpers::SetMethod(isolate, tpl, "kick", &Kick);

V8Helpers::SetMethod(isolate, tpl, "isEntityInStreamRange", &IsEntityInStreamRange);

V8Helpers::SetMethod(isolate, tpl, "setClothes", &SetClothes);
V8Helpers::SetMethod(isolate, tpl, "setDlcClothes", &SetDlcClothes);
V8Helpers::SetMethod(isolate, tpl, "getClothes", &GetClothes);
V8Helpers::SetMethod(isolate, tpl, "getDlcClothes", &GetDlcClothes);

V8Helpers::SetMethod(isolate, tpl, "setProp", &SetProps);
V8Helpers::SetMethod(isolate, tpl, "setDlcProp", &SetDlcProps);
V8Helpers::SetMethod(isolate, tpl, "getProp", &GetProps);
V8Helpers::SetMethod(isolate, tpl, "getDlcProp", &GetDlcProps);
V8Helpers::SetMethod(isolate, tpl, "clearProp", &ClearProps);

V8Helpers::SetMethod(isolate, tpl, "setIntoVehicle", &SetIntoVehicle);

V8Helpers::SetMethod(isolate, tpl, "playAmbientSpeech", &PlayAmbientSpeech);

// Appearance getter & setter
V8Helpers::SetMethod(isolate, tpl, "setHeadOverlay", &SetHeadOverlay);
V8Helpers::SetMethod(isolate, tpl, "removeHeadOverlay", &RemoveHeadOverlay);
V8Helpers::SetMethod(isolate, tpl, "setHeadOverlayColor", &SetHeadOverlayColor);
V8Helpers::SetMethod(isolate, tpl, "getHeadOverlay", &GetHeadOverlay);
V8Helpers::SetMethod(isolate, tpl, "setFaceFeature", &SetFaceFeature);
V8Helpers::SetMethod(isolate, tpl, "getFaceFeatureScale", &GetFaceFeatureScale);
V8Helpers::SetMethod(isolate, tpl, "removeFaceFeature", &RemoveFaceFeature);
V8Helpers::SetMethod(isolate, tpl, "setHeadBlendPaletteColor", &SetHeadBlendPaletteColor);
V8Helpers::SetMethod(isolate, tpl, "getHeadBlendPaletteColor", &GetHeadBlendPaletteColor);
V8Helpers::SetMethod(isolate, tpl, "setHeadBlendData", &SetHeadBlendData);
V8Helpers::SetMethod(isolate, tpl, "getHeadBlendData", &GetHeadBlendData);
V8Helpers::SetMethod(isolate, tpl, "setEyeColor", &SetEyeColor);
V8Helpers::SetMethod(isolate, tpl, "getEyeColor", &GetEyeColor);
V8Helpers::SetMethod(isolate, tpl, "setHairColor", &SetHairColor);
V8Helpers::SetMethod(isolate, tpl, "getHairColor", &GetHairColor);
V8Helpers::SetMethod(isolate, tpl, "setHairHighlightColor", &SetHairHighlightColor);
V8Helpers::SetMethod(isolate, tpl, "getHairHighlightColor", &GetHairHighlightColor);
});
extern V8Class v8Player("Player",
v8Entity,
nullptr,
[](v8::Local<v8::FunctionTemplate> tpl)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();

v8::Local<v8::ObjectTemplate> proto = tpl->PrototypeTemplate();

V8Helpers::SetStaticMethod(isolate, tpl, "getByID", &StaticGetByID);
V8Helpers::SetStaticAccessor(isolate, tpl, "all", &AllGetter);

V8Helpers::SetMethod(isolate, tpl, "emit", &Emit);
V8Helpers::SetMethod(isolate, tpl, "emitRaw", &EmitRaw);

V8Helpers::SetMethod(isolate, tpl, "hasLocalMeta", &HasLocalMeta);
V8Helpers::SetMethod(isolate, tpl, "setLocalMeta", &SetLocalMeta);
V8Helpers::SetMethod(isolate, tpl, "getLocalMeta", &GetLocalMeta);
V8Helpers::SetMethod(isolate, tpl, "deleteLocalMeta", &DeleteLocalMeta);

V8Helpers::SetAccessor<IPlayer, uint32_t, &IPlayer::GetPing>(isolate, tpl, "ping");
V8Helpers::SetAccessor<IPlayer, StringView, &IPlayer::GetIP>(isolate, tpl, "ip");
V8Helpers::SetAccessor<IPlayer, StringView, &IPlayer::GetName>(isolate, tpl, "name");
V8Helpers::SetAccessor<IPlayer, Ref<IVehicle>, &IPlayer::GetVehicle>(isolate, tpl, "vehicle");
V8Helpers::SetAccessor<IPlayer, uint8_t, &IPlayer::GetSeat>(isolate, tpl, "seat");
V8Helpers::SetAccessor<IPlayer, uint16_t, &IPlayer::GetHealth, &IPlayer::SetHealth>(isolate, tpl, "health");
V8Helpers::SetAccessor<IPlayer, uint16_t, &IPlayer::GetMaxHealth, &IPlayer::SetMaxHealth>(isolate, tpl, "maxHealth");
V8Helpers::SetAccessor<IPlayer, uint16_t, &IPlayer::GetArmour, &IPlayer::SetArmour>(isolate, tpl, "armour");
V8Helpers::SetAccessor<IPlayer, uint16_t, &IPlayer::GetMaxArmour, &IPlayer::SetMaxArmour>(isolate, tpl, "maxArmour");
V8Helpers::SetAccessor(isolate, tpl, "weapons", &GetWeapons);
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsDead>(isolate, tpl, "isDead");
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsInRagdoll>(isolate, tpl, "isInRagdoll");
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsAiming>(isolate, tpl, "isAiming");
// V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsJumping>(isolate, tpl, "isJumping");
// V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsShooting>(isolate, tpl, "isShooting");
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsReloading>(isolate, tpl, "isReloading");
V8Helpers::SetAccessor<IPlayer, Position, &IPlayer::GetAimPos>(isolate, tpl, "aimPos");
V8Helpers::SetAccessor<IPlayer, Rotation, &IPlayer::GetHeadRotation>(isolate, tpl, "headRot");

V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsSuperJumpEnabled>(isolate, tpl, "isSuperJumpEnabled");
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsCrouching>(isolate, tpl, "isCrouching");
V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsStealthy>(isolate, tpl, "isStealthy");

V8Helpers::SetAccessor<IPlayer, Ref<IEntity>, &IPlayer::GetEntityAimingAt>(isolate, tpl, "entityAimingAt");
V8Helpers::SetAccessor<IPlayer, Position, &IPlayer::GetEntityAimOffset>(isolate, tpl, "entityAimOffset");

V8Helpers::SetAccessor<IPlayer, uint32_t, &IPlayer::GetCurrentWeapon, &IPlayer::SetCurrentWeapon>(isolate, tpl, "currentWeapon");
V8Helpers::SetAccessor(isolate, tpl, "currentWeaponComponents", &CurrentWeaponComponentsGetter);
V8Helpers::SetAccessor<IPlayer, uint8_t, &IPlayer::GetCurrentWeaponTintIndex>(isolate, tpl, "currentWeaponTintIndex");

V8Helpers::SetAccessor(isolate, tpl, "socialID", &SocialIDGetter);
V8Helpers::SetAccessor(isolate, tpl, "hwidHash", &HwidHashGetter);
V8Helpers::SetAccessor(isolate, tpl, "hwidExHash", &HwidExHashGetter);

V8Helpers::SetAccessor<IPlayer, StringView, &IPlayer::GetAuthToken>(isolate, tpl, "authToken");

V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::IsFlashlightActive>(isolate, tpl, "flashlightActive");

V8Helpers::SetAccessor<IPlayer, float, &IPlayer::GetMoveSpeed>(isolate, tpl, "moveSpeed");

V8Helpers::SetAccessor<IPlayer, bool, &IPlayer::GetInvincible, &IPlayer::SetInvincible>(isolate, tpl, "invincible");

V8Helpers::SetMethod(isolate, tpl, "spawn", &Spawn);
V8Helpers::SetMethod(isolate, tpl, "setDateTime", &SetDateTime);
V8Helpers::SetMethod(isolate, tpl, "setWeather", &SetWeather);

V8Helpers::SetMethod<IPlayer, &IPlayer::ClearBloodDamage>(isolate, tpl, "clearBloodDamage");
V8Helpers::SetMethod(isolate, tpl, "giveWeapon", &GiveWeapon);
V8Helpers::SetMethod(isolate, tpl, "removeWeapon", &RemoveWeapon);
V8Helpers::SetMethod<IPlayer, &IPlayer::RemoveAllWeapons>(isolate, tpl, "removeAllWeapons");

V8Helpers::SetMethod(isolate, tpl, "addWeaponComponent", &AddWeaponComponent);
V8Helpers::SetMethod(isolate, tpl, "removeWeaponComponent", &RemoveWeaponComponent);

V8Helpers::SetMethod(isolate, tpl, "setWeaponTintIndex", &SetWeaponTintIndex);

V8Helpers::SetMethod(isolate, tpl, "kick", &Kick);

V8Helpers::SetMethod(isolate, tpl, "isEntityInStreamRange", &IsEntityInStreamRange);

V8Helpers::SetMethod(isolate, tpl, "setClothes", &SetClothes);
V8Helpers::SetMethod(isolate, tpl, "setDlcClothes", &SetDlcClothes);
V8Helpers::SetMethod(isolate, tpl, "getClothes", &GetClothes);
V8Helpers::SetMethod(isolate, tpl, "getDlcClothes", &GetDlcClothes);

V8Helpers::SetMethod(isolate, tpl, "setProp", &SetProps);
V8Helpers::SetMethod(isolate, tpl, "setDlcProp", &SetDlcProps);
V8Helpers::SetMethod(isolate, tpl, "getProp", &GetProps);
V8Helpers::SetMethod(isolate, tpl, "getDlcProp", &GetDlcProps);
V8Helpers::SetMethod(isolate, tpl, "clearProp", &ClearProps);

V8Helpers::SetMethod(isolate, tpl, "setIntoVehicle", &SetIntoVehicle);

V8Helpers::SetMethod(isolate, tpl, "playAmbientSpeech", &PlayAmbientSpeech);

// Appearance getter & setter
V8Helpers::SetMethod(isolate, tpl, "setHeadOverlay", &SetHeadOverlay);
V8Helpers::SetMethod(isolate, tpl, "removeHeadOverlay", &RemoveHeadOverlay);
V8Helpers::SetMethod(isolate, tpl, "setHeadOverlayColor", &SetHeadOverlayColor);
V8Helpers::SetMethod(isolate, tpl, "getHeadOverlay", &GetHeadOverlay);
V8Helpers::SetMethod(isolate, tpl, "setFaceFeature", &SetFaceFeature);
V8Helpers::SetMethod(isolate, tpl, "getFaceFeatureScale", &GetFaceFeatureScale);
V8Helpers::SetMethod(isolate, tpl, "removeFaceFeature", &RemoveFaceFeature);
V8Helpers::SetMethod(isolate, tpl, "setHeadBlendPaletteColor", &SetHeadBlendPaletteColor);
V8Helpers::SetMethod(isolate, tpl, "getHeadBlendPaletteColor", &GetHeadBlendPaletteColor);
V8Helpers::SetMethod(isolate, tpl, "setHeadBlendData", &SetHeadBlendData);
V8Helpers::SetMethod(isolate, tpl, "getHeadBlendData", &GetHeadBlendData);
V8Helpers::SetMethod(isolate, tpl, "setEyeColor", &SetEyeColor);
V8Helpers::SetMethod(isolate, tpl, "getEyeColor", &GetEyeColor);
V8Helpers::SetMethod(isolate, tpl, "setHairColor", &SetHairColor);
V8Helpers::SetMethod(isolate, tpl, "getHairColor", &GetHairColor);
V8Helpers::SetMethod(isolate, tpl, "setHairHighlightColor", &SetHairHighlightColor);
V8Helpers::SetMethod(isolate, tpl, "getHairHighlightColor", &GetHairHighlightColor);
});
Loading

0 comments on commit 9b6d7f4

Please sign in to comment.