Пример #1
0
void 
CreateReposDlg::OnButtonBrowseDirClick(wxCommandEvent & WXUNUSED(event))
{
  wxASSERT(0 != m_comboDir);

  wxDirDialog dialog(this, _("Select a directory"),
                     GetDir(),
                     wxDD_NEW_DIR_BUTTON);

  if (dialog.ShowModal() == wxID_OK)
  {
    m_comboDir->SetValue(dialog.GetPath());
    CheckValues();
  }
}
Пример #2
0
// 添加到CByteArray
bool CShape::CodeToDataBlock(DBWriteSet& setWriteDB, bool bExData)
{
	CBaseObject::CodeToDataBlock(setWriteDB,bExData);
	setWriteDB.AddToByteArray((BYTE)GetCurRgnType());
	setWriteDB.AddToByteArray(GetRegionID());
	setWriteDB.AddToByteArray(GetRegionExID());
	setWriteDB.AddToByteArray(GetPosX());
	setWriteDB.AddToByteArray(GetPosY());
	setWriteDB.AddToByteArray(GetDir());
	setWriteDB.AddToByteArray(GetPos());
	setWriteDB.AddToByteArray(GetSpeed());
	setWriteDB.AddToByteArray(GetState());
	setWriteDB.AddToByteArray(GetAction());
	return true;
}
Пример #3
0
void TestFileNameTools(void)
{
	char whole[]="c:/windows/system32/abc.dll";
	char des[256];

	GetDir(whole,des);
	printf("%s\n",des);

	GetName(whole,des);
	printf("%s\n",des);

	GetExt(whole,des);
	printf("%s\n",des);

}
Пример #4
0
// 添加到CByteArray
bool CShape::AddShapeToByteArray(vector<BYTE>* pByteArray)
{
	_AddToByteArray(pByteArray,(CGUID&)GetExID());
	_AddToByteArray(pByteArray, (long)GetCurRgnType());
	_AddToByteArray(pByteArray, GetRegionID());
	_AddToByteArray(pByteArray, GetRegionExID());
	_AddToByteArray(pByteArray, GetPosX());
	_AddToByteArray(pByteArray, GetPosY());
	_AddToByteArray(pByteArray, GetDir());
	_AddToByteArray(pByteArray, GetPos());
	_AddToByteArray(pByteArray, GetSpeed());
	_AddToByteArray(pByteArray, GetState());
	_AddToByteArray(pByteArray, GetAction());
	return true;
}
Пример #5
0
		void SyncDeltaManager::Store (const Sync::ChainID_t& chainId, const Sync::Payloads_t& payloads)
		{
			Settings_.beginGroup (chainId);
			bool shouldStore = Settings_.value ("EverRequested", false).toBool ();
			Settings_.endGroup ();
			if (!shouldStore)
				return;

			QDir dir = GetDir (chainId);
			int curNum = GetLastFileNum (chainId);

			Q_FOREACH (const Sync::Payload& payload, payloads)
				StoreImpl (dir.absoluteFilePath (QString::number (++curNum)), payload);

			SetLastFileNum (chainId, curNum);
		}
