Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
NetUser.cpp
Go to the documentation of this file.
1 /* Project Starshatter 4.5
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: NetUser.cpp
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  This class represents a user connecting to the multiplayer lobby
13 */
14 
15 
16 #include "MemDebug.h"
17 #include "NetUser.h"
18 #include "NetAuth.h"
19 #include "NetLobby.h"
20 #include "Player.h"
21 #include "FormatUtil.h"
22 
23 // +-------------------------------------------------------------------+
24 
25 static Color user_colors[] = {
36  Color::Tan,
38 };
39 
40 static int user_color_index = 0;
41 
42 // +-------------------------------------------------------------------+
43 
44 NetUser::NetUser(const char* n)
45 : name(n), netid(0), host(false),
46 rank(0), flight_time(0), missions(0), kills(0), losses(0),
47 auth_state(NetAuth::NET_AUTH_INITIAL),
48 auth_level(NetAuth::NET_AUTH_MINIMAL)
49 {
50  if (user_color_index < 0 || user_color_index >= 12)
51  user_color_index = 0;
52 
53  color = user_colors[user_color_index++];
54 
55  ZeroMemory(salt, sizeof(salt));
56 }
57 
58 NetUser::NetUser(const Player* player)
59 : netid(0), host(false),
60 rank(0), flight_time(0), missions(0), kills(0), losses(0),
61 auth_state(NetAuth::NET_AUTH_INITIAL),
62 auth_level(NetAuth::NET_AUTH_MINIMAL)
63 {
64  if (user_color_index < 0 || user_color_index >= 12)
65  user_color_index = 0;
66 
67  color = user_colors[user_color_index++];
68 
69  if (player) {
70  name = player->Name();
71  pass = player->Password();
72  signature = player->Signature();
73  squadron = player->Squadron();
74  rank = player->Rank();
75  flight_time = player->FlightTime();
76  missions = player->Missions();
77  kills = player->Kills();
78  losses = player->Losses();
79  }
80 
81  ZeroMemory(salt, sizeof(salt));
82 }
83 
85 { }
86 
87 // +-------------------------------------------------------------------+
88 
89 Text
91 {
92  Text content;
93 
94  content += "name \"";
95  content += SafeQuotes(name);
96  content += "\" sig \"";
97  content += SafeQuotes(signature);
98  content += "\" squad \"";
99  content += SafeQuotes(squadron);
100 
101  char buffer[256];
102  sprintf_s(buffer, "\" rank %d time %d miss %d kill %d loss %d host %s ",
104  host ? "true" : "false");
105 
106  content += buffer;
107 
108  return content;
109 }
110 
111 // +-------------------------------------------------------------------+
112 
113 bool
115 {
117 }