diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2020-05-05 19:22:17 +0200 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2020-05-05 19:22:17 +0200 |
commit | f45ea0a1cf5ab2c46e53d3e352cb3a5b0ded1b80 (patch) | |
tree | dc15134e54afea71e397a16ab828a0a73edc0ea9 /src | |
parent | some more miami (diff) | |
parent | some miami limits (diff) | |
download | re3-f45ea0a1cf5ab2c46e53d3e352cb3a5b0ded1b80.tar re3-f45ea0a1cf5ab2c46e53d3e352cb3a5b0ded1b80.tar.gz re3-f45ea0a1cf5ab2c46e53d3e352cb3a5b0ded1b80.tar.bz2 re3-f45ea0a1cf5ab2c46e53d3e352cb3a5b0ded1b80.tar.lz re3-f45ea0a1cf5ab2c46e53d3e352cb3a5b0ded1b80.tar.xz re3-f45ea0a1cf5ab2c46e53d3e352cb3a5b0ded1b80.tar.zst re3-f45ea0a1cf5ab2c46e53d3e352cb3a5b0ded1b80.zip |
Diffstat (limited to 'src')
44 files changed, 109 insertions, 2021 deletions
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 39285296..6eac44df 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -698,7 +698,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) if (pVehicle->bExtendedRange) threshold *= 1.5f; if (distanceToPlayer > threshold && !CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){ - if (pVehicle->GetIsOnScreenAndNotCulled()){ + if (pVehicle->GetIsOnScreen()){ pVehicle->bFadeOut = true; }else{ CWorld::Remove(pVehicle); @@ -724,7 +724,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) if (pVehicle->GetStatus() != STATUS_WRECKED || pVehicle->m_nTimeOfDeath == 0) return; if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nTimeOfDeath + 60000 && - !pVehicle->GetIsOnScreenAndNotCulled()){ + !pVehicle->GetIsOnScreen()){ if ((pVehicle->GetPosition() - vecPlayerPos).MagnitudeSqr() > SQR(7.5f)){ if (!CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){ CWorld::Remove(pVehicle); @@ -1643,43 +1643,13 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t CPathNode* pTargetNode; int16 numNodes; float distanceToTargetNode; -#ifndef MIAMI - if (pTarget && pTarget->m_pCurGroundEntity && - pTarget->m_pCurGroundEntity->IsBuilding() && - ((CBuilding*)pTarget->m_pCurGroundEntity)->GetIsATreadable() && - ((CTreadable*)pTarget->m_pCurGroundEntity)->m_nodeIndices[0][0] >= 0){ - CTreadable* pCurrentMapObject = (CTreadable*)pTarget->m_pCurGroundEntity; - int closestNode = -1; - float minDist = 100000.0f; - for (int i = 0; i < 12; i++){ - int node = pCurrentMapObject->m_nodeIndices[0][i]; - if (node < 0) - break; - float dist = (ThePaths.m_pathNodes[node].GetPosition() - pTarget->GetPosition()).Magnitude(); - if (dist < minDist){ - minDist = dist; - closestNode = node; - } - } - ThePaths.DoPathSearch(0, pCurNode->GetPosition(), curNode, -#ifdef FIX_PATHFIND_BUG - CVector(targetX, targetY, targetZ), -#else - CVector(targetX, targetY, 0.0f), -#endif - &pTargetNode, &numNodes, 1, pVehicle, &distanceToTargetNode, 999999.9f, closestNode); - }else -#endif - { - - ThePaths.DoPathSearch(0, pCurNode->GetPosition(), curNode, + ThePaths.DoPathSearch(0, pCurNode->GetPosition(), curNode, #ifdef FIX_PATHFIND_BUG - CVector(targetX, targetY, targetZ), + CVector(targetX, targetY, targetZ), #else - CVector(targetX, targetY, 0.0f), + CVector(targetX, targetY, 0.0f), #endif - &pTargetNode, &numNodes, 1, pVehicle, &distanceToTargetNode, 999999.9f, -1); - } + &pTargetNode, &numNodes, 1, pVehicle, &distanceToTargetNode, 999999.9f, -1); int newNextNode; int nextLink; diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index b8203821..3337b3c9 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -18,37 +18,21 @@ CPathFind ThePaths; #define MIN_PED_ROUTE_DISTANCE 23.8f -#ifdef MIAMI #define NUMTEMPNODES 5000 #define NUMDETACHED_CARS 1024 #define NUMDETACHED_PEDS 1214 #define NUMTEMPEXTERNALNODES 4600 -#else -#define NUMTEMPNODES 4000 -#define NUMDETACHED_CARS 100 -#define NUMDETACHED_PEDS 50 -#endif -// object flags: -// 1 UseInRoadBlock -// 2 east/west road(?) - CPathInfoForObject *InfoForTileCars; CPathInfoForObject *InfoForTilePeds; -#ifndef MIAMI -// unused -CTempDetachedNode *DetachedNodesCars; -CTempDetachedNode *DetachedNodesPeds; -#else CPathInfoForObject *DetachedInfoForTileCars; CPathInfoForObject *DetachedInfoForTilePeds; CTempNodeExternal *TempExternalNodes; int32 NumTempExternalNodes; int32 NumDetachedPedNodeGroups; int32 NumDetachedCarNodeGroups; -#endif bool CPedPath::CalcPedRoute(int8 pathType, CVector position, CVector destination, CVector *pointPoses, int16 *pointsFound, int16 maxPoints) @@ -243,7 +227,7 @@ CPedPath::AddBlockade(CEntity *pEntity, CPedPathNode(*pathNodes)[40], CVector *p } } -#ifdef MIAMI +//--MIAMI: done // Make sure all externals link TO an internal void CPathInfoForObject::SwapConnectionsToBeRightWayRound(void) @@ -262,7 +246,6 @@ CPathInfoForObject::SwapConnectionsToBeRightWayRound(void) tile[i].crossing = tmp; } } -#endif //--MIAMI: done void @@ -275,9 +258,7 @@ CPathFind::Init(void) m_numConnections = 0; m_numCarPathLinks = 0; unk = 0; -#ifdef MIAMI NumTempExternalNodes = 0; -#endif for(i = 0; i < NUM_PATHNODES; i++) m_pathNodes[i].distance = MAX_DIST; @@ -292,23 +273,12 @@ CPathFind::AllocatePathFindInfoMem(int16 numPathGroups) delete[] InfoForTilePeds; InfoForTilePeds = nil; - // NB: MIAMI doesn't use numPathGroups here but hardcodes 4500 - InfoForTileCars = new CPathInfoForObject[12*numPathGroups]; - memset(InfoForTileCars, 0, 12*numPathGroups*sizeof(CPathInfoForObject)); - InfoForTilePeds = new CPathInfoForObject[12*numPathGroups]; - memset(InfoForTilePeds, 0, 12*numPathGroups*sizeof(CPathInfoForObject)); - -#ifndef MIAMI - // unused - delete[] DetachedNodesCars; - DetachedNodesCars = nil; - delete[] DetachedNodesPeds; - DetachedNodesPeds = nil; - DetachedNodesCars = new CTempDetachedNode[NUMDETACHED_CARS]; - memset(DetachedNodesCars, 0, NUMDETACHED_CARS*sizeof(CTempDetachedNode)); - DetachedNodesPeds = new CTempDetachedNode[NUMDETACHED_PEDS]; - memset(DetachedNodesPeds, 0, NUMDETACHED_PEDS*sizeof(CTempDetachedNode)); -#else + // NB: MIAMI doesn't use numPathGroups here but hardcodes PATHNODESIZE + InfoForTileCars = new CPathInfoForObject[12*PATHNODESIZE]; + memset(InfoForTileCars, 0, 12*PATHNODESIZE*sizeof(CPathInfoForObject)); + InfoForTilePeds = new CPathInfoForObject[12*PATHNODESIZE]; + memset(InfoForTilePeds, 0, 12*PATHNODESIZE*sizeof(CPathInfoForObject)); + delete[] DetachedInfoForTileCars; DetachedInfoForTileCars = nil; delete[] DetachedInfoForTilePeds; @@ -323,7 +293,6 @@ CPathFind::AllocatePathFindInfoMem(int16 numPathGroups) NumTempExternalNodes = 0; NumDetachedPedNodeGroups = 0; NumDetachedCarNodeGroups = 0; -#endif } //--MIAMI: done @@ -337,106 +306,53 @@ CPathFind::RegisterMapObject(CTreadable *mapObject) void CPathFind::StoreNodeInfoPed(int16 id, int16 node, int8 type, int8 next, int16 x, int16 y, int16 z, int16 width, bool crossing) { - int i, j; + int i; i = id*12 + node; InfoForTilePeds[i].type = type; InfoForTilePeds[i].next = next; -#ifndef MIAMI - InfoForTilePeds[i].x = x; - InfoForTilePeds[i].y = y; - InfoForTilePeds[i].z = z; -#else InfoForTilePeds[i].x = x/16.0f; InfoForTilePeds[i].y = y/16.0f; InfoForTilePeds[i].z = z/16.0f; -#endif InfoForTilePeds[i].numLeftLanes = 0; InfoForTilePeds[i].numRightLanes = 0; InfoForTilePeds[i].crossing = crossing; -#ifdef MIAMI InfoForTilePeds[i].flag02 = false; InfoForTilePeds[i].roadBlock = false; InfoForTilePeds[i].disabled = false; InfoForTilePeds[i].waterPath = false; InfoForTilePeds[i].betweenLevels = false; -#endif -#ifndef MIAMI - if(type) - for(i = 0; i < node; i++){ - j = id*12 + i; - if(x == InfoForTilePeds[j].x && y == InfoForTilePeds[j].y){ - printf("^^^^^^^^^^^^^ AARON IS TOO CHICKEN TO EAT MEAT!\n"); - printf("Several ped nodes on one road segment have identical coordinates (%d==%d && %d==%d)\n", - x, InfoForTilePeds[j].x, y, InfoForTilePeds[j].y); - printf("Modelindex of cullprit: %d\n\n", id); - } - } -#else if(node == 11) InfoForTilePeds[id*12].SwapConnectionsToBeRightWayRound(); -#endif } //--MIAMI: TODO: implement all the arguments once we can load the VC map void CPathFind::StoreNodeInfoCar(int16 id, int16 node, int8 type, int8 next, int16 x, int16 y, int16 z, int16 width, int8 numLeft, int8 numRight) { - int i, j; + int i; i = id*12 + node; InfoForTileCars[i].type = type; InfoForTileCars[i].next = next; -#ifndef MIAMI - InfoForTileCars[i].x = x; - InfoForTileCars[i].y = y; - InfoForTileCars[i].z = z; -#else InfoForTileCars[i].x = x/16.0f; InfoForTileCars[i].y = y/16.0f; InfoForTileCars[i].z = z/16.0f; -#endif InfoForTileCars[i].numLeftLanes = numLeft; InfoForTileCars[i].numRightLanes = numRight; -#ifdef MIAMI InfoForTileCars[i].crossing = false; InfoForTileCars[i].flag02 = false; InfoForTileCars[i].roadBlock = false; InfoForTileCars[i].disabled = false; InfoForTileCars[i].waterPath = false; InfoForTileCars[i].betweenLevels = false; -#endif - -#ifndef MIAMI - if(type) - for(i = 0; i < node; i++){ - j = id*12 + i; - if(x == InfoForTileCars[j].x && y == InfoForTileCars[j].y){ - printf("^^^^^^^^^^^^^ AARON IS TOO CHICKEN TO EAT MEAT!\n"); - printf("Several car nodes on one road segment have identical coordinates (%d==%d && %d==%d)\n", - x, InfoForTileCars[j].x, y, InfoForTileCars[j].y); - printf("Modelindex of cullprit: %d\n\n", id); - } - } -#else if(node == 11) InfoForTileCars[id*12].SwapConnectionsToBeRightWayRound(); -#endif } -#ifndef MIAMI -void -CPathFind::CalcNodeCoors(int16 x, int16 y, int16 z, int id, CVector *out) -{ - CVector pos; - pos.x = x / 16.0f; - pos.y = y / 16.0f; - pos.z = z / 16.0f; - *out = m_mapObjects[id]->GetMatrix() * pos; -} -#else +//--MIAMI: done void CPathFind::CalcNodeCoors(float x, float y, float z, int id, CVector *out) { @@ -446,7 +362,6 @@ CPathFind::CalcNodeCoors(float x, float y, float z, int id, CVector *out) pos.z = z; *out = m_mapObjects[id]->GetMatrix() * pos; } -#endif //--MIAMI: done bool @@ -460,29 +375,18 @@ CPathFind::LoadPathFindData(void) void CPathFind::PreparePathData(void) { - int i, j, k; - int numExtern, numIntern, numLanes; - float maxX, maxY; + int i, j; + int numExtern, numIntern; CTempNode *tempNodes; printf("PreparePathData\n"); if(!CPathFind::LoadPathFindData() && // empty InfoForTileCars && InfoForTilePeds && -#ifndef MIAMI - DetachedNodesCars && DetachedNodesPeds -#else - DetachedInfoForTileCars && DetachedInfoForTilePeds && TempExternalNodes -#endif - ){ + DetachedInfoForTileCars && DetachedInfoForTilePeds && TempExternalNodes){ tempNodes = new CTempNode[NUMTEMPNODES]; m_numConnections = 0; -#ifndef MIAMI - for(i = 0; i < PATHNODESIZE; i++) - m_pathNodes[i].unkBits = 0; -#endif - for(i = 0; i < PATHNODESIZE; i++){ numExtern = 0; numIntern = 0; @@ -496,7 +400,6 @@ CPathFind::PreparePathData(void) printf("ILLEGAL BLOCK. MORE THAN 1 INTERNALS AND NOT 2 EXTERNALS (Modelindex:%d)\n", i); } -#ifdef MIAMI int numExternDetached, numInternDetached; for(i = 0; i < NUMDETACHED_CARS; i++){ numExternDetached = 0; @@ -509,7 +412,6 @@ CPathFind::PreparePathData(void) } // no diagnostic here } -#endif for(i = 0; i < PATHNODESIZE; i++) for(j = 0; j < 12; j++) @@ -522,7 +424,6 @@ CPathFind::PreparePathData(void) if(InfoForTileCars[i*12 + j].numLeftLanes + InfoForTileCars[i*12 + j].numRightLanes <= 0) printf("ILLEGAL BLOCK. NO LANES IN NODE (Obj:%d)\n", i); } -#ifdef MIAMI for(i = 0; i < NUMDETACHED_CARS; i++) for(j = 0; j < 12; j++) if(DetachedInfoForTilePeds[i*12 + j].type == NodeTypeExtern){ @@ -534,61 +435,13 @@ CPathFind::PreparePathData(void) if(DetachedInfoForTilePeds[i*12 + j].numLeftLanes + DetachedInfoForTilePeds[i*12 + j].numRightLanes <= 0) printf("ILLEGAL BLOCK. NO LANES IN NODE (Obj:%d)\n", i); } -#endif m_numPathNodes = 0; -#ifndef MIAMI - PreparePathDataForType(PATH_CAR, tempNodes, InfoForTileCars, 1.0f, DetachedNodesCars, NUMDETACHED_CARS); - m_numCarPathNodes = m_numPathNodes; - PreparePathDataForType(PATH_PED, tempNodes, InfoForTilePeds, 1.0f, DetachedNodesPeds, NUMDETACHED_PEDS); -#else PreparePathDataForType(PATH_CAR, tempNodes, InfoForTileCars, 1.0f, DetachedInfoForTileCars, NumDetachedCarNodeGroups); m_numCarPathNodes = m_numPathNodes; PreparePathDataForType(PATH_PED, tempNodes, InfoForTilePeds, 1.0f, DetachedInfoForTilePeds, NumDetachedPedNodeGroups); -#endif m_numPedPathNodes = m_numPathNodes - m_numCarPathNodes; -#ifndef MIAMI - // TODO: figure out what exactly is going on here - // Some roads seem to get a west/east flag - for(i = 0; i < m_numMapObjects; i++){ - numExtern = 0; - numIntern = 0; - numLanes = 0; - maxX = 0.0f; - maxY = 0.0f; - for(j = 0; j < 12; j++){ - k = i*12 + j; - if(InfoForTileCars[k].type == NodeTypeExtern){ - numExtern++; - if(InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes > numLanes) - numLanes = InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes; - maxX = Max(maxX, Abs(InfoForTileCars[k].x)); - maxY = Max(maxY, Abs(InfoForTileCars[k].y)); - }else if(InfoForTileCars[k].type == NodeTypeIntern) - numIntern++; - } - - if(numIntern == 1 && numExtern == 2){ - if(numLanes < 4){ - if((i & 7) == 4){ // WHAT? - m_objectFlags[i] |= UseInRoadBlock; - if(maxX > maxY) - m_objectFlags[i] |= ObjectEastWest; - else - m_objectFlags[i] &= ~ObjectEastWest; - } - }else{ - m_objectFlags[i] |= UseInRoadBlock; - if(maxX > maxY) - m_objectFlags[i] |= ObjectEastWest; - else - m_objectFlags[i] &= ~ObjectEastWest; - } - } - } -#endif - delete[] tempNodes; CountFloodFillGroups(PATH_CAR); @@ -599,19 +452,12 @@ CPathFind::PreparePathData(void) delete[] InfoForTilePeds; InfoForTilePeds = nil; -#ifndef MIAMI - delete[] DetachedNodesCars; - DetachedNodesCars = nil; - delete[] DetachedNodesPeds; - DetachedNodesPeds = nil; -#else delete[] DetachedInfoForTileCars; DetachedInfoForTileCars = nil; delete[] DetachedInfoForTilePeds; DetachedInfoForTilePeds = nil; delete[] TempExternalNodes; TempExternalNodes = nil; -#endif } printf("Done with PreparePathData\n"); } @@ -659,13 +505,8 @@ CPathFind::CountFloodFillGroups(uint8 type) if(node->numLinks == 0){ if(type == PATH_CAR) -#ifndef MIAMI - printf("Single car node: %f %f %f (%d)\n", - node->GetX(), node->GetY(), node->GetZ(), m_mapObjects[node->objectIndex]->GetModelIndex()); -#else printf("Single car node: %f %f %f\n", node->GetX(), node->GetY(), node->GetZ()); -#endif else printf("Single ped node: %f %f %f\n", node->GetX(), node->GetY(), node->GetZ()); @@ -696,42 +537,28 @@ int32 TempListLength; //--MIAMI: done void CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoForObject *objectpathinfo, -#ifndef MIAMI - float maxdist, CTempDetachedNode *detachednodes, int numDetached) -#else float maxdist, CPathInfoForObject *detachednodes, int numDetached) -#endif { static CVector CoorsXFormed; - int i, j, k, l; + int i, j, k; int l1, l2; int start; float posx, posy; float dx, dy, mag; float nearestDist; int nearestId; - int next; int oldNumPathNodes, oldNumLinks; float dist; int iseg, jseg; - int istart, jstart; int done, cont; int tileStart; oldNumPathNodes = m_numPathNodes; oldNumLinks = m_numConnections; -#ifndef MIAMI -#define OBJECTINDEX(n) (m_pathNodes[(n)].objectIndex) - // Initialize map objects - for(i = 0; i < m_numMapObjects; i++) - for(j = 0; j < 12; j++) - m_mapObjects[i]->m_nodeIndices[type][j] = -1; -#else #define OBJECTINDEX(n) (mapObjIndices[(n)]) int16 *mapObjIndices = new int16[NUM_PATHNODES]; NumTempExternalNodes = 0; -#endif // Calculate internal nodes, store them and connect them to defining object for(i = 0; i < m_numMapObjects; i++){ @@ -747,10 +574,6 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor &CoorsXFormed); m_pathNodes[m_numPathNodes].SetPosition(CoorsXFormed); OBJECTINDEX(m_numPathNodes) = i; -#ifndef MIAMI - m_pathNodes[m_numPathNodes].unkBits = 1; - m_mapObjects[i]->m_nodeIndices[type][j] = m_numPathNodes; -#else m_pathNodes[m_numPathNodes].width = objectpathinfo[start + j].width; m_pathNodes[m_numPathNodes].speedLimit = objectpathinfo[start + j].speedLimit; m_pathNodes[m_numPathNodes].spawnRate = objectpathinfo[start + j].spawnRate; @@ -759,10 +582,8 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor m_pathNodes[m_numPathNodes].bWaterPath = objectpathinfo[start + j].waterPath; m_pathNodes[m_numPathNodes].flagB2 = objectpathinfo[start + j].flag02; m_pathNodes[m_numPathNodes].bBetweenLevels = objectpathinfo[start + j].betweenLevels; -#endif m_numPathNodes++; } -#ifdef MIAMI else if(objectpathinfo[start + j].type == NodeTypeExtern){ CalcNodeCoors( objectpathinfo[start + j].x, @@ -779,11 +600,9 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor TempExternalNodes[NumTempExternalNodes].isCross = !!objectpathinfo[start + j].crossing; NumTempExternalNodes++; } -#endif } } -#ifdef MIAMI // Same thing for detached nodes for(i = 0; i < numDetached; i++){ tileStart = m_numPathNodes; @@ -819,87 +638,9 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor } } } -#endif // Insert external nodes into TempList TempListLength = 0; -#ifndef MIAMI - for(i = 0; i < m_numMapObjects; i++){ - start = 12 * m_mapObjects[i]->GetModelIndex(); - for(j = 0; j < 12; j++){ - if(objectpathinfo[start + j].type != NodeTypeExtern) - continue; - CalcNodeCoors( - objectpathinfo[start + j].x, - objectpathinfo[start + j].y, - objectpathinfo[start + j].z, - i, - &CoorsXFormed); - - // find closest unconnected node - nearestId = -1; - nearestDist = maxdist; - for(k = 0; k < TempListLength; k++){ - if(tempnodes[k].linkState != 1) - continue; - dx = tempnodes[k].pos.x - CoorsXFormed.x; - if(Abs(dx) < nearestDist){ - dy = tempnodes[k].pos.y - CoorsXFormed.y; - if(Abs(dy) < nearestDist){ - nearestDist = Max(Abs(dx), Abs(dy)); - nearestId = k; - } - } - } - - if(nearestId < 0){ - // None found, add this one to temp list - tempnodes[TempListLength].pos = CoorsXFormed; - next = objectpathinfo[start + j].next; - if(next < 0){ - // no link from this node, find link to this node - next = 0; - for(k = start; j != objectpathinfo[k].next; k++) - next++; - } - // link to connecting internal node - tempnodes[TempListLength].link1 = m_mapObjects[i]->m_nodeIndices[type][next]; - if(type == PATH_CAR){ - tempnodes[TempListLength].numLeftLanes = objectpathinfo[start + j].numLeftLanes; - tempnodes[TempListLength].numRightLanes = objectpathinfo[start + j].numRightLanes; - } - tempnodes[TempListLength++].linkState = 1; - }else{ - // Found nearest, connect it to our neighbour - next = objectpathinfo[start + j].next; - if(next < 0){ - // no link from this node, find link to this node - next = 0; - for(k = start; j != objectpathinfo[k].next; k++) - next++; - } - tempnodes[nearestId].link2 = m_mapObjects[i]->m_nodeIndices[type][next]; - tempnodes[nearestId].linkState = 2; - - // collapse this node with nearest we found - dx = m_pathNodes[tempnodes[nearestId].link1].GetX() - m_pathNodes[tempnodes[nearestId].link2].GetX(); - dy = m_pathNodes[tempnodes[nearestId].link1].GetY() - m_pathNodes[tempnodes[nearestId].link2].GetY(); - tempnodes[nearestId].pos = (tempnodes[nearestId].pos + CoorsXFormed)*0.5f; - mag = Sqrt(dx*dx + dy*dy); - tempnodes[nearestId].dirX = dx/mag; - tempnodes[nearestId].dirY = dy/mag; - // do something when number of lanes doesn't agree - if(type == PATH_CAR) - if(tempnodes[nearestId].numLeftLanes != 0 && tempnodes[nearestId].numRightLanes != 0 && - (objectpathinfo[start + j].numLeftLanes == 0 || objectpathinfo[start + j].numRightLanes == 0)){ - // why switch left and right here? - tempnodes[nearestId].numLeftLanes = objectpathinfo[start + j].numRightLanes; - tempnodes[nearestId].numRightLanes = objectpathinfo[start + j].numLeftLanes; - } - } - } - } -#else for(i = 0; i < NumTempExternalNodes; i++){ // find closest unconnected node nearestId = -1; @@ -954,7 +695,6 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor } } } -#endif // Loop through previously added internal nodes and link them for(i = oldNumPathNodes; i < m_numPathNodes; i++){ @@ -977,49 +717,30 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor continue; dist = (m_pathNodes[i].GetPosition() - m_pathNodes[ConnectedNode(m_numConnections)].GetPosition()).Magnitude(); -#ifndef MIAMI - m_distances[m_numConnections] = dist; - m_connectionFlags[m_numConnections].flags = 0; -#else m_distances[m_numConnections] = Min(dist, 255); if(tempnodes[j].isCross) m_connections[j] |= 0x8000; // crosses road flag -#endif if(type == PATH_CAR){ // IMPROVE: use a goto here // Find existing car path link for(k = 0; k < m_numCarPathLinks; k++){ -#ifndef MIAMI - if(m_carPathLinks[k].dir.x == tempnodes[j].dirX && - m_carPathLinks[k].dir.y == tempnodes[j].dirY && - m_carPathLinks[k].pos.x == tempnodes[j].pos.x && - m_carPathLinks[k].pos.y == tempnodes[j].pos.y){ -#else if(m_carPathLinks[k].dirX == tempnodes[j].dirX && m_carPathLinks[k].dirY == tempnodes[j].dirY && m_carPathLinks[k].x == (int)(tempnodes[j].pos.x*8.0f) && m_carPathLinks[k].y == (int)(tempnodes[j].pos.y*8.0f)){ -#endif m_carPathConnections[m_numConnections] = k; k = m_numCarPathLinks; } } // k is m_numCarPathLinks+1 if we found one if(k == m_numCarPathLinks){ -#ifndef MIAMI - m_carPathLinks[m_numCarPathLinks].dir.x = tempnodes[j].dirX; - m_carPathLinks[m_numCarPathLinks].dir.y = tempnodes[j].dirY; - m_carPathLinks[m_numCarPathLinks].pos.x = tempnodes[j].pos.x; - m_carPathLinks[m_numCarPathLinks].pos.y = tempnodes[j].pos.y; -#else m_carPathLinks[m_numCarPathLinks].dirX = tempnodes[j].dirX; m_carPathLinks[m_numCarPathLinks].dirY = tempnodes[j].dirY; m_carPathLinks[m_numCarPathLinks].x = tempnodes[j].pos.x*8.0f; m_carPathLinks[m_numCarPathLinks].y = tempnodes[j].pos.y*8.0f; m_carPathLinks[m_numCarPathLinks].flag1 = false; m_carPathLinks[m_numCarPathLinks].width = tempnodes[j].width; -#endif m_carPathLinks[m_numCarPathLinks].pathNodeIndex = i; m_carPathLinks[m_numCarPathLinks].numLeftLanes = tempnodes[j].numLeftLanes; m_carPathLinks[m_numCarPathLinks].numRightLanes = tempnodes[j].numRightLanes; @@ -1033,7 +754,6 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor m_numConnections++; } -#ifdef MIAMI CPathInfoForObject *tile; if(mapObjIndices[i] < 0){ if(type == PATH_CAR) @@ -1046,7 +766,6 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor else tile = &InfoForTilePeds[12 * m_mapObjects[mapObjIndices[i]]->GetModelIndex()]; } -#endif // Find i inside path segment iseg = 0; @@ -1054,9 +773,6 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor if(OBJECTINDEX(j) == OBJECTINDEX(i)) iseg++; -#ifndef MIAMI - istart = 12 * m_mapObjects[m_pathNodes[i].objectIndex]->GetModelIndex(); -#endif // Add links to other internal nodes for(j = Max(oldNumPathNodes, i-12); j < Min(m_numPathNodes, i+12); j++){ if(OBJECTINDEX(i) != OBJECTINDEX(j) || i == j) @@ -1064,23 +780,13 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor // N.B.: in every path segment, the externals have to be at the end jseg = j-i + iseg; -#ifndef MIAMI - jstart = 12 * m_mapObjects[m_pathNodes[j].objectIndex]->GetModelIndex(); - if(objectpathinfo[istart + iseg].next == jseg || - objectpathinfo[jstart + jseg].next == iseg){ -#else if(tile[iseg].next == jseg || tile[jseg].next == iseg){ -#endif // Found a link between i and jConnectionSetCrossesRoad // NB this clears the flags in MIAMI m_connections[m_numConnections] = j; dist = (m_pathNodes[i].GetPosition() - m_pathNodes[j].GetPosition()).Magnitude(); -#ifndef MIAMI - m_distances[m_numConnections] = dist; -#else m_distances[m_numConnections] = Min(dist, 255); -#endif if(type == PATH_CAR){ posx = (m_pathNodes[i].GetX() + m_pathNodes[j].GetX())*0.5f; @@ -1090,9 +796,7 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor mag = Sqrt(dx*dx + dy*dy); dx /= mag; dy /= mag; -#ifdef MIAMI int width = Max(m_pathNodes[i].width, m_pathNodes[j].width); -#endif if(i < j){ dx = -dx; dy = -dy; @@ -1100,36 +804,22 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor // IMPROVE: use a goto here // Find existing car path link for(k = 0; k < m_numCarPathLinks; k++){ -#ifndef MIAMI - if(m_carPathLinks[k].dir.x == dx && - m_carPathLinks[k].dir.y == dy && - m_carPathLinks[k].pos.x == posx && - m_carPathLinks[k].pos.y == posy){ -#else if(m_carPathLinks[k].dirX == (int)(dx*100.0f) && m_carPathLinks[k].dirY == (int)(dy*100.0f) && m_carPathLinks[k].x == (int)(posx*8.0f) && m_carPathLinks[k].y == (int)(posy*8.0f)){ -#endif m_carPathConnections[m_numConnections] = k; k = m_numCarPathLinks; } } // k is m_numCarPathLinks+1 if we found one if(k == m_numCarPathLinks){ -#ifndef MIAMI - m_carPathLinks[m_numCarPathLinks].dir.x = dx; - m_carPathLinks[m_numCarPathLinks].dir.y = dy; - m_carPathLinks[m_numCarPathLinks].pos.x = posx; - m_carPathLinks[m_numCarPathLinks].pos.y = posy; -#else m_carPathLinks[m_numCarPathLinks].dirX = dx*100.0f; m_carPathLinks[m_numCarPathLinks].dirY = dy*100.0f; m_carPathLinks[m_numCarPathLinks].x = posx*8.0f; m_carPathLinks[m_numCarPathLinks].y = posy*8.0f; m_carPathLinks[m_numCarPathLinks].flag1 = false; m_carPathLinks[m_numCarPathLinks].width = width; -#endif m_carPathLinks[m_numCarPathLinks].pathNodeIndex = i; m_carPathLinks[m_numCarPathLinks].numLeftLanes = -1; m_carPathLinks[m_numCarPathLinks].numRightLanes = -1; @@ -1139,17 +829,9 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor } }else{ // Crosses road -#ifndef MIAMI - if(objectpathinfo[istart + iseg].next == jseg && objectpathinfo[istart + iseg].crossing || - objectpathinfo[jstart + jseg].next == iseg && objectpathinfo[jstart + jseg].crossing) - m_connectionFlags[m_numConnections].bCrossesRoad = true; - else - m_connectionFlags[m_numConnections].bCrossesRoad = false; -#else if(tile[iseg].next == jseg && tile[iseg].crossing || tile[jseg].next == iseg && tile[jseg].crossing) m_connections[m_numConnections] |= 0x8000; // crosses road flag -#endif } m_pathNodes[i].numLinks++; @@ -1162,11 +844,7 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor done = 0; // Set number of lanes for all nodes somehow // very strange code -#ifndef MIAMI - for(k = 0; !done && k < 10; k++){ -#else for(k = 0; !done && k < 12; k++){ -#endif done = 1; for(i = 0; i < m_numPathNodes; i++){ if(m_pathNodes[i].numLinks != 2) @@ -1174,35 +852,6 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor l1 = m_carPathConnections[m_pathNodes[i].firstLink]; l2 = m_carPathConnections[m_pathNodes[i].firstLink+1]; -#ifndef MIAMI - if(m_carPathLinks[l1].numLeftLanes == -1 && - m_carPathLinks[l2].numLeftLanes != -1){ - done = 0; - if(m_carPathLinks[l2].pathNodeIndex == i){ - // why switch left and right here? - m_carPathLinks[l1].numLeftLanes = m_carPathLinks[l2].numRightLanes; - m_carPathLinks[l1].numRightLanes = m_carPathLinks[l2].numLeftLanes; - }else{ - m_carPathLinks[l1].numLeftLanes = m_carPathLinks[l2].numLeftLanes; - m_carPathLinks[l1].numRightLanes = m_carPathLinks[l2].numRightLanes; - } - m_carPathLinks[l1].pathNodeIndex = i; - }else if(m_carPathLinks[l1].numLeftLanes != -1 && - m_carPathLinks[l2].numLeftLanes == -1){ - done = 0; - if(m_carPathLinks[l1].pathNodeIndex == i){ - // why switch left and right here? - m_carPathLinks[l2].numLeftLanes = m_carPathLinks[l1].numRightLanes; - m_carPathLinks[l2].numRightLanes = m_carPathLinks[l1].numLeftLanes; - }else{ - m_carPathLinks[l2].numLeftLanes = m_carPathLinks[l1].numLeftLanes; - m_carPathLinks[l2].numRightLanes = m_carPathLinks[l1].numRightLanes; - } - m_carPathLinks[l2].pathNodeIndex = i; - }else if(m_carPathLinks[l1].numLeftLanes == -1 && - m_carPathLinks[l2].numLeftLanes == -1) - done = 0; -#else int8 l1Left = m_carPathLinks[l1].numLeftLanes; int8 l1Right = m_carPathLinks[l1].numRightLanes; int8 l2Left = m_carPathLinks[l2].numLeftLanes; @@ -1247,7 +896,6 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor m_carPathLinks[l1].numRightLanes = l1Right; m_carPathLinks[l2].numLeftLanes = l2Left; m_carPathLinks[l2].numRightLanes = l2Right; -#endif } } @@ -1255,17 +903,10 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor for(i = 0; i < m_numPathNodes; i++) for(j = 0; j < m_pathNodes[i].numLinks; j++){ k = m_carPathConnections[m_pathNodes[i].firstLink + j]; -#ifndef MIAMI - if(m_carPathLinks[k].numLeftLanes < 0) - m_carPathLinks[k].numLeftLanes = 1; - if(m_carPathLinks[k].numRightLanes < 0) - m_carPathLinks[k].numRightLanes = 1; -#else if(m_carPathLinks[k].numLeftLanes == -1) m_carPathLinks[k].numLeftLanes = 0; if(m_carPathLinks[k].numRightLanes == -1) m_carPathLinks[k].numRightLanes = 0; -#endif } } @@ -1274,10 +915,6 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor do{ cont = 0; for(i = 0; i < m_numPathNodes; i++){ -#ifndef MIAMI - m_pathNodes[i].bDisabled = false; - m_pathNodes[i].bBetweenLevels = false; -#endif // See if node is a dead end, if so, we're not done yet if(!m_pathNodes[i].bDeadEnd){ k = 0; @@ -1310,26 +947,11 @@ CPathFind::PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoFor m_connections[j] = node-1; } -#ifndef MIAMI - // Also in treadables - for(j = 0; j < m_numMapObjects; j++) - for(k = 0; k < 12; k++){ - if(m_mapObjects[j]->m_nodeIndices[PATH_PED][k] == i){ - // remove this one - for(l = k; l < 12-1; l++) - m_mapObjects[j]->m_nodeIndices[PATH_PED][l] = m_mapObjects[j]->m_nodeIndices[PATH_PED][l+1]; - m_mapObjects[j]->m_nodeIndices[PATH_PED][11] = -1; - }else if(m_mapObjects[j]->m_nodeIndices[PATH_PED][k] > i) - m_mapObjects[j]->m_nodeIndices[PATH_PED][k]--; - } -#endif - i--; m_numPathNodes--; } -#ifdef MIAMI + delete[] mapObjIndices; -#endif } //--MIAMI: done @@ -1349,17 +971,6 @@ CPathFind::CalcRoadDensity(float x, float y) next = m_carPathConnections[m_pathNodes[i].firstLink + j]; density += m_carPathLinks[next].numLeftLanes * dist; density += m_carPathLinks[next].numRightLanes * dist; - -#ifndef MIAMI - if(m_carPathLinks[next].numLeftLanes < 0) - printf("Link from object %d to %d (MIs)\n", - m_mapObjects[m_pathNodes[i].objectIndex]->GetModelIndex(), - m_mapObjects[m_pathNodes[ConnectedNode(m_pathNodes[i].firstLink + j)].objectIndex]->GetModelIndex()); - if(m_carPathLinks[next].numRightLanes < 0) - printf("Link from object %d to %d (MIs)\n", - m_mapObjects[m_pathNodes[i].objectIndex]->GetModelIndex(), - m_mapObjects[m_pathNodes[ConnectedNode(m_pathNodes[i].firstLink + j)].objectIndex]->GetModelIndex()); -#endif } } } @@ -1585,13 +1196,8 @@ CPathFind::PedMarkRoadsBetweenLevelsInArea(float x1, float x2, float y1, float y } //--MIAMI: done -#ifndef MIAMI -int32 -CPathFind::FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool ignoreDisabled, bool ignoreBetweenLevels) -#else int32 CPathFind::FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool ignoreDisabled, bool ignoreBetweenLevels, bool ignoreFlagB4, bool bWaterPath) -#endif { int i; int firstNode, lastNode; @@ -1613,25 +1219,15 @@ CPathFind::FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bo for(i = firstNode; i < lastNode; i++){ if(ignoreDisabled && m_pathNodes[i].bDisabled) continue; if(ignoreBetweenLevels && m_pathNodes[i].bBetweenLevels) continue; -#ifndef MIAMI - switch(m_pathNodes[i].unkBits){ - case 1: - case 2: -#else if(ignoreFlagB4 && m_pathNodes[i].flagB4) continue; if(bWaterPath != m_pathNodes[i].bWaterPath) continue; -#endif - dist = Abs(m_pathNodes[i].GetX() - coors.x) + - Abs(m_pathNodes[i].GetY() - coors.y) + - 3.0f*Abs(m_pathNodes[i].GetZ() - coors.z); - if(dist < closestDist){ - closestDist = dist; - closestNode = i; - } -#ifndef MIAMI - break; + dist = Abs(m_pathNodes[i].GetX() - coors.x) + + Abs(m_pathNodes[i].GetY() - coors.y) + + 3.0f*Abs(m_pathNodes[i].GetZ() - coors.z); + if(dist < closestDist){ + closestDist = dist; + closestNode = i; } -#endif } return closestDist < distLimit ? closestNode : -1; } @@ -1659,27 +1255,18 @@ CPathFind::FindNodeClosestToCoorsFavourDirection(CVector coors, uint8 type, floa } for(i = firstNode; i < lastNode; i++){ -#ifndef MIAMI - switch(m_pathNodes[i].unkBits){ - case 1: - case 2: -#endif - dX = m_pathNodes[i].GetX() - coors.x; - dY = m_pathNodes[i].GetY() - coors.y; - dist = Abs(dX) + Abs(dY) + - 3.0f*Abs(m_pathNodes[i].GetZ() - coors.z); + dX = m_pathNodes[i].GetX() - coors.x; + dY = m_pathNodes[i].GetY() - coors.y; + dist = Abs(dX) + Abs(dY) + + 3.0f*Abs(m_pathNodes[i].GetZ() - coors.z); + if(dist < closestDist){ + NormalizeXY(dX, dY); + dist -= (dX*dirX + dY*dirY - 1.0f)*20.0f; if(dist < closestDist){ - NormalizeXY(dX, dY); - dist -= (dX*dirX + dY*dirY - 1.0f)*20.0f; - if(dist < closestDist){ - closestDist = dist; - closestNode = i; - } + closestDist = dist; + closestNode = i; } -#ifndef MIAMI - break; } -#endif } return closestNode; } @@ -1856,44 +1443,6 @@ CPathFind::GeneratePedCreationCoors(float x, float y, float minDist, float maxDi return false; } -#ifndef MIAMI -CTreadable* -CPathFind::FindRoadObjectClosestToCoors(CVector coors, uint8 type) -{ - int i, j, k; - int node1, node2; - CTreadable *closestMapObj = nil; - float closestDist = 10000.0f; - - for(i = 0; i < m_numMapObjects; i++){ - CTreadable *mapObj = m_mapObjects[i]; - if(mapObj->m_nodeIndices[type][0] < 0) - continue; - CVector vDist = mapObj->GetPosition() - coors; - float fDist = Abs(vDist.x) + Abs(vDist.y) + Abs(vDist.z); - if(fDist < 200.0f || fDist < closestDist) - for(j = 0; j < 12; j++){ - node1 = mapObj->m_nodeIndices[type][j]; - if(node1 < 0) - break; - // FIX: game uses ThePaths here explicitly - for(k = 0; k < m_pathNodes[node1].numLinks; k++){ - node2 = ConnectedNode(m_pathNodes[node1].firstLink + k); - float lineDist = CCollision::DistToLine(&m_pathNodes[node1].GetPosition(), &m_pathNodes[node2].GetPosition(), &coors); - if(lineDist < closestDist){ - closestDist = lineDist; - if((coors - m_pathNodes[node1].GetPosition()).MagnitudeSqr() < (coors - m_pathNodes[node2].GetPosition()).MagnitudeSqr()) - closestMapObj = m_mapObjects[m_pathNodes[node1].objectIndex]; - else - closestMapObj = m_mapObjects[m_pathNodes[node2].objectIndex]; - } - } - } - } - return closestMapObj; -} -#endif - //--MIAMI: done void CPathFind::FindNextNodeWandering(uint8 type, CVector coors, CPathNode **lastNode, CPathNode **nextNode, uint8 curDir, uint8 *nextDir) @@ -1902,24 +1451,8 @@ CPathFind::FindNextNodeWandering(uint8 type, CVector coors, CPathNode **lastNode CPathNode *node; if(lastNode == nil || (node = *lastNode) == nil || (coors - (*lastNode)->GetPosition()).MagnitudeSqr() > 7.0f){ -#ifndef MIAMI - // need to find the node we're coming from - node = nil; - CTreadable *obj = FindRoadObjectClosestToCoors(coors, type); - float nodeDist = 1000000000.0f; - for(i = 0; i < 12; i++){ - if(obj->m_nodeIndices[type][i] < 0) - break; - float dist = (coors - m_pathNodes[obj->m_nodeIndices[type][i]].GetPosition()).MagnitudeSqr(); - if(dist < nodeDist){ - nodeDist = dist; - node = &m_pathNodes[obj->m_nodeIndices[type][i]]; - } - } -#else int32 nodeIdx = FindNodeClosestToCoors(coors, type, 999999.88f); node = &m_pathNodes[nodeIdx]; -#endif } CVector2D vCurDir(Sin(curDir*PI/4.0f), Cos(curDir * PI / 4.0f)); @@ -1975,11 +1508,7 @@ CPathFind::FindNextNodeWandering(uint8 type, CVector coors, CPathNode **lastNode } } -#ifndef MIAMI -static CPathNode *apNodesToBeCleared[4995]; -#else static CPathNode *apNodesToBeCleared[6525]; -#endif //--MIAMI: done void @@ -1997,45 +1526,6 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta } // Find start -#ifndef MIAMI - int numPathsToTry; - CTreadable *startObj; - if(startNodeId < 0){ - if(vehicle == nil || (startObj = vehicle->m_treadable[type]) == nil) - startObj = FindRoadObjectClosestToCoors(start, type); - numPathsToTry = 0; - for(i = 0; i < 12; i++){ - if(startObj->m_nodeIndices[type][i] < 0) - break; - if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == m_pathNodes[targetNodeId].group) - numPathsToTry++; - } - }else{ - numPathsToTry = 1; - startObj = m_mapObjects[m_pathNodes[startNodeId].objectIndex]; - } - if(numPathsToTry == 0) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } - - if(startNodeId < 0){ - // why only check node 0? - if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != - m_pathNodes[targetNodeId].group) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } - }else{ - if(m_pathNodes[startNodeId].group != m_pathNodes[targetNodeId].group) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } - } -#else if(startNodeId < 0) startNodeId = FindNodeClosestToCoors(start, type, 999999.88f); if(startNodeId < 0) { @@ -2053,7 +1543,6 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta if(pDist) *pDist = 100000.0f; return; } -#endif for(i = 0; i < ARRAY_SIZE(m_searchNodes); i++) m_searchNodes[i].SetNext(nil); @@ -2064,23 +1553,11 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta // Dijkstra's algorithm // Find distances int numPathsFound = 0; -#ifndef MIAMI - if(startNodeId < 0 && m_mapObjects[m_pathNodes[targetNodeId].objectIndex] == startObj) - numPathsFound++; - for(i = 0; numPathsFound < numPathsToTry; i = (i+1) & 0x1FF){ -#else for(i = 0; numPathsFound == 0; i = (i+1) & 0x1FF){ -#endif CPathNode *node; for(node = m_searchNodes[i].GetNext(); node; node = node->GetNext()){ -#ifndef MIAMI - if(m_mapObjects[node->objectIndex] == startObj && - (startNodeId < 0 || node == &m_pathNodes[startNodeId])) - numPathsFound++; -#else if(node == &m_pathNodes[startNodeId]) numPathsFound = 1; -#endif for(j = 0; j < node->numLinks; j++){ int next = ConnectedNode(node->firstLink + j); @@ -2100,39 +1577,12 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta // Find out whence to start tracing back CPathNode *curNode; -#ifndef MIAMI - if(startNodeId < 0){ - int minDist = MAX_DIST; - *pNumNodes = 1; - for(i = 0; i < 12; i++){ - if(startObj->m_nodeIndices[type][i] < 0) - break; - int dist = (m_pathNodes[startObj->m_nodeIndices[type][i]].GetPosition() - start).Magnitude(); - if(m_pathNodes[startObj->m_nodeIndices[type][i]].distance + dist < minDist){ - minDist = m_pathNodes[startObj->m_nodeIndices[type][i]].distance + dist; - curNode = &m_pathNodes[startObj->m_nodeIndices[type][i]]; - } - } - if(maxNumNodes == 0){ - *pNumNodes = 0; - }else{ - nodes[0] = curNode; - *pNumNodes = 1; - } - if(pDist) - *pDist = minDist; - }else -#endif - { - curNode = &m_pathNodes[startNodeId]; - *pNumNodes = 0; - if(pDist) - *pDist = m_pathNodes[startNodeId].distance; - } + curNode = &m_pathNodes[startNodeId]; + *pNumNodes = 0; + if(pDist) + *pDist = m_pathNodes[startNodeId].distance; -#ifdef MIAMI nodes[(*pNumNodes)++] = curNode; -#endif // Trace back to target and update list of nodes while(*pNumNodes < maxNumNodes && curNode != &m_pathNodes[targetNodeId]) for(i = 0; i < curNode->numLinks; i++){ @@ -2146,7 +1596,6 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta for(i = 0; i < numNodesToBeCleared; i++) apNodesToBeCleared[i]->distance = MAX_DIST; - return; } static CPathNode *pNodeList[32]; @@ -2164,11 +1613,7 @@ CPathFind::TestCoorsCloseness(CVector target, uint8 type, CVector start) else DoPathSearch(type, start, -1, target, nil, &DummyResult2, 0, nil, &dist, 50.0f, -1); if(type == PATH_CAR) -#ifndef MIAMI - return dist < 160.0f; -#else return dist < 150.0f; -#endif else return dist < 100.0f; } @@ -2341,7 +1786,6 @@ CPathFind::DisplayPathData(void) } } -#ifdef MIAMI CPathNode* CPathFind::GetNode(int16 index) { @@ -2361,4 +1805,3 @@ CPathFind::GetIndex(CPathNode *node) else return (node - ThePaths.m_pathNodes) + ARRAY_SIZE(ThePaths.m_searchNodes); } -#endif diff --git a/src/control/PathFind.h b/src/control/PathFind.h index d2799f87..73bce325 100644 --- a/src/control/PathFind.h +++ b/src/control/PathFind.h @@ -9,9 +9,6 @@ enum { NodeTypeExtern = 1, NodeTypeIntern = 2, - - UseInRoadBlock = 1, - ObjectEastWest = 2, }; enum @@ -55,33 +52,6 @@ public: struct CPathNode { -#ifndef MIAMI - CVector pos; - CPathNode *prev; - CPathNode *next; - int16 distance; // in path search - int16 objectIndex; - int16 firstLink; - uint8 numLinks; - - uint8 unkBits : 2; - uint8 bDeadEnd : 1; - uint8 bDisabled : 1; - uint8 bBetweenLevels : 1; - - int8 group; - - CVector &GetPosition(void) { return pos; } - void SetPosition(const CVector &p) { pos = p; } - float GetX(void) { return pos.x; } - float GetY(void) { return pos.y; } - float GetZ(void) { return pos.z; } - - CPathNode *GetPrev(void) { return prev; } - CPathNode *GetNext(void) { return next; } - void SetPrev(CPathNode *node) { prev = node; } - void SetNext(CPathNode *node) { next = node; } -#else int16 prevIndex; int16 nextIndex; int16 x; @@ -118,7 +88,6 @@ struct CPathNode CPathNode *GetNext(void); void SetPrev(CPathNode *node); void SetNext(CPathNode *node); -#endif }; union CConnectionFlags @@ -132,24 +101,6 @@ union CConnectionFlags struct CCarPathLink { -#ifndef MIAMI - CVector2D pos; - CVector2D dir; - int16 pathNodeIndex; - int8 numLeftLanes; - int8 numRightLanes; - uint8 trafficLightType; - - uint8 bBridgeLights : 1; - // more? - - CVector2D &GetPosition(void) { return pos; } - CVector2D &GetDirection(void) { return dir; } - float GetX(void) { return pos.x; } - float GetY(void) { return pos.y; } - float GetDirX(void) { return dir.x; } - float GetDirY(void) { return dir.y; } -#else int16 x; int16 y; int16 pathNodeIndex; @@ -168,7 +119,6 @@ struct CCarPathLink float GetY(void) { return y/8.0f; } float GetDirX(void) { return dirX/100.0f; } float GetDirY(void) { return dirY/100.0f; } -#endif float OneWayLaneOffset() { @@ -183,16 +133,6 @@ struct CCarPathLink // This is what we're reading from the files, only temporary struct CPathInfoForObject { -#ifndef MIAMI - int16 x; - int16 y; - int16 z; - int8 type; - int8 next; - int8 numLeftLanes; - int8 numRightLanes; - uint8 crossing : 1; -#else float x; float y; float z; @@ -213,7 +153,6 @@ struct CPathInfoForObject uint8 spawnRate : 4; void SwapConnectionsToBeRightWayRound(void); -#endif }; extern CPathInfoForObject *InfoForTileCars; extern CPathInfoForObject *InfoForTilePeds; @@ -221,15 +160,6 @@ extern CPathInfoForObject *InfoForTilePeds; struct CTempNode { CVector pos; -#ifndef MIAMI - float dirX; - float dirY; - int16 link1; - int16 link2; - int8 numLeftLanes; - int8 numRightLanes; - int8 linkState; -#else int8 dirX; // *100 int8 dirY; int16 link1; @@ -239,10 +169,8 @@ struct CTempNode int8 width; bool isCross; int8 linkState; -#endif }; -#ifdef MIAMI struct CTempNodeExternal // made up name { CVector pos; @@ -252,14 +180,6 @@ struct CTempNodeExternal // made up name int8 width; bool isCross; }; -#endif - -#ifndef MIAMI -struct CTempDetachedNode // unused -{ - uint8 foo[20]; -}; -#endif class CPathFind { @@ -267,15 +187,8 @@ public: CPathNode m_pathNodes[NUM_PATHNODES]; CCarPathLink m_carPathLinks[NUM_CARPATHLINKS]; CTreadable *m_mapObjects[NUM_MAPOBJECTS]; -#ifndef MIAMI - uint8 m_objectFlags[NUM_MAPOBJECTS]; - int16 m_connections[NUM_PATHCONNECTIONS]; - int16 m_distances[NUM_PATHCONNECTIONS]; - CConnectionFlags m_connectionFlags[NUM_PATHCONNECTIONS]; -#else uint16 m_connections[NUM_PATHCONNECTIONS]; // and flags uint8 m_distances[NUM_PATHCONNECTIONS]; -#endif int16 m_carPathConnections[NUM_PATHCONNECTIONS]; int32 m_numPathNodes; @@ -293,20 +206,12 @@ public: void RegisterMapObject(CTreadable *mapObject); void StoreNodeInfoPed(int16 id, int16 node, int8 type, int8 next, int16 x, int16 y, int16 z, int16 width, bool crossing); void StoreNodeInfoCar(int16 id, int16 node, int8 type, int8 next, int16 x, int16 y, int16 z, int16 width, int8 numLeft, int8 numRight); -#ifndef MIAMI - void CalcNodeCoors(int16 x, int16 y, int16 z, int32 id, CVector *out); -#else void CalcNodeCoors(float x, float y, float z, int32 id, CVector *out); -#endif bool LoadPathFindData(void); void PreparePathData(void); void CountFloodFillGroups(uint8 type); void PreparePathDataForType(uint8 type, CTempNode *tempnodes, CPathInfoForObject *objectpathinfo, -#ifndef MIAMI - float maxdist, CTempDetachedNode *detachednodes, int32 numDetached); -#else float maxdist, CPathInfoForObject *detachednodes, int32 numDetached); -#endif bool IsPathObject(int id) { return id < PATHNODESIZE && (InfoForTileCars[id*12].type != 0 || InfoForTilePeds[id*12].type != 0); } @@ -324,27 +229,19 @@ public: void MarkRoadsBetweenLevelsNodeAndNeighbours(int32 nodeId); void MarkRoadsBetweenLevelsInArea(float x1, float x2, float y1, float y2, float z1, float z2); void PedMarkRoadsBetweenLevelsInArea(float x1, float x2, float y1, float y2, float z1, float z2); -#ifndef MIAMI - int32 FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool ignoreDisabled = false, bool ignoreBetweenLevels = false); -#else -//--MIAMI: TODO: check callers for new arguments +// TODO(MIAMI): check callers for new arguments int32 FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool ignoreDisabled = false, bool ignoreBetweenLevels = false, bool ignoreFlagB4 = false, bool bWaterPath = false); -#endif int32 FindNodeClosestToCoorsFavourDirection(CVector coors, uint8 type, float dirX, float dirY); float FindNodeOrientationForCarPlacement(int32 nodeId); float FindNodeOrientationForCarPlacementFacingDestination(int32 nodeId, float x, float y, bool towards); bool NewGenerateCarCreationCoors(float x, float y, float dirX, float dirY, float spawnDist, float angleLimit, bool forward, CVector *pPosition, int32 *pNode1, int32 *pNode2, float *pPositionBetweenNodes, bool ignoreDisabled = false); bool GeneratePedCreationCoors(float x, float y, float minDist, float maxDist, float minDistOffScreen, float maxDistOffScreen, CVector *pPosition, int32 *pNode1, int32 *pNode2, float *pPositionBetweenNodes, CMatrix *camMatrix); -#ifndef MIAMI - CTreadable *FindRoadObjectClosestToCoors(CVector coors, uint8 type); -#endif void FindNextNodeWandering(uint8, CVector, CPathNode**, CPathNode**, uint8, uint8*); void DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector target, CPathNode **nodes, int16 *numNodes, int16 maxNumNodes, CVehicle *vehicle, float *dist, float distLimit, int32 forcedTargetNode); bool TestCoorsCloseness(CVector target, uint8 type, CVector start); void Save(uint8 *buf, uint32 *size); void Load(uint8 *buf, uint32 size); -#ifdef MIAMI CPathNode *GetNode(int16 index); int16 GetIndex(CPathNode *node); @@ -352,27 +249,16 @@ public: bool ConnectionCrossesRoad(int id) { return !!(m_connections[id] & 0x8000); } bool ConnectionHasTrafficLight(int id) { return !!(m_connections[id] & 0x4000); } void ConnectionSetTrafficLight(int id) { m_connections[id] |= 0x4000; } -#else - uint16 ConnectedNode(int id) { return m_connections[id]; } - bool ConnectionCrossesRoad(int id) { return m_connectionFlags[id].bCrossesRoad; } - bool ConnectionHasTrafficLight(int id) { return m_connectionFlags[id].bTrafficLight; } - void ConnectionSetTrafficLight(int id) { m_connectionFlags[id].bTrafficLight = true; } -#endif void DisplayPathData(void); }; -#ifndef MIAMI -static_assert(sizeof(CPathFind) == 0x49bf4, "CPathFind: error"); -#endif extern CPathFind ThePaths; -#ifdef MIAMI inline CPathNode *CPathNode::GetPrev(void) { return ThePaths.GetNode(prevIndex); } inline CPathNode *CPathNode::GetNext(void) { return ThePaths.GetNode(nextIndex); } inline void CPathNode::SetPrev(CPathNode *node) { prevIndex = ThePaths.GetIndex(node); } inline void CPathNode::SetNext(CPathNode *node) { nextIndex = ThePaths.GetIndex(node); } -#endif extern bool gbShowPedPaths; extern bool gbShowCarPaths; diff --git a/src/control/Record.cpp b/src/control/Record.cpp index 6ae99e2c..b357d35d 100644 --- a/src/control/Record.cpp +++ b/src/control/Record.cpp @@ -420,19 +420,6 @@ void CRecordDataForChase::GiveUsACar(int32 mi, CVector pos, float angle, CAutomo //--MIAMI: unused void RemoveUnusedCollision(void) { -#ifndef MIAMI - static const char* dontDeleteArray[] = { - "rd_SrRoad2A50", "rd_SrRoad2A20", "rd_CrossRda1w22", "rd_CrossRda1rw22", - "road_broadway02", "road_broadway01", "com_21way5", "com_21way50", - "cm1waycrosscom", "com_21way20", "com_21way10", "road_broadway04", - "com_rvroads52", "com_roadsrv", "com_roadkb23", "com_roadkb22" - }; - for (int i = 0; i < ARRAY_SIZE(dontDeleteArray); i++) - CModelInfo::GetModelInfo(dontDeleteArray[i], nil)->GetColModel()->level = LEVEL_NONE; - CModelInfo::RemoveColModelsFromOtherLevels(LEVEL_NONE); - for (int i = 0; i < ARRAY_SIZE(dontDeleteArray); i++) - CModelInfo::GetModelInfo(dontDeleteArray[i], nil)->GetColModel()->level = LEVEL_COMMERCIAL; -#endif } void CRecordDataForChase::StartChaseScene(float startTime) diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp index 322cc1df..3a271170 100644 --- a/src/control/RoadBlocks.cpp +++ b/src/control/RoadBlocks.cpp @@ -15,40 +15,23 @@ #include "CarCtrl.h" #include "General.h" -#ifndef MIAMI -#define ROADBLOCKDIST (80.0f) -#else #define ROADBLOCKDIST (90.0f) -#endif int16 CRoadBlocks::NumRoadBlocks; -#ifndef MIAMI -int16 CRoadBlocks::RoadBlockObjects[NUMROADBLOCKS]; -#else int16 CRoadBlocks::RoadBlockNodes[NUMROADBLOCKS]; -#endif bool CRoadBlocks::InOrOut[NUMROADBLOCKS]; -//--MIAMI: TODO: script roadblocks +//--MIAMI: TODO void CRoadBlocks::Init(void) { int i; NumRoadBlocks = 0; -#ifndef MIAMI - for (i = 0; i < ThePaths.m_numMapObjects; i++) { - if (ThePaths.m_objectFlags[i] & UseInRoadBlock) { -#else for(i = 0; i < ThePaths.m_numCarPathNodes; i++){ if(ThePaths.m_pathNodes[i].bUseInRoadBlock && ThePaths.m_pathNodes[i].numLinks == 2){ -#endif if (NumRoadBlocks < NUMROADBLOCKS) { InOrOut[NumRoadBlocks] = true; -#ifndef MIAMI - RoadBlockObjects[NumRoadBlocks] = i; -#else RoadBlockNodes[NumRoadBlocks] = i; -#endif NumRoadBlocks++; } else { #ifndef MASTER @@ -59,6 +42,8 @@ CRoadBlocks::Init(void) } } } + + // TODO(MIAMI): script roadblocks } void @@ -120,6 +105,7 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType } } +//--MIAMI: TODO: implement this void CRoadBlocks::GenerateRoadBlocks(void) { @@ -128,12 +114,7 @@ CRoadBlocks::GenerateRoadBlocks(void) int16 nRoadblockNode = (int16)(NUMROADBLOCKS * frame) / 16; const int16 maxRoadBlocks = (int16)(NUMROADBLOCKS * (frame + 1)) / 16; for (; nRoadblockNode < Min(NumRoadBlocks, maxRoadBlocks); nRoadblockNode++) { -#ifndef MIAMI - CTreadable *mapObject = ThePaths.m_mapObjects[RoadBlockObjects[nRoadblockNode]]; - CVector2D vecDistance = FindPlayerCoors() - mapObject->GetPosition(); -#else CVector2D vecDistance = FindPlayerCoors() - ThePaths.m_pathNodes[nRoadblockNode].GetPosition(); -#endif if (vecDistance.x > -ROADBLOCKDIST && vecDistance.x < ROADBLOCKDIST && vecDistance.y > -ROADBLOCKDIST && vecDistance.y < ROADBLOCKDIST && vecDistance.Magnitude() < ROADBLOCKDIST) { @@ -218,5 +199,5 @@ CRoadBlocks::GenerateRoadBlocks(void) } } -//--MIAMI: TODO script roadblocks + // TODO(MIAMI): script roadblocks } diff --git a/src/control/Script.h b/src/control/Script.h index 12a507c1..a44fc7c1 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -372,9 +372,7 @@ private: friend class CRunningScript; friend class CHud; friend void CMissionCleanup::Process(); -#ifdef MIAMI friend class CColStore; -#endif }; diff --git a/src/core/ColStore.cpp b/src/core/ColStore.cpp index 0c3356c5..0715ae6e 100644 --- a/src/core/ColStore.cpp +++ b/src/core/ColStore.cpp @@ -1,5 +1,4 @@ #include "common.h" -#ifdef MIAMI #include "templates.h" #include "General.h" @@ -227,5 +226,3 @@ CColStore::HasCollisionLoaded(const CVector2D &pos) return false; return true; } - -#endif diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index f20fee6d..61cb14db 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -20,10 +20,8 @@ #include "SurfaceTable.h" #include "Lines.h" #include "Collision.h" -#ifdef MIAMI #include "Camera.h" #include "ColStore.h" -#endif enum Direction { @@ -44,9 +42,7 @@ CCollision::Init(void) { ms_colModelCache.Init(NUMCOLCACHELINKS); ms_collisionInMemory = LEVEL_NONE; -#ifdef MIAMI CColStore::Initialise(); -#endif } //--MIAMI: done @@ -54,50 +50,13 @@ void CCollision::Shutdown(void) { ms_colModelCache.Shutdown(); -#ifdef MIAMI CColStore::Shutdown(); -#endif } //--MIAMI: done void CCollision::Update(void) { -#ifndef MIAMI - CVector playerCoors; - playerCoors = FindPlayerCoors(); - eLevelName level = CTheZones::m_CurrLevel; - bool forceLevelChange = false; - - if(CTimer::GetTimeInMilliseconds() < 2000 || CCutsceneMgr::IsCutsceneProcessing()) - return; - - // hardcode a level if there are no zones - if(level == LEVEL_NONE){ - if(CGame::currLevel == LEVEL_INDUSTRIAL && - playerCoors.x < 400.0f){ - level = LEVEL_COMMERCIAL; - forceLevelChange = true; - }else if(CGame::currLevel == LEVEL_SUBURBAN && - playerCoors.x > -450.0f && playerCoors.y < -1400.0f){ - level = LEVEL_COMMERCIAL; - forceLevelChange = true; - }else{ - if(playerCoors.x > 800.0f){ - level = LEVEL_INDUSTRIAL; - forceLevelChange = true; - }else if(playerCoors.x < -800.0f){ - level = LEVEL_SUBURBAN; - forceLevelChange = true; - } - } - } - if(level != LEVEL_NONE && level != CGame::currLevel) - CGame::currLevel = level; - if(ms_collisionInMemory != CGame::currLevel) - LoadCollisionWhenINeedIt(forceLevelChange); - CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel); -#endif } //--MIAMI: unused @@ -142,116 +101,12 @@ GetCollisionInSector(CSector §) void CCollision::LoadCollisionWhenINeedIt(bool forceChange) { -#ifndef MIAMI - eLevelName level, l; - bool multipleLevels; - CVector playerCoors; - CVehicle *veh; - CEntryInfoNode *ei; - int sx, sy; - int xmin, xmax, ymin, ymax; - int x, y; - - level = LEVEL_NONE; - - playerCoors = FindPlayerCoors(); - sx = CWorld::GetSectorIndexX(playerCoors.x); - sy = CWorld::GetSectorIndexY(playerCoors.y); - multipleLevels = false; - - veh = FindPlayerVehicle(); - if(veh && veh->IsTrain()){ - if(((CTrain*)veh)->m_nDoorState != TRAIN_DOOR_OPEN) - return; - }else if(playerCoors.z < -4.0f && !CCullZones::DoINeedToLoadCollision()) - return; - - // Figure out whose level's collisions we're most likely to be interested in - if(!forceChange){ - if(veh && veh->IsBoat()){ - // on water we expect to be between levels - multipleLevels = true; - }else{ - xmin = Max(sx - 1, 0); - xmax = Min(sx + 1, NUMSECTORS_X-1); - ymin = Max(sy - 1, 0); - ymax = Min(sy + 1, NUMSECTORS_Y-1); - - for(x = xmin; x <= xmax; x++) - for(y = ymin; y <= ymax; y++){ - l = GetCollisionInSector(*CWorld::GetSector(x, y)); - if(l != LEVEL_NONE){ - if(level == LEVEL_NONE) - level = l; - if(level != l) - multipleLevels = true; - } - } - } - - if(multipleLevels && veh && veh->IsBoat()) - for(ei = veh->m_entryInfoList.first; ei; ei = ei->next){ - level = GetCollisionInSector(*ei->sector); - if(level != LEVEL_NONE) - break; - } - } - - if(level == CGame::currLevel || forceChange){ - CTimer::Stop(); - DMAudio.SetEffectsFadeVol(0); - CPad::StopPadsShaking(); - LoadCollisionScreen(CGame::currLevel); - DMAudio.Service(); - - CPopulation::DealWithZoneChange(ms_collisionInMemory, CGame::currLevel, false); - CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL); - CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL); - CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN); - CStreaming::RemoveBigBuildings(LEVEL_INDUSTRIAL); - CStreaming::RemoveBigBuildings(LEVEL_COMMERCIAL); - CStreaming::RemoveBigBuildings(LEVEL_SUBURBAN); - CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel); - CStreaming::RemoveUnusedModelsInLoadedList(); - CGame::TidyUpMemory(true, true); - CFileLoader::LoadCollisionFromDatFile(CGame::currLevel); - ms_collisionInMemory = CGame::currLevel; - CReplay::EmptyReplayBuffer(); - if(CGame::currLevel != LEVEL_NONE) - LoadSplash(GetLevelSplashScreen(CGame::currLevel)); - CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); - CStreaming::RemoveUnusedBuildings(CGame::currLevel); - CStreaming::RequestBigBuildings(CGame::currLevel); - CStreaming::LoadAllRequestedModels(true); - CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel); - - CGame::TidyUpMemory(true, true); - CTimer::Update(); - DMAudio.SetEffectsFadeVol(127); - } -#endif } //--MIAMI: done void CCollision::SortOutCollisionAfterLoad(void) { -#ifndef MIAMI - if(ms_collisionInMemory == CGame::currLevel) - return; - - CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel); - if(CGame::currLevel != LEVEL_NONE){ - CFileLoader::LoadCollisionFromDatFile(CGame::currLevel); - if(!CGame::playingIntro) - LoadSplash(GetLevelSplashScreen(CGame::currLevel)); - } - ms_collisionInMemory = CGame::currLevel; - CGame::TidyUpMemory(true, false); -#else - CColStore::LoadCollision(TheCamera.GetPosition()); - CStreaming::LoadAllRequestedModels(false); -#endif } void @@ -2000,11 +1855,7 @@ CColModel::CColModel(void) vertices = nil; triangles = nil; trianglePlanes = nil; -#ifndef MIAMI - level = CGame::currLevel; -#else level = 0; // generic col slot -#endif ownsCollisionVolumes = true; } diff --git a/src/core/Collision.h b/src/core/Collision.h index fc3c1647..18fad76b 100644 --- a/src/core/Collision.h +++ b/src/core/Collision.h @@ -87,17 +87,14 @@ struct CStoredCollPoly struct CColModel { + // TODO(MIAMI): CSphere and CBox CColSphere boundingSphere; CColBox boundingBox; int16 numSpheres; int16 numLines; int16 numBoxes; int16 numTriangles; -#ifndef MIAMI - int32 level; -#else - uint8 level; // colstore slot but probably same name -#endif + uint8 level; // colstore slot but probably still named level bool ownsCollisionVolumes; CColSphere *spheres; CColLine *lines; diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index ab09d72f..c23f7114 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -24,10 +24,8 @@ #include "ZoneCull.h" #include "CdStream.h" #include "FileLoader.h" -#ifdef MIAMI #include "Streaming.h" #include "ColStore.h" -#endif char CFileLoader::ms_line[256]; @@ -50,16 +48,12 @@ CFileLoader::LoadLevel(const char *filename) { int fd; RwTexDictionary *savedTxd; - eLevelName savedLevel; bool objectsLoaded; char *line; char txdname[64]; savedTxd = RwTexDictionaryGetCurrent(); objectsLoaded = false; -#ifndef MIAMI - savedLevel = CGame::currLevel; -#endif if(savedTxd == nil){ savedTxd = RwTexDictionaryCreate(); RwTexDictionarySetCurrent(savedTxd); @@ -83,17 +77,8 @@ CFileLoader::LoadLevel(const char *filename) AddTexDictionaries(savedTxd, txd); RwTexDictionaryDestroy(txd); }else if(strncmp(line, "COLFILE", 7) == 0){ -#ifndef MIAMI - int level; - sscanf(line+8, "%d", &level); - CGame::currLevel = (eLevelName)level; - LoadingScreenLoadingFile(line+10); - LoadCollisionFile(line+10); - CGame::currLevel = savedLevel; -#else LoadingScreenLoadingFile(line+10); LoadCollisionFile(line+10, 0); -#endif }else if(strncmp(line, "MODELFILE", 9) == 0){ LoadingScreenLoadingFile(line + 10); LoadModelFile(line + 10); @@ -105,16 +90,11 @@ CFileLoader::LoadLevel(const char *filename) LoadObjectTypes(line + 4); }else if(strncmp(line, "IPL", 3) == 0){ if(!objectsLoaded){ -#ifndef MIAMI - CModelInfo::ConstructMloClumps(); - CObjectData::Initialise("DATA\\OBJECT.DAT"); -#else LoadingScreenLoadingFile("Collision"); CObjectData::Initialise("DATA\\OBJECT.DAT"); CStreaming::Init(); CColStore::LoadAllCollision(); - // TODO: anim indices -#endif + // TODO(MIAMI): anim indices objectsLoaded = true; } LoadingScreenLoadingFile(line + 4); @@ -132,42 +112,14 @@ CFileLoader::LoadLevel(const char *filename) CFileMgr::CloseFile(fd); RwTexDictionarySetCurrent(savedTxd); -#ifdef MIAMI int i; for(i = 1; i < COLSTORESIZE; i++) if(CColStore::GetSlot(i)) CColStore::GetBoundingBox(i).Grow(120.0f); CWorld::RepositionCertainDynamicObjects(); CColStore::RemoveAllCollision(); -#endif } -#ifndef MIAMI -void -CFileLoader::LoadCollisionFromDatFile(int currlevel) -{ - int fd; - char *line; - - fd = CFileMgr::OpenFile(CGame::aDatFile, "r"); - assert(fd > 0); - - for(line = LoadLine(fd); line; line = LoadLine(fd)){ - if(*line == '#') - continue; - - if(strncmp(line, "COLFILE", 7) == 0){ - int level; - sscanf(line+8, "%d", &level); - if(currlevel == level) - LoadCollisionFile(line+10); - } - } - - CFileMgr::CloseFile(fd); -} -#endif - char* CFileLoader::LoadLine(int fd) { @@ -209,13 +161,8 @@ struct ColHeader }; //--MIAMI: done -#ifndef MIAMI -void -CFileLoader::LoadCollisionFile(const char *filename) -#else void CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot) -#endif { int fd; char modelname[24]; @@ -232,17 +179,11 @@ CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot) mi = CModelInfo::GetModelInfo(modelname, nil); if(mi){ -#ifndef MIAMI - if(mi->GetColModel()){ -#else if(mi->GetColModel() && mi->DoesOwnColModel()){ -#endif LoadCollisionModel(work_buff+24, *mi->GetColModel(), modelname); }else{ CColModel *model = new CColModel; -#ifdef MIAMI model->level = colSlot; -#endif LoadCollisionModel(work_buff+24, *model, modelname); mi->SetColModel(model, true); } @@ -254,7 +195,6 @@ CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot) CFileMgr::CloseFile(fd); } -#ifdef MIAMI bool CFileLoader::LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlot) { @@ -278,8 +218,6 @@ CFileLoader::LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlo mi = CModelInfo::GetModelInfo(modelname, &modelIndex); if(mi){ -if(modelIndex == 855) -modelIndex = modelIndex; CColStore::IncludeModelIndex(colSlot, modelIndex); CColModel *model = new CColModel; model->level = colSlot; @@ -328,7 +266,6 @@ CFileLoader::LoadCollisionFile(uint8 *buffer, uint32 size, uint8 colSlot) } return true; } -#endif void CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname) @@ -617,7 +554,6 @@ CFileLoader::LoadObjectTypes(const char *filename) enum { NONE, OBJS, - MLO, TOBJ, HIER, CARS, @@ -652,16 +588,10 @@ CFileLoader::LoadObjectTypes(const char *filename) else if(strncmp(line, "path", 4) == 0) section = PATH; else if(strncmp(line, "2dfx", 4) == 0) section = TWODFX; }else if(strncmp(line, "end", 3) == 0){ - section = section == MLO ? OBJS : NONE; + section = NONE; }else switch(section){ case OBJS: - if(strncmp(line, "sta", 3) == 0) - mlo = LoadMLO(line); - else - LoadObject(line); - break; - case MLO: - LoadMLOInstance(mlo, line); + LoadObject(line); break; case TOBJ: LoadTimeObject(line); @@ -764,57 +694,6 @@ CFileLoader::LoadObject(const char *line) MatchModelString(model, id); } -int -CFileLoader::LoadMLO(const char *line) -{ - char smth[8]; - char name[24]; - int modelIndex; - float someFloat; - - sscanf(line, "%s %s %d %f", smth, name, &modelIndex, &someFloat); - CMloModelInfo *minfo = CModelInfo::AddMloModel(modelIndex); - minfo->SetName(name); - minfo->field_34 = someFloat; - int instId = CModelInfo::GetMloInstanceStore().allocPtr; - minfo->firstInstance = instId; - minfo->lastInstance = instId; - minfo->SetTexDictionary("generic"); - return modelIndex; -} - -void -CFileLoader::LoadMLOInstance(int id, const char *line) -{ - char name[24]; - RwV3d pos, scale, rot; - float angle; - int modelIndex; - - CMloModelInfo *minfo = (CMloModelInfo*)CModelInfo::GetModelInfo(id); - sscanf(line, "%d %s %f %f %f %f %f %f %f %f %f %f", - &modelIndex, - name, - &pos.x, &pos.y, &pos.z, - &scale.x, &scale.y, &scale.z, - &rot.x, &rot.y, &rot.z, - &angle); - float rad = Acos(angle) * 2.0f; - CInstance *inst = CModelInfo::GetMloInstanceStore().alloc(); - minfo->lastInstance++; - - RwMatrix *matrix = RwMatrixCreate(); - RwMatrixScale(matrix, &scale, rwCOMBINEREPLACE); - RwMatrixRotate(matrix, &rot, -RADTODEG(rad), rwCOMBINEPOSTCONCAT); - RwMatrixTranslate(matrix, &pos, rwCOMBINEPOSTCONCAT); - - inst->GetMatrix() = CMatrix(matrix); - inst->GetMatrix().UpdateRW(); - - inst->m_modelIndex = modelIndex; - RwMatrixDestroy(matrix); -} - void CFileLoader::LoadTimeObject(const char *line) { @@ -1182,7 +1061,6 @@ CFileLoader::LoadObjectInstance(const char *line) CSimpleModelInfo *mi; RwMatrix *xform; CEntity *entity; -#ifdef MIAMI float area; if(sscanf(line, "%d %s %f %f %f %f %f %f %f %f %f %f %f", @@ -1190,27 +1068,22 @@ CFileLoader::LoadObjectInstance(const char *line) &trans.x, &trans.y, &trans.z, &scale.x, &scale.y, &scale.z, &axis.x, &axis.y, &axis.z, &angle) != 13){ -#endif - if(sscanf(line, "%d %s %f %f %f %f %f %f %f %f %f %f", - &id, name, - &trans.x, &trans.y, &trans.z, - &scale.x, &scale.y, &scale.z, - &axis.x, &axis.y, &axis.z, &angle) != 12) - return; -#ifdef MIAMI + if(sscanf(line, "%d %s %f %f %f %f %f %f %f %f %f %f", + &id, name, + &trans.x, &trans.y, &trans.z, + &scale.x, &scale.y, &scale.z, + &axis.x, &axis.y, &axis.z, &angle) != 12) + return; area = 0; } -#endif mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(id); if(mi == nil) return; assert(mi->IsSimple()); -#ifdef MIAMI if(!CStreaming::IsObjectInCdImage(id)) debug("Not in cdimage %s\n", mi->GetName()); -#endif angle = -RADTODEG(2.0f * acosf(angle)); xform = RwMatrixCreate(); @@ -1226,9 +1099,7 @@ CFileLoader::LoadObjectInstance(const char *line) entity->SetModelIndexNoCreate(id); entity->GetMatrix() = CMatrix(xform); entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition()); -#ifdef MIAMI entity->m_area = area; -#endif if(mi->IsSimple()){ if(mi->m_isBigBuilding) entity->SetupBigBuilding(); @@ -1239,27 +1110,24 @@ CFileLoader::LoadObjectInstance(const char *line) entity->bIsVisible = false; CWorld::Add(entity); -#ifdef MIAMI CColModel *col = entity->GetColModel(); if(col->numSpheres || col->numBoxes || col->numTriangles){ if(col->level != 0) CColStore::GetBoundingBox(col->level).ContainRect(entity->GetBoundRect()); }else entity->bUsesCollision = false; - // TODO: set some flag here if col min is below 6 -#endif + // TODO(MIAMI): set some flag here if col min is below 6 }else{ entity = new CDummyObject; entity->SetModelIndexNoCreate(id); entity->GetMatrix() = CMatrix(xform); CWorld::Add(entity); + // TODO(MIAMI) //--MIAMI: TODO if(IsGlass(entity->GetModelIndex())) entity->bIsVisible = false; entity->m_level = CTheZones::GetLevelFromPosition(entity->GetPosition()); -#ifdef MIAMI entity->m_area = area; -#endif } RwMatrixDestroy(xform); diff --git a/src/core/FileLoader.h b/src/core/FileLoader.h index aa8dcdb8..6abac9d8 100644 --- a/src/core/FileLoader.h +++ b/src/core/FileLoader.h @@ -5,16 +5,11 @@ class CFileLoader static char ms_line[256]; public: static void LoadLevel(const char *filename); - static void LoadCollisionFromDatFile(int currlevel); static char *LoadLine(int fd); static RwTexDictionary *LoadTexDictionary(const char *filename); -#ifndef MIAMI - static void LoadCollisionFile(const char *filename); -#else - static void LoadCollisionFile(const char *filename, uint8 colSlot = 0); + static void LoadCollisionFile(const char *filename, uint8 colSlot); static bool LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlot); static bool LoadCollisionFile(uint8 *buffer, uint32 size, uint8 colSlot); -#endif static void LoadCollisionModel(uint8 *buf, struct CColModel &model, char *name); static void LoadModelFile(const char *filename); static RpAtomic *FindRelatedModelInfoCB(RpAtomic *atomic, void *data); @@ -29,8 +24,6 @@ public: static void LoadObjectTypes(const char *filename); static void LoadObject(const char *line); - static int LoadMLO(const char *line); - static void LoadMLOInstance(int id, const char *line); static void LoadTimeObject(const char *line); static void LoadClumpObject(const char *line); static void LoadVehicleObject(const char *line); diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index fc845a4c..e2c2a453 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -1060,10 +1060,10 @@ CMenuManager::Draw() rightText = TheText.Get(gbBigWhiteDebugLightSwitchedOn ? "FEM_ON" : "FEM_OFF"); break; case MENUACTION_PEDROADGROUPS: - rightText = TheText.Get(gbShowPedRoadGroups ? "FEM_ON" : "FEM_OFF"); + // REMOVED(MIAMI) break; case MENUACTION_CARROADGROUPS: - rightText = TheText.Get(gbShowCarRoadGroups ? "FEM_ON" : "FEM_OFF"); + // REMOVED(MIAMI) break; case MENUACTION_COLLISIONPOLYS: rightText = TheText.Get(gbShowCollisionPolys ? "FEM_ON" : "FEM_OFF"); @@ -4904,11 +4904,11 @@ CMenuManager::ProcessOnOffMenuOptions() DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); break; case MENUACTION_PEDROADGROUPS: - gbShowPedRoadGroups = !gbShowPedRoadGroups; + // REMOVED(MIAMI) DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); break; case MENUACTION_CARROADGROUPS: - gbShowCarRoadGroups = !gbShowCarRoadGroups; + // REMOVED(MIAMI) DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); break; case MENUACTION_COLLISIONPOLYS: diff --git a/src/core/Frontend.h b/src/core/Frontend.h index c27e5239..a6ca4aa0 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -624,10 +624,8 @@ public: void LoadAllTextures(); void LoadSettings(); void MessageScreen(const char *); -#ifdef MIAMI - //--MIAMI: TODO: implement the second argument + // TODO(MIAMI): implement the second argument void MessageScreen(const char *str, bool) { MessageScreen(str); } -#endif void PickNewPlayerColour(); void PrintBriefs(); static void PrintErrorMessage(); diff --git a/src/core/Game.cpp b/src/core/Game.cpp index d0b3f5a3..ea3301a1 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -89,9 +89,7 @@ eLevelName CGame::currLevel; -#ifdef MIAMI int32 CGame::currArea; -#endif bool CGame::bDemoMode = true; bool CGame::nastyGame = true; bool CGame::frenchGame; @@ -322,9 +320,6 @@ bool CGame::Initialise(const char* datFile) CDraw::SetFOV(120.0f); CDraw::ms_fLODDistance = 500.0f; LoadingScreen("Loading the Game", "Setup streaming", nil); -#ifndef MIAMI - CStreaming::Init(); -#endif CStreaming::LoadInitialVehicles(); CStreaming::LoadInitialPeds(); CStreaming::RequestBigBuildings(LEVEL_NONE); @@ -372,14 +367,7 @@ bool CGame::Initialise(const char* datFile) CWaterCannons::Init(); CBridge::Init(); CGarages::Init(); -#ifndef MIAMI - LoadingScreen("Loading the Game", "Position dynamic objects", nil); - CWorld::RepositionCertainDynamicObjects(); -#endif LoadingScreen("Loading the Game", "Initialise vehicle paths", nil); -#ifdef GTA_ZONECULL - CCullZones::ResolveVisibilities(); -#endif CTrain::InitTrains(); CPlane::InitPlanes(); CCredits::Init(); @@ -390,9 +378,6 @@ bool CGame::Initialise(const char* datFile) CTheScripts::Process(); TheCamera.Process(); LoadingScreen("Loading the Game", "Load scene", nil); -#ifndef MIAMI - CModelInfo::RemoveColModelsFromOtherLevels(currLevel); -#endif CCollision::ms_collisionInMemory = currLevel; for (int i = 0; i < MAX_PADS; i++) CPad::GetPad(i)->Clear(true); @@ -532,12 +517,6 @@ void CGame::ReloadIPLs(void) CRoadBlocks::Init(); CCranes::InitCranes(); CGarages::Init(); -#ifndef MIAMI - CWorld::RepositionCertainDynamicObjects(); -#endif -#ifdef GTA_ZONECULL - CCullZones::ResolveVisibilities(); -#endif CRenderer::SortBIGBuildings(); CTimer::Update(); } diff --git a/src/core/Game.h b/src/core/Game.h index 227da56e..2bd468ba 100644 --- a/src/core/Game.h +++ b/src/core/Game.h @@ -35,9 +35,7 @@ class CGame { public: static eLevelName currLevel; -#ifdef MIAMI static int32 currArea; -#endif static bool bDemoMode; static bool nastyGame; static bool frenchGame; diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h index 13266331..c649d49d 100644 --- a/src/core/PlayerInfo.h +++ b/src/core/PlayerInfo.h @@ -80,6 +80,3 @@ public: ~CPlayerInfo() { }; }; -#ifndef MIAMI -static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error"); -#endif diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index d212dd05..14819d30 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -18,7 +18,6 @@ #include "FileMgr.h" #include "FileLoader.h" #include "Zones.h" -#include "ZoneCull.h" #include "Radar.h" #include "Camera.h" #include "Record.h" @@ -28,14 +27,10 @@ #include "CutsceneMgr.h" #include "CdStream.h" #include "Streaming.h" -#ifdef FIX_BUGS #include "Replay.h" -#endif #include "main.h" -#ifdef MIAMI #include "ColStore.h" #include "DMAudio.h" -#endif bool CStreaming::ms_disableStreaming; bool CStreaming::ms_bLoadingBigModel; @@ -57,9 +52,6 @@ int32 CStreaming::ms_vehiclesLoaded[MAXVEHICLESLOADED]; int32 CStreaming::ms_lastVehicleDeleted; CDirectory *CStreaming::ms_pExtraObjectsDir; int32 CStreaming::ms_numPriorityRequests; -#ifndef MIAMI -bool CStreaming::ms_hasLoadedLODs; -#endif int32 CStreaming::ms_currentPedGrp; int32 CStreaming::ms_currentPedLoading; int32 CStreaming::ms_lastCullZone; @@ -190,9 +182,6 @@ CStreaming::Init2(void) ms_pExtraObjectsDir = new CDirectory(EXTRADIRSIZE); ms_numPriorityRequests = 0; -#ifndef MIAMI - ms_hasLoadedLODs = true; -#endif ms_currentPedGrp = -1; ms_lastCullZone = -1; // unused because RemoveModelsNotVisibleFromCullzone is gone ms_loadedGangs = 0; @@ -238,19 +227,6 @@ CStreaming::Init2(void) CModelInfo::GetModelInfo("IslandLODcomSUB", &islandLODcomSub); CModelInfo::GetModelInfo("IslandLODsubIND", &islandLODsubInd); CModelInfo::GetModelInfo("IslandLODsubCOM", &islandLODsubCom); - -#ifndef MIAMI - for(i = CPools::GetBuildingPool()->GetSize()-1; i >= 0; i--){ - CBuilding *building = CPools::GetBuildingPool()->GetSlot(i); - if(building == nil) - continue; - if(building->GetModelIndex() == islandLODindust) pIslandLODindustEntity = building; - if(building->GetModelIndex() == islandLODcomInd) pIslandLODcomIndEntity = building; - if(building->GetModelIndex() == islandLODcomSub) pIslandLODcomSubEntity = building; - if(building->GetModelIndex() == islandLODsubInd) pIslandLODsubIndEntity = building; - if(building->GetModelIndex() == islandLODsubCom) pIslandLODsubComEntity = building; - } -#endif } void @@ -288,7 +264,6 @@ CStreaming::Shutdown(void) void CStreaming::Update(void) { - CEntity *train; CStreamingInfo *si, *prev; bool requestedSubway = false; @@ -302,46 +277,24 @@ CStreaming::Update(void) if(CTimer::GetIsPaused()) return; -#ifndef MIAMI - train = FindPlayerTrain(); - if(train && train->GetPosition().z < 0.0f){ - RequestSubway(); - requestedSubway = true; - }else if(!ms_disableStreaming) - AddModelsToRequestList(TheCamera.GetPosition()); -#else LoadBigBuildingsWhenNeeded(); if(!ms_disableStreaming && TheCamera.GetPosition().z < 55.0f) AddModelsToRequestList(TheCamera.GetPosition()); -#endif DeleteFarAwayRwObjects(TheCamera.GetPosition()); if(!ms_disableStreaming && -#ifndef MIAMI - !CCutsceneMgr::IsRunning() && - !requestedSubway && - !CGame::playingIntro && -#else !CCutsceneMgr::IsCutsceneProcessing() && -#endif ms_numModelsRequested < 5 && - !CRenderer::m_loadingPriority -#ifdef MIAMI - && CGame::currArea == 0 - // replay is also MIAMI -#endif -#ifdef FIX_BUGS - && !CReplay::IsPlayingBack() -#endif - ){ + !CRenderer::m_loadingPriority && + CGame::currArea == 0 && + !CReplay::IsPlayingBack()){ StreamVehiclesAndPeds(); StreamZoneModels(FindPlayerCoors()); } LoadRequestedModels(); -#ifdef MIAMI if(CWorld::Players[0].m_pRemoteVehicle){ CColStore::AddCollisionNeededAtPosn(FindPlayerCoors()); CColStore::LoadCollision(CWorld::Players[0].m_pRemoteVehicle->GetPosition()); @@ -350,7 +303,6 @@ CStreaming::Update(void) CColStore::LoadCollision(FindPlayerCoors()); CColStore::EnsureCollisionIsInMemory(FindPlayerCoors()); } -#endif for(si = ms_endRequestedList.m_prev; si != &ms_startRequestedList; si = prev){ prev = si->m_prev; @@ -397,8 +349,7 @@ void CStreaming::LoadCdDirectory(const char *dirname, int n) { int fd, lastID, imgSelector; - int modelId, txdId; - uint32 posn, size; + int modelId; CDirectory::DirectoryInfo direntry; char *dot; @@ -409,50 +360,6 @@ CStreaming::LoadCdDirectory(const char *dirname, int n) imgSelector = n<<24; assert(sizeof(direntry) == 32); while(CFileMgr::Read(fd, (char*)&direntry, sizeof(direntry))){ -#ifndef MIAMI - dot = strchr(direntry.name, '.'); - if(dot) *dot = '\0'; - if(direntry.size > (uint32)ms_streamingBufferSize) - ms_streamingBufferSize = direntry.size; - - if(!CGeneral::faststrcmp(dot+1, "DFF") || !CGeneral::faststrcmp(dot+1, "dff")){ - if(CModelInfo::GetModelInfo(direntry.name, &modelId)){ - if(ms_aInfoForModel[modelId].GetCdPosnAndSize(posn, size)){ - debug("%s appears more than once in %s\n", direntry.name, dirname); - lastID = -1; - }else{ - direntry.offset |= imgSelector; - ms_aInfoForModel[modelId].SetCdPosnAndSize(direntry.offset, direntry.size); - if(lastID != -1) - ms_aInfoForModel[lastID].m_nextID = modelId; - lastID = modelId; - } - }else{ -#ifdef FIX_BUGS - // remember which cdimage this came from - ms_pExtraObjectsDir->AddItem(direntry, n); -#else - ms_pExtraObjectsDir->AddItem(direntry); -#endif - lastID = -1; - } - }else if(!CGeneral::faststrcmp(dot+1, "TXD") || !CGeneral::faststrcmp(dot+1, "txd")){ - txdId = CTxdStore::FindTxdSlot(direntry.name); - if(txdId == -1) - txdId = CTxdStore::AddTxdSlot(direntry.name); - if(ms_aInfoForModel[txdId + STREAM_OFFSET_TXD].GetCdPosnAndSize(posn, size)){ - debug("%s appears more than once in %s\n", direntry.name, dirname); - lastID = -1; - }else{ - direntry.offset |= imgSelector; - ms_aInfoForModel[txdId + STREAM_OFFSET_TXD].SetCdPosnAndSize(direntry.offset, direntry.size); - if(lastID != -1) - ms_aInfoForModel[lastID].m_nextID = txdId + STREAM_OFFSET_TXD; - lastID = txdId + STREAM_OFFSET_TXD; - } - }else - lastID = -1; -#else bool bAddToStreaming = false; if(direntry.size > (uint32)ms_streamingBufferSize) @@ -491,7 +398,7 @@ CStreaming::LoadCdDirectory(const char *dirname, int n) modelId = CColStore::AddColSlot(direntry.name); modelId += STREAM_OFFSET_COL; bAddToStreaming = true; - // TODO: IFP + // TODO(MIAMI): IFP }else{ *dot = '.'; lastID = -1; @@ -509,7 +416,6 @@ CStreaming::LoadCdDirectory(const char *dirname, int n) lastID = modelId; } } -#endif } CFileMgr::CloseFile(fd); @@ -575,11 +481,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) RwStreamClose(stream, &mem); return false; } -#ifndef MIAMI - }else{ -#else }else if(streamId >= STREAM_OFFSET_TXD && streamId < STREAM_OFFSET_COL){ -#endif // Txd assert(streamId < NUMSTREAMINFO); if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_KEEP_IN_MEMORY) == 0 && @@ -604,7 +506,6 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) RwStreamClose(stream, &mem); return false; } -#ifdef MIAMI }else if(streamId >= STREAM_OFFSET_COL && streamId < NUMSTREAMINFO){ if(!CColStore::LoadCol(streamId-STREAM_OFFSET_COL, mem.start, mem.length)){ debug("Failed to load %s.col\n", CColStore::GetColName(streamId - STREAM_OFFSET_COL)); @@ -613,24 +514,11 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) RwStreamClose(stream, &mem); return false; } - // TODO: IFPs -#endif + // TODO(MIAMI): IFP } RwStreamClose(stream, &mem); -#ifndef MIAMI - // We shouldn't even end up here unless load was successful - if(!success){ - ReRequestModel(streamId); - if(streamId < STREAM_OFFSET_TXD) - debug("Failed to load %s.dff\n", mi->GetName()); - else - debug("Failed to load %s.txd\n", CTxdStore::GetTxdName(streamId - STREAM_OFFSET_TXD)); - return false; - } -#endif - if(streamId < STREAM_OFFSET_TXD){ // Model // Vehicles and Peds not in loaded list @@ -648,14 +536,11 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_CANT_REMOVE) == 0) ms_aInfoForModel[streamId].AddToList(&ms_startLoadedList); } -#ifndef MIAMI - }else{ -#else - }else if(streamId >= STREAM_OFFSET_TXD && streamId < STREAM_OFFSET_COL){ // TODO: animations -#endif + }else if(streamId >= STREAM_OFFSET_TXD && streamId < STREAM_OFFSET_COL){ // Txd if((ms_aInfoForModel[streamId].m_flags & STREAMFLAGS_CANT_REMOVE) == 0) ms_aInfoForModel[streamId].AddToList(&ms_startLoadedList); + // TODO(MIAMI): animations } // Mark objects as loaded @@ -667,12 +552,6 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) endTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond(); timeDiff = endTime - startTime; if(timeDiff > 5){ -#ifndef MIAMI - if(streamId < STREAM_OFFSET_TXD) - debug("model %s took %d ms\n", CModelInfo::GetModelInfo(streamId)->GetName(), timeDiff); - else - debug("txd %s took %d ms\n", CTxdStore::GetTxdName(streamId - STREAM_OFFSET_TXD), timeDiff); -#else // TODO: is this inlined? static char objname[32]; if(streamId < STREAM_OFFSET_TXD) @@ -681,9 +560,8 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) sprintf(objname, "%s.txd", CTxdStore::GetTxdName(streamId-STREAM_OFFSET_TXD)); else if(streamId >= STREAM_OFFSET_COL && streamId < NUMSTREAMINFO) sprintf(objname, "%s.col", CColStore::GetColName(streamId-STREAM_OFFSET_COL)); - // TODO: IFP + // TODO(MIAMI): IFP debug("%s took %d ms\n", objname, timeDiff); -#endif } return true; @@ -841,11 +719,7 @@ CStreaming::RequestSubway(void) } } -#ifndef MIAMI -#define BIGBUILDINGFLAGS STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_PRIORITY -#else #define BIGBUILDINGFLAGS STREAMFLAGS_DONT_REMOVE -#endif void CStreaming::RequestBigBuildings(eLevelName level) @@ -857,18 +731,12 @@ CStreaming::RequestBigBuildings(eLevelName level) for(i = n; i >= 0; i--){ b = CPools::GetBuildingPool()->GetSlot(i); if(b && b->bIsBIGBuilding && b->m_level == level) -#ifdef MIAMI if(!b->bStreamBIGBuilding) -#endif - RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS); + RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS); } RequestIslands(level); -#ifndef MIAMI - ms_hasLoadedLODs = false; -#endif } -#ifdef MIAMI void CStreaming::RequestBigBuildings(eLevelName level, const CVector &pos) { @@ -903,7 +771,6 @@ CStreaming::InstanceBigBuildings(eLevelName level, const CVector &pos) b->CreateRwObject(); } } -#endif void CStreaming::RequestIslands(eLevelName level) @@ -1002,20 +869,13 @@ CStreaming::RemoveModel(int32 id) return; if(ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED){ -#ifndef MIAMI - if(id < STREAM_OFFSET_TXD) - CModelInfo::GetModelInfo(id)->DeleteRwObject(); - else - CTxdStore::RemoveTxd(id - STREAM_OFFSET_TXD); -#else if(id < STREAM_OFFSET_TXD) CModelInfo::GetModelInfo(id)->DeleteRwObject(); else if(id >= STREAM_OFFSET_TXD && id < STREAM_OFFSET_COL) CTxdStore::RemoveTxd(id - STREAM_OFFSET_TXD); else if(id >= STREAM_OFFSET_COL && id < NUMSTREAMINFO) CColStore::RemoveCol(id - STREAM_OFFSET_COL); - // TODO: IFP -#endif + // TODO(MIAMI): IFP ms_memoryUsed -= ms_aInfoForModel[id].GetCdSize()*CDSTREAM_SECTOR_SIZE; } @@ -1034,20 +894,13 @@ CStreaming::RemoveModel(int32 id) } if(ms_aInfoForModel[id].m_loadState == STREAMSTATE_STARTED){ -#ifndef MIAMI - if(id < STREAM_OFFSET_TXD) - RpClumpGtaCancelStream(); - else - CTxdStore::RemoveTxd(id - STREAM_OFFSET_TXD); -#else if(id < STREAM_OFFSET_TXD) RpClumpGtaCancelStream(); else if(id >= STREAM_OFFSET_TXD && id < STREAM_OFFSET_COL) CTxdStore::RemoveTxd(id - STREAM_OFFSET_TXD); else if(id >= STREAM_OFFSET_COL && id < NUMSTREAMINFO) CColStore::RemoveCol(id - STREAM_OFFSET_COL); - // TODO: IFP -#endif + // TODO(MIAMI): IFP } ms_aInfoForModel[id].m_loadState = STREAMSTATE_NOTLOADED; @@ -1155,7 +1008,6 @@ DeleteIsland(CEntity *island) void CStreaming::RemoveIslandsNotUsed(eLevelName level) { -#ifdef MIAMI int i; if(pIslandLODindustEntity == nil) for(i = CPools::GetBuildingPool()->GetSize()-1; i >= 0; i--){ @@ -1168,7 +1020,6 @@ CStreaming::RemoveIslandsNotUsed(eLevelName level) if(building->GetModelIndex() == islandLODsubInd) pIslandLODsubIndEntity = building; if(building->GetModelIndex() == islandLODsubCom) pIslandLODsubComEntity = building; } -#endif switch(level){ case LEVEL_INDUSTRIAL: @@ -1400,43 +1251,6 @@ CStreaming::IsObjectInCdImage(int32 id) return ms_aInfoForModel[id].GetCdPosnAndSize(posn, size); } -#ifndef MIAMI -void -CStreaming::HaveAllBigBuildingsLoaded(eLevelName level) -{ - int i, n; - CEntity *e; - - if(ms_hasLoadedLODs) - return; - - if(level == LEVEL_INDUSTRIAL){ - if(ms_aInfoForModel[islandLODcomInd].m_loadState != STREAMSTATE_LOADED || - ms_aInfoForModel[islandLODsubInd].m_loadState != STREAMSTATE_LOADED) - return; - }else if(level == LEVEL_COMMERCIAL){ - if(ms_aInfoForModel[islandLODindust].m_loadState != STREAMSTATE_LOADED || - ms_aInfoForModel[islandLODsubCom].m_loadState != STREAMSTATE_LOADED) - return; - }else if(level == LEVEL_SUBURBAN){ - if(ms_aInfoForModel[islandLODindust].m_loadState != STREAMSTATE_LOADED || - ms_aInfoForModel[islandLODcomSub].m_loadState != STREAMSTATE_LOADED) - return; - } - - n = CPools::GetBuildingPool()->GetSize()-1; - for(i = n; i >= 0; i--){ - e = CPools::GetBuildingPool()->GetSlot(i); - if(e && e->bIsBIGBuilding && e->m_level == level && - ms_aInfoForModel[e->GetModelIndex()].m_loadState != STREAMSTATE_LOADED) - return; - } - - RemoveUnusedBigBuildings(level); - ms_hasLoadedLODs = true; -} -#endif - void CStreaming::SetModelIsDeletable(int32 id) { @@ -1669,7 +1483,6 @@ CStreaming::RemoveCurrentZonesModels(void) ms_loadedGangCars = 0; } -#ifdef MIAMI void CStreaming::LoadBigBuildingsWhenNeeded(void) { @@ -1705,7 +1518,6 @@ CStreaming::LoadBigBuildingsWhenNeeded(void) CTimer::Resume(); DMAudio.SetEffectsFadeVol(127); } -#endif // Find starting offset of the cdimage we next want to read @@ -2235,10 +2047,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float if(xmin < pos.x && pos.x < xmax && ymin < pos.y && pos.y < ymax && (CVector2D(x, y) - pos).MagnitudeSqr() < lodDistSq) -#ifdef GTA_ZONECULL - if(CRenderer::IsEntityCullZoneVisible(e)) -#endif - RequestModel(e->GetModelIndex(), 0); + RequestModel(e->GetModelIndex(), 0); } } } @@ -2261,10 +2070,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list) (!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){ CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex()); if (mi->GetModelType() != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())) -#ifdef GTA_ZONECULL - if(CRenderer::IsEntityCullZoneVisible(e)) -#endif - RequestModel(e->GetModelIndex(), 0); + RequestModel(e->GetModelIndex(), 0); } } } @@ -2687,17 +2493,7 @@ CStreaming::LoadScene(const CVector &pos) RemoveModel(si - ms_aInfoForModel); } CRenderer::m_loadingPriority = false; -#ifdef GTA_ZONECULL - CCullZones::ForceCullZoneCoors(pos); -#endif DeleteAllRwObjects(); -#ifndef MIAMI - AddModelsToRequestList(pos); - CRadar::StreamRadarSections(pos); - RemoveUnusedBigBuildings(level); - RequestBigBuildings(level); - LoadAllRequestedModels(false); -#else if(level == LEVEL_NONE) level = CGame::currLevel; CGame::currLevel = level; @@ -2711,13 +2507,12 @@ CStreaming::LoadScene(const CVector &pos) AddModelsToRequestList(pos); CRadar::StreamRadarSections(pos); - // TODO: stream zone vehicles + // TODO(MIAMI): stream zone vehicles LoadAllRequestedModels(false); - // TODO: InstanceLoadedModels + // TODO(MIAMI): InstanceLoadedModels for(int i = 0; i < NUMSTREAMINFO; i++) ms_aInfoForModel[i].m_flags &= ~STREAMFLAGS_20; -#endif debug("End load scene\n"); } diff --git a/src/core/Streaming.h b/src/core/Streaming.h index d2920824..ba868a54 100644 --- a/src/core/Streaming.h +++ b/src/core/Streaming.h @@ -4,12 +4,8 @@ enum { STREAM_OFFSET_TXD = MODELINFOSIZE, -#ifndef MIAMI - NUMSTREAMINFO = STREAM_OFFSET_TXD+TXDSTORESIZE -#else STREAM_OFFSET_COL = STREAM_OFFSET_TXD+TXDSTORESIZE, NUMSTREAMINFO = STREAM_OFFSET_COL+COLSTORESIZE -#endif }; enum StreamFlags @@ -19,9 +15,7 @@ enum StreamFlags STREAMFLAGS_DEPENDENCY = 0x04, // Is this right? STREAMFLAGS_PRIORITY = 0x08, STREAMFLAGS_NOFADE = 0x10, -#ifdef MIAMI - STREAMFLAGS_20 = 0x20, -#endif + STREAMFLAGS_20 = 0x20, // TODO(MIAMI): what's this STREAMFLAGS_CANT_REMOVE = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED, STREAMFLAGS_KEEP_IN_MEMORY = STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED|STREAMFLAGS_DEPENDENCY, @@ -102,9 +96,6 @@ public: static int32 ms_lastVehicleDeleted; static CDirectory *ms_pExtraObjectsDir; static int32 ms_numPriorityRequests; -#ifndef MIAMI - static bool ms_hasLoadedLODs; -#endif static int32 ms_currentPedGrp; static int32 ms_lastCullZone; static uint16 ms_loadedGangs; @@ -125,28 +116,20 @@ public: static bool FinishLoadingLargeFile(int8 *buf, int32 streamId); static bool HasModelLoaded(int32 id) { return ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED; } static bool HasTxdLoaded(int32 id) { return HasModelLoaded(id+STREAM_OFFSET_TXD); } -#ifdef MIAMI static bool HasColLoaded(int32 id) { return HasModelLoaded(id+STREAM_OFFSET_COL); } -#endif static bool CanRemoveModel(int32 id) { return (ms_aInfoForModel[id].m_flags & STREAMFLAGS_CANT_REMOVE) == 0; } static bool CanRemoveTxd(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_TXD); } -#ifdef MIAMI static bool CanRemoveCol(int32 id) { return CanRemoveModel(id+STREAM_OFFSET_COL); } -#endif static void RequestModel(int32 model, int32 flags); static void ReRequestModel(int32 model) { RequestModel(model, ms_aInfoForModel[model].m_flags); } static void RequestTxd(int32 txd, int32 flags) { RequestModel(txd + STREAM_OFFSET_TXD, flags); } static void ReRequestTxd(int32 txd) { ReRequestModel(txd + STREAM_OFFSET_TXD); } -#ifdef MIAMI static void RequestCol(int32 col, int32 flags) { RequestModel(col + STREAM_OFFSET_COL, flags); } static void ReRequestCol(int32 col) { ReRequestModel(col + STREAM_OFFSET_COL); } -#endif static void RequestSubway(void); static void RequestBigBuildings(eLevelName level); -#ifdef MIAMI static void RequestBigBuildings(eLevelName level, const CVector &pos); static void InstanceBigBuildings(eLevelName level, const CVector &pos); -#endif static void RequestIslands(eLevelName level); static void RequestSpecialModel(int32 modelId, const char *modelName, int32 flags); static void RequestSpecialChar(int32 charId, const char *modelName, int32 flags); @@ -155,9 +138,7 @@ public: static void DecrementRef(int32 id); static void RemoveModel(int32 id); static void RemoveTxd(int32 id) { RemoveModel(id + STREAM_OFFSET_TXD); } -#ifdef MIAMI static void RemoveCol(int32 id) { RemoveModel(id + STREAM_OFFSET_COL); } -#endif static void RemoveUnusedBuildings(eLevelName level); static void RemoveBuildings(eLevelName level); static void RemoveUnusedBigBuildings(eLevelName level); @@ -172,9 +153,6 @@ public: static bool IsTxdUsedByRequestedModels(int32 txdId); static bool AddToLoadedVehiclesList(int32 modelId); static bool IsObjectInCdImage(int32 id); -#ifndef MIAMI - static void HaveAllBigBuildingsLoaded(eLevelName level); -#endif static void SetModelIsDeletable(int32 id); static void SetModelTxdIsDeletable(int32 id); static void SetMissionDoesntRequireModel(int32 id); @@ -183,9 +161,7 @@ public: static void StreamVehiclesAndPeds(void); static void StreamZoneModels(const CVector &pos); static void RemoveCurrentZonesModels(void); -#ifdef MIAMI static void LoadBigBuildingsWhenNeeded(void); -#endif static int32 GetCdImageOffset(int32 lastPosn); static int32 GetNextFileOnCd(int32 position, bool priority); diff --git a/src/core/config.h b/src/core/config.h index c3904fa9..902b0686 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -7,57 +7,44 @@ enum Config { MAX_CDIMAGES = 8, // additional cdimages MAX_CDCHANNELS = 5, -#ifndef MIAMI - MODELINFOSIZE = 5500, - TXDSTORESIZE = 850, -#else MODELINFOSIZE = 6500, TXDSTORESIZE = 1385, COLSTORESIZE = 31, -#endif EXTRADIRSIZE = 128, CUTSCENEDIRSIZE = 512, - SIMPLEMODELSIZE = 5000, - MLOMODELSIZE = 1, - MLOINSTANCESIZE = 1, - TIMEMODELSIZE = 30, + SIMPLEMODELSIZE = 5000, // only 3885 in VC??? + TIMEMODELSIZE = 385, CLUMPMODELSIZE = 5, - PEDMODELSIZE = 90, - VEHICLEMODELSIZE = 120, - XTRACOMPSMODELSIZE = 2, - TWODFXSIZE = 2000, + WEAPONMODELSIZE = 37, + PEDMODELSIZE = 130, + VEHICLEMODELSIZE = 120, // only 110 in VC??? + TWODFXSIZE = 2000, // only 1210 in VC??? MAXVEHICLESLOADED = 50, // 70 on mobile NUMOBJECTINFO = 168, // object.dat // Pool sizes - NUMPTRNODES = 30000, // 26000 on PS2 - NUMENTRYINFOS = 5400, // 3200 on PS2 - NUMPEDS = 140, // 90 on PS2 - NUMVEHICLES = 110, // 70 on PS2 - NUMBUILDINGS = 5500, // 4915 on PS2 - NUMTREADABLES = 1214, - NUMOBJECTS = 450, - NUMDUMMIES = 2802, // 2368 on PS2 - NUMAUDIOSCRIPTOBJECTS = 256, - NUMCUTSCENEOBJECTS = 50, + NUMPTRNODES = 50000, + NUMENTRYINFOS = 5400, // only 3200 in VC??? + NUMPEDS = 140, + NUMVEHICLES = 110, + NUMBUILDINGS = 7000, + NUMTREADABLES = 1214, // 1 in VC + NUMOBJECTS = 460, + NUMDUMMIES = 2802, // 2340 in VC + NUMAUDIOSCRIPTOBJECTS = 256, // 192 in VC + NUMCUTSCENEOBJECTS = 50, // does not exist in VC + // TODO(MIAMI): colmodel pool NUMTEMPOBJECTS = 30, // Path data -#ifndef MIAMI - NUM_PATHNODES = 4930, - NUM_CARPATHLINKS = 2076, - NUM_MAPOBJECTS = 1250, - NUM_PATHCONNECTIONS = 10260, -#else NUM_PATHNODES = 9650, NUM_CARPATHLINKS = 3500, NUM_MAPOBJECTS = 1250, NUM_PATHCONNECTIONS = 20400, -#endif // Link list lengths NUMALPHALIST = 20, @@ -123,11 +110,7 @@ enum Config { NUMMODELSPERPEDGROUP = 8, NUMSHOTINFOS = 100, -#ifndef MIAMI - NUMROADBLOCKS = 600, -#else NUMROADBLOCKS = 300, -#endif NUMVISIBLEENTITIES = 2000, NUMINVISIBLEENTITIES = 150, @@ -160,12 +143,6 @@ enum Config { //#define GTA_PS2 //#define GTA_XBOX -#ifndef MIAMI -#define GTA_TRAIN // This game has trains -#define GTA_BRIDGE // This game has the bridge -#define GTA_ZONECULL // This game culls by zones -#endif - // This enables things from the PS2 version on PC #define GTA_PS2_STUFF diff --git a/src/core/re3.cpp b/src/core/re3.cpp index a74b81a3..739786b5 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -333,8 +333,6 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Render", "Show Ped Paths", &gbShowPedPaths, nil); DebugMenuAddVarBool8("Render", "Show Car Paths", &gbShowCarPaths, nil); DebugMenuAddVarBool8("Render", "Show Car Path Links", &gbShowCarPathsLinks, nil); - DebugMenuAddVarBool8("Render", "Show Ped Road Groups", &gbShowPedRoadGroups, nil); - DebugMenuAddVarBool8("Render", "Show Car Road Groups", &gbShowCarRoadGroups, nil); DebugMenuAddVarBool8("Render", "Show Collision Lines", &gbShowCollisionLines, nil); DebugMenuAddVarBool8("Render", "Show Collision Polys", &gbShowCollisionPolys, nil); DebugMenuAddVarBool8("Render", "Don't render Buildings", &gbDontRenderBuildings, nil); diff --git a/src/core/templates.h b/src/core/templates.h index 74bc4713..44ab566b 100644 --- a/src/core/templates.h +++ b/src/core/templates.h @@ -34,25 +34,20 @@ class CPool int m_allocPtr; public: + // TODO(MIAMI): remove ctor without name argument CPool(int size){ // TODO: use new here m_entries = (U*)malloc(sizeof(U)*size); m_flags = (Flags*)malloc(sizeof(Flags)*size); m_size = size; -#ifndef MIAMI - m_allocPtr = 0; -#else m_allocPtr = -1; -#endif for(int i = 0; i < size; i++){ m_flags[i].id = 0; m_flags[i].free = 1; } } -#ifdef MIAMI CPool(int size, const char *name) : CPool(size) {} -#endif ~CPool() { Flush(); } diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp index 955f32a8..453ee806 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -52,9 +52,7 @@ CEntity::CEntity(void) bRenderScorched = false; bHasBlip = false; bIsBIGBuilding = false; -#ifdef MIAMI bStreamBIGBuilding = false; -#endif bRenderDamaged = false; bBulletProof = false; @@ -63,10 +61,6 @@ CEntity::CEntity(void) bMeleeProof = false; bOnlyDamagedByPlayer = false; bStreamingDontDelete = false; -#ifdef GTA_ZONECULL - bZoneCulled = false; - bZoneCulled2 = false; -#endif bRemoveFromWorld = false; bHasHitWall = false; @@ -153,17 +147,6 @@ CEntity::GetIsOnScreenComplex(void) return TheCamera.IsBoxVisible(boundBox, &TheCamera.GetCameraMatrix()); } -bool -CEntity::GetIsOnScreenAndNotCulled(void) -{ -#ifdef GTA_ZONECULL - return GetIsOnScreen() && CRenderer::IsEntityCullZoneVisible(this); -#else - return GetIsOnScreen(); -#endif -} - - void CEntity::Add(void) { @@ -348,11 +331,9 @@ CEntity::SetupBigBuilding(void) bStreamingDontDelete = true; bUsesCollision = false; m_level = CTheZones::GetLevelFromPosition(GetPosition()); -#ifdef MIAMI if(mi->m_lodDistances[0] <= 2000.0f) bStreamBIGBuilding = true; - // TODO: the stuff down there isn't right yet -#endif + // TODO(MIAMI): the stuff down there isn't right yet if(m_level == LEVEL_NONE){ if(mi->GetTxdSlot() != CTxdStore::FindTxdSlot("generic")){ mi->SetTexDictionary("generic"); @@ -975,10 +956,6 @@ CEntity::SaveEntityFlags(uint8*& buf) if (bMeleeProof) tmp |= BIT(27); if (bOnlyDamagedByPlayer) tmp |= BIT(28); if (bStreamingDontDelete) tmp |= BIT(29); -#ifdef GTA_ZONECULL - if (bZoneCulled) tmp |= BIT(30); - if (bZoneCulled2) tmp |= BIT(31); -#endif WriteSaveBuf<uint32>(buf, tmp); @@ -1030,10 +1007,6 @@ CEntity::LoadEntityFlags(uint8*& buf) bMeleeProof = !!(tmp & BIT(27)); bOnlyDamagedByPlayer = !!(tmp & BIT(28)); bStreamingDontDelete = !!(tmp & BIT(29)); -#ifdef GTA_ZONECULL - bZoneCulled = !!(tmp & BIT(30)); - bZoneCulled2 = !!(tmp & BIT(31)); -#endif tmp = ReadSaveBuf<uint32>(buf); diff --git a/src/entities/Entity.h b/src/entities/Entity.h index 49c6932c..0534de27 100644 --- a/src/entities/Entity.h +++ b/src/entities/Entity.h @@ -59,25 +59,19 @@ public: uint32 bRenderScorched : 1; uint32 bHasBlip : 1; uint32 bIsBIGBuilding : 1; // Set if this entity is a big building -#ifdef MIAMI uint32 bStreamBIGBuilding : 1; // set when draw dist <= 2000 -#endif - uint32 bRenderDamaged : 1; // use damaged LOD models for objects with applicable damage // flagsC + uint32 bRenderDamaged : 1; // use damaged LOD models for objects with applicable damage uint32 bBulletProof : 1; uint32 bFireProof : 1; uint32 bCollisionProof : 1; uint32 bMeleeProof : 1; uint32 bOnlyDamagedByPlayer : 1; uint32 bStreamingDontDelete : 1; // Dont let the streaming remove this -#ifdef GTA_ZONECULL - uint32 bZoneCulled : 1; - uint32 bZoneCulled2 : 1; // only treadables+10m -#endif + uint32 bRemoveFromWorld : 1; // remove this entity next time it should be processed // flagsD - uint32 bRemoveFromWorld : 1; // remove this entity next time it should be processed uint32 bHasHitWall : 1; // has collided with a building (changes subsequent collisions) uint32 bImBeingRendered : 1; // don't delete me because I'm being rendered uint32 bTouchingWater : 1; // used by cBuoyancy::ProcessBuoyancy @@ -85,20 +79,17 @@ public: uint32 bDrawLast : 1; // draw object last uint32 bNoBrightHeadLights : 1; uint32 bDoNotRender : 1; + uint32 bDistanceFade : 1; // Fade entity because it is far away // flagsE - uint32 bDistanceFade : 1; // Fade entity because it is far away uint32 m_flagE2 : 1; + // TODO(MIAMI) uint16 m_scanCode; uint16 m_randomSeed; int16 m_modelIndex; -#ifndef MIAMI - uint16 m_level; // int16 -#else int8 m_level; int8 m_area; -#endif CReference *m_pFirstReference; public: @@ -156,7 +147,6 @@ public: bool GetIsTouching(CVector const ¢er, float r); bool GetIsOnScreen(void); bool GetIsOnScreenComplex(void); - bool GetIsOnScreenAndNotCulled(void); bool IsVisible(void) { return m_rwObject && bIsVisible && GetIsOnScreen(); } bool IsVisibleComplex(void) { return m_rwObject && bIsVisible && GetIsOnScreenComplex(); } int16 GetModelIndex(void) const { return m_modelIndex; } diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index a61aaa78..3f1ec325 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -263,23 +263,11 @@ CPhysical::AddCollisionRecord(CEntity *ent) } } +//--MIAMI: done void CPhysical::AddCollisionRecord_Treadable(CEntity *ent) { if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){ -#ifndef MIAMI - CTreadable *t = (CTreadable*)ent; - if(t->m_nodeIndices[PATH_PED][0] >= 0 || - t->m_nodeIndices[PATH_PED][1] >= 0 || - t->m_nodeIndices[PATH_PED][2] >= 0 || - t->m_nodeIndices[PATH_PED][3] >= 0) - m_treadable[PATH_PED] = t; - if(t->m_nodeIndices[PATH_CAR][0] >= 0 || - t->m_nodeIndices[PATH_CAR][1] >= 0 || - t->m_nodeIndices[PATH_CAR][2] >= 0 || - t->m_nodeIndices[PATH_CAR][3] >= 0) - m_treadable[PATH_CAR] = t; -#endif } } diff --git a/src/entities/Treadable.h b/src/entities/Treadable.h index 78f69c8a..c3ab755e 100644 --- a/src/entities/Treadable.h +++ b/src/entities/Treadable.h @@ -8,12 +8,5 @@ public: static void *operator new(size_t); static void operator delete(void*, size_t); -#ifndef MIAMI - int16 m_nodeIndices[2][12]; // first car, then ped -#endif - bool GetIsATreadable(void) { return true; } }; -#ifndef MIAMI -static_assert(sizeof(CTreadable) == 0x94, "CTreadable: error"); -#endif diff --git a/src/modelinfo/MloModelInfo.cpp b/src/modelinfo/MloModelInfo.cpp deleted file mode 100644 index 7535e6c5..00000000 --- a/src/modelinfo/MloModelInfo.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "common.h" - -#include "VisibilityPlugins.h" -#include "ModelInfo.h" - -void -CMloModelInfo::ConstructClump() -{ - m_clump = RpClumpCreate(); - RwFrame *mainFrame = RwFrameCreate(); - RwFrameSetIdentity(mainFrame); - RpClumpSetFrame(m_clump, mainFrame); - - for (int i = firstInstance; i < lastInstance; i++) { - int modelId = CModelInfo::GetMloInstanceStore().store[i].m_modelIndex; - RwMatrix *attMat = CModelInfo::GetMloInstanceStore().store[i].GetMatrix().m_attachment; - CSimpleModelInfo *minfo = (CSimpleModelInfo*)CModelInfo::GetModelInfo(modelId); - - if (minfo->m_atomics[0] != nil) { - RpAtomic *newAtomic = RpAtomicClone(minfo->m_atomics[0]); - RwFrame *newFrame = RwFrameCreate(); - if (newAtomic != nil && newFrame != nil) { - *RwFrameGetMatrix(newFrame) = *attMat; - RpAtomicSetFrame(newAtomic, newFrame); - RwFrameAddChild(mainFrame, newFrame); - RpClumpAddAtomic(m_clump, newAtomic); - } else { - debug("Failed to allocate memory while creating template MLO.\n"); - } - } - } - - if (RpClumpGetNumAtomics(m_clump) != 0) { - CVisibilityPlugins::SetClumpModelInfo(m_clump, this); - } else { - RpClumpDestroy(m_clump); - m_clump = nil; - } -}
\ No newline at end of file diff --git a/src/modelinfo/MloModelInfo.h b/src/modelinfo/MloModelInfo.h deleted file mode 100644 index d4344706..00000000 --- a/src/modelinfo/MloModelInfo.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "ClumpModelInfo.h" - -class CMloModelInfo : public CClumpModelInfo -{ -public: - float field_34; // draw distance? - int firstInstance; - int lastInstance; -public: - CMloModelInfo(void) : CClumpModelInfo(MITYPE_MLO) {} - void ConstructClump(); -};
\ No newline at end of file diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp index 62deae2b..79353b1b 100644 --- a/src/modelinfo/ModelInfo.cpp +++ b/src/modelinfo/ModelInfo.cpp @@ -8,13 +8,10 @@ CBaseModelInfo *CModelInfo::ms_modelInfoPtrs[MODELINFOSIZE]; CStore<CSimpleModelInfo, SIMPLEMODELSIZE> CModelInfo::ms_simpleModelStore; -CStore<CMloModelInfo, MLOMODELSIZE> CModelInfo::ms_mloModelStore; -CStore<CInstance, MLOINSTANCESIZE> CModelInfo::ms_mloInstanceStore; CStore<CTimeModelInfo, TIMEMODELSIZE> CModelInfo::ms_timeModelStore; CStore<CClumpModelInfo, CLUMPMODELSIZE> CModelInfo::ms_clumpModelStore; CStore<CPedModelInfo, PEDMODELSIZE> CModelInfo::ms_pedModelStore; CStore<CVehicleModelInfo, VEHICLEMODELSIZE> CModelInfo::ms_vehicleModelStore; -CStore<CXtraCompsModelInfo, XTRACOMPSMODELSIZE> CModelInfo::ms_xtraCompsModelStore; CStore<C2dEffect, TWODFXSIZE> CModelInfo::ms_2dEffectStore; void @@ -26,11 +23,8 @@ CModelInfo::Initialise(void) for(i = 0; i < MODELINFOSIZE; i++) ms_modelInfoPtrs[i] = nil; ms_2dEffectStore.clear(); - ms_mloInstanceStore.clear(); - ms_xtraCompsModelStore.clear(); ms_simpleModelStore.clear(); ms_timeModelStore.clear(); - ms_mloModelStore.clear(); ms_clumpModelStore.clear(); ms_pedModelStore.clear(); ms_vehicleModelStore.clear(); @@ -90,8 +84,6 @@ CModelInfo::ShutDown(void) int i; for(i = 0; i < ms_simpleModelStore.allocPtr; i++) ms_simpleModelStore.store[i].Shutdown(); - for(i = 0; i < ms_mloInstanceStore.allocPtr; i++) - ms_mloInstanceStore.store[i].Shutdown(); for(i = 0; i < ms_timeModelStore.allocPtr; i++) ms_timeModelStore.store[i].Shutdown(); for(i = 0; i < ms_clumpModelStore.allocPtr; i++) @@ -100,18 +92,11 @@ CModelInfo::ShutDown(void) ms_vehicleModelStore.store[i].Shutdown(); for(i = 0; i < ms_pedModelStore.allocPtr; i++) ms_pedModelStore.store[i].Shutdown(); - for(i = 0; i < ms_xtraCompsModelStore.allocPtr; i++) - ms_xtraCompsModelStore.store[i].Shutdown(); - for(i = 0; i < ms_mloInstanceStore.allocPtr; i++) - ms_mloInstanceStore.store[i].Shutdown(); for(i = 0; i < ms_2dEffectStore.allocPtr; i++) ms_2dEffectStore.store[i].Shutdown(); ms_2dEffectStore.clear(); ms_simpleModelStore.clear(); - ms_mloInstanceStore.clear(); - ms_mloModelStore.clear(); - ms_xtraCompsModelStore.clear(); ms_timeModelStore.clear(); ms_pedModelStore.clear(); ms_clumpModelStore.clear(); @@ -128,18 +113,6 @@ CModelInfo::AddSimpleModel(int id) return modelinfo; } -CMloModelInfo * -CModelInfo::AddMloModel(int id) -{ - CMloModelInfo *modelinfo; - modelinfo = CModelInfo::ms_mloModelStore.alloc(); - CModelInfo::ms_modelInfoPtrs[id] = modelinfo; - modelinfo->m_clump = nil; - modelinfo->firstInstance = 0; - modelinfo->lastInstance = 0; - return modelinfo; -} - CTimeModelInfo* CModelInfo::AddTimeModel(int id) { @@ -200,7 +173,6 @@ CModelInfo::GetModelInfo(const char *name, int *id) return nil; } -#ifdef MIAMI CBaseModelInfo* CModelInfo::GetModelInfo(const char *name, int minIndex, int maxIndex) { @@ -212,7 +184,6 @@ CModelInfo::GetModelInfo(const char *name, int minIndex, int maxIndex) } return nil; } -#endif bool CModelInfo::IsBoatModel(int32 id) @@ -228,32 +199,6 @@ CModelInfo::IsBikeModel(int32 id) ((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BIKE; } -#ifndef MIAMI -void -CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level) -{ - int i; - CBaseModelInfo *mi; - CColModel *colmodel; - - for(i = 0; i < MODELINFOSIZE; i++){ - mi = GetModelInfo(i); - if(mi){ - colmodel = mi->GetColModel(); - if(colmodel && colmodel->level != LEVEL_NONE && colmodel->level != level) - colmodel->RemoveCollisionVolumes(); - } - } -} -#endif - -void -CModelInfo::ConstructMloClumps() -{ - for (int i = 0; i < ms_mloModelStore.allocPtr; i++) - ms_mloModelStore.store[i].ConstructClump(); -} - void CModelInfo::ReInit2dEffects() { diff --git a/src/modelinfo/ModelInfo.h b/src/modelinfo/ModelInfo.h index dadc8f8b..46f8c117 100644 --- a/src/modelinfo/ModelInfo.h +++ b/src/modelinfo/ModelInfo.h @@ -3,52 +3,41 @@ #include "2dEffect.h" #include "BaseModelInfo.h" #include "SimpleModelInfo.h" -#include "MloModelInfo.h" #include "TimeModelInfo.h" #include "ClumpModelInfo.h" #include "PedModelInfo.h" #include "VehicleModelInfo.h" -#include "XtraCompsModelInfo.h" #include "Instance.h" class CModelInfo { static CBaseModelInfo *ms_modelInfoPtrs[MODELINFOSIZE]; static CStore<CSimpleModelInfo, SIMPLEMODELSIZE> ms_simpleModelStore; - static CStore<CMloModelInfo, MLOMODELSIZE> ms_mloModelStore; - static CStore<CInstance, MLOINSTANCESIZE> ms_mloInstanceStore; static CStore<CTimeModelInfo, TIMEMODELSIZE> ms_timeModelStore; static CStore<CClumpModelInfo, CLUMPMODELSIZE> ms_clumpModelStore; static CStore<CPedModelInfo, PEDMODELSIZE> ms_pedModelStore; static CStore<CVehicleModelInfo, VEHICLEMODELSIZE> ms_vehicleModelStore; static CStore<C2dEffect, TWODFXSIZE> ms_2dEffectStore; - static CStore<CXtraCompsModelInfo, XTRACOMPSMODELSIZE> ms_xtraCompsModelStore; public: static void Initialise(void); static void ShutDown(void); static CSimpleModelInfo *AddSimpleModel(int id); - static CMloModelInfo *AddMloModel(int id); static CTimeModelInfo *AddTimeModel(int id); static CClumpModelInfo *AddClumpModel(int id); static CPedModelInfo *AddPedModel(int id); static CVehicleModelInfo *AddVehicleModel(int id); static CStore<C2dEffect, TWODFXSIZE> &Get2dEffectStore(void) { return ms_2dEffectStore; } - static CStore<CInstance, MLOINSTANCESIZE> &GetMloInstanceStore(void) { return ms_mloInstanceStore; } static CBaseModelInfo *GetModelInfo(const char *name, int *id); static CBaseModelInfo *GetModelInfo(int id){ return ms_modelInfoPtrs[id]; } -#ifdef MIAMI static CBaseModelInfo *GetModelInfo(const char *name, int minIndex, int maxIndex); -#endif static bool IsBoatModel(int32 id); static bool IsBikeModel(int32 id); - static void RemoveColModelsFromOtherLevels(eLevelName level); - static void ConstructMloClumps(); static void ReInit2dEffects(); }; diff --git a/src/modelinfo/SimpleModelInfo.cpp b/src/modelinfo/SimpleModelInfo.cpp index 63b057da..424fb0e5 100644 --- a/src/modelinfo/SimpleModelInfo.cpp +++ b/src/modelinfo/SimpleModelInfo.cpp @@ -130,7 +130,6 @@ CSimpleModelInfo::GetAtomicFromDistance(float dist) return nil; } -#ifdef MIAMI RpAtomic* CSimpleModelInfo::GetFirstAtomicFromDistance(float dist) { @@ -138,7 +137,6 @@ CSimpleModelInfo::GetFirstAtomicFromDistance(float dist) return m_atomics[0]; return nil; } -#endif void CSimpleModelInfo::FindRelatedModel(void) diff --git a/src/modelinfo/SimpleModelInfo.h b/src/modelinfo/SimpleModelInfo.h index 451a9c00..403e2969 100644 --- a/src/modelinfo/SimpleModelInfo.h +++ b/src/modelinfo/SimpleModelInfo.h @@ -40,9 +40,7 @@ public: float GetNearDistance(void); float GetLargestLodDistance(void); RpAtomic *GetAtomicFromDistance(float dist); -#ifdef MIAMI - RpAtomic *GetFirstAtomicFromDistance(float dist); // inline -#endif + RpAtomic *GetFirstAtomicFromDistance(float dist); void FindRelatedModel(void); void SetupBigBuilding(void); diff --git a/src/modelinfo/XtraCompsModelInfo.h b/src/modelinfo/XtraCompsModelInfo.h deleted file mode 100644 index 9832399c..00000000 --- a/src/modelinfo/XtraCompsModelInfo.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "ClumpModelInfo.h" - -class CXtraCompsModelInfo : public CClumpModelInfo -{ - int field_34; -public: - CXtraCompsModelInfo(void) : CClumpModelInfo(MITYPE_XTRACOMPS) { field_34 = 0; } - void SetClump(RpClump*) {}; - void Shutdown(void) {}; -};
\ No newline at end of file diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index 3c25d827..1d6782fc 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -187,11 +187,6 @@ CCivilianPed::CivilianAI(void) void CCivilianPed::ProcessControl(void) { -#ifndef MIAMI - if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory) - return; -#endif - CPed::ProcessControl(); if (bWasPostponed) diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index 7140af76..0c78279e 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -425,14 +425,9 @@ CCopPed::CopAI(void) #ifdef VC_PED_PORTS float dotProd; if (m_nRoadblockNode != -1) { -#ifndef MIAMI - CTreadable *roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_nRoadblockNode]]; - dotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockRoad->GetPosition(), GetPosition() - roadBlockRoad->GetPosition()); -#else - // TODO: check this, i'm only getting this compile here.... + // TODO(MIAMI): check this, i'm only getting this compile here.... CPathNode *roadBlockNode = &ThePaths.m_pathNodes[CRoadBlocks::RoadBlockNodes[m_nRoadblockNode]]; dotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockNode->GetPosition(), GetPosition() - roadBlockNode->GetPosition()); -#endif } else dotProd = -1.0f; @@ -565,11 +560,6 @@ CCopPed::CopAI(void) void CCopPed::ProcessControl(void) { -#ifndef MIAMI - if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory) - return; -#endif - CPed::ProcessControl(); if (bWasPostponed) return; @@ -717,7 +707,7 @@ CCopPed::ProcessControl(void) return; bool dontShoot = false; - if (GetIsOnScreenAndNotCulled()) { + if (GetIsOnScreen()) { if (((CTimer::GetFrameCounter() + m_randomSeed) & 0x1F) == 17) { CEntity *foundBuilding = nil; CColPoint foundCol; diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp index e85cfc8b..38ea4bef 100644 --- a/src/peds/EmergencyPed.cpp +++ b/src/peds/EmergencyPed.cpp @@ -44,11 +44,6 @@ CEmergencyPed::InRange(CPed *victim) void CEmergencyPed::ProcessControl(void) { -#ifndef MIAMI - if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory) - return; -#endif - CPed::ProcessControl(); if (bWasPostponed) return; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 04b62e46..2048d805 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -9397,11 +9397,6 @@ CPed::ProcessControl(void) CColPoint foundCol; CEntity *foundEnt = nil; -#ifndef MIAMI - if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory) - return; -#endif - int alpha = CVisibilityPlugins::GetClumpAlpha(GetClump()); if (!bFadeOut) { if (alpha < 255) { diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index fed607ed..f794e1b6 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -858,90 +858,6 @@ CPopulation::AddPedInCar(CVehicle* car) void CPopulation::MoveCarsAndPedsOutOfAbandonedZones() { -#ifndef MIAMI - eLevelName level; - int zone; - int frame = CTimer::GetFrameCounter() & 7; - if (frame == 1) { - int movedVehicleCount = 0; - int poolSize = CPools::GetVehiclePool()->GetSize(); - for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { - - CVehicle* veh = CPools::GetVehiclePool()->GetSlot(poolIndex); - if (veh && veh->m_nZoneLevel == LEVEL_NONE && veh->IsCar()) { - - if(veh->GetStatus() != STATUS_ABANDONED && veh->GetStatus() != STATUS_WRECKED && veh->GetStatus() != STATUS_PLAYER && - veh->GetStatus() != STATUS_PLAYER_REMOTE) { - - CVector vehPos(veh->GetPosition()); - CPopulation::FindCollisionZoneForCoors(&vehPos, &zone, &level); - - // Level 0 is transition zones, and we don't wanna touch cars on transition zones. - if (level != LEVEL_NONE && level != CCollision::ms_collisionInMemory && vehPos.z > -4.0f) { - if (veh->bIsLocked || !veh->CanBeDeleted()) { - switch (movedVehicleCount & 3) { - case 0: - veh->SetPosition(RegenerationPoint_a); - break; - case 1: - veh->SetPosition(RegenerationPoint_b); - break; - case 2: - veh->SetPosition(RegenerationPoint_a.x, RegenerationPoint_b.y, RegenerationPoint_a.z); - break; - case 3: - veh->SetPosition(RegenerationPoint_b.x, RegenerationPoint_a.y, RegenerationPoint_a.z); - break; - default: - break; - } - veh->GetMatrix().GetPosition().z += (movedVehicleCount / 4) * 7.0f; - veh->GetMatrix().GetForward() = RegenerationForward; - ((CAutomobile*)veh)->PlaceOnRoadProperly(); - CCarCtrl::JoinCarWithRoadSystem(veh); - CTheScripts::ClearSpaceForMissionEntity(veh->GetPosition(), veh); - ++movedVehicleCount; - } else { - CWorld::Remove(veh); - delete veh; - } - } - } - } - } - } else if (frame == 5) { - int poolSize = CPools::GetPedPool()->GetSize(); - for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) { - - CPed *ped = CPools::GetPedPool()->GetSlot(poolIndex); - if (ped && ped->m_nZoneLevel == LEVEL_NONE && !ped->bInVehicle) { - - CVector pedPos(ped->GetPosition()); - CPopulation::FindCollisionZoneForCoors(&pedPos, &zone, &level); - - // Level 0 is transition zones, and we don't wanna touch peds on transition zones. - if (level != LEVEL_NONE && level != CCollision::ms_collisionInMemory && pedPos.z > -4.0f) { - if (ped->CanBeDeleted()) { - CWorld::Remove(ped); - delete ped; - } else if (ped->m_nPedType != PEDTYPE_PLAYER1 && ped->m_nPedType != PEDTYPE_PLAYER2) { - ped->SetPosition(RegenerationPoint_a); - - bool foundGround; - float groundZ = CWorld::FindGroundZFor3DCoord(ped->GetPosition().x, ped->GetPosition().y, - ped->GetPosition().z + 2.0f, &foundGround); - - if (foundGround) { - ped->GetMatrix().GetPosition().z = 1.0f + groundZ; - //ped->GetPosition().z += 0.0f; - CTheScripts::ClearSpaceForMissionEntity(ped->GetPosition(), ped); - } - } - } - } - } - } -#endif } void diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 03bc175a..10a551fb 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -20,8 +20,6 @@ #include "PointLights.h" #include "Renderer.h" -bool gbShowPedRoadGroups; -bool gbShowCarRoadGroups; bool gbShowCollisionPolys; bool gbShowCollisionLines; bool gbShowCullZoneDebugStuff; @@ -193,23 +191,7 @@ CRenderer::RenderRoads(void) for(i = 0; i < ms_nNoOfVisibleEntities; i++){ t = (CTreadable*)ms_aVisibleEntityPtrs[i]; if(t->IsBuilding() && t->GetIsATreadable()){ -#ifndef MASTER -#ifndef MIAMI - if(gbShowCarRoadGroups || gbShowPedRoadGroups){ - int ind = 0; - if(gbShowCarRoadGroups) - ind += ThePaths.m_pathNodes[t->m_nodeIndices[PATH_CAR][0]].group; - if(gbShowPedRoadGroups) - ind += ThePaths.m_pathNodes[t->m_nodeIndices[PATH_PED][0]].group; - SetAmbientColoursToIndicateRoadGroup(ind); - } -#endif -#endif RenderOneRoad(t); -#ifndef MASTER - if(gbShowCarRoadGroups || gbShowPedRoadGroups) - ReSetAmbientAndDirectionalColours(); -#endif } } } @@ -328,153 +310,6 @@ enum Visbility int32 CRenderer::SetupEntityVisibility(CEntity *ent) { -#ifndef MIAMI - CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->m_modelIndex); - CTimeModelInfo *ti; - int32 other; - float dist; - - bool request = true; - if (mi->GetModelType() == MITYPE_TIME) { - ti = (CTimeModelInfo*)mi; - other = ti->GetOtherTimeModel(); - if(CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff())){ - // don't fade in, or between time objects - if(CANTIMECULL) - ti->m_alpha = 255; - }else{ - // Hide if possible - if(CANTIMECULL) - return VIS_INVISIBLE; - // can't cull, so we'll try to draw this one, but don't request - // it since what we really want is the other one. - request = false; - } - }else{ - if (mi->GetModelType() != MITYPE_SIMPLE) { - if(FindPlayerVehicle() == ent && - TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON){ - // Player's vehicle in first person mode - if(TheCamera.Cams[TheCamera.ActiveCam].DirectionWasLooking == LOOKING_FORWARD || - ent->GetModelIndex() == MI_RHINO || - ent->GetModelIndex() == MI_COACH || - TheCamera.m_bInATunnelAndABigVehicle){ - ent->bNoBrightHeadLights = true; - }else{ - m_pFirstPersonVehicle = (CVehicle*)ent; - ent->bNoBrightHeadLights = false; - } - return VIS_OFFSCREEN; - }else{ - // All sorts of Clumps - if(ent->m_rwObject == nil || !ent->bIsVisible) - return VIS_INVISIBLE; - if(!ent->GetIsOnScreen()) - return VIS_OFFSCREEN; - if(ent->bDrawLast){ - dist = (ent->GetPosition() - ms_vecCameraPosition).Magnitude(); - CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist); - ent->bDistanceFade = false; - return VIS_INVISIBLE; - }else - return VIS_VISIBLE; - } - return VIS_INVISIBLE; - } - if(ent->IsObject() && - ((CObject*)ent)->ObjectCreatedBy == TEMP_OBJECT){ - if(ent->m_rwObject == nil || !ent->bIsVisible) - return VIS_INVISIBLE; - return ent->GetIsOnScreen() ? VIS_VISIBLE : VIS_OFFSCREEN; - } - } - - // Simple ModelInfo - - dist = (ent->GetPosition() - ms_vecCameraPosition).Magnitude(); - - // This can only happen with multi-atomic models (e.g. railtracks) - // but why do we bump up the distance? can only be fading... - if(LOD_DISTANCE + STREAM_DISTANCE < dist && dist < mi->GetLargestLodDistance()) - dist = mi->GetLargestLodDistance(); - - if(ent->IsObject() && ent->bRenderDamaged) - mi->m_isDamaged = true; - - RpAtomic *a = mi->GetAtomicFromDistance(dist); - if(a){ - mi->m_isDamaged = false; - if(ent->m_rwObject == nil) - ent->CreateRwObject(); - assert(ent->m_rwObject); - RpAtomic *rwobj = (RpAtomic*)ent->m_rwObject; - // Make sure our atomic uses the right geometry and not - // that of an atomic for another draw distance. - if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj)) - RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?) - mi->IncreaseAlpha(); - if(ent->m_rwObject == nil || !ent->bIsVisible) - return VIS_INVISIBLE; - - if(!ent->GetIsOnScreen()){ - mi->m_alpha = 255; - return VIS_OFFSCREEN; - } - - if(mi->m_alpha != 255){ - CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist); - ent->bDistanceFade = true; - return VIS_INVISIBLE; - } - - if(mi->m_drawLast || ent->bDrawLast){ - CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist); - ent->bDistanceFade = false; - return VIS_INVISIBLE; - } - return VIS_VISIBLE; - } - - // Object is not loaded, figure out what to do - - if(mi->m_noFade){ - mi->m_isDamaged = false; - // request model - if(dist - STREAM_DISTANCE < mi->GetLargestLodDistance() && request) - return VIS_STREAMME; - return VIS_INVISIBLE; - } - - // We might be fading - - a = mi->GetAtomicFromDistance(dist - FADE_DISTANCE); - mi->m_isDamaged = false; - if(a == nil){ - // request model - if(dist - FADE_DISTANCE - STREAM_DISTANCE < mi->GetLargestLodDistance() && request) - return VIS_STREAMME; - return VIS_INVISIBLE; - } - - if(ent->m_rwObject == nil) - ent->CreateRwObject(); - assert(ent->m_rwObject); - RpAtomic *rwobj = (RpAtomic*)ent->m_rwObject; - if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj)) - RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?) - mi->IncreaseAlpha(); - if(ent->m_rwObject == nil || !ent->bIsVisible) - return VIS_INVISIBLE; - - if(!ent->GetIsOnScreen()){ - mi->m_alpha = 255; - return VIS_OFFSCREEN; - }else{ - CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist); - ent->bDistanceFade = true; - return VIS_OFFSCREEN; // Why this? - } -#else CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->m_modelIndex); CTimeModelInfo *ti; int32 other; @@ -625,95 +460,11 @@ CRenderer::SetupEntityVisibility(CEntity *ent) ent->bDistanceFade = true; return VIS_OFFSCREEN; // Why this? } -#endif } int32 CRenderer::SetupBigBuildingVisibility(CEntity *ent) { -#ifndef MIAMI - CSimpleModelInfo *mi = (CSimpleModelInfo *)CModelInfo::GetModelInfo(ent->GetModelIndex()); - CTimeModelInfo *ti; - int32 other; - - if (mi->GetModelType() == MITYPE_TIME) { - ti = (CTimeModelInfo*)mi; - other = ti->GetOtherTimeModel(); - // Hide objects not in time range if possible - if(CANTIMECULL) - if(!CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff())) - return VIS_INVISIBLE; - // Draw like normal - } else if (mi->GetModelType() == MITYPE_VEHICLE) - return ent->IsVisible() ? VIS_VISIBLE : VIS_INVISIBLE; - - float dist = (ms_vecCameraPosition-ent->GetPosition()).Magnitude(); - CSimpleModelInfo *nonLOD = mi->GetRelatedModel(); - - // Find out whether to draw below near distance. - // This is only the case if there is a non-LOD which is either not - // loaded or not completely faded in yet. - if(dist < mi->GetNearDistance() && dist < LOD_DISTANCE + STREAM_DISTANCE){ - // No non-LOD or non-LOD is completely visible. - if(nonLOD == nil || - nonLOD->GetRwObject() && nonLOD->m_alpha == 255) - return VIS_INVISIBLE; - - // But if it is a time object, we'd rather draw the wrong - // non-LOD than the right LOD. - if (nonLOD->GetModelType() == MITYPE_TIME) { - ti = (CTimeModelInfo*)nonLOD; - other = ti->GetOtherTimeModel(); - if(other != -1 && CModelInfo::GetModelInfo(other)->GetRwObject()) - return VIS_INVISIBLE; - } - } - - RpAtomic *a = mi->GetAtomicFromDistance(dist); - if(a){ - if(ent->m_rwObject == nil) - ent->CreateRwObject(); - assert(ent->m_rwObject); - RpAtomic *rwobj = (RpAtomic*)ent->m_rwObject; - - // Make sure our atomic uses the right geometry and not - // that of an atomic for another draw distance. - if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj)) - RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?) - if(!ent->IsVisibleComplex()) - return VIS_INVISIBLE; - if(mi->m_drawLast){ - CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist); - ent->bDistanceFade = false; - return VIS_INVISIBLE; - } - return VIS_VISIBLE; - } - - if(mi->m_noFade){ - ent->DeleteRwObject(); - return VIS_INVISIBLE; - } - - - // get faded atomic - a = mi->GetAtomicFromDistance(dist - FADE_DISTANCE); - if(a == nil){ - ent->DeleteRwObject(); - return VIS_INVISIBLE; - } - - // Fade... - if(ent->m_rwObject == nil) - ent->CreateRwObject(); - assert(ent->m_rwObject); - RpAtomic *rwobj = (RpAtomic*)ent->m_rwObject; - if(RpAtomicGetGeometry(a) != RpAtomicGetGeometry(rwobj)) - RpAtomicSetGeometry(rwobj, RpAtomicGetGeometry(a), rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?) - if(ent->IsVisibleComplex()) - CVisibilityPlugins::InsertEntityIntoSortedList(ent, dist); - return VIS_INVISIBLE; -#else CSimpleModelInfo *mi = (CSimpleModelInfo*)CModelInfo::GetModelInfo(ent->m_modelIndex); CTimeModelInfo *ti; int32 other; @@ -827,7 +578,6 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent) }else mi->m_alpha = 255; return VIS_INVISIBLE; -#endif } void @@ -974,11 +724,7 @@ CRenderer::ScanWorld(void) } ScanSectorPoly(poly, 3, ScanSectorList); -#ifndef MIAMI - ScanBigBuildingList(CWorld::GetBigBuildingList(CCollision::ms_collisionInMemory)); -#else ScanBigBuildingList(CWorld::GetBigBuildingList(CGame::currLevel)); -#endif ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_NONE)); } } @@ -1223,13 +969,6 @@ CRenderer::ScanBigBuildingList(CPtrList &list) CPtrNode *node; CEntity *ent; -#ifndef MIAMI - for(node = list.first; node; node = node->next){ - ent = (CEntity*)node->item; - if(!ent->bZoneCulled && SetupBigBuildingVisibility(ent) == VIS_VISIBLE) - ms_aVisibleEntityPtrs[ms_nNoOfVisibleEntities++] = ent; - } -#else // TODO(MIAMI): some flags and such for(node = list.first; node; node = node->next){ ent = (CEntity*)node->item; @@ -1243,7 +982,6 @@ CRenderer::ScanBigBuildingList(CPtrList &list) break; } } -#endif } void diff --git a/src/render/Renderer.h b/src/render/Renderer.h index e28995c3..5bf211e4 100644 --- a/src/render/Renderer.h +++ b/src/render/Renderer.h @@ -2,8 +2,6 @@ class CEntity; -extern bool gbShowPedRoadGroups; -extern bool gbShowCarRoadGroups; extern bool gbShowCollisionPolys; extern bool gbShowCollisionLines; extern bool gbShowCullZoneDebugStuff; diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index b1a101e3..5b7d1b05 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -615,16 +615,6 @@ CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump) } bool -CVisibilityPlugins::MloVisibilityCB(RpClump *clump) -{ - RwFrame *frame = RpClumpGetFrame(clump); - CMloModelInfo *modelInfo = (CMloModelInfo*)GetFrameHierarchyId(frame); - if (sq(modelInfo->field_34) < GetDistanceSquaredFromCamera(frame)) - return false; - return CVisibilityPlugins::FrustumSphereCB(clump); -} - -bool CVisibilityPlugins::FrustumSphereCB(RpClump *clump) { RwSphere sphere; diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index c22a060c..68c0821a 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -543,13 +543,6 @@ RestoreForStartLoad() ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().z); CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel); -#ifndef MIAMI - CCollision::SortOutCollisionAfterLoad(); - CStreaming::RequestBigBuildings(CGame::currLevel); - CStreaming::LoadAllRequestedModels(false); - CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel); - CGame::TidyUpMemory(true, false); -#endif if (CloseFile(file)) { return true; diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 602eb589..8b267c09 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -229,12 +229,6 @@ CAutomobile::ProcessControl(void) colModel = GetColModel(); bWarnedPeds = false; -#ifndef MIAMI - // skip if the collision isn't for the current level - if(colModel->level > LEVEL_NONE && colModel->level != CCollision::ms_collisionInMemory) - return; -#endif - // Improve grip of vehicles in certain cases bool strongGrip1 = false; bool strongGrip2 = false; diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index ecf760e4..2a33d68a 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -109,11 +109,6 @@ CBoat::GetComponentWorldPosition(int32 component, CVector &pos) void CBoat::ProcessControl(void) { -#ifndef MIAMI - if(m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory) - return; -#endif - bool onLand = m_fDamageImpulse > 0.0f && m_vecDamageNormal.z > 0.1f; PruneWakeTrail(); diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index efbc56c0..2baa9218 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -99,9 +99,7 @@ CVehicle::CVehicle(uint8 CreatedBy) m_bSirenOrAlarm = 0; m_nCarHornTimer = 0; m_nCarHornPattern = 0; -#ifdef MIAMI bParking = false; -#endif m_nAlarmState = 0; m_nDoorLock = CARLOCK_UNLOCKED; m_nLastWeaponDamage = -1; @@ -121,9 +119,7 @@ CVehicle::CVehicle(uint8 CreatedBy) AutoPilot.m_nTimeToStartMission = CTimer::GetTimeInMilliseconds(); AutoPilot.m_bStayInCurrentLevel = false; AutoPilot.m_bIgnorePathfinding = false; -#ifdef MIAMI AutoPilot.m_nSwitchDistance = 20; -#endif } CVehicle::~CVehicle() |