This is a snip of code from AV and I am about to tell you once again, the single coolest thing in C++ is member pointers(function and data). oh and local class declarations are also THE shit. I suppose this isnt neccisarily the most readable code in the world but.... the most awsome things rarely are. Now if only synergy supported this :d
void MessageBox::SendMessage(ArchverseCore::Game::DiplomaticMessage &message) { Player sendingPlayer, recivingPlayer; if(PLAYER_TABLE.Exists(message._senderId) && PLAYER_TABLE.Exists(message._targetId)) { class PushMessage { private: uint32_t _messageId; vector<uint32_t>& (MessageBox::*_target)(); public: PushMessage(uint32_t messageId, vector<uint32_t>& (MessageBox::*target)()) : _messageId(messageId), _target(target) {} bool operator()(Player& player) { (player.Messages().*_target)().push_back(_messageId); return true; } }; MESSAGE_TABLE.SaveMessage(message); PLAYER_TABLE.LockedTransaction(message._senderId, PushMessage(message._id, &MessageBox::Sent)); PLAYER_TABLE.LockedTransaction(message._targetId, PushMessage(message._id, &MessageBox::Inbox)); } }
Trackbacks
Use the following link to trackback from your own site:
http://www.archverse.com/typo/trackbacks?article_id=8
I link wow gold and world of warcraft gold wow power leveling