static char *FindExtender( char *fullpath, char **endname ) { #if defined(DOS4G) char *name; const char __far *d4gname; unsigned len; d4gname = DOSEnvFind( "DOS4GPATH" ); if( d4gname != NULL ) { _DBG_Write("Got DOS4GPATH -<"); _DBG_Write(d4gname); _DBG_Writeln(">"); len = _fstrlen( d4gname ); if( len > 4 ) { const char __far *ext = d4gname + len - 4; if( ext[0] == '.' && LOW( ext[1] ) == 'e' && LOW( ext[2] ) == 'x' && LOW( ext[3] ) == 'e' ) { _DBG_Writeln( "is exe\r\n" ); *endname = CopyStr( d4gname, fullpath ); return( fullpath ); } } name = CheckPath( d4gname, fullpath, endname ); if( name != NULL ) { _DBG_Writeln( "found in path\r\n" ); return( name ); } } #endif return( CheckPath( DOSEnvFind( "PATH" ), fullpath, endname ) ); }
bool Controller::CalculateWin(int x, int y) { if (CheckPath(x, y, 1, 0) + CheckPath(x, y, -1, 0) - 1 >= settings->winAmount) return true; if (CheckPath(x, y, 1, 1) + CheckPath(x, y, -1, -1) - 1 >= settings->winAmount) return true; if (CheckPath(x, y, 0, 1) + CheckPath(x, y, 0, -1) - 1 >= settings->winAmount) return true; if (CheckPath(x, y, -1,1) + CheckPath(x, y, 1, -1) - 1 >= settings->winAmount) return true; return false; }
void wxFileDirPickerCtrlBase::UpdatePickerFromTextCtrl() { wxASSERT(m_text); if (m_bIgnoreNextTextCtrlUpdate) { // ignore this update m_bIgnoreNextTextCtrlUpdate = false; return; } // remove the eventually present path-separator from the end of the textctrl // string otherwise we would generate a wxFileDirPickerEvent when changing // from e.g. /home/user to /home/user/ and we want to avoid it ! wxString newpath(GetTextCtrlValue()); if (!CheckPath(newpath)) return; // invalid user input if (m_pickerIface->GetPath() != newpath) { m_pickerIface->SetPath(newpath); // update current working directory, if necessary // NOTE: the path separator is required because if newpath is "C:" // then no change would happen if (IsCwdToUpdate()) wxSetWorkingDirectory(newpath); // fire an event wxFileDirPickerEvent event(GetEventType(), this, GetId(), newpath); GetEventHandler()->ProcessEvent(event); } }
ResourceLocation& ResourceLocation::operator=( std::string rhs ) { this->RelativePath = rhs; SME_ASSERT(CheckPath() == true); return *this; }
bool CCensorNode::CheckPath(const UString &path, bool isFile) const { bool include; if(CheckPath(path, isFile, include)) return include; return false; }
/* OnWizardNext * ---------------------------------------------------------------------------- */ LRESULT CPropLangPath::OnWizardNext() { UpdateData(TRUE); m_bSkipTest = GetFocus()->GetSafeHwnd() == m_cInstallPath.GetSafeHwnd(); if (! CheckPath()) { return -1; } return CPropBase::OnWizardNext(); }
bool wxFileDirPickerCtrlBase::CreateBase(wxWindow *parent, wxWindowID id, const wxString &path, const wxString &message, const wxString &wildcard, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name ) { wxASSERT_MSG(path.empty() || CheckPath(path), wxT("Invalid initial path!")); if (!wxPickerBase::CreateBase(parent, id, path, pos, size, style, validator, name)) return false; if (!HasFlag(wxFLP_OPEN) && !HasFlag(wxFLP_SAVE)) m_windowStyle |= wxFLP_OPEN; // wxFD_OPEN is the default // check that the styles are not contradictory wxASSERT_MSG( !(HasFlag(wxFLP_SAVE) && HasFlag(wxFLP_OPEN)), _T("can't specify both wxFLP_SAVE and wxFLP_OPEN at once") ); wxASSERT_MSG( !HasFlag(wxFLP_SAVE) || !HasFlag(wxFLP_FILE_MUST_EXIST), _T("wxFLP_FILE_MUST_EXIST can't be used with wxFLP_SAVE" ) ); wxASSERT_MSG( !HasFlag(wxFLP_OPEN) || !HasFlag(wxFLP_OVERWRITE_PROMPT), _T("wxFLP_OVERWRITE_PROMPT can't be used with wxFLP_OPEN") ); // create a wxFilePickerWidget or a wxDirPickerWidget... m_pickerIface = CreatePicker(this, path, message, wildcard); if ( !m_pickerIface ) return false; m_picker = m_pickerIface->AsControl(); // complete sizer creation wxPickerBase::PostCreation(); m_picker->Connect(GetEventType(), wxFileDirPickerEventHandler(wxFileDirPickerCtrlBase::OnFileDirChange), NULL, this); // default's wxPickerBase textctrl limit is too small for this control: // make it bigger if (m_text) m_text->SetMaxLength(512); return true; }
qboolean isValidChildNode (vec3_t start, vec3_t v, int max_distance, int max_z_delta) { // node should be within +/- 32 units of start on the Z axis if (fabs(v[2]-start[2]) > max_z_delta) return false; // distance check, next node could be anywhere between 128 - 255 units away if (Get2dDistance(start, v) >= max_distance) return false; // basic visibility check if (!gi.inPVS(start, v)) return false; // advanced visibility check, make sure the path is wide enough to walk to if (!CheckPath(start, v)) return false; return true; }
BOOL CDirBrowns::OnInitDialog() { m_pathName.Replace('/','\\'); CDialog::OnInitDialog(); // TODO: Add extra initialization here if(!CheckPath(m_pathName)) m_pathName=m_currentPath; SetDlgItemText(IDC_PATHNAME,m_pathName); CString driver=m_pathName.Left(2); m_drvList.Select(driver); m_dirTree.SetPath(m_pathName); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CDirBrowns::OnOK() { // TODO: Add your control notification handler code here CString temp; GetDlgItemText(IDC_PATHNAME,temp); if(temp==m_pathName) { EndDialog(IDOK);return;} temp.Replace('/','\\'); if(!CheckPath(temp)) { CString str; str.Format(_T("%s不是一个合法的目录!"),temp); AfxMessageBox(str); return; } m_pathName=temp; SetDlgItemText(IDC_PATHNAME,m_pathName); CString driver=m_pathName.Left(2); m_drvList.Select(driver); m_dirTree.SetPath(m_pathName); }
void AbstractNewDialog::OnOK() { UpdateData(TRUE); // Check that the project name is valid CString name = GetName(); if (name.FindOneOf(invalid) != -1) { CString msg; msg.Format("The %s name cannot contain any of the following:\n%s",GetType(),invalid); MessageBox(msg,INFORM_TITLE,MB_ICONERROR|MB_OK); return; } // Check that the project author is valid CStringW invalidW(invalid); if (m_author.FindOneOf(invalidW) != -1) { CString msg; msg.Format("The author's name cannot contain any of the following:\n%s",invalid); MessageBox(msg,INFORM_TITLE,MB_ICONERROR|MB_OK); return; } if (m_author.CompareNoCase(L"Reserved") == 0) { MessageBox("The author cannot be called 'Reserved'",INFORM_TITLE,MB_ICONERROR|MB_OK); return; } // Check if the project directory is valid if (CheckPath() == false) return; // Save the name of the author if (GetDlgItem(IDC_AUTHOR)->IsWindowEnabled()) theApp.WriteProfileString("User",L"Name",m_author); I7BaseDialog::OnOK(); }
/* static */ nsresult sbURIChecker::CheckURI(nsACString& aDomain, nsACString& aPath, nsIURI* aURI) { #ifdef PR_LOGGING if (!gURICheckerLog) { gURICheckerLog = PR_NewLogModule("sbURIChecker"); } LOG(("sbURIChecker::CheckURI(domain:%s path:%s)", aDomain.BeginReading(), aPath.BeginReading())); #endif NS_ENSURE_ARG_POINTER(aURI); nsCString domain(aDomain); nsresult rv = CheckDomain( domain, aURI ); if ( NS_FAILED(rv) ) { LOG(("sbURIChecker::CheckURI() -- FAILED domain Check")); return rv; } nsCString path(aPath); rv = CheckPath( path, aURI ); if ( NS_FAILED(rv) ) { LOG(("sbURIChecker::CheckURI() -- FAILED path Check")); return rv; } // everything passed, assign into the inputs if ( aDomain.IsEmpty() ) { aDomain.Assign(domain); } if ( aPath.IsEmpty() ) { aPath.Assign(path); } return NS_OK; }
bool TerrainInfo::CheckPathAccurate(float srcX, float srcY, float srcZ, float& dstX, float& dstY, float& dstZ, Unit* mover, bool onlyLOS ) const { float tstX = dstX; float tstY = dstY; float tstZ = dstZ; // check by standart way. may be not need path checking? if (!mover && CheckPath(srcX, srcY, srcZ, tstX, tstY, tstZ) && IsNextZcoordOK(tstX, tstY, tstZ, 5.0f)) { DEBUG_LOG("TerrainInfo::CheckPathAccurate vmaps hit! delta is %f %f %f",dstX - tstX,dstY - tstY,dstZ - tstZ); dstX = tstX; dstY = tstY; dstZ = tstZ + 0.1f; return true; } const float distance = sqrt((dstY - srcY)*(dstY - srcY) + (dstX - srcX)*(dstX - srcX)); const float DELTA = 0.5f; const uint8 numChecks = ceil(fabs(distance/DELTA)); const float DELTA_X = (dstX-srcX)/numChecks; const float DELTA_Y = (dstY-srcY)/numChecks; const float DELTA_Z = (dstZ-srcZ)/numChecks; float lastGoodX = srcX; float lastGoodY = srcY; float lastGoodZ = srcZ; uint32 errorsCount = 0; uint32 goodCount = 0; uint32 vmaperrorsCount = 0; std::set<GameObject*> inLOSGOList; bool bGOCheck = false; if (mover) { std::list<GameObject*> tempTargetGOList; MaNGOS::GameObjectInRangeCheck check(mover, tstX, tstY, tstZ, distance + 2.0f *mover->GetObjectBoundingRadius()); MaNGOS::GameObjectListSearcher<MaNGOS::GameObjectInRangeCheck> searcher(tempTargetGOList, check); Cell::VisitAllObjects(mover, searcher, 2*mover->GetObjectBoundingRadius()); if (!tempTargetGOList.empty()) { for(std::list<GameObject*>::iterator iter = tempTargetGOList.begin(); iter != tempTargetGOList.end(); ++iter) { GameObject* pGo = *iter; if (!pGo || !pGo->IsInWorld()) continue; // Not require check GO's, if his not in path // first fast check if (pGo->GetPositionX() > std::max(srcX, dstX) || pGo->GetPositionX() < std::min(srcX, dstX) || pGo->GetPositionY() > std::max(srcY, dstY) || pGo->GetPositionY() < std::min(srcY, dstY)) continue; // don't check very small and very large objects if (pGo->GetDeterminativeSize(true) < mover->GetObjectBoundingRadius() * 0.5f || pGo->GetDeterminativeSize(false) > mover->GetObjectBoundingRadius() * 100.0f) continue; // second check by angle float angle = mover->GetAngle(pGo) - mover->GetAngle(dstX, dstY); if (abs(sin(angle)) * pGo->GetExactDist2d(srcX, srcY) > pGo->GetObjectBoundingRadius() * 0.5f) continue; bool bLOSBreak = false; switch (pGo->GetGoType()) { case GAMEOBJECT_TYPE_TRAP: case GAMEOBJECT_TYPE_SPELL_FOCUS: case GAMEOBJECT_TYPE_MO_TRANSPORT: case GAMEOBJECT_TYPE_CAMERA: case GAMEOBJECT_TYPE_FISHINGNODE: case GAMEOBJECT_TYPE_SUMMONING_RITUAL: case GAMEOBJECT_TYPE_SPELLCASTER: case GAMEOBJECT_TYPE_FISHINGHOLE: case GAMEOBJECT_TYPE_CAPTURE_POINT: break; case GAMEOBJECT_TYPE_DOOR: if (pGo->isSpawned() && pGo->GetGoState() == GO_STATE_READY) bLOSBreak = true; break; case GAMEOBJECT_TYPE_TRANSPORT: if (pGo->isSpawned() && pGo->GetGoState() == GO_STATE_ACTIVE) bLOSBreak = true; break; case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING: if (!pGo->HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED)) bLOSBreak = true; break; default: if (pGo->isSpawned()) bLOSBreak = true; break; } if (bLOSBreak) inLOSGOList.insert(pGo); } } if (!inLOSGOList.empty()) bGOCheck = true; } //Going foward until max distance for (uint8 i = 1; i < numChecks; ++i) { float prevX = srcX + (float(i-1)*DELTA_X); float prevY = srcY + (float(i-1)*DELTA_Y); float prevZ = GetHeight(prevX, prevY, srcZ + 5.0f); tstX = srcX + (float(i)*DELTA_X); tstY = srcY + (float(i)*DELTA_Y); tstZ = GetHeight(tstX, tstY, srcZ + 5.0f); MaNGOS::NormalizeMapCoord(tstX); MaNGOS::NormalizeMapCoord(tstY); if (tstZ <= INVALID_HEIGHT) break; tstZ += (0.5f + DELTA_Z); if (!CheckPath(prevX, prevY, prevZ, tstX, tstY, tstZ)) { ++vmaperrorsCount; ++errorsCount; goodCount = 0; } else if (!IsNextZcoordOK(tstX, tstY, tstZ, 5.0f)) { ++errorsCount; goodCount = 0; } else if (mover && bGOCheck) { bool bError = false; for(std::set<GameObject*>::const_iterator iter = inLOSGOList.begin(); iter != inLOSGOList.end(); ++iter) { if (!(*iter) || (*iter)->GetDistance2d(tstX, tstY) > (*iter)->GetObjectBoundingRadius()) continue; // DEBUG_LOG("TerrainInfo::CheckPathAccurate GO %s in LOS found, %f %f %f ",(*iter)->GetObjectGuid().GetString().c_str(),tstX,tstY,tstZ); bError = true; break; } if (bError) { ++errorsCount; goodCount = 0; } else ++goodCount; } else { ++goodCount; } // DEBUG_LOG("TerrainInfo::CheckPathAccurate test data %f %f %f good=%u, errors=%u vmap=%u",tstX,tstY,tstZ, goodCount, errorsCount, vmaperrorsCount); if (!errorsCount) { lastGoodX = prevX; lastGoodY = prevY; lastGoodZ = prevZ; } else if (onlyLOS) break; if (errorsCount && goodCount > 10) { --errorsCount; goodCount -= 10; } } if (errorsCount) { dstX = lastGoodX; dstY = lastGoodY; dstZ = GetHeight(lastGoodX, lastGoodY, lastGoodZ+2.0f) + 0.5f; } else { dstX = tstX; dstY = tstY; dstZ = GetHeight(tstX, tstY, tstZ+2.0f) + 0.5f; } return (errorsCount == 0); }
ResourceLocation::ResourceLocation( std::string Path ) : RelativePath(Path) { SME_ASSERT(CheckPath() == true); }
unsigned char ReadIniFile(void) { HANDLE hr=NULL; unsigned char Index=0; char Temp[MAX_PATH]; //Loads the config structure from the hard disk CurrentConfig.CPUMultiplyer = GetPrivateProfileInt("CPU","DoubleSpeedClock",2,IniFilePath); CurrentConfig.FrameSkip = GetPrivateProfileInt("CPU","FrameSkip",1,IniFilePath); CurrentConfig.SpeedThrottle = GetPrivateProfileInt("CPU","Throttle",1,IniFilePath); CurrentConfig.CpuType = GetPrivateProfileInt("CPU","CpuType",0,IniFilePath); CurrentConfig.MaxOverclock = GetPrivateProfileInt("CPU", "MaxOverClock",100, IniFilePath); CurrentConfig.AudioRate = GetPrivateProfileInt("Audio","Rate",3,IniFilePath); GetPrivateProfileString("Audio","SndCard","",CurrentConfig.SoundCardName,63,IniFilePath); Cassette::readConfig(IniFilePath); CurrentConfig.MonitorType = GetPrivateProfileInt("Video","MonitorType",1,IniFilePath); CurrentConfig.ScanLines = GetPrivateProfileInt("Video","ScanLines",0,IniFilePath); CurrentConfig.Resize = GetPrivateProfileInt("Video","AllowResize",0,IniFilePath); CurrentConfig.Aspect = GetPrivateProfileInt("Video","ForceAspect",0,IniFilePath); CurrentConfig.AutoStart = GetPrivateProfileInt("Misc","AutoStart",1,IniFilePath); CurrentConfig.CartAutoStart = GetPrivateProfileInt("Misc","CartAutoStart",1,IniFilePath); GetPrivateProfileString("Misc", "LastPakPath", "", Temp, MAX_PATH, IniFilePath); vccPakSetLastPath(Temp); GetPrivateProfileString("Misc", "LastPrnPath", "", LastPrnPath, MAX_PATH, IniFilePath); CurrentConfig.RamSize = GetPrivateProfileInt("Memory","RamSize",1,IniFilePath); GetPrivateProfileString("Memory","ExternalBasicImage","",CurrentConfig.ExternalBasicImage,MAX_PATH,IniFilePath); GetPrivateProfileString("Module","OnBoot","",CurrentConfig.ModulePath,MAX_PATH,IniFilePath); CurrentConfig.KeyMap = GetPrivateProfileInt("Misc","KeyMapIndex",0,IniFilePath); if (CurrentConfig.KeyMap>3) CurrentConfig.KeyMap=0; //Default to DECB Mapping vccKeyboardBuildRuntimeTable((keyboardlayout_e)CurrentConfig.KeyMap); CheckPath(CurrentConfig.ModulePath); CheckPath(CurrentConfig.ExternalBasicImage); Left.UseMouse=GetPrivateProfileInt("LeftJoyStick","UseMouse",1,IniFilePath); Left.Left=GetPrivateProfileInt("LeftJoyStick","Left",75,IniFilePath); Left.Right=GetPrivateProfileInt("LeftJoyStick","Right",77,IniFilePath); Left.Up=GetPrivateProfileInt("LeftJoyStick","Up",72,IniFilePath); Left.Down=GetPrivateProfileInt("LeftJoyStick","Down",80,IniFilePath); Left.Fire1=GetPrivateProfileInt("LeftJoyStick","Fire1",59,IniFilePath); Left.Fire2=GetPrivateProfileInt("LeftJoyStick","Fire2",60,IniFilePath); Left.DiDevice=GetPrivateProfileInt("LeftJoyStick","DiDevice",0,IniFilePath); Left.HiRes= GetPrivateProfileInt("LeftJoyStick", "HiResDevice", 0, IniFilePath); Right.UseMouse=GetPrivateProfileInt("RightJoyStick","UseMouse",1,IniFilePath); Right.Left=GetPrivateProfileInt("RightJoyStick","Left",75,IniFilePath); Right.Right=GetPrivateProfileInt("RightJoyStick","Right",77,IniFilePath); Right.Up=GetPrivateProfileInt("RightJoyStick","Up",72,IniFilePath); Right.Down=GetPrivateProfileInt("RightJoyStick","Down",80,IniFilePath); Right.Fire1=GetPrivateProfileInt("RightJoyStick","Fire1",59,IniFilePath); Right.Fire2=GetPrivateProfileInt("RightJoyStick","Fire2",60,IniFilePath); Right.DiDevice=GetPrivateProfileInt("RightJoyStick","DiDevice",0,IniFilePath); Right.HiRes = GetPrivateProfileInt("RightJoyStick", "HiResDevice", 0, IniFilePath); for (Index = 0; Index < NumberOfSoundCards; Index++) { if (!strcmp(SoundCards[Index].CardName, CurrentConfig.SoundCardName)) { CurrentConfig.SndOutDev = Index; } } TempConfig=CurrentConfig; vccPakInsertModule (CurrentConfig.ModulePath); // Should this be here? return(0); }
void loop(){ api.getMyZRState(self); //get my own location and save to self api.getOtherZRState(other); //get opponent's location and save to other if (counter < 2) { itemNum = 0; otherNum = 1; if(self[0]<0){ itemNum=1; otherNum=0; } } stayInBounds(); if(step==acquireLaser){ //fist step stayInBounds(); if(game.haveItem(1, itemNum)||counter==68){ if(otherNum!=itemNum){ atarget[0]=-atarget[0]; otherNum=1-otherNum; } else{ step = GravityPull; } } if(counter > 28 && !game.isNetBroken()) { if(otherNum!=itemNum){ atarget[0]=-atarget[0]; otherNum=1-otherNum; } else if (!game.haveItem(1, otherNum)) { if(otherNum!=itemNum){ atarget[0]=-atarget[0]; otherNum=1-otherNum; } } else{ step = GravityPull; } } debrisOnPath=CheckPath(atarget); //check if any debris is on way to laser pack if(debrisOnPath > -1){ //if so if(distance(self, debrisArr[debrisOnPath])< 0.32f){ //slow down as you approach the debris mathVecSubtract(down, self, debrisArr[debrisOnPath], 3); down[1]=0; mathVecNormalize(down, 3); down[0]*=3; down[2]*=3; api.setVelocityTarget (down); } else{ goFast(atarget, 0.07f); } } else{ //if no debris on path, go straight to laser api.setPositionTarget(atarget); arbState[0] = self[3]; arbState[1] = self[4]; arbState[2] = self[5]; //DEBUG(("%f",mathVecMagnitude(arbState, 3))); if(distance(self, atarget)< 0.05f && mathVecMagnitude(arbState, 3) < 0.01f){ //if close enough to laser pack step=spin; } } } else if(step == spin){ aimToPickUpLaser[0]=0.0f; aimToPickUpLaser[1]=0.0f; aimToPickUpLaser[2]=0.3f; api.setAttRateTarget(aimToPickUpLaser); //spin robot to pick up laser pack api.setPositionTarget(atarget); //mantain position on top of laser pack if(game.haveItem(0, otherNum)){ //go to next step if laser pack is acquired if(other[1] > 0.3f) { step=smasherBot; } else { step = moveToShootPos; } atarget[0]=-0.05f;//-0.35;//0.1;//0.30;//0.33; atarget[1]=0.6f;//0.15;//0.3;//0.44;//0.29; atarget[2]=0.1f;//0.1;//0;//-0.2;//-0.31;//-0.48; if(itemNum==1){ atarget[2]=-atarget[2]; } down[0] = 0.0f; down[1] = 0.0f; down[2] = 0.0f; } } else if(step==moveToShootPos){ // if second step game.getCometState(0, arbState); //DEBUG(("%f, %f, %f", arbState[0], arbState[1], arbState[2])); mathVecSubtract(aimVector,arbState,self,3); //find vector between self and the starting position of the comet atarget[0] = arbState[0] - 0.35f; if(itemNum == 1){ atarget[0] = arbState[0] + 0.35f; } debrisOnPath=CheckPath(atarget); //check for any debris on path to Shooting location if(debrisOnPath > -1){ //if there is, get it if(distance(self, debrisArr[debrisOnPath])< 0.3f){ //slow down as you approach the debris mathVecSubtract(down, self, debrisArr[debrisOnPath], 3); down[0]=0.0f; down[1]=0.0f; mathVecNormalize(down, 3); api.setForces(down); } else{ api.setPositionTarget(atarget); } } else{ //if there isn't, go straight to shooting Location api.setPositionTarget(atarget); } api.setAttitudeTarget(aimVector); //constantly be adjusting attitude to face starting position of comet if(counter>87){ down[0] = 0.015f; down[1] = -0.026f;//23; down[2] = 0.005f; if(itemNum == 1){ down[0] *= -1; down[2] *= -1; } api.setVelocityTarget(down); } if(counter==90){ //wait for phase two to begin and go onto next step step=shootLaser; } } if(step==shootLaser){ //phase two: shooting lasers game.getCometState(0, arbState); //get position of comet //game.predictCometState(3, arbState, finState); //predict position of comet in three seconds (gives more sooting accuracy) mathVecSubtract(aimVector,arbState,self,3); //find vector between self and comet's [predicted] position if(counter>92){ down[0] = 0.015f; down[1] = -0.025f;//23; down[2] = 0.01f; if(itemNum == 1){ down[0] *= -1; down[2] *= -1; } api.setVelocityTarget(down); } api.setAttitudeTarget(aimVector); //constantly adjust attitude to aim at the comet if(isInShot()){ hit = game.shootLaser(); //shoot laser if(hit){ //print whether shot was successful DEBUG (("Hit on B5")); //joke referencing the game Battlefield } else{ //print if shot missed DEBUG (("MISS")); } } //api.setPositionTarget(shootPos); if(game.laserShotsRemaining()==0){ //once out of laser shots, go onto next step step=smasherBot; } } if(step==smasherBot){ // once finished shooting comets, play SmasherBot stayInBounds(); goFast(other, 0.09); if(counter>64&&counter<90){ stayInBounds(); step = moveToShootPos; } } /* if(step == antiSmasherBot){ findClosestDebris(); if(game.haveDebris(0,x)){ DEBUG(("Gotcha")); debCounter++; } x=closestDebris; DEBUG((" x is: %d", closestDebris)); goFast(debrisArr[x],0.06); game.getCometState(0, arbState); gravityStartPos[0] = arbState[0] + 0.15; gravityStartPos[2] = arbState[2] - 0.05; if(itemNum == 1){ gravityStartPos[0] = arbState[0] - 0.15; gravityStartPos[2] = arbState[2] + 0.05; } if(debCounter==2 || counter>64){ step=GravityPull; } } */ if(step == GravityPull){ if(counter<91){ gravityStartPos[0] = 0.45;//arbState[0] + 0.15f; gravityStartPos[2] = arbState[2] - 0.05f; if(itemNum == 1){ gravityStartPos[0] = -0.45;//arbState[0] - 0.15f; gravityStartPos[2] = arbState[2] + 0.05f; } debrisOnPath=CheckPath(gravityStartPos); //check if any debris is on way to laser pack if(debrisOnPath > -1){ //if so if(distance(self, debrisArr[debrisOnPath])< 0.3f){ //slow down as you approach the debris mathVecSubtract(down, self, debrisArr[debrisOnPath], 3); down[1]=0; mathVecNormalize(down, 3); api.setForces(down); } else{ goFast(gravityStartPos, 0.06f); } } else{ //if no debris on path, go straight to laser goFast(gravityStartPos, 0.06f); } } else{ game.getCometState(0, arbState); //get position of comet //game.predictCometState(3, arbState, finState); atarget[0] = arbState[0] + 0.2f; if(self[0]<0){ atarget[0] = arbState[0] - 0.2f; } atarget[1] = arbState[1] - 0.1f; atarget[2] = arbState[2]; goFast(atarget, 0.09f); } } counter++; }
bool TerrainInfo::CheckPathAccurate(float srcX, float srcY, float srcZ, float& dstX, float& dstY, float& dstZ, Unit* mover ) const { float tstX = dstX; float tstY = dstY; float tstZ = dstZ; // check by standart way. may be not need path checking? if (!mover && CheckPath(srcX, srcY, srcZ, tstX, tstY, tstZ) && IsNextZcoordOK(tstX, tstY, tstZ, 5.0f)) { DEBUG_LOG("TerrainInfo::CheckPathAccurate vmaps hit! delta is %f %f %f",dstX - tstX,dstY - tstY,dstZ - tstZ); dstX = tstX; dstY = tstY; dstZ = tstZ + 0.1f; return true; } const float distance = sqrt((dstY - srcY)*(dstY - srcY) + (dstX - srcX)*(dstX - srcX)); const float DELTA = 0.5f; const uint8 numChecks = ceil(fabs(distance/DELTA)); const float DELTA_X = (dstX-srcX)/numChecks; const float DELTA_Y = (dstY-srcY)/numChecks; float lastGoodX = srcX; float lastGoodY = srcY; float lastGoodZ = srcZ; uint32 errorsCount = 0; uint32 goodCount = 0; uint32 vmaperrorsCount = 0; //Going foward until max distance for (uint8 i = 1; i < numChecks; ++i) { float prevX = srcX + (float(i-1)*DELTA_X); float prevY = srcY + (float(i-1)*DELTA_Y); float prevZ = GetHeight(prevX, prevY, srcZ+5.0f); tstX = srcX + (float(i)*DELTA_X); tstY = srcY + (float(i)*DELTA_Y); tstZ = GetHeight(tstX, tstY, srcZ+5.0f); MaNGOS::NormalizeMapCoord(tstX); MaNGOS::NormalizeMapCoord(tstY); if (tstZ <= INVALID_HEIGHT) break; tstZ += 0.5f; if (!CheckPath(prevX, prevY, prevZ, tstX, tstY, tstZ)) { ++vmaperrorsCount; ++errorsCount; goodCount = 0; } else if (!IsNextZcoordOK(tstX, tstY, tstZ, 5.0f)) { ++errorsCount; goodCount = 0; } else if (mover) { std::list<GameObject*> tempTargetGOList; MaNGOS::GameObjectInRangeCheck check(mover, tstX, tstY, tstZ, 2*mover->GetObjectBoundingRadius()); MaNGOS::GameObjectListSearcher<MaNGOS::GameObjectInRangeCheck> searcher(tempTargetGOList, check); Cell::VisitAllObjects(mover, searcher, 2*mover->GetObjectBoundingRadius()); if (!tempTargetGOList.empty()) { for(std::list<GameObject*>::iterator iter = tempTargetGOList.begin(); iter != tempTargetGOList.end(); ++iter) { if (((*iter)->GetGoType() == GAMEOBJECT_TYPE_DOOR && (*iter)->GetGoState() == GO_STATE_READY) || (*iter)->GetGoType() != GAMEOBJECT_TYPE_DOOR) { ++errorsCount; goodCount = 0; } } } else ++goodCount; } else { ++goodCount; } if (!errorsCount) { lastGoodX = prevX; lastGoodY = prevY; lastGoodZ = prevZ; } // DEBUG_LOG("TerrainInfo::CheckPathAccurate test data %f %f %f good=%u, errors=%u vmap=%u",tstX,tstY,tstZ, goodCount, errorsCount, vmaperrorsCount); if (errorsCount && goodCount > 10) { --errorsCount; goodCount -= 10; } } if (errorsCount) { dstX = lastGoodX; dstY = lastGoodY; dstZ = GetHeight(lastGoodX, lastGoodY, lastGoodZ+2.0f) + 0.5f; } else { dstX = tstX; dstY = tstY; dstZ = GetHeight(tstX, tstY, tstZ+2.0f) + 0.5f; } return (errorsCount == 0); }
int main (int args, char *argc[]) { FILE *f; char buf[64]; char temp[64]; char path[64]; int add; long oldscore; unsigned int oldtime; unsigned int start = time(NULL); unsigned int spent; srand(time(NULL)); printf("\n"); printf("*********************************************************\n"); printf("Welcome to TAWS (Text Adventure Without Swords) volume 2!\n"); printf("*********************************************************\n"); printf("\n"); ConstructGrid(); DisplayGrid(); timestart = time(NULL); while (1) { printf("\n"); printf("Enter command here: "); scanf("%s", buf); if (!strcmp(buf, "show")) DisplayGrid(); else if (buf[0] == '5' || !strcmp(buf, "new")) { ConstructGrid(); DisplayGrid(); timestart = time(NULL); } else if (!strcmp(buf, "score")) printf("Score: %li\n", score); else if (!strcmp(buf, "help")) { printf("The object of TAWS v2 is to enter a sequence\n"); printf("of numbers (on the numpad) that matches a path to\n"); printf("the finish (F) from the start (S). Avoid mines (*).\n"); printf("For example, 8 moves up, 9 moves up and right, and 2 moves down.\n"); printf("-- Commands --\n"); printf("#####: Type a series of numbers and hit enter to enter a path.\n"); printf("'score': Show your current score.\n"); printf("'new' or '5': Generate a new board.\n"); printf("'show': Display current board.\n"); printf("'help': Show this help.\n"); printf("'highscore': See a saved highscore.\n"); printf("'exit': Exit the game, but why would you want that?\n"); printf("-- Tips --\n"); printf("The shorter your path and faster you do it, the more points you get!\n"); } else if (!strcmp(buf, "TAWS")) { printf("TAWS is most commonly known as Text Adventure Without Swords.\n"); printf("However, it has other meanings as well, including:\n"); printf("Timed Avoidance Withstanding Simulation\n"); printf("Torrential Admission of Watery Soup\n"); printf("Timetable Antithesis Waking Somebody\n"); printf("Top Ankle Wise Surrender\n"); printf("... or just TAWS.\n"); } else if (!strcmp(buf, "highscore")) { printf("Please enter a name: "); scanf("%s", temp); sprintf(path, "%s.sav", temp); f = fopen(path, "rb"); if (f) { fread(&oldscore, sizeof(long), 1, f); fread(&oldtime, sizeof(unsigned int), 1, f); fclose(f); printf("Old score for %s: %li in %u seconds.\n", temp, oldscore, oldtime); } else printf("Failed to open save file %s.\n", path); } else if (!strcmp(buf, "quit") || !strcmp(buf, "exit")) break; else if (IsANumber(buf[0])) { int result = CheckPath(buf); if(result == FINISH) { float timediff = (float)(time(NULL)-timestart); if (timediff > 0) add = 50-(strlen(buf)-4)*4 + (int)(50.0f*(float)strlen(buf)/(float)(time(NULL)-timestart)); else add = 50-(strlen(buf)-4)*4 + (int)(50.0f*(float)strlen(buf)); printf("Score: %li+%i=%li\n", score, add, score+add); score += add; } else { printf("You didn't make it to the finish!\n"); printf("Score: %li-250=%li\n", score, score-250); score -= 250; } ConstructGrid(); DisplayGrid(); timestart = time(NULL); } else printf("Come on, type something real (try 'help').\n"); } spent = time(NULL)-start; printf("You got %li points in %u minutes and %u seconds. Good job!\n", score, (spent/60), (spent%60)); printf("Please enter your name: "); scanf("%s", buf); sprintf(temp, "%s.sav", buf); f = fopen(temp, "rb"); if (f) { fread(&oldscore, sizeof(long), 1, f); fread(&oldtime, sizeof(unsigned int), 1, f); fclose(f); } else { oldscore = 0; oldtime = 0; } if (score > oldscore) { f = fopen(temp, "wb"); if (f) { printf("New personal highscore: %li in %u seconds!\n", score, spent); fwrite(&score, sizeof(long), 1, f); fwrite(&spent, sizeof(unsigned int), 1, f); } } if (oldscore > 0) printf("Old personal highscore: %li in %u seconds.\n", oldscore, oldtime); printf("Well wasn't that fun? See you next time!\n\n"); return 0; }
bool CCensorNode::CheckPath(const UString &path, bool isFile, bool &include) const { UStringVector pathParts; SplitPathToParts(path, pathParts); return CheckPath(pathParts, isFile, include); }