#include #include #include #include #include #include #include #include #include namespace Obj { CPathObjectTracker *CPathMan::TrackObject(CCompositeObject *p_ob, int node_number) { Script::CStruct *p_node=SkateScript::GetNode(node_number); #ifdef __NOPT_ASSERT__ Dbg_MsgAssert(p_node,("NULL p_node for node %d",node_number)); #endif int path_number=0; if (!p_node->GetInteger("PathNum",&path_number)) { Dbg_MsgAssert(0,("Node %d does not contain a PathNum",node_number)); } Dbg_MsgAssert(path_number>=0 && path_numberGetInteger("PathNum",&path_number)) { Dbg_MsgAssert(0,("Node %d does not contain a PathNum",node_number)); } // Dbg_MsgAssert(path_number>=0 && path_numbermNodeNameChecksum)); for (int i=0; iGetSize(); for ( uint16 i = 0; i < array_size; ++i ) { Script::CStruct *p_start_node=p_node_array->GetStructure( i ); // Rail nodes are linked into a path, but don't need path numbers, so don't bother // adding them to save memory. uint32 class_type=0; p_start_node->GetChecksum( CRCD(0x12b4e660,"Class"), &class_type ); if ( class_type == CRCD( 0x8e6b02ad, "RailNode" ) || class_type == CRCD(0x30c19600, "ClimbingNode") ) { continue; } // make sure this isn't a pedai waypoint uint32 type; if ( class_type == CRCD( 0x4c23a77e, "Waypoint" ) && p_start_node->GetChecksum( CRCD( 0x7321a8d6, "type" ), &type, Script::NO_ASSERT ) && type == CRCD( 0xcba10ffa, "PedAI" ) ) { continue; } int num_links=SkateScript::GetNumLinks( p_start_node ); int node_path_number = 0; // Check if the node is linked to something, and has not already had a PathNum // given to it. if ( ( num_links || class_type == CRCD( 0x4c23a77e, "WayPoint" ) ) && !p_start_node->ContainsComponentNamed( CRCD( 0x9c91c3ca, "PathNum" ) ) ) { // printf("found a non PedAI waypoint\n"); // The node and subsequent nodes that it is linked to require a PathNum Script::CStruct *p_node=p_start_node; // The path number that is going to be written in is m_num_paths to start with, // but that might change if we hit a node that already has a path number. In that // case we'll rewind and write that number in instead. int path_number_to_write=m_num_paths; while (true) { if (p_node->GetInteger( CRCD( 0x9c91c3ca, "PathNum" ),&node_path_number)) { // We've hit a node that has already had a PathNum written in. if (node_path_number==path_number_to_write) { // The path num matches what we started with, so must have looped // back to the start, so finished. break; } // We've hit a node that has a different PathNum. So we need to rewind // back to where we started and write in that path number instead. // This happens due to the fact that the nodes could be in any order in // the node array, so paths can start being traversed from any point, not // necessarily the start. path_number_to_write=node_path_number; p_node=p_start_node; } // Wack in the path number p_node->AddInteger(0x9c91c3ca/*PathNum*/,path_number_to_write); // Check if this is a terminating node of the path, and stop if so. int num_links=SkateScript::GetNumLinks(p_node); if (num_links==0) { break; } // On to the next node. Note the if the path branches, it will only // follow the first branch. The other branches will end up getting // their own path numbers. Don't know if this will be a problem yet. p_node=p_node_array->GetStructure(SkateScript::GetLink( p_node, 0 )); } // If path_number got used, increment it ready for the next path. if (path_number_to_write==m_num_paths) { ++m_num_paths; Dbg_MsgAssert(m_num_pathsAllocateObjectTrackerMemory(); return true; } } // namespace Obj