コード例 #1
0
ファイル: BlockID.cpp プロジェクト: 36451/MCServer
	void init()
	{
		m_bHasRunInit = true;

		cIniFile Ini;
		if (!Ini.ReadFile("items.ini"))
		{
			return;
		}
		int KeyID = Ini.FindKey("Items");
		if (KeyID == cIniFile::noID)
		{
			return;
		}
		int NumValues = Ini.GetNumValues(KeyID);
		for (int i = 0; i < NumValues; i++)
		{
			AString Name = Ini.GetValueName(KeyID, i);
			if (Name.empty())
			{
				continue;
			}
			AString Value = Ini.GetValue(KeyID, i);
			AddToMap(Name, Value);
		}  // for i - Ini.Values[]
	}
コード例 #2
0
ファイル: entity.c プロジェクト: superkehoed/midterm
/**
 * Instantly moves an entity to a specific position on a map
 * @param ent The entity to be moved
 * @param map The map to move the entity on
 * @param pos The map position to move the entity to
 */
void MoveEntity(Entity_T *ent, Map_T *map, Vec2f pos)
{
	const GLfloat map_width_limit = MAX_MAP_WIDTH / 2 * TILE_WIDTH;
	const GLfloat map_height_limit = MAX_MAP_HEIGHT / 2 * TILE_HEIGHT;
	Tile_T *tile;
	if(pos.x < -map_width_limit || pos.x > map_width_limit
	|| pos.y < -map_height_limit || pos.y > map_height_limit){
		//Error - Position out of bounds
		return;
	}

	if((tile = TileAtPos(map, pos)) == NULL)
	{
		//Error - Moving to nonexistent tile
		return;
	}
	else if(IS_SET(tile->flags, TILEFLAG_NO_PASS))
	{
		//Error - Moving to nopass tile
		return;
	}
	ent->body->p.x = pos.x + ent->size.x / 2;
	ent->body->p.y = pos.y + ent->size.y / 2;
	if(ent->onMap != map)
		AddToMap(ent, map);
}
コード例 #3
0
ファイル: mapobjctrl.cpp プロジェクト: ZhouWeikuan/darkreign2
  //
  // Post Load
  //
  // Do post mission load functions
  //
  void PostLoad()
  {
    // Add required objects to the map
    for (NList<AddToMapItem>::Iterator i(&listAddToMap); *i; i++)
    {
      MapObj *obj = (*i)->obj;

      if (!obj->GetParent())
      {
        AddToMap(obj);

        if ((*i)->zip)
        {
          obj->ToggleFootPrint(TRUE);
        }
      }
    }

    listAddToMap.DisposeAll();
  }
コード例 #4
0
ファイル: mapobjctrl.cpp プロジェクト: ZhouWeikuan/darkreign2
  //
  // ObjectNewOnMap
  //
  // Creates a new object of 'type' and places on the map using 'matrix'
  //
  MapObj* ObjectNewOnMap(MapObjType *type, const Matrix &matrix, U32 id, Bool zip, Bool complete)
  {
    ASSERT(type);

    // Create the new object
    MapObj *newObj = ObjectNew(type, id, complete);

    // Set the object transform
    newObj->SetSimCurrent(matrix);

    // Add to the map
    AddToMap(newObj);

    // Zip if required
    if (zip)
    {
      newObj->ToggleFootPrint(TRUE);
    }

    return (newObj);
  }
コード例 #5
0
void NonTermContextProperty::ProcessValue(const std::string &value)
{
  vector<string> toks;
  Tokenize(toks, value);

  FactorCollection &fc = FactorCollection::Instance();

  size_t numNT = Scan<size_t>(toks[0]);
  m_probStores.resize(numNT);

  size_t ind = 1;
  while (ind < toks.size()) {
	  vector<const Factor *> factors;

	  for (size_t nt = 0; nt < numNT; ++nt) {
		  size_t ntInd = Scan<size_t>(toks[ind]);
		  assert(nt == ntInd);
		  ++ind;

		  for (size_t contextInd = 0; contextInd < 4; ++contextInd) {
			//cerr << "toks[" << ind << "]=" << toks[ind] << endl;
  			  const Factor *factor = fc.AddFactor(toks[ind], false);
			  factors.push_back(factor);
			  ++ind;
		  }
	  }

	  // done with the context. Just get the count and put it all into data structures
	  // cerr << "count=" << toks[ind] << endl;
          float count = Scan<float>(toks[ind]);
          ++ind;

	  for (size_t i = 0; i < factors.size(); ++i) {
		  size_t ntInd = i / 4;
		  size_t contextInd = i % 4;
		  const Factor *factor = factors[i];
		  AddToMap(ntInd, contextInd, factor, count);
	  }
  }
}
コード例 #6
0
ファイル: BlockID.cpp プロジェクト: Xury/MCServer
	cBlockIDMap(void)
	{
		cIniFile Ini("items.ini");
		if (!Ini.ReadFile())
		{
			return;
		}
		long KeyID = Ini.FindKey("Items");
		if (KeyID == cIniFile::noID)
		{
			return;
		}
		unsigned NumValues = Ini.GetNumValues(KeyID);
		for (unsigned i = 0; i < NumValues; i++)
		{
			AString Name = Ini.ValueName(KeyID, i);
			if (Name.empty())
			{
				continue;
			}
			AString Value = Ini.GetValue(KeyID, i);
			AddToMap(Name, Value);
		}  // for i - Ini.Values[]
	}
