|
Last change
on this file since edfd1d0 was edfd1d0, checked in by dportnoy <dmp1488@…>, 13 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
|
| Line | |
|---|
| 1 | #include "Player.h"
|
|---|
| 2 |
|
|---|
| 3 | #include <iostream>
|
|---|
| 4 | #include <arpa/inet.h>
|
|---|
| 5 |
|
|---|
| 6 | using namespace std;
|
|---|
| 7 |
|
|---|
| 8 | Player::Player(string name, string password)
|
|---|
| 9 | {
|
|---|
| 10 | this->name = name;
|
|---|
| 11 | this->password = password;
|
|---|
| 12 | this->pos.x = 200;
|
|---|
| 13 | this->pos.y = 200;
|
|---|
| 14 |
|
|---|
| 15 | cout << "Created new player: " << this->name << endl;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | Player::Player(string name, sockaddr_in addr)
|
|---|
| 19 | {
|
|---|
| 20 | this->name = name;
|
|---|
| 21 | this->password = "";
|
|---|
| 22 | this->pos.x = 200;
|
|---|
| 23 | this->pos.y = 200;
|
|---|
| 24 | this->addr = addr;
|
|---|
| 25 |
|
|---|
| 26 | cout << "Created new played: " << this->name << endl;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | Player::~Player()
|
|---|
| 30 | {
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | void Player::setAddr(sockaddr_in addr)
|
|---|
| 34 | {
|
|---|
| 35 | this->addr = addr;
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | void 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.