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

Function G2API_CopyGhoul2Instance

code/rd-vanilla/G2_API.cpp:2011–2045  ·  view source on GitHub ↗

copy a model from one ghoul2 instance to another, and reset the root surface on the new model if need be NOTE if modelIndex = -1 then copy all the models

Source from the content-addressed store, hash-verified

2009// copy a model from one ghoul2 instance to another, and reset the root surface on the new model if need be
2010// NOTE if modelIndex = -1 then copy all the models
2011void G2API_CopyGhoul2Instance(CGhoul2Info_v &ghoul2From, CGhoul2Info_v &ghoul2To, int modelIndex)
2012{
2013 //Ensiform: I'm commenting this out because modelIndex appears unused and legitimately set in gamecode
2014 //assert(modelIndex==-1); // copy individual bolted parts is not used in jk2 and I didn't want to deal with it
2015 // if ya want it, we will add it back correctly
2016
2017 G2ERROR(ghoul2From.IsValid(),"Invalid ghlInfo");
2018 if (ghoul2From.IsValid())
2019 {
2020 ghoul2To.DeepCopy(ghoul2From);
2021#ifdef _G2_GORE //check through gore stuff then, as well.
2022 int model = 0;
2023
2024 //(since we are sharing this gore set with the copied instance we will have to increment
2025 //the reference count - if the goreset is "removed" while the refcount is > 0, the refcount
2026 //is decremented to avoid giving other instances an invalid pointer -rww)
2027 while (model < ghoul2To.size())
2028 {
2029 if ( ghoul2To[model].mGoreSetTag )
2030 {
2031 CGoreSet* gore = FindGoreSet ( ghoul2To[model].mGoreSetTag );
2032 assert(gore);
2033 if (gore)
2034 {
2035 gore->mRefCount++;
2036 }
2037 }
2038
2039 model++;
2040 }
2041#endif
2042 G2ANIM(ghoul2From,"G2API_CopyGhoul2Instance (source)");
2043 G2ANIM(ghoul2To,"G2API_CopyGhoul2Instance (dest)");
2044 }
2045}
2046
2047char *G2API_GetSurfaceName(CGhoul2Info *ghlInfo, int surfNumber)
2048{

Callers

nothing calls this directly

Calls 4

FindGoreSetFunction · 0.70
IsValidMethod · 0.45
DeepCopyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected