Exemplo n.º 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);
}
Exemplo n.º 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());
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
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 ) );
}
Exemplo n.º 6
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");
  }
}