Skip to content

Commit 0814af9

Browse files
authored
Merge pull request #1148 from openmultiplayer/amir/changes
network, npcs, and docker script changes
2 parents 8a97bd4 + 659893d commit 0814af9

File tree

9 files changed

+49
-3
lines changed

9 files changed

+49
-3
lines changed

SDK

Server/Components/LegacyNetwork/legacy_network_impl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ void RakNetLegacyNetwork::start()
828828

829829
IConfig& config = core->getConfig();
830830
int maxPlayers = *config.getInt("max_players");
831+
int minimumSendBPS = *config.getFloat("network.minimum_send_bits_per_second");
831832

832833
int port = *config.getInt("network.port");
833834
int sleep = static_cast<int>(*config.getFloat("sleep"));
@@ -837,6 +838,8 @@ void RakNetLegacyNetwork::start()
837838
bool artwork = !artwork_config ? false : *artwork_config;
838839
bool allow037 = *config.getBool("network.allow_037_clients");
839840

841+
SAMPRakNet::SetMinimumSendBitsPerSecond(minimumSendBPS); // Default: 96 kbps (~12 KB/s)
842+
840843
query.setCore(core);
841844

842845
std::stringstream version;

Server/Components/NPCs/NPC/npc.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,11 @@ void NPC::setWeaponState(PlayerWeaponState state)
17921792
}
17931793
}
17941794

1795+
Vector3 NPC::getPositionMovingTo() const
1796+
{
1797+
return targetPosition_;
1798+
}
1799+
17951800
void NPC::updateWeaponState()
17961801
{
17971802
switch (weapon_)

Server/Components/NPCs/NPC/npc.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ class NPC : public INPC, public PoolIDProvider, public NoCopy
116116

117117
void setWeaponState(PlayerWeaponState state) override;
118118

119+
Vector3 getPositionMovingTo() const override;
120+
119121
void setAmmoInClip(int ammo) override;
120122

121123
int getAmmoInClip() const override;

Server/Components/Pawn/Scripting/NPC/Natives.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ SCRIPT_API(NPC_GetSkin, bool(INPC& npc))
144144
return -1;
145145
}
146146

147+
SCRIPT_API(NPC_GetCustomSkin, bool(INPC& npc))
148+
{
149+
auto player = npc.getPlayer();
150+
if (player)
151+
{
152+
IPlayerCustomModelsData* data = queryExtension<IPlayerCustomModelsData>(player);
153+
if (!data)
154+
{
155+
return -1;
156+
}
157+
return data->getCustomSkin();
158+
}
159+
return -1;
160+
}
161+
147162
SCRIPT_API(NPC_IsStreamedIn, bool(INPC& npc, IPlayer& player))
148163
{
149164
return npc.isStreamedInForPlayer(player);
@@ -535,7 +550,7 @@ SCRIPT_API(NPC_GetPathPoint, bool(int pathId, int pointIndex, Vector3& position,
535550
return false;
536551
}
537552

538-
SCRIPT_API(NPC_GetCurrentPathPointIndex, bool(INPC& npc))
553+
SCRIPT_API(NPC_GetCurrentPathPointIndex, int(INPC& npc))
539554
{
540555
return npc.getCurrentPathPointIndex();
541556
}
@@ -1088,3 +1103,9 @@ SCRIPT_API(NPC_SetWeaponState, bool(INPC& npc, int weaponState))
10881103
npc.setWeaponState(PlayerWeaponState(weaponState));
10891104
return true;
10901105
}
1106+
1107+
SCRIPT_API(NPC_GetPosMovingTo, bool(INPC& npc, Vector3& position))
1108+
{
1109+
position = npc.getPositionMovingTo();
1110+
return true;
1111+
}

Server/Source/core_impl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ static const std::map<String, ConfigStorage> Defaults {
125125
{ "network.allow_037_clients", true },
126126
{ "network.grace_period", 5000 },
127127
{ "network.use_omp_encryption", false },
128+
{ "network.minimum_send_bits_per_second", 96000.0f }, // 96 kbps (~12 KB/s)
128129
// rcon
129130
{ "rcon.allow_teleport", false },
130131
{ "rcon.enable", false },

docker/build_ubuntu-20.04/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/sh
22
[ -z $CONFIG ] && config=Release || config="$CONFIG"
3+
[ -z $BUILD_SHARED ] && build_shared=1 || build_shared="$BUILD_SHARED"
4+
[ -z $BUILD_SERVER ] && build_server=1 || build_server="$BUILD_SERVER"
5+
[ -z $BUILD_TOOLS ] && build_tools=0 || build_tools="$BUILD_TOOLS"
36
[ -z $TARGET_BUILD_ARCH ] && target_build_arch=x86 || target_build_arch="$TARGET_BUILD_ARCH"
47

58
cd build \
@@ -8,6 +11,10 @@ cmake .. \
811
-G Ninja \
912
-DTARGET_BUILD_ARCH=$target_build_arch \
1013
-DCMAKE_BUILD_TYPE=$config \
14+
-DSHARED_OPENSSL=$build_shared \
15+
-DSTATIC_STDCXX=true \
16+
-DBUILD_SERVER=$build_server \
17+
-DBUILD_ABI_CHECK_TOOL=$build_tools \
1118
&&
1219
cmake \
1320
--build . \

docker/build_ubuntu-22.04/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/sh
22
[ -z $CONFIG ] && config=Release || config="$CONFIG"
3+
[ -z $BUILD_SHARED ] && build_shared=1 || build_shared="$BUILD_SHARED"
4+
[ -z $BUILD_SERVER ] && build_server=1 || build_server="$BUILD_SERVER"
5+
[ -z $BUILD_TOOLS ] && build_tools=0 || build_tools="$BUILD_TOOLS"
36
[ -z $TARGET_BUILD_ARCH ] && target_build_arch=x86 || target_build_arch="$TARGET_BUILD_ARCH"
47

58
cd build \
@@ -8,6 +11,10 @@ cmake .. \
811
-G Ninja \
912
-DTARGET_BUILD_ARCH=$target_build_arch \
1013
-DCMAKE_BUILD_TYPE=$config \
14+
-DSHARED_OPENSSL=$build_shared \
15+
-DSTATIC_STDCXX=true \
16+
-DBUILD_SERVER=$build_server \
17+
-DBUILD_ABI_CHECK_TOOL=$build_tools \
1118
&&
1219
cmake \
1320
--build . \

0 commit comments

Comments
 (0)