1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
2 
3 #include "System/SafeVector.h"
4 
5 #ifdef USE_SAFE_VECTOR
6 #include "System/Log/ILog.h"
7 #include "System/Platform/CrashHandler.h"
8 #include "System/maindefines.h"
9 
10 CR_BIND_TEMPLATE(safe_vector<float>, )
11 
safe_element(size_type idx) const12 template <> const float& safe_vector<float>::safe_element(size_type idx) const {
13 	static const float def = 0.0f;
14 
15 	if (showError) {
16 		showError = false;
17 		LOG_L(L_ERROR, "[%s const] index " _STPF_ " out of bounds! (size " _STPF_ ")", __FUNCTION__, idx, size());
18 #ifndef UNITSYNC
19 		CrashHandler::OutputStacktrace();
20 #endif
21 	}
22 
23 	return def;
24 }
25 
safe_element(size_type idx)26 template <> float& safe_vector<float>::safe_element(size_type idx) {
27 	static float def = 0.0f;
28 
29 	if (showError) {
30 		showError = false;
31 		LOG_L(L_ERROR, "[%s] index " _STPF_ " out of bounds! (size " _STPF_ ")", __FUNCTION__, idx, size());
32 #ifndef UNITSYNC
33 		CrashHandler::OutputStacktrace();
34 #endif
35 	}
36 
37 	return def;
38 }
39 
40 #endif // USE_SAFE_VECTOR
41