char *NameGenerator::GeneratePersonName ()
{

	LoadNames ();								// Won't do anything if names exist

	int size_f = fornames.Size ();
	int size_s = surnames.Size ();
	
	int index_f = NumberGenerator::RandomNumber ( size_f );
	int index_s = NumberGenerator::RandomNumber ( size_s );

	// Build the name;

    char *forname = fornames.GetData (index_f);
    char *surname = surnames.GetData (index_s);
	char name [SIZE_PERSON_NAME];
	UplinkSnprintf ( name, sizeof ( name ), "%s %s", forname, surname );

    delete [] surname;
	surnames.RemoveData (index_s);

    UplinkStrncpy ( tempname, name, sizeof ( tempname ) );
	return tempname;

}
Exemple #2
0
// Find a string by name
int FStringTable::FindString (const char *name) const
{
	if (Names == NULL)
	{
		LoadNames ();
	}

	const WORD *nameOfs = (WORD *)Names;
	const char *nameBase = (char *)Names + NumStrings*4;

	int min = 0;
	int max = NumStrings-1;

	while (min <= max)
	{
		const int mid = (min + max) / 2;
		const char *const tablename = LESHORT(nameOfs[mid*2]) + nameBase;
		const int lex = stricmp (name, tablename);
		if (lex == 0)
			return nameOfs[mid*2+1];
		else if (lex < 0)
			max = mid - 1;
		else
			min = mid + 1;
	}
	return -1;
}
char *NameGenerator::GenerateCompanyName ()
{

	LoadNames ();

	int size1 = companynamesA.Size ();
	int size2 = companynamesB.Size ();


	// Choose part 1 (primary name part1)
	int index1 = NumberGenerator::RandomNumber ( size1 );

	// Choose part 2 (primary name part2)
	int index2 = NumberGenerator::RandomNumber ( size2 );

	// Build the name 

    char *companynameA = companynamesA.GetData (index1);
    char *companynameB = companynamesB.GetData (index2);
	char name [SIZE_COMPANY_NAME];
	UplinkSnprintf ( name, sizeof ( name ), "%s %s", companynameA, companynameB );

	delete [] companynameA;
    companynamesA.RemoveData (index1);

    UplinkStrncpy ( tempname, name, sizeof ( tempname ) );
	return tempname;

}
void LoadState::Enter()
{
	SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance();
	m_hBackground = pGraphics->LoadTexture(L"resource/graphics/MenuBackgrounds/Options.png");
	m_hButton = pGraphics->LoadTexture("resource/graphics/optionsButton.png");
	m_hButtonHighlighted = pGraphics->LoadTexture("resource/graphics/optionHighlighted.png");
	m_hNameFrame = pGraphics->LoadTexture("resource/graphics/MenuBackgrounds/saveScroll.png");

	//SlotName();
	LoadNames();
}
    void CheckAndReloadFacade()
    {
        if (CURRENT_LAYOUT != data_timestamp_ptr->layout ||
            CURRENT_DATA != data_timestamp_ptr->data ||
            CURRENT_TIMESTAMP != data_timestamp_ptr->timestamp)
        {
            // release the previous shared memory segments
            SharedMemory::Remove(CURRENT_LAYOUT);
            SharedMemory::Remove(CURRENT_DATA);

            CURRENT_LAYOUT = data_timestamp_ptr->layout;
            CURRENT_DATA = data_timestamp_ptr->data;
            CURRENT_TIMESTAMP = data_timestamp_ptr->timestamp;

            m_layout_memory.reset(SharedMemoryFactory::Get(CURRENT_LAYOUT));

            data_layout = (SharedDataLayout *)(m_layout_memory->Ptr());

            m_large_memory.reset(SharedMemoryFactory::Get(CURRENT_DATA));
            shared_memory = (char *)(m_large_memory->Ptr());

            const char *file_index_ptr =
                data_layout->GetBlockPtr<char>(shared_memory, SharedDataLayout::FILE_INDEX_PATH);
            file_index_path = boost::filesystem::path(file_index_ptr);
            if (!boost::filesystem::exists(file_index_path))
            {
                SimpleLogger().Write(logDEBUG) << "Leaf file name " << file_index_path.string();
                throw osrm::exception("Could not load leaf index file."
                                      "Is any data loaded into shared memory?");
            }

            LoadGraph();
            LoadChecksum();
            LoadNodeAndEdgeInformation();
            LoadGeometries();
            LoadTimestamp();
            LoadViaNodeList();
            LoadNames();

            data_layout->PrintInformation();

            SimpleLogger().Write() << "number of geometries: " << m_coordinate_list->size();
            for (unsigned i = 0; i < m_coordinate_list->size(); ++i)
            {
                if (!GetCoordinateOfNode(i).is_valid())
                {
                    SimpleLogger().Write() << "coordinate " << i << " not valid";
                }
            }
        }
    }