コード例 #7
0
/**
 * Add the dir to the g_OpenDirs map.
 * @param[in] dir The dir to add to g_OpenDirs.
 * @return int The index of the DIR in g_OpenDirs, or -1 if there are too many
 *     open dirs. */
static int AddDirToMap(DIR* dir) {
  return AddToMap((void**)g_OpenDirs, MAX_OPEN_DIRS, dir);
}
コード例 #8
0
/**
 * Add the file to the g_OpenFiles map.
 * @param[in] file The file to add to g_OpenFiles.
 * @return int The index of the FILE in g_OpenFiles, or -1 if there are too many
 *     open files. */
static int AddFileToMap(FILE* file) {
  return AddToMap((void**)g_OpenFiles, MAX_OPEN_FILES, file);
}
コード例 #9
0
ファイル: makehm.cpp プロジェクト: dbremner/VC2010Samples
int _tmain(int argc, TCHAR** argv)
{
	int iFirstParam = 1;

	// Turn on the "termination on heap corruption" flag.
	(void)HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);

	// generate output for HTML Help format
	BOOL fHTMLFormat = FALSE;

	// <include.h> filename to be copied
	const TCHAR *pszIncludeFilename = NULL;

	// additional include path
	const TCHAR *pszIncludePath = NULL;

	if( argc > 1 && _tcsicmp(argv[1], _T("/h")) == 0 )
	{
		fHTMLFormat = TRUE;
		iFirstParam++;

		if( ( argc > 3 ) && _tcsicmp(argv[2], _T("/a")) == 0 ) // copy file operation
		{
			pszIncludeFilename = argv[3];
			iFirstParam += 2;

			if( argc > 5 && _tcsicmp(argv[4], _T("/i")) == 0 )
			{
				pszIncludePath = argv[5];
				iFirstParam += 2;
			}
		}
	}

	// add symbol mappings to the map.
	BOOL fAddedToMap = FALSE;
	int i;
	for (i = iFirstParam; i < argc && _tcschr(argv[i], _T(',')) != NULL; i++)
	{
		AddToMap(argv[i]);
		fAddedToMap = TRUE;
	}

	// must only have 1-2 parms left on command line.
	if (!fAddedToMap || i < argc-2 || i > argc-1)
	{
		UsageErr(NULL, NULL);
		ASSERT(FALSE);
	}

	// open input file.
	CLineFile fileIn;
	fileIn.SafeOpen(argv[i], CLineFile::modeRead);

	// open/hook up output file.
	CLineFile fileOut;
	if (i+1 < argc)
		fileOut.SafeOpen(argv[i+1], CLineFile::modeWrite | CLineFile::modeCreate);
	else
		fileOut.m_pStream = stdout;

	// process the file.
	CString strLine;
	while (fileIn.ReadLine(strLine))
	{
		if (MapLine(strLine, fHTMLFormat))
		{
			fileOut.WriteLine(strLine);
		}
	}

	// close input file.
	fileIn.Close();

	if( pszIncludeFilename != NULL )
	{
		CString strIncludeFilePath = FindIncludeFile( pszIncludeFilename, pszIncludePath );
		if( strIncludeFilePath.IsEmpty() )
		{
			_ftprintf(stderr, _T("Error: Additional include file %s not found\n\n"), pszIncludeFilename );
			fileOut.Close();
			exit(1);
		}

		fileIn.SafeOpen(strIncludeFilePath, CLineFile::modeRead);

		while (fileIn.ReadLine(strLine))
		{
			fileOut.WriteLine(strLine);
		}
	}

	// close output file.
	fileOut.Close();

	return 0;
}