Merge pull request #780 from Sergeanur/VC/ObjectData

ObjectData
This commit is contained in:
erorcun 2020-10-24 17:55:40 +03:00 committed by GitHub
commit 0913abe616
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 5 deletions

View file

@ -23,7 +23,7 @@ enum Config {
MAXVEHICLESLOADED = 50, // 70 on mobile
NUMOBJECTINFO = 400, // TODO(MIAMI): fantasy // object.dat
NUMOBJECTINFO = 210,
// Pool sizes
NUMPTRNODES = 50000,

View file

@ -6,6 +6,8 @@
#include "FileMgr.h"
#include "ObjectData.h"
//--MIAMI: file done
CObjectInfo CObjectData::ms_aObjectInfo[NUMOBJECTINFO];
// Another ugly file reader
@ -18,11 +20,55 @@ CObjectData::Initialise(const char *filename)
float percentSubmerged;
int damageEffect, responseCase, camAvoid;
CBaseModelInfo *mi;
ms_aObjectInfo[0].m_fMass = 99999.0f;
ms_aObjectInfo[0].m_fTurnMass = 99999.0f;
ms_aObjectInfo[0].m_fAirResistance = 0.99f;
ms_aObjectInfo[0].m_fElasticity = 0.1f;
ms_aObjectInfo[0].m_fBuoyancy = GRAVITY * ms_aObjectInfo[0].m_fMass * 2.0f;
ms_aObjectInfo[0].m_fUprootLimit = 0.0f;
ms_aObjectInfo[0].m_fCollisionDamageMultiplier = 1.0f;
ms_aObjectInfo[0].m_nCollisionDamageEffect = 0;
ms_aObjectInfo[0].m_nSpecialCollisionResponseCases = 0;
ms_aObjectInfo[0].m_bCameraToAvoidThisObject = false;
ms_aObjectInfo[1].m_fMass = 99999.0f;
ms_aObjectInfo[1].m_fTurnMass = 99999.0f;
ms_aObjectInfo[1].m_fAirResistance = 0.99f;
ms_aObjectInfo[1].m_fElasticity = 0.1f;
ms_aObjectInfo[1].m_fBuoyancy = ms_aObjectInfo[0].m_fBuoyancy;
ms_aObjectInfo[1].m_fUprootLimit = 0.0f;
ms_aObjectInfo[1].m_fCollisionDamageMultiplier = 1.0f;
ms_aObjectInfo[1].m_nCollisionDamageEffect = 0;
ms_aObjectInfo[1].m_nSpecialCollisionResponseCases = 0;
ms_aObjectInfo[1].m_bCameraToAvoidThisObject = true;
ms_aObjectInfo[2].m_fMass = 99999.0f;
ms_aObjectInfo[2].m_fTurnMass = 99999.0f;
ms_aObjectInfo[2].m_fAirResistance = 0.99f;
ms_aObjectInfo[2].m_fElasticity = 0.1f;
ms_aObjectInfo[2].m_fBuoyancy = ms_aObjectInfo[0].m_fBuoyancy;
ms_aObjectInfo[2].m_fUprootLimit = 0.0f;
ms_aObjectInfo[2].m_fCollisionDamageMultiplier = 1.0f;
ms_aObjectInfo[2].m_nCollisionDamageEffect = 0;
ms_aObjectInfo[2].m_bCameraToAvoidThisObject = false;
ms_aObjectInfo[2].m_nSpecialCollisionResponseCases = 4;
ms_aObjectInfo[3].m_fMass = 99999.0f;
ms_aObjectInfo[3].m_fTurnMass = 99999.0f;
ms_aObjectInfo[3].m_fAirResistance = 0.99f;
ms_aObjectInfo[3].m_fElasticity = 0.1f;
ms_aObjectInfo[3].m_fBuoyancy = ms_aObjectInfo[0].m_fBuoyancy;
ms_aObjectInfo[3].m_fUprootLimit = 0.0f;
ms_aObjectInfo[3].m_fCollisionDamageMultiplier = 1.0f;
ms_aObjectInfo[3].m_nCollisionDamageEffect = 0;
ms_aObjectInfo[3].m_nSpecialCollisionResponseCases = 4;
ms_aObjectInfo[3].m_bCameraToAvoidThisObject = true;
CFileMgr::SetDir("");
CFileMgr::LoadFile(filename, work_buff, sizeof(work_buff), "r");
id = 0;
id = 4;
p = (char*)work_buff;
while(*p != '*'){
// skip over white space and comments
@ -44,7 +90,11 @@ CObjectData::Initialise(const char *filename)
}
if(*p == '\n')
p++;
#ifdef FIX_BUGS
*lp = '\0'; // FIX: game wrote '\n' here
#else
*lp = '\n';
#endif
assert(id < NUMOBJECTINFO);
sscanf(line, "%s %f %f %f %f %f %f %f %d %d %d", name,
@ -63,9 +113,23 @@ CObjectData::Initialise(const char *filename)
ms_aObjectInfo[id].m_bCameraToAvoidThisObject = camAvoid;
mi = CModelInfo::GetModelInfo(name, nil);
if(mi)
mi->SetObjectID(id++);
else
if (mi) {
if (ms_aObjectInfo[0].m_fMass != ms_aObjectInfo[id].m_fMass
|| ms_aObjectInfo[0].m_fCollisionDamageMultiplier != ms_aObjectInfo[id].m_fCollisionDamageMultiplier
|| ms_aObjectInfo[0].m_nCollisionDamageEffect != ms_aObjectInfo[id].m_nCollisionDamageEffect
|| ((ms_aObjectInfo[0].m_nSpecialCollisionResponseCases != ms_aObjectInfo[id].m_nSpecialCollisionResponseCases)
&& (ms_aObjectInfo[2].m_nSpecialCollisionResponseCases != ms_aObjectInfo[id].m_nSpecialCollisionResponseCases))) {
mi->SetObjectID(id++);
} else if (ms_aObjectInfo[0].m_nSpecialCollisionResponseCases == ms_aObjectInfo[id].m_nSpecialCollisionResponseCases) {
if (ms_aObjectInfo[0].m_bCameraToAvoidThisObject == ms_aObjectInfo[id].m_bCameraToAvoidThisObject)
mi->SetObjectID(0);
else
mi->SetObjectID(1);
} else if (ms_aObjectInfo[2].m_bCameraToAvoidThisObject == ms_aObjectInfo[id].m_bCameraToAvoidThisObject)
mi->SetObjectID(2);
else
mi->SetObjectID(3);
} else
debug("CObjectData: Cannot find object %s\n", name);
}
}
@ -92,6 +156,7 @@ CObjectData::SetObjectData(int32 modelId, CObject &object)
object.m_bCameraToAvoidThisObject = objinfo->m_bCameraToAvoidThisObject;
if(object.m_fMass >= 99998.0f){
object.bInfiniteMass = true;
object.m_phy_flagA08 = true;
object.bAffectedByGravity = false;
object.bExplosionProof = true;
}