diff options
author | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:54 -0500 |
commit | b2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch) | |
tree | 3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/llmessage/llmessagetemplate.cpp | |
parent | Second Life viewer sources 1.14.0.1 (diff) | |
download | meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2 meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz |
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/llmessage/llmessagetemplate.cpp')
-rw-r--r-- | linden/indra/llmessage/llmessagetemplate.cpp | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llmessagetemplate.cpp b/linden/indra/llmessage/llmessagetemplate.cpp new file mode 100644 index 0000000..026843d --- /dev/null +++ b/linden/indra/llmessage/llmessagetemplate.cpp | |||
@@ -0,0 +1,146 @@ | |||
1 | #include "linden_common.h" | ||
2 | |||
3 | #include "llmessagetemplate.h" | ||
4 | |||
5 | #include "message.h" | ||
6 | |||
7 | void LLMsgVarData::addData(const void *data, S32 size, EMsgVariableType type, S32 data_size) | ||
8 | { | ||
9 | mSize = size; | ||
10 | mDataSize = data_size; | ||
11 | if ( (type != MVT_VARIABLE) && (type != MVT_FIXED) | ||
12 | && (mType != MVT_VARIABLE) && (mType != MVT_FIXED)) | ||
13 | { | ||
14 | if (mType != type) | ||
15 | { | ||
16 | llwarns << "Type mismatch in LLMsgVarData::addData for " << mName | ||
17 | << llendl; | ||
18 | } | ||
19 | } | ||
20 | if(size) | ||
21 | { | ||
22 | delete mData; // Delete it if it already exists | ||
23 | mData = new U8[size]; | ||
24 | htonmemcpy(mData, data, mType, size); | ||
25 | } | ||
26 | } | ||
27 | |||
28 | void LLMsgData::addDataFast(char *blockname, char *varname, const void *data, S32 size, EMsgVariableType type, S32 data_size) | ||
29 | { | ||
30 | // remember that if the blocknumber is > 0 then the number is appended to the name | ||
31 | char *namep = (char *)blockname; | ||
32 | LLMsgBlkData* block_data = mMemberBlocks[namep]; | ||
33 | if (block_data->mBlockNumber) | ||
34 | { | ||
35 | namep += block_data->mBlockNumber; | ||
36 | block_data->addData(varname, data, size, type, data_size); | ||
37 | } | ||
38 | else | ||
39 | { | ||
40 | block_data->addData(varname, data, size, type, data_size); | ||
41 | } | ||
42 | } | ||
43 | |||
44 | // LLMessageVariable functions and friends | ||
45 | |||
46 | std::ostream& operator<<(std::ostream& s, LLMessageVariable &msg) | ||
47 | { | ||
48 | s << "\t\t" << msg.mName << " ("; | ||
49 | switch (msg.mType) | ||
50 | { | ||
51 | case MVT_FIXED: | ||
52 | s << "Fixed, " << msg.mSize << " bytes total)\n"; | ||
53 | break; | ||
54 | case MVT_VARIABLE: | ||
55 | s << "Variable, " << msg.mSize << " bytes of size info)\n"; | ||
56 | break; | ||
57 | default: | ||
58 | s << "Unknown\n"; | ||
59 | break; | ||
60 | } | ||
61 | return s; | ||
62 | } | ||
63 | |||
64 | // LLMessageBlock functions and friends | ||
65 | |||
66 | std::ostream& operator<<(std::ostream& s, LLMessageBlock &msg) | ||
67 | { | ||
68 | s << "\t" << msg.mName << " ("; | ||
69 | switch (msg.mType) | ||
70 | { | ||
71 | case MBT_SINGLE: | ||
72 | s << "Fixed"; | ||
73 | break; | ||
74 | case MBT_MULTIPLE: | ||
75 | s << "Multiple - " << msg.mNumber << " copies"; | ||
76 | break; | ||
77 | case MBT_VARIABLE: | ||
78 | s << "Variable"; | ||
79 | break; | ||
80 | default: | ||
81 | s << "Unknown"; | ||
82 | break; | ||
83 | } | ||
84 | if (msg.mTotalSize != -1) | ||
85 | { | ||
86 | s << ", " << msg.mTotalSize << " bytes each, " << msg.mNumber*msg.mTotalSize << " bytes total)\n"; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | s << ")\n"; | ||
91 | } | ||
92 | |||
93 | |||
94 | for (LLMessageBlock::message_variable_map_t::iterator iter = msg.mMemberVariables.begin(); | ||
95 | iter != msg.mMemberVariables.end(); iter++) | ||
96 | { | ||
97 | LLMessageVariable& ci = *(iter->second); | ||
98 | s << ci; | ||
99 | } | ||
100 | |||
101 | return s; | ||
102 | } | ||
103 | |||
104 | // LLMessageTemplate functions and friends | ||
105 | |||
106 | std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg) | ||
107 | { | ||
108 | switch (msg.mFrequency) | ||
109 | { | ||
110 | case MFT_HIGH: | ||
111 | s << "========================================\n" << "Message #" << msg.mMessageNumber << "\n" << msg.mName << " ("; | ||
112 | s << "High"; | ||
113 | break; | ||
114 | case MFT_MEDIUM: | ||
115 | s << "========================================\n" << "Message #"; | ||
116 | s << (msg.mMessageNumber & 0xFF) << "\n" << msg.mName << " ("; | ||
117 | s << "Medium"; | ||
118 | break; | ||
119 | case MFT_LOW: | ||
120 | s << "========================================\n" << "Message #"; | ||
121 | s << (msg.mMessageNumber & 0xFFFF) << "\n" << msg.mName << " ("; | ||
122 | s << "Low"; | ||
123 | break; | ||
124 | default: | ||
125 | s << "Unknown"; | ||
126 | break; | ||
127 | } | ||
128 | |||
129 | if (msg.mTotalSize != -1) | ||
130 | { | ||
131 | s << ", " << msg.mTotalSize << " bytes total)\n"; | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | s << ")\n"; | ||
136 | } | ||
137 | |||
138 | for (LLMessageTemplate::message_block_map_t::iterator iter = msg.mMemberBlocks.begin(); | ||
139 | iter != msg.mMemberBlocks.end(); iter++) | ||
140 | { | ||
141 | LLMessageBlock* ci = iter->second; | ||
142 | s << *ci; | ||
143 | } | ||
144 | |||
145 | return s; | ||
146 | } | ||