void RefQuantityListObjectParam::packObjectFrame(OutputFrame::Ptr f, uint32_t objID){ f->packInt(refquant.size()); for(std::map<std::pair<int32_t, uint32_t>, uint32_t>::iterator itcurr = refquant.begin(); itcurr != refquant.end(); ++itcurr){ f->packInt(itcurr->first.first); f->packInt(itcurr->first.second); f->packInt(itcurr->second); } }
bool AsyncTimeRemaining::createFrame(OutputFrame::Ptr f) { f->setType(ft02_Time_Remaining); f->packInt(rtime); if(f->getVersion() >= fv0_4){ f->packInt(why); //reason f->packInt(Game::getGame()->getTurnNumber()); f->packString(Game::getGame()->getTurnName()); } return true; }
void Order::describeOrder(OutputFrame::Ptr f) const { f->setType(ft02_OrderDesc); f->packInt(type); f->packString(name); f->packString(description); f->packInt(parameters.size()); std::for_each( parameters.begin(), parameters.end(), boost::bind( &OrderParameter::packOrderDescFrame, _1, f ) ); f->packInt64(descmodtime); }
void Order::createFrame(OutputFrame::Ptr f, int pos) { f->setType(ft02_Order); if(f->getVersion() <= fv0_3){ f->packInt(Game::getGame()->getOrderManager()->getOrderQueue(orderqueueid)->getObjectId()); }else{ f->packInt(orderqueueid); } f->packInt(pos); f->packInt(type); f->packInt(turns); f->packIdMap(resources); std::for_each( parameters.begin(), parameters.end(), boost::bind( &OrderParameter::pack, _1, f ) ); }
void Category::pack(OutputFrame::Ptr frame) const{ frame->setType(ft03_Category); frame->packInt(id); frame->packInt64(getModTime()); //timestamp frame->packString(name); frame->packString(desc); }
void Planet::packExtraData(OutputFrame::Ptr frame){ OwnedObject::packExtraData(frame); std::map<uint32_t, std::pair<uint32_t, uint32_t> > reslist = dynamic_cast<ResourceListObjectParam*>(obj->getParameter(4,1))->getResources(); frame->packInt(reslist.size()); for(std::map<uint32_t, std::pair<uint32_t, uint32_t> >::iterator itcurr = reslist.begin(); itcurr != reslist.end(); ++itcurr){ frame->packInt(itcurr->first); frame->packInt(itcurr->second.first); frame->packInt(itcurr->second.second); frame->packInt(0); } //unneeded as per llnz, doesn't allow client to connect //frame->packInt(dynamic_cast<IntegerObjectParam*>(obj->getParameter(5,1))->getValue()); }
void OwnedObject::packExtraData(OutputFrame::Ptr frame){ SpaceObject::packExtraData(frame); ReferenceObjectParam* playerref = ((ReferenceObjectParam*)(obj->getParameter(OWNERGRPID,OWNERPARAMID))); frame->packInt((playerref->getReferencedId() == 0) ? 0xffffffff : playerref->getReferencedId()); }
void Player::pack(OutputFrame::Ptr frame) const { frame->setType(ft03_Player); frame->packInt(id); frame->packString(name); frame->packString("Human"); frame->packInt64(getModTime()); }
void Fleet::packExtraData(OutputFrame::Ptr frame){ Logger::getLogger()->debug("Enter: Fleet::packExtraData"); OwnedObject::packExtraData(frame); std::map<std::pair<int32_t, uint32_t>, uint32_t> ships = ((RefQuantityListObjectParam*)(obj->getParameter(4,1)))->getRefQuantityList(); frame->packInt(ships.size()); for(std::map<std::pair<int32_t, uint32_t>, uint32_t>::iterator itcurr = ships.begin(); itcurr != ships.end(); ++itcurr){ //if(itcurr->second > 0){ frame->packInt(itcurr->first.second); frame->packInt(itcurr->second); //} } frame->packInt(((IntegerObjectParam*)(obj->getParameter(4,2)))->getValue()); Logger::getLogger()->debug("Exit: Fleet::packExtraData"); }
void Board::packMessage(OutputFrame::Ptr frame, uint32_t msgnum) { if (msgnum < message_count) { Message::Ptr message; retrieveMessageList(); if (msgnum < message_ids.size()) { IdList::iterator itpos = message_ids.begin(); advance(itpos, msgnum); message = Game::getGame()->getBoardManager()->getMessage(*itpos); } if (message != NULL) { frame->setType(ft02_Message); frame->packInt(id); frame->packInt(msgnum); message->pack(frame); } else { WARNING("Board has messages but persistence didn't get it"); WARNING("POSSIBLE DATABASE INCONSISTANCE"); throw FrameException(fec_TempUnavailable, "Could not get Message at this time"); } } else { throw FrameException(fec_NonExistant, "No such Message on board"); } }
void Message::pack(OutputFrame::Ptr frame) const { if (frame->getVersion() == fv0_2) { frame->packInt(1); frame->packInt(0); } else { frame->packInt(0); } frame->packString(name); frame->packString(desc); if (frame->getVersion() > fv0_2) { frame->packInt(turn_number); frame->packInt(references.size()); for (References::iterator itcurr = references.begin(); itcurr != references.end(); ++itcurr) { frame->packInt((*itcurr).first); frame->packInt((*itcurr).second); } } }
void PropertyValue::packFrame(OutputFrame::Ptr frame) const{ frame->packInt(propid); frame->packString(display); }
void Board::pack(OutputFrame::Ptr frame) const { ProtocolObject::pack( frame ); frame->packInt(message_count); frame->packInt64(getModTime()); }
void ReferenceObjectParam::packObjectFrame(OutputFrame::Ptr f, uint32_t objID){ f->packInt(reftype); f->packInt(refid); }
void IntegerObjectParam::packObjectFrame(OutputFrame::Ptr f, uint32_t objID){ f->packInt(value); }