This is GKHSLocalServer.m in view mode; [Download] [Up]
// GKHSLocalServer.m // under development; anything with ***** is yet to be completed // This class is the actual high score server for any given game. // This subclass handles local high score files. // I need to do exception handling in here to catch any DO problems, // but haven't got around to it yet, so exceptions will currently crash // the server. :-< ***** #import <appkit/appkit.h> #import <daymisckit/daymisckit.h> #import <gamekit/gamekit.h> #import <remote/NXProxy.h> #import <objc/objc-runtime.h> #import <objc/objc-load.h> @implementation GKHSLocalServer - initForGame:(const char *)name // designated initializer { if (![super initForGame:name]) return nil; if (!gameInfo) { // these are available locally, so set them up now. [self setTemplate:[[[NXApp delegate] highScoreController] tableProtoType]]; [self setGameInfo:[[NXApp delegate] gameInfo]]; } return self; } - (const char *)pathToTables { // High score files are stored inside the app wrapper. // any unloaded slots will be expected to be in the wrapper, too. return [NXApp appDirectory]; } - (oneway)setGameInfo:(bycopy in id)info { [super setGameInfo:info]; // Really need to set up for which table this is ***** right now assume 0 // This sets up the max # high scores for a local server [table setMaxScoresPerPlayer:[gameInfo maxScoresPerPlayerTable:0 net:NO]]; #ifdef NOISYDEBUG fprintf(stderr, "GKHSLocalServer: maxScorePerPlayer is %d.\n", [gameInfo maxScoresPerPlayerTable:0 net:NO]); #endif [self save]; return self; } - save { // make sure that the high score file is world read/write so everyone // can alter it (and save their scores) char *cmd = malloc(1024); [super save]; sprintf(cmd, "chmod 666 %s", [scoreFile stringValue]); system(cmd); free(cmd); return self; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.