MCPcopy Create free account
hub / github.com/JACoders/OpenJK / ReadMember

Method ReadMember

code/icarus/BlockStream.cpp:124–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122*/
123
124int CBlockMember::ReadMember( char **stream, long *streamPos, CIcarus* icarus )
125{
126 IGameInterface* game = icarus->GetGame();
127 m_id = LittleLong(*(int *) (*stream + *streamPos));
128 *streamPos += sizeof( int );
129
130 if ( m_id == CIcarus::ID_RANDOM )
131 {//special case, need to initialize this member's data to Q3_INFINITE so we can randomize the number only the first time random is checked when inside a wait
132 m_size = sizeof( float );
133 *streamPos += sizeof( int );
134 m_data = game->Malloc( m_size );
135 float infinite = game->MaxFloat();
136 memcpy( m_data, &infinite, m_size );
137 }
138 else
139 {
140 m_size = LittleLong(*(int *) (*stream + *streamPos));
141 *streamPos += sizeof( int );
142 m_data = game->Malloc( m_size );
143 memcpy( m_data, (*stream + *streamPos), m_size );
144#ifdef Q3_BIG_ENDIAN
145 // only TK_INT, TK_VECTOR and TK_FLOAT has to be swapped, but just in case
146 if (m_size == 4 && m_id != CIcarus::TK_STRING && m_id != CIcarus::TK_IDENTIFIER && m_id != CIcarus::TK_CHAR)
147 *(int *)m_data = LittleLong(*(int *)m_data);
148#endif
149 }
150 *streamPos += m_size;
151
152 return true;
153}
154
155/*
156-------------------------

Callers 1

ReadBlockMethod · 0.45

Calls 3

MallocMethod · 0.80
MaxFloatMethod · 0.80
GetGameMethod · 0.45

Tested by

no test coverage detected