source: network-game/common/Player.cpp@ edfd1d0

Last change on this file since edfd1d0 was edfd1d0, checked in by dportnoy <dmp1488@…>, 12 years ago

Moved the Player class to the common directory, added a position to Player, added a new message type for sending player info, and made the server broadcast player positions everytime it receives and replies to a message

  • Property mode set to 100644
File size: 756 bytes
RevLine 
[8e540f4]1#include "Player.h"
[2488852]2
3#include <iostream>
4#include <arpa/inet.h>
5
6using namespace std;
7
[59061f6]8Player::Player(string name, string password)
9{
10 this->name = name;
11 this->password = password;
[edfd1d0]12 this->pos.x = 200;
13 this->pos.y = 200;
[59061f6]14
15 cout << "Created new player: " << this->name << endl;
16}
17
[8e540f4]18Player::Player(string name, sockaddr_in addr)
[2488852]19{
20 this->name = name;
[59061f6]21 this->password = "";
[edfd1d0]22 this->pos.x = 200;
23 this->pos.y = 200;
[2488852]24 this->addr = addr;
25
26 cout << "Created new played: " << this->name << endl;
27}
28
[8e540f4]29Player::~Player()
[2488852]30{
31}
32
[59061f6]33void Player::setAddr(sockaddr_in addr)
34{
35 this->addr = addr;
36}
[edfd1d0]37
38void Player::clearSensitiveInfo()
39{
40 this->password = "";
41 this->addr.sin_family = 0;
42 this->addr.sin_port = 0;
43 this->addr.sin_addr.s_addr = 0;
44}
Note: See TracBrowser for help on using the repository browser.