- if(m_walk_around)
- {
- if(!m_next_pos_exists){
- /* Find some position where to go next */
- v3s16 dps[3*3*3];
- int num_dps = 0;
- for(int dx=-1; dx<=1; dx++)
- for(int dy=-1; dy<=1; dy++)
- for(int dz=-1; dz<=1; dz++){
- if(dx == 0 && dy == 0)
- continue;
- if(dx != 0 && dz != 0 && dy != 0)
- continue;
- dps[num_dps++] = v3s16(dx,dy,dz);
- }
- u32 order[3*3*3];
- get_random_u32_array(order, num_dps);
- for(int i=0; i<num_dps; i++){
- v3s16 p = dps[order[i]] + pos_i;
- bool is_free = checkFreeAndWalkablePosition(map,
- p + pos_size_off, size_blocks);
- if(!is_free)
- continue;
- m_next_pos_i = p;
- m_next_pos_exists = true;
- break;
- }
- }
- }
- }
- else if(m_move_type == "constant_speed")
- {
- m_base_position += m_speed * dtime;
-
- v3s16 pos_i = floatToInt(m_base_position, BS);
- v3s16 size_blocks = v3s16(m_size.X+0.5,m_size.Y+0.5,m_size.X+0.5);
- v3s16 pos_size_off(0,0,0);
- if(m_size.X >= 2.5){
- pos_size_off.X = -1;
- pos_size_off.Y = -1;
- }
- bool free = checkFreePosition(map, pos_i + pos_size_off, size_blocks);
- if(!free){
- explodeSquare(map, pos_i, v3s16(3,3,3));
- m_removed = true;
- return;
- }
- }
- else
- {
- errorstream<<"MobV2SAO::step(): id="<<m_id<<" unknown move_type=\""
- <<m_move_type<<"\""<<std::endl;
- }
+// No prototype, PlayerSAO does not need to be deserialized
+
+PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
+ const std::set<std::string> &privs, bool is_singleplayer):
+ ServerActiveObject(env_, v3f(0,0,0)),
+ m_player(player_),
+ m_peer_id(peer_id_),
+ m_inventory(NULL),
+ m_damage(0),
+ m_last_good_position(0,0,0),
+ m_time_from_last_punch(0),
+ m_nocheat_dig_pos(32767, 32767, 32767),
+ m_nocheat_dig_time(0),
+ m_wield_index(0),
+ m_position_not_sent(false),
+ m_armor_groups_sent(false),
+ m_properties_sent(true),
+ m_privs(privs),
+ m_is_singleplayer(is_singleplayer),
+ m_animation_speed(0),
+ m_animation_blend(0),
+ m_animation_sent(false),
+ m_bone_position_sent(false),
+ m_attachment_parent_id(0),
+ m_attachment_sent(false),
+ // public
+ m_moved(false),
+ m_inventory_not_sent(false),
+ m_hp_not_sent(false),
+ m_breath_not_sent(false),
+ m_wielded_item_not_sent(false),
+ m_physics_override_speed(1),
+ m_physics_override_jump(1),
+ m_physics_override_gravity(1),
+ m_physics_override_sneak(true),
+ m_physics_override_sneak_glitch(true),
+ m_physics_override_sent(false)
+{
+ assert(m_player);
+ assert(m_peer_id != 0);
+ setBasePosition(m_player->getPosition());
+ m_inventory = &m_player->inventory;
+ m_armor_groups["fleshy"] = 100;
+
+ m_prop.hp_max = PLAYER_MAX_HP;
+ m_prop.physical = false;
+ m_prop.weight = 75;
+ m_prop.collisionbox = core::aabbox3d<f32>(-1/3.,-1.0,-1/3., 1/3.,1.0,1/3.);
+ // start of default appearance, this should be overwritten by LUA
+ m_prop.visual = "upright_sprite";
+ m_prop.visual_size = v2f(1, 2);
+ m_prop.textures.clear();
+ m_prop.textures.push_back("player.png");
+ m_prop.textures.push_back("player_back.png");
+ m_prop.colors.clear();
+ m_prop.colors.push_back(video::SColor(255, 255, 255, 255));
+ m_prop.spritediv = v2s16(1,1);
+ // end of default appearance
+ m_prop.is_visible = true;
+ m_prop.makes_footstep_sound = true;
+}