void StorageBase::SetManaged(bool managed) { if (!managed) SetColor(ObjectColor::Black); SetSwitch(Managed, managed); }
void command_swa( struct char_buffer* cbuff ) { char str_arg1[CONFIG_CLI_MAX_CHARACTERS]; char str_arg2[CONFIG_CLI_MAX_CHARACTERS]; char arg1; if( next_token( cbuff, str_arg1 ) == 0 || str_arg1[0] == '\0' || str_arg1[1] != '\0' || next_token( cbuff, str_arg2 ) != 0 ) { CommandOutput( "[SWA]\tInvalid Arguments" ); return; } //check the switch state if( str_arg1[0] != 's' && str_arg1[0] != 'c' ) { CommandOutput( "[SWA]\tInvalid Switch State" ); return; } if( str_arg1[0] == 'c' ) { arg1 = (char)SWITCH_CURVED; CommandOutput( "[SWA]\tSwitching All Switches To Curved" ); } else { arg1 = (char)SWITCH_STRAIGHT; CommandOutput( "[SWA]\tSwitching All Switches To Straight" ); } int i = 0; for( i = 0; i < 22; i++ ) { SetSwitch( switch_index_inverse( i ), arg1 ); } }
static int Mic2_SetEnabled(u85xx_switch_t *sw, u85xx_device_t *devices, sqlite3* db_p) { unsigned int i; bool enable = false; mic_config_t mic_config; int ret; if (devices[U8540_DEV_HSIN].active) { ret = Alsactrl_DB_GetMicConfig_Generic(db_p, devices[U8540_DEV_MIC].name, &mic_config); if (ret < 0) { LOG_E("Unable to get mic-config for '%s'!", devices[U8540_DEV_MIC].name); return ret; } if (mic_config.mics[0] == MIC2) enable = true; } if (devices[U8540_DEV_MIC].active) { ret = Alsactrl_DB_GetMicConfig_Generic(db_p, devices[U8540_DEV_HSIN].name, &mic_config); if (ret < 0) { LOG_E("Unable to get mic-config for '%s'!", devices[U8540_DEV_HSIN].name); return ret; } for (i = 0; i < mic_config.n_mics; i++) if (mic_config.mics[i] == MIC2) enable = true; } return SetSwitch(sw, enable); }
void command_sw( struct char_buffer* cbuff ) { char str_arg1[CONFIG_CLI_MAX_CHARACTERS]; char str_arg2[CONFIG_CLI_MAX_CHARACTERS]; char str_arg3[CONFIG_CLI_MAX_CHARACTERS]; int arg1 = 0; char arg2; if( next_token( cbuff, str_arg1 ) == 0 || !str_is_integer( str_arg1 ) || next_token( cbuff, str_arg2 ) == 0 || str_arg2[0] == '\0' || str_arg2[1] != '\0' || next_token( cbuff, str_arg3 ) != 0 ) { CommandOutput( "[SW]\tInvalid Arguments" ); return; } arg1 = str_atoi( str_arg1 ); //check the switch number if( switch_index( arg1 ) == -1 ) { CommandOutput( "[SW]\tInvalid Switch Number" ); return; } //check the switch state if( str_arg2[0] != 's' && str_arg2[0] != 'c' ) { CommandOutput( "[SW]\tInvalid Switch State" ); return; } if( str_arg2[0] == 'c' ) { arg2 = (char)SWITCH_CURVED; CommandOutput( "[SW]\tSwitching %d To Curved", arg1 ); } else { arg2 = (char)SWITCH_STRAIGHT; CommandOutput( "[SW]\tSwitching %d To Straight", arg1 ); } SetSwitch( arg1, arg2 ); }
Compiler::Compiler(wxXmlNode* node, Compiler::eRegexType regexType) : m_objectNameIdenticalToFileName(false) , m_isDefault(false) { // ensure all relevant entries exist in switches map (makes sure they show up in build settings dlg) SetSwitch("Include", ""); SetSwitch("Debug", ""); SetSwitch("Preprocessor", ""); SetSwitch("Library", ""); SetSwitch("LibraryPath", ""); SetSwitch("Source", ""); SetSwitch("Output", ""); SetSwitch("Object", ""); SetSwitch("ArchiveOutput", ""); SetSwitch("PreprocessOnly", ""); // ensure all relevant entries exist in tools map (makes sure they show up in build settings dlg) SetTool("LinkerName", ""); SetTool("SharedObjectLinkerName", ""); SetTool("CXX", ""); SetTool("CC", ""); SetTool("AR", ""); SetTool("ResourceCompiler", ""); SetTool("MAKE", ""); SetTool("AS", "as"); // Assembler, default to as m_fileTypes.clear(); if(node) { m_name = XmlUtils::ReadString(node, wxT("Name")); m_compilerFamily = XmlUtils::ReadString(node, "CompilerFamily"); if(m_compilerFamily == "GNU GCC") { // fix wrong name m_compilerFamily = COMPILER_FAMILY_GCC; } m_isDefault = XmlUtils::ReadBool(node, "IsDefault"); if(!node->HasProp(wxT("GenerateDependenciesFiles"))) { if(m_name == wxT("gnu g++") || m_name == wxT("gnu gcc")) { m_generateDependeciesFile = true; } else m_generateDependeciesFile = false; } else { m_generateDependeciesFile = XmlUtils::ReadBool(node, wxT("GenerateDependenciesFiles")); } if(!node->HasProp(wxT("ReadObjectsListFromFile"))) { m_readObjectFilesFromList = true; } else { m_readObjectFilesFromList = XmlUtils::ReadBool(node, wxT("ReadObjectsListFromFile")); } m_objectNameIdenticalToFileName = XmlUtils::ReadBool(node, wxT("ObjectNameIdenticalToFileName")); wxXmlNode* child = node->GetChildren(); while(child) { if(child->GetName() == wxT("Switch")) { m_switches[XmlUtils::ReadString(child, wxT("Name"))] = XmlUtils::ReadString(child, wxT("Value")); } else if(child->GetName() == wxT("Tool")) { m_tools[XmlUtils::ReadString(child, wxT("Name"))] = XmlUtils::ReadString(child, wxT("Value")); } else if(child->GetName() == wxT("Option")) { wxString name = XmlUtils::ReadString(child, wxT("Name")); if(name == wxT("ObjectSuffix")) { m_objectSuffix = XmlUtils::ReadString(child, wxT("Value")); } else if(name == wxT("DependSuffix")) { m_dependSuffix = XmlUtils::ReadString(child, wxT("Value")); } else if(name == wxT("PreprocessSuffix")) { m_preprocessSuffix = XmlUtils::ReadString(child, wxT("Value")); } } else if(child->GetName() == wxT("File")) { Compiler::CmpFileTypeInfo ft; ft.compilation_line = XmlUtils::ReadString(child, wxT("CompilationLine")); ft.extension = XmlUtils::ReadString(child, wxT("Extension")).Lower(); long kind = (long)CmpFileKindSource; if(XmlUtils::ReadLong(child, wxT("Kind"), kind) == CmpFileKindSource) { ft.kind = CmpFileKindSource; } else { ft.kind = CmpFileKindResource; } m_fileTypes[ft.extension] = ft; } else if(child->GetName() == wxT("Pattern")) { if(XmlUtils::ReadString(child, wxT("Name")) == wxT("Error")) { // found an error description CmpInfoPattern errPattern; errPattern.fileNameIndex = XmlUtils::ReadString(child, wxT("FileNameIndex")); errPattern.lineNumberIndex = XmlUtils::ReadString(child, wxT("LineNumberIndex")); errPattern.columnIndex = XmlUtils::ReadString(child, "ColumnIndex", "-1"); errPattern.pattern = child->GetNodeContent(); m_errorPatterns.push_back(errPattern); } else if(XmlUtils::ReadString(child, wxT("Name")) == wxT("Warning")) { // found a warning description CmpInfoPattern warnPattern; warnPattern.fileNameIndex = XmlUtils::ReadString(child, wxT("FileNameIndex")); warnPattern.lineNumberIndex = XmlUtils::ReadString(child, wxT("LineNumberIndex")); warnPattern.columnIndex = XmlUtils::ReadString(child, "ColumnIndex", "-1"); warnPattern.pattern = child->GetNodeContent(); m_warningPatterns.push_back(warnPattern); } } else if(child->GetName() == wxT("GlobalIncludePath")) { m_globalIncludePath = child->GetNodeContent(); } else if(child->GetName() == wxT("GlobalLibPath")) { m_globalLibPath = child->GetNodeContent(); } else if(child->GetName() == wxT("PathVariable")) { m_pathVariable = child->GetNodeContent(); } else if(child->GetName() == wxT("CompilerOption")) { CmpCmdLineOption cmpOption; cmpOption.name = XmlUtils::ReadString(child, wxT("Name")); cmpOption.help = child->GetNodeContent(); m_compilerOptions[cmpOption.name] = cmpOption; } else if(child->GetName() == wxT("LinkerOption")) { CmpCmdLineOption cmpOption; cmpOption.name = XmlUtils::ReadString(child, wxT("Name")); cmpOption.help = child->GetNodeContent(); m_linkerOptions[cmpOption.name] = cmpOption; } else if(child->GetName() == wxT("InstallationPath")) { m_installationPath = child->GetNodeContent(); } child = child->GetNext(); } if(GetTool("MAKE").IsEmpty()) { BuilderConfigPtr bldr = BuildSettingsConfigST::Get()->GetBuilderConfig(""); if(bldr) { SetTool("MAKE", wxString() << bldr->GetToolPath() << " -j " << bldr->GetToolJobs()); } } // Default values for the assembler if(GetTool("AS").IsEmpty() && GetName().CmpNoCase("vc++") == 0) { SetTool("AS", "nasm"); } else if(GetTool("AS").IsEmpty()) { SetTool("AS", "as"); } // For backward compatibility, if the compiler / linker options are empty - add them if(IsGnuCompatibleCompiler() && m_compilerOptions.empty()) { AddDefaultGnuComplierOptions(); } if(IsGnuCompatibleCompiler() && m_linkerOptions.empty()) { AddDefaultGnuLinkerOptions(); } } else { // Create a default compiler: g++ m_name = ""; m_compilerFamily = COMPILER_FAMILY_GCC; m_isDefault = false; SetSwitch("Include", "-I"); SetSwitch("Debug", "-g "); SetSwitch("Preprocessor", "-D"); SetSwitch("Library", "-l"); SetSwitch("LibraryPath", "-L"); SetSwitch("Source", "-c "); SetSwitch("Output", "-o "); SetSwitch("Object", "-o "); SetSwitch("ArchiveOutput", " "); SetSwitch("PreprocessOnly", "-E"); m_objectSuffix = ".o"; m_preprocessSuffix = ".i"; if(regexType == kRegexGNU) { AddPattern(eErrorPattern, "^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]*)([:0-9]*)(: )((fatal " "error)|(error)|(undefined reference))", 1, 3, 4); AddPattern(eErrorPattern, "^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ " "*)(:)(\\(\\.text\\+[0-9a-fx]*\\))", 3, 1, -1); AddPattern(eErrorPattern, "^([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([^ ][a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ " "*)(:)([0-9]+)(:)", 3, 1, -1); AddPattern(eErrorPattern, "undefined reference to", -1, -1, -1); AddPattern(eErrorPattern, "\\*\\*\\* \\[[a-zA-Z\\-_0-9 ]+\\] (Error)", -1, -1, -1); AddPattern(eWarningPattern, "([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?( warning)", 1, 3, 4); AddPattern(eWarningPattern, "([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?( note)", 1, 3, -1); AddPattern(eWarningPattern, "([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?([ ]+instantiated)", 1, 3, -1); AddPattern(eWarningPattern, "(In file included from *)([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)(:)([0-9]+ *)(:)([0-9:]*)?", 2, 4, -1); AddDefaultGnuComplierOptions(); AddDefaultGnuLinkerOptions(); } else { AddPattern( eErrorPattern, "^windres: ([a-zA-Z:]{0,2}[ a-zA-Z\\\\.0-9_/\\+\\-]+) *:([0-9]+): syntax error", 1, 2); AddPattern(eErrorPattern, "(^[a-zA-Z\\\\.0-9 _/\\:\\+\\-]+ *)(\\()([0-9]+)(\\))( \\: )(error)", 1, 3); AddPattern(eErrorPattern, "(LINK : fatal error)", 1, 1); AddPattern(eErrorPattern, "(NMAKE : fatal error)", 1, 1); AddPattern(eWarningPattern, "(^[a-zA-Z\\\\.0-9 _/\\:\\+\\-]+ *)(\\()([0-9]+)(\\))( \\: )(warning)", 1, 3); AddPattern(eWarningPattern, "([a-z_A-Z]*\\.obj)( : warning)", 1, 1); AddPattern(eWarningPattern, "(cl : Command line warning)", 1, 1); } SetTool("LinkerName", "g++"); #ifdef __WXMAC__ SetTool("SharedObjectLinkerName", "g++ -dynamiclib -fPIC"); #else SetTool("SharedObjectLinkerName", "g++ -shared -fPIC"); #endif SetTool("CXX", "g++"); SetTool("CC", "gcc"); SetTool("AR", "ar rcu"); SetTool("ResourceCompiler", "windres"); SetTool("AS", "as"); #ifdef __WXMSW__ SetTool("MAKE", "mingw32-make"); #else SetTool("MAKE", "make"); #endif m_globalIncludePath = wxEmptyString; m_globalLibPath = wxEmptyString; m_pathVariable = wxEmptyString; m_generateDependeciesFile = false; m_readObjectFilesFromList = true; m_objectNameIdenticalToFileName = false; } if(m_generateDependeciesFile && m_dependSuffix.IsEmpty()) { m_dependSuffix = m_objectSuffix + wxT(".d"); } if(!m_switches[wxT("PreprocessOnly")].IsEmpty() && m_preprocessSuffix.IsEmpty()) { m_preprocessSuffix = m_objectSuffix + wxT(".i"); } if(m_fileTypes.empty()) { AddCmpFileType("cpp", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("cxx", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("c++", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("c", CmpFileKindSource, "$(CC) $(SourceSwitch) \"$(FileFullPath)\" $(CFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("cc", CmpFileKindSource, "$(CXX) $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("m", CmpFileKindSource, "$(CXX) -x objective-c $(SourceSwitch) \"$(FileFullPath)\" $(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("mm", CmpFileKindSource, "$(CXX) -x objective-c++ $(SourceSwitch) \"$(FileFullPath)\" " "$(CXXFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "$(IncludePath)"); AddCmpFileType("s", CmpFileKindSource, "$(AS) \"$(FileFullPath)\" $(ASFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "-I$(IncludePath)"); AddCmpFileType("rc", CmpFileKindResource, "$(RcCompilerName) -i \"$(FileFullPath)\" $(RcCmpOptions) " "$(ObjectSwitch)$(IntermediateDirectory)/" "$(ObjectName)$(ObjectSuffix) $(RcIncludePath)"); } // Add support for assembler file if(m_fileTypes.count("s") == 0) { AddCmpFileType("s", CmpFileKindSource, "$(AS) \"$(FileFullPath)\" $(ASFLAGS) " "$(ObjectSwitch)$(IntermediateDirectory)/$(ObjectName)$(ObjectSuffix) " "-I$(IncludePath)"); } }
static int VoiceMasterGenerator_SetEnabled(u85xx_switch_t *sw, u85xx_device_t *devices, sqlite3* db_p) { UNUSED_PAR(db_p); return SetSwitch(sw, devices[U8540_DEV_MODEMDL].active || devices[U8540_DEV_MODEMUL].active); }
static int LineIn_SetEnabled(u85xx_switch_t *sw, u85xx_device_t *devices, sqlite3* db_p) { UNUSED_PAR(db_p); return SetSwitch(sw, devices[U8540_DEV_LINEIN].active); }
static int Vibra1_SetEnabled(u85xx_switch_t *sw, u85xx_device_t *devices, sqlite3* db_p) { UNUSED_PAR(db_p); return SetSwitch(sw, devices[U8540_DEV_VIBL].active); }
static int Carkit_SetEnabled(u85xx_switch_t *sw, u85xx_device_t *devices, sqlite3* db_p) { UNUSED_PAR(db_p); return SetSwitch(sw, devices[U8540_DEV_CARKITOUT].active); }
static int Earpiece_SetEnabled(u85xx_switch_t *sw, u85xx_device_t *devices, sqlite3* db_p) { UNUSED_PAR(db_p); return SetSwitch(sw, devices[U8540_DEV_EARP].active); }
/* ** GroundClass Exec() function. ** NOTE: returns TRUE if we've processed this frame. FALSE if we're to do ** dead reckoning (in VU) */ int GroundClass::Exec (void) { //RV - I-Hawk - Added a 0 vector for RV new PS calls Tpoint PSvec; PSvec.x = 0; PSvec.y = 0; PSvec.z = 0; Tpoint pos; Tpoint vec; float speedScale; float groundZ; float labelLOD; float drawLOD; RadarClass *radar = NULL; SoundPos.UpdatePos((SimBaseClass *)this); //Cobra pos.x = 0.0f; pos.y = 0.0f; pos.z = 0.0f; // MLR 5/23/2004 - pos.x = XPos(); pos.y = YPos(); pos.z = OTWDriver.GetApproxGroundLevel( pos.x, pos.y ); // pos.z = -10.0f;//Cobra trying to fix the stupid uninit CTD SetPosition(pos.x, pos.y, pos.z); // dead? -- we do nothing if ( IsDead() ){ return FALSE; } // if damaged if ( pctStrength < 0.5f ){ if (sfxTimer > 1.5f - gai->distLOD * 1.3){ // reset the timer sfxTimer = 0.0f; pos.z -= 10.0f; // VP_changes this shoud be checked why have GetGroundLevel been subtracted by 10.0F // Sometimes the trails seem strange vec.x = PRANDFloat() * 20.0f; vec.y = PRANDFloat() * 20.0f; vec.z = PRANDFloat() * 20.0f; /* OTWDriver.AddSfxRequest( new SfxClass( SFX_TRAILSMOKE, // type SFX_MOVES | SFX_NO_GROUND_CHECK, // flags &pos, // world pos &vec, // vector 3.5f, // time to live 4.5f // scale ) ); */ DrawableParticleSys::PS_AddParticleEx((SFX_TRAILSMOKE + 1), &pos, &vec); } } if (IsExploding()){ // KCK: I've never seen this section of code executed. Maybe it gets hit, but I doubt // it. if (!IsSetFlag( SHOW_EXPLOSION )){ // Show the explosion Tpoint pos, vec; Falcon4EntityClassType *classPtr = (Falcon4EntityClassType *)EntityType(); //DrawableGroundVehicle *destroyedPtr; // FRB //Cobra TJL 11/07/04 CTD point initialize here pos.x = 0.0f; pos.y = 0.0f; pos.z = 0.0f; // MLR 5/23/2004 - uncommented out the x, y pos.x = XPos(); pos.y = YPos(); pos.z = OTWDriver.GetApproxGroundLevel( pos.x, pos.y ) - 10.0f; vec.x = 0.0f; vec.y = 0.0f; vec.z = 0.0f; // create a new drawable for destroyed vehicle // sometimes..... //RV - I-Hawk - Commenting all this if statement... not necessary /* if ( rand() & 1 ){ destroyedPtr = new DrawableGroundVehicle( classPtr->visType[3], &pos, Yaw(), 1.0f ); groundZ = PRANDFloatPos() * 60.0f + 15.0f; /* OTWDriver.AddSfxRequest( new SfxClass ( SFX_BURNING_PART, // type &pos, // world pos &vec, // (DrawableBSP *)destroyedPtr, groundZ, // time to live 1.0f // scale ) ); */ /* DrawableParticleSys::PS_AddParticleEx((SFX_BURNING_PART + 1), &pos, &vec); pos.z += 10.0f; /* OTWDriver.AddSfxRequest( new SfxClass( SFX_FEATURE_EXPLOSION, // type &pos, // world pos groundZ, // time to live 100.0f // scale ) ); */ /* DrawableParticleSys::PS_AddParticleEx((SFX_FEATURE_EXPLOSION + 1), &pos, &PSvec); } */ //RV - I-Hawk - seperating explosion type for ground/sea domains. also //adding a check so soldiers will not explode like ground vehicles... if (GetDomain() == DOMAIN_LAND && GetType() != TYPE_FOOT) { //pos.z -= 20.0f; /* OTWDriver.AddSfxRequest( new SfxClass( SFX_VEHICLE_EXPLOSION, // type &pos, // world pos 1.5f, // time to live 100.0f // scale ) ); */ DrawableParticleSys::PS_AddParticleEx((SFX_VEHICLE_EXPLOSION + 1), &pos, &PSvec); } else if ( GetDomain() == DOMAIN_SEA ) { DrawableParticleSys::PS_AddParticleEx((SFX_WATER_FIREBALL + 1), &pos, &PSvec); } // make sure we don't do it again... SetFlag( SHOW_EXPLOSION ); // we can now kill it immediately SetDead(TRUE); } return FALSE; } // exec any base functionality SimVehicleClass::Exec(); // Sept 30, 2002 // VP_changes: Frequently Z value is not in the correct place. It should follow the terrain. if ( drawPointer ){ drawPointer->GetPosition( &pos ); } else { return FALSE; } //JAM 27Sep03 - Let's try this groundZ = pos.z; // - 0.7f; KCK: WTF is this? //VP_changes Sept 25 groundZ = OTWDriver.GetGroundLevel( pos.x, pos.y ); // Movement/Targeting for local entities if (IsLocal() && SimDriver.MotionOn()) { //I commented this out, because it is done in gai->ProcessTargeting down below DSP 4/30/99 // Refresh our target pointer (if any) //SetTarget( SimCampHandoff( targetPtr, targetList, HANDOFF_RANDOM ) ); // Look for someone to do radar fire control for us FindBattalionFireControl(); // RV - Biker - Switch on lights for ground/naval vehicles int isNight = TimeOfDayGeneral(TheCampaign.CurrentTime) < TOD_DAWNDUSK ? true : false; if (drawPointer && ((DrawableBSP *)drawPointer)->GetNumSwitches() >= AIRDEF_LIGHT_SWITCH) { if (isShip) { isNight = (TimeOfDayGeneral(TheCampaign.CurrentTime) <= TOD_DAWNDUSK || realWeather->weatherCondition == INCLEMENT) ? true : false; if (pctStrength > 0.50f) { ((DrawableBSP *)drawPointer)->SetSwitchMask(0, isNight); ((DrawableBSP *)drawPointer)->SetSwitchMask(AIRDEF_LIGHT_SWITCH, isNight); } } else if (GetVt() > 1.0f) { VuListIterator vehicleWalker(SimDriver.combinedList); FalconEntity* object = (FalconEntity*)vehicleWalker.GetFirst(); bool hasThreat = false; float range = 999.9f * NM_TO_FT; // Consider each potential target in our environment while (object && !hasThreat) { // Skip sleeping sim objects if (object->IsSim()) { if (!((SimBaseClass*)object)->IsAwake()) { object = (FalconEntity*)vehicleWalker.GetNext(); continue; } } // Fow now we skip missles -- might want to display them eventually... if (object->IsMissile() || object->IsBomb()) { object = (FalconEntity*)vehicleWalker.GetNext(); continue; } if (object->GetTeam() == GetTeam()) { object = (FalconEntity*)vehicleWalker.GetNext(); continue; } float dx = object->XPos() - XPos(); float dy = object->YPos() - YPos(); float dz = object->ZPos() - ZPos(); range = (float)sqrt(dx*dx + dy*dy + dz*dz); if (range < 5.0f * NM_TO_FT) hasThreat = true; object = (FalconEntity*)vehicleWalker.GetNext(); } // If no enemy nearby and not heavy damaged switch on lights if (!hasThreat && pctStrength > 0.75f) { ((DrawableBSP *)drawPointer)->SetSwitchMask(AIRDEF_LIGHT_SWITCH, isNight); } else { ((DrawableBSP *)drawPointer)->SetSwitchMask(AIRDEF_LIGHT_SWITCH, 0); } } else { ((DrawableBSP *)drawPointer)->SetSwitchMask(AIRDEF_LIGHT_SWITCH, 0); } } // RV - Biker - Do also switch on lights for tractor vehicles if (truckDrawable && truckDrawable->GetNumSwitches() >= AIRDEF_LIGHT_SWITCH) { if (GetVt() > 1.0f) { VuListIterator vehicleWalker(SimDriver.combinedList); FalconEntity* object = (FalconEntity*)vehicleWalker.GetFirst(); bool hasThreat = false; float range = 999.9f * NM_TO_FT; // Consider each potential target in our environment while (object && !hasThreat) { // Skip sleeping sim objects if (object->IsSim()) { if (!((SimBaseClass*)object)->IsAwake()) { object = (FalconEntity*)vehicleWalker.GetNext(); continue; } } // Fow now we skip missles -- might want to display them eventually... if (object->IsMissile() || object->IsBomb()) { object = (FalconEntity*)vehicleWalker.GetNext(); continue; } if (object->GetTeam() == GetTeam()) { object = (FalconEntity*)vehicleWalker.GetNext(); continue; } float dx = object->XPos() - XPos(); float dy = object->YPos() - YPos(); float dz = object->ZPos() - ZPos(); range = (float)sqrt(dx*dx + dy*dy + dz*dz); if (range < 5.0f * NM_TO_FT) hasThreat = true; object = (FalconEntity*)vehicleWalker.GetNext(); } // If no enemy nearby and not heavy damaged switch on lights if (!hasThreat && pctStrength > 0.75f) { truckDrawable->SetSwitchMask(AIRDEF_LIGHT_SWITCH, isNight); } else { truckDrawable->SetSwitchMask(AIRDEF_LIGHT_SWITCH, 0); } } else { truckDrawable->SetSwitchMask(AIRDEF_LIGHT_SWITCH, 0); } } // RV - Biker - Shut down ship radar if damaged if (isShip && radarDown == false && pctStrength < 0.9f && rand()%50 > (pctStrength - 0.50f)*100) { isEmitter = false; RadarClass *radar = (RadarClass*)FindSensor(this, SensorClass::Radar); if (radar) { radarDown = true; radar->SetDesiredTarget(NULL); radar->SetEmitting(FALSE); } if (targetPtr) { SelectWeapon(true); } } // 2001-03-26 ADDED BY S.G. NEED TO KNOW IF THE RADAR CALLED SetSpotted // RV - Biker - Rotate radars float deltaDOF; float curDOF = GetDOFValue(5); deltaDOF = 180.0f * DTR * SimLibMajorFrameTime; curDOF += deltaDOF; if ( curDOF > 360.0f * DTR ) curDOF -= 360.0f * DTR; SetDOF(5, curDOF); int spottedSet = FALSE; // END OF ADDED SECTION // 2002-03-21 ADDED BY S.G. // If localData only has zeros, // there is a good chance they are not valid (should not happen here though)... if (targetPtr) { SimObjectLocalData* localData= targetPtr->localData; if ( localData->ataFrom == 0.0f && localData->az == 0.0f && localData->el == 0.0f && localData->range == 0.0f ) { CalcRelAzElRangeAta(this, targetPtr); } } // END OF ADDED SECTION 2002-03-21 // check for sending radar emmisions // 2002-02-26 MODIFIED BY S.G. // Added the nextTargetUpdate check to prevent the radar code to run on every frame! if ( isEmitter && nextTargetUpdate < SimLibElapsedTime){ // 2002-02-26 ADDED BY S.G. Next radar scan is 1 sec for aces, 2 for vets, etc ... nextTargetUpdate = SimLibElapsedTime + (5 - gai->skillLevel) * SEC_TO_MSEC; radar = (RadarClass*)FindSensor( this, SensorClass::Radar ); ShiAssert( radar ); if (radar){ radar->Exec( targetList ); } // 2001-03-26 ADDED BY S.G. // IF WE CAN SEE THE RADAR'S TARGET AND WE ARE A AIR DEFENSE THINGY // NOT IN A BKOGEN MORAL STATE, MARK IT AS SPOTTED IF WE'RE BRIGHT ENOUGH if ( radar && radar->CurrentTarget() && gai->skillLevel >= 3 && ((UnitClass *)GetCampaignObject())->GetSType() == STYPE_UNIT_AIR_DEFENSE && !((UnitClass *)GetCampaignObject())->Broken() ){ CampBaseClass *campBaseObj; if (radar->CurrentTarget()->BaseData()->IsSim()){ campBaseObj = ((SimBaseClass *)radar->CurrentTarget()->BaseData())->GetCampaignObject(); } else{ campBaseObj = (CampBaseClass *)radar->CurrentTarget()->BaseData(); } // JB 011002 If campBaseObj is NULL the target may be chaff if (campBaseObj && !(campBaseObj->GetSpotted(GetTeam())) && campBaseObj->IsFlight()){ RequestIntercept((FlightClass *)campBaseObj, GetTeam()); } spottedSet = TRUE; if (campBaseObj && radar->GetRadarDatFile()){ campBaseObj->SetSpotted( GetTeam(), TheCampaign.CurrentTime, (radar->radarData->flag & RAD_NCTR) != 0 && radar->CurrentTarget()->localData && radar->CurrentTarget()->localData->ataFrom < 45.0f * DTR && radar->CurrentTarget()->localData->range < radar->GetRadarDatFile()->MaxNctrRange / (2.0f * (16.0f - (float)gai->skillLevel) / 16.0f) ); } // 2002-03-05 MODIFIED BY S.G. target's aspect and skill used in the equation } // END OF ADDED SECTION } // 2001-03-26 ADDED BY S.G. // IF THE BATTALION LEAD HAS LOS // ON IT AND WE ARE A AIR DEFENSE THINGY NOT IN A BKOGEN MORAL STATE, // MARK IT AS SPOTTED IF WE'RE BRIGHT ENOUGH // 2002-02-11 MODIFED BY S.G. // Since I only identify visually, need to perform this even if spotted by radar in case I can ID it. if ( /*!spottedSet && gai->skillLevel >= 3 && */ ((UnitClass *)GetCampaignObject())->GetSType() == STYPE_UNIT_AIR_DEFENSE && gai == gai->battalionCommand && !((UnitClass *)GetCampaignObject())->Broken() && gai->GetAirTargetPtr() && CheckLOS(gai->GetAirTargetPtr()) ){ CampBaseClass *campBaseObj; if (gai->GetAirTargetPtr()->BaseData()->IsSim()) campBaseObj = ((SimBaseClass *)gai->GetAirTargetPtr()->BaseData())->GetCampaignObject(); else campBaseObj = (CampBaseClass *)gai->GetAirTargetPtr()->BaseData(); // JB 011002 If campBaseObj is NULL the target may be chaff if (!spottedSet && campBaseObj && !(campBaseObj->GetSpotted(GetTeam())) && campBaseObj->IsFlight()) RequestIntercept((FlightClass *)campBaseObj, GetTeam()); if (campBaseObj) campBaseObj->SetSpotted(GetTeam(),TheCampaign.CurrentTime, 1); // 2002-02-11 MODIFIED BY S.G. Visual detection means identified as well } // END OF ADDED SECTION // KCK: When should we run a target update cycle? if (SimLibElapsedTime > lastProcess){ gai->ProcessTargeting(); lastProcess = SimLibElapsedTime + processRate; } // KCK: Check if it's ok to think if (SimLibElapsedTime > lastThought ){ // do movement and (possibly) firing.... gai->Process (); lastThought = SimLibElapsedTime + thoughtRate; } // RV - Biker - Only allow SAM fire if radar still does work SimWeaponClass *theWeapon = Sms->GetCurrentWeapon(); // FRB - This version seems to give SAMs a little more activity if(SimLibElapsedTime > nextSamFireTime && !allowSamFire){ allowSamFire = TRUE; } // Biker's version //if(SimLibElapsedTime > nextSamFireTime && !allowSamFire) //{ // if (radarDown == false || (theWeapon && theWeapon->IsMissile() && theWeapon->sensorArray[0]->Type() == SensorClass::IRST)) // allowSamFire = TRUE; //} // Move and update delta; gai->Move_Towards_Dest(); // edg: always insure that our Z position is valid for the entity. // the draw pointer should have this value // KCK NOTE: The Z we have is actually LAST FRAME's Z. Probably not a big deal. SetPosition( XPos() + XDelta() * SimLibMajorFrameTime, YPos() + YDelta() * SimLibMajorFrameTime, groundZ ); // do firing // this also does weapon keep alive if ( Sms ){ gai->Fire(); } } // KCK: I simplified this some. This is now speed squared. speedScale = XDelta()*XDelta() + YDelta()*YDelta(); // set our level of detail if ( gai == gai->battalionCommand ){ gai->SetDistLOD(); } else{ gai->distLOD = gai->battalionCommand->distLOD; } // do some extra LOD stuff: if the unit is not a lead veh amd the // distLOD is less than a certain value, remove it from the draw // list. if (drawPointer && gai->rank != GNDAI_BATTALION_COMMANDER){ // distLOD cutoff by ranking (KCK: This is explicit for testing, could be a formula/table) if (gai->rank & GNDAI_COMPANY_LEADER){ labelLOD = .5F; drawLOD = .25F; } else if (gai->rank & GNDAI_PLATOON_LEADER){ labelLOD = .925F; drawLOD = .5F; } else { labelLOD = 1.1F; drawLOD = .75F; } // RV - Biker - Why do this maybe helpful knowing which vehicle has problems // Determine wether to draw label or not if (gai->distLOD < labelLOD){ if (!IsSetLocalFlag(NOT_LABELED)){ drawPointer->SetLabel ("", 0xff00ff00); // Don't label SetLocalFlag(NOT_LABELED); } } else if (IsSetLocalFlag(NOT_LABELED)){ SetLabel(this); UnSetLocalFlag(NOT_LABELED); } //if (IsSetLocalFlag(NOT_LABELED)) { // SetLabel(this); // UnSetLocalFlag(NOT_LABELED); //} } if (!targetPtr){ //rotate turret to be pointing forward again float maxAz = TURRET_ROTATE_RATE * SimLibMajorFrameTime; float maxEl = TURRET_ELEVATE_RATE * SimLibMajorFrameTime; float newEl; if (isAirDefense){ newEl = 60.0F*DTR; } else { newEl = 0.0F; } float delta = newEl - GetDOFValue(AIRDEF_ELEV); if(delta > 180.0F*DTR){ delta -= 180.0F*DTR; } else if(delta < -180.0F*DTR){ delta += 180.0F*DTR; } // Do elevation adjustments if (delta > maxEl){ SetDOFInc(AIRDEF_ELEV, maxEl); } else if (delta < -maxEl){ SetDOFInc(AIRDEF_ELEV, -maxEl); } else { SetDOF(AIRDEF_ELEV, newEl); } SetDOF(AIRDEF_ELEV, min(85.0F*DTR, max(GetDOFValue(AIRDEF_ELEV), 0.0F))); SetDOF(AIRDEF_ELEV2, GetDOFValue(AIRDEF_ELEV)); delta = 0.0F - GetDOFValue(AIRDEF_AZIMUTH); if(delta > 180.0F*DTR){ delta -= 180.0F*DTR; } else if(delta < -180.0F*DTR){ delta += 180.0F*DTR; } // Now do the azmuth adjustments if (delta > maxAz){ SetDOFInc(AIRDEF_AZIMUTH, maxAz); } else if (delta < -maxAz){ SetDOFInc(AIRDEF_AZIMUTH, -maxAz); } // RV - Biker - Don't do this //else // SetDOF(AIRDEF_AZIMUTH, 0.0F); } // Special shit by ground type if ( isFootSquad ){ if ( speedScale > 0.0f ){ // Couldn't this be done in the drawable class's update function??? ((DrawableGuys*)drawPointer)->SetSquadMoving( TRUE ); } else { // Couldn't this be done in the drawable class's update function??? ((DrawableGuys*)drawPointer)->SetSquadMoving( FALSE ); } // If we're less than 80% of the way from "FAR" toward the viewer, just draw one guy // otherwise, put 5 guys in a squad. if (gai->distLOD < 0.8f) { ((DrawableGuys*)drawPointer)->SetNumInSquad( 1 ); } else { ((DrawableGuys*)drawPointer)->SetNumInSquad( 5 ); } } // We're not a foot squad, so do the vehicle stuff else if ( !IsSetLocalFlag( IS_HIDDEN ) && speedScale > 300.0f ) { // speedScale /= ( 900.0f * KPH_TO_FPS * KPH_TO_FPS); // essentially 1.0F at 30 mph // JPO - for engine noise VehicleClassDataType *vc = GetVehicleClassData(Type() - VU_LAST_ENTITY_TYPE); ShiAssert(FALSE == F4IsBadReadPtr(vc, sizeof *vc)); // (a) Make sound: // everything sounds like a tank right now if ( GetCampaignObject()->IsBattalion() ){ //if (vc) if (vc && vc->EngineSound!=34){ // kludge prevent 34 from playing SoundPos.Sfx( vc->EngineSound, 0, 1.0, 0); // MLR 5/16/2004 - } else{ SoundPos.Sfx( SFX_TANK, 0, 1.0, 0); // MLR 5/16/2004 - } // (b) Make dust // dustTimer += SimLibMajorFrameTime; // if ( dustTimer > max( 0.2f, 4.5f - speedScale - gai->distLOD * 3.3f ) ) if ( ((rand() & 7) == 7) && gSfxCount[ SFX_GROUND_DUSTCLOUD ] < gSfxLODCutoff && gTotSfx < gSfxLODTotCutoff ){ // reset the timer // dustTimer = 0.0f; pos.x += PRANDFloat() * 5.0f; pos.y += PRANDFloat() * 5.0f; pos.z = groundZ; // RV - Biker - Move that smoke more behind the vehicle mlTrig trig; mlSinCos (&trig, Yaw()); pos.x -= 15.0f*trig.cos; pos.y -= 15.0f*trig.sin; vec.x = PRANDFloat() * 5.0f; vec.y = PRANDFloat() * 5.0f; vec.z = -20.0f; //JAM 24Oct03 - No dust trails when it's raining. if(realWeather->weatherCondition < INCLEMENT){ /* OTWDriver.AddSfxRequest( new SfxClass (SFX_VEHICLE_DUST, // type //JAM 03Oct03 // new SfxClass (SFX_GROUND_DUSTCLOUD, // type SFX_USES_GRAVITY | SFX_NO_DOWN_VECTOR | SFX_MOVES | SFX_NO_GROUND_CHECK, &pos, // world pos &vec, 1.0f, // time to live 1.f)); //JAM 03Oct03 8.5f )); // scale */ DrawableParticleSys::PS_AddParticleEx((SFX_VEHICLE_DUST + 1), &pos, &vec); } } // (c) Make sure we're using our 'Moving' model (i.e. Trucked artillery, APC, etc) if (truckDrawable){ // Keep truck 20 feet behind us (HACK HACK) Tpoint truckPos; mlTrig trig; mlSinCos (&trig, Yaw()); truckPos.x = XPos()-20.0F*trig.cos; truckPos.y = YPos()-20.0F*trig.sin; truckPos.z = ZPos(); truckDrawable->Update(&truckPos, Yaw()+PI); } if (isTowed || hasCrew){ SetSwitch(0,0x2); } } else // itsa task force { if (vc){ SoundPos.Sfx( vc->EngineSound, 0, 1.0, 0); } else { SoundPos.Sfx( SFX_SHIP, 0, 1.0, 0); } //RV - I-Hawk - Do wakes only at some cases if ( (rand() & 7) == 7 ) { //I-Hawk - not using all this anymore // // reset the timer // dustTimer = 0.0f; //float ttl; //static float trailspd = 5.0f; //static float bowfx = 0.92f; //static float sternfx = 0.75f; //float spdratio = GetVt() / ((UnitClass*)GetCampaignObject())->GetMaxSpeed(); float radius; if ( drawPointer ){ radius = drawPointer->Radius(); // JPO from 0.15 - now done inline } else{ radius = 90.0f; } //I-Hawk - Fixed position for ships wakes, effect "delay" in position is //handled by PS now. No more the "V shape" of water wakes. pos.x = XPos() + XDelta() * SimLibMajorFrameTime; pos.y = YPos() + YDelta() * SimLibMajorFrameTime; pos.z = groundZ; //// JPO - think this is sideways on. ///* //vec.x = dmx[1][0] * spdratio * PRANDFloat() * trailspd; //vec.y = dmx[1][1] * spdratio * PRANDFloat() * trailspd; //vec.z = 0.5f; // from -20 JPO //*/ //I-Hawk - More correct vector for wakes vec.x = XDelta(); vec.y = YDelta(); vec.z = 0.0f; //I-Hawk - Separate wake effect for different ships size int theSFX; if ( radius < 200.0f ) { theSFX = SFX_WATER_WAKE_SMALL; } else if ( radius >= 200.0f && radius < 400.0f ) { theSFX = SFX_WATER_WAKE_MEDIUM; } else if ( radius >= 400.0f ) { theSFX = SFX_WATER_WAKE_LARGE; } //I-Hawk - The PS DrawableParticleSys::PS_AddParticleEx((theSFX + 1), &pos, &vec); } } } // Otherwise, we're not moving or are hidden. Do some stuff else { // (b) Make sure we're using our 'Holding' model (i.e. Unlimbered artillery, troops prone, etc) if (truckDrawable){ // Once we stop, our truck doesn't move at all - but sits further away than when moving Tpoint truckPos; truckPos.x = XPos() + 40.0F; truckPos.y = YPos(); truckPos.z = 0.0F; truckDrawable->Update(&truckPos, Yaw()); } if (isTowed || hasCrew){ SetSwitch(0,0x1); } } // ACMI Output if (gACMIRec.IsRecording() && (SimLibFrameCount & 0x0f ) == 0){ ACMIGenPositionRecord genPos; genPos.hdr.time = SimLibElapsedTime * MSEC_TO_SEC + OTWDriver.todOffset; genPos.data.type = Type(); genPos.data.uniqueID = ACMIIDTable->Add(Id(),NULL,TeamInfo[GetTeam()]->GetColor());//.num_; genPos.data.x = XPos(); genPos.data.y = YPos(); genPos.data.z = ZPos(); genPos.data.roll = Roll(); genPos.data.pitch = Pitch(); genPos.data.yaw = Yaw(); // Remove genPos.data.teamColor = TeamInfo[GetTeam()]->GetColor(); gACMIRec.GenPositionRecord( &genPos ); } return IsLocal(); }
void StorageBase::SetClean(bool clean) { SetSwitch(Clean, clean); if (!clean && IsBlack()) SetColor(ObjectColor::Grey); }