Get map loading sort-of working.

Segfaults, but the Map class can now be instantiated.
This commit is contained in:
Bill Currie 2010-09-12 16:25:25 +09:00
parent 68a55eaf8d
commit eba4402d8e
11 changed files with 67 additions and 11 deletions

View file

@ -5,6 +5,7 @@
@interface DictList:NSMutableArray
{
NSMutableArray *array;
}
-initListFromFile:(FILE *) fp;

View file

@ -2,6 +2,9 @@
#include "DictList.h"
#include "Dict.h"
#define THING DictList
#include "THING+NSArray.m"
@implementation DictList
//
// Read in variable # of objects from FILE *
@ -10,7 +13,8 @@
{
id d;
[super init];
self = [super init];
array = [[NSMutableArray alloc] init];
do {
d =[(Dict *)[Dict alloc] initFromFile:fp];
if (d != NULL)

View file

@ -15,6 +15,7 @@ typedef struct epair_s {
@interface Entity:NSMutableArray
{
NSMutableArray *array;
epair_t *epairs;
BOOL modifiable;
}

View file

@ -10,6 +10,9 @@
#include "Map.h"
#include "CameraView.h"
#define THING Entity
#include "THING+NSArray.m"
@implementation Entity
vec3_t bad_mins = { -8, -8, -8 };
@ -56,7 +59,8 @@ vec3_t bad_maxs = { 8, 8, 8 };
vec3_t min, max;
float *v;
[super init];
self = [super init];
array = [[NSMutableArray alloc] init];
modifiable = YES;
@ -294,7 +298,7 @@ int nument;
int i, c;
float *color;
[self init];
self = [self init];
if (!Script_GetToken (script, true)) {
[self dealloc];

View file

@ -33,6 +33,7 @@ typedef enum { esize_model, esize_fixed } esize_t;
@interface EntityClassList:NSMutableArray
{
NSMutableArray *array;
id nullclass;
char *source_path;
}

View file

@ -146,6 +146,9 @@ text source:(const char *) filename
@end
//===========================================================================
#define THING EntityClassList
#include "THING+NSArray.m"
@implementation EntityClassList
/*
=================
@ -241,7 +244,8 @@ id entity_classes_i;
-initForSourceDirectory:(char *) path
{
[super init];
self = [super init];
array = [[NSMutableArray alloc] init];
source_path = path;
[self scanDirectory];

View file

@ -37,7 +37,9 @@ QuakeEd_HEADERS= \
CameraView.h Clipper.h Dict.h DictList.h Entity.h EntityClass.h \
InspectorControl.h KeypairView.h Map.h PopScrollView.h Preferences.h \
Project.h QuakeEd.h SetBrush.h Storage.h TexturePalette.h TextureView.h \
Things.h XYView.h ZScrollView.h ZView.h render.h
Things.h XYView.h ZScrollView.h ZView.h render.h \
\
THING+NSArray.m
#
# Class files

View file

@ -11,6 +11,7 @@ extern id map_i;
@interface Map:NSMutableArray
{
NSMutableArray *array;
id currentEntity;
id oldselection; // temp when loading a new map
float minz, maxz;

View file

@ -17,6 +17,8 @@
#include "InspectorControl.h"
#include "Project.h"
#define THING Map
#include "THING+NSArray.m"
id map_i;
@ -28,8 +30,10 @@ FILE METHODS
===============================================================================
*/
- init {
[super init];
- init
{
self = [super init];
array = [[NSMutableArray alloc] init];
map_i = self;
minz = 0;
maxz = 80;
@ -54,7 +58,6 @@ FILE METHODS
[o moveToEntity];
else {
[w removeObjectAtIndex:0];
[o release];
}
}
@ -63,7 +66,6 @@ FILE METHODS
o =[self objectAtIndex:0];
[self removeObjectAtIndex:0];
[o removeAllObjects];
[o release];
}
return self;
@ -1084,7 +1086,6 @@ subtractSelection
if (![currentEntity count]) {
o = currentEntity;
[self removeObject:o];
[o release];
}
Sys_Printf ("subtracted selection\n");

View file

@ -113,7 +113,7 @@ AutoSave
Every five minutes, save a modified map
===============
*/
- (void) AutoSave {
- (void) AutoSave {
// automatic backup
if (autodirty) {
autodirty = NO;
@ -348,6 +348,8 @@ App delegate methods
userInfo: nil repeats:YES];
path =[NSBezierPath new];
[[Map alloc] init];
}
-(void)applicationDidFinishLaunching:(NSNotification *) notification

View file

@ -0,0 +1,35 @@
@implementation THING (NSArray)
- (NSUInteger) count
{
return [array count];
}
- (id) objectAtIndex: (NSUInteger)index
{
if (index >= [self count])
return 0;
return [array objectAtIndex: index];
}
- (void) addObject: (id)anObject
{
[array addObject: anObject];
}
- (void) insertObject: (id)anObject atIndex: (NSUInteger)index
{
[array insertObject: anObject atIndex: index];
}
- (void) removeObjectAtIndex: (NSUInteger)index
{
[array removeObjectAtIndex: index];
}
- (void) replaceObjectAtIndex: (NSUInteger)index withObject: (id)anObject
{
[array replaceObjectAtIndex: index withObject: anObject];
}
@end