1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/****************************************************************************
* Structures and Enums
****************************************************************************/
enum state {
START,
NO_NICK,
PLAYING
};
enum connections {
dialup,
DSL,
cable
};
struct user_items {
int cdburners;
int cds;
long hdspace; //in MB
int numtitles;
float download_queue;
enum connections connection_type;
};
struct player {
int id;
int sock;
enum state current_state;
char nick[21];
float cash;
struct user_items inventory;
char cheated;
int total_sales;
float price;
};
struct item {
int id;
char name[80];
float price;
};
/****************************************************************************
* Function Prototypes
****************************************************************************/
void startsession(int);
void dataHandler(struct player*);
void print(int sock, char* msg);
void setnonblocking(int sock);
void newUser(int sock);
int nick_exists(char *name);
void strip_nl_chars(char *buffer);
void print_instructions(int sock);
void list_commands(int sock);
void command_detail(int sock, char *command);
void shout(int uid, char *msg);
void whisper(int uid, char *buffer);
int match(const char *string, char *pattern);
void end_session(struct player* activePlayer);
void initialize_items();
void display_store(int sock);
void buy(struct player* buyer, char *buffer);
void viewInventory(struct player* buyer);
void updateUsers(float secDiff);
void saleStuff(struct player* seller, float secs);
void cheat(struct player* cheater);
void setprice(struct player* user, char *buffer);
void viewStatus(struct player* buyer);
/****************************************************************************
* Global Variables
****************************************************************************/
int nextid = 0; //this will be the UID of the new user
struct dlinkedlist playerList, allItems;
struct ilinkedlist itemList;
float download_speeds[3];
|