This is HighScoreDistributor.m in view mode; [Download] [Up]
#import <appkit/appkit.h> #import <gamekit/gamekit.h> #import <remote/NXConnection.h> #import <objc/HashTable.h> #define name "DAYHighScoreServer" @implementation HighScoreDistributor - init { [super init]; servers = [[HashTable alloc] initKeyDesc:"*" valueDesc:"@" capacity:0]; return self; } - getServerFor:(const char *)gameName { // all we do is maintain a hash table that uses the name of the server // as a key. If the server is in the hash table, we return it. If it // isn't in the table, then we create a new server and return it. id newServer, temp; if ([servers isKey:gameName]) return [servers valueForKey:gameName]; newServer = [[HighScoreServer alloc] initForGame:gameName]; temp = [servers insertKey:gameName value:newServer]; if (temp) { // server existed. Shouldn't get here if that was the case; // if we _do_ get here, it's a bug in NeXT's HashTable! fprintf(stderr, "%s: Just blew away the %s server!\n", name, [temp gameName]); [[temp save] free]; } return newServer; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.