2016-10-08 19:08:23 +02:00
|
|
|
/*
|
|
|
|
Minetest
|
|
|
|
Copyright (C) 2010-2016 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
Copyright (C) 2014-2016 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2016-10-08 19:08:23 +02:00
|
|
|
|
|
|
|
#include "player.h"
|
2017-03-17 10:39:47 +01:00
|
|
|
#include "cloudparams.h"
|
2016-10-08 19:08:23 +02:00
|
|
|
|
|
|
|
class PlayerSAO;
|
|
|
|
|
2017-01-27 08:59:30 +01:00
|
|
|
enum RemotePlayerChatResult
|
|
|
|
{
|
2016-10-08 19:08:23 +02:00
|
|
|
RPLAYER_CHATRESULT_OK,
|
|
|
|
RPLAYER_CHATRESULT_FLOODING,
|
|
|
|
RPLAYER_CHATRESULT_KICK,
|
|
|
|
};
|
2017-01-27 08:59:30 +01:00
|
|
|
|
2016-10-08 19:08:23 +02:00
|
|
|
/*
|
|
|
|
Player on the server
|
|
|
|
*/
|
|
|
|
class RemotePlayer : public Player
|
|
|
|
{
|
2017-04-23 14:35:08 +02:00
|
|
|
friend class PlayerDatabaseFiles;
|
2017-04-23 16:22:53 +02:00
|
|
|
|
2016-10-08 19:08:23 +02:00
|
|
|
public:
|
|
|
|
RemotePlayer(const char *name, IItemDefManager *idef);
|
2017-08-19 14:25:35 +02:00
|
|
|
virtual ~RemotePlayer() = default;
|
2016-10-08 19:08:23 +02:00
|
|
|
|
2016-10-30 14:53:26 +01:00
|
|
|
void deSerialize(std::istream &is, const std::string &playername, PlayerSAO *sao);
|
2016-10-08 19:08:23 +02:00
|
|
|
|
|
|
|
PlayerSAO *getPlayerSAO() { return m_sao; }
|
|
|
|
void setPlayerSAO(PlayerSAO *sao) { m_sao = sao; }
|
|
|
|
|
|
|
|
const RemotePlayerChatResult canSendChatMessage();
|
|
|
|
|
|
|
|
void setHotbarItemcount(s32 hotbar_itemcount)
|
|
|
|
{
|
|
|
|
hud_hotbar_itemcount = hotbar_itemcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 getHotbarItemcount() const { return hud_hotbar_itemcount; }
|
|
|
|
|
|
|
|
void overrideDayNightRatio(bool do_override, float ratio)
|
|
|
|
{
|
|
|
|
m_day_night_ratio_do_override = do_override;
|
|
|
|
m_day_night_ratio = ratio;
|
|
|
|
}
|
|
|
|
|
|
|
|
void getDayNightRatio(bool *do_override, float *ratio)
|
|
|
|
{
|
|
|
|
*do_override = m_day_night_ratio_do_override;
|
|
|
|
*ratio = m_day_night_ratio;
|
|
|
|
}
|
|
|
|
|
2017-04-07 08:50:17 +02:00
|
|
|
void setHotbarImage(const std::string &name) { hud_hotbar_image = name; }
|
2016-10-08 19:08:23 +02:00
|
|
|
|
2018-03-08 22:05:47 +01:00
|
|
|
const std::string &getHotbarImage() const { return hud_hotbar_image; }
|
2016-10-08 19:08:23 +02:00
|
|
|
|
|
|
|
void setHotbarSelectedImage(const std::string &name)
|
|
|
|
{
|
|
|
|
hud_hotbar_selected_image = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string &getHotbarSelectedImage() const
|
|
|
|
{
|
|
|
|
return hud_hotbar_selected_image;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSky(const video::SColor &bgcolor, const std::string &type,
|
2017-04-28 04:06:49 +02:00
|
|
|
const std::vector<std::string> ¶ms, bool &clouds)
|
2016-10-08 19:08:23 +02:00
|
|
|
{
|
|
|
|
m_sky_bgcolor = bgcolor;
|
|
|
|
m_sky_type = type;
|
|
|
|
m_sky_params = params;
|
2017-04-28 04:06:49 +02:00
|
|
|
m_sky_clouds = clouds;
|
2016-10-08 19:08:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void getSky(video::SColor *bgcolor, std::string *type,
|
2017-04-28 04:06:49 +02:00
|
|
|
std::vector<std::string> *params, bool *clouds)
|
2016-10-08 19:08:23 +02:00
|
|
|
{
|
|
|
|
*bgcolor = m_sky_bgcolor;
|
|
|
|
*type = m_sky_type;
|
|
|
|
*params = m_sky_params;
|
2017-04-28 04:06:49 +02:00
|
|
|
*clouds = m_sky_clouds;
|
2016-10-08 19:08:23 +02:00
|
|
|
}
|
|
|
|
|
2017-03-17 10:39:47 +01:00
|
|
|
void setCloudParams(const CloudParams &cloud_params)
|
|
|
|
{
|
|
|
|
m_cloud_params = cloud_params;
|
|
|
|
}
|
|
|
|
|
2017-05-04 07:52:31 +02:00
|
|
|
const CloudParams &getCloudParams() const { return m_cloud_params; }
|
2017-03-17 10:39:47 +01:00
|
|
|
|
2016-10-08 19:08:23 +02:00
|
|
|
bool checkModified() const { return m_dirty || inventory.checkModified(); }
|
|
|
|
|
|
|
|
void setModified(const bool x)
|
|
|
|
{
|
|
|
|
m_dirty = x;
|
|
|
|
if (!x)
|
|
|
|
inventory.setModified(x);
|
|
|
|
}
|
|
|
|
|
2016-10-08 23:13:38 +02:00
|
|
|
void setLocalAnimations(v2s32 frames[4], float frame_speed)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
local_animations[i] = frames[i];
|
|
|
|
local_animation_speed = frame_speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void getLocalAnimations(v2s32 *frames, float *frame_speed)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
frames[i] = local_animations[i];
|
|
|
|
*frame_speed = local_animation_speed;
|
|
|
|
}
|
|
|
|
|
2016-10-30 14:53:26 +01:00
|
|
|
void setDirty(bool dirty) { m_dirty = true; }
|
|
|
|
|
2017-06-18 19:55:15 +02:00
|
|
|
u16 protocol_version = 0;
|
2017-04-07 08:50:17 +02:00
|
|
|
|
2017-09-30 12:00:05 +02:00
|
|
|
session_t getPeerId() const { return m_peer_id; }
|
|
|
|
|
|
|
|
void setPeerId(session_t peer_id) { m_peer_id = peer_id; }
|
|
|
|
|
2016-10-08 19:08:23 +02:00
|
|
|
private:
|
|
|
|
/*
|
|
|
|
serialize() writes a bunch of text that can contain
|
|
|
|
any characters except a '\0', and such an ending that
|
|
|
|
deSerialize stops reading exactly at the right point.
|
|
|
|
*/
|
|
|
|
void serialize(std::ostream &os);
|
2017-01-27 08:59:30 +01:00
|
|
|
void serializeExtraAttributes(std::string &output);
|
2016-10-08 19:08:23 +02:00
|
|
|
|
2017-06-18 19:55:15 +02:00
|
|
|
PlayerSAO *m_sao = nullptr;
|
|
|
|
bool m_dirty = false;
|
2016-10-08 19:08:23 +02:00
|
|
|
|
|
|
|
static bool m_setting_cache_loaded;
|
|
|
|
static float m_setting_chat_message_limit_per_10sec;
|
|
|
|
static u16 m_setting_chat_message_limit_trigger_kick;
|
|
|
|
|
2017-06-18 19:55:15 +02:00
|
|
|
u32 m_last_chat_message_sent = std::time(0);
|
|
|
|
float m_chat_message_allowance = 5.0f;
|
|
|
|
u16 m_message_rate_overhead = 0;
|
2016-10-08 19:08:23 +02:00
|
|
|
|
2017-10-29 19:31:50 +01:00
|
|
|
bool m_day_night_ratio_do_override = false;
|
2016-10-08 19:08:23 +02:00
|
|
|
float m_day_night_ratio;
|
2017-06-18 19:55:15 +02:00
|
|
|
std::string hud_hotbar_image = "";
|
|
|
|
std::string hud_hotbar_selected_image = "";
|
2016-10-08 19:08:23 +02:00
|
|
|
|
|
|
|
std::string m_sky_type;
|
|
|
|
video::SColor m_sky_bgcolor;
|
|
|
|
std::vector<std::string> m_sky_params;
|
2017-04-28 04:06:49 +02:00
|
|
|
bool m_sky_clouds;
|
|
|
|
|
2017-03-17 10:39:47 +01:00
|
|
|
CloudParams m_cloud_params;
|
2017-09-30 12:00:05 +02:00
|
|
|
|
|
|
|
session_t m_peer_id = PEER_ID_INEXISTENT;
|
2016-10-08 19:08:23 +02:00
|
|
|
};
|