Skip to content
Browse files

Source release of Wolfenstein 3D Classic Platinum for iOS, 1.2

  • Loading branch information...
1 parent a82aba6 commit 16304944b423f6daed7804422395406599a7d576 @tbradshaw tbradshaw committed
Showing with 10,694 additions and 184 deletions.
  1. +1 −0 wolf3d/code/env/common.h
  2. +11 −3 wolf3d/code/env/fileio.c
  3. +17 −1 wolf3d/code/env/files.c
  4. +1 −0 wolf3d/code/env/filesystem.h
  5. +1 −1 wolf3d/code/env/sound.c
  6. +30 −6 wolf3d/code/env/sound_sfx_id.c
  7. +41 −6 wolf3d/code/env/texture_manager.c
  8. +15 −0 wolf3d/code/iphone/EAGLView.h
  9. +123 −3 wolf3d/code/iphone/EAGLView.m
  10. +1,986 −0 wolf3d/code/iphone/FSCopyObject.c
  11. +258 −0 wolf3d/code/iphone/FSCopyObject.h
  12. +212 −0 wolf3d/code/iphone/GenLinkedList.c
  13. +93 −0 wolf3d/code/iphone/GenLinkedList.h
  14. +16 −14 wolf3d/code/iphone/Info.plist
  15. +104 −0 wolf3d/code/iphone/arialGlyphRects.h
  16. BIN wolf3d/code/iphone/default.png
  17. +8 −0 wolf3d/code/iphone/gles_glue.c
  18. +334 −0 wolf3d/code/iphone/hud.c
  19. +39 −0 wolf3d/code/iphone/iphone_alerts.h
  20. +110 −0 wolf3d/code/iphone/iphone_alerts.m
  21. +359 −0 wolf3d/code/iphone/iphone_downloadSOD.m
  22. +223 −0 wolf3d/code/iphone/iphone_downloadUserMap.m
  23. +588 −15 wolf3d/code/iphone/iphone_loop.c
  24. +32 −9 wolf3d/code/iphone/iphone_main.c
  25. +478 −0 wolf3d/code/iphone/iphone_mapselector.c
  26. +2,989 −77 wolf3d/code/iphone/iphone_menus.c
  27. +45 −5 wolf3d/code/iphone/iphone_wolf.h
  28. +1,409 −0 wolf3d/code/iphone/wolf3d.xcodeproj/greghodges.mode1v3
  29. +578 −0 wolf3d/code/iphone/wolf3d.xcodeproj/greghodges.pbxuser
  30. +76 −9 wolf3d/code/iphone/wolf3d.xcodeproj/project.pbxproj
  31. +3 −1 wolf3d/code/iphone/wolf3dAppDelegate.h
  32. +226 −2 wolf3d/code/iphone/wolf3dAppDelegate.m
  33. BIN wolf3d/code/iphone/wolf3d_icon.png
  34. +8 −8 wolf3d/code/wolf/wolf_actor_ai.c
  35. +5 −4 wolf3d/code/wolf/wolf_ai_com.c
  36. +58 −3 wolf3d/code/wolf/wolf_client_main.c
  37. +113 −1 wolf3d/code/wolf/wolf_level.c
  38. +1 −2 wolf3d/code/wolf/wolf_local.h
  39. +3 −1 wolf3d/code/wolf/wolf_main.c
  40. +72 −4 wolf3d/code/wolf/wolf_player.c
  41. +1 −0 wolf3d/code/wolf/wolf_player.h
  42. +14 −5 wolf3d/code/wolf/wolf_powerups.c
  43. +1 −1 wolf3d/code/wolf/wolf_pushwalls.c
  44. +10 −3 wolf3d/code/wolf/wolf_renderer.c
  45. +2 −0 wolf3d/code/wolfiphone.h
