void Client::interact(u8 action, const PointedThing& pointed) { if(m_state != LC_Ready) { errorstream << "Client::interact() " "Canceled (not connected)" << std::endl; return; } /* [0] u16 command [2] u8 action [3] u16 item [5] u32 length of the next item [9] serialized PointedThing actions: 0: start digging (from undersurface) or use 1: stop digging (all parameters ignored) 2: digging completed 3: place block or item (to abovesurface) 4: use item */ NetworkPacket pkt(TOSERVER_INTERACT, 1 + 2 + 0); pkt << action; pkt << (u16)getPlayerItem(); std::ostringstream tmp_os(std::ios::binary); pointed.serialize(tmp_os); pkt.putLongString(tmp_os.str()); Send(&pkt); }
void Client::interact(u8 action, const PointedThing& pointed) { if(m_state != LC_Ready) { infostream << "Client::interact() " "cancelled (not connected)" << std::endl; return; } /* [0] u16 command [2] u8 action [3] u16 item [5] u32 length of the next item [9] serialized PointedThing actions: 0: start digging (from undersurface) or use 1: stop digging (all parameters ignored) 2: digging completed 3: place block or item (to abovesurface) 4: use item */ MSGPACK_PACKET_INIT(TOSERVER_INTERACT, 3); PACK(TOSERVER_INTERACT_ACTION, action); PACK(TOSERVER_INTERACT_ITEM, getPlayerItem()); PACK(TOSERVER_INTERACT_POINTED_THING, pointed); // Send as reliable Send(0, buffer, true); }
void Client::interact(u8 action, const PointedThing& pointed) { if(m_state != LC_Ready) { errorstream << "Client::interact() " "Canceled (not connected)" << std::endl; return; } LocalPlayer *myplayer = m_env.getLocalPlayer(); if (myplayer == NULL) return; /* [0] u16 command [2] u8 action [3] u16 item [5] u32 length of the next item (plen) [9] serialized PointedThing [9 + plen] player position information actions: 0: start digging (from undersurface) or use 1: stop digging (all parameters ignored) 2: digging completed 3: place block or item (to abovesurface) 4: use item 5: perform secondary action of item */ NetworkPacket pkt(TOSERVER_INTERACT, 1 + 2 + 0); pkt << action; pkt << (u16)getPlayerItem(); std::ostringstream tmp_os(std::ios::binary); pointed.serialize(tmp_os); pkt.putLongString(tmp_os.str()); writePlayerPos(myplayer, &m_env.getClientMap(), &pkt); Send(&pkt); }
ServerWeapon::ServerWeapon(const WeaponConfig* conf, obj_ServerPlayer* owner, int backpackIdx, const wiWeaponAttachment& attm) { m_pConfig = conf; m_Owner = owner; m_BackpackIdx = backpackIdx; memset(m_Attachments, 0, sizeof(m_Attachments)); memset(m_WeaponAttachmentStats, 0, sizeof(m_WeaponAttachmentStats)); // init default attachments for(int i=0; i<WPN_ATTM_MAX; i++) { uint32_t id = attm.attachments[i] ? attm.attachments[i] : m_pConfig->FPSDefaultID[i]; const WeaponAttachmentConfig* wac = g_pWeaponArmory->getAttachmentConfig(id); // verify attachment is legit if(!m_pConfig->isAttachmentValid(wac)) wac = NULL; m_Attachments[i] = wac; } recalcAttachmentsStats(); wiInventoryItem& wi = getPlayerItem(); const WeaponAttachmentConfig* clipCfg = getClipConfig(); // check if we need to modify starting ammo. (SERVER CODE SYNC POINT) if(wi.Var1 < 0) { if(clipCfg) wi.Var1 = clipCfg->m_Clipsize; else wi.Var1 = 0; } // set itemid of clip (SERVER CODE SYNC POINT) if(wi.Var2 < 0 && clipCfg) { wi.Var2 = clipCfg->m_itemID; } }