Exemple #1
0
void Category::pack(OutputFrame::Ptr frame) const{
  frame->setType(ft03_Category);
  frame->packInt(id);
  frame->packInt64(getModTime()); //timestamp
  frame->packString(name);
  frame->packString(desc);
}
Exemple #2
0
void Player::pack(OutputFrame::Ptr frame) const {
    frame->setType(ft03_Player);
    frame->packInt(id);
    frame->packString(name);
    frame->packString("Human");
    frame->packInt64(getModTime());
}
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);
  }
}
Exemple #4
0
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());

}
Exemple #5
0
void OwnedObject::packExtraData(OutputFrame::Ptr frame){
  SpaceObject::packExtraData(frame);
  
  ReferenceObjectParam* playerref = ((ReferenceObjectParam*)(obj->getParameter(OWNERGRPID,OWNERPARAMID)));
  frame->packInt((playerref->getReferencedId() == 0) ? 0xffffffff : playerref->getReferencedId());

}
Exemple #6
0
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");

}
Exemple #7
0
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 ) );
}
Exemple #8
0
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);
    }
  }
}
Exemple #9
0
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");
  }
}
Exemple #10
0
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);
}
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;
}
Exemple #12
0
void PropertyValue::packFrame(OutputFrame::Ptr frame) const{
  frame->packInt(propid);
  frame->packString(display);
}
Exemple #13
0
void Wormhole::packExtraData(OutputFrame::Ptr frame) {
   Vector3d end = getEndB();
   frame->packInt64(end.getX());
   frame->packInt64(end.getY());
   frame->packInt64(end.getZ());
}
Exemple #14
0
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);
}