本文整理汇总了C++中LList::PutData方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::PutData方法的具体用法?C++ LList::PutData怎么用?C++ LList::PutData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LList
的用法示例。
在下文中一共展示了LList::PutData方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConcatPaths
LList <char *> *ListSubDirectoryNames(const char *_dir)
{
LList<char *> *result = new LList<char *>();
#ifdef WIN32
_finddata_t thisfile;
long fileindex;
char *dir = ConcatPaths( _dir, "*.*", NULL );
fileindex = _findfirst( dir, &thisfile );
int exitmeplease = 0;
while( fileindex != -1 && !exitmeplease )
{
if( strcmp( thisfile.name, "." ) != 0 &&
strcmp( thisfile.name, ".." ) != 0 &&
(thisfile.attrib & _A_SUBDIR) )
{
char *newname = strdup( thisfile.name );
result->PutData( newname );
}
exitmeplease = _findnext( fileindex, &thisfile );
}
delete[] dir;
#else
DIR *dir = opendir(_dir);
if (dir == NULL)
return result;
for (struct dirent *entry; (entry = readdir(dir)) != NULL; ) {
if (entry->d_name[0] == '.')
continue;
char fullname[strlen(_dir) + strlen(entry->d_name) + 2];
sprintf(fullname, "%s%s%s",
_dir,
_dir[0] ? "/" : "",
entry->d_name);
if (IsDirectory(fullname))
result->PutData( strdup(entry->d_name) );
}
closedir(dir);
#endif
return result;
}
示例2: EclDirtyRectangle
void EclDirtyRectangle ( int x, int y, int w, int h )
{
DirtyRect *dr = new DirtyRect(x, y, w, h);
dirtyrects.PutData( dr );
for ( int i = 0; i < windows.Size(); ++i )
{
EclWindow *window = windows.GetData(i);
if ( EclRectangleOverlap( x, y, w, h, window->m_x, window->m_y, window->m_w, window->m_h ) )
EclDirtyWindow ( window );
}
}
示例3: Authentication_RequestStatus
void Authentication_RequestStatus( char *_key, int _keyId, char *_ip )
{
//
// Does the key already exist in our list?
s_authResultsMutex.Lock();
AuthenticationResult *result = NULL;
for( int i = 0; i < s_authResults.Size(); ++i )
{
AuthenticationResult *authResult = s_authResults[i];
if( strcmp(authResult->m_authKey, _key) == 0 )
{
result = authResult;
break;
}
}
//
// Add the key to our list if required
if( !result )
{
result = new AuthenticationResult();
strcpy( result->m_authKey, _key );
result->m_keyId = _keyId;
if( _ip ) strcpy( result->m_ip, _ip );
else strcpy( result->m_ip, "unknown" );
s_authResults.PutData( result );
}
s_authResultsMutex.Unlock();
//
// Start the authorisation thread if required
if( !s_authThreadRunning )
{
s_authThreadRunning = true;
NetStartThread( AuthenticationThread );
}
}
示例4: Authentication_SetStatus
void Authentication_SetStatus( char *_key, int _keyId, int _status )
{
bool authChanged = false;
s_authResultsMutex.Lock();
AuthenticationResult *result = NULL;
for( int i = 0; i < s_authResults.Size(); ++i )
{
AuthenticationResult *authResult = s_authResults[i];
if( strcmp(authResult->m_authKey, _key) == 0 )
{
result = authResult;
break;
}
}
if( !result )
{
result = new AuthenticationResult();
strcpy( result->m_authKey, _key );
s_authResults.PutData( result );
}
if( result->m_authResult != _status )
{
char *authString = Authentication_GetStatusString(_status);
AppDebugOut( "Received Authentication : %s : (keyID %d) : %s\n", _key, _keyId, authString );
}
result->m_authResult = _status;
result->m_keyId = _keyId;
s_authResultsMutex.Unlock();
}
示例5: Update
void AlliancesWindow::Update()
{
//
// Build a list of all teams;
LList<Team *> teams;
for( int i = 0; i < g_app->GetWorld()->m_teams.Size(); ++i )
{
Team *team = g_app->GetWorld()->m_teams[i];
teams.PutData( team );
}
//
// Now put the other teams in, in alliance order
int currentIndex = 0;
while( teams.Size() > 0 )
{
Team *baseTeam = teams[0];
m_teamOrder[currentIndex] = baseTeam->m_teamId;
++currentIndex;
teams.RemoveData(0);
for( int i = 0; i < teams.Size(); ++i )
{
Team *possibleAlly = teams[i];
if( possibleAlly->m_allianceId == baseTeam->m_allianceId )
{
m_teamOrder[currentIndex] = possibleAlly->m_teamId;
++currentIndex;
teams.RemoveData(i);
--i;
}
}
}
//
// Are there any votes we can see?
for( int i = 0; i < MAX_TEAMS; ++i )
{
m_votes[i] = -1;
}
currentIndex = 0;
for( int i = 0; i < g_app->GetWorld()->m_votingSystem.m_votes.Size(); ++i )
{
if( g_app->GetWorld()->m_votingSystem.m_votes.ValidIndex(i) )
{
Vote *vote = g_app->GetWorld()->m_votingSystem.m_votes[i];
if( vote->m_result == Vote::VoteUnknown &&
vote->CanSeeVote( g_app->GetWorld()->m_myTeamId ) )
{
m_votes[currentIndex] = i;
++currentIndex;
}
}
}
//
// Make sure we are the right size
m_h = 120 + g_app->GetWorld()->m_teams.Size() * 42;
m_h += currentIndex * 45;
if( currentIndex > 0 ) m_h += 10;
m_h = max(m_h, 300 );
GetButton("Close")->m_y = m_h - 25;
}
示例6: AppAssert
// Finds all the filenames in the specified directory that match the specified
// filter. Directory should be like "data/textures" or "data/textures/".
// Filter can be NULL or "" or "*.bmp" or "map_*" or "map_*.txt"
// Set FullFilename to true if you want results like "data/textures/blah.bmp"
// or false for "blah.bmp"
LList <char *> *ListDirectory( const char *_dir, const char *_filter, bool _fullFilename )
{
if(_filter == NULL || _filter[0] == '\0')
{
_filter = "*";
}
if(_dir == NULL || _dir[0] == '\0')
{
_dir = "";
}
// Create a DArray for our results
LList <char *> *result = new LList<char *>();
// Now add on all files found locally
#ifdef WIN32
char searchstring [256];
AppAssert(strlen(_dir) + strlen(_filter) < sizeof(searchstring) - 1);
sprintf( searchstring, "%s%s", _dir, _filter );
_finddata_t thisfile;
long fileindex = _findfirst( searchstring, &thisfile );
int exitmeplease = 0;
while( fileindex != -1 && !exitmeplease )
{
if( strcmp( thisfile.name, "." ) != 0 &&
strcmp( thisfile.name, ".." ) != 0 &&
!(thisfile.attrib & _A_SUBDIR) )
{
char *newname = NULL;
if( _fullFilename )
{
int len = strlen(_dir) + strlen(thisfile.name);
newname = new char [len + 1];
sprintf( newname, "%s%s", _dir, thisfile.name );
}
else
{
int len = strlen(thisfile.name);
newname = new char [len + 1];
sprintf( newname, "%s", thisfile.name );
}
result->PutData( newname );
}
exitmeplease = _findnext( fileindex, &thisfile );
}
#else
DIR *dir = opendir(_dir[0] ? _dir : ".");
if (dir == NULL)
return result;
for (struct dirent *entry; (entry = readdir(dir)) != NULL; ) {
if (FilterMatch(entry->d_name, _filter)) {
char fullname[strlen(_dir) + strlen(entry->d_name) + 2];
sprintf(fullname, "%s%s%s",
_dir,
_dir[0] ? "/" : "",
entry->d_name);
if (!IsDirectory(fullname)) {
result->PutData(
newStr(_fullFilename ? fullname : entry->d_name));
}
}
}
closedir(dir);
#endif
return result;
}
示例7: FindTarget
void Nuke::FindTarget( int team, int targetTeam, int launchedBy, Fixed range, Fixed *longitude, Fixed *latitude, int *objectId )
{
START_PROFILE("Nuke::FindTarget");
WorldObject *launcher = g_app->GetWorld()->GetWorldObject(launchedBy);
if( !launcher )
{
END_PROFILE("Nuke::FindTarget");
return;
}
LList<int> validTargets;
for( int i = 0; i < g_app->GetWorld()->m_objects.Size(); ++i )
{
if( g_app->GetWorld()->m_objects.ValidIndex(i) )
{
WorldObject *obj = g_app->GetWorld()->m_objects[i];
if( obj->m_teamId == targetTeam &&
obj->m_seen[team] &&
!obj->IsMovingObject() )
{
Fixed distanceSqd = g_app->GetWorld()->GetDistanceSqd( launcher->m_longitude, launcher->m_latitude, obj->m_longitude, obj->m_latitude);
if( distanceSqd <= range * range )
{
int numTargetedNukes = CountTargetedNukes( team, obj->m_longitude, obj->m_latitude );
if( (obj->m_type == WorldObject::TypeRadarStation && numTargetedNukes < 2 ) ||
(obj->m_type != WorldObject::TypeRadarStation && numTargetedNukes < 4 ) )
{
validTargets.PutData(obj->m_objectId);
}
}
}
}
}
if( validTargets.Size() > 0 )
{
int targetId = syncrand() % validTargets.Size();
int objIndex = validTargets[ targetId ];
WorldObject *obj = g_app->GetWorld()->GetWorldObject(objIndex);
if( obj )
{
*longitude = obj->m_longitude;
*latitude = obj->m_latitude;
*objectId = obj->m_objectId;
END_PROFILE("Nuke::FindTarget");
return;
}
}
Team *friendlyTeam = g_app->GetWorld()->GetTeam( team );
int maxPop = 500000; // Don't bother hitting cities with less than 0.5M survivors
for( int i = 0; i < g_app->GetWorld()->m_cities.Size(); ++i )
{
if( g_app->GetWorld()->m_cities.ValidIndex(i) )
{
City *city = g_app->GetWorld()->m_cities[i];
if( !g_app->GetWorld()->IsFriend( city->m_teamId, team) &&
g_app->GetWorld()->GetDistanceSqd( city->m_longitude, city->m_latitude, launcher->m_longitude, launcher->m_latitude) <= range * range)
{
int numTargetedNukes = CountTargetedNukes(team, city->m_longitude, city->m_latitude);
int estimatedPop = City::GetEstimatedPopulation( team, i, numTargetedNukes );
if( estimatedPop > maxPop )
{
maxPop = estimatedPop;
*longitude = city->m_longitude;
*latitude = city->m_latitude;
*objectId = -1;
}
}
}
}
END_PROFILE("Nuke::FindTarget");
}
示例8: Advance
//.........这里部分代码省略.........
//
// Second pass : Recalculate all Sound Priorities starting with the nearest sounds
// Reduce priorities as more of the same sounds are played
BTree<float> existingInstances;
//
// Also look out for the highest priority new sound to swap in
START_PROFILE("Recalculate Priorities" );
LList<SoundInstance *> newInstances;
SoundInstance *newInstance = NULL;
float highestInstancePriority = 0.0f;
for( int i = 0; i < numSortedIds; ++i )
{
SoundInstanceId id = sortedIds[i];
SoundInstance *instance = GetSoundInstance( id );
AppDebugAssert( instance );
instance->m_calculatedPriority = instance->m_perceivedVolume;
BTree<float> *existingInstance = existingInstances.LookupTree( instance->m_eventName );
if( existingInstance )
{
instance->m_calculatedPriority *= existingInstance->data;
existingInstance->data *= 0.75f;
}
else
{
existingInstances.PutData( instance->m_eventName, 0.75f );
}
if( !instance->IsPlaying() )
{
if( instance->m_positionType == SoundInstance::TypeMusic )
{
newInstances.PutData( instance );
}
else if( instance->m_calculatedPriority > highestInstancePriority )
{
newInstance = instance;
highestInstancePriority = instance->m_calculatedPriority;
}
}
}
if( newInstance )
{
newInstances.PutData( newInstance );
}
END_PROFILE("Recalculate Priorities" );
for( int i = 0; i < newInstances.Size(); ++i )
{
SoundInstance *newInstance = newInstances[i];
bool isMusic = (newInstance->m_positionType == SoundInstance::TypeMusic);
// Find worst old sound to get rid of
START_PROFILE("Find best Channel" );
int bestAvailableChannel = FindBestAvailableChannel( isMusic );
示例9: ToggleVersionMenu
void SWInterface::ToggleVersionMenu ( char *program, int x, int y )
{
if ( program &&
!IsVisibleVersionMenu ( program ) ) {
// Create it
LList <char *> software; // Bit of a hack - think about this
LList <float> versions;
DataBank *db = &(game->GetWorld ()->GetPlayer ()->gateway.databank);
for ( int di = 0; di < db->GetDataSize (); ++di ) {
if ( db->GetDataFile (di) &&
db->GetDataFile (di)->TYPE == DATATYPE_PROGRAM &&
strcmp ( db->GetDataFile (di)->title, program ) == 0 ) {
software.PutData ( db->GetDataFile (di)->title );
versions.PutData ( db->GetDataFile (di)->version );
}
}
// Ensures total time = 500ms
int timesplit = 500;
if ( software.Size () > 0 )
timesplit /= software.Size ();
for ( int si = 0; si < software.Size (); ++si ) {
char caption [128], tooltip [128], name [128];
UplinkSnprintf ( caption, sizeof ( caption ), "%s v%1.1f", software.GetData (si), versions.GetData (si) );
UplinkStrncpy ( tooltip, "Runs this software application", sizeof ( tooltip ) );
UplinkSnprintf ( name, sizeof ( name ), "hud_version %d", si );
EclRegisterButton ( x, y, 120, 15, caption, tooltip, name );
EclRegisterButtonCallbacks ( name, SoftwareDraw, SoftwareClick, button_click, button_highlight );
EclRegisterMovement ( name, x, y - si * 17, si * timesplit );
}
SgPlaySound ( RsArchiveFileOpen ("sounds/softwaremenu.wav"), "sounds/softwaremenu.wav", false );
}
else {
// Remove it
// We don't know how many entries there could be, so keep deleting until they run out
int i = 0;
char name [128];
UplinkSnprintf ( name, sizeof ( name ), "hud_version %d", i );
while ( EclGetButton ( name ) != NULL ) {
EclRemoveButton ( name );
++i;
UplinkSnprintf ( name, sizeof ( name ), "hud_version %d", i );
}
// Force redraw of the button that fathered this menu
char bname [32];
UplinkSnprintf ( bname, sizeof ( bname ), "hud_software %d", currentprogrambutton );
EclDirtyButton ( bname );
currentprogrambutton = -1;
}
}
示例10: ToggleSubMenu
void SWInterface::ToggleSubMenu ( int softwareTYPE, int x, int y )
{
if ( !IsVisibleSubMenu ( softwareTYPE ) ) {
// Create a list of all software in memory
LList <char *> software; // Bit of a hack - think about this
LList <float> versions;
DataBank *db = &(game->GetWorld ()->GetPlayer ()->gateway.databank);
for ( int di = 0; di < db->GetDataSize (); ++di ) {
if ( db->GetDataFile (di) &&
db->GetDataFile (di)->TYPE == DATATYPE_PROGRAM &&
db->GetDataFile (di)->softwareTYPE == softwareTYPE ) {
// This sofware is the correct type. Add it into the list if it isn't already there,
// or if its version is higher than any existing program of the same name
// First try to find a software item of the same name
int existingindex = -1;
for ( int si = 0; si < software.Size (); ++si ) {
if ( strcmp ( software.GetData (si), db->GetDataFile (di)->title ) == 0 ) {
existingindex = si;
break;
}
}
// If it already exists, add this item in only if it has a higher version number
if ( existingindex == -1 ) {
software.PutData ( db->GetDataFile (di)->title );
versions.PutData ( db->GetDataFile (di)->version );
}
if ( existingindex != -1 &&
db->GetDataFile (di)->version > versions.GetData (existingindex) ) {
software.RemoveData ( existingindex );
versions.RemoveData ( existingindex );
software.PutDataAtIndex ( db->GetDataFile (di)->title, existingindex );
versions.PutDataAtIndex ( db->GetDataFile (di)->version, existingindex );
}
}
}
int timesplit = 500;
if ( software.Size () > 0 )
timesplit /= software.Size (); // Ensures total time = 500ms
for ( int si = 0; si < software.Size (); ++si ) {
char caption [128], tooltip [128], name [128];
UplinkSnprintf ( caption, sizeof ( caption ), "%s v%1.1f", software.GetData (si), versions.GetData (si) );
UplinkStrncpy ( tooltip, "Runs this software application", sizeof ( tooltip ) );
UplinkSnprintf ( name, sizeof ( name ), "hud_software %d", si );
EclRegisterButton ( x, y, 140, 15, caption, tooltip, name );
EclRegisterButtonCallbacks ( name, SoftwareDraw, SoftwareClick, button_click, SoftwareHighlight );
EclRegisterMovement ( name, x, y - si * 17, si * timesplit );
}
currentsubmenu = softwareTYPE;
SgPlaySound ( RsArchiveFileOpen ( "sounds/softwaremenu.wav" ), "sounds/softwaremenu.wav", false );
}
else {
// Remove the software menu
// We don't know how many entries there could be, so keep deleting until they run out
int i = 0;
char name [32];
UplinkSnprintf ( name, sizeof ( name ), "hud_software %d", i );
while ( EclGetButton ( name ) != NULL ) {
EclRemoveButton ( name );
++i;
UplinkSnprintf ( name, sizeof ( name ), "hud_software %d", i );
}
// Redraw the button that was selected
char bname [32];
UplinkSnprintf ( bname, sizeof ( bname ), "hud_swmenu %d", currentsubmenu );
EclDirtyButton ( bname );
currentsubmenu = SOFTWARETYPE_NONE;
//.........这里部分代码省略.........