MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Init

Method Init

engine/Poseidon/Network/NetworkClient.cpp:171–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169 _soundId = 0; // incremented for each PlaySound
170
171 GetValue(_chatSound, Pars >> "CfgInGameUI" >> "Chat" >> "sound");
172
173 // ensure no content remain
174 Poseidon::DeleteDirectoryStructure("tmp", false);
175
176 _clientInfo = new ClientInfoObject();
177
178 _hideBodies = 0;
179}
180
181bool NetworkClient::Init(RString address, RString password, bool botClient)
182{
183 // load some settings from Flashpoint.cfg
184 ParamFile cfg;
185 cfg.Parse(FlashpointCfg);
186
187 _client = CreateNetClient(cfg);
188 if (!_client)
189 {
190 _connectResult = CRError;
191 return false;
192 }
193
194 _client->SetNetworkParams(cfg);
195
196 int connectPort = GetNetworkConnectPort();
197 if (connectPort <= 0)
198 {
199 connectPort = GetNetworkPort();
200 }
201 MPVersionInfo versionInfo;
202 versionInfo.versionActual = MP_VERSION_ACTUAL;
203 versionInfo.versionRequired = MP_VERSION_REQUIRED;
204 strncpy(versionInfo.mod, ModSystem::GetModNames(), MOD_LENGTH); // folder names, not local paths
205 versionInfo.mod[MOD_LENGTH - 1] = 0;
206 strncpy(versionInfo.versionTag, GetVersionTag(), VERSION_TAG_LENGTH);
207 versionInfo.versionTag[VERSION_TAG_LENGTH - 1] = 0;
208 _connectResult =
209 _client->Init(address, password, botClient, connectPort, Glob.header.playerName, versionInfo, MAGIC_APP);
210 if (_connectResult != CROK)
211 {
212 _client = nullptr;
213 return false;
214 }
215
216 if (ShouldInitializeClientVoice(botClient))
217 {
218 _client->InitVoice();
219 }

Callers 1

DoRespawnMethod · 0.45

Calls 8

CreateNetClientFunction · 0.85
GetNetworkConnectPortFunction · 0.85
GetNetworkPortFunction · 0.85
GetVersionTagFunction · 0.85
InitVoiceMethod · 0.80
ParseMethod · 0.45
SetNetworkParamsMethod · 0.45

Tested by

no test coverage detected