From 42841c2435617451ea9b213d7499803526609601 Mon Sep 17 00:00:00 2001 From: dhewg Date: Sun, 1 Jan 2012 17:47:34 +0100 Subject: [PATCH] Get rid of RegCodeHandler() Unhooked ancient code in the OSX backend which isn't working for D3XP. --- neo/sys/osx/DOOMController.mm | 174 ---------------------------------- 1 file changed, 174 deletions(-) diff --git a/neo/sys/osx/DOOMController.mm b/neo/sys/osx/DOOMController.mm index 40ed7053..904373cf 100644 --- a/neo/sys/osx/DOOMController.mm +++ b/neo/sys/osx/DOOMController.mm @@ -65,24 +65,8 @@ FPU_EXCEPTION_DIVIDE_BY_ZERO | \ /* FPU_EXCEPTION_INEXACT_RESULT | */ \ 0 -#define kRegKey @"RegCode" - -static const ControlID kRegCode1EditText = { 'RegC', 1 }; - -struct RegCodeInfo -{ - char prefRegCode1[256]; - bool okPressed; - WindowRef window; - ControlRef regCode1EditText; -}; - -static OSErr DoRegCodeDialog( char* ioRegCode1 ); - - @interface DOOMController (Private) - (void)quakeMain; -- (BOOL)checkRegCodes; - (BOOL)checkOS; @end @@ -370,29 +354,6 @@ extern void CL_Quit_f(void); [pool release]; } -- (BOOL)checkRegCodes -{ - BOOL retval; - NSString *cdKey; - NSUserDefaults *userDefaults; - - userDefaults = [NSUserDefaults standardUserDefaults]; - cdKey = [userDefaults stringForKey:kRegKey]; - - retval = TRUE; - if ( cdKey == nil || [cdKey length] == 0 ) { - char regCode[256]; - if ( DoRegCodeDialog( regCode ) != noErr ) { - retval = FALSE; - } - else { - [userDefaults setObject:[NSString stringWithCString: regCode] forKey:kRegKey]; - [userDefaults synchronize]; - } - } - return retval; -} - - (BOOL)checkOS { OSErr err; @@ -736,138 +697,3 @@ main int main( int argc, char *argv[] ) { return NSApplicationMain( argc, (const char **)argv ); } - -bool FormatRegCode(const char* inRegCode, char* outRegCode) -{ - // Clean up the reg code. Remove spaces. Accept only numbers/letters. - char* dst = outRegCode; - const char* src = inRegCode; - while (*src) - { - if (isalnum(*src)) - *dst++ = *src; - else if (*src != ' ') - return false; - src++; - } - *dst = 0; - - // Reg codes are 18 characters in length - return strlen(outRegCode) == 18; -} - -/* - =============== - RegCodeHandler - =============== - */ -static pascal OSStatus RegCodeHandler( EventHandlerCallRef, EventRef inEvent, void* inUserData ) -{ -#if 1 - // FIXME: the CD key API has changed for startup check support and expansion pack key support - return noErr; -#else - HICommand cmd; - OSStatus result = eventNotHandledErr; - RegCodeInfo* regCodeInfo = (RegCodeInfo*)inUserData; - - GetEventParameter( inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof( cmd ), NULL, &cmd ); - - switch ( cmd.commandID ) { - case kHICommandOK: - bool fValid; - Size actualSize; - char cntrl[256]; - char doomKey[256]; - char strippedKey[256]; - - fValid = false; - strippedKey[0] = doomKey[0] = NULL; - GetControlData ( regCodeInfo->regCode1EditText, kControlEntireControl, kControlEditTextTextTag, 256, cntrl, &actualSize ); - cntrl[actualSize] = NULL; - if ( FormatRegCode( cntrl, strippedKey ) ) { - strncat( doomKey, strippedKey, 16 ); - strcat( doomKey, " " ); - strncat( doomKey, strippedKey + 16, 2 ); - fValid = session->CheckKey( doomKey ); - } - if ( fValid ) { - strcpy( regCodeInfo->prefRegCode1, doomKey ); - session->SetCDKey( doomKey ); - } - else { - unsigned char theError[512]; - unsigned char theExplanation[512]; - CFStringRef theErrorStr = CFCopyLocalizedString( CFSTR("DVD_KEY_ERROR"), "" ); - CFStringRef theExplanationStr = CFCopyLocalizedString( CFSTR("DVD_KEY_EXPLANATION"), "" ); - c2pstrcpy( theError, CFStringGetCStringPtr( theErrorStr, kCFStringEncodingMacRoman ) ); - c2pstrcpy( theExplanation, CFStringGetCStringPtr( theExplanationStr, kCFStringEncodingMacRoman ) ); - - StandardAlert(kAlertStopAlert, theError, theExplanation, NULL, NULL); - - // Highlight the invalid reg code - ClearKeyboardFocus(regCodeInfo->window); - SetKeyboardFocus( regCodeInfo->window, regCodeInfo->regCode1EditText, kControlEditTextPart ); - ControlEditTextSelectionRec sel = {0, 32000}; - SetControlData (regCodeInfo->regCode1EditText, kControlEntireControl, kControlEditTextSelectionTag, sizeof(sel), &sel); - break; - } - - regCodeInfo->okPressed = true; - QuitAppModalLoopForWindow( regCodeInfo->window ); - result = noErr; - - break; - - case kHICommandCancel: - regCodeInfo->okPressed = false; - QuitAppModalLoopForWindow( regCodeInfo->window ); - result = noErr; - break; - - } - return result; -#endif -} - -/* - =============== - DoRegCodeDialog - =============== - */ -static OSErr DoRegCodeDialog( char* ioRegCode1 ) -{ - OSErr err; - RegCodeInfo regCodeInfo; - memset(®CodeInfo, 0, sizeof(regCodeInfo)); - - IBNibRef aslNib; - CFBundleRef theBundle = CFBundleGetMainBundle(); - err = CreateNibReferenceWithCFBundle( theBundle, CFSTR("ASLCore"), &aslNib ); - err = ::CreateWindowFromNib( aslNib, CFSTR("Reg Code Sheet"), ®CodeInfo.window ); - if (err != noErr) - return err; - - GetControlByID( regCodeInfo.window, &kRegCode1EditText, ®CodeInfo.regCode1EditText ); - assert( regCodeInfo.regCode1EditText ); - SetKeyboardFocus( regCodeInfo.window, regCodeInfo.regCode1EditText, kControlEditTextPart ); - ControlEditTextSelectionRec sel = {0, 32000}; - SetControlData (regCodeInfo.regCode1EditText, kControlEntireControl, kControlEditTextSelectionTag, sizeof(sel), &sel); - - EventTypeSpec cmdEvent = { kEventClassCommand, kEventCommandProcess }; - EventHandlerUPP handler = NewEventHandlerUPP( RegCodeHandler ); - InstallWindowEventHandler( regCodeInfo.window, handler, 1, &cmdEvent, ®CodeInfo, NULL ); - - RepositionWindow( regCodeInfo.window, NULL, kWindowAlertPositionOnMainScreen ); - ShowWindow( regCodeInfo.window ); - - RunAppModalLoopForWindow( regCodeInfo.window ); - - DisposeWindow( regCodeInfo.window ); - - if (regCodeInfo.okPressed) { - strcpy(ioRegCode1, regCodeInfo.prefRegCode1); - } - - return regCodeInfo.okPressed ? (OSErr)noErr : (OSErr)userCanceledErr; -}