From 8898ad9b25fca6afe2374d293a981db02a83d7e9 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 31 May 2012 14:46:27 +0000 Subject: Committing the documentation to svn to have it accessible online --- Doc/doxygen/html/_net_gram_8cpp_source.html | 219 ++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 Doc/doxygen/html/_net_gram_8cpp_source.html (limited to 'Doc/doxygen/html/_net_gram_8cpp_source.html') diff --git a/Doc/doxygen/html/_net_gram_8cpp_source.html b/Doc/doxygen/html/_net_gram_8cpp_source.html new file mode 100644 index 0000000..749c15f --- /dev/null +++ b/Doc/doxygen/html/_net_gram_8cpp_source.html @@ -0,0 +1,219 @@ + + + + + +Starshatter_Open: D:/SRC/StarshatterSVN/NetEx/NetGram.cpp Source File + + + + + + + + + + + + + +
+
+ + + + + + +
+
Starshatter_Open +
+
Open source Starshatter engine
+
+
+ + + + + +
+
+ +
+
+
+ +
+ + + + +
+ +
+ +
+
+
NetGram.cpp
+
+
+Go to the documentation of this file.
1 /* Project nGenEx
+
2  Destroyer Studios LLC
+
3  Copyright © 1997-2004. All Rights Reserved.
+
4 
+
5  SUBSYSTEM: NetEx.lib
+
6  FILE: NetGram.cpp
+
7  AUTHOR: John DiCamillo
+
8 
+
9 
+
10  OVERVIEW
+
11  ========
+
12  Generic Network Packet (Datagram) Implementation
+
13 */
+
14 
+
15 
+
16 #include "MemDebug.h"
+
17 #include "NetGram.h"
+
18 #include "NetLayer.h"
+
19 
+
20 // +-------------------------------------------------------------------+
+
21 
+
22 static DWORD net_gram_sequence = 1;
+
23 
+
24 // +-------------------------------------------------------------------+
+
25 
+ +
30  : retries(0), packet_id(0), send_time(0)
+
31 { }
+
32 
+
36 NetGram::NetGram(const NetAddr& src, Text msg)
+
37  : addr(src), retries(0), send_time(0)
+
38 {
+
39  body = msg;
+
40 
+
41  if (body.length() >= NET_GRAM_HEADER_SIZE) {
+
42  BYTE* data = (BYTE*) body.data();
+
43 
+
44  packet_id = (((DWORD) data[0]) << 24) +
+
45  (((DWORD) data[1]) << 16) +
+
46  (((DWORD) data[2]) << 8) +
+
47  ((DWORD) data[3]);
+
48  }
+
49 }
+
50 
+
54 NetGram::NetGram(const NetAddr& dst, Text user_data, int r)
+
55  : addr(dst), retries(r)
+
56 {
+ +
58  packet_id = net_gram_sequence++;
+
59 
+
60  if (retries)
+ +
62 
+
63  static BYTE buf[NET_GRAM_MAX_SIZE];
+
64  buf[0] = (BYTE) (packet_id >> 24) & 0xff;
+
65  buf[1] = (BYTE) (packet_id >> 16) & 0xff;
+
66  buf[2] = (BYTE) (packet_id >> 8) & 0xff;
+
67  buf[3] = (BYTE) (packet_id) & 0xff;
+
68 
+
69  int len = user_data.length();
+ + +
72 
+
73  CopyMemory(buf+NET_GRAM_HEADER_SIZE, user_data.data(), len);
+
74 
+
75  body = Text((char*) buf, len+NET_GRAM_HEADER_SIZE);
+
76 }
+
77 
+
78 // +--------------------------------------------------------------------+
+
79 
+
80 void
+ +
82 {
+
83  if (retries > 0) {
+
84  retries--;
+ +
86  }
+
87 }
+
88 
+
89 // +--------------------------------------------------------------------+
+
90 
+
91 NetGram
+ +
93 {
+
94  NetGram ack;
+
95 
+ + +
98 
+
99  static BYTE buf[NET_GRAM_HEADER_SIZE];
+
100  buf[0] = (BYTE) (ack.packet_id >> 24) & 0xff;
+
101  buf[1] = (BYTE) (ack.packet_id >> 16) & 0xff;
+
102  buf[2] = (BYTE) (ack.packet_id >> 8) & 0xff;
+
103  buf[3] = (BYTE) (ack.packet_id) & 0xff;
+
104 
+
105  ack.body = Text((char*) buf, NET_GRAM_HEADER_SIZE);
+
106 
+
107  return ack;
+
108 }
+
109 
+
110 
+
111 
+
+
+ + + + -- cgit v1.1