Position *Message::ExtractPosition() { int x = ExtractInt(); int y = ExtractInt(); Position *position = new Position(x, y); return position; }
View *Message::ExtractView() { if (message_type_ == kViewUpdateMessage) { int width = ExtractInt(); int height = ExtractInt(); char *view_data = ExtractArray(); int pos_x = ExtractInt(); int pos_y = ExtractInt(); View *view = new View(view_data, width, height, Position(pos_x, pos_y)); return view; } return NULL; }
char *Message::ExtractArray() { int size = ExtractInt(); char *array = new char [size]; memcpy(array, buffer_ + position_, size); position_ += size; return array; }
GLDEF_C TInt E32Main() { TBuf<30> cmd; User::CommandLine(cmd); // schedule Handle is first TInt scheduleHandle=0, taskHandle=0, errCode=0, schCount=0, taskCount=0; cmd = ExtractInt(cmd, scheduleHandle); // task Handle is second cmd = ExtractInt(cmd, taskHandle); // expected error code is third cmd = ExtractInt(cmd, errCode); // expected schedule count (based on this exe UID/Capability is fourth cmd = ExtractInt(cmd, schCount); // expected task count (based on this exe UID/Capability is fourth cmd = ExtractInt(cmd, taskCount); return Execute(scheduleHandle, taskHandle, errCode, schCount, taskCount); }
Entity *Message::ExtractEntity() { if (message_type_ == kEntityDataMessage || message_type_ == kViewUpdateMessage) { boost::uuids::uuid source = ExtractUuid(); std::string name = ExtractString(); int health_value = ExtractInt(); int health_bound = ExtractInt(); BoundedAttribute health(health_value, health_bound); Entity *entity = new Entity(name, health); entity->AssignId(source); std::string weapon_name = ExtractString(); int value = ExtractInt(); int min_damage = ExtractInt(); int max_damage = ExtractInt(); Weapon *weapon = new Weapon(weapon_name, value, min_damage, max_damage); weapon->Equip(*entity); return entity; } return NULL; }