mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Cleanup & bugfix
* ObjectRef::set_local_animation: fix wrong lua return (should push a boolean, currently returns nil) * ObjectRef::set_eye_offset: fix wrong lua return (should push a boolean, currently returns nil) * Fix various Server functions which depends on RemotePlayer objet and return true/false when player object is nil whereas it's a caller implementation error. Change those bool functions to void and add sanitize_check call instead. Current callers are always checking player object validity * Optimize Server::setClouds : use CloudParams object ref instead of attribute deserialization from structure & perform RemotePlayer::setCloudParams directly in server class like many other calls * Optimize Server::SendCloudParams: use CloudParams object ref instead of deserialized attributes
This commit is contained in:
parent
c7656edaa5
commit
c7c03ad7a6
3 changed files with 25 additions and 71 deletions
|
@ -1775,17 +1775,11 @@ void Server::SendSetSky(session_t peer_id, const video::SColor &bgcolor,
|
|||
Send(&pkt);
|
||||
}
|
||||
|
||||
void Server::SendCloudParams(session_t peer_id, float density,
|
||||
const video::SColor &color_bright,
|
||||
const video::SColor &color_ambient,
|
||||
float height,
|
||||
float thickness,
|
||||
const v2f &speed)
|
||||
void Server::SendCloudParams(session_t peer_id, const CloudParams ¶ms)
|
||||
{
|
||||
NetworkPacket pkt(TOCLIENT_CLOUD_PARAMS, 0, peer_id);
|
||||
pkt << density << color_bright << color_ambient
|
||||
<< height << thickness << speed;
|
||||
|
||||
pkt << params.density << params.color_bright << params.color_ambient
|
||||
<< params.height << params.thickness << params.speed;
|
||||
Send(&pkt);
|
||||
}
|
||||
|
||||
|
@ -3113,54 +3107,36 @@ Address Server::getPeerAddress(session_t peer_id)
|
|||
return m_con->GetPeerAddress(peer_id);
|
||||
}
|
||||
|
||||
bool Server::setLocalPlayerAnimations(RemotePlayer *player,
|
||||
void Server::setLocalPlayerAnimations(RemotePlayer *player,
|
||||
v2s32 animation_frames[4], f32 frame_speed)
|
||||
{
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
sanity_check(player);
|
||||
player->setLocalAnimations(animation_frames, frame_speed);
|
||||
SendLocalPlayerAnimations(player->getPeerId(), animation_frames, frame_speed);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Server::setPlayerEyeOffset(RemotePlayer *player, v3f first, v3f third)
|
||||
void Server::setPlayerEyeOffset(RemotePlayer *player, const v3f &first, const v3f &third)
|
||||
{
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
sanity_check(player);
|
||||
player->eye_offset_first = first;
|
||||
player->eye_offset_third = third;
|
||||
SendEyeOffset(player->getPeerId(), first, third);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Server::setSky(RemotePlayer *player, const video::SColor &bgcolor,
|
||||
void Server::setSky(RemotePlayer *player, const video::SColor &bgcolor,
|
||||
const std::string &type, const std::vector<std::string> ¶ms,
|
||||
bool &clouds)
|
||||
{
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
sanity_check(player);
|
||||
player->setSky(bgcolor, type, params, clouds);
|
||||
SendSetSky(player->getPeerId(), bgcolor, type, params, clouds);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Server::setClouds(RemotePlayer *player, float density,
|
||||
const video::SColor &color_bright,
|
||||
const video::SColor &color_ambient,
|
||||
float height,
|
||||
float thickness,
|
||||
const v2f &speed)
|
||||
void Server::setClouds(RemotePlayer *player, const CloudParams ¶ms)
|
||||
{
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
SendCloudParams(player->getPeerId(), density,
|
||||
color_bright, color_ambient, height,
|
||||
thickness, speed);
|
||||
return true;
|
||||
sanity_check(player);
|
||||
player->setCloudParams(params);
|
||||
SendCloudParams(player->getPeerId(), params);
|
||||
}
|
||||
|
||||
bool Server::overrideDayNightRatio(RemotePlayer *player, bool do_override,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue