ftp.nice.ch/pub/next/games/action/xox/XoxWars94.NI.bs.tar.gz#/pack/XoxWars.bproj/XoxList.m

This is XoxList.m in view mode; [Download] [Up]

XoxPlayers

@class BundleClasses : List
{
	const char* ext;
	int elen;
}

- initWith:(const char*) bext
{
	[super init];
	ext = bext;
	elen = strlen(ext);
	return self;
}

- loadFrom: (const char *) dirname 
{
    DIR *dir;
    struct direct *de;
    char path[MAXPATHLEN];
    char name[60];
	char *iptr;
	BOOL validName;

	if (!ext || !len) return nil;

	dir = opendir(dirname);
	if (dir == NULL)
	{
		return self;
	}

	while ((de = readdir(dir)) != NULL)
	{
		int i, numstrings;
	
		// Ignore '.'-files (not really necessary, I guess)
		if (de->d_name[0] == '.')
			continue;

		validName = NO;
		if (de->d_namlen > elen && 
				!strcmp(&de->d_name[de->d_namlen-elen], ext))
		{
			validName = YES;
		}

		if (!validName) continue;


		// check if the name matches a module already loaded
		numstrings = [gameList count];
		strcpy(name, de->d_name);

		// Smash out the '.' in "Foo.ext"
		if (iptr = rindex(name, '.'))
			*iptr = '\0';
		
		sprintf(path,"%s/%s.XoX",dirname,name);
		
		m = [[GameInfo alloc] 
			initWithScenario:NULL name:name path:path];
	    [gameList addObject: m];
	}

    closedir(dir);

    return self;
}

- setupGameBrowser
{
	id theMatrix;
	char buf[MAXPATHLEN];
	const char *ptr;

	strcpy( buf, NXHomeDirectory());
	strcat( buf, "/Library/XoxGames");

	gameList = [[GameList alloc] init];

	[self loadGamesFrom:buf];
	ptr = NXGetDefaultValue([NXApp appName], "altGamePath");
	if (ptr) [self loadGamesFrom:ptr];
	[self loadGamesFrom: [[NXBundle mainBundle] directory]];
	[self loadGamesFrom: "/LocalLibrary/XoxGames"];


	return self;
}

			do
			{
				NXBundle *myBundle = [[NXBundle allocFromZone:bundleZone]
					initForDirectory:[gi path]];

				theClass = [myBundle classNamed:[gi scenarioName]];

				if (theClass)
				{
					theScenario = [[theClass allocFromZone:scenarioZone] init];
				}
				else
				{
					[myBundle free];
				}

			} while ((!theClass) && [gi useNextPath]);

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.