Permalink
Browse files

added set_name and some minor missing stuff

  • Loading branch information...
1 parent 62a1c7a commit 88bf2ce0f08f8cb2ccb06818b0b9fbccd60dd84e Daniel (dmilith) Dettlaff committed Aug 28, 2008
Showing with 8 additions and 7 deletions.
  1. +4 −0 character.cpp
  2. +2 −1 character.h
  3. +2 −6 tests/asio_client_test.cpp
View
@@ -276,3 +276,7 @@ Ccharacter::set_max_load( int32_t max_load_ ) {
max_load = max_load_;
}
+void
+Ccharacter::set_name( std::string name_ ) {
+ name = name_;
+}
View
@@ -88,6 +88,8 @@ class Ccharacter {
void set_age( int16_t age_ );
void set_soul( Csoul* soul_ );
void set_max_load( int32_t max_load_ );
+ void set_position( Ccoordinates position_ );
+ void set_name( std::string name_ );
void gain_armor( int32_t armor_ );
void gain_health( int32_t damage_ ); // get hurt or get heal
void gain_gold( int64_t gold_amount_ ); // could be negative
@@ -97,7 +99,6 @@ class Ccharacter {
void gain_strength( int64_t strength_ );
void gain_intelligence( int64_t intelligence_ );
void gain_luck( int16_t luck_ );
- void set_position( Ccoordinates position_ );
bool is_dead();
}; // player/ npc/ character
@@ -38,18 +38,14 @@ int main(int argc, char* argv[]) {
udp::resolver::iterator iterator = resolver.resolve( query );
using namespace std; // For strlen.
- // std::cout << "Enter message: ";
- // char request[max_length];
- // std::cin.getline(request, max_length);
- // size_t request_length = strlen(request);
z->set_age( 666 );
+ z->set_name( "yep that's me" );
s.send_to( boost::asio::buffer( z, sizeof( Ccharacter ) ), *iterator );
- // char reply[max_length];
udp::endpoint sender_endpoint;
size_t reply_length = s.receive_from( boost::asio::buffer( zz, sizeof( Ccharacter ) ), sender_endpoint );
std::cout << "Reply is: ";
- std::cout << zz->get_age(); //, sizeof( Ccharacter ) );
+ std::cout << zz->get_age() << " " << zz->get_name();
std::cout << "\n";
}
catch (std::exception& e) {

0 comments on commit 88bf2ce

Please sign in to comment.