Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
NetChat.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: NetChat.cpp
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Single chat message and sender
13 */
14 
15 
16 #include "MemDebug.h"
17 #include "NetChat.h"
18 #include "NetLayer.h"
19 
20 // +-------------------------------------------------------------------+
21 
22 static int chat_id_key = 1000;
23 
24 // +-------------------------------------------------------------------+
25 
26 NetChatEntry::NetChatEntry(const NetUser* u, const char* s)
27 : id(chat_id_key++), msg(s)
28 {
29  if (u) {
30  user = u->Name();
31  color = u->GetColor();
32  }
33  else {
34  user = "unknown";
35  color = Color::Gray;
36  }
37 
38  time = NetLayer::GetUTC();
39 }
40 
41 NetChatEntry::NetChatEntry(int msg_id, const char* u, const char* s)
42 : id(msg_id), user(u), msg(s)
43 {
44  color = Color::Gray;
45  time = NetLayer::GetUTC();
46 
47  if (id >= chat_id_key)
48  chat_id_key = id + 1;
49 }
50 
52 { }
53