char *NameGenerator::GenerateAgentAlias ()
{

	LoadNames ();

	int index = NumberGenerator::RandomNumber ( agentaliases.Size () );

	char *result = agentaliases.GetData (index);
    UplinkStrncpy ( tempname, result, sizeof ( tempname ) );

    delete [] result;
	agentaliases.RemoveData (index);

	return tempname;

}
Exemple #7
0
Names::Names(GameInterface* game)
    : game_(game)
{
    LoadNames();
}
int main( int argc, char **argv )
	{
	char	*args;
	int		i = 0;
	FILE	*op;
	char	filename[MAX_PATH];

	if (argc >= 2)
		{
		for(int i=1; i<argc; i++)
			{
			args = argv[i];
			switch ( args[1] )
				{
				case 'd':
					sprintf(gBaseDir,args + 2);
					break;
				case 'l':
					sprintf(gLangDir,args + 2);
					sprintf(gBaseDir,"D:\\falcon4\\%s\\campaign\\save",gLangDir);
					break;
				default:
					break;
				}
			}
		}
	else
		{
		sprintf(gBaseDir,"D:\\falcon4\\campaign\\save");
		sprintf(gLangDir,"output");
		printf("Working directory: %s",gBaseDir);
//		scanf("%s",baseDir);
		}

	ReadIndex("strings");
	LoadNames("Korea");
	BuildExampleNames();
	sprintf(filename,"%s\\%s.txt",gBaseDir,gLangDir);
	op = fopen(filename,"w");

	while (FilesToRead[i][0])
		{
		ClearTokenList();
		fprintf(op,"\n==============================\n");
		fprintf(op,"FILENAME: %s\n",FilesToRead[i]);
		fprintf(op,"==============================\n");
		printf("\n==============================\n");
		printf("FILENAME: %s\n",FilesToRead[i]);
		printf("==============================\n");
		AnalyseFile(FilesToRead[i]);
		DoFile(FilesToRead[i],op);
		i++;
		}

	FreeIndex();
	FreeNames();
	fclose(op);
	printf("Done! - press <return> to exit\n");
	getchar();

	return 1;
	}
    void CheckAndReloadFacade()
    {
        if (CURRENT_LAYOUT != data_timestamp_ptr->layout ||
            CURRENT_DATA != data_timestamp_ptr->data ||
            CURRENT_TIMESTAMP != data_timestamp_ptr->timestamp)
        {
            // Get exclusive lock
            SimpleLogger().Write(logDEBUG) << "Updates available, getting exclusive lock";
            boost::unique_lock<boost::shared_mutex> lock(data_mutex);

            if (CURRENT_LAYOUT != data_timestamp_ptr->layout ||
                CURRENT_DATA != data_timestamp_ptr->data)
            {
                // release the previous shared memory segments
                SharedMemory::Remove(CURRENT_LAYOUT);
                SharedMemory::Remove(CURRENT_DATA);

                CURRENT_LAYOUT = data_timestamp_ptr->layout;
                CURRENT_DATA = data_timestamp_ptr->data;
                CURRENT_TIMESTAMP = 0;  // Force trigger a reload

                SimpleLogger().Write(logDEBUG) << "Current layout was different to new layout, swapping";
            }
            else
            {
                SimpleLogger().Write(logDEBUG) << "Current layout was same to new layout, not swapping";
            }

            if (CURRENT_TIMESTAMP != data_timestamp_ptr->timestamp)
            {
                CURRENT_TIMESTAMP = data_timestamp_ptr->timestamp;

                SimpleLogger().Write(logDEBUG) << "Performing data reload";
                m_layout_memory.reset(SharedMemoryFactory::Get(CURRENT_LAYOUT));

                data_layout = (SharedDataLayout *) (m_layout_memory->Ptr());

                m_large_memory.reset(SharedMemoryFactory::Get(CURRENT_DATA));
                shared_memory = (char *) (m_large_memory->Ptr());

                const char *file_index_ptr =
                        data_layout->GetBlockPtr<char>(shared_memory, SharedDataLayout::FILE_INDEX_PATH);
                file_index_path = boost::filesystem::path(file_index_ptr);
                if (!boost::filesystem::exists(file_index_path)) {
                    SimpleLogger().Write(logDEBUG) << "Leaf file name "
                    << file_index_path.string();
                    throw osrm::exception("Could not load leaf index file. "
                                                  "Is any data loaded into shared memory?");
                }

                LoadGraph();
                LoadChecksum();
                LoadNodeAndEdgeInformation();
                LoadGeometries();
                LoadTimestamp();
                LoadViaNodeList();
                LoadNames();
                LoadCoreInformation();

                data_layout->PrintInformation();

                SimpleLogger().Write() << "number of geometries: " << m_coordinate_list->size();
                for (unsigned i = 0; i < m_coordinate_list->size(); ++i)
                {
                    if (!GetCoordinateOfNode(i).is_valid())
                    {
                        SimpleLogger().Write() << "coordinate " << i << " not valid";
                    }
                }
            }
            SimpleLogger().Write(logDEBUG) << "Releasing exclusive lock";
        }
    }