Пример #6
0
bool ReportModule(void* fn)
{
    CIttLocker lock;
    if (g_savepath.empty())
        return true;

    SModuleInfo module_info = Fn2Mdl(fn);

    std::string path = GetDir(g_savepath) + std::to_string((uint64_t)module_info.base) + ".mdl";
    int fd = open(path.c_str(), O_WRONLY|O_CREAT|O_EXCL, FilePermissions);
    if (-1 == fd) return true; //file already exists
    std::string text = module_info.path + " " + std::to_string(module_info.size);
    int res = write(fd, text.c_str(), (unsigned int)text.size());
    close(fd);
    return res != -1;
}
bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
{
    // this is broken & unsafe to use on linux.
    if( m_Type == TREE_DIRECTORY )
        return false;

    if( name.IsEmpty() )
        return false;

    const wxString  sep = wxFileName().GetPathSeparator();
    wxString        newFile;
    wxString        dirs = GetDir();

    if( !dirs.IsEmpty() && GetType() != TREE_DIRECTORY )
        newFile = dirs + sep + name;
    else
        newFile = name;

    if( newFile == GetFileName() )
        return false;

    wxString    ext = TREE_PROJECT_FRAME::GetFileExt( GetType() );

    wxRegEx     reg( wxT( "^.*\\" ) + ext + wxT( "$" ), wxRE_ICASE );

    if( check && !ext.IsEmpty() && !reg.Matches( newFile ) )
    {
        wxMessageDialog dialog( m_parent, _(
            "Changing file extension will change file type.\n Do you want to continue ?" ),
            _( "Rename File" ),
            wxYES_NO | wxICON_QUESTION );

        if( wxID_YES != dialog.ShowModal() )
            return false;
    }

    if( !wxRenameFile( GetFileName(), newFile, false ) )
    {
        wxMessageDialog( m_parent, _( "Unable to rename file ... " ),
                         _( "Permission error ?" ), wxICON_ERROR | wxOK );
        return false;
    }

    SetFileName( newFile );

    return true;
}
Пример #8
0
func Activate(pCaster,pRealcaster) {
  var pClonk, pComboObj, fBlast;
  if(pRealcaster) pClonk=pRealcaster;
  else pClonk=pCaster;

  var iResult;
  if (iResult = CheckEffect("LightningNSpell", 0, 125)) return(iResult!=-1 && RemoveObject());
  
  // Zielen wenn möglich
  if (pClonk->~DoSpellAim(this())) return(1);

  var obj = CreateObject(MCLX, 0, 0, GetOwner(pClonk));
  obj->Launch(pClonk, GetDir(pClonk), GetX(pClonk), GetY(pClonk), 0);
  Sound("Thunder*");
  RemoveObject();
  return(1);
}
Пример #9
0
void Projectile::Update( float _dt )
{
	// Add the current velocity to the position.
	this->SetPos(this->GetPos() + this->GetVel() * _dt);
	this->SetVel(this->GetVel() * 0.99f);
	
	// Cap max speed
	if(D3DXVec2Length(&this->GetVel()) > this->GetMaxSpeed())
	{
		D3DXVECTOR2 cappedVel;
		D3DXVec2Normalize(&cappedVel,&this->GetVel());
		cappedVel *= this->GetMaxSpeed();
		this->SetVel(cappedVel);
	}

	D3DXVECTOR2 vel = this->GetDir() * this->GetMaxSpeed();
	this->SetVel(vel);

	if( m_IsHoming )
	{
		// TODO:: this is for player only, change for AI.
		if(m_Target != nullptr && m_Target->GetIsAlive())
		{
			TurnToTarget(_dt);
			// TODO:: also leave smoke trail
		}
		else
		{
			if(this->m_Owner->GetType() == Entity_PlayerShip)
				m_Target = AIManager::GetInstance()->GetClosestEnemy(this->GetPos());
			else
				m_Target = AIManager::GetInstance()->GetTarget();
		}

		m_SmokeTrailEmitter->Update(_dt*2.0f, GetPos().x, GetPos().y - GetDir().y*16);
	}

	

	m_Life -= _dt;
	if(m_Life <= 0.0f)
	{
		m_Life = 5.0f;
		this->SetIsAlive(false);
	}
}
Пример #10
0
private func DoDirControl(int iDir)
  {
  // Abbruch, wenn das Zielobjekt weg ist
  if (!pTargetObject) return(Abort());
  // Richtungsänderung?
  if (iDir != GetDir(pTargetObject))
    {
    iAngle=-iAngle;
    pTargetObject->SetDir(iDir);
    pArrow->UpdateAngle(iAngle);
    pTargetObject->~AimingAngle(iAngle);
    }
  else
    // Tastendruck in Zielrichtung: Zaubern! - nicht bei tumble!
    if(!(GetAction(pTargetObject) S= "Tumble"))
     DoEnter();
  return(1);
  }
