MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / LoadAnimation

Method LoadAnimation

CryAnimation/ControllerManager.cpp:132–192  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////// Loads the animation controllers into the existing animation record. May be used to load the animation the first time, or reload it upon request. Does nothing if there are already controls in the existing animation record.

Source from the content-addressed store, hash-verified

130// May be used to load the animation the first time, or reload it upon request.
131// Does nothing if there are already controls in the existing animation record.
132bool CControllerManager::LoadAnimation(int nAnimId)
133{
134 FUNCTION_PROFILER( g_GetISystem(),PROFILE_ANIMATION );
135
136 Animation& Anim = m_arrAnims[nAnimId];
137 if (Anim.IsLoaded())
138 return true;
139
140 if (Anim.nFlags & Animation::FLAGS_LOAD_PENDING)
141 {
142 // we already have this animation being loaded
143 return true;
144 }
145
146 unsigned nFileSize = g_GetStreamEngine()->GetFileSize(Anim.strFileName.c_str());
147
148 if (!nFileSize) // no such file
149 {
150 if (!(Anim.nFlags & GlobalAnimation::FLAGS_DISABLE_LOAD_ERROR_LOG))
151 g_GetLog()->LogError ("\003CControllerManager::LoadAnimation: file loading %s file not found", Anim.strFileName.c_str());
152 return false;
153 }
154
155 if (Anim.IsInfoLoaded())
156 { // we can start loading asynchronously
157 // this structure will keep the info until the completion routine is called
158 PendingAnimLoad_AutoPtr pAnimLoad = new PendingAnimLoad;
159 pAnimLoad->nAnimId = nAnimId;
160 pAnimLoad->pFile = new CFileMapping;
161 pAnimLoad->pFile->attach (malloc (nFileSize), nFileSize);
162 pAnimLoad->nFrameId = g_nFrameID;
163
164 // these parameters tell that the file must be read directly into the file mapping object
165 // the file mapping object will be passed to the chunk reader that will parse the data
166 StreamReadParams params;
167 params.dwUserData = (DWORD_PTR)(PendingAnimLoad*)pAnimLoad;
168 params.nSize = nFileSize;
169 params.pBuffer = pAnimLoad->pFile->getData();
170
171 // now we're prepared to read, register the pending operation and start reading
172 m_setPendingAnimLoads.insert (pAnimLoad);
173 // mark the animation as being loaded
174 Anim.nFlags |= Animation::FLAGS_LOAD_PENDING;
175 // we're not interested in the pointer to the read stream - we only need to know when it's finished
176 pAnimLoad->pStream = g_GetStreamEngine()->StartRead("Animation", Anim.strFileName.c_str(), this, &params);
177 return true;
178 }
179 else
180 {
181 // if the info hasn't still been loaded, we need to load synchronously
182 // try to read the file
183 CChunkFileReader Reader;
184 if (!Reader.open (Anim.strFileName))
185 {
186 if (!(Anim.nFlags & GlobalAnimation::FLAGS_DISABLE_LOAD_ERROR_LOG))
187 g_GetLog()->LogError ("\003CControllerManager::LoadAnimation: file loading %s, last error is: %s", Anim.strFileName.c_str(), Reader.getLastError());
188 return false;
189 }

Callers

nothing calls this directly

Calls 15

g_GetISystemFunction · 0.85
g_GetStreamEngineFunction · 0.85
g_GetLogFunction · 0.85
AnimCtrlSortPredClass · 0.70
sortFunction · 0.50
IsLoadedMethod · 0.45
GetFileSizeMethod · 0.45
c_strMethod · 0.45
LogErrorMethod · 0.45
IsInfoLoadedMethod · 0.45
attachMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected