mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Get map loading sort-of working.
Segfaults, but the Map class can now be instantiated.
This commit is contained in:
parent
4fdc34ea86
commit
0e4259361c
11 changed files with 67 additions and 11 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
@interface DictList:NSMutableArray
|
||||
{
|
||||
NSMutableArray *array;
|
||||
}
|
||||
|
||||
-initListFromFile:(FILE *) fp;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -15,6 +15,7 @@ typedef struct epair_s {
|
|||
|
||||
@interface Entity:NSMutableArray
|
||||
{
|
||||
NSMutableArray *array;
|
||||
epair_t *epairs;
|
||||
BOOL modifiable;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -33,6 +33,7 @@ typedef enum { esize_model, esize_fixed } esize_t;
|
|||
|
||||
@interface EntityClassList:NSMutableArray
|
||||
{
|
||||
NSMutableArray *array;
|
||||
id nullclass;
|
||||
char *source_path;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
35
tools/Forge/Bundles/MapEdit/THING+NSArray.m
Normal file
35
tools/Forge/Bundles/MapEdit/THING+NSArray.m
Normal 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
|
Loading…
Reference in a new issue