Пример #11
0
func Activate(pCaster,pRealcaster) {
  var pClonk;
  if(pRealcaster) pClonk=pRealcaster;
  else pClonk=pCaster;

  var iResult;
  if (iResult = CheckEffect("Blast", 0, 125)) return(iResult!=-1 && RemoveObject());
  
  // Zielen wenn möglich
  if (pClonk->~DoSpellAim(this())) return(1);

  // Blitz erzeugen
  var obj = CreateObject(_LVS, 0, 0, GetOwner(pClonk));
  obj->Launch(pClonk, GetDir(pClonk), GetX(pClonk), GetY(pClonk), 0);
  Sound("Inflame");
  RemoveObject();
  return(1);
}
Пример #12
0
  /** 
   * Get list of runs associated with production
   *  
   * @param url     The production URL 
   * @param mc      True of MC
   * @param minSize Least size of runs to use 
   * 
   * @return true on success
   */
  Bool_t GetRuns(const TString& url, Bool_t mc, ULong_t minSize)
  {
    TString index("job");
    if (!Download(Form("%s%s", (mc ? "" : "raw/"), url.Data()), index)) 
      return false;

    std::ifstream in(index.Data());
    TString tgt1(mc ? "window.open" : "runDetails");
    TString line  = "";
    do { 
      line.ReadLine(in);
      if (!line.Contains(tgt1)) continue;
      Int_t   first = -1;
      Int_t   last  = -1;
      if (!mc) { 
	first = line.Index(tgt1);
	last  = line.Index(")", first+tgt1.Length()+1);
      }
      else { 
	Int_t tmp = line.Index(">");
	first = line.Index(">", tmp+1);
	last  = line.Index("<", first);
      }
      if (first == kNPOS || last == kNPOS) { 
	Error("GetDir", "Failed to get directory from %s", line.Data());
	return false;
      }
      first += (mc ? 1 : tgt1.Length()+1);
      last  -= first;
      TString srun  = line(first, last);
      ULong_t runNo = srun.Atoll();
      if (fDebug) Info("", "Got run %lu (%s)", runNo, srun.Data());

      if (!GetSize(in, runNo, mc, minSize)) continue;
      if (!GetDir(in, runNo, mc))           continue;

      if (!fRuns.IsNull()) fRuns.Append(",");
      fRuns.Append(Form("%lu", runNo));
    } while (!in.eof());
    in.close();
    if (fRuns.IsNull()) return false;

    return true;
  }
Пример #13
0
// -------------------------------------------------------------------------
// SUBROUTINE - TrueDir
//
// This routine returns the direction given the north direction in 0-15.
//
// Returns: The direction in a 0-15 order with 0 north and clockwise from that.
//          16 is returned for no DS2401s found.
//
int TrueDir(int portnum, WeatherStruct *wet)
{
   int dir;
   int retdir;

   dir = GetDir(portnum, wet);

   if(dir != 16)
   {
      if( (dir-wet->north) < 0 )
         retdir = (dir - wet->north + 16);
      else
         retdir = dir - wet->north;
   }
   else
      retdir = 16;

   return retdir;
}
Пример #14
0
_Spit::_Spit(const Id & owner, float spd, bool bBounce, int bounceMax, int sndInd)
: Projectile(PROJ_SPIT, owner), m_bBounce(bBounce), m_bounceMax(bounceMax),
m_bounceCur(0), m_tSnd(0)
{
	//set move
	m_spd.MoveSetSpeed(spd);

	SetFlag(PROJ_FLAG_OBJINVUL, bBounce);

	if(sndInd > -1)
	{
		BASS_3DVECTOR pos, orient;

		memcpy(&pos, (float*)GetLoc(), sizeof(pos)); pos.z *= -1;
		memcpy(&orient, (float*)GetDir(), sizeof(orient)); orient.z *= -1;

		m_tSnd = TaTaSoundPlay(sndInd, &pos, &orient, 0);
	}
}
Пример #15
0
SVFIP VirtualFAT::GetPath(SVFIP Item, char* PathName)
{
    SVFIP D;
    char *p, *s;

    if (!Item) D = Root;
    else D = Item;

    if (lstrlen(PathName)==0) return Root;

    p = my_strdup(PathName);
    char *fn = ExtractName(PathName);
    while (TRUE){
        char * t = ExtractRoot(p);
        
        D = GetDir(D, t);
        
        if (!D) {
            my_free(t);
            my_free(p);
            my_free(fn);
            return NULL;
        }
        s = my_substr(p, lstrlen(t)+1, lstrlen(p));                
        if (lstrlen(s)==0) {        
            my_free(t);
            my_free(p);
            my_free(s);
            my_free(fn);
            return D;
        }        
        my_free(p);
        my_free(t);        
        p = s;
    }
    my_free(p);
    my_free(fn);
    
    return NULL;
}
Пример #16
0
			Sync::Payloads_t DeltaStorage::Get (const Sync::ChainID_t& chainId)
			{
				DeltasRequested (chainId);

				QMap<int, Sync::Payload> tmpPayloads;

				QDir dir = GetDir (chainId);

				Q_FOREACH (const QString& filename, dir.entryList (QDir::Files | QDir::NoDotAndDotDot))
				{
					bool ok = true;
					int num = filename.toInt (&ok);
					if (!ok)
						continue;

					QFile file (dir.absoluteFilePath (filename));
					if (!file.open (QIODevice::ReadOnly))
					{
						qWarning () << Q_FUNC_INFO
								<< "unable to open"
								<< file.fileName ()
								<< "for reading:"
								<< file.errorString ();
						throw std::runtime_error ("Unable to open file for reading.");
					}

					QByteArray data = file.readAll ();
					Sync::Payload payload = Sync::Deserialize (qUncompress (data));
					tmpPayloads [num] = payload;
				}

				QList<Sync::Payload> result;
				QList<int> keys = tmpPayloads.keys ();
				std::sort (keys.begin (), keys.end ());
				Q_FOREACH (int key, keys)
					result << tmpPayloads [key];

				return result;
			}
