// // bool processPacket(p) // Last modified: 08Nov2009 // // Responds appropriately to auction announcements. // // Returns: true if successful, false otherwise // Parameters: // p in/out the packet to be processed // bool Robot::processPacket(Packet &p) { bool success = false; switch (p.type) { case PUSH_AUCTION_ANNOUNCEMENT: { GLfloat range = rangeSensor(p); if (range > 0.0f) { GLfloat b_j = E * range; Bid *b = new Bid(b_j, getID()); success = env->sendMsg(b, p.fromID, (-1 * (ID * 10)), BID); } else success = true; } case BID: { if(p.msg!=NULL) { bids.push_back((Bid*)p.msg); success = true; numBids++; //cout << "bid received, total = " << numBids << endl; } } break; default: break; } return success; } // processPacket(Packet &)
// // bool processPacket(p) // Last modified: 08Nov2009 // // Responds appropriately to auction announcements. // // Returns: true if successful, false otherwise // Parameters: // p in/out the packet to be processed // bool Robot::processPacket(Packet &p) { bool success = false; switch (p.type) { case AUCTION_ANNOUNCEMENT: { GLfloat range = rangeSensor(p); if (range > 0.0f) { GLfloat b_j = E * range; Bid *b = new Bid(b_j, getID()); success = env->sendMsg(b, p.fromID, (-1 * (ID * 10)), BID); } else success = true; } break; default: break; } return success; } // processPacket(Packet &)