View
1 wolf3d/code/env/common.h
@@ -181,6 +181,7 @@ extern void Client_Init( void );
#define BUTTON_ATTACK 1
#define BUTTON_USE 2
#define BUTTON_CHANGE_WEAPON 4
+#define BUTTON_ALTERNATE_ATTACK 8 //gsh
#define BUTTON_ANY 128 // any key whatsoever
View
14 wolf3d/code/env/fileio.c
@@ -216,8 +216,6 @@ PUBLIC filehandle_t *FS_OpenFile( const char *filename, W32 FlagsAndAttributes )
pathBase = iphoneDocDirectory;
my_snprintf( netpath, sizeof( netpath ), "%s/%s", pathBase, filename );
} else {
-// extern char iphoneAppDirectory[1024];
-// pathBase = iphoneAppDirectory;
pathBase = FS_Gamedir();
my_snprintf( netpath, sizeof( netpath ), "%s/%s", pathBase, filename );
}
@@ -225,7 +223,17 @@ PUBLIC filehandle_t *FS_OpenFile( const char *filename, W32 FlagsAndAttributes )
// high performance file mapping path, avoiding stdio
fd = open( netpath, O_RDONLY );
if ( fd == -1 ) {
- return NULL;
+// return NULL;
+ //if it couldn't be found in that path then check again in the document directory
+ //gsh
+ //pathBase = FS_ForceGamedir();
+ extern char iphoneDocDirectory[1024];
+ pathBase = iphoneDocDirectory;
+ my_snprintf( netpath, sizeof( netpath ), "%s/%s", pathBase, filename );
+ fd = open( netpath, O_RDONLY );
+ if ( fd == -1 ) { //okay, couldn't find it there either... return null
+ return NULL;
+ }
}
fstat( fd, &s );
View
18 wolf3d/code/env/files.c
@@ -60,7 +60,7 @@
PRIVATE char fs_gamedir[ MAX_OSPATH ];
-
+//PRIVATE char fs_soddir[ MAX_OSPATH ]; //gsh
/*
@@ -77,8 +77,24 @@ PRIVATE char fs_gamedir[ MAX_OSPATH ];
*/
PUBLIC char *FS_Gamedir( void )
{
+ /*
+ //gsh... this is a trick to load in where the iphoneDocDirectory is
+ if (currentMap.episode >= 6)
+ {
+// sprintf( fs_soddir, "%s/SODbase", iphoneDocDirectory ); //if you're downloading the SOD data
+ sprintf( fs_soddir, "%s/", iphoneDocDirectory ); //if you're only downloading the spear maps
+ return fs_soddir;
+ }*/
+
return fs_gamedir;
}
+/*
+//gsh this is so that we can force a non-SOD folder
+//it's only getting used in the FSOpenFile() of fileio.c
+PUBLIC char *FS_ForceGamedir( void )
+{
+ return fs_gamedir;
+}*/
/*
View
1 wolf3d/code/env/filesystem.h
@@ -45,6 +45,7 @@
extern void FS_InitFilesystem(void);
extern char *FS_Gamedir(void);
+//extern char *FS_ForceGamedir(void); //gsh
View
2 wolf3d/code/env/sound.c
@@ -690,7 +690,7 @@ PRIVATE void Sound_Register( void )
{
s_initSound = Cvar_Get( "s_initSound", "1", CVAR_INIT );
- s_masterVolume = Cvar_Get( "s_masterVolume", "1.0", CVAR_ARCHIVE );
+ s_masterVolume = Cvar_Get( "s_masterVolume", "0.3", CVAR_ARCHIVE ); //gsh changed this from "1.0" to "0.3" for the volume hack... otherwise it's too loud
s_sfxVolume = Cvar_Get( "s_sfxVolume", "1.0", CVAR_ARCHIVE );
s_musicVolume = Cvar_Get( "s_musicVolume", "1.0", CVAR_ARCHIVE );
s_minDistance = Cvar_Get( "s_minDistance", "0.0", CVAR_ARCHIVE );
View
36 wolf3d/code/env/sound_sfx_id.c
@@ -248,33 +248,57 @@ PUBLIC void Sound_BeginRegistration( void )
s_registering = true;
}
+
PUBLIC sfx_t *Sound_RegisterSound( const char *name )
{
sfx_t *sfx;
+ bool isSpearSound = false;
if( ! sound_initialized )
{
return NULL;
}
-
- if( g_version->value == 1 )
+
+ if( g_version->value == SPEAROFDESTINY && currentMap.episode >= 6 && strncmp(name, "iphone", 6) && currentMap.episode < 9)//added the episode & iphone check... gsh
{
+ isSpearSound = true;
+
char tempname[ 256 ];
-
my_snprintf( tempname, sizeof( tempname ), "sod%s", name );
-
sfx = Sound_FindSound( tempname );
+
+ //gsh
+ //Com_Printf("Finding Sound: %s\n", tempname);
}
else
{
sfx = Sound_FindSound( name );
+
+ //gsh
+ //Com_Printf("Finding Sound: %s\n", name);
}
-
+/*
+ //original
if( ! s_registering )
{
Sound_LoadSound( sfx );
}
-
+*/
+ //gsh
+ if( ! s_registering )
+ {
+ //if it couldn't be found and we tried finding it in sod
+ //then it might exist in wolf3d
+ if( !Sound_LoadSound( sfx ) && isSpearSound)
+ {
+ sfx = Sound_FindSound( name );
+ //Com_Printf("Finding Sound Again: %s\n", name);
+
+ if( ! s_registering )
+ Sound_LoadSound( sfx ); //try loading again
+ }
+ }
+
return sfx;
}
View
47 wolf3d/code/env/texture_manager.c
@@ -464,14 +464,14 @@ PUBLIC texture_t *TM_FindTexture( const char *name, texturetype_t type )
{
return r_notexture;
}
-
+
// Check for file extension
len = strlen( name );
if( len < 5 )
{
return r_notexture;
}
-
+
// look for it in the texture cache
for( i = 0, tex = ttextures; i < numttextures; ++i, ++tex )
{
@@ -490,7 +490,8 @@ PUBLIC texture_t *TM_FindTexture( const char *name, texturetype_t type )
return r_notexture;
}
-// Com_Printf( "Loading texture: %s\n", name );
+ //gsh
+ //Com_Printf( "Loading texture: %s\n", name );
// look for the pre-digested 5551 version
strcpy( digested, name );
@@ -514,7 +515,6 @@ PUBLIC texture_t *TM_FindTexture( const char *name, texturetype_t type )
{ GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, GL_UNSIGNED_BYTE, 2 },
};
-
picHeader_t *ph = (picHeader_t *)fh->filedata;
int noMips = 0;
@@ -606,7 +606,7 @@ PUBLIC texture_t *TM_FindTexture( const char *name, texturetype_t type )
if ( fh == NULL ) {
Com_Printf( "Failed to find texture %s\n", name );
return r_notexture;
- }
+ } //else { //added the else...gsh
jpgSize = FS_GetFileSize( fh );
jpgData = fh->ptrStart;
@@ -616,13 +616,48 @@ PUBLIC texture_t *TM_FindTexture( const char *name, texturetype_t type )
if ( ! data ) {
free( jpgData );
return r_notexture;
- }
+ } //else { //added the else
tex = TM_LoadTexture( name, data, width, height, type, bytes );
MM_FREE( data );
tex->maxS = tex->maxT = 1.0f;
return tex;
+
+
+ }
+
+ /*
+ Com_Printf("Trying to find texture made it to the end\n");
+
+ //gsh.. couldn't find it... try doing it again, but looking in a new location
+ if (spritelocation == SODSPRITESDIRNAME && spritelocation != WL6SPRITESDIRNAME)
+ {
+ //need to remove the 'sod'
+ if (strncmp(spritelocation, name, strlen(spritelocation)) == 0)
+ {
+ char buffer[64];
+ char tempName[64];
+ int offset = strlen(spritelocation) + 1;
+ for (int i = 0; i < strlen(name) - offset; ++i)
+ {
+ buffer[i] = name[i+offset];
+ }
+ buffer[i] = '\0'; //just in case
+
+ spritelocation = WL6SPRITESDIRNAME;
+
+ //TODO:
+ my_snprintf(tempName, sizeof(tempName), "%s/%s", spritelocation, buffer);
+
+ Com_Printf("tempName: %s\n", tempName);
+ Com_Printf("buffer: %s\n", buffer);
+
+ spritelocation = SODSPRITESDIRNAME; //return to sodsprites
+ tex = TM_FindTexture( tempName, type);
+ return tex;
+ }
}
+ return r_notexture;*/
return NULL;
}
View
15 wolf3d/code/iphone/EAGLView.h
@@ -24,6 +24,13 @@
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
+
+
+
+#ifdef VOLUMEHACK
+#import <MediaPlayer/MPVolumeView.h>
+#endif
+
/*
This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
The view content is basically an EAGL surface you render your OpenGL scene into.
@@ -49,6 +56,14 @@ Note that setting the view non-opaque will only work if the EAGL surface has an
NSTimer *animationTimer;
NSTimeInterval animationInterval;
+ //gsh... an attempt at hacking the volume button
+#ifdef VOLUMEHACK
+ MPVolumeView *volumeView;
+ UISlider *volumeViewSlider;
+ float lastFramesVolume;
+#endif
+// NSThread *pLoadThread;
+
}
@property NSTimeInterval animationInterval;
View
126 wolf3d/code/iphone/EAGLView.m
@@ -16,6 +16,11 @@
#include "wolfiphone.h"
+
+
+//gsh
+//#define NOTIFYLISTEN //uncomment to receive notifications
+
struct AVSystemControllerPrivate;
@interface AVSystemController : NSObject
@@ -144,6 +149,40 @@ - (id)initWithCoder:(NSCoder*)coder {
((void(*)(int))eglSwapInterval)( 2 );
}
#endif
+
+#ifdef VOLUMEHACK
+ //-------------------
+ // Volume Button Hack
+ //gsh
+ // Note: MediaPlayer framework required for this trick
+ //create a MPVolumeView to hack the volume button
+ CGRect frame = CGRectMake(0, -30, 180, 10); //put this thing offscreen
+ volumeView = [[[MPVolumeView alloc] initWithFrame:frame] autorelease];
+ [volumeView sizeToFit];
+ [self addSubview:volumeView];
+
+ // Find the volume view slider
+ for (UIView *view in [volumeView subviews]){
+ if ([[[view class] description] isEqualToString:@"MPVolumeSlider"]) {
+ volumeViewSlider = (UISlider *)view;
+ }
+ }
+
+ //listen for volume changes
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(volumeListener:)
+ name:@"AVSystemController_SystemVolumeDidChangeNotification"
+ object:nil];
+
+ //---------------------
+#endif
+
+#ifdef NOTIFYLISTEN //gsh
+ //this is a general purpose listener
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationListener:)
+ name:nil
+ object:nil];
+#endif
// with swapinterval, we want to update as fast as possible
float interval = 1.0 / 30.0f;
@@ -155,7 +194,14 @@ - (id)initWithCoder:(NSCoder*)coder {
return self;
}
+//gsh
+- (void)viewDidLoad {
+
+ Com_Printf("\n---------------\nviewDidLoad() called\n---------------\n\n");
+}
+
- (void)drawView {
+
[ (wolf3dAppDelegate *)[UIApplication sharedApplication].delegate restartAccelerometerIfNeeded];
#if 0
@@ -175,11 +221,28 @@ - (void)drawView {
}
}
#endif
+
+#ifdef VOLUMEHACK
//------------------
+ // volume hack
+
+
+ //check for volume adjustments gsh
+ if ( menuState == IPM_CONTROLS)
+ {
+ if (lastFramesVolume != s_masterVolume->value)
+ {
+ lastFramesVolume = s_masterVolume->value;
+ [volumeViewSlider setValue:lastFramesVolume animated:NO];
+ [volumeViewSlider _commitVolumeChange];
+ }
+ }
+#endif
iphoneFrame(); // swapBuffers() will be called from here
}
+
- (void)swapBuffers {
// glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
loggedTimes[iphoneFrameNum&(MAX_LOGGED_TIMES-1)].beforeSwap = Sys_Milliseconds();
@@ -215,7 +278,11 @@ - (void)dealloc {
- (void) handleTouches:(NSSet*)touches withEvent:(UIEvent*)event {
int touchCount = 0;
int points[16];
- static int previousTouchCount;
+ static int previousTouchCount = 0;
+
+ //gsh
+ if (previousTouchCount == 0)
+ isTouchMoving = 0;
NSSet *t = [event allTouches];
for (UITouch *myTouch in t)
@@ -232,10 +299,12 @@ - (void) handleTouches:(NSSet*)touches withEvent:(UIEvent*)event {
}
if (myTouch.phase == UITouchPhaseMoved) {
// touch moved handler
+ //gsh, use this for swipe events in the scrolling menus
+ isTouchMoving = 1;
}
if (myTouch.phase == UITouchPhaseEnded) {
touchCount--;
- }
+ }
}
// toggle the console with four touches
@@ -281,11 +350,62 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[self handleTouches:touches withEvent:event];
}
-
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self handleTouches:touches withEvent:event];
}
+// gsh
+#ifdef NOTIFYLISTEN
+- (void) notificationListener:(NSNotification *)notify
+{
+ Com_Printf("notificationListener: %s\n", [notify.name UTF8String]);
+//NSString
+
+ if ([notify.name isEqualToString:@"CPDistributedMessagingCenterServerDidTerminateNotification"] && menuState == IPM_STOREKIT)
+ {
+ iphoneMessageBox("Apple Store Failed", "Connection to app store has terminated. Please try again later.");
+ menuState = IPM_MAIN;
+ }
+ //sometimes after requrestProductData() is called we get these notifications
+ //and the storekit no longer responds (making it appear as a crash)
+ /*
+notificationListener: CPDistributedMessagingCenterServerDidTerminateNotification
+notificationListener: SKNotificationRequestFinished
+notificationListener: SKNotificationTransactionsRefreshed
+notificationListener: CPDistributedMessagingCenterServerDidTerminateNotification
+*/
+}
+#endif
+
+#ifdef VOLUMEHACK
+//-------------------
+// Volume Button Hack
+// gsh
+// currently this is problematic...
+// it's slow if the user holds the volume button
+// let's see if inlining this with the normal game loop is faster
+// than listening for the event... it's not
+// Note: MediaPlayer framework required for this trick
+//-------------------
+- (void) volumeListener:(NSNotification *)notify
+{
+ //TODO: provide left/right click attacks
+ if (volumeViewSlider.value < s_masterVolume->value)
+ {
+
+ [volumeViewSlider setValue:s_masterVolume->value animated:NO];//volumeSetting animated:NO];
+ [volumeViewSlider _commitVolumeChange]; //again, ignoring compiler warning complaints
+ //this might have a warning because it's currently undocumented?
+ Cvar_Set("volumeFireDown", "1");
+ }
+ else if (volumeViewSlider.value > s_masterVolume->value)//volumeSetting)
+ {
+ [volumeViewSlider setValue:s_masterVolume->value animated:NO];//volumeSetting animated:NO];
+ [volumeViewSlider _commitVolumeChange]; //again, ignoring compiler warning complaints
+ Cvar_Set("volumeFireUp", "1");
+ }
+}
+#endif
@end
View
1,986 wolf3d/code/iphone/FSCopyObject.c
1,986 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
258 wolf3d/code/iphone/FSCopyObject.h
@@ -0,0 +1,258 @@
+/*
+ File: FSCopyObject.h
+
+ Contains: A Copy/Delete Files/Folders engine which uses the HFS+ API's
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
+ ("Apple") in consideration of your agreement to the following terms, and your
+ use, installation, modification or redistribution of this Apple software
+ constitutes acceptance of these terms. If you do not agree with these terms,
+ please do not use, install, modify or redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and subject
+ to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
+ copyrights in this original Apple software (the "Apple Software"), to use,
+ reproduce, modify and redistribute the Apple Software, with or without
+ modifications, in source and/or binary forms; provided that if you redistribute
+ the Apple Software in its entirety and without modifications, you must retain
+ this notice and the following text and disclaimers in all such redistributions of
+ the Apple Software. Neither the name, trademarks, service marks or logos of
+ Apple Computer, Inc. may be used to endorse or promote products derived from the
+ Apple Software without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or implied,
+ are granted by Apple herein, including but not limited to any patent rights that
+ may be infringed by your derivative works or by other works in which the Apple
+ Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+ WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+ COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+ OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+ (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright © 2002-2004 Apple Computer, Inc., All Rights Reserved
+*/
+
+
+#ifndef __FSCOPYOBJECT_H__
+#define __FSCOPYOBJECT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if TARGET_API_MAC_OSX || defined( __APPLE_CC__ )
+#include <CoreServices/CoreServices.h>
+#endif
+
+#define DEBUG 1 /* set to zero if you don't want debug spew */
+
+#if DEBUG
+ #include <stdio.h>
+
+ #define QuoteExceptionString(x) #x
+
+ #define dwarning(s) do { printf s; fflush(stderr); } while( 0 )
+
+ #define mycheck_noerr( error ) \
+ do { \
+ if( (OSErr) error != noErr ) { \
+ dwarning((QuoteExceptionString(error) " != noErr in File: %s, Function: %s, Line: %d, Error: %d\n", \
+ __FILE__, __FUNCTION__, __LINE__, (OSErr) error)); \
+ } \
+ } while( false )
+
+ #define mycheck( assertion ) \
+ do { \
+ if( ! assertion ) { \
+ dwarning((QuoteExceptionString(assertion) " failed in File: %s, Function: %s, Line: %d\n", \
+ __FILE__, __FUNCTION__, __LINE__)); \
+ } \
+ } while( false )
+
+ #define myverify(assertion) mycheck(assertion)
+ #define myverify_noerr(assertion) mycheck_noerr( (assertion) )
+#else
+ #define dwarning(s)
+
+ #define mycheck(assertion)
+ #define mycheck_noerr(err)
+ #define myverify(assertion) do { (void) (assertion); } while (0)
+ #define myverify_noerr(assertion) myverify(assertion)
+#endif
+
+/*
+ This code takes some tricks/techniques from MoreFilesX (by Jim Luther) and
+ MPFileCopy (by Quinn), wraps them all up into an easy to use API, and adds a bunch of
+ features and bug fixes. It will run on Mac OS 9.1 through 9.2.x and 10.1.x
+ and up (Classic, Carbon and Mach-O)
+*/
+
+ /* Different options that FSCopyObject can take during a copy */
+typedef UInt32 DupeAction;
+enum {
+ kDupeActionStandard, /* will do the copy with no frills */
+ kDupeActionReplace, /* will delete the existing object and then copy over the new one */
+ kDupeActionRename /* will rename the new object if an object of the same name exists */
+};
+
+/*****************************************************************************/
+
+#pragma mark CopyObjectFilterProcPtr
+
+/*
+ This is the prototype for the CallCopyObjectFilterProc function which
+ is called once for each file and directory found by FSCopyObject.
+ The CallCopyObjectFilterProc can use the read-only data it receives for
+ whatever it wants.
+
+ The result of the CallCopyObjectFilterProc function indicates if
+ the copy should be stopped. To stop the copy, return an error; to continue
+ the copy, return noErr.
+
+ The yourDataPtr parameter can point to whatever data structure you might
+ want to access from within the CallCopyObjectFilterProc.
+
+ Note: If an error had occured during the copy of the current object
+ (currentOSErr != noErr) the FSRef etc might not be valid
+
+ containerChanged --> Set to true if the container's contents changed
+ during iteration.
+ currentLevel --> The current recursion level into the container.
+ 1 = the container, 2 = the container's immediate
+ subdirectories, etc.
+ currentOSErr --> The current error code, shows the results of the
+ copy of the current object (ref)
+ catalogInfo --> The catalog information for the current object.
+ Only the fields requested by the whichInfo
+ parameter passed to FSIterateContainer are valid.
+ ref --> The FSRef to the current object.
+ spec --> The FSSpec to the current object if the wantFSSpec
+ parameter passed to FSCopyObject is true.
+ name --> The name of the current object if the wantName
+ parameter passed to FSCopyObject is true.
+ yourDataPtr --> An optional pointer to whatever data structure you
+ might want to access from within the
+ CallCopyObjectFilterProc.
+ result <-- To continue the copy, return noErr
+
+ __________
+
+ Also see: FSCopyObject
+*/
+
+typedef CALLBACK_API( OSErr , CopyObjectFilterProcPtr ) (
+ Boolean containerChanged,
+ ItemCount currentLevel,
+ OSErr currentOSErr,
+ const FSCatalogInfo *catalogInfo,
+ const FSRef *ref,
+ const FSSpec *spec,
+ const HFSUniStr255 *name,
+ void *yourDataPtr);
+
+
+/*****************************************************************************/
+
+#pragma mark CallCopyObjectFilterProc
+
+#define CallCopyObjectFilterProc(userRoutine, containerChanged, currentLevel, currentOSErr, catalogInfo, ref, spec, name, yourDataPtr) \
+ (*(userRoutine))((containerChanged), (currentLevel), (currentOSErr), (catalogInfo), (ref), (spec), (name), (yourDataPtr))
+
+/*****************************************************************************/
+
+#pragma mark FSCopyObject
+
+/*
+ The FSCopyObject function takes a source object (can be a file or directory)
+ and copies it (and its contents if it's a directory) to the new destination
+ directory.
+
+ It will call your CopyObjectFilterProcPtr once for each object copied
+
+ The maxLevels parameter is only used when the object is a directory,
+ ignored otherwise.
+ It lets you control how deep the recursion goes.
+ If maxLevels is 1, FSCopyObject only scans the specified directory;
+ if maxLevels is 2, FSCopyObject scans the specified directory and
+ one subdirectory below the specified directory; etc. Set maxLevels to
+ zero to scan all levels.
+
+ The yourDataPtr parameter can point to whatever data structure you might
+ want to access from within your CopyObjectFilterProcPtr.
+
+ source --> The FSRef to the object you want to copy
+ destDir --> The FSRef to the directory you wish to copy source to
+ maxLevels --> Maximum number of directory levels to scan or
+ zero to scan all directory levels, ignored if the
+ object is a file
+ whichInfo --> The fields of the FSCatalogInfo you wish passed
+ to you in your CopyObjectFilterProc
+ dupeAction --> The action to take if an object of the same name exists
+ in the destination
+ newName --> The name you want the new object to have. If you pass
+ in NULL, the source object name will be used.
+ wantFSSpec --> Set to true if you want the FSSpec to each
+ object passed to your CopyObjectFilterProc.
+ wantName --> Set to true if you want the name of each
+ object passed to your CopyObjectFilterProc.
+ filterProcPtr --> A pointer to the CopyObjectFilterProc you
+ want called once for each object found
+ by FSCopyObject.
+ yourDataPtr --> An optional pointer to whatever data structure you
+ might want to access from within the
+ CopyObjectFilterProc.
+ newObjectRef --> An optional pointer to an FSRef that, on return,
+ references the new object. If you don't want this
+ info returned, pass in NULL
+ newObjectSpec --> An optional pointer to an FSSPec that, on return,
+ references the new object. If you don't want this
+ info returned, pass in NULL
+*/
+
+OSErr FSCopyObject( const FSRef *source,
+ const FSRef *destDir,
+ ItemCount maxLevels,
+ FSCatalogInfoBitmap whichInfo,
+ DupeAction dupeAction,
+ const HFSUniStr255 *newName, /* can be NULL */
+ Boolean wantFSSpec,
+ Boolean wantName,
+ CopyObjectFilterProcPtr filterProcPtr, /* can be NULL */
+ void *yourDataPtr, /* can be NULL */
+ FSRef *newObjectRef, /* can be NULL */
+ FSSpec *newObjectSpec); /* can be NULL */
+
+/*****************************************************************************/
+
+#pragma mark FSDeleteObjects
+
+/*
+ The FSDeleteObjects function takes an FSRef to a file or directory
+ and attempts to delete it. If the object is a directory, all files
+ and subdirectories in the specified directory are deleted. If a
+ locked file or directory is encountered, it is unlocked and then
+ deleted. After deleting the directory's contents, the directory
+ is deleted. If any unexpected errors are encountered,
+ FSDeleteContainer quits and returns to the caller.
+
+ source --> FSRef to an object (can be file or directory).
+
+ __________
+*/
+
+OSErr FSDeleteObjects( const FSRef *source );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
View
212 wolf3d/code/iphone/GenLinkedList.c
@@ -0,0 +1,212 @@
+/*
+ File: GenLinkedList.c
+
+ Contains: Linked List utility routines
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
+ ("Apple") in consideration of your agreement to the following terms, and your
+ use, installation, modification or redistribution of this Apple software
+ constitutes acceptance of these terms. If you do not agree with these terms,
+ please do not use, install, modify or redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and subject
+ to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
+ copyrights in this original Apple software (the "Apple Software"), to use,
+ reproduce, modify and redistribute the Apple Software, with or without
+ modifications, in source and/or binary forms; provided that if you redistribute
+ the Apple Software in its entirety and without modifications, you must retain
+ this notice and the following text and disclaimers in all such redistributions of
+ the Apple Software. Neither the name, trademarks, service marks or logos of
+ Apple Computer, Inc. may be used to endorse or promote products derived from the
+ Apple Software without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or implied,
+ are granted by Apple herein, including but not limited to any patent rights that
+ may be infringed by your derivative works or by other works in which the Apple
+ Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+ WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+ COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+ OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+ (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright © 2003-2004 Apple Computer, Inc., All Rights Reserved
+*/
+
+#include "GenLinkedList.h"
+
+#pragma mark --- Data Structures ---
+
+ /* This is the internal data structure for the nodes in the linked list. */
+ /* */
+ /* Note: The memory pointed to by pNext is owned by the list and is disposed of */
+ /* in DestroyList. It should not be disposed of in any other way. */
+ /* */
+ /* Note: The memory pointed to by pData is owned by the caller of the linked */
+ /* list. The caller is responsible for disposing of this memory. This can be */
+ /* done by simply implementing a DisposeDataProc that will be called on each */
+ /* node in the list, giving the caller a chance to dispose of any memory */
+ /* created. The DisposeDataProc is called from DestroyList */
+struct GenNode
+{
+ struct GenNode *pNext; /* Pointer to the next node in the list */
+ GenDataPtr pData; /* The data for this node, owned by caller */
+};
+typedef struct GenNode GenNode;
+
+#pragma mark --- List Implementation ---
+
+ /* Initializes the given GenLinkedList to an empty list. This MUST be */
+ /* called before any operations are performed on the list, otherwise bad things */
+ /* will happen. */
+void InitLinkedList( GenLinkedList *pList, DisposeDataProcPtr disposeProcPtr)
+{
+ if( pList == NULL )
+ return;
+
+ pList->pHead = pList->pTail = NULL;
+ pList->NumberOfItems = 0;
+ pList->DisposeProcPtr = disposeProcPtr;
+}
+
+ /* returns the current number of items in the given list. */
+ /* If pList == NULL, it returns 0 */
+ItemCount GetNumberOfItems( GenLinkedList *pList )
+{
+ return (pList) ? pList->NumberOfItems : 0;
+}
+
+ /* Creates a new node, containing pData, and adds it to the tail of pList. */
+ /* Note: if an error occurs, pList is unchanged. */
+OSErr AddToTail( GenLinkedList *pList, void *pData )
+{
+ OSErr err = paramErr;
+ GenNode *tmpNode = NULL;
+
+ if( pList == NULL || pData == NULL )
+ return err;
+
+ /* create memory for new node, if this fails we _must_ bail */
+ err = ( ( tmpNode = (GenNode*) NewPtr( sizeof( GenNode ) ) ) != NULL ) ? noErr : MemError();
+ if( err == noErr )
+ {
+ tmpNode->pData = pData; /* Setup new node */
+ tmpNode->pNext = NULL;
+
+ if( pList->pTail != NULL ) /* more then one item already */
+ ((GenNode*) pList->pTail)->pNext = (void*) tmpNode; /* so append to tail */
+ else
+ pList->pHead = (void*) tmpNode; /* no items, so adjust head */
+
+ pList->pTail = (void*) tmpNode;
+ pList->NumberOfItems += 1;
+ }
+
+ return err;
+}
+
+ /* Takes pSrcList and inserts it into pDestList at the location pIter points to. */
+ /* The lists must have the same DisposeProcPtr, but the Data can be different. If pSrcList */
+ /* is empty, it does nothing and just returns */
+ /* */
+ /* If pIter == NULL, insert pSrcList before the head */
+ /* else If pIter == pTail, append pSrcList to the tail */
+ /* else insert pSrcList in the middle somewhere */
+ /* On return: pSrcList is cleared and is an empty list. */
+ /* The data that was owned by pSrcList is now owned by pDestList */
+void InsertList( GenLinkedList *pDestList, GenLinkedList *pSrcList, GenIteratorPtr pIter )
+{
+ if( pDestList == NULL || pSrcList == NULL ||
+ pSrcList->pHead == NULL || pSrcList->pTail == NULL ||
+ pDestList->DisposeProcPtr != pSrcList->DisposeProcPtr )
+ return;
+
+ if( pDestList->pHead == NULL && pDestList->pTail == NULL ) /* empty list */
+ {
+ pDestList->pHead = pSrcList->pHead;
+ pDestList->pTail = pSrcList->pTail;
+ }
+ else if( pIter == NULL ) /* insert before head */
+ {
+ /* attach the list */
+ ((GenNode*)pSrcList->pTail)->pNext = pDestList->pHead;
+ /* fix up head */
+ pDestList->pHead = pSrcList->pHead;
+ }
+ else if( pIter == pDestList->pTail ) /* append to tail */
+ {
+ /* attach the list */
+ ((GenNode*)pDestList->pTail)->pNext = pSrcList->pHead;
+ /* fix up tail */
+ pDestList->pTail = pSrcList->pTail;
+ }
+ else /* insert in middle somewhere */
+ {
+ GenNode *tmpNode = ((GenNode*)pIter)->pNext;
+ ((GenNode*)pIter)->pNext = pSrcList->pHead;
+ ((GenNode*)pSrcList->pTail)->pNext = tmpNode;
+ }
+
+ pDestList->NumberOfItems += pSrcList->NumberOfItems; /* sync up NumberOfItems */
+
+ InitLinkedList( pSrcList, NULL); /* reset the source list */
+}
+
+ /* Goes through the list and disposes of any memory we allocated. Calls the DisposeProcPtr,*/
+ /* if it exists, to give the caller a chance to free up their memory */
+void DestroyList( GenLinkedList *pList )
+{
+ GenIteratorPtr pIter = NULL,
+ pNextIter = NULL;
+
+ if( pList == NULL )
+ return;
+
+ for( InitIterator( pList, &pIter ), pNextIter = pIter; pIter != NULL; pIter = pNextIter )
+ {
+ Next( &pNextIter ); /* get the next node before we blow away the link */
+
+ if( pList->DisposeProcPtr != NULL )
+ CallDisposeDataProc( pList->DisposeProcPtr, GetData( pIter ) );
+ DisposePtr( (char*) pIter );
+ }
+
+ InitLinkedList( pList, NULL);
+}
+
+/*#############################################*/
+/*#############################################*/
+/*#############################################*/
+
+#pragma mark -
+#pragma mark --- Iterator Implementation ---
+
+ /* Initializes pIter to point at the head of pList */
+ /* This must be called before performing any operations with pIter */
+void InitIterator( GenLinkedList *pList, GenIteratorPtr *pIter )
+{
+ if( pList != NULL && pIter != NULL )
+ *pIter = pList->pHead;
+}
+
+ /* On return, pIter points to the next node in the list. NULL if its gone */
+ /* past the end of the list */
+void Next( GenIteratorPtr *pIter )
+{
+ if( pIter != NULL )
+ *pIter = ((GenNode*)*pIter)->pNext;
+}
+
+ /* Returns the data of the current node that pIter points to */
+GenDataPtr GetData( GenIteratorPtr pIter )
+{
+ return ( pIter != NULL ) ? ((GenNode*)pIter)->pData : NULL;
+}
View
93 wolf3d/code/iphone/GenLinkedList.h
@@ -0,0 +1,93 @@
+/*
+ File: GenLinkedList.h
+
+ Contains: Linked List utility routines prototypes
+
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
+ ("Apple") in consideration of your agreement to the following terms, and your
+ use, installation, modification or redistribution of this Apple software
+ constitutes acceptance of these terms. If you do not agree with these terms,
+ please do not use, install, modify or redistribute this Apple software.
+
+ In consideration of your agreement to abide by the following terms, and subject
+ to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
+ copyrights in this original Apple software (the "Apple Software"), to use,
+ reproduce, modify and redistribute the Apple Software, with or without
+ modifications, in source and/or binary forms; provided that if you redistribute
+ the Apple Software in its entirety and without modifications, you must retain
+ this notice and the following text and disclaimers in all such redistributions of
+ the Apple Software. Neither the name, trademarks, service marks or logos of
+ Apple Computer, Inc. may be used to endorse or promote products derived from the
+ Apple Software without specific prior written permission from Apple. Except as
+ expressly stated in this notice, no other rights or licenses, express or implied,
+ are granted by Apple herein, including but not limited to any patent rights that
+ may be infringed by your derivative works or by other works in which the Apple
+ Software may be incorporated.
+
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+ WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+ COMBINATION WITH YOUR PRODUCTS.
+
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+ OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+ (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright © 2003-2004 Apple Computer, Inc., All Rights Reserved
+*/
+
+
+#ifndef __GENLINKEDLIST__
+#define __GENLINKEDLIST__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if TARGET_API_MAC_OSX || defined( __APPLE_CC__ )
+#include <CoreServices/CoreServices.h>
+#endif
+
+/* This is a quick, simple and generic linked list implementation. I tried */
+/* to setup the code so that you could use any linked list implementation you */
+/* want. They just need to support these few functions. */
+
+typedef void* GenIteratorPtr;
+typedef void* GenDataPtr;
+
+ /* This is a callback that is called from DestroyList for each node in the */
+ /* list. It gives the caller the oportunity to free any memory they might */
+ /* allocated in each node. */
+typedef CALLBACK_API( void , DisposeDataProcPtr ) ( GenDataPtr pData );
+
+#define CallDisposeDataProc( userRoutine, pData ) (*(userRoutine))((pData))
+
+struct GenLinkedList
+{
+ GenDataPtr pHead; /* Pointer to the head of the list */
+ GenDataPtr pTail; /* Pointer to the tail of the list */
+ ItemCount NumberOfItems; /* Number of items in the list (mostly for debugging) */
+ DisposeDataProcPtr DisposeProcPtr; /* rountine called to dispose of caller data, can be NULL */
+};
+typedef struct GenLinkedList GenLinkedList;
+
+void InitLinkedList ( GenLinkedList *pList, DisposeDataProcPtr disposeProcPtr );
+ItemCount GetNumberOfItems( GenLinkedList *pList );
+OSErr AddToTail ( GenLinkedList *pList, GenDataPtr pData );
+void InsertList ( GenLinkedList *pDestList, GenLinkedList *pSrcList, GenIteratorPtr pIter );
+void DestroyList ( GenLinkedList *pList );
+
+void InitIterator ( GenLinkedList *pList, GenIteratorPtr *pIter );
+void Next ( GenIteratorPtr *pIter );
+GenDataPtr GetData ( GenIteratorPtr pIter );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
View
30 wolf3d/code/iphone/Info.plist
@@ -7,13 +7,13 @@
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
- <string>${PRODUCT_NAME}</string>
+ <string>${PRODUCT_NAME}+</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>${PRODUCT_NAME}_icon.png</string>
<key>CFBundleIdentifier</key>
- <string>${PROFILE_PREFIX}.${PRODUCT_NAME:identifier}</string>
+ <string>com.idsoftware.${PRODUCT_NAME:identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
@@ -22,26 +22,28 @@
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
- <key>CFBundleVersion</key>
- <string>1.1</string>
- <key>LSRequiresIPhoneOS</key>
- <true/>
- <key>NSMainNibFile</key>
- <string>MainWindow</string>
- <key>UIInterfaceOrientation</key>
- <string>UIInterfaceOrientationLandscapeLeft</string>
- <key>UIStatusBarHidden</key>
- <true/>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
- <string>com.idsoftware.wolf3d</string>
+ <string>com.idsoftware.wolf3dp</string>
<key>CFBundleURLSchemes</key>
<array>
- <string>wolf3d</string>
+ <string>wolf3dp</string>
</array>
</dict>
</array>
+ <key>CFBundleVersion</key>
+ <string>1.2</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>NSMainNibFile</key>
+ <string>MainWindow</string>
+ <key>UIInterfaceOrientation</key>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <key>UIPrerenderedIcon</key>
+ <true/>
+ <key>UIStatusBarHidden</key>
+ <true/>
</dict>
</plist>
View
104 wolf3d/code/iphone/arialGlyphRects.h
@@ -0,0 +1,104 @@
+// generated by fontimg
+//
+
+typedef struct { unsigned short x0, y0, x1, y1; float xoff, yoff, xadvance; } GlyphRect;
+
+GlyphRect glyphRects[] = {
+ /* ' ' */ { 2, 2, 2, 2, 0.000000, 0.000000, 7.958042 },
+ /* '!' */ { 6, 2, 9, 22, 2.250000, -20.750000, 7.958042 },
+ /* '"' */ { 14, 2, 21, 9, 1.250000, -20.750000, 10.167832 },
+ /* '#' */ { 26, 2, 41, 23, 0.250000, -21.000000, 15.930070 },
+ /* '$' */ { 46, 2, 59, 27, 1.000000, -22.500000, 15.930070 },
+ /* '%' */ { 64, 2, 86, 24, 1.500000, -21.000000, 25.468531 },
+ /* '&' */ { 92, 2, 109, 23, 1.000000, -21.000000, 19.104895 },
+ /* ''' */ { 114, 2, 117, 9, 1.250000, -20.750000, 5.468532 },
+ /* '(' */ { 122, 2, 129, 29, 1.500000, -21.000000, 9.538462 },
+ /* ')' */ { 134, 2, 141, 29, 1.500000, -21.000000, 9.538462 },
+ /* '*' */ { 146, 2, 155, 11, 0.750000, -21.000000, 11.146853 },
+ /* '+' */ { 160, 2, 173, 15, 1.500000, -17.000000, 16.727272 },
+ /* ',' */ { 178, 2, 181, 9, 2.250000, -3.000000, 7.958042 },
+ /* '-' */ { 186, 2, 194, 4, 0.750000, -8.750000, 9.538462 },
+ /* '.' */ { 198, 2, 201, 5, 2.500000, -3.000000, 7.958042 },
+ /* '/' */ { 206, 2, 214, 23, 0.000000, -21.000000, 7.958042 },
+ /* '0' */ { 218, 2, 231, 23, 1.000000, -20.750000, 15.930070 },
+ /* '1' */ { 236, 2, 243, 22, 3.000000, -20.750000, 15.930070 },
+ /* '2' */ { 2, 34, 15, 54, 0.750000, -20.750000, 15.930070 },
+ /* '3' */ { 20, 34, 33, 55, 1.000000, -20.750000, 15.930070 },
+ /* '4' */ { 38, 34, 52, 54, 0.250000, -20.750000, 15.930070 },
+ /* '5' */ { 58, 34, 72, 54, 1.000000, -20.250000, 15.930070 },
+ /* '6' */ { 76, 34, 89, 55, 1.000000, -20.750000, 15.930070 },
+ /* '7' */ { 94, 34, 107, 54, 1.250000, -20.250000, 15.930070 },
+ /* '8' */ { 112, 34, 125, 55, 1.000000, -20.750000, 15.930070 },
+ /* '9' */ { 130, 34, 143, 55, 1.000000, -20.750000, 15.930070 },
+ /* ':' */ { 148, 34, 151, 49, 2.500000, -15.000000, 7.958042 },
+ /* ';' */ { 156, 34, 159, 53, 2.250000, -15.000000, 7.958042 },
+ /* '<' */ { 164, 34, 177, 48, 1.500000, -17.250000, 16.727272 },
+ /* '=' */ { 182, 34, 195, 42, 1.500000, -14.500000, 16.727272 },
+ /* '>' */ { 200, 34, 213, 48, 1.500000, -17.250000, 16.727272 },
+ /* '?' */ { 218, 34, 231, 55, 1.250000, -21.000000, 15.930070 },
+ /* '@' */ { 2, 60, 28, 87, 1.500000, -21.000000, 29.076923 },
+ /* 'A' */ { 34, 60, 53, 80, -0.250000, -20.750000, 19.104895 },
+ /* 'B' */ { 58, 60, 73, 80, 2.000000, -20.750000, 19.104895 },
+ /* 'C' */ { 78, 60, 96, 81, 1.250000, -21.000000, 20.685314 },
+ /* 'D' */ { 102, 60, 119, 80, 2.000000, -20.750000, 20.685314 },
+ /* 'E' */ { 124, 60, 139, 80, 2.250000, -20.750000, 19.104895 },
+ /* 'F' */ { 144, 60, 158, 80, 2.250000, -20.750000, 17.496504 },
+ /* 'G' */ { 162, 60, 181, 81, 1.500000, -21.000000, 22.279720 },
+ /* 'H' */ { 186, 60, 202, 80, 2.250000, -20.750000, 20.685314 },
+ /* 'I' */ { 208, 60, 211, 80, 2.500000, -20.750000, 7.958042 },
+ /* 'J' */ { 216, 60, 227, 81, 0.750000, -20.750000, 14.321678 },
+ /* 'K' */ { 232, 60, 249, 80, 2.000000, -20.750000, 19.104895 },
+ /* 'L' */ { 2, 92, 15, 112, 2.000000, -20.750000, 15.930070 },
+ /* 'M' */ { 20, 92, 39, 112, 2.000000, -20.750000, 23.860140 },
+ /* 'N' */ { 44, 92, 60, 112, 2.000000, -20.750000, 20.685314 },
+ /* 'O' */ { 66, 92, 85, 113, 1.250000, -21.000000, 22.279720 },
+ /* 'P' */ { 90, 92, 106, 112, 2.000000, -20.750000, 19.104895 },
+ /* 'Q' */ { 110, 92, 130, 114, 1.000000, -21.000000, 22.279720 },
+ /* 'R' */ { 136, 92, 154, 112, 2.250000, -20.750000, 20.685314 },
+ /* 'S' */ { 160, 92, 176, 113, 1.250000, -21.000000, 19.104895 },
+ /* 'T' */ { 182, 92, 198, 112, 0.500000, -20.750000, 17.496504 },
+ /* 'U' */ { 204, 92, 220, 113, 2.250000, -20.750000, 20.685314 },
+ /* 'V' */ { 226, 92, 245, 112, 0.000000, -20.750000, 19.104895 },
+ /* 'W' */ { 2, 120, 28, 140, 0.250000, -20.750000, 27.034966 },
+ /* 'X' */ { 34, 120, 53, 140, 0.000000, -20.750000, 19.104895 },
+ /* 'Y' */ { 58, 120, 77, 140, 0.000000, -20.750000, 19.104895 },
+ /* 'Z' */ { 82, 120, 98, 140, 0.500000, -20.750000, 17.496504 },
+ /* '[' */ { 104, 120, 109, 146, 1.750000, -20.750000, 7.958042 },
+ /* '\' */ { 114, 120, 122, 141, 0.000000, -21.000000, 7.958042 },
+ /* ']' */ { 126, 120, 131, 146, 0.500000, -20.750000, 7.958042 },
+ /* '^' */ { 136, 120, 148, 131, 0.750000, -21.000000, 13.440559 },
+ /* '_' */ { 152, 120, 169, 122, -0.500000, 3.750000, 15.930070 },
+ /* '`' */ { 174, 120, 179, 124, 1.000000, -20.750000, 9.538462 },
+ /* 'a' */ { 184, 120, 197, 135, 1.000000, -15.250000, 15.930070 },
+ /* 'b' */ { 202, 120, 215, 141, 1.750000, -20.750000, 15.930070 },
+ /* 'c' */ { 220, 120, 233, 135, 1.000000, -15.250000, 14.321678 },
+ /* 'd' */ { 238, 120, 251, 141, 0.750000, -20.750000, 15.930070 },
+ /* 'e' */ { 2, 152, 15, 167, 1.000000, -15.250000, 15.930070 },
+ /* 'f' */ { 20, 152, 28, 173, 0.250000, -21.000000, 7.958042 },
+ /* 'g' */ { 34, 152, 47, 173, 0.750000, -15.250000, 15.930070 },
+ /* 'h' */ { 52, 152, 64, 172, 1.750000, -20.750000, 15.930070 },
+ /* 'i' */ { 70, 152, 72, 172, 1.750000, -20.750000, 6.363636 },
+ /* 'j' */ { 78, 152, 84, 179, -1.500000, -20.750000, 6.363636 },
+ /* 'k' */ { 88, 152, 100, 172, 1.750000, -20.750000, 14.321678 },
+ /* 'l' */ { 106, 152, 108, 172, 1.750000, -20.750000, 6.363636 },
+ /* 'm' */ { 114, 152, 134, 167, 1.750000, -15.250000, 23.860140 },
+ /* 'n' */ { 140, 152, 152, 167, 1.750000, -15.250000, 15.930070 },
+ /* 'o' */ { 158, 152, 172, 167, 0.750000, -15.250000, 15.930070 },
+ /* 'p' */ { 178, 152, 191, 173, 1.750000, -15.250000, 15.930070 },
+ /* 'q' */ { 196, 152, 209, 173, 1.000000, -15.250000, 15.930070 },
+ /* 'r' */ { 214, 152, 222, 167, 1.750000, -15.250000, 9.538462 },
+ /* 's' */ { 228, 152, 240, 167, 0.750000, -15.250000, 14.321678 },
+ /* 't' */ { 246, 152, 253, 172, 0.500000, -20.250000, 7.958042 },
+ /* 'u' */ { 2, 184, 14, 199, 1.750000, -15.000000, 15.930070 },
+ /* 'v' */ { 20, 184, 33, 199, 0.250000, -15.000000, 14.321678 },
+ /* 'w' */ { 38, 184, 58, 199, 0.000000, -15.000000, 20.685314 },
+ /* 'x' */ { 64, 184, 78, 199, 0.000000, -15.000000, 14.321678 },
+ /* 'y' */ { 84, 184, 98, 205, 0.250000, -15.000000, 14.321678 },
+ /* 'z' */ { 102, 184, 115, 199, 0.500000, -15.000000, 14.321678 },
+ /* '{' */ { 120, 184, 128, 211, 0.750000, -21.000000, 9.566434 },
+ /* '|' */ { 134, 184, 136, 211, 2.500000, -21.000000, 7.440559 },
+ /* '}' */ { 142, 184, 150, 211, 0.500000, -21.000000, 9.566434 },
+ /* '~' */ { 156, 184, 170, 188, 1.000000, -12.500000, 16.727272 },
+ /* '' */ { 176, 184, 190, 202, 3.500000, -18.000000, 21.482517 }
+};
+
View
BIN wolf3d/code/iphone/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
8 wolf3d/code/iphone/gles_glue.c
@@ -101,6 +101,14 @@ void pfglVertex2i( GLint x, GLint y ) {
immediate[ curr_vertex ] = vab;
curr_vertex++;
}
+void pfglVertex2f( GLfloat x, GLfloat y ) {
+ assert( curr_vertex < MAX_VERTS );
+ vab.xyz[ 0 ] = (float)x;
+ vab.xyz[ 1 ] = (float)y;
+ vab.xyz[ 2 ] = 0.0f;
+ immediate[ curr_vertex ] = vab;
+ curr_vertex++;
+}
void pfglColor4ub( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) {
vab.c[ 0 ] = r;
vab.c[ 1 ] = g;
View
334 wolf3d/code/iphone/hud.c
@@ -224,6 +224,7 @@ void HudEditFrame() {
// solid background color and some UI elements for context
R_Draw_Fill( 0, 0, 480, 320, gray );
+
iphoneDrawFace();
iphoneDrawNotifyText();
@@ -247,3 +248,336 @@ void HudEditFrame() {
}
}
+//gsh
+/*
+int boundsLeft = 86;//70;
+int boundsRight = 386;//480-72;
+int boundsAbove = 80-15;//97;
+int boundsUnder = 285-15;//320-15;
+*/
+//------------------
+// ConvertFromImageToScreen
+// This converts a point placed in the screen of the iphone image
+// to the screen coordinates of the actual iphone
+// gsh
+//-------------------
+void ConvertFromImageToScreen(int *x, int *y, rect_t boundsRect)
+{
+ int boundsLeft = boundsRect.x;
+ int boundsRight = boundsRect.x + boundsRect.width;
+ int boundsAbove = boundsRect.y;
+ int boundsUnder = boundsRect.y + boundsRect.height;
+
+ int valX = *x;//prevTouches[0][0];
+ int valY = *y;//prevTouches[0][1];
+
+ //int boundsLeft = 64;
+ //int boundsRight = 480-64;
+ int width = boundsRight - boundsLeft;
+
+ //int boundsAbove = 100;
+ //int boundsUnder = 320-10;
+ int height = boundsUnder - boundsAbove;
+
+ valX -= boundsLeft;
+ valX = 480*valX/width;
+
+ valY -= boundsAbove;
+ valY = 320*valY/height;
+
+ *x = valX;
+ *y = valY;
+}
+
+//------------------
+// ConvertFromScreenToImage
+// This converts a point placed on the screen of the iphone
+// to the coordinates of the screen of the iphone image
+// gsh
+//-------------------
+void ConvertFromScreenToImage(int *x, int *y, rect_t boundsRect)
+{
+ int boundsLeft = boundsRect.x;
+ int boundsRight = boundsRect.x + boundsRect.width;
+ int boundsAbove = boundsRect.y;
+ int boundsUnder = boundsRect.y + boundsRect.height;
+
+ int valX = *x;//prevTouches[0][0];
+ int valY = *y;//prevTouches[0][1];
+
+ //int boundsLeft = 64;
+ //int boundsRight = 480-64;
+ int width = boundsRight - boundsLeft;
+
+ //int boundsAbove = 100;
+ //int boundsUnder = 320-10;
+ int height = boundsUnder - boundsAbove;
+
+ valX = width*valX/480;
+ valX += boundsLeft;
+
+ valY = height*valY/320;
+ valY += boundsAbove;
+
+ *x = valX;
+ *y = valY;
+}
+
+//------------------
+// ScaleFromScreenToImage
+// This converts to the correct scale to draw with
+// gsh
+//-------------------
+void ScaleFromScreenToImage(int *width, int *height, rect_t boundsRect)
+{
+ int boundsLeft = boundsRect.x;
+ int boundsRight = boundsRect.x + boundsRect.width;
+ int boundsAbove = boundsRect.y;
+ int boundsUnder = boundsRect.y + boundsRect.height;
+
+ int w = *width;
+ int h = *height;
+
+ //int boundsLeft = 64;
+ //int boundsRight = 480-64;
+ int iW = boundsRight - boundsLeft;
+
+ //int boundsAbove = 100;
+ //int boundsUnder = 320-10;
+ int iH = boundsUnder - boundsAbove;
+
+ w = w*iW/480;
+ h = h*iH/320;
+
+ *width = w;
+ *height = h;
+}
+
+
+/*
+ ==================
+ iphoneHudEditFrame
+ Same as HudEditFrame only different
+ gsh
+ ==================
+ */
+void iphoneHudEditFrame() {
+ int w;
+ int x;
+ colour3_t gray = { 32, 32, 32 };
+
+ int adjustY = 10;
+
+ rect_t boundsRect = RectMake(86, 80-adjustY, 300, 205);
+
+
+
+ //iphoneSetNotifyText( "Drag the controls" );
+
+ if ( numTouches == 0 && numPrevTouches == 1 && dragHud ) {
+ // if it was released near the center, make it inactive
+ int x = prevTouches[0][0];
+ int y = prevTouches[0][1];
+
+ //convert x, y coordinates from iphone_image to screen coordinates
+ ConvertFromImageToScreen( &x, &y, boundsRect);
+ //ConvertFromScreenToImage( &x, &y);
+
+ if ( x > 120 && x < 360 && y > 80 && y < 240 ) {
+ dragHud->hudFlags |= HF_DISABLED;
+ } else {
+ // magnet pull a matchable axis if it is close enough
+ if ( dragHud == &huds.forwardStick ) {
+ SnapSticks( &huds.sideStick, dragHud );
+ SnapSticks( &huds.turnStick, dragHud );
+ }
+ if ( dragHud == &huds.sideStick ) {
+ SnapSticks( &huds.forwardStick, dragHud );
+ }
+ if ( dragHud == &huds.turnStick ) {
+ SnapSticks( &huds.forwardStick, dragHud );
+ }
+ }
+ Sound_StartLocalSound( "iphone/baction_01.wav" );
+ dragHud = NULL;
+ }
+
+ if ( numTouches == 1 && numPrevTouches == 0 ) {
+ // identify the hud being touched for drag
+ int x = touches[0][0];
+ int y = touches[0][1];
+
+ //convert x, y coordinates from iphone_image to screen coordinates
+ ConvertFromImageToScreen( &x, &y, boundsRect);
+// ConvertFromScreenToImage( &x, &y);
+
+ dragHud = NULL;
+ for ( hudPic_t *hud = (hudPic_t *)&huds ; hud != (hudPic_t *)(&huds+1) ; hud++ ) {
+ if ( x >= hud->x && x - hud->x < hud->width &&
+ y >= hud->y && y - hud->y < hud->height ) {
+ dragHud = hud;
+ //int tempDragX = dragHud->x;
+ //int tempDragY = dragHud->y;
+ //ConvertFromImageToScreen(&, <#int * y#>)
+ dragX = dragHud->x - x;
+ dragY = dragHud->y - y;
+ Sound_StartLocalSound( "iphone/bdown_01.wav" );
+ dragHud->hudFlags &= ~HF_DISABLED;
+ break;
+ }
+ }
+ }
+
+ if ( numTouches == 1 && numPrevTouches == 1 && dragHud ) {
+ // adjust the position of the dragHud
+ int x = touches[0][0];
+ int y = touches[0][1];
+ ConvertFromImageToScreen(&x, &y, boundsRect);
+
+ dragHud->x = x + dragX;
+ dragHud->y = y + dragY;
+ if ( dragHud->x < 0 ) {
+ dragHud->x = 0;
+ }
+ if ( dragHud->x > 480 - dragHud->width ) {
+ dragHud->x = 480 - dragHud->width;
+ }
+ if ( dragHud->y < 0 ) {
+ dragHud->y = 0;
+ }
+ if ( dragHud->y > 320 - dragHud->height ) {
+ dragHud->y = 320 - dragHud->height;
+ }
+ }
+
+ // layout the disabled items in the center
+ w = 0;
+ for ( hudPic_t *hud = (hudPic_t *)&huds ; hud != (hudPic_t *)(&huds+1) ; hud++ ) {
+ if ( hud->hudFlags & HF_DISABLED ) {
+ w += hud->width;
+ }
+ }
+ x = 240 - w / 2;
+
+ for ( hudPic_t *hud = (hudPic_t *)&huds ; hud != (hudPic_t *)(&huds+1) ; hud++ ) {
+ if ( hud->hudFlags & HF_DISABLED ) {
+ hud->x = x;
+ hud->y = 160-hud->height/2;
+ x += hud->width;
+ }
+ }
+
+ // decide where the menu button, map button, and ammo will draw
+
+ // solid background color and some UI elements for context
+ R_Draw_Fill( 0, 0, 480, 320, gray );
+
+ iphoneDrawPic(0, 0, 480, 320, "iphone/submenus_background_image.tga");
+ //iphoneDrawPic(240-108, 0, 217, 50, "iphone/header_advanced.tga");
+ iphoneDrawPic(240-108*9/10, 0, 217*9/10, 50*9/10, "iphone/header_advanced.tga");
+
+ //gsh
+ iphoneDrawPic(10, 60-adjustY, 462, 250, "iphone/iphone_image.tga");
+// iphoneDrawPic(0, 320-240, 480, 240, "iphone/iphone_image.tga");
+
+
+// iphoneDrawFace();
+// iphoneDrawNotifyText();
+
+
+ // draw the active items at their current locations
+ for ( hudPic_t *hud = (hudPic_t *)&huds ; hud != (hudPic_t *)(&huds+1) ; hud++ ) { //nice foreach loop!
+ if ( hud->hudFlags & HF_DISABLED ) {
+ pfglColor3f( 0.5, 0.5, 0.5 );
+ }
+ if ( hud == &huds.ammo ) {
+ int x = huds.ammo.x + huds.ammo.width / 2;
+ int y = huds.ammo.y;
+ int w = 48;
+ int h = 48;
+
+ ConvertFromScreenToImage(&x, &y, boundsRect);
+ ScaleFromScreenToImage(&w, &h, boundsRect);
+
+ iphoneDrawNumber( x, y, 99, w, h );
+ } else {
+ int x = hud->x;
+ int y = hud->y;
+ int w = hud->width;
+ int h = hud->height;
+
+ ConvertFromScreenToImage(&x, &y, boundsRect);
+ ScaleFromScreenToImage(&w, &h, boundsRect);
+
+ iphoneDrawPicNum( x, y, w, h, hud->glTexNum );
+ }
+ pfglColor3f( 1, 1, 1 );
+ }
+
+
+
+
+
+ // draw the back button
+ if ( iphoneDrawPicWithTouch( 0, 0, 64, 36, "iphone/button_back.tga" ) ) {
+ menuState = IPM_CONTROLS;
+ iphoneSetNotifyText( "" );
+ }
+
+ //x = 64;
+ //if (revLand->value)
+ x = 480-64;
+ // draw the menu button
+ if ( iphoneDrawPicWithTouch( x, 0, 64, 36, "iphone/menu.tga" ) ) {
+ //if ( iphoneDrawPicWithTouch( 64, 0, 64, 36, "iphone/button_menu_yellow.tga" ) ) {
+ menuState = IPM_MAIN;
+ iphoneSetNotifyText( "" );
+ }
+
+ /*
+ //------------------------------------
+ //Draw volume up/down settings... gsh
+ int width = 64*9/10;
+ int height = 36;//48*9/10;
+
+ int y = 0;
+ y = 0;
+ x = 480-width;
+ if (revLand->value){
+ y = 320-height;
+ x = 0;
+ }
+
+ //gsh
+ if ((int)volumeFireUpSetting->value) {
+ if (iphoneDrawPicWithTouch( x, y, width, height, "iphone/button_pistol.tga" ))
+ Cvar_Set("volumeFireUpSetting", "0");
+ }
+ else {
+ if (iphoneDrawPicWithTouch( x, y, width, height, "iphone/button_knife.tga" ))
+ Cvar_Set("volumeFireUpSetting", "1");
+ }
+
+
+ x = 480-width-width-5;
+ if (revLand->value)
+ x = width+5;
+
+ if ((int)volumeFireDownSetting->value) {
+ if (iphoneDrawPicWithTouch( x, y, width, height, "iphone/button_pistol.tga" ))
+ Cvar_Set("volumeFireDownSetting", "0");
+ }
+ else {
+ if (iphoneDrawPicWithTouch( x, y, width, height, "iphone/button_knife.tga" ))
+ Cvar_Set("volumeFireDownSetting", "1");
+ }
+ //-----------------------------------
+ */
+ //draw the instructions
+ //if (revLand->value)
+ // iphoneDrawText(x+width+20, 300, 16, 16, "Drag the controls to customize");
+ //else
+// iphoneCenterText(240, 300, "Drag each element of the controls to customize");
+ iphoneCenterArialText(245, 315, 0.8f, "Drag each element of the controls to customize");
+}
+
View
39 wolf3d/code/iphone/iphone_alerts.h
@@ -0,0 +1,39 @@
+/*
+ * iphone_alerts.h
+ * wolf3d
+ *
+ * Created by Greg Hodges on 7/14/09.
+ * Copyright 2009 id software. All rights reserved.
+ *
+ * C wrappers for the UIAlertView.
+ *
+ */
+/*
+
+ Copyright (C) 2009 Id Software, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ */
+
+
+#ifndef __IPHONE_ALERTS__
+#define __IPHONE_ALERTS__
+
+void iphoneMessageBox(char *title, char *message);
+void iphoneKillMessageBox();
+void iphoneYesNoBox(char *title, char *message);
+
+#endif
View
110 wolf3d/code/iphone/iphone_alerts.m
@@ -0,0 +1,110 @@
+/*
+ * iphone_alerts.c
+ * wolf3d
+ *
+ * Created by Greg Hodges on 7/14/09.
+ * Copyright 2009 id software. All rights reserved.
+ *
+ */
+/*
+
+ Copyright (C) 2009 Id Software, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ */
+
+
+#import "iphone_alerts.h"
+#import "wolf3dAppDelegate.h"
+
+
+/*
+ ==================================
+ MessageBox
+ Provides a basic pop-up message box
+ ===================================
+ */
+UIAlertView *alert;
+
+void InitAlert()
+{
+ alert = [[UIAlertView alloc] initWithTitle:@"Title"
+ message:@"Message"
+ delegate:nil
+ cancelButtonTitle:@"OK"
+ otherButtonTitles: nil];
+}
+
+
+void iphoneMessageBox(char *title, char *message)
+{
+ //check if alert exists and initialize if it isn't
+ if (!alert)
+ {
+ InitAlert();
+ }
+
+ NSString *nsTitle = [[NSString alloc] initWithCString:title];
+ NSString *nsMessage = [[NSString alloc] initWithCString:message];
+
+ alert.title = nsTitle;
+ alert.message = nsMessage;
+
+ [alert show];
+}
+
+void iphoneKillMessageBox()
+{
+ [alert dismissWithClickedButtonIndex:alert.cancelButtonIndex animated:NO];
+}
+
+#if 1
+/*
+ ==================================
+ YesNoBox
+ Provides a yes/no box. The
+ appdelegate responds to this
+ through the UIAlerViewDelegate
+ ClickedButton call.
+ ===================================
+ */
+UIAlertView *alertYesNo;
+
+void InitAlertYesNo()
+{
+ alertYesNo = [[UIAlertView alloc] initWithTitle:@"Title"
+ message:@"Message"
+ delegate:(wolf3dAppDelegate *)[UIApplication sharedApplication].delegate//nil
+ cancelButtonTitle:@"No"
+ otherButtonTitles:@"Yes", nil];
+}
+
+void iphoneYesNoBox(char *title, char *message)
+{
+ if (!alertYesNo)
+ {
+ InitAlertYesNo();
+ }
+
+ NSString *nsTitle = [[NSString alloc] initWithCString:title];
+ NSString *nsMessage = [[NSString alloc] initWithCString:message];
+
+ alertYesNo.title = nsTitle;
+ alertYesNo.message = nsMessage;
+
+ [alertYesNo show];
+}
+#endif
View
359 wolf3d/code/iphone/iphone_downloadSOD.m
@@ -0,0 +1,359 @@
+//
+// iphone_downloadSOD.m
+// wolf3d
+//
+// Created by Greg Hodges on 6/8/09.
+// Copyright 2009 id software. All rights reserved.
+//
+/*
+
+ Copyright (C) 2009 Id Software, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ */
+
+
+
+#import "../wolfiphone.h"
+#import "wolf3dAppDelegate.h"
+#import "iphone_alerts.h"
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <unistd.h>
+
+#import <SystemConfiguration/SCNetworkReachability.h> //this is for testing network availability
+
+//Note: in order to link the zlib library into the build from usr/lib/libz.ylib
+// the flag -lz was added to the OTHER_LDFLAGS under the build options.
+// To get there: right click on the wolf3d project. choose get info.
+// Click on build and scroll to "Other Link Flags" under "Linking"
+
+
+extern void Com_Printf(const char* fmt, ... );
+extern void my_snprintf( char *dest, size_t size, const char *format, ... );
+
+#ifdef SPEARSTOREKIT
+extern void PurchaseSOD();
+extern bool isStorekitAvailable;
+#endif
+extern char iphoneDocDirectory[1024];
+extern menuState_t menuState;
+
+
+int inf(FILE *source, FILE *dest);
+void zerr(int ret);
+
+
+//this is used for determining if we have the correctly sized data
+const unsigned int DownloadFileSize = 45583; //size of maps
+
+//-----------------------------
+// TestURLConnection
+// Test for internet access
+//-----------------------------
+int TestURLConnection()
+{
+ Com_Printf("Testing URL Connection\n");
+
+ //We wish to be able to test connectability to both apple and id
+ //because we need to communicate to both in order to complete the Spear of Destiny Transaction
+
+ char *hostid = "www.idsoftware.com";
+ char *hostApple = "www.apple.com";
+ SCNetworkReachabilityFlags flags[2];
+ SCNetworkReachabilityRef reachability;
+ BOOL gotFlags[2];
+
+ reachability = SCNetworkReachabilityCreateWithName(NULL, hostid);
+ gotFlags[0] = SCNetworkReachabilityGetFlags(reachability, &flags[0]);
+ CFRelease(reachability);
+
+ reachability = SCNetworkReachabilityCreateWithName(NULL, hostApple);
+ gotFlags[1] = SCNetworkReachabilityGetFlags(reachability, &flags[1]);
+ CFRelease(reachability);
+
+
+ if (gotFlags[0] && gotFlags[1])
+ {
+ // kSCNetworkReachabilityFlagsReachable indicates that the specified nodename or address can
+ // be reached using the current network configuration.
+ if ((flags[0] & kSCNetworkReachabilityFlagsReachable) && (flags[1] & kSCNetworkReachabilityFlagsReachable))
+ {
+ Com_Printf("Both Hosts were reached\n");
+ return 1;
+ }
+ }
+
+ //TODO: alert user they cannot download SOD
+ iphoneMessageBox("Host Server Unavailable", "Check your internet connection and try again later.");
+
+ return 0;
+}
+
+//-----------------------------
+// OpenURLConnection
+// This connects to a server and downloads the file located there
+//-----------------------------
+void OpenURLConnection( const char *url )
+{
+ Com_Printf( "ConnectURL char *: %s\n", url );
+
+ //convert url to nsstring
+ NSString *nssURL = [NSString stringWithUTF8String: url];
+
+ // create the request
+ NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:nssURL]
+ cachePolicy:NSURLRequestUseProtocolCachePolicy
+ timeoutInterval:60.0];
+
+ // create the connection with the request
+ // and start loading the data
+ NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest
+ delegate:(wolf3dAppDelegate *)[UIApplication sharedApplication].delegate];
+
+ if (!theConnection)
+ {
+ // inform the user that the download could not be made
+ Com_Printf("Connection failed... no download plausible\n");
+
+ //inform user
+ iphoneMessageBox("Connection Failed", "The install was unable to download. Check your internet connection and try again later.");
+
+ //return to main menu
+ menuState = IPM_MAIN;
+ }
+}
+
+//============================
+// DisplayWrongVersionedOS
+// Display to the user they have the wrong OS version and cannot use storekit
+//=============================
+void DisplayWrongVersionedOS()
+{
+ iphoneMessageBox("Feature Unavailable", "Your device is not updated. This feature requires OS 3.0 or higher.");
+}
+
+//============================
+// BeginStoreKit
+// This starts the purchasing process of the storekit framework
+//=============================
+#ifdef SPEARSTOREKIT
+void BeginStoreKit()
+{
+ //only start the storekit API if it exists
+ if (isStorekitAvailable)
+ {
+ if (TestURLConnection()) //check URL connection again
+ {
+ menuState = IPM_STOREKIT;
+ Com_Printf("BeginStoreKit() called\n");
+ PurchaseSOD();
+ }
+ }
+ else
+ DisplayWrongVersionedOS();
+}
+#endif
+
+
+//============================
+// DownloadSOD
+// starts the download process of SOD
+// this is called after purchase of the SOD levels is confirmed
+//=============================
+void DownloadSOD()
+{
+ menuState = IPM_DOWNLOADPROGRESS; //change the menu to the download screen
+
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+
+ //check if download.tgz already exists and delete if it does
+ //create/open file for saving
+ NSString *fileatpath = [documentsDirectory stringByAppendingString:@"/downloadedfile.tgz"];
+ NSFileHandle *file = [NSFileHandle fileHandleForWritingAtPath:fileatpath];
+
+ if (file) //file exists... delete it, we do not care to append to a pre-exisiting file
+ {
+ if( remove( [fileatpath UTF8String] ) != 0 )
+ Com_Printf("Error deleting buffer\n");
+ else
+ Com_Printf("Deleted buffer\n");
+ }
+
+ //TODO: change this url to what will eventually be the permanent location
+ OpenURLConnection("http://gregory.hodges.googlepages.com/spearMaps.tgz");
+
+ //after this the control automatically goes back to the appDelegate where it receives the packets of downloaded information
+}
+
+unsigned int dataAmount = 0;
+unsigned int dataTotalAmount = 0;
+extern unsigned int totalDownloaded;
+//int hasBeenMessaged = 0;
+
+//============================
+// AppendData
+// adds a packet of data directly to file
+//============================
+void AppendDataToFile(NSData* data)
+{
+ NSUInteger length = [data length];
+
+ dataAmount = (unsigned int)length;
+ dataTotalAmount += dataAmount;
+ totalDownloaded = dataTotalAmount; //update the download screen with the total downloaded
+
+ //get documents directory
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+
+ //create/open file for saving
+ NSString *fileatpath = [documentsDirectory stringByAppendingString:@"/downloadedfile.tgz"];
+ NSFileHandle *file = [NSFileHandle fileHandleForWritingAtPath:fileatpath];
+
+ if (!file) //file does not exist... create and append file
+ {
+ NSLog(@"open file failed\ncreating file with path: %@\n", fileatpath);
+ [[NSFileManager defaultManager] createFileAtPath:fileatpath
+ contents:data
+ attributes:nil];
+ return;
+ }
+
+ //seek to end of file and append data
+ [file seekToEndOfFile];
+ [file writeData:data];
+ [file closeFile];
+}
+
+
+
+//===========================
+// DecompressData
+// Calls into untgz.c to start data inflation
+// this function should not be getting called
+//============================
+void DecompressData()
+{
+ Com_Printf("Starting DecompressData");
+
+ char path[1024];
+ my_snprintf(path, sizeof(path), "%s/downloadedfile.tgz", iphoneDocDirectory);
+}
+
+//================================
+// IsSpearPurchased
+// returns 1 if Spear was purchased
+//================================
+int IsSpearPurchased()
+{
+ //get documents directory
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+
+ //create/open file for saving
+ NSString *fileatpath = [documentsDirectory stringByAppendingString:@"/SpearPurchased.log"];
+ NSFileHandle *file = [NSFileHandle fileHandleForWritingAtPath:fileatpath];
+
+ if (file)
+ return 1;
+
+ return 0;
+}
+
+//================================
+// IsSpearInstalled
+// returns 1 if Spear is installed
+//================================
+int IsSpearInstalled()
+{
+ //get documents directory
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+
+ //create/open file for saving
+ NSString *fileatpath = [documentsDirectory stringByAppendingString:@"/SpearInstalled.log"];
+ NSFileHandle *file = [NSFileHandle fileHandleForWritingAtPath:fileatpath];
+
+ if (file)
+ return 1;
+
+ return 0;
+}
+
+//================================
+// WriteDownloadLog
+// records that we've finished installing SOD
+// but haven't completed the purchase
+//================================
+void WriteInstallLog()
+{
+ char *buffer = "useless data";
+ NSData *data = [[NSData alloc] initWithBytes: (void *)buffer length: strlen(buffer)];
+
+ //get documents directory
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+
+ //create/open file for saving
+ NSString *fileatpath = [documentsDirectory stringByAppendingString:@"/SpearInstalled.log"];
+ NSFileHandle *file = [NSFileHandle fileHandleForWritingAtPath:fileatpath];
+
+ if (!file) //file does not exist... create and append file
+ {
+ NSLog(@"open file failed\ncreating file with path: %@\n", fileatpath);
+ [[NSFileManager defaultManager] createFileAtPath:fileatpath
+ contents:data
+ attributes:nil];
+ return;
+ }
+
+}
+
+//================================
+// FinalizeDownload
+// Installs the needed files for SOD and
+// removes any unwanted data
+//================================
+extern void iphoneWriteConfig();
+void FinalizeDownload()
+{
+ // get the documents directory
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+ NSString *fileName = [documentsDirectory stringByAppendingString:@"/downloadedfile.tgz"];
+
+ //inflate the data and store in its appropriate directory
+ DecompressData();
+
+ //TODO: After inflating data... we should delete the downloadedfile.tgz
+ if( remove( [fileName UTF8String] ) != 0 )
+ Com_Printf( "Error deleting downloadedfile.tgz\n" );
+ else
+ Com_Printf( "downloadedfile.tgz successfully deleted\n" );
+
+
+ iphoneKillMessageBox();
+
+ //write a file that lets wolf3d know that SOD is installed
+ WriteInstallLog();
+
+#ifdef SPEARSTOREKIT
+ //start the storekit
+ BeginStoreKit();
+#endif
+}
View
223 wolf3d/code/iphone/iphone_downloadUserMap.m
@@ -0,0 +1,223 @@
+/*
+ * iphone_downloadUserMap.c
+ * wolf3d
+ *
+ * Created by Greg Hodges on 7/20/09.
+ * Copyright 2009 id software. All rights reserved.
+ *
+ */
+/*
+
+ Copyright (C) 2009 Id Software, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ */
+
+
+#import "../wolfiphone.h"
+#import "wolf3dAppDelegate.h"
+#import "iphone_alerts.h"
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <unistd.h>
+
+extern void Com_Printf(const char* fmt, ... );
+extern void my_snprintf( char *dest, size_t size, const char *format, ... );
+
+extern char iphoneDocDirectory[1024];
+extern menuState_t menuState;
+
+
+int inf(FILE *source, FILE *dest);
+void zerr(int ret);
+
+
+char mapName[1024];// = "/";
+
+//this is used for determining if we have the correctly sized data
+const unsigned int DownloadUserFileSize = 4096; //max size of maps?
+
+
+//-----------------------------
+// DownloadURLConnection
+// This connects to a server and downloads the file located there
+//-----------------------------
+void DownloadURLConnection( char *url )
+{
+ Com_Printf( "ConnectURL char *: %s\n", url );
+
+ int length = strlen(url);
+ if (length <= 4)
+ {
+ iphoneMessageBox("error", "url is not a valid map name. Maps must end in \".map\"");
+ return;
+ }
+
+ length = strlen(url);
+ //acquire file name of map
+ int pos = length;
+ while (pos > 0)
+ {
+ --pos;
+ if (url[pos] == '/')
+ break;
+ }
+ ++pos;
+ strcpy(mapName, url + pos);
+
+ //-------------------------------------------------
+ //check if this file already exists... if so, delete the old one
+ //get documents directory
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+
+ //get maps directory
+ NSString *mapsDirectory = [documentsDirectory stringByAppendingString:@"/usermaps/"];
+
+ DIR *dp = opendir ([mapsDirectory UTF8String]);
+ if (dp != NULL)
+ {
+ struct dirent *ep;
+ while (ep = readdir (dp))
+ {
+ //if you find a .DS_Store file... ignore it!
+ if ( strcmp(ep->d_name, ".DS_Store") == 0 )
+ continue;
+ if ( strcmp(ep->d_name, ".") == 0 )
+ continue;
+ if ( strcmp(ep->d_name, "..") == 0 )
+ continue;
+
+ if (strcmp(ep->d_name, mapName) == 0)
+ {
+ printf("found a file with name: %s\n", mapName);
+ printf("overwiting file\n");
+ //TODO: delete this file
+ char buffer[2048];
+ sprintf(buffer, "%s%s", [mapsDirectory UTF8String], mapName);
+ printf("removing at: %s\n", buffer);
+ remove(buffer);
+ }
+ }
+ }
+ //-------------------------------------------------
+
+
+ //convert url to nsstring
+ NSString *nssURL = [NSString stringWithUTF8String: url];
+
+ // create the request
+ NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:nssURL]
+ cachePolicy:NSURLRequestUseProtocolCachePolicy
+ timeoutInterval:60.0];
+
+ // create the connection with the request
+ // and start loading the data
+ NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest
+ delegate:(wolf3dAppDelegate *)[UIApplication sharedApplication].delegate];
+
+ if (!theConnection)
+ {
+ // inform the user that the download could not be made
+ Com_Printf("Connection failed... no download plausible\n");
+
+ //inform user
+ iphoneMessageBox("Connection Failed", "Can not download. Check your internet connection, file url and try again later.");
+
+ //return to main menu
+ menuState = IPM_MAIN;
+ }
+
+ menuState = IPM_DOWNLOADPROGRESS;
+}
+
+unsigned int userDataAmount = 0;
+unsigned int userDataTotalAmount = 0;
+extern unsigned int totalDownloaded;
+
+//============================
+// AppendData
+// adds a packet of data directly to file
+//============================
+void AppendUserDataToFile(NSData* data)
+{
+ NSUInteger length = [data length];
+
+ userDataAmount = (unsigned int)length;
+ userDataTotalAmount += userDataAmount;
+ totalDownloaded = userDataTotalAmount; //update the download screen with the total downloaded
+
+ //get documents directory
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+
+ //get maps directory