Пример #17
0
IVFileSystem::FileStreamPtr VSimpleVfs::OpenFile(
	VStringParam in_strPathAndName,
	VAccessModeFlags in_Access)
{
	IVDirectory* pDir;
	
	// get dir
	pDir = GetDir(in_strPathAndName);

	// get file
	std::string strPathAndName = in_strPathAndName;
	std::string strFileName;
	strFileName.assign(
		std::find(strPathAndName.rbegin(), strPathAndName.rend(), '/').base(),
		strPathAndName.end() );

	// open it
	VDirectory::FileIter fileIter = pDir->Files();
	while(fileIter.HasNext())
	{
		if( strFileName == fileIter->GetName().AsCString() )
			break;
		else
			++fileIter;
	}

	if( !fileIter.HasNext() )
	{
		std::string errorMsg = "file \"";
		errorMsg += strFileName;
		errorMsg += "\" does not exist";

		V3D_THROW(VIOException, errorMsg.c_str());
	}

	IVFile::FileStreamPtr pFileStream = fileIter->Open(in_Access);

	return pFileStream;
}
Пример #18
0
void CPyScriptAutoConfigDlg::OnBnClickedBtnBrowse()
{
	CFileDialog dlgFile(true,_T(".py"),_T("*.py"),0,_T("Python Script Files (*.py)|*.py||"));
	CString str = GetDir(m_strConverterFilespec);
	dlgFile.m_ofn.lpstrInitialDir = str;

	if (dlgFile.DoModal() != IDOK)
		return;

	// since this is a new table, reset all the relevant fields
	ResetFields();

	m_strConverterFilespec = dlgFile.GetPathName( );

	if( m_strConverterFilespec.IsEmpty() )
		return;

	m_ctlScriptFilespec.SetWindowText(m_strConverterFilespec);

	// initialize the combo box of function names
	InitFuncNameComboBox();

	m_cbFunctionNames.SetFocus();
}
	ERMsg CUISolutionMesonetDaily::GetWeatherStation(const std::string& ID, CTM TM, CWeatherStation& station, CCallback& callback)
	{
		ERMsg msg;

		string workingDir = GetDir(WORKING_DIR);
		int firstYear = as<int>(FIRST_YEAR);
		int lastYear = as<int>(LAST_YEAR);
		size_t nbYears = lastYear - firstYear + 1;


		((CLocation&)station) = m_stations[ID];
		Trim(station.m_name);

		bool bFirst = true;
		for (size_t y = 0; y < nbYears&&msg; y++)
		{
			int year = firstYear + int(y);

			string filePath = workingDir + ToString(year) + "\\" + ID + ".wea";
			if (FileExists(filePath))
				msg += station.LoadData(filePath, -996, false);

			msg += callback.StepIt(0);
		}//for all year


		if (msg)
		{
			//verify station is valid
			if (station.HaveData())
				msg = station.IsValid();
		}


		return msg;
	}
Пример #20
0
float CSkeleton::CBone::GetLength() const
{
	return GetDir().Abs();
}
Пример #21
0
CSkeleton::TVec CSkeleton::CBone::GetDirNormalized() const
{
	return GetDir().Normalized();
}
Пример #22
0
/*---------------------------------------------------------------------------------------------
Name				:	GetFolderPath(void)
Purpose				:	File location or directory path [e.g.: "c:\folder\subfolder\"]
Parameters			:	None.
Return				:	CString -   File location or directory path
Globals Modified	:	None.
--------------------------------------------------------------------------------------------*/
CString	CPath::GetFolderPath()
{
	return _strDrive + GetDir();
}
Пример #23
0
CString CXTPSplitPath::GetFullPath() const
{
	return GetDrive() + GetDir();
}
Пример #24
0
//=============================================================================
void Update(float dt)
{
	// selecting unit
	INT2 tile((cursor_pos.x + cam_pos.x)/32, (cursor_pos.y + cam_pos.y)/32);
	if(tile.x >= 0 && tile.y >= 0 && tile.x < MAP_W && tile.y < MAP_W && MousePressedRelease(1))
	{
		Tile& t = mapa[tile.x+tile.y*MAP_W];
		selected = t.unit;
	}

	// sleep button
	if(player && player->alive && player->inside_building && cursor_pos.x >= 32 && cursor_pos.y >= 700 && cursor_pos.x < 32+16 && cursor_pos.y < 700+16 && MousePressedRelease(1))
	{
		if(player->gold >= 10 && !player->sleeping && player->hp != player->base->hp)
		{
			player->gold -= 10;
			player->sleeping = true;
			player->sleeping_progress = 0.f;
		}
	}

	// update player
	if(player && player->alive && player->waiting <= 0.f && !player->moving)
	{
		Unit& u = *player;

		if(player->sleeping)
		{
			player->sleeping_progress += dt;
			if(player->sleeping_progress >= 1.f)
			{
				player->hp += 5;
				player->sleeping_progress = 0.f;
				if(player->hp >= player->base->hp)
				{
					player->hp = player->base->hp;
					player->sleeping = false;
				}
			}
		}
		else if(u.inside_building)
		{
			// unit inside building, press SPACE to exit
			if(KeyPressedRelease(SDL_SCANCODE_SPACE) && !mapa[u.pos.x+u.pos.y*MAP_W].unit)
			{
				if(!TryMove(u, DIR_S, false))
				{
					if(rand()%2 == 0)
					{
						if(!TryMove(u, DIR_SW, false))
						{
							if(TryMove(u, DIR_SE, false))
								u.inside_building = false;
						}
						else
							u.inside_building = false;
					}
					else
					{
						if(!TryMove(u, DIR_SE, false))
						{
							if(TryMove(u, DIR_SW, false))
								u.inside_building = false;
						}
						else
							u.inside_building = false;
					}
				}
				else
					u.inside_building = false;
			}
		}
		else
		{
			struct Key1
			{
				SDL_Scancode k1;
				SDL_Scancode k2;
				DIR dir;
			};
			const Key1 keys1[] = {
				SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_4, DIR_W,
				SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_6, DIR_E,
				SDL_SCANCODE_UP, SDL_SCANCODE_KP_8, DIR_N,
				SDL_SCANCODE_DOWN, SDL_SCANCODE_KP_2, DIR_S
			};
			struct Key2
			{
				SDL_Scancode k1;
				SDL_Scancode k2;
				SDL_Scancode k3;
				DIR dir;
			};
			const Key2 keys2[] = {
				SDL_SCANCODE_KP_1, SDL_SCANCODE_LEFT, SDL_SCANCODE_DOWN, DIR_SW,
				SDL_SCANCODE_KP_3, SDL_SCANCODE_RIGHT, SDL_SCANCODE_DOWN, DIR_SE,
				SDL_SCANCODE_KP_7, SDL_SCANCODE_LEFT, SDL_SCANCODE_UP, DIR_NW,
				SDL_SCANCODE_KP_9, SDL_SCANCODE_RIGHT, SDL_SCANCODE_UP, DIR_NE
			};

			for(int i=0; i<4; ++i)
			{
				if(KeyDown(keys2[i].k1) || (KeyDown(keys2[i].k2) && KeyDown(keys2[i].k3)))
				{
					if(TryMove(u, keys2[i].dir, true))
						break;
				}
			}
			if(!u.moving && u.waiting <= 0.f)
			{
				for(int i=0; i<4; ++i)
				{
					if(KeyDown(keys1[i].k1) || KeyDown(keys1[i].k2))
					{
						if(TryMove(u, keys1[i].dir, true))
							break;
					}
				}
			}
		}
	}

	// update ai
	for(vector<Unit*>::iterator it = units.begin(), end = units.end(); it != end; ++it)
	{
		Unit& u = **it;
		u.attack_timer -= dt;
		if(u.hp <= 0)
		{
			if(&u == player)
				player = NULL;
			if(u.moving)
				mapa[u.new_pos.x+u.new_pos.y*MAP_W].unit = NULL;
			mapa[u.pos.x+u.pos.y*MAP_W].unit = NULL;
			delete &u;
			it = units.erase(it);
			end = units.end();
			if(it == end)
				break;
		}
		else if(u.waiting > 0.f)
			u.waiting -= dt;
		else if(u.moving)
		{
			u.move_progress += dt*u.base->move_speed;
			if(u.move_progress >= 1.f)
			{
				u.moving = false;
				mapa[u.pos.x+u.pos.y*MAP_W].unit = NULL;
				u.pos = u.new_pos;
				Tile& tile = mapa[u.pos.x+u.pos.y*MAP_W];
				if(tile.building)
				{
					tile.unit = NULL;
					u.inside_building = true;
					if(player->untaxed_gold)
					{
						int tax = player->untaxed_gold*TAX/100;
						player->untaxed_gold -= tax;
						player->gold += player->untaxed_gold;
						player->untaxed_gold = 0;
					}
				}
			}
		}
		else if(&u != player && player && player->alive && !player->inside_building)
		{
			INT2 enemy_pt;
			int dist = GetClosestPoint(u.pos, *player, enemy_pt);
			if(dist <= 50)
			{
				if(dist <= 15)
				{
					// in attack range
					if(u.attack_timer <= 0.f)
					{
						Hit& hit = Add1(hits);
						hit.pos = player->GetPos();
						hit.timer = 0.5f;
						hit._ref = player->_ref;
						u.waiting = 0.5f;
						u.attack_timer = 1.f/u.base->attack_speed;
						player->hp -= u.base->attack - player->base->defense;
						if(player->hp <= 0)
						{
							player->alive = false;
							u.gold += (player->gold + player->untaxed_gold);
							player->gold = 0;
							player->untaxed_gold = 0;
						}
					}
				}
				else
				{
					DIR dir = GetDir(u.pos, enemy_pt);
					if(!TryMove(u, dir, false))
					{
						struct SubDir
						{
							DIR a, b;
						};
						const SubDir sub_dir[8] = {
							DIR_SE, DIR_SW, //DIR_S,
							DIR_W, DIR_S, //DIR_SW,
							DIR_NW, DIR_SW, //DIR_W,
							DIR_N, DIR_W, //DIR_NW,
							DIR_NE, DIR_NW, //DIR_N,
							DIR_N, DIR_E, //DIR_NE,
							DIR_SE, DIR_NE, //DIR_E,
							DIR_S, DIR_E //DIR_SE,
						};
						if(rand()%2 == 0)
						{
							if(!TryMove(u, sub_dir[dir].a, false))
								TryMove(u, sub_dir[dir].b, false);
						}
						else
						{
							if(!TryMove(u, sub_dir[dir].b, false))
								TryMove(u, sub_dir[dir].a, false);
						}
					}
				}
			}
		}
	}

	// update hit animations
	for(vector<Hit>::iterator it = hits.begin(), end = hits.end(); it != end;)
	{
		Hit& hit = *it;
		hit.timer -= dt;
		if(hit.timer <= 0.f)
		{
			if(it+1 == end)
			{
				hits.pop_back();
				break;
			}
			else
			{
				std::iter_swap(it, end-1);
				hits.pop_back();
				end = hits.end();
			}
		}
		else
		{
			if(CheckRef(hit._ref))
				hit.pos = hit._ref->GetRef().GetPos();
			++it;
		}
	}

	// set camera
	if(player)
	{
		cam_pos = player->GetPos() - SCREEN_SIZE/2;
		if(cam_pos.x < 0)
			cam_pos.x = 0;
		if(cam_pos.y < 0)
			cam_pos.y = 0;
		if(cam_pos.x + SCREEN_SIZE.x > MAP_W*32)
			cam_pos.x = MAP_W*32-SCREEN_SIZE.x;
		if(cam_pos.y + SCREEN_SIZE.y > MAP_H*32)
			cam_pos.y = MAP_H*32-SCREEN_SIZE.y;
	}
}
Пример #25
0
PathString PathString::ReplaceExt(const mpt::PathString &newExt) const
//--------------------------------------------------------------------
{
	return GetDrive() + GetDir() + GetFileName() + newExt;
}
Пример #26
0
RepoReader::RepoReader( string start )
{
    GetDir(start);
    startPt = start;
}
Пример #27
0
public func Activate(caster, real_caster) {
  // Zaubernden Clonk ermitteln
  var clonk = caster;
  if (real_caster) clonk = real_caster;

  // Richtungsvorzeichen ermitteln
  var dir_sign = -1;
  if (GetDir(caster) == DIR_Right()) dir_sign = +1;

  // Evtl. mit Flint kombinieren
  var obj;
  if (obj = FindContents(FLNT, clonk)) {
    // Holz erzeugen, anzünden und in Guckrichtung schleudern
    var wood = CreateObject(WOOD, 5*dir_sign, 0, -1);
    Incinerate(wood);
    // Richtigen Controller setzen
    SetController(GetController(clonk),wood);
    SetXDir(40*dir_sign, wood);
    SetYDir(-10, wood);
    // Flint verbrauchen
    RemoveObject(obj);
  }
  // Evtl. mit Pfeil kombinieren
  else
  {
    obj = FindContents(ARRW, clonk);
    if(!obj) if(FindContents(ARWP, clonk))
      obj = FindContents(ARWP, clonk)->GetItem();
    if(obj) {
      // Ein paar Objekte schleudern
      var fling_cnt = RandomX(4, 10);
      var fling_obj;
      while (fling_obj = FindObject(0, 0, 0, -1, -1, OCF_InFree(), 0, 0, NoContainer(), fling_obj)) {
        // Zu weit weg vom Clonk?
        if (ObjectDistance(clonk, fling_obj) > 5*GetDefCoreVal("Width", "DefCore", GetID(caster)))
          break;
        // Der Wolf konnte keine Steinhütten wegblasen - Clonks können keine Hütten mit Fundament wegblasen
        if (!LocalN("basement", fling_obj))
          {
          var pBasement = Local(9, fling_obj);
          if (GetType(pBasement) != C4V_C4Object()) pBasement=0;
          if (pBasement) if (!PrivateCall(pBasement, "BasementID")) pBasement=0;
          if (!pBasement)
            {
            SetXDir(dir_sign*Min(80, 80*350/GetMass(fling_obj)), fling_obj);
            SetYDir(-Min(20, 20/GetMass(fling_obj)), fling_obj);
            // Bei Objekten noch den Controller anpassen
            if(GetCategory(fling_obj) & C4D_Object())
              SetController(GetController(clonk),fling_obj);
            }
          }
        // Schon genügend Objekte geschleudert?
        if (!fling_cnt--) break;
      }
      if (!Contained(clonk)) {
        Fling(clonk, 8*dir_sign, -2);
      }
      // Pfeil verbrauchen
      RemoveObject(obj);
    }
    // Sonst normale Wirkung
    else {
      AddEffect("WindUSpell", 0, 104, 50, 0, GetID(), GetDir(caster));
      Sound("Wind2");
    }
  }
  
  RemoveObject();
  return(1);
}
Пример #28
0
func Script39()
{
	if (GetDir(GetActionTarget(0,valley_clnk))!=DIR_Right) return(goto(39));
}
int AttackMelee::Callback(unsigned int msg, unsigned int wParam, int lParam)
{
	switch(msg)
	{
	case ENTITYMSG_UPDATE:
		{
			//check to see if the owner's animation is done...
			//ENTITY_FLAG_POLLDEATH
			EntityCommon *pEntity = (EntityCommon *)IDPageQuery(GetOwner());

			if(pEntity)
			{
				hOBJ obj = pEntity->GetOBJ();

				if(OBJIsStateEnd(obj))
				{
					//Poll ourself to death!
					SetFlag(ENTITY_FLAG_POLLDEATH, true);
				}
				else
				{
					if(m_jointInd != -1)
					{
						D3DXVECTOR3 cPt;

						//set location
						OBJJointGetWorldLoc(obj, m_jointInd, (float*)cPt);
						SetLoc(cPt);

						//set dir and velocity
						SetDir(pEntity->GetDir());
						SetVel(pEntity->GetDir());
					}
				}
			}
		}
		break;
	
	case ENTITYMSG_ENTITYCOLLIDE://, (WPARAM)pEntity
		{
			EntityCommon *pEntity = (EntityCommon *)wParam;
			EntityCommon *pOwner = (EntityCommon *)IDPageQuery(GetOwner());

			//play a sound if ind is > -1
			int sndInd = -1;

			if(pOwner)
			{
				//check to see if the owner is not the same type as entity
				//also make sure this entity is not immune
				if(pOwner->GetEntityType() != pEntity->GetEntityType()
					&& !pEntity->CheckFlag(CRE_FLAG_MELEEIMMUNE))
				{
					//check to see if the entity is a creature
					if(pEntity->GetEntityType() == ENTITY_TYPE_TATA
						|| pEntity->GetEntityType() == ENTITY_TYPE_ENEMY)
					{
						//hit this fella
						Creature *pCre = (Creature *)pEntity;

						if(!pCre->Hit())
						{
							OBJSetState(pOwner->GetOBJ(), CREANIM_IDLE1);
							pOwner->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_WALL, (LPARAM)&sndInd);
						}
						else
							pOwner->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_CRE, (LPARAM)&sndInd);

						SetFlag(ENTITY_FLAG_POLLDEATH, true);
					}
					else
					{
						//Poll ourself to death!
						SetFlag(ENTITY_FLAG_POLLDEATH, true);
						OBJSetState(pOwner->GetOBJ(), CREANIM_IDLE1);

						pOwner->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_WALL, (LPARAM)&sndInd);
					}
				}
				else
				{
					//Poll ourself to death!
					SetFlag(ENTITY_FLAG_POLLDEATH, true);
					OBJSetState(pOwner->GetOBJ(), CREANIM_IDLE1);

					pOwner->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_WALL, (LPARAM)&sndInd);
				}
			}

			//play sound
			if(sndInd > -1)
			{
				BASS_3DVECTOR pos, orient;
				memcpy(&pos, (float*)GetLoc(), sizeof(pos)); pos.z *= -1;
				memcpy(&orient, (float*)GetDir(), sizeof(orient)); orient.z *= -1;

				TaTaSoundPlay(sndInd, &pos, &orient, 0);
			}
		}
		break;

	case ENTITYMSG_WORLDCOLLIDE: //(WPARAM)hQBSP, (LPARAM)txtID
		{
			//stop the attack and set the owner back to normal state
			EntityCommon *pEntity = (EntityCommon *)IDPageQuery(GetOwner());

			if(pEntity)
			{
				OBJSetState(pEntity->GetOBJ(), CREANIM_IDLE1);

				//Poll ourself to death!
				SetFlag(ENTITY_FLAG_POLLDEATH, true);

				int sndInd=-1;
				pEntity->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_WALL, (LPARAM)&sndInd);

				//play sound
				if(sndInd > -1)
				{
					BASS_3DVECTOR pos, orient;
					memcpy(&pos, (float*)GetLoc(), sizeof(pos)); pos.z *= -1;
					memcpy(&orient, (float*)GetDir(), sizeof(orient)); orient.z *= -1;

					TaTaSoundPlay(sndInd, &pos, &orient, 0);
				}
			}
		}
		break;

	case ENTITYMSG_DEATH:
		break;

	case ENTITYMSG_ALLOWGRAVITY:
		//simply don't allow gravity
		return 0;
	}

	return RETCODE_SUCCESS;
}
Пример #30
0
func Script67()
{
	if (GetDir(GetActionTarget(0,catapult_clnk))!=DIR_Left) return(goto(67));
}