mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 23:11:38 +00:00
Pass .m files through indent.
The result isn't perfect, but it cleans up the whitespace and makes the code more consistent with the rest of the project.
This commit is contained in:
parent
d3a12ee727
commit
d23300d58b
25 changed files with 5481 additions and 5886 deletions
File diff suppressed because it is too large
Load diff
|
@ -10,79 +10,73 @@
|
||||||
#include "CameraView.h"
|
#include "CameraView.h"
|
||||||
#include "QuakeEd.h"
|
#include "QuakeEd.h"
|
||||||
|
|
||||||
id clipper_i;
|
id clipper_i;
|
||||||
|
|
||||||
@implementation Clipper
|
@implementation Clipper
|
||||||
|
|
||||||
- init
|
-init
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
clipper_i = self;
|
clipper_i = self;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)hide
|
-(BOOL) hide
|
||||||
{
|
{
|
||||||
int oldnum;
|
int oldnum;
|
||||||
|
|
||||||
oldnum = num;
|
oldnum = num;
|
||||||
num = 0;
|
num = 0;
|
||||||
return (oldnum > 0);
|
return (oldnum > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
- flipNormal
|
-flipNormal
|
||||||
{
|
{
|
||||||
vec3_t temp;
|
vec3_t temp;
|
||||||
|
|
||||||
if (num == 2)
|
if (num == 2) {
|
||||||
{
|
|
||||||
VectorCopy (pos[0], temp);
|
VectorCopy (pos[0], temp);
|
||||||
VectorCopy (pos[1], pos[0]);
|
VectorCopy (pos[1], pos[0]);
|
||||||
VectorCopy (temp, pos[1]);
|
VectorCopy (temp, pos[1]);
|
||||||
}
|
} else if (num == 3) {
|
||||||
else if (num == 3)
|
|
||||||
{
|
|
||||||
VectorCopy (pos[0], temp);
|
VectorCopy (pos[0], temp);
|
||||||
VectorCopy (pos[2], pos[0]);
|
VectorCopy (pos[2], pos[0]);
|
||||||
VectorCopy (temp, pos[2]);
|
VectorCopy (temp, pos[2]);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Sys_Printf ("no clipplane");
|
Sys_Printf ("no clipplane");
|
||||||
NSBeep ();
|
NSBeep ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)getFace: (face_t *)f
|
-(BOOL) getFace:(face_t *) f
|
||||||
{
|
{
|
||||||
vec3_t v1, v2, norm;
|
vec3_t v1, v2, norm;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
VectorCopy (vec3_origin, plane.normal);
|
VectorCopy (vec3_origin, plane.normal);
|
||||||
plane.dist = 0;
|
plane.dist = 0;
|
||||||
if (num < 2)
|
if (num < 2)
|
||||||
return NO;
|
return NO;
|
||||||
if (num == 2)
|
if (num == 2) {
|
||||||
{
|
|
||||||
VectorCopy (pos[0], pos[2]);
|
VectorCopy (pos[0], pos[2]);
|
||||||
pos[2][2] += 16;
|
pos[2][2] += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i = 0; i < 3; i++)
|
||||||
VectorCopy (pos[i], f->planepts[i]);
|
VectorCopy (pos[i], f->planepts[i]);
|
||||||
|
|
||||||
VectorSubtract (pos[2], pos[0], v1);
|
VectorSubtract (pos[2], pos[0], v1);
|
||||||
VectorSubtract (pos[1], pos[0], v2);
|
VectorSubtract (pos[1], pos[0], v2);
|
||||||
|
|
||||||
CrossProduct (v1, v2, norm);
|
CrossProduct (v1, v2, norm);
|
||||||
VectorNormalize (norm);
|
VectorNormalize (norm);
|
||||||
|
|
||||||
if ( !norm[0] && !norm[1] && !norm[2] )
|
if (!norm[0] && !norm[1] && !norm[2])
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
[texturepalette_i getTextureDef: &f->texture];
|
[texturepalette_i getTextureDef:&f->texture];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -92,38 +86,36 @@ id clipper_i;
|
||||||
XYClick
|
XYClick
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
- XYClick: (NSPoint)pt
|
-XYClick:(NSPoint) pt
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
vec3_t new;
|
vec3_t new;
|
||||||
|
|
||||||
new[0] = [xyview_i snapToGrid: pt.x];
|
new[0] =[xyview_i snapToGrid:pt.x];
|
||||||
new[1] = [xyview_i snapToGrid: pt.y];
|
new[1] =[xyview_i snapToGrid:pt.y];
|
||||||
new[2] = [map_i currentMinZ];
|
new[2] =[map_i currentMinZ];
|
||||||
|
|
||||||
// see if a point is allready there
|
// see if a point is allready there
|
||||||
for (i=0 ; i<num ; i++)
|
for (i = 0; i < num; i++) {
|
||||||
{
|
if (new[0] == pos[i][0] && new[1] == pos[i][1]) {
|
||||||
if (new[0] == pos[i][0] && new[1] == pos[i][1])
|
if (pos[i][2] ==[map_i currentMinZ])
|
||||||
{
|
pos[i][2] =[map_i currentMaxZ];
|
||||||
if (pos[i][2] == [map_i currentMinZ])
|
|
||||||
pos[i][2] = [map_i currentMaxZ];
|
|
||||||
else
|
else
|
||||||
pos[i][2] = [map_i currentMinZ];
|
pos[i][2] =[map_i currentMinZ];
|
||||||
[quakeed_i updateAll];
|
[quakeed_i updateAll];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (num == 3)
|
if (num == 3)
|
||||||
num = 0;
|
num = 0;
|
||||||
|
|
||||||
VectorCopy (new, pos[num]);
|
VectorCopy (new, pos[num]);
|
||||||
num++;
|
num++;
|
||||||
|
|
||||||
[quakeed_i updateAll];
|
[quakeed_i updateAll];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,45 +124,43 @@ XYClick
|
||||||
XYDrag
|
XYDrag
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
- (BOOL)XYDrag: (NSPoint *)pt
|
-(BOOL) XYDrag:(NSPoint *) pt
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i = 0; i < 3; i++) {
|
||||||
{
|
if (fabs (pt->x - pos[i][0] > 10) || fabs (pt->y - pos[i][1] > 10))
|
||||||
if (fabs(pt->x - pos[i][0] > 10) || fabs(pt->y - pos[i][1] > 10) )
|
|
||||||
continue;
|
continue;
|
||||||
// drag this point
|
// drag this point
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- ZClick: (NSPoint)pt
|
-ZClick:(NSPoint) pt
|
||||||
{
|
{
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
- carve
|
-carve
|
||||||
{
|
{
|
||||||
[map_i makeSelectedPerform: @selector(carveByClipper)];
|
[map_i makeSelectedPerform:@selector (carveByClipper)];
|
||||||
num = 0;
|
num = 0;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- cameraDrawSelf
|
-cameraDrawSelf
|
||||||
{
|
{
|
||||||
vec3_t mid;
|
vec3_t mid;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
linecolor (1,0.5,0);
|
|
||||||
|
|
||||||
for (i=0 ; i<num ; i++)
|
linecolor (1, 0.5, 0);
|
||||||
{
|
|
||||||
|
for (i = 0; i < num; i++) {
|
||||||
VectorCopy (pos[i], mid);
|
VectorCopy (pos[i], mid);
|
||||||
mid[0] -= 8;
|
mid[0] -= 8;
|
||||||
mid[1] -= 8;
|
mid[1] -= 8;
|
||||||
|
@ -178,7 +168,7 @@ XYDrag
|
||||||
mid[0] += 16;
|
mid[0] += 16;
|
||||||
mid[1] += 16;
|
mid[1] += 16;
|
||||||
CameraLineto (mid);
|
CameraLineto (mid);
|
||||||
|
|
||||||
VectorCopy (pos[i], mid);
|
VectorCopy (pos[i], mid);
|
||||||
mid[0] -= 8;
|
mid[0] -= 8;
|
||||||
mid[1] += 8;
|
mid[1] += 8;
|
||||||
|
@ -187,47 +177,45 @@ XYDrag
|
||||||
mid[1] -= 16;
|
mid[1] -= 16;
|
||||||
CameraLineto (mid);
|
CameraLineto (mid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- XYDrawSelf
|
-XYDrawSelf
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char text[8];
|
char text[8];
|
||||||
|
|
||||||
PSsetrgbcolor (1,0.5,0);
|
|
||||||
//XXX PSselectfont("Helvetica-Medium",10/[xyview_i currentScale]);
|
|
||||||
PSrotate(0);
|
|
||||||
|
|
||||||
for (i=0 ; i<num ; i++)
|
PSsetrgbcolor (1, 0.5, 0);
|
||||||
{
|
// XXX PSselectfont("Helvetica-Medium",10/[xyview_i currentScale]);
|
||||||
PSmoveto (pos[i][0]-4, pos[i][1]-4);
|
PSrotate (0);
|
||||||
|
|
||||||
|
for (i = 0; i < num; i++) {
|
||||||
|
PSmoveto (pos[i][0] - 4, pos[i][1] - 4);
|
||||||
sprintf (text, "%i", i);
|
sprintf (text, "%i", i);
|
||||||
PSshow (text);
|
PSshow (text);
|
||||||
PSstroke ();
|
PSstroke ();
|
||||||
PSarc ( pos[i][0], pos[i][1], 10, 0, 360);
|
PSarc (pos[i][0], pos[i][1], 10, 0, 360);
|
||||||
PSstroke ();
|
PSstroke ();
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- ZDrawSelf
|
-ZDrawSelf
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char text[8];
|
char text[8];
|
||||||
|
|
||||||
PSsetrgbcolor (1,0.5,0);
|
|
||||||
//XXX PSselectfont("Helvetica-Medium",10/[zview_i currentScale]);
|
|
||||||
PSrotate(0);
|
|
||||||
|
|
||||||
for (i=0 ; i<num ; i++)
|
PSsetrgbcolor (1, 0.5, 0);
|
||||||
{
|
// XXX PSselectfont("Helvetica-Medium",10/[zview_i currentScale]);
|
||||||
PSmoveto (-28+i*8 - 4, pos[i][2]-4);
|
PSrotate (0);
|
||||||
|
|
||||||
|
for (i = 0; i < num; i++) {
|
||||||
|
PSmoveto (-28 + i * 8 - 4, pos[i][2] - 4);
|
||||||
sprintf (text, "%i", i);
|
sprintf (text, "%i", i);
|
||||||
PSshow (text);
|
PSshow (text);
|
||||||
PSstroke ();
|
PSstroke ();
|
||||||
PSarc ( -28+i*8, pos[i][2], 10, 0, 360);
|
PSarc (-28 + i * 8, pos[i][2], 10, 0, 360);
|
||||||
PSstroke ();
|
PSstroke ();
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
|
|
@ -3,23 +3,21 @@
|
||||||
|
|
||||||
@implementation Dict
|
@implementation Dict
|
||||||
|
|
||||||
- init
|
-init
|
||||||
{
|
{
|
||||||
[super initCount:0
|
[super initCount: 0 elementSize:sizeof (dict_t)
|
||||||
elementSize:sizeof(dict_t)
|
description:NULL];
|
||||||
description:NULL];
|
return self;
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- print
|
-print
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
for (i=0 ; i<numElements ; i++)
|
for (i = 0; i < numElements; i++) {
|
||||||
{
|
d =[self elementAt:i];
|
||||||
d = [self elementAt: i];
|
printf ("%s : %s\n", d->key, d->value);
|
||||||
printf ("%s : %s\n",d->key, d->value);
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -31,80 +29,75 @@ copyFromZone
|
||||||
JDC
|
JDC
|
||||||
===========
|
===========
|
||||||
*/
|
*/
|
||||||
- copy
|
-copy
|
||||||
{
|
{
|
||||||
id new;
|
id new;
|
||||||
int i;
|
int i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
char *old;
|
char *old;
|
||||||
|
|
||||||
new = [super copy];
|
new =[super copy];
|
||||||
for (i=0 ; i<numElements ; i++)
|
for (i = 0; i < numElements; i++) {
|
||||||
{
|
d =[self elementAt:i];
|
||||||
d = [self elementAt: i];
|
|
||||||
old = d->key;
|
old = d->key;
|
||||||
d->key = malloc(strlen(old)+1);
|
d->key = malloc (strlen (old) + 1);
|
||||||
strcpy (d->key, old);
|
strcpy (d->key, old);
|
||||||
|
|
||||||
old = d->value;
|
old = d->value;
|
||||||
d->value = malloc(strlen(old)+1);
|
d->value = malloc (strlen (old) + 1);
|
||||||
strcpy (d->value, old);
|
strcpy (d->value, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
- initFromFile:(FILE *)fp
|
-initFromFile:(FILE *) fp
|
||||||
{
|
{
|
||||||
[self init];
|
[self init];
|
||||||
return [self parseBraceBlock:fp];
|
return[self parseBraceBlock:fp];
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
//===============================================
|
||||||
//
|
//
|
||||||
// Dictionary pair functions
|
// Dictionary pair functions
|
||||||
//
|
//
|
||||||
//===============================================
|
//===============================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// Write a { } block out to a FILE*
|
// Write a { } block out to a FILE*
|
||||||
//
|
//
|
||||||
- writeBlockTo:(FILE *)fp
|
-writeBlockTo:(FILE *) fp
|
||||||
{
|
{
|
||||||
int max;
|
int max;
|
||||||
int i;
|
int i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
fprintf(fp,"{\n");
|
fprintf (fp, "{\n");
|
||||||
max = [super count];
|
max =[super count];
|
||||||
for (i = 0;i < max;i++)
|
for (i = 0; i < max; i++) {
|
||||||
{
|
d =[super elementAt:i];
|
||||||
d = [super elementAt:i];
|
fprintf (fp, "\t{\"%s\"\t\"%s\"}\n", d->key, d->value);
|
||||||
fprintf(fp,"\t{\"%s\"\t\"%s\"}\n",d->key,d->value);
|
|
||||||
}
|
}
|
||||||
fprintf(fp,"}\n");
|
fprintf (fp, "}\n");
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Write a single { } block out
|
// Write a single { } block out
|
||||||
//
|
//
|
||||||
- writeFile:(char *)path
|
-writeFile:(char *) path
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
fp = fopen(path,"w+t");
|
fp = fopen (path, "w+t");
|
||||||
if (fp != NULL)
|
if (fp != NULL) {
|
||||||
{
|
printf ("Writing dictionary file %s.\n", path);
|
||||||
printf("Writing dictionary file %s.\n",path);
|
fprintf (fp, "// QE_Project file %s\n", path);
|
||||||
fprintf(fp,"// QE_Project file %s\n",path);
|
|
||||||
[self writeBlockTo:fp];
|
[self writeBlockTo:fp];
|
||||||
fclose(fp);
|
fclose (fp);
|
||||||
}
|
} else {
|
||||||
else
|
printf ("Error writing %s!\n", path);
|
||||||
{
|
|
||||||
printf("Error writing %s!\n",path);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,165 +106,160 @@ JDC
|
||||||
|
|
||||||
//===============================================
|
//===============================================
|
||||||
//
|
//
|
||||||
// Utility methods
|
// Utility methods
|
||||||
//
|
//
|
||||||
//===============================================
|
//===============================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find a keyword in storage
|
// Find a keyword in storage
|
||||||
// Returns * to dict_t, otherwise NULL
|
// Returns * to dict_t, otherwise NULL
|
||||||
//
|
//
|
||||||
- (dict_t *) findKeyword:(char *)key
|
-(dict_t *) findKeyword:(char *) key
|
||||||
{
|
{
|
||||||
int max;
|
int max;
|
||||||
int i;
|
int i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
max = [super count];
|
max =[super count];
|
||||||
for (i = 0;i < max;i++)
|
for (i = 0; i < max; i++) {
|
||||||
{
|
d =[super elementAt:i];
|
||||||
d = [super elementAt:i];
|
if (!strcmp (d->key, key))
|
||||||
if (!strcmp(d->key,key))
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Change a keyword's string
|
// Change a keyword's string
|
||||||
//
|
//
|
||||||
- changeStringFor:(char *)key to:(char *)value
|
-changeStringFor:(char *)
|
||||||
|
key to:(char *) value
|
||||||
{
|
{
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
dict_t newd;
|
dict_t newd;
|
||||||
|
|
||||||
d = [self findKeyword:key];
|
d =[self findKeyword:key];
|
||||||
if (d != NULL)
|
if (d != NULL) {
|
||||||
{
|
free (d->value);
|
||||||
free(d->value);
|
d->value = malloc (strlen (value) + 1);
|
||||||
d->value = malloc(strlen(value)+1);
|
strcpy (d->value, value);
|
||||||
strcpy(d->value,value);
|
} else {
|
||||||
}
|
newd.key = malloc (strlen (key) + 1);
|
||||||
else
|
strcpy (newd.key, key);
|
||||||
{
|
newd.value = malloc (strlen (value) + 1);
|
||||||
newd.key = malloc(strlen(key)+1);
|
strcpy (newd.value, value);
|
||||||
strcpy(newd.key,key);
|
|
||||||
newd.value = malloc(strlen(value)+1);
|
|
||||||
strcpy(newd.value,value);
|
|
||||||
[self addElement:&newd];
|
[self addElement:&newd];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search for keyword, return the string *
|
// Search for keyword, return the string *
|
||||||
//
|
//
|
||||||
- (char *)getStringFor:(char *)name
|
-(char *) getStringFor:(char *) name
|
||||||
{
|
{
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
d = [self findKeyword:name];
|
d =[self findKeyword:name];
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
return d->value;
|
return d->value;
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search for keyword, return the value
|
// Search for keyword, return the value
|
||||||
//
|
//
|
||||||
- (unsigned int)getValueFor:(char *)name
|
-(unsigned int) getValueFor:(char *) name
|
||||||
{
|
{
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
d = [self findKeyword:name];
|
d =[self findKeyword:name];
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
return atol(d->value);
|
return atol (d->value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return # of units in keyword's value
|
// Return # of units in keyword's value
|
||||||
//
|
//
|
||||||
- (int) getValueUnits:(char *)key
|
-(int) getValueUnits:(char *) key
|
||||||
{
|
{
|
||||||
id temp;
|
id temp;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
temp = [self parseMultipleFrom:key];
|
temp =[self parseMultipleFrom:key];
|
||||||
count = [temp count];
|
count =[temp count];
|
||||||
[temp release];
|
[temp release];
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convert List to string
|
// Convert List to string
|
||||||
//
|
//
|
||||||
- (char *)convertListToString:(id)list
|
-(char *) convertListToString:(id) list
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
char tempstr[4096];
|
char tempstr[4096];
|
||||||
char *s;
|
char *s;
|
||||||
char *newstr;
|
char *newstr;
|
||||||
|
|
||||||
max = [list count];
|
max =[list count];
|
||||||
tempstr[0] = 0;
|
tempstr[0] = 0;
|
||||||
for (i = 0;i < max;i++)
|
for (i = 0; i < max; i++) {
|
||||||
{
|
s =[list elementAt:i];
|
||||||
s = [list elementAt:i];
|
strcat (tempstr, s);
|
||||||
strcat(tempstr,s);
|
strcat (tempstr, " ");
|
||||||
strcat(tempstr," ");
|
|
||||||
}
|
}
|
||||||
newstr = malloc(strlen(tempstr)+1);
|
newstr = malloc (strlen (tempstr) + 1);
|
||||||
strcpy(newstr,tempstr);
|
strcpy (newstr, tempstr);
|
||||||
|
|
||||||
return newstr;
|
return newstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// JDC: I wrote this to simplify removing vectors
|
// JDC: I wrote this to simplify removing vectors
|
||||||
//
|
//
|
||||||
- removeKeyword:(char *)key
|
-removeKeyword:(char *) key
|
||||||
{
|
{
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
d = [self findKeyword:key];
|
d =[self findKeyword:key];
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return self;
|
return self;
|
||||||
[self removeElementAt:d - (dict_t*)dataPtr];
|
[self removeElementAt:d - (dict_t *) dataPtr];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Delete string from keyword's value
|
// Delete string from keyword's value
|
||||||
//
|
//
|
||||||
- delString:(char *)string fromValue:(char *)key
|
-delString:(char *)
|
||||||
|
string fromValue:(char *) key
|
||||||
{
|
{
|
||||||
id temp;
|
id temp;
|
||||||
int count;
|
int count;
|
||||||
int i;
|
int i;
|
||||||
char *s;
|
char *s;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
d = [self findKeyword:key];
|
d =[self findKeyword:key];
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
temp = [self parseMultipleFrom:key];
|
temp =[self parseMultipleFrom:key];
|
||||||
count = [temp count];
|
count =[temp count];
|
||||||
for (i = 0;i < count;i++)
|
for (i = 0; i < count; i++) {
|
||||||
{
|
s =[temp elementAt:i];
|
||||||
s = [temp elementAt:i];
|
if (!strcmp (s, string)) {
|
||||||
if (!strcmp(s,string))
|
|
||||||
{
|
|
||||||
[temp removeElementAt:i];
|
[temp removeElementAt:i];
|
||||||
free(d->value);
|
free (d->value);
|
||||||
d->value = [self convertListToString:temp];
|
d->value =[self convertListToString:temp];
|
||||||
[temp release];
|
[temp release];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,186 +267,179 @@ JDC
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add string to keyword's value
|
// Add string to keyword's value
|
||||||
//
|
//
|
||||||
- addString:(char *)string toValue:(char *)key
|
-addString:(char *)
|
||||||
|
string toValue:(char *) key
|
||||||
{
|
{
|
||||||
char *newstr;
|
char *newstr;
|
||||||
char spacing[] = "\t";
|
char spacing[] = "\t";
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
|
|
||||||
d = [self findKeyword:key];
|
d =[self findKeyword:key];
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
newstr = malloc(strlen(string) + strlen(d->value) + strlen(spacing) + 1);
|
newstr =
|
||||||
strcpy(newstr,d->value);
|
malloc (strlen (string) + strlen (d->value) + strlen (spacing) + 1);
|
||||||
strcat(newstr,spacing);
|
strcpy (newstr, d->value);
|
||||||
strcat(newstr,string);
|
strcat (newstr, spacing);
|
||||||
free(d->value);
|
strcat (newstr, string);
|
||||||
|
free (d->value);
|
||||||
d->value = newstr;
|
d->value = newstr;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
//===============================================
|
||||||
//
|
//
|
||||||
// Use these for multiple parameters in a keyword value
|
// Use these for multiple parameters in a keyword value
|
||||||
//
|
//
|
||||||
//===============================================
|
//===============================================
|
||||||
char *searchStr;
|
char *searchStr;
|
||||||
char item[4096];
|
char item[4096];
|
||||||
|
|
||||||
- setupMultiple:(char *)value
|
-setupMultiple:(char *) value
|
||||||
{
|
{
|
||||||
searchStr = value;
|
searchStr = value;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *)getNextParameter
|
-(char *) getNextParameter
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if (!searchStr)
|
if (!searchStr)
|
||||||
return NULL;
|
return NULL;
|
||||||
strcpy(item,searchStr);
|
strcpy (item, searchStr);
|
||||||
s = FindWhitespcInBuffer(item);
|
s = FindWhitespcInBuffer (item);
|
||||||
if (!*s)
|
if (!*s)
|
||||||
searchStr = NULL;
|
searchStr = NULL;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
*s = 0;
|
*s = 0;
|
||||||
searchStr = FindNonwhitespcInBuffer(s+1);
|
searchStr = FindNonwhitespcInBuffer (s + 1);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parses a keyvalue string & returns a Storage full of those items
|
// Parses a keyvalue string & returns a Storage full of those items
|
||||||
//
|
//
|
||||||
- (id) parseMultipleFrom:(char *)key
|
-(id) parseMultipleFrom:(char *) key
|
||||||
{
|
{
|
||||||
#define ITEMSIZE 128
|
#define ITEMSIZE 128
|
||||||
id stuff;
|
id stuff;
|
||||||
char string[ITEMSIZE];
|
char string[ITEMSIZE];
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = [self getStringFor:key];
|
s =[self getStringFor:key];
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
stuff = [[Storage alloc]
|
stuff =[[Storage alloc]
|
||||||
initCount:0
|
initCount: 0 elementSize: ITEMSIZE description:NULL];
|
||||||
elementSize:ITEMSIZE
|
|
||||||
description:NULL];
|
|
||||||
|
|
||||||
[self setupMultiple:s];
|
[self setupMultiple:s];
|
||||||
while((s = [self getNextParameter]))
|
while ((s =[self getNextParameter])) {
|
||||||
{
|
bzero (string, ITEMSIZE);
|
||||||
bzero(string,ITEMSIZE);
|
strcpy (string, s);
|
||||||
strcpy(string,s);
|
|
||||||
[stuff addElement:string];
|
[stuff addElement:string];
|
||||||
}
|
}
|
||||||
|
|
||||||
return stuff;
|
return stuff;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
//===============================================
|
||||||
//
|
//
|
||||||
// Dictionary pair parsing
|
// Dictionary pair parsing
|
||||||
//
|
//
|
||||||
//===============================================
|
//===============================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// parse all keyword/value pairs within { } 's
|
// parse all keyword/value pairs within { } 's
|
||||||
//
|
//
|
||||||
- (id) parseBraceBlock:(FILE *)fp
|
-(id) parseBraceBlock:(FILE *) fp
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
dict_t pair;
|
dict_t pair;
|
||||||
char string[1024];
|
char string[1024];
|
||||||
|
|
||||||
c = FindBrace(fp);
|
c = FindBrace (fp);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while((c = FindBrace(fp)) != '}')
|
while ((c = FindBrace (fp)) != '}') {
|
||||||
{
|
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
// c = FindNonwhitespc(fp);
|
// c = FindNonwhitespc(fp);
|
||||||
// if (c == -1)
|
// if (c == -1)
|
||||||
// return NULL;
|
// return NULL;
|
||||||
// CopyUntilWhitespc(fp,string);
|
// CopyUntilWhitespc(fp,string);
|
||||||
|
|
||||||
// JDC: fixed to allow quoted keys
|
// JDC: fixed to allow quoted keys
|
||||||
c = FindNonwhitespc(fp);
|
c = FindNonwhitespc (fp);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
c = fgetc(fp);
|
c = fgetc (fp);
|
||||||
if ( c == '\"')
|
if (c == '\"')
|
||||||
CopyUntilQuote(fp,string);
|
CopyUntilQuote (fp, string);
|
||||||
else
|
else {
|
||||||
{
|
ungetc (c, fp);
|
||||||
ungetc (c,fp);
|
CopyUntilWhitespc (fp, string);
|
||||||
CopyUntilWhitespc(fp,string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pair.key = malloc(strlen(string)+1);
|
pair.key = malloc (strlen (string) + 1);
|
||||||
strcpy(pair.key,string);
|
strcpy (pair.key, string);
|
||||||
|
|
||||||
c = FindQuote(fp);
|
c = FindQuote (fp);
|
||||||
CopyUntilQuote(fp,string);
|
CopyUntilQuote (fp, string);
|
||||||
pair.value = malloc(strlen(string)+1);
|
pair.value = malloc (strlen (string) + 1);
|
||||||
strcpy(pair.value,string);
|
strcpy (pair.value, string);
|
||||||
|
|
||||||
[super addElement:&pair];
|
[super addElement:&pair];
|
||||||
c = FindBrace(fp);
|
c = FindBrace (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
//===============================================
|
//===============================================
|
||||||
//
|
//
|
||||||
// C routines for string parsing
|
// C routines for string parsing
|
||||||
//
|
//
|
||||||
//===============================================
|
//===============================================
|
||||||
int GetNextChar(FILE *fp)
|
int
|
||||||
|
GetNextChar (FILE * fp)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int c2;
|
int c2;
|
||||||
|
|
||||||
c = getc(fp);
|
c = getc (fp);
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return -1;
|
return -1;
|
||||||
if (c == '/') // parse comments
|
if (c == '/') // parse comments
|
||||||
{
|
{
|
||||||
c2 = getc(fp);
|
c2 = getc (fp);
|
||||||
if (c2 == '/')
|
if (c2 == '/') {
|
||||||
{
|
while ((c2 = getc (fp)) != '\n');
|
||||||
while((c2 = getc(fp)) != '\n');
|
c = getc (fp);
|
||||||
c = getc(fp);
|
} else
|
||||||
}
|
ungetc (c2, fp);
|
||||||
else
|
|
||||||
ungetc(c2,fp);
|
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyUntilWhitespc(FILE *fp,char *buffer)
|
void
|
||||||
|
CopyUntilWhitespc (FILE * fp, char *buffer)
|
||||||
{
|
{
|
||||||
int count = 800;
|
int count = 800;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while(count--)
|
while (count--) {
|
||||||
{
|
c = GetNextChar (fp);
|
||||||
c = GetNextChar(fp);
|
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return;
|
return;
|
||||||
if (c <= ' ')
|
if (c <= ' ') {
|
||||||
{
|
|
||||||
*buffer = 0;
|
*buffer = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -466,18 +447,17 @@ void CopyUntilWhitespc(FILE *fp,char *buffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopyUntilQuote(FILE *fp,char *buffer)
|
void
|
||||||
|
CopyUntilQuote (FILE * fp, char *buffer)
|
||||||
{
|
{
|
||||||
int count = 800;
|
int count = 800;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while(count--)
|
while (count--) {
|
||||||
{
|
c = GetNextChar (fp);
|
||||||
c = GetNextChar(fp);
|
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return;
|
return;
|
||||||
if (c == '\"')
|
if (c == '\"') {
|
||||||
{
|
|
||||||
*buffer = 0;
|
*buffer = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -485,31 +465,30 @@ void CopyUntilQuote(FILE *fp,char *buffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FindBrace(FILE *fp)
|
int
|
||||||
|
FindBrace (FILE * fp)
|
||||||
{
|
{
|
||||||
int count = 800;
|
int count = 800;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while(count--)
|
while (count--) {
|
||||||
{
|
c = GetNextChar (fp);
|
||||||
c = GetNextChar(fp);
|
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return -1;
|
return -1;
|
||||||
if (c == '{' ||
|
if (c == '{' || c == '}')
|
||||||
c == '}')
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FindQuote(FILE *fp)
|
int
|
||||||
|
FindQuote (FILE * fp)
|
||||||
{
|
{
|
||||||
int count = 800;
|
int count = 800;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while(count--)
|
while (count--) {
|
||||||
{
|
c = GetNextChar (fp);
|
||||||
c = GetNextChar(fp);
|
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return -1;
|
return -1;
|
||||||
if (c == '\"')
|
if (c == '\"')
|
||||||
|
@ -518,63 +497,63 @@ int FindQuote(FILE *fp)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FindWhitespc(FILE *fp)
|
int
|
||||||
|
FindWhitespc (FILE * fp)
|
||||||
{
|
{
|
||||||
int count = 800;
|
int count = 800;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while(count--)
|
|
||||||
{
|
|
||||||
c = GetNextChar(fp);
|
|
||||||
if (c == EOF)
|
|
||||||
return -1;
|
|
||||||
if (c <= ' ')
|
|
||||||
{
|
|
||||||
ungetc(c,fp);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int FindNonwhitespc(FILE *fp)
|
while (count--) {
|
||||||
{
|
c = GetNextChar (fp);
|
||||||
int count = 800;
|
|
||||||
int c;
|
|
||||||
|
|
||||||
while(count--)
|
|
||||||
{
|
|
||||||
c = GetNextChar(fp);
|
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
return -1;
|
return -1;
|
||||||
if (c > ' ')
|
if (c <= ' ') {
|
||||||
{
|
ungetc (c, fp);
|
||||||
ungetc(c,fp);
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *FindWhitespcInBuffer(char *buffer)
|
int
|
||||||
|
FindNonwhitespc (FILE * fp)
|
||||||
{
|
{
|
||||||
int count = 1000;
|
int count = 800;
|
||||||
char *b = buffer;
|
int c;
|
||||||
|
|
||||||
while(count--)
|
while (count--) {
|
||||||
|
c = GetNextChar (fp);
|
||||||
|
if (c == EOF)
|
||||||
|
return -1;
|
||||||
|
if (c > ' ') {
|
||||||
|
ungetc (c, fp);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
FindWhitespcInBuffer (char *buffer)
|
||||||
|
{
|
||||||
|
int count = 1000;
|
||||||
|
char *b = buffer;
|
||||||
|
|
||||||
|
while (count--)
|
||||||
if (*b <= ' ')
|
if (*b <= ' ')
|
||||||
return b;
|
return b;
|
||||||
else
|
else
|
||||||
b++;
|
b++;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *FindNonwhitespcInBuffer(char *buffer)
|
char *
|
||||||
|
FindNonwhitespcInBuffer (char *buffer)
|
||||||
{
|
{
|
||||||
int count = 1000;
|
int count = 1000;
|
||||||
char *b = buffer;
|
char *b = buffer;
|
||||||
|
|
||||||
while(count--)
|
while (count--)
|
||||||
if (*b > ' ')
|
if (*b > ' ')
|
||||||
return b;
|
return b;
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,64 +3,60 @@
|
||||||
#include "Dict.h"
|
#include "Dict.h"
|
||||||
|
|
||||||
@implementation DictList
|
@implementation DictList
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read in variable # of objects from FILE *
|
// Read in variable # of objects from FILE *
|
||||||
//
|
//
|
||||||
- initListFromFile:(FILE *)fp
|
- initListFromFile:(FILE *) fp
|
||||||
{
|
{
|
||||||
id d;
|
id d;
|
||||||
|
|
||||||
[super init];
|
[super init];
|
||||||
do
|
do {
|
||||||
{
|
d =[(Dict *)[Dict alloc] initFromFile:fp];
|
||||||
d = [(Dict *)[Dict alloc] initFromFile:fp];
|
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
[self addObject:d];
|
[self addObject:d];
|
||||||
} while(d != NULL);
|
} while (d != NULL);
|
||||||
[d release];
|
[d release];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Write out list file
|
// Write out list file
|
||||||
//
|
//
|
||||||
- writeListFile:(char *)filename
|
-writeListFile:(char *) filename
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int i;
|
int i;
|
||||||
id obj;
|
id obj;
|
||||||
|
|
||||||
fp = fopen(filename,"w+t");
|
fp = fopen (filename, "w+t");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
fprintf(fp,"// Object List written by QuakeEd\n");
|
|
||||||
|
|
||||||
for (i = 0;i < [self count];i++)
|
fprintf (fp, "// Object List written by QuakeEd\n");
|
||||||
{
|
|
||||||
obj = [self objectAtIndex:i];
|
for (i = 0; i <[self count]; i++) {
|
||||||
|
obj =[self objectAtIndex:i];
|
||||||
[obj writeBlockTo:fp];
|
[obj writeBlockTo:fp];
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose (fp);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find the keyword in all the Dict objects
|
// Find the keyword in all the Dict objects
|
||||||
//
|
//
|
||||||
- (id) findDictKeyword:(char *)key
|
-(id) findDictKeyword:(char *) key
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
dict_t *d;
|
dict_t *d;
|
||||||
id dict;
|
id dict;
|
||||||
|
|
||||||
for (i = 0;i < [self count];i++)
|
for (i = 0; i <[self count]; i++) {
|
||||||
{
|
dict =[self objectAtIndex:i];
|
||||||
dict = [self objectAtIndex:i];
|
d =[(Dict *) dict findKeyword:key];
|
||||||
d = [(Dict *)dict findKeyword:key];
|
|
||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,89 +12,85 @@
|
||||||
|
|
||||||
@implementation Entity
|
@implementation Entity
|
||||||
|
|
||||||
vec3_t bad_mins = {-8, -8, -8};
|
vec3_t bad_mins = { -8, -8, -8 };
|
||||||
vec3_t bad_maxs = {8, 8, 8};
|
vec3_t bad_maxs = { 8, 8, 8 };
|
||||||
|
|
||||||
- createFixedBrush: (vec3_t)org
|
-createFixedBrush:(vec3_t) org
|
||||||
{
|
{
|
||||||
vec3_t emins, emaxs;
|
vec3_t emins, emaxs;
|
||||||
float *v, *v2, *color;
|
float *v, *v2, *color;
|
||||||
id new;
|
id new;
|
||||||
texturedef_t td;
|
texturedef_t td;
|
||||||
|
|
||||||
// get class
|
// get class
|
||||||
new = [entity_classes_i classForName: [self valueForQKey: "classname"]];
|
new =[entity_classes_i classForName: [self valueForQKey:"classname"]];
|
||||||
if (new) {
|
if (new) {
|
||||||
v = [new mins];
|
v =[new mins];
|
||||||
v2 = [new maxs];
|
v2 =[new maxs];
|
||||||
} else {
|
} else {
|
||||||
v = bad_mins;
|
v = bad_mins;
|
||||||
v2 = bad_maxs;
|
v2 = bad_maxs;
|
||||||
}
|
}
|
||||||
|
|
||||||
color = [new drawColor];
|
color =[new drawColor];
|
||||||
|
|
||||||
modifiable = NO;
|
modifiable = NO;
|
||||||
memset(&td,0,sizeof(td));
|
memset (&td, 0, sizeof (td));
|
||||||
strcpy (td.texture,"entity");
|
strcpy (td.texture, "entity");
|
||||||
|
|
||||||
VectorAdd (org, v, emins);
|
VectorAdd (org, v, emins);
|
||||||
VectorAdd (org, v2, emaxs);
|
VectorAdd (org, v2, emaxs);
|
||||||
new = [[SetBrush alloc] initOwner: self mins:emins maxs:emaxs
|
new =[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture:&td];
|
||||||
texture: &td];
|
[new setEntityColor:color];
|
||||||
[new setEntityColor: color];
|
|
||||||
|
[self addObject:new];
|
||||||
|
|
||||||
[self addObject: new];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- initClass: (char *)classname
|
-initClass:(char *) classname
|
||||||
{
|
{
|
||||||
id new;
|
id new;
|
||||||
esize_t esize;
|
esize_t esize;
|
||||||
char value[80];
|
char value[80];
|
||||||
vec3_t min, max;
|
vec3_t min, max;
|
||||||
float *v;
|
float *v;
|
||||||
|
|
||||||
[super init];
|
[super init];
|
||||||
|
|
||||||
modifiable = YES;
|
modifiable = YES;
|
||||||
|
|
||||||
[self setKey: "classname" toValue:classname];
|
[self setKey: "classname" toValue:classname];
|
||||||
|
|
||||||
// get class
|
// get class
|
||||||
new = [entity_classes_i classForName: [self valueForQKey: "classname"]];
|
new =[entity_classes_i classForName: [self valueForQKey:"classname"]];
|
||||||
if (!new)
|
if (!new)
|
||||||
esize = esize_model;
|
esize = esize_model;
|
||||||
else
|
else
|
||||||
esize = [new esize];
|
esize =[new esize];
|
||||||
|
|
||||||
// create a brush if needed
|
|
||||||
if (esize == esize_fixed)
|
|
||||||
{
|
|
||||||
v = [new mins];
|
|
||||||
[[map_i selectedBrush] getMins: min maxs: max];
|
|
||||||
VectorSubtract (min, v, min);
|
|
||||||
|
|
||||||
sprintf (value, "%i %i %i",(int)min[0], (int)min[1], (int)min[2]);
|
|
||||||
[self setKey:"origin" toValue: value];
|
|
||||||
|
|
||||||
[self createFixedBrush: min];
|
// create a brush if needed
|
||||||
}
|
if (esize == esize_fixed) {
|
||||||
else
|
v =[new mins];
|
||||||
|
[[map_i selectedBrush] getMins: min maxs:max];
|
||||||
|
VectorSubtract (min, v, min);
|
||||||
|
|
||||||
|
sprintf (value, "%i %i %i", (int) min[0], (int) min[1], (int) min[2]);
|
||||||
|
[self setKey: "origin" toValue:value];
|
||||||
|
|
||||||
|
[self createFixedBrush:min];
|
||||||
|
} else
|
||||||
modifiable = YES;
|
modifiable = YES;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)dealloc
|
-(void) dealloc
|
||||||
{
|
{
|
||||||
epair_t *e, *n;
|
epair_t *e, *n;
|
||||||
|
|
||||||
for (e=epairs ; e ; e=n)
|
for (e = epairs; e; e = n) {
|
||||||
{
|
|
||||||
n = e->next;
|
n = e->next;
|
||||||
free (e->key);
|
free (e->key);
|
||||||
free (e->value);
|
free (e->value);
|
||||||
|
@ -103,78 +99,79 @@ vec3_t bad_maxs = {8, 8, 8};
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)modifiable
|
-(BOOL) modifiable
|
||||||
{
|
{
|
||||||
return modifiable;
|
return modifiable;
|
||||||
}
|
}
|
||||||
|
|
||||||
- setModifiable: (BOOL)m
|
-setModifiable:(BOOL) m
|
||||||
{
|
{
|
||||||
modifiable = m;
|
modifiable = m;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeObject: o
|
-(void) removeObject:o
|
||||||
{
|
{
|
||||||
[super removeObject: o];
|
[super removeObject:o];
|
||||||
if ([self count])
|
if ([self count])
|
||||||
return;
|
return;
|
||||||
// the entity is empty, so remove the entire thing
|
// the entity is empty, so remove the entire thing
|
||||||
if ( self == [map_i objectAtIndex: 0])
|
if (self ==[map_i objectAtIndex:0])
|
||||||
return; // never remove the world
|
return; // never remove the world
|
||||||
|
|
||||||
[map_i removeObject: self];
|
[map_i removeObject:self];
|
||||||
[self release];
|
[self release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (char *)valueForQKey: (char *)k
|
-(char *) valueForQKey:(char *) k
|
||||||
{
|
{
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
static char ret[64];
|
static char ret[64];
|
||||||
|
|
||||||
for (e=epairs ; e ; e=e->next)
|
for (e = epairs; e; e = e->next)
|
||||||
if (!strcmp(k,e->key))
|
if (!strcmp (k, e->key)) {
|
||||||
{
|
|
||||||
strcpy (ret, e->value);
|
strcpy (ret, e->value);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
- getVector: (vec3_t)v forKey: (char *)k
|
-getVector:(vec3_t)
|
||||||
|
v forKey:(char *) k
|
||||||
{
|
{
|
||||||
char *c;
|
char *c;
|
||||||
|
|
||||||
c = [self valueForQKey: k];
|
c =[self valueForQKey:k];
|
||||||
|
|
||||||
v[0] = v[1] = v[2] = 0;
|
v[0] = v[1] = v[2] = 0;
|
||||||
|
|
||||||
sscanf (c, "%f %f %f", &v[0], &v[1], &v[2]);
|
sscanf (c, "%f %f %f", &v[0], &v[1], &v[2]);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- print
|
-print
|
||||||
{
|
{
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
|
|
||||||
for (e=epairs ; e ; e=e->next)
|
for (e = epairs; e; e = e->next)
|
||||||
printf ("%20s : %20s\n",e->key, e->value);
|
printf ("%20s : %20s\n", e->key, e->value);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- setKey:(const char *)k toValue:(const char *)v
|
-setKey:(const char *)
|
||||||
|
k toValue:(const char *) v
|
||||||
{
|
{
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
|
|
||||||
while (*k && *k <= ' ')
|
while (*k && *k <= ' ')
|
||||||
k++;
|
k++;
|
||||||
if (!*k)
|
if (!*k)
|
||||||
return self; // don't set NULL values
|
return self; // don't set NULL values
|
||||||
|
|
||||||
for (e=epairs ; e ; e=e->next) {
|
for (e = epairs; e; e = e->next) {
|
||||||
if (!strcmp (k, e->key)) {
|
if (!strcmp (k, e->key)) {
|
||||||
free (e->value);
|
free (e->value);
|
||||||
e->value = strdup (v);
|
e->value = strdup (v);
|
||||||
|
@ -182,59 +179,56 @@ vec3_t bad_maxs = {8, 8, 8};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e = malloc (sizeof(epair_t));
|
e = malloc (sizeof (epair_t));
|
||||||
|
|
||||||
e->key = strdup (k);
|
e->key = strdup (k);
|
||||||
e->value = strdup (v);
|
e->value = strdup (v);
|
||||||
e->next = epairs;
|
e->next = epairs;
|
||||||
epairs = e;
|
epairs = e;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)numPairs
|
-(int) numPairs
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
|
|
||||||
i=0;
|
i = 0;
|
||||||
for (e=epairs ; e ; e=e->next)
|
for (e = epairs; e; e = e->next)
|
||||||
i++;
|
i++;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (epair_t *)epairs
|
-(epair_t *) epairs
|
||||||
{
|
{
|
||||||
return epairs;
|
return epairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
- removeKeyPair: (char *)key
|
-removeKeyPair:(char *) key
|
||||||
{
|
{
|
||||||
epair_t *e, *e2;
|
epair_t *e, *e2;
|
||||||
|
|
||||||
if (!epairs)
|
if (!epairs)
|
||||||
return self;
|
return self;
|
||||||
e = epairs;
|
e = epairs;
|
||||||
if (!strcmp(e->key, key))
|
if (!strcmp (e->key, key)) {
|
||||||
{
|
|
||||||
epairs = e->next;
|
epairs = e->next;
|
||||||
free (e);
|
free (e);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; e ; e=e->next)
|
for (; e; e = e->next) {
|
||||||
{
|
if (e->next && !strcmp (e->next->key, key)) {
|
||||||
if (e->next && !strcmp(e->next->key, key))
|
|
||||||
{
|
|
||||||
e2 = e->next;
|
e2 = e->next;
|
||||||
e->next = e2->next;
|
e->next = e2->next;
|
||||||
free (e2);
|
free (e2);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("WARNING: removeKeyPair: %s not found\n", key);
|
printf ("WARNING: removeKeyPair: %s not found\n", key);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -245,37 +239,37 @@ targetname
|
||||||
If the entity does not have a "targetname" key, a unique one is generated
|
If the entity does not have a "targetname" key, a unique one is generated
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
- (char *)targetname
|
-(char *) targetname
|
||||||
{
|
{
|
||||||
char *t;
|
char *t;
|
||||||
int i, count;
|
int i, count;
|
||||||
id ent;
|
id ent;
|
||||||
int tval, maxt;
|
int tval, maxt;
|
||||||
char name[20];
|
char name[20];
|
||||||
|
|
||||||
t = [self valueForQKey: "targetname"];
|
t =[self valueForQKey:"targetname"];
|
||||||
if (t && t[0])
|
if (t && t[0])
|
||||||
return t;
|
return t;
|
||||||
|
|
||||||
// make a unique name of the form t<number>
|
// make a unique name of the form t<number>
|
||||||
count = [map_i count];
|
count =[map_i count];
|
||||||
maxt = 0;
|
maxt = 0;
|
||||||
for (i=1 ; i<count ; i++)
|
for (i = 1; i < count; i++) {
|
||||||
{
|
ent =[map_i objectAtIndex:i];
|
||||||
ent = [map_i objectAtIndex: i];
|
t =[ent valueForQKey:"targetname"];
|
||||||
t = [ent valueForQKey: "targetname"];
|
|
||||||
if (!t || t[0] != 't')
|
if (!t || t[0] != 't')
|
||||||
continue;
|
continue;
|
||||||
tval = atoi (t+1);
|
tval = atoi (t + 1);
|
||||||
if (tval > maxt)
|
if (tval > maxt)
|
||||||
maxt = tval;
|
maxt = tval;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (name,"t%i",maxt+1);
|
sprintf (name, "t%i", maxt + 1);
|
||||||
|
|
||||||
[self setKey: "targetname" toValue: name];
|
[self setKey: "targetname" toValue:name];
|
||||||
|
|
||||||
return [self valueForQKey: "targetname"]; // so it's not on the stack
|
return[self valueForQKey:"targetname"];
|
||||||
|
// so it's not on the stack
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -286,40 +280,39 @@ FILE METHODS
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int nument;
|
int nument;
|
||||||
|
|
||||||
- initFromScript: (script_t *) script
|
-initFromScript:(script_t *) script
|
||||||
{
|
{
|
||||||
char *key;
|
char *key;
|
||||||
id eclass, brush;
|
id eclass, brush;
|
||||||
char *spawn;
|
char *spawn;
|
||||||
vec3_t emins, emaxs;
|
vec3_t emins, emaxs;
|
||||||
vec3_t org;
|
vec3_t org;
|
||||||
texturedef_t td;
|
texturedef_t td;
|
||||||
esize_t esize;
|
esize_t esize;
|
||||||
int i, c;
|
int i, c;
|
||||||
float *color;
|
float *color;
|
||||||
|
|
||||||
[self init];
|
[self init];
|
||||||
|
|
||||||
if (!Script_GetToken (script, true))
|
if (!Script_GetToken (script, true)) {
|
||||||
{
|
|
||||||
[self dealloc];
|
[self dealloc];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (Script_Token (script), "{") )
|
if (strcmp (Script_Token (script), "{"))
|
||||||
Sys_Error ("initFromFileP: { not found");
|
Sys_Error ("initFromFileP: { not found");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!Script_GetToken (script, true))
|
if (!Script_GetToken (script, true))
|
||||||
break;
|
break;
|
||||||
if (!strcmp (Script_Token (script), "}") )
|
if (!strcmp (Script_Token (script), "}"))
|
||||||
break;
|
break;
|
||||||
if (!strcmp (Script_Token (script), "{") ) {
|
if (!strcmp (Script_Token (script), "{")) {
|
||||||
// read a brush
|
// read a brush
|
||||||
brush = [[SetBrush alloc] initFromScript: script owner:self];
|
brush =[[SetBrush alloc] initFromScript: script owner:self];
|
||||||
[self addObject: brush];
|
[self addObject:brush];
|
||||||
} else {
|
} else {
|
||||||
// read a key / value pair
|
// read a key / value pair
|
||||||
key = strdup (Script_Token (script));
|
key = strdup (Script_Token (script));
|
||||||
|
@ -328,122 +321,114 @@ int nument;
|
||||||
free (key);
|
free (key);
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
nument++;
|
nument++;
|
||||||
|
|
||||||
// get class
|
// get class
|
||||||
spawn = [self valueForQKey: "classname"];
|
spawn =[self valueForQKey:"classname"];
|
||||||
eclass = [entity_classes_i classForName: spawn];
|
eclass =[entity_classes_i classForName:spawn];
|
||||||
|
|
||||||
esize = [eclass esize];
|
esize =[eclass esize];
|
||||||
|
|
||||||
[self getVector: org forKey: "origin"];
|
[self getVector: org forKey:"origin"];
|
||||||
|
|
||||||
if ([self count] && esize != esize_model)
|
if ([self count] && esize != esize_model) {
|
||||||
{
|
printf ("WARNING:Entity with brushes and wrong model type\n");
|
||||||
printf ("WARNING:Entity with brushes and wrong model type\n");
|
|
||||||
[self removeAllObjects];
|
[self removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![self count] && esize == esize_model)
|
if (![self count] && esize == esize_model) {
|
||||||
{
|
printf ("WARNING:Entity with no brushes and esize_model\n");
|
||||||
printf ("WARNING:Entity with no brushes and esize_model\n");
|
[texturepalette_i getTextureDef:&td];
|
||||||
[texturepalette_i getTextureDef: &td];
|
for (i = 0; i < 3; i++) {
|
||||||
for (i=0 ; i<3 ; i++)
|
|
||||||
{
|
|
||||||
emins[i] = org[i] - 8;
|
emins[i] = org[i] - 8;
|
||||||
emaxs[i] = org[i] + 8;
|
emaxs[i] = org[i] + 8;
|
||||||
}
|
}
|
||||||
brush = [[SetBrush alloc] initOwner: self mins:emins maxs:emaxs
|
brush =[[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture:&td];
|
||||||
texture: &td];
|
[self addObject:brush];
|
||||||
[self addObject: brush];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a brush if needed
|
// create a brush if needed
|
||||||
if (esize == esize_fixed)
|
if (esize == esize_fixed)
|
||||||
[self createFixedBrush: org];
|
[self createFixedBrush:org];
|
||||||
else
|
else
|
||||||
modifiable = YES;
|
modifiable = YES;
|
||||||
|
|
||||||
// set all the brush colors
|
// set all the brush colors
|
||||||
color = [eclass drawColor];
|
color =[eclass drawColor];
|
||||||
|
|
||||||
c = [self count];
|
c =[self count];
|
||||||
for (i=0 ; i<c ; i++)
|
for (i = 0; i < c; i++) {
|
||||||
{
|
brush =[self objectAtIndex:i];
|
||||||
brush = [self objectAtIndex: i];
|
[brush setEntityColor:color];
|
||||||
[brush setEntityColor: color];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- writeToFILE: (FILE *)f region:(BOOL)reg;
|
-writeToFILE:(FILE *)
|
||||||
|
f region:(BOOL) reg;
|
||||||
{
|
{
|
||||||
epair_t *e;
|
epair_t *e;
|
||||||
int i;
|
int i;
|
||||||
id new;
|
id new;
|
||||||
char value[80];
|
char value[80];
|
||||||
vec3_t mins, maxs, org;
|
vec3_t mins, maxs, org;
|
||||||
const vec_t *v;
|
const vec_t *v;
|
||||||
BOOL temporg;
|
BOOL temporg;
|
||||||
char oldang[80];
|
char oldang[80];
|
||||||
|
|
||||||
temporg = NO;
|
temporg = NO;
|
||||||
if (reg)
|
if (reg) {
|
||||||
{
|
if (!strcmp ([self valueForQKey:"classname"], "info_player_start")) {
|
||||||
if ( !strcmp ([self valueForQKey: "classname"], "info_player_start") )
|
// move the playerstart
|
||||||
{ // move the playerstart temporarily to the camera position
|
// temporarily to the camera
|
||||||
|
// position
|
||||||
temporg = YES;
|
temporg = YES;
|
||||||
strcpy (oldang, [self valueForQKey: "angle"]);
|
strcpy (oldang,[self valueForQKey:"angle"]);
|
||||||
sprintf (value, "%i", (int)([cameraview_i yawAngle]*180/M_PI));
|
sprintf (value, "%i", (int) ([cameraview_i yawAngle] * 180 / M_PI));
|
||||||
[self setKey: "angle" toValue: value];
|
[self setKey: "angle" toValue:value];
|
||||||
}
|
} else if (self !=[map_i objectAtIndex:0]
|
||||||
else if ( self != [map_i objectAtIndex: 0]
|
&&[[self objectAtIndex:0] regioned])
|
||||||
&& [[self objectAtIndex: 0] regioned] )
|
return self; // skip the entire entity definition
|
||||||
return self; // skip the entire entity definition
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (f,"{\n");
|
fprintf (f, "{\n");
|
||||||
|
|
||||||
// set an origin epair
|
// set an origin epair
|
||||||
if (!modifiable)
|
if (!modifiable) {
|
||||||
{
|
[[self objectAtIndex: 0] getMins: mins maxs:maxs];
|
||||||
[[self objectAtIndex: 0] getMins: mins maxs: maxs];
|
if (temporg) {
|
||||||
if (temporg)
|
[cameraview_i getOrigin:mins];
|
||||||
{
|
|
||||||
[cameraview_i getOrigin: mins];
|
|
||||||
mins[0] -= 16;
|
mins[0] -= 16;
|
||||||
mins[1] -= 16;
|
mins[1] -= 16;
|
||||||
mins[2] -= 48;
|
mins[2] -= 48;
|
||||||
}
|
}
|
||||||
new = [entity_classes_i classForName:
|
new =[entity_classes_i classForName:
|
||||||
[self valueForQKey: "classname"]];
|
[self valueForQKey:"classname"]];
|
||||||
if (new)
|
if (new)
|
||||||
v = [new mins];
|
v =[new mins];
|
||||||
else
|
else
|
||||||
v = vec3_origin;
|
v = vec3_origin;
|
||||||
|
|
||||||
VectorSubtract (mins, v, org);
|
VectorSubtract (mins, v, org);
|
||||||
sprintf (value, "%i %i %i",(int)org[0], (int)org[1], (int)org[2]);
|
sprintf (value, "%i %i %i", (int) org[0], (int) org[1], (int) org[2]);
|
||||||
[self setKey:"origin" toValue: value];
|
[self setKey: "origin" toValue:value];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (e=epairs ; e ; e=e->next)
|
for (e = epairs; e; e = e->next)
|
||||||
fprintf (f,"\"%s\"\t\"%s\"\n", e->key, e->value);
|
fprintf (f, "\"%s\"\t\"%s\"\n", e->key, e->value);
|
||||||
|
|
||||||
// fixed size entities don't save out brushes
|
// fixed size entities don't save out brushes
|
||||||
if ( modifiable )
|
if (modifiable) {
|
||||||
{
|
for (i = 0; i <[self count]; i++)
|
||||||
for (i = 0 ; i < [self count]; i++)
|
[[self objectAtIndex: i] writeToFILE: f region:reg];
|
||||||
[[self objectAtIndex: i] writeToFILE: f region: reg];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (f,"}\n");
|
fprintf (f, "}\n");
|
||||||
|
|
||||||
if (temporg)
|
if (temporg)
|
||||||
[self setKey: "angle" toValue: oldang];
|
[self setKey: "angle" toValue:oldang];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
@implementation EntityClass
|
@implementation EntityClass
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_vector (script_t *script, vec3_t vec)
|
parse_vector (script_t * script, vec3_t vec)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ parse_vector (script_t *script, vec3_t vec)
|
||||||
r = sscanf (script->p, "%f %f %f)", &vec[0], &vec[1], &vec[2]);
|
r = sscanf (script->p, "%f %f %f)", &vec[0], &vec[1], &vec[2]);
|
||||||
if (r != 3)
|
if (r != 3)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while (strcmp (script->token->str, ")")) {
|
while (strcmp (script->token->str, ")")) {
|
||||||
if (!Script_GetToken (script, 0))
|
if (!Script_GetToken (script, 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -41,16 +41,17 @@ parse_vector (script_t *script, vec3_t vec)
|
||||||
//
|
//
|
||||||
// /*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY SILVER_KEY
|
// /*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY SILVER_KEY
|
||||||
|
|
||||||
- initFromText: (const char *)text source: (const char *)filename
|
-initFromText:(const char *)
|
||||||
|
text source:(const char *) filename
|
||||||
{
|
{
|
||||||
const char *t;
|
const char *t;
|
||||||
size_t len;
|
size_t len;
|
||||||
int i;
|
int i;
|
||||||
script_t *script;
|
script_t *script;
|
||||||
|
|
||||||
[super init];
|
[super init];
|
||||||
|
|
||||||
text += strlen("/*QUAKED ");
|
text += strlen ("/*QUAKED ");
|
||||||
|
|
||||||
script = Script_New ();
|
script = Script_New ();
|
||||||
Script_Start (script, filename, text);
|
Script_Start (script, filename, text);
|
||||||
|
@ -65,8 +66,8 @@ parse_vector (script_t *script, vec3_t vec)
|
||||||
// grab the color
|
// grab the color
|
||||||
if (!parse_vector (script, color))
|
if (!parse_vector (script, color))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// get the size
|
// get the size
|
||||||
if (!strcmp (script->token->str, "(")) {
|
if (!strcmp (script->token->str, "(")) {
|
||||||
Script_UngetToken (script);
|
Script_UngetToken (script);
|
||||||
if (!parse_vector (script, mins))
|
if (!parse_vector (script, mins))
|
||||||
|
@ -80,7 +81,7 @@ parse_vector (script_t *script, vec3_t vec)
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the flags
|
// get the flags
|
||||||
// any remaining words on the line are parm flags
|
// any remaining words on the line are parm flags
|
||||||
for (i = 0; i < MAX_FLAGS; i++) {
|
for (i = 0; i < MAX_FLAGS; i++) {
|
||||||
|
@ -93,50 +94,49 @@ parse_vector (script_t *script, vec3_t vec)
|
||||||
Script_GetToken (script, 0);
|
Script_GetToken (script, 0);
|
||||||
|
|
||||||
// find the length until close comment
|
// find the length until close comment
|
||||||
for (t = script->p; t[0] && !(t[0] == '*' && t[1] == '/'); t++)
|
for (t = script->p; t[0] && !(t[0] == '*' && t[1] == '/'); t++);
|
||||||
;
|
|
||||||
|
|
||||||
// copy the comment block out
|
// copy the comment block out
|
||||||
len = t - text;
|
len = t - text;
|
||||||
comments = malloc (len + 1);
|
comments = malloc (len + 1);
|
||||||
memcpy (comments, text, len);
|
memcpy (comments, text, len);
|
||||||
comments[len] = 0;
|
comments[len] = 0;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (esize_t)esize
|
-(esize_t) esize
|
||||||
{
|
{
|
||||||
return esize;
|
return esize;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *)classname
|
-(char *) classname
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float *)mins
|
-(float *) mins
|
||||||
{
|
{
|
||||||
return mins;
|
return mins;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float *)maxs
|
-(float *) maxs
|
||||||
{
|
{
|
||||||
return maxs;
|
return maxs;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float *)drawColor
|
-(float *) drawColor
|
||||||
{
|
{
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *)comments
|
-(char *) comments
|
||||||
{
|
{
|
||||||
return comments;
|
return comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (char *)flagName: (unsigned)flagnum
|
-(char *) flagName:(unsigned) flagnum
|
||||||
{
|
{
|
||||||
if (flagnum >= MAX_FLAGS)
|
if (flagnum >= MAX_FLAGS)
|
||||||
Sys_Error ("EntityClass flagName: bad number");
|
Sys_Error ("EntityClass flagName: bad number");
|
||||||
|
@ -144,31 +144,27 @@ parse_vector (script_t *script, vec3_t vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
@implementation EntityClassList
|
@implementation EntityClassList
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
insertEC:
|
insertEC:
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
- (void)insertEC: ec
|
- (void) insertEC:ec
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
name = [ec classname];
|
name =[ec classname];
|
||||||
for (i=0 ; i<[self count] ; i++)
|
for (i = 0; i <[self count]; i++) {
|
||||||
{
|
if (strcasecmp (name,[[self objectAtIndex:i] classname]) < 0) {
|
||||||
if (strcasecmp (name, [[self objectAtIndex: i] classname]) < 0)
|
|
||||||
{
|
|
||||||
[self insertObject: ec atIndex:i];
|
[self insertObject: ec atIndex:i];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[self addObject: ec];
|
[self addObject:ec];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,16 +173,16 @@ insertEC:
|
||||||
scanFile
|
scanFile
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
- (void)scanFile: (char *)filename
|
-(void) scanFile:(char *) filename
|
||||||
{
|
{
|
||||||
int size, line;
|
int size, line;
|
||||||
char *data;
|
char *data;
|
||||||
id cl;
|
id cl;
|
||||||
int i;
|
int i;
|
||||||
char path[1024];
|
char path[1024];
|
||||||
QFile *file;
|
QFile *file;
|
||||||
|
|
||||||
sprintf (path,"%s/%s", source_path, filename);
|
sprintf (path, "%s/%s", source_path, filename);
|
||||||
|
|
||||||
file = Qopen (path, "rt");
|
file = Qopen (path, "rt");
|
||||||
if (!file)
|
if (!file)
|
||||||
|
@ -198,12 +194,12 @@ scanFile
|
||||||
Qclose (file);
|
Qclose (file);
|
||||||
|
|
||||||
line = 1;
|
line = 1;
|
||||||
for (i=0 ; i<size ; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
if (!strncmp(data+i, "/*QUAKED",8)) {
|
if (!strncmp (data + i, "/*QUAKED", 8)) {
|
||||||
cl = [[EntityClass alloc] initFromText: (data + i)
|
cl =[[EntityClass alloc] initFromText:(data + i)
|
||||||
source: va ("%s:%d", filename, line)];
|
source:va ("%s:%d", filename, line)];
|
||||||
if (cl)
|
if (cl)
|
||||||
[self insertEC: cl];
|
[self insertEC:cl];
|
||||||
} else if (data[i] == '\n') {
|
} else if (data[i] == '\n') {
|
||||||
line++;
|
line++;
|
||||||
}
|
}
|
||||||
|
@ -218,62 +214,61 @@ scanFile
|
||||||
scanDirectory
|
scanDirectory
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
- (void)scanDirectory
|
-(void) scanDirectory
|
||||||
{
|
{
|
||||||
int count, i;
|
int count, i;
|
||||||
struct dirent **namelist, *ent;
|
struct dirent **namelist, *ent;
|
||||||
|
|
||||||
[self removeAllObjects];
|
[self removeAllObjects];
|
||||||
|
|
||||||
count = scandir(source_path, &namelist, NULL, NULL);
|
count = scandir (source_path, &namelist, NULL, NULL);
|
||||||
|
|
||||||
for (i=0 ; i<count ; i++)
|
for (i = 0; i < count; i++) {
|
||||||
{
|
int len;
|
||||||
int len;
|
|
||||||
ent = namelist[i];
|
ent = namelist[i];
|
||||||
len = strlen (ent->d_name);
|
len = strlen (ent->d_name);
|
||||||
if (len <= 3)
|
if (len <= 3)
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp (ent->d_name+len-3,".qc"))
|
if (!strcmp (ent->d_name + len - 3, ".qc"))
|
||||||
[self scanFile: ent->d_name];
|
[self scanFile:ent->d_name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
id entity_classes_i;
|
id entity_classes_i;
|
||||||
|
|
||||||
|
|
||||||
- initForSourceDirectory: (char *)path
|
-initForSourceDirectory:(char *) path
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
|
|
||||||
source_path = path;
|
source_path = path;
|
||||||
[self scanDirectory];
|
[self scanDirectory];
|
||||||
|
|
||||||
entity_classes_i = self;
|
entity_classes_i = self;
|
||||||
|
|
||||||
nullclass = [[EntityClass alloc]
|
nullclass =[[EntityClass alloc]
|
||||||
initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/"
|
initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/" source:va ("%s:%d", __FILE__,
|
||||||
source: va ("%s:%d", __FILE__, __LINE__ - 1)];
|
__LINE__ -
|
||||||
|
1)];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)classForName: (char *)name
|
-(id) classForName:(char *) name
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
id o;
|
id o;
|
||||||
|
|
||||||
for (i=0 ; i<[self count] ; i++)
|
for (i = 0; i <[self count]; i++) {
|
||||||
{
|
o =[self objectAtIndex:i];
|
||||||
o = [self objectAtIndex: i];
|
if (!strcmp (name,[o classname]))
|
||||||
if (!strcmp (name,[o classname]) )
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullclass;
|
return nullclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,18 @@
|
||||||
#include "TexturePalette.h"
|
#include "TexturePalette.h"
|
||||||
#include "Preferences.h"
|
#include "Preferences.h"
|
||||||
|
|
||||||
id inspcontrol_i;
|
id inspcontrol_i;
|
||||||
|
|
||||||
@implementation InspectorControl
|
@implementation InspectorControl
|
||||||
|
|
||||||
- awakeFromNib
|
-awakeFromNib {
|
||||||
{
|
|
||||||
inspcontrol_i = self;
|
inspcontrol_i = self;
|
||||||
|
|
||||||
currentInspectorType = -1;
|
currentInspectorType = -1;
|
||||||
|
|
||||||
contentList = [[NSArray alloc] init];
|
contentList =[[NSArray alloc] init];
|
||||||
windowList = [[NSArray alloc] init];
|
windowList =[[NSArray alloc] init];
|
||||||
itemList = [[NSArray alloc] init];
|
itemList =[[NSArray alloc] init];
|
||||||
|
|
||||||
// ADD NEW INSPECTORS HERE...
|
// ADD NEW INSPECTORS HERE...
|
||||||
|
|
||||||
|
@ -36,7 +35,7 @@ id inspcontrol_i;
|
||||||
[contentList addObject:[win_things_i contentView]];
|
[contentList addObject:[win_things_i contentView]];
|
||||||
[itemThings_i setKeyEquivalent:@"3"];
|
[itemThings_i setKeyEquivalent:@"3"];
|
||||||
[itemList addObject:itemThings_i];
|
[itemList addObject:itemThings_i];
|
||||||
|
|
||||||
[windowList addObject:win_prefs_i];
|
[windowList addObject:win_prefs_i];
|
||||||
[contentList addObject:[win_prefs_i contentView]];
|
[contentList addObject:[win_prefs_i contentView]];
|
||||||
[itemPrefs_i setKeyEquivalent:@"4"];
|
[itemPrefs_i setKeyEquivalent:@"4"];
|
||||||
|
@ -61,7 +60,7 @@ id inspcontrol_i;
|
||||||
|
|
||||||
[inspectorView_i setAutoresizesSubviews:YES];
|
[inspectorView_i setAutoresizesSubviews:YES];
|
||||||
|
|
||||||
inspectorSubview_i = [contentList objectAtIndex:i_project];
|
inspectorSubview_i =[contentList objectAtIndex:i_project];
|
||||||
[inspectorView_i addSubview:inspectorSubview_i];
|
[inspectorView_i addSubview:inspectorSubview_i];
|
||||||
|
|
||||||
currentInspectorType = -1;
|
currentInspectorType = -1;
|
||||||
|
@ -72,56 +71,57 @@ id inspcontrol_i;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sent by the PopUpList in the Inspector
|
// Sent by the PopUpList in the Inspector
|
||||||
// Each cell in the PopUpList must have the correct tag
|
// Each cell in the PopUpList must have the correct tag
|
||||||
//
|
//
|
||||||
- changeInspector:sender
|
-changeInspector:sender
|
||||||
{
|
{
|
||||||
id cell;
|
id cell;
|
||||||
|
|
||||||
cell = [sender selectedCell];
|
cell =[sender selectedCell];
|
||||||
[self changeInspectorTo:[cell tag]];
|
[self changeInspectorTo:[cell tag]];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Change to specific Inspector
|
// Change to specific Inspector
|
||||||
//
|
//
|
||||||
- changeInspectorTo:(insp_e)which
|
-changeInspectorTo:(insp_e) which
|
||||||
{
|
{
|
||||||
id newView;
|
id newView;
|
||||||
NSRect r;
|
NSRect r;
|
||||||
id cell;
|
id cell;
|
||||||
NSRect f;
|
NSRect f;
|
||||||
|
|
||||||
if (which == currentInspectorType)
|
if (which == currentInspectorType)
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
currentInspectorType = which;
|
currentInspectorType = which;
|
||||||
newView = [contentList objectAtIndex:which];
|
newView =[contentList objectAtIndex:which];
|
||||||
|
|
||||||
cell = [itemList objectAtIndex:which]; // set PopUpButton title
|
cell =[itemList objectAtIndex:which];// set PopUpButton title
|
||||||
[popUpButton_i setTitle:[cell title]];
|
[popUpButton_i setTitle:[cell title]];
|
||||||
|
|
||||||
[inspectorView_i replaceSubview:inspectorSubview_i with:newView];
|
[inspectorView_i replaceSubview: inspectorSubview_i with:newView];
|
||||||
r = [inspectorView_i frame];
|
r =[inspectorView_i frame];
|
||||||
inspectorSubview_i = newView;
|
inspectorSubview_i = newView;
|
||||||
[inspectorSubview_i setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[inspectorSubview_i setAutoresizingMask:NSViewWidthSizable |
|
||||||
|
NSViewHeightSizable];
|
||||||
r.size.width -= 4;
|
r.size.width -= 4;
|
||||||
r.size.height -= 4;
|
r.size.height -= 4;
|
||||||
[inspectorSubview_i setFrameSize:r.size];
|
[inspectorSubview_i setFrameSize:r.size];
|
||||||
|
|
||||||
[inspectorSubview_i lockFocus];
|
[inspectorSubview_i lockFocus];
|
||||||
f = [inspectorSubview_i bounds];
|
f =[inspectorSubview_i bounds];
|
||||||
PSsetgray(NSLightGray);
|
PSsetgray (NSLightGray);
|
||||||
NSRectFill(f);
|
NSRectFill (f);
|
||||||
[inspectorSubview_i unlockFocus];
|
[inspectorSubview_i unlockFocus];
|
||||||
[inspectorView_i display];
|
[inspectorView_i display];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (insp_e)getCurrentInspector
|
-(insp_e) getCurrentInspector
|
||||||
{
|
{
|
||||||
return currentInspectorType;
|
return currentInspectorType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,15 @@
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "Things.h"
|
#include "Things.h"
|
||||||
|
|
||||||
id keypairview_i;
|
id keypairview_i;
|
||||||
|
|
||||||
@implementation KeypairView
|
@implementation KeypairView
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
initWithFrame:
|
initWithFrame:
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
- initWithFrame:(NSRect)frameRect
|
- initWithFrame:(NSRect) frameRect
|
||||||
{
|
{
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame:frameRect];
|
||||||
keypairview_i = self;
|
keypairview_i = self;
|
||||||
|
@ -21,75 +20,73 @@ initWithFrame:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- calcViewSize
|
-calcViewSize
|
||||||
{
|
{
|
||||||
NSRect b;
|
NSRect b;
|
||||||
NSPoint pt;
|
NSPoint pt;
|
||||||
int count;
|
int count;
|
||||||
id ent;
|
id ent;
|
||||||
|
|
||||||
ent = [map_i currentEntity];
|
|
||||||
count = [ent numPairs];
|
|
||||||
|
|
||||||
//XXX[_super_view setFlipped: YES];
|
ent =[map_i currentEntity];
|
||||||
|
count =[ent numPairs];
|
||||||
b = [_super_view bounds];
|
|
||||||
b.size.height = LINEHEIGHT*count + SPACING;
|
// XXX[_super_view setFlipped: YES];
|
||||||
[self setBounds: b];
|
|
||||||
|
b =[_super_view bounds];
|
||||||
|
b.size.height = LINEHEIGHT * count + SPACING;
|
||||||
|
[self setBounds:b];
|
||||||
pt.x = pt.y = 0;
|
pt.x = pt.y = 0;
|
||||||
[self scrollPoint: pt];
|
[self scrollPoint:pt];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- drawSelf:(const NSRect *)rects :(int)rectCount
|
-drawSelf: (const NSRect *) rects:(int) rectCount
|
||||||
{
|
{
|
||||||
epair_t *pair;
|
epair_t *pair;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
//XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
// XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
||||||
PSrectfill(0,0,_bounds.size.width,_bounds.size.height);
|
PSrectfill (0, 0, _bounds.size.width, _bounds.size.height);
|
||||||
|
|
||||||
//XXX PSselectfont("Helvetica-Bold",FONTSIZE);
|
// XXX PSselectfont("Helvetica-Bold",FONTSIZE);
|
||||||
PSrotate(0);
|
PSrotate (0);
|
||||||
PSsetgray(0);
|
PSsetgray (0);
|
||||||
|
|
||||||
pair = [[map_i currentEntity] epairs];
|
pair =[[map_i currentEntity] epairs];
|
||||||
y = _bounds.size.height - LINEHEIGHT;
|
y = _bounds.size.height - LINEHEIGHT;
|
||||||
for ( ; pair ; pair=pair->next)
|
for (; pair; pair = pair->next) {
|
||||||
{
|
PSmoveto (SPACING, y);
|
||||||
PSmoveto(SPACING, y);
|
PSshow (pair->key);
|
||||||
PSshow(pair->key);
|
PSmoveto (100, y);
|
||||||
PSmoveto(100, y);
|
PSshow (pair->value);
|
||||||
PSshow(pair->value);
|
|
||||||
y -= LINEHEIGHT;
|
y -= LINEHEIGHT;
|
||||||
}
|
}
|
||||||
PSstroke();
|
PSstroke ();
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDown:(NSEvent *)theEvent
|
-(void) mouseDown:(NSEvent *) theEvent
|
||||||
{
|
{
|
||||||
NSPoint loc;
|
NSPoint loc;
|
||||||
int i;
|
int i;
|
||||||
epair_t *p;
|
epair_t *p;
|
||||||
|
|
||||||
|
loc =[theEvent locationInWindow];
|
||||||
|
loc =[self convertPoint: loc fromView:NULL];
|
||||||
|
|
||||||
loc = [theEvent locationInWindow];
|
|
||||||
loc = [self convertPoint:loc fromView:NULL];
|
|
||||||
|
|
||||||
i = (_bounds.size.height - loc.y - 4) / LINEHEIGHT;
|
i = (_bounds.size.height - loc.y - 4) / LINEHEIGHT;
|
||||||
|
|
||||||
p = [[map_i currentEntity] epairs];
|
p =[[map_i currentEntity] epairs];
|
||||||
while ( i )
|
while (i) {
|
||||||
{
|
p = p->next;
|
||||||
p=p->next;
|
|
||||||
if (!p)
|
if (!p)
|
||||||
return;
|
return;
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
if (p)
|
if (p)
|
||||||
[things_i setSelectedKey: p];
|
[things_i setSelectedKey:p];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,6 @@
|
||||||
#include "PopScrollView.h"
|
#include "PopScrollView.h"
|
||||||
|
|
||||||
@implementation PopScrollView
|
@implementation PopScrollView
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
initWithFrame: button:
|
initWithFrame: button:
|
||||||
|
@ -10,57 +9,52 @@ initWithFrame: button:
|
||||||
Initizes a scroll view with a button at it's lower right corner
|
Initizes a scroll view with a button at it's lower right corner
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
|
- initWithFrame:(NSRect)
|
||||||
|
frameRect button1:b1 button2:b2 {
|
||||||
|
[super initWithFrame:frameRect];
|
||||||
|
|
||||||
- initWithFrame:(NSRect)frameRect button1:b1 button2:b2
|
[self addSubview:b1];
|
||||||
{
|
[self addSubview:b2];
|
||||||
[super initWithFrame: frameRect];
|
|
||||||
|
|
||||||
[self addSubview: b1];
|
|
||||||
[self addSubview: b2];
|
|
||||||
|
|
||||||
button1 = b1;
|
button1 = b1;
|
||||||
button2 = b2;
|
button2 = b2;
|
||||||
|
|
||||||
[self setHasHorizontalScroller: YES];
|
[self setHasHorizontalScroller:YES];
|
||||||
[self setHasVerticalScroller: YES];
|
[self setHasVerticalScroller:YES];
|
||||||
|
|
||||||
|
[self setBorderType:NSBezelBorder];
|
||||||
|
|
||||||
[self setBorderType: NSBezelBorder];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
tile
|
tile
|
||||||
|
|
||||||
Adjust the size for the pop up scale menu
|
Adjust the size for the pop up scale menu
|
||||||
=================
|
=================
|
||||||
*/
|
*/ -tile
|
||||||
|
|
||||||
- tile
|
|
||||||
{
|
{
|
||||||
NSRect scrollerframe;
|
NSRect scrollerframe;
|
||||||
NSRect buttonframe, buttonframe2;
|
NSRect buttonframe, buttonframe2;
|
||||||
NSRect newframe;
|
NSRect newframe;
|
||||||
|
|
||||||
[super tile];
|
[super tile];
|
||||||
buttonframe = [button1 frame];
|
buttonframe =[button1 frame];
|
||||||
buttonframe2 = [button2 frame];
|
buttonframe2 =[button2 frame];
|
||||||
scrollerframe = [_horizScroller frame];
|
scrollerframe =[_horizScroller frame];
|
||||||
|
|
||||||
newframe.origin.y = scrollerframe.origin.y;
|
newframe.origin.y = scrollerframe.origin.y;
|
||||||
newframe.origin.x = scrollerframe.size.width - buttonframe.size.width;
|
newframe.origin.x = scrollerframe.size.width - buttonframe.size.width;
|
||||||
newframe.size.width = buttonframe.size.width;
|
newframe.size.width = buttonframe.size.width;
|
||||||
newframe.size.height = scrollerframe.size.height;
|
newframe.size.height = scrollerframe.size.height;
|
||||||
scrollerframe.size.width -= newframe.size.width;
|
scrollerframe.size.width -= newframe.size.width;
|
||||||
[button1 setFrame: newframe];
|
[button1 setFrame:newframe];
|
||||||
newframe.size.width = buttonframe2.size.width;
|
newframe.size.width = buttonframe2.size.width;
|
||||||
newframe.origin.x -= newframe.size.width;
|
newframe.origin.x -= newframe.size.width;
|
||||||
[button2 setFrame: newframe];
|
[button2 setFrame:newframe];
|
||||||
scrollerframe.size.width -= newframe.size.width;
|
scrollerframe.size.width -= newframe.size.width;
|
||||||
|
|
||||||
[_horizScroller setFrame: scrollerframe];
|
[_horizScroller setFrame:scrollerframe];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -78,10 +72,9 @@ Adjust the size for the pop up scale menu
|
||||||
|
|
||||||
-(BOOL) acceptsFirstResponder
|
-(BOOL) acceptsFirstResponder
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -4,84 +4,90 @@
|
||||||
#include "QuakeEd.h"
|
#include "QuakeEd.h"
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
|
|
||||||
id preferences_i;
|
id preferences_i;
|
||||||
|
|
||||||
#define DEFOWNER "QuakeEd2"
|
#define DEFOWNER "QuakeEd2"
|
||||||
|
|
||||||
float lightaxis[3] = {1, 0.6, 0.75};
|
float lightaxis[3] = { 1, 0.6, 0.75 };
|
||||||
|
|
||||||
@implementation Preferences
|
@implementation Preferences
|
||||||
|
|
||||||
- init
|
-init
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
preferences_i = self;
|
preferences_i = self;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _atoi (char *c)
|
int
|
||||||
|
_atoi (char *c)
|
||||||
{
|
{
|
||||||
if (!c)
|
if (!c)
|
||||||
return 0;
|
return 0;
|
||||||
return atoi(c);
|
return atoi (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _atof (char *c)
|
int
|
||||||
|
_atof (char *c)
|
||||||
{
|
{
|
||||||
if (!c)
|
if (!c)
|
||||||
return 0;
|
return 0;
|
||||||
return atof(c);
|
return atof (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteNumericDefault (char *name, float value)
|
void
|
||||||
|
WriteNumericDefault (char *name, float value)
|
||||||
{
|
{
|
||||||
char str[128];
|
char str[128];
|
||||||
|
|
||||||
sprintf (str,"%f", value);
|
sprintf (str, "%f", value);
|
||||||
//XXX NSWriteDefault (DEFOWNER, name, str);
|
// XXX NSWriteDefault (DEFOWNER, name, str);
|
||||||
}
|
}
|
||||||
void WriteStringDefault (char *name, char *value)
|
|
||||||
|
void
|
||||||
|
WriteStringDefault (char *name, char *value)
|
||||||
{
|
{
|
||||||
//XXX NSWriteDefault (DEFOWNER, name, value);
|
// XXX NSWriteDefault (DEFOWNER, name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read in at start of program
|
// Read in at start of program
|
||||||
//
|
//
|
||||||
- readDefaults
|
-readDefaults
|
||||||
{
|
{
|
||||||
char *string = "";
|
char *string = "";
|
||||||
float value = 0;
|
float value = 0;
|
||||||
|
|
||||||
//XXX string = (char *)NSGetDefaultValue(DEFOWNER,"ProjectPath");
|
// XXX string = (char *)NSGetDefaultValue(DEFOWNER,"ProjectPath");
|
||||||
[self setProjectPath: string];
|
[self setProjectPath:string];
|
||||||
|
|
||||||
//XXX string = (char *)NSGetDefaultValue(DEFOWNER,"BspSoundPath");
|
// XXX string = (char *)NSGetDefaultValue(DEFOWNER,"BspSoundPath");
|
||||||
[self setBspSoundPath:string];
|
[self setBspSoundPath:string];
|
||||||
|
|
||||||
//XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"ShowBSPOutput"));
|
// XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"ShowBSPOutput"));
|
||||||
[self setShowBSP:value];
|
[self setShowBSP:value];
|
||||||
|
|
||||||
//XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"OffsetBrushCopy"));
|
// XXX value = _atoi((char
|
||||||
|
// *)NSGetDefaultValue(DEFOWNER,"OffsetBrushCopy"));
|
||||||
[self setBrushOffset:value];
|
[self setBrushOffset:value];
|
||||||
|
|
||||||
//XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"StartWad"));
|
// XXX value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"StartWad"));
|
||||||
[self setStartWad:value];
|
[self setStartWad:value];
|
||||||
|
|
||||||
//XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Xlight"));
|
// XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Xlight"));
|
||||||
[self setXlight:value];
|
[self setXlight:value];
|
||||||
|
|
||||||
//XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Ylight"));
|
// XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Ylight"));
|
||||||
[self setYlight:value];
|
[self setYlight:value];
|
||||||
|
|
||||||
//XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Zlight"));
|
// XXX value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Zlight"));
|
||||||
[self setZlight:value];
|
[self setZlight:value];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- setProjectPath:(char *)path
|
-setProjectPath:(char *) path
|
||||||
{
|
{
|
||||||
if (!path)
|
if (!path)
|
||||||
path = "";
|
path = "";
|
||||||
|
@ -91,14 +97,15 @@ void WriteStringDefault (char *name, char *value)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- setCurrentProject:sender
|
-setCurrentProject:sender
|
||||||
{
|
{
|
||||||
[startproject_i setStringValue: [NSString stringWithCString:[project_i currentProjectFile]]];
|
[startproject_i setStringValue: [NSString stringWithCString:[project_i
|
||||||
[self UIChanged: self];
|
currentProjectFile]]];
|
||||||
|
[self UIChanged:self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *)getProjectPath
|
-(char *) getProjectPath
|
||||||
{
|
{
|
||||||
return projectpath;
|
return projectpath;
|
||||||
}
|
}
|
||||||
|
@ -106,35 +113,33 @@ void WriteStringDefault (char *name, char *value)
|
||||||
|
|
||||||
//
|
//
|
||||||
//===============================================
|
//===============================================
|
||||||
// BSP sound stuff
|
// BSP sound stuff
|
||||||
//===============================================
|
//===============================================
|
||||||
//
|
//
|
||||||
// Set the BSP sound using an OpenPanel
|
// Set the BSP sound using an OpenPanel
|
||||||
//
|
//
|
||||||
- setBspSound:sender
|
-setBspSound:sender
|
||||||
{
|
{
|
||||||
id panel;
|
id panel;
|
||||||
NSString *types[] = {@"snd"};
|
NSString *types[] = { @"snd" };
|
||||||
int rtn;
|
int rtn;
|
||||||
NSArray *filenames;
|
NSArray *filenames;
|
||||||
char path[1024], file[64];
|
char path[1024], file[64];
|
||||||
|
|
||||||
panel = [NSOpenPanel new];
|
|
||||||
|
|
||||||
//XXX ExtractFilePath (bspSound, path);
|
panel =[NSOpenPanel new];
|
||||||
//XXX ExtractFileBase (bspSound, file);
|
|
||||||
|
|
||||||
rtn = [panel
|
|
||||||
runModalForDirectory:[NSString stringWithCString:path]
|
|
||||||
file: [NSString stringWithCString:file]
|
|
||||||
types: [NSArray arrayWithObjects:types count:1]];
|
|
||||||
|
|
||||||
if (rtn)
|
// XXX ExtractFilePath (bspSound, path);
|
||||||
{
|
// XXX ExtractFileBase (bspSound, file);
|
||||||
filenames = [panel filenames];
|
|
||||||
strcpy(bspSound,[[panel directory] cString]);
|
rtn =[panel runModalForDirectory: [NSString stringWithCString:path]
|
||||||
strcat(bspSound,"/");
|
file: [NSString stringWithCString:file]
|
||||||
strcat(bspSound, [[filenames objectAtIndex:0] cString]);
|
types: [NSArray arrayWithObjects: types count:1]];
|
||||||
|
|
||||||
|
if (rtn) {
|
||||||
|
filenames =[panel filenames];
|
||||||
|
strcpy (bspSound,[[panel directory] cString]);
|
||||||
|
strcat (bspSound, "/");
|
||||||
|
strcat (bspSound,[[filenames objectAtIndex:0] cString]);
|
||||||
[self setBspSoundPath:bspSound];
|
[self setBspSoundPath:bspSound];
|
||||||
[self playBspSound];
|
[self playBspSound];
|
||||||
}
|
}
|
||||||
|
@ -144,48 +149,47 @@ void WriteStringDefault (char *name, char *value)
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Play the BSP sound
|
// Play the BSP sound
|
||||||
//
|
//
|
||||||
- playBspSound
|
-playBspSound
|
||||||
{
|
{
|
||||||
[bspSound_i play];
|
[bspSound_i play];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the bspSound path
|
// Set the bspSound path
|
||||||
//
|
//
|
||||||
- setBspSoundPath:(char *)path
|
-setBspSoundPath:(char *) path
|
||||||
{
|
{
|
||||||
if (!path)
|
if (!path)
|
||||||
path = "";
|
path = "";
|
||||||
strcpy(bspSound,path);
|
strcpy (bspSound, path);
|
||||||
|
|
||||||
if (bspSound_i)
|
if (bspSound_i)
|
||||||
[bspSound_i release];
|
[bspSound_i release];
|
||||||
bspSound_i = [[NSSound alloc] initWithContentsOfFile:[NSString stringWithCString:bspSound]];
|
bspSound_i =[[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString:bspSound]];
|
||||||
if (!bspSound_i)
|
if (!bspSound_i) {
|
||||||
{
|
|
||||||
strcpy (bspSound, "/NextLibrary/Sounds/Funk.snd");
|
strcpy (bspSound, "/NextLibrary/Sounds/Funk.snd");
|
||||||
bspSound_i = [[NSSound alloc] initWithContentsOfFile:[NSString stringWithCString:bspSound]];
|
bspSound_i =[[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString:bspSound]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[bspSoundField_i setStringValue:[NSString stringWithCString:bspSound]];
|
[bspSoundField_i setStringValue: [NSString stringWithCString:bspSound]];
|
||||||
|
|
||||||
WriteStringDefault ("BspSoundPath", bspSound);
|
WriteStringDefault ("BspSoundPath", bspSound);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
//===============================================
|
||||||
// Show BSP Output management
|
// Show BSP Output management
|
||||||
//===============================================
|
//===============================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the state
|
// Set the state
|
||||||
//
|
//
|
||||||
- setShowBSP:(int)state
|
-setShowBSP:(int) state
|
||||||
{
|
{
|
||||||
showBSP = state;
|
showBSP = state;
|
||||||
[showBSP_i setIntValue:state];
|
[showBSP_i setIntValue:state];
|
||||||
|
@ -195,22 +199,22 @@ void WriteStringDefault (char *name, char *value)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the state
|
// Get the state
|
||||||
//
|
//
|
||||||
- (int)getShowBSP
|
-(int) getShowBSP
|
||||||
{
|
{
|
||||||
return showBSP;
|
return showBSP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===============================================
|
//===============================================
|
||||||
// "Offset Brush ..." management
|
// "Offset Brush ..." management
|
||||||
//===============================================
|
//===============================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the state
|
// Set the state
|
||||||
//
|
//
|
||||||
- setBrushOffset:(int)state
|
-setBrushOffset:(int) state
|
||||||
{
|
{
|
||||||
brushOffset = state;
|
brushOffset = state;
|
||||||
[brushOffset_i setIntValue:state];
|
[brushOffset_i setIntValue:state];
|
||||||
|
@ -219,42 +223,42 @@ void WriteStringDefault (char *name, char *value)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the state
|
// Get the state
|
||||||
//
|
//
|
||||||
- (int)getBrushOffset
|
-(int) getBrushOffset
|
||||||
{
|
{
|
||||||
return brushOffset;
|
return brushOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===============================================
|
//===============================================
|
||||||
// StartWad
|
// StartWad
|
||||||
//===============================================
|
//===============================================
|
||||||
|
|
||||||
- setStartWad:(int)value // set start wad (0-2)
|
-setStartWad:(int) value // set start wad (0-2)
|
||||||
{
|
{
|
||||||
startwad = value;
|
startwad = value;
|
||||||
if (startwad<0 || startwad>2)
|
if (startwad < 0 || startwad > 2)
|
||||||
startwad = 0;
|
startwad = 0;
|
||||||
|
|
||||||
[startwad_i selectCellAtRow:startwad column: 0];
|
[startwad_i selectCellAtRow: startwad column:0];
|
||||||
|
|
||||||
WriteNumericDefault ("StartWad", value);
|
WriteNumericDefault ("StartWad", value);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)getStartWad
|
-(int) getStartWad
|
||||||
{
|
{
|
||||||
return startwad;
|
return startwad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===============================================
|
//===============================================
|
||||||
// X,Y,Z light values
|
// X,Y,Z light values
|
||||||
//===============================================
|
//===============================================
|
||||||
//
|
//
|
||||||
// Set the state
|
// Set the state
|
||||||
//
|
//
|
||||||
- setXlight:(float)value
|
-setXlight:(float) value
|
||||||
{
|
{
|
||||||
xlight = value;
|
xlight = value;
|
||||||
if (xlight < 0.25 || xlight > 1)
|
if (xlight < 0.25 || xlight > 1)
|
||||||
|
@ -264,7 +268,8 @@ void WriteStringDefault (char *name, char *value)
|
||||||
WriteNumericDefault ("Xlight", xlight);
|
WriteNumericDefault ("Xlight", xlight);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
- setYlight:(float)value
|
|
||||||
|
-setYlight:(float) value
|
||||||
{
|
{
|
||||||
ylight = value;
|
ylight = value;
|
||||||
if (ylight < 0.25 || ylight > 1)
|
if (ylight < 0.25 || ylight > 1)
|
||||||
|
@ -274,7 +279,8 @@ void WriteStringDefault (char *name, char *value)
|
||||||
WriteNumericDefault ("Ylight", ylight);
|
WriteNumericDefault ("Ylight", ylight);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
- setZlight:(float)value
|
|
||||||
|
-setZlight:(float) value
|
||||||
{
|
{
|
||||||
zlight = value;
|
zlight = value;
|
||||||
if (zlight < 0.25 || zlight > 1)
|
if (zlight < 0.25 || zlight > 1)
|
||||||
|
@ -286,19 +292,21 @@ void WriteStringDefault (char *name, char *value)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the state
|
// Get the state
|
||||||
//
|
//
|
||||||
- (float)getXlight
|
-(float) getXlight
|
||||||
{
|
{
|
||||||
return [xlight_i floatValue];
|
return[xlight_i floatValue];
|
||||||
}
|
}
|
||||||
- (float)getYlight
|
|
||||||
|
-(float) getYlight
|
||||||
{
|
{
|
||||||
return [ylight_i floatValue];
|
return[ylight_i floatValue];
|
||||||
}
|
}
|
||||||
- (float)getZlight
|
|
||||||
|
-(float) getZlight
|
||||||
{
|
{
|
||||||
return [zlight_i floatValue];
|
return[zlight_i floatValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -310,22 +318,22 @@ UIChanged
|
||||||
Grab all the current UI state
|
Grab all the current UI state
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
-UIChanged: sender
|
-UIChanged:sender
|
||||||
{
|
{
|
||||||
qprintf ("defaults updated");
|
qprintf ("defaults updated");
|
||||||
|
|
||||||
[self setProjectPath: (char *)[startproject_i stringValue]];
|
|
||||||
[self setBspSoundPath: (char *)[bspSoundField_i stringValue]];
|
|
||||||
[self setShowBSP: [showBSP_i intValue]];
|
|
||||||
[self setBrushOffset: [brushOffset_i intValue]];
|
|
||||||
[self setStartWad: [startwad_i selectedRow]];
|
|
||||||
[self setXlight: [xlight_i floatValue]];
|
|
||||||
[self setYlight: [ylight_i floatValue]];
|
|
||||||
[self setZlight: [zlight_i floatValue]];
|
|
||||||
|
|
||||||
[map_i makeGlobalPerform: @selector(flushTextures)];
|
[self setProjectPath:(char *)[startproject_i stringValue]];
|
||||||
|
[self setBspSoundPath:(char *)[bspSoundField_i stringValue]];
|
||||||
|
[self setShowBSP:[showBSP_i intValue]];
|
||||||
|
[self setBrushOffset:[brushOffset_i intValue]];
|
||||||
|
[self setStartWad:[startwad_i selectedRow]];
|
||||||
|
[self setXlight:[xlight_i floatValue]];
|
||||||
|
[self setYlight:[ylight_i floatValue]];
|
||||||
|
[self setZlight:[zlight_i floatValue]];
|
||||||
|
|
||||||
|
[map_i makeGlobalPerform:@selector (flushTextures)];
|
||||||
[quakeed_i updateAll];
|
[quakeed_i updateAll];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
#include "TexturePalette.h"
|
#include "TexturePalette.h"
|
||||||
|
|
||||||
|
|
||||||
id project_i;
|
id project_i;
|
||||||
|
|
||||||
@implementation Project
|
@implementation Project
|
||||||
|
|
||||||
- init
|
-init
|
||||||
{
|
{
|
||||||
project_i = self;
|
project_i = self;
|
||||||
|
|
||||||
|
@ -30,145 +30,139 @@ id project_i;
|
||||||
|
|
||||||
//===========================================================
|
//===========================================================
|
||||||
//
|
//
|
||||||
// Project code
|
// Project code
|
||||||
//
|
//
|
||||||
//===========================================================
|
//===========================================================
|
||||||
- initVars
|
-initVars
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
s = [preferences_i getProjectPath];
|
|
||||||
//XXX StripFilename(s);
|
|
||||||
strcpy(path_basepath,s);
|
|
||||||
|
|
||||||
strcpy(path_progdir,s);
|
|
||||||
strcat(path_progdir,"/"SUBDIR_ENT);
|
|
||||||
|
|
||||||
strcpy(path_mapdirectory,s);
|
|
||||||
strcat(path_mapdirectory,"/"SUBDIR_MAPS); // source dir
|
|
||||||
|
|
||||||
strcpy(path_finalmapdir,s);
|
s =[preferences_i getProjectPath];
|
||||||
strcat(path_finalmapdir,"/"SUBDIR_MAPS); // dest dir
|
// XXX StripFilename(s);
|
||||||
|
strcpy (path_basepath, s);
|
||||||
[basepathinfo_i setStringValue:[NSString stringWithCString:s]]; // in Project Inspector
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if ((s = [projectInfo getStringFor:BASEPATHKEY]))
|
|
||||||
{
|
|
||||||
strcpy(path_basepath,s);
|
|
||||||
|
|
||||||
strcpy(path_progdir,s);
|
|
||||||
strcat(path_progdir,"/"SUBDIR_ENT);
|
|
||||||
|
|
||||||
strcpy(path_mapdirectory,s);
|
|
||||||
strcat(path_mapdirectory,"/"SUBDIR_MAPS); // source dir
|
|
||||||
|
|
||||||
strcpy(path_finalmapdir,s);
|
strcpy (path_progdir, s);
|
||||||
strcat(path_finalmapdir,"/"SUBDIR_MAPS); // dest dir
|
strcat (path_progdir, "/" SUBDIR_ENT);
|
||||||
|
|
||||||
[basepathinfo_i setStringValue:s]; // in Project Inspector
|
strcpy (path_mapdirectory, s);
|
||||||
|
strcat (path_mapdirectory, "/" SUBDIR_MAPS); // source dir
|
||||||
|
|
||||||
|
strcpy (path_finalmapdir, s);
|
||||||
|
strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir
|
||||||
|
|
||||||
|
[basepathinfo_i setStringValue: [NSString stringWithCString:s]];
|
||||||
|
// in Project Inspector
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if ((s =[projectInfo getStringFor:BASEPATHKEY])) {
|
||||||
|
strcpy (path_basepath, s);
|
||||||
|
|
||||||
|
strcpy (path_progdir, s);
|
||||||
|
strcat (path_progdir, "/" SUBDIR_ENT);
|
||||||
|
|
||||||
|
strcpy (path_mapdirectory, s);
|
||||||
|
strcat (path_mapdirectory, "/" SUBDIR_MAPS); // source dir
|
||||||
|
|
||||||
|
strcpy (path_finalmapdir, s);
|
||||||
|
strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir
|
||||||
|
|
||||||
|
[basepathinfo_i setStringValue:s];
|
||||||
|
// in Project Inspector
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((s = [projectInfo getStringFor:BSPFULLVIS]))
|
if ((s =[projectInfo getStringFor:BSPFULLVIS])) {
|
||||||
{
|
strcpy (string_fullvis, s);
|
||||||
strcpy(string_fullvis,s);
|
changeString ('@', '\"', string_fullvis);
|
||||||
changeString('@','\"',string_fullvis);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((s = [projectInfo getStringFor:BSPFASTVIS]))
|
|
||||||
{
|
|
||||||
strcpy(string_fastvis,s);
|
|
||||||
changeString('@','\"',string_fastvis);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((s = [projectInfo getStringFor:BSPNOVIS]))
|
|
||||||
{
|
|
||||||
strcpy(string_novis,s);
|
|
||||||
changeString('@','\"',string_novis);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((s = [projectInfo getStringFor:BSPRELIGHT]))
|
|
||||||
{
|
|
||||||
strcpy(string_relight,s);
|
|
||||||
changeString('@','\"',string_relight);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((s = [projectInfo getStringFor:BSPLEAKTEST]))
|
|
||||||
{
|
|
||||||
strcpy(string_leaktest,s);
|
|
||||||
changeString('@','\"',string_leaktest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s = [projectInfo getStringFor:BSPENTITIES]))
|
if ((s =[projectInfo getStringFor:BSPFASTVIS])) {
|
||||||
{
|
strcpy (string_fastvis, s);
|
||||||
strcpy(string_entities,s);
|
changeString ('@', '\"', string_fastvis);
|
||||||
changeString('@','\"', string_entities);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build list of wads
|
if ((s =[projectInfo getStringFor:BSPNOVIS])) {
|
||||||
wadList = [projectInfo parseMultipleFrom:WADSKEY];
|
strcpy (string_novis, s);
|
||||||
|
changeString ('@', '\"', string_novis);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((s =[projectInfo getStringFor:BSPRELIGHT])) {
|
||||||
|
strcpy (string_relight, s);
|
||||||
|
changeString ('@', '\"', string_relight);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((s =[projectInfo getStringFor:BSPLEAKTEST])) {
|
||||||
|
strcpy (string_leaktest, s);
|
||||||
|
changeString ('@', '\"', string_leaktest);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((s =[projectInfo getStringFor:BSPENTITIES])) {
|
||||||
|
strcpy (string_entities, s);
|
||||||
|
changeString ('@', '\"', string_entities);
|
||||||
|
}
|
||||||
|
// Build list of wads
|
||||||
|
wadList =[projectInfo parseMultipleFrom:WADSKEY];
|
||||||
|
|
||||||
|
// Build list of maps & descriptions
|
||||||
|
mapList =[projectInfo parseMultipleFrom:MAPNAMESKEY];
|
||||||
|
descList =[projectInfo parseMultipleFrom:DESCKEY];
|
||||||
|
[self changeChar: '_' to: ' ' in:descList];
|
||||||
|
|
||||||
// Build list of maps & descriptions
|
|
||||||
mapList = [projectInfo parseMultipleFrom:MAPNAMESKEY];
|
|
||||||
descList = [projectInfo parseMultipleFrom:DESCKEY];
|
|
||||||
[self changeChar:'_' to:' ' in:descList];
|
|
||||||
|
|
||||||
[self initProjSettings];
|
[self initProjSettings];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Init Project Settings fields
|
// Init Project Settings fields
|
||||||
//
|
//
|
||||||
- initProjSettings
|
-initProjSettings
|
||||||
{
|
{
|
||||||
[pis_basepath_i setStringValue:[NSString stringWithCString:path_basepath]];
|
[pis_basepath_i setStringValue: [NSString stringWithCString:path_basepath]];
|
||||||
[pis_fullvis_i setStringValue:[NSString stringWithCString:string_fullvis]];
|
[pis_fullvis_i setStringValue: [NSString stringWithCString:string_fullvis]];
|
||||||
[pis_fastvis_i setStringValue:[NSString stringWithCString:string_fastvis]];
|
[pis_fastvis_i setStringValue: [NSString stringWithCString:string_fastvis]];
|
||||||
[pis_novis_i setStringValue:[NSString stringWithCString:string_novis]];
|
[pis_novis_i setStringValue: [NSString stringWithCString:string_novis]];
|
||||||
[pis_relight_i setStringValue:[NSString stringWithCString:string_relight]];
|
[pis_relight_i setStringValue: [NSString stringWithCString:string_relight]];
|
||||||
[pis_leaktest_i setStringValue:[NSString stringWithCString:string_leaktest]];
|
[pis_leaktest_i setStringValue: [NSString stringWithCString:string_leaktest]];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add text to the BSP Output window
|
// Add text to the BSP Output window
|
||||||
//
|
//
|
||||||
- addToOutput:(char *)string
|
-addToOutput:(char *) string
|
||||||
{
|
{
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
end = [BSPoutput_i textLength];
|
end =[BSPoutput_i textLength];
|
||||||
[BSPoutput_i replaceCharactersInRange:NSMakeRange (end, 0) withString:[NSString stringWithCString:string]];
|
[BSPoutput_i replaceCharactersInRange: NSMakeRange (end, 0) withString: [NSString stringWithCString:string]];
|
||||||
|
|
||||||
end = [BSPoutput_i textLength];
|
end =[BSPoutput_i textLength];
|
||||||
[BSPoutput_i setSelectedRange:NSMakeRange (end, 0)];
|
[BSPoutput_i setSelectedRange:NSMakeRange (end, 0)];
|
||||||
//XXX [BSPoutput_i scrollSelToVisible];
|
// XXX [BSPoutput_i scrollSelToVisible];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- clearBspOutput:sender
|
-clearBspOutput:sender
|
||||||
{
|
{
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
end = [BSPoutput_i textLength];
|
end =[BSPoutput_i textLength];
|
||||||
[BSPoutput_i replaceCharactersInRange:NSMakeRange (0, end) withString:@""];
|
[BSPoutput_i replaceCharactersInRange: NSMakeRange (0, end) withString:@""];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- print
|
-print
|
||||||
{
|
{
|
||||||
//XXX [BSPoutput_i printPSCode:self];
|
// XXX [BSPoutput_i printPSCode:self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- initProject
|
-initProject
|
||||||
{
|
{
|
||||||
[self parseProjectFile];
|
[self parseProjectFile];
|
||||||
if (projectInfo == NULL)
|
if (projectInfo == NULL)
|
||||||
|
@ -179,57 +173,56 @@ id project_i;
|
||||||
[pis_wads_i setReusesColumns:YES];
|
[pis_wads_i setReusesColumns:YES];
|
||||||
[pis_wads_i loadColumnZero];
|
[pis_wads_i loadColumnZero];
|
||||||
|
|
||||||
[things_i initEntities];
|
[things_i initEntities];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Change a character to another in a Storage list of strings
|
// Change a character to another in a Storage list of strings
|
||||||
//
|
//
|
||||||
- changeChar:(char)f to:(char)t in:(id)obj
|
-changeChar:(char)
|
||||||
|
f to:(char)
|
||||||
|
t in:(id) obj
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
char *string;
|
char *string;
|
||||||
|
|
||||||
max = [obj count];
|
max =[obj count];
|
||||||
for (i = 0;i < max;i++)
|
for (i = 0; i < max; i++) {
|
||||||
{
|
string =[obj elementAt:i];
|
||||||
string = [obj elementAt:i];
|
changeString (f, t, string);
|
||||||
changeString(f,t,string);
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fill the QuakeEd Maps or wads browser
|
// Fill the QuakeEd Maps or wads browser
|
||||||
// (Delegate method - delegated in Interface Builder)
|
// (Delegate method - delegated in Interface Builder)
|
||||||
//
|
//
|
||||||
- (int)browser:sender fillMatrix:matrix inColumn:(int)column
|
-(int) browser: sender fillMatrix: matrix inColumn:(int) column
|
||||||
{
|
{
|
||||||
id cell, list;
|
id cell, list;
|
||||||
int max;
|
int max;
|
||||||
char *name;
|
char *name;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (sender == mapbrowse_i)
|
if (sender == mapbrowse_i)
|
||||||
list = mapList;
|
list = mapList;
|
||||||
else if (sender == pis_wads_i)
|
else if (sender == pis_wads_i)
|
||||||
list = wadList;
|
list = wadList;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
list = nil;
|
list = nil;
|
||||||
Sys_Error ("Project: unknown browser to fill");
|
Sys_Error ("Project: unknown browser to fill");
|
||||||
}
|
}
|
||||||
|
|
||||||
max = [list count];
|
max =[list count];
|
||||||
for (i = 0 ; i<max ; i++)
|
for (i = 0; i < max; i++) {
|
||||||
{
|
name =[list elementAt:i];
|
||||||
name = [list elementAt:i];
|
|
||||||
[matrix addRow];
|
[matrix addRow];
|
||||||
cell = [matrix cellAtRow:i column:0];
|
cell =[matrix cellAtRow: i column:0];
|
||||||
[cell setStringValue:[NSString stringWithCString:name]];
|
[cell setStringValue: [NSString stringWithCString:name]];
|
||||||
[cell setLeaf:YES];
|
[cell setLeaf:YES];
|
||||||
[cell setLoaded:YES];
|
[cell setLoaded:YES];
|
||||||
}
|
}
|
||||||
|
@ -237,55 +230,52 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clicked on a map name or description!
|
// Clicked on a map name or description!
|
||||||
//
|
//
|
||||||
- clickedOnMap:sender
|
-clickedOnMap:sender
|
||||||
{
|
{
|
||||||
id matrix;
|
id matrix;
|
||||||
int row;
|
int row;
|
||||||
char fname[1024];
|
char fname[1024];
|
||||||
id panel;
|
id panel;
|
||||||
|
|
||||||
matrix = [sender matrixInColumn:0];
|
matrix =[sender matrixInColumn:0];
|
||||||
row = [matrix selectedRow];
|
row =[matrix selectedRow];
|
||||||
sprintf(fname,"%s/%s.map",path_mapdirectory,
|
sprintf (fname, "%s/%s.map", path_mapdirectory, (char *)[mapList elementAt:row]);
|
||||||
(char *)[mapList elementAt:row]);
|
|
||||||
|
panel = NSGetAlertPanel (@"Loading...",
|
||||||
panel = NSGetAlertPanel(@"Loading...",
|
@"Loading map. Please wait.", NULL, NULL, NULL);
|
||||||
@"Loading map. Please wait.",NULL,NULL,NULL);
|
|
||||||
[panel orderFront:NULL];
|
[panel orderFront:NULL];
|
||||||
|
|
||||||
[quakeed_i doOpen:fname];
|
[quakeed_i doOpen:fname];
|
||||||
|
|
||||||
[panel performClose:NULL];
|
[panel performClose:NULL];
|
||||||
//NSFreeAlertPanel(panel);
|
// NSFreeAlertPanel(panel);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- setTextureWad: (char *)wf
|
-setTextureWad:(char *) wf
|
||||||
{
|
{
|
||||||
int i, c;
|
int i, c;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
qprintf ("loading %s", wf);
|
qprintf ("loading %s", wf);
|
||||||
|
|
||||||
// set the row in the settings inspector wad browser
|
// set the row in the settings inspector wad browser
|
||||||
c = [wadList count];
|
c =[wadList count];
|
||||||
for (i=0 ; i<c ; i++)
|
for (i = 0; i < c; i++) {
|
||||||
{
|
|
||||||
name = (char *)[wadList elementAt:i];
|
name = (char *)[wadList elementAt:i];
|
||||||
if (!strcmp(name, wf))
|
if (!strcmp (name, wf)) {
|
||||||
{
|
[[pis_wads_i matrixInColumn: 0] selectCellAtRow: i column:0];
|
||||||
[[pis_wads_i matrixInColumn:0] selectCellAtRow: i column: 0];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the texture inspector
|
// update the texture inspector
|
||||||
[texturepalette_i initPaletteFromWadfile:wf ];
|
[texturepalette_i initPaletteFromWadfile:wf];
|
||||||
[[map_i objectAtIndex: 0] setKey:"wad" toValue: wf];
|
[[map_i objectAtIndex: 0] setKey: "wad" toValue:wf];
|
||||||
// [inspcontrol_i changeInspectorTo:i_textures];
|
// [inspcontrol_i changeInspectorTo:i_textures];
|
||||||
|
|
||||||
[quakeed_i updateAll];
|
[quakeed_i updateAll];
|
||||||
|
|
||||||
|
@ -293,42 +283,41 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clicked on a wad name
|
// Clicked on a wad name
|
||||||
//
|
//
|
||||||
- clickedOnWad:sender
|
-clickedOnWad:sender
|
||||||
{
|
{
|
||||||
id matrix;
|
id matrix;
|
||||||
int row;
|
int row;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
matrix = [sender matrixInColumn:0];
|
matrix =[sender matrixInColumn:0];
|
||||||
row = [matrix selectedRow];
|
row =[matrix selectedRow];
|
||||||
|
|
||||||
name = (char *)[wadList elementAt:row];
|
name = (char *)[wadList elementAt:row];
|
||||||
[self setTextureWad: name];
|
[self setTextureWad:name];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read in the <name>.QE_Project file
|
// Read in the <name>.QE_Project file
|
||||||
//
|
//
|
||||||
- parseProjectFile
|
-parseProjectFile
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
int rtn;
|
int rtn;
|
||||||
|
|
||||||
path = [preferences_i getProjectPath];
|
path =[preferences_i getProjectPath];
|
||||||
if (!path || !path[0] || access(path,0))
|
if (!path || !path[0] || access (path, 0)) {
|
||||||
{
|
rtn = NSRunAlertPanel (@"Project Error!",
|
||||||
rtn = NSRunAlertPanel(@"Project Error!",
|
@"A default project has not been found.\n",
|
||||||
@"A default project has not been found.\n"
|
@"Open Project", NULL, NULL);
|
||||||
, @"Open Project", NULL, NULL);
|
|
||||||
if ([self openProject] == nil)
|
if ([self openProject] == nil)
|
||||||
while (1) // can't run without a project
|
while (1) // can't run without a project
|
||||||
[NSApp terminate: self];
|
[NSApp terminate:self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self openProjectFile:path];
|
[self openProjectFile:path];
|
||||||
|
@ -336,103 +325,102 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Loads and parses a project file
|
// Loads and parses a project file
|
||||||
//
|
//
|
||||||
- openProjectFile:(char *)path
|
-openProjectFile:(char *) path
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
strcpy(path_projectinfo,path);
|
strcpy (path_projectinfo, path);
|
||||||
|
|
||||||
projectInfo = NULL;
|
projectInfo = NULL;
|
||||||
fp = fopen(path,"r+t");
|
fp = fopen (path, "r+t");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
stat(path,&s);
|
stat (path, &s);
|
||||||
lastModified = s.st_mtime;
|
lastModified = s.st_mtime;
|
||||||
|
|
||||||
projectInfo = [(Dict *)[Dict alloc] initFromFile:fp];
|
projectInfo =[(Dict *)[Dict alloc] initFromFile:fp];
|
||||||
fclose(fp);
|
fclose (fp);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *)currentProjectFile
|
-(char *) currentProjectFile
|
||||||
{
|
{
|
||||||
return path_projectinfo;
|
return path_projectinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open a project file
|
// Open a project file
|
||||||
//
|
//
|
||||||
- openProject
|
-openProject
|
||||||
{
|
{
|
||||||
char path[128];
|
char path[128];
|
||||||
id openpanel;
|
id openpanel;
|
||||||
int rtn;
|
int rtn;
|
||||||
NSString *projtypes[] ={ @"qpr"};
|
NSString *projtypes[] = { @"qpr" };
|
||||||
NSArray *filenames;
|
NSArray *filenames;
|
||||||
const char *dir;
|
const char *dir;
|
||||||
|
|
||||||
openpanel = [NSOpenPanel new];
|
openpanel =[NSOpenPanel new];
|
||||||
//[openpanel allowMultipleFiles:NO];
|
// [openpanel allowMultipleFiles:NO];
|
||||||
//[openpanel chooseDirectories:NO];
|
// [openpanel chooseDirectories:NO];
|
||||||
rtn = [openpanel runModalForTypes:[NSArray arrayWithObjects: projtypes count:1]];
|
rtn =[openpanel runModalForTypes: [NSArray arrayWithObjects: projtypes count:1]];
|
||||||
if (rtn == NSOKButton)
|
if (rtn == NSOKButton) {
|
||||||
{
|
filenames =[openpanel filenames];
|
||||||
filenames = [openpanel filenames];
|
dir =[[openpanel directory] cString];
|
||||||
dir = [[openpanel directory] cString];
|
sprintf (path, "%s/%s", dir,[[filenames objectAtIndex:0] cString]);
|
||||||
sprintf (path, "%s/%s", dir, [[filenames objectAtIndex:0] cString]);
|
strcpy (path_projectinfo, path);
|
||||||
strcpy(path_projectinfo,path);
|
[self openProjectFile:path];
|
||||||
[self openProjectFile:path];
|
return self;
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search for a string in a List of strings
|
// Search for a string in a List of strings
|
||||||
//
|
//
|
||||||
- (int)searchForString:(char *)str in:(id)obj
|
-(int) searchForString:(char *)
|
||||||
|
str in:(id) obj
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
max = [obj count];
|
max =[obj count];
|
||||||
for (i = 0;i < max; i++)
|
for (i = 0; i < max; i++) {
|
||||||
{
|
|
||||||
s = (char *)[obj elementAt:i];
|
s = (char *)[obj elementAt:i];
|
||||||
if (!strcmp(s,str))
|
if (!strcmp (s, str))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *)getMapDirectory
|
-(char *) getMapDirectory
|
||||||
{
|
{
|
||||||
return path_mapdirectory;
|
return path_mapdirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *)getFinalMapDirectory
|
-(char *) getFinalMapDirectory
|
||||||
{
|
{
|
||||||
return path_finalmapdir;
|
return path_finalmapdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *)getProgDirectory
|
-(char *) getProgDirectory
|
||||||
{
|
{
|
||||||
return path_progdir;
|
return path_progdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the WAD name for cmd-8
|
// Return the WAD name for cmd-8
|
||||||
//
|
//
|
||||||
- (char *)getWAD8
|
-(char *) getWAD8
|
||||||
{
|
{
|
||||||
if (!path_wad8[0])
|
if (!path_wad8[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -440,9 +428,9 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the WAD name for cmd-9
|
// Return the WAD name for cmd-9
|
||||||
//
|
//
|
||||||
- (char *)getWAD9
|
-(char *) getWAD9
|
||||||
{
|
{
|
||||||
if (!path_wad9[0])
|
if (!path_wad9[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -450,9 +438,9 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the WAD name for cmd-0
|
// Return the WAD name for cmd-0
|
||||||
//
|
//
|
||||||
- (char *)getWAD0
|
-(char *) getWAD0
|
||||||
{
|
{
|
||||||
if (!path_wad0[0])
|
if (!path_wad0[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -460,9 +448,9 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the FULLVIS cmd string
|
// Return the FULLVIS cmd string
|
||||||
//
|
//
|
||||||
- (char *)getFullVisCmd
|
-(char *) getFullVisCmd
|
||||||
{
|
{
|
||||||
if (!string_fullvis[0])
|
if (!string_fullvis[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -470,9 +458,9 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the FASTVIS cmd string
|
// Return the FASTVIS cmd string
|
||||||
//
|
//
|
||||||
- (char *)getFastVisCmd
|
-(char *) getFastVisCmd
|
||||||
{
|
{
|
||||||
if (!string_fastvis[0])
|
if (!string_fastvis[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -480,9 +468,9 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the NOVIS cmd string
|
// Return the NOVIS cmd string
|
||||||
//
|
//
|
||||||
- (char *)getNoVisCmd
|
-(char *) getNoVisCmd
|
||||||
{
|
{
|
||||||
if (!string_novis[0])
|
if (!string_novis[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -490,9 +478,9 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the RELIGHT cmd string
|
// Return the RELIGHT cmd string
|
||||||
//
|
//
|
||||||
- (char *)getRelightCmd
|
-(char *) getRelightCmd
|
||||||
{
|
{
|
||||||
if (!string_relight[0])
|
if (!string_relight[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -500,16 +488,16 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return the LEAKTEST cmd string
|
// Return the LEAKTEST cmd string
|
||||||
//
|
//
|
||||||
- (char *)getLeaktestCmd
|
-(char *) getLeaktestCmd
|
||||||
{
|
{
|
||||||
if (!string_leaktest[0])
|
if (!string_leaktest[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
return string_leaktest;
|
return string_leaktest;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *)getEntitiesCmd
|
-(char *) getEntitiesCmd
|
||||||
{
|
{
|
||||||
if (!string_entities[0])
|
if (!string_entities[0])
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -517,21 +505,18 @@ id project_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
//====================================================
|
//====================================================
|
||||||
// C Functions
|
// C Functions
|
||||||
//====================================================
|
//====================================================
|
||||||
|
|
||||||
//
|
//
|
||||||
// Change a character to a different char in a string
|
// Change a character to a different char in a string
|
||||||
//
|
//
|
||||||
void changeString(char cf,char ct,char *string)
|
void
|
||||||
|
changeString (char cf, char ct, char *string)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j = 0;j < strlen(string);j++)
|
for (j = 0; j < strlen (string); j++)
|
||||||
if (string[j] == cf)
|
if (string[j] == cf)
|
||||||
string[j] = ct;
|
string[j] = ct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, const char *argv[])
|
main (int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
return NSApplicationMain (argc, argv);
|
return NSApplicationMain (argc, argv);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,25 +1,25 @@
|
||||||
/* Implementation of Objective C NeXT-compatible Storage object
|
/* Implementation of Objective C NeXT-compatible Storage object
|
||||||
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
|
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
|
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
|
||||||
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
|
||||||
|
|
||||||
This file is part of the GNUstep Base Library.
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public
|
modify it under the terms of the GNU Library General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2 of the License, or (at your option) any later version.
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
Library General Public License for more details.
|
Library General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
You should have received a copy of the GNU Library General Public
|
||||||
License along with this library; if not, write to the Free
|
License along with this library; if not, write to the Free
|
||||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* #include <config.h> */
|
/* #include <config.h> */
|
||||||
#include "Storage.h"
|
#include "Storage.h"
|
||||||
|
@ -28,257 +28,250 @@
|
||||||
|
|
||||||
|
|
||||||
#define GNU_STORAGE_NTH(x,N) \
|
#define GNU_STORAGE_NTH(x,N) \
|
||||||
({ GNUStorageId* __s=(GNUStorageId*)(x); \
|
({ GNUStorageId* __s=(GNUStorageId*)(x); \
|
||||||
(void*)(((char*)__s->dataPtr)+(__s->elementSize*(N))); })
|
(void*)(((char*)__s->dataPtr)+(__s->elementSize*(N))); })
|
||||||
#define STORAGE_NTH(N) GNU_STORAGE_NTH (self, N)
|
#define STORAGE_NTH(N) GNU_STORAGE_NTH (self, N)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@defs(Storage)
|
@defs (Storage)
|
||||||
} GNUStorageId;
|
} GNUStorageId;
|
||||||
|
|
||||||
@implementation Storage
|
@implementation Storage
|
||||||
|
|
||||||
+ initialize
|
+initialize
|
||||||
{
|
{
|
||||||
if (self == [Storage class])
|
if (self ==[Storage class])
|
||||||
[self setVersion:0]; /* beta release */
|
[self setVersion:0]; /* beta release */
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INITIALIZING, FREEING;
|
// INITIALIZING, FREEING;
|
||||||
|
|
||||||
- initCount: (NSUInteger)numSlots
|
-initCount: (NSUInteger) numSlots elementSize: (NSUInteger) sizeInBytes description:(const char *)
|
||||||
elementSize: (NSUInteger)sizeInBytes
|
elemDesc;
|
||||||
description: (const char*)elemDesc;
|
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
numElements = numSlots;
|
numElements = numSlots;
|
||||||
maxElements = (numSlots > 0) ? numSlots : 1;
|
maxElements = (numSlots > 0) ? numSlots : 1;
|
||||||
elementSize = sizeInBytes;
|
elementSize = sizeInBytes;
|
||||||
description = elemDesc;
|
description = elemDesc;
|
||||||
dataPtr = (void*) objc_malloc (maxElements * elementSize);
|
dataPtr = (void *) objc_malloc (maxElements * elementSize);
|
||||||
bzero(dataPtr, numElements * elementSize);
|
bzero (dataPtr, numElements * elementSize);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- init
|
-init
|
||||||
{
|
{
|
||||||
return [self initCount:1
|
return[self initCount: 1 elementSize:sizeof (id)
|
||||||
elementSize:sizeof(id)
|
description:@encode (id)];
|
||||||
description:@encode(id)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)dealloc
|
-(void) dealloc
|
||||||
{
|
{
|
||||||
if (dataPtr)
|
if (dataPtr)
|
||||||
free(dataPtr);
|
free (dataPtr);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (const char*) description
|
-(const char *) description
|
||||||
{
|
{
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// COPYING;
|
// COPYING;
|
||||||
|
|
||||||
- copy
|
-copy
|
||||||
{
|
{
|
||||||
Storage *c = [super copy];
|
Storage *c =[super copy];
|
||||||
c->dataPtr = (void*) objc_malloc (maxElements * elementSize);
|
|
||||||
memcpy(c->dataPtr, dataPtr, numElements * elementSize);
|
c->dataPtr = (void *) objc_malloc (maxElements * elementSize);
|
||||||
return c;
|
memcpy (c->dataPtr, dataPtr, numElements * elementSize);
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
// COMPARING TWO STORAGES;
|
// COMPARING TWO STORAGES;
|
||||||
|
|
||||||
- (BOOL)isEqual: anObject
|
-(BOOL) isEqual:anObject
|
||||||
{
|
{
|
||||||
if ([anObject isKindOfClass: [Storage class]]
|
if ([anObject isKindOfClass:[Storage class]]
|
||||||
&& [anObject count] == [self count]
|
&&[anObject count] ==[self count]
|
||||||
&& !memcmp(((GNUStorageId*)anObject)->dataPtr,
|
&& !memcmp (((GNUStorageId *) anObject)->dataPtr,
|
||||||
dataPtr, numElements*elementSize))
|
dataPtr, numElements * elementSize))
|
||||||
return YES;
|
return YES;
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MANAGING THE STORAGE CAPACITY;
|
// MANAGING THE STORAGE CAPACITY;
|
||||||
|
|
||||||
static inline void _makeRoomForAnotherIfNecessary(Storage *self)
|
static inline void
|
||||||
|
_makeRoomForAnotherIfNecessary (Storage * self)
|
||||||
{
|
{
|
||||||
if (self->numElements == self->maxElements)
|
if (self->numElements == self->maxElements) {
|
||||||
{
|
self->maxElements *= 2;
|
||||||
self->maxElements *= 2;
|
self->dataPtr = (void *)
|
||||||
self->dataPtr = (void*)
|
objc_realloc (self->dataPtr, self->maxElements * self->elementSize);
|
||||||
objc_realloc (self->dataPtr, self->maxElements*self->elementSize);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _shrinkIfDesired(Storage *self)
|
static inline void
|
||||||
|
_shrinkIfDesired (Storage * self)
|
||||||
{
|
{
|
||||||
if (self->numElements < (self->maxElements / 2))
|
if (self->numElements < (self->maxElements / 2)) {
|
||||||
{
|
self->maxElements /= 2;
|
||||||
self->maxElements /= 2;
|
self->dataPtr = (void *)
|
||||||
self->dataPtr = (void *)
|
objc_realloc (self->dataPtr, self->maxElements * self->elementSize);
|
||||||
objc_realloc (self->dataPtr, self->maxElements*self->elementSize);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- setAvailableCapacity:(NSUInteger)numSlots
|
-setAvailableCapacity:(NSUInteger) numSlots
|
||||||
{
|
{
|
||||||
if (numSlots > numElements)
|
if (numSlots > numElements) {
|
||||||
{
|
maxElements = numSlots;
|
||||||
maxElements = numSlots;
|
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
|
||||||
dataPtr = (void*) objc_realloc (dataPtr, maxElements * elementSize);
|
}
|
||||||
}
|
return self;
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- setNumSlots:(NSUInteger)numSlots
|
-setNumSlots:(NSUInteger) numSlots
|
||||||
{
|
{
|
||||||
if (numSlots > numElements)
|
if (numSlots > numElements) {
|
||||||
{
|
maxElements = numSlots;
|
||||||
maxElements = numSlots;
|
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
|
||||||
dataPtr = (void*) objc_realloc (dataPtr, maxElements * elementSize);
|
bzero (STORAGE_NTH (numElements),
|
||||||
bzero(STORAGE_NTH(numElements), (maxElements-numElements)*elementSize);
|
(maxElements - numElements) * elementSize);
|
||||||
}
|
} else if (numSlots < numElements) {
|
||||||
else if (numSlots < numElements)
|
numElements = numSlots;
|
||||||
{
|
_shrinkIfDesired (self);
|
||||||
numElements = numSlots;
|
}
|
||||||
_shrinkIfDesired (self);
|
return self;
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Manipulating objects by index */
|
/* Manipulating objects by index */
|
||||||
|
|
||||||
#define CHECK_INDEX(IND) if (IND >= numElements) return 0
|
#define CHECK_INDEX(IND) if (IND >= numElements) return 0
|
||||||
|
|
||||||
- (NSUInteger) count
|
-(NSUInteger) count
|
||||||
{
|
{
|
||||||
return numElements;
|
return numElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void*) elementAt: (NSUInteger)index
|
-(void *) elementAt:(NSUInteger) index
|
||||||
{
|
{
|
||||||
CHECK_INDEX(index);
|
CHECK_INDEX (index);
|
||||||
return STORAGE_NTH (index);
|
return STORAGE_NTH (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
- addElement: (void*)anElement
|
-addElement:(void *) anElement
|
||||||
{
|
{
|
||||||
_makeRoomForAnotherIfNecessary(self);
|
_makeRoomForAnotherIfNecessary (self);
|
||||||
memcpy(STORAGE_NTH(numElements), anElement, elementSize);
|
memcpy (STORAGE_NTH (numElements), anElement, elementSize);
|
||||||
numElements++;
|
numElements++;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- insertElement: (void*)anElement at: (NSUInteger)index
|
-insertElement:(void *)
|
||||||
|
anElement at:(NSUInteger) index
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
CHECK_INDEX(index);
|
CHECK_INDEX (index);
|
||||||
_makeRoomForAnotherIfNecessary(self);
|
_makeRoomForAnotherIfNecessary (self);
|
||||||
#ifndef STABLE_MEMCPY
|
|
||||||
for (i = numElements; i >= index; i--)
|
|
||||||
memcpy (STORAGE_NTH(i+1), STORAGE_NTH(i), elementSize);
|
|
||||||
#else
|
|
||||||
memcpy (STORAGE_NTH (index+1),
|
|
||||||
STORAGE_NTH (index),
|
|
||||||
elementSize*(numElements-index));
|
|
||||||
#endif
|
|
||||||
memcpy(STORAGE_NTH(i), anElement, elementSize);
|
|
||||||
numElements++;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- removeElementAt: (NSUInteger)index
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
CHECK_INDEX(index);
|
|
||||||
numElements--;
|
|
||||||
#ifndef STABLE_MEMCPY
|
#ifndef STABLE_MEMCPY
|
||||||
for (i = index; i < numElements; i++)
|
for (i = numElements; i >= index; i--)
|
||||||
memcpy(STORAGE_NTH(i),
|
memcpy (STORAGE_NTH (i + 1), STORAGE_NTH (i), elementSize);
|
||||||
STORAGE_NTH(i+1),
|
|
||||||
elementSize);
|
|
||||||
#else
|
#else
|
||||||
memcpy (STORAGE_NTH (index),
|
memcpy (STORAGE_NTH (index + 1),
|
||||||
STORAGE_NTH (index+1),
|
STORAGE_NTH (index), elementSize * (numElements - index));
|
||||||
elementSize*(numElements-index-1));
|
#endif
|
||||||
#endif
|
memcpy (STORAGE_NTH (i), anElement, elementSize);
|
||||||
_shrinkIfDesired(self);
|
numElements++;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- removeLastElement
|
-removeElementAt:(NSUInteger) index
|
||||||
{
|
{
|
||||||
if (numElements)
|
int i;
|
||||||
{
|
|
||||||
numElements--;
|
CHECK_INDEX (index);
|
||||||
_shrinkIfDesired(self);
|
numElements--;
|
||||||
}
|
#ifndef STABLE_MEMCPY
|
||||||
return self;
|
for (i = index; i < numElements; i++)
|
||||||
|
memcpy (STORAGE_NTH (i), STORAGE_NTH (i + 1), elementSize);
|
||||||
|
#else
|
||||||
|
memcpy (STORAGE_NTH (index),
|
||||||
|
STORAGE_NTH (index + 1), elementSize * (numElements - index - 1));
|
||||||
|
#endif
|
||||||
|
_shrinkIfDesired (self);
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- replaceElementAt:(NSUInteger)index with:(void*)newElement
|
-removeLastElement
|
||||||
{
|
{
|
||||||
CHECK_INDEX(index);
|
if (numElements) {
|
||||||
memcpy(STORAGE_NTH(index), newElement, elementSize);
|
numElements--;
|
||||||
return self;
|
_shrinkIfDesired (self);
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
-replaceElementAt:(NSUInteger)
|
||||||
|
index with:(void *) newElement
|
||||||
|
{
|
||||||
|
CHECK_INDEX (index);
|
||||||
|
memcpy (STORAGE_NTH (index), newElement, elementSize);
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emptying the Storage */
|
/* Emptying the Storage */
|
||||||
|
|
||||||
- empty
|
-empty
|
||||||
{
|
{
|
||||||
numElements = 0;
|
numElements = 0;
|
||||||
maxElements = 1;
|
maxElements = 1;
|
||||||
dataPtr = (void*) objc_realloc (dataPtr, maxElements * elementSize);
|
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Archiving */
|
/* Archiving */
|
||||||
|
|
||||||
- write: (TypedStream*)aStream
|
-write:(TypedStream *) aStream
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
[super write:aStream];
|
[super write:aStream];
|
||||||
objc_write_types(aStream, "III*",
|
objc_write_types (aStream, "III*",
|
||||||
&numElements, &maxElements, &elementSize, &description);
|
&numElements, &maxElements, &elementSize, &description);
|
||||||
for (i = 0; i < numElements; i++)
|
for (i = 0; i < numElements; i++)
|
||||||
objc_write_type(aStream, description, STORAGE_NTH(i));
|
objc_write_type (aStream, description, STORAGE_NTH (i));
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- read: (TypedStream*)aStream
|
-read:(TypedStream *) aStream
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
[super read:aStream];
|
[super read:aStream];
|
||||||
objc_read_types(aStream, "III*",
|
objc_read_types (aStream, "III*",
|
||||||
&numElements, &maxElements, &elementSize, &description);
|
&numElements, &maxElements, &elementSize, &description);
|
||||||
dataPtr = (void*) objc_malloc (maxElements * elementSize);
|
dataPtr = (void *) objc_malloc (maxElements * elementSize);
|
||||||
for (i = 0; i < numElements; i++)
|
for (i = 0; i < numElements; i++)
|
||||||
objc_read_type(aStream, description, STORAGE_NTH(i));
|
objc_read_type (aStream, description, STORAGE_NTH (i));
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ new
|
+new
|
||||||
{
|
{
|
||||||
return [[self alloc] init];
|
return[[self alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ newCount:(NSUInteger)count elementSize:(NSUInteger)sizeInBytes
|
+newCount:(NSUInteger)
|
||||||
description:(const char *)descriptor
|
count elementSize:(NSUInteger) sizeInBytes
|
||||||
|
description:(const char *) descriptor
|
||||||
{
|
{
|
||||||
return [[self alloc] initCount:count elementSize:sizeInBytes
|
return[[self alloc] initCount: count elementSize: sizeInBytes description:descriptor];
|
||||||
description:descriptor];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -13,143 +13,136 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
|
||||||
|
|
||||||
@implementation TextureView
|
@implementation TextureView
|
||||||
|
|
||||||
- init
|
-init
|
||||||
{
|
{
|
||||||
deselectIndex = -1;
|
deselectIndex = -1;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- setParent:(id)from
|
-setParent:(id) from
|
||||||
{
|
{
|
||||||
parent_i = from;
|
parent_i = from;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)acceptsFirstMouse
|
-(BOOL) acceptsFirstMouse
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- drawSelf:(const NSRect *)rects :(int)rectCount
|
-drawSelf: (const NSRect *) rects:(int) rectCount
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
id list_i;
|
id list_i;
|
||||||
texpal_t *t;
|
texpal_t *t;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
NSPoint p;
|
NSPoint p;
|
||||||
NSRect r;
|
NSRect r;
|
||||||
int selected;
|
int selected;
|
||||||
|
|
||||||
selected = [parent_i getSelectedTexture];
|
|
||||||
list_i = [parent_i getList];
|
|
||||||
GSSetFont (DEFCTXT, [NSFont fontWithName:@"Helvetica-Medium" size:FONTSIZE]);
|
|
||||||
PSrotate(0);
|
|
||||||
|
|
||||||
PSsetgray(NSLightGray);
|
|
||||||
PSrectfill(rects->origin.x, rects->origin.y,
|
|
||||||
rects->size.width, rects->size.height);
|
|
||||||
|
|
||||||
if (!list_i) // WADfile didn't init
|
selected =[parent_i getSelectedTexture];
|
||||||
|
list_i =[parent_i getList];
|
||||||
|
GSSetFont (DEFCTXT,[NSFont fontWithName: @"Helvetica-Medium" size:FONTSIZE]);
|
||||||
|
PSrotate (0);
|
||||||
|
|
||||||
|
PSsetgray (NSLightGray);
|
||||||
|
PSrectfill (rects->origin.x, rects->origin.y,
|
||||||
|
rects->size.width, rects->size.height);
|
||||||
|
|
||||||
|
if (!list_i) // WADfile didn't init
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
if (deselectIndex != -1)
|
if (deselectIndex != -1) {
|
||||||
{
|
t =[list_i elementAt:deselectIndex];
|
||||||
t = [list_i elementAt:deselectIndex];
|
|
||||||
r = t->r;
|
r = t->r;
|
||||||
r.origin.x -= TEX_INDENT;
|
r.origin.x -= TEX_INDENT;
|
||||||
r.origin.y -= TEX_INDENT;
|
r.origin.y -= TEX_INDENT;
|
||||||
r.size.width += TEX_INDENT*2;
|
r.size.width += TEX_INDENT * 2;
|
||||||
r.size.height += TEX_INDENT*2;
|
r.size.height += TEX_INDENT * 2;
|
||||||
|
|
||||||
//XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
// XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
|
||||||
PSrectfill(r.origin.x, r.origin.y,
|
PSrectfill (r.origin.x, r.origin.y, r.size.width, r.size.height);
|
||||||
r.size.width, r.size.height);
|
|
||||||
p = t->r.origin;
|
p = t->r.origin;
|
||||||
p.y += TEX_SPACING;
|
p.y += TEX_SPACING;
|
||||||
[t->image drawAtPoint:p fromRect:r operation:NSCompositeCopy fraction:1.0];
|
[t->image drawAtPoint: p fromRect: r operation: NSCompositeCopy fraction:1.0];
|
||||||
PSsetgray(0);
|
PSsetgray (0);
|
||||||
x = t->r.origin.x;
|
x = t->r.origin.x;
|
||||||
y = t->r.origin.y + 7;
|
y = t->r.origin.y + 7;
|
||||||
PSmoveto(x,y);
|
PSmoveto (x, y);
|
||||||
PSshow(t->name);
|
PSshow (t->name);
|
||||||
PSstroke();
|
PSstroke ();
|
||||||
deselectIndex = -1;
|
deselectIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
max = [list_i count];
|
max =[list_i count];
|
||||||
PSsetgray(0);
|
PSsetgray (0);
|
||||||
|
|
||||||
for (i = 0;i < max; i++)
|
for (i = 0; i < max; i++) {
|
||||||
{
|
t =[list_i elementAt:i];
|
||||||
t = [list_i elementAt:i];
|
|
||||||
r = t->r;
|
r = t->r;
|
||||||
r.origin.x -= TEX_INDENT/2;
|
r.origin.x -= TEX_INDENT / 2;
|
||||||
r.size.width += TEX_INDENT;
|
r.size.width += TEX_INDENT;
|
||||||
r.origin.y += 4;
|
r.origin.y += 4;
|
||||||
if (NSIntersectsRect(rects[0],r) == YES &&
|
if (NSIntersectsRect (rects[0], r) == YES && t->display) {
|
||||||
t->display)
|
if (selected == i) {
|
||||||
{
|
PSsetgray (1);
|
||||||
if (selected == i)
|
PSrectfill (r.origin.x, r.origin.y,
|
||||||
{
|
r.size.width, r.size.height);
|
||||||
PSsetgray(1);
|
PSsetrgbcolor (1, 0, 0);
|
||||||
PSrectfill(r.origin.x,r.origin.y,
|
PSrectstroke (r.origin.x, r.origin.y,
|
||||||
r.size.width,r.size.height);
|
r.size.width, r.size.height);
|
||||||
PSsetrgbcolor(1,0,0);
|
PSsetgray (0);
|
||||||
PSrectstroke(r.origin.x, r.origin.y,
|
|
||||||
r.size.width, r.size.height);
|
|
||||||
PSsetgray(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p = t->r.origin;
|
p = t->r.origin;
|
||||||
p.y += TEX_SPACING;
|
p.y += TEX_SPACING;
|
||||||
[t->image drawAtPoint:p fromRect:r operation:NSCompositeCopy fraction:1.0];
|
[t->image drawAtPoint: p fromRect: r operation: NSCompositeCopy fraction:1.0];
|
||||||
x = t->r.origin.x;
|
x = t->r.origin.x;
|
||||||
y = t->r.origin.y + 7;
|
y = t->r.origin.y + 7;
|
||||||
PSmoveto(x,y);
|
PSmoveto (x, y);
|
||||||
PSshow(t->name);
|
PSshow (t->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PSstroke();
|
PSstroke ();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- deselect
|
-deselect
|
||||||
{
|
{
|
||||||
deselectIndex = [parent_i getSelectedTexture];
|
deselectIndex =[parent_i getSelectedTexture];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- mouseDown:(NSEvent *)theEvent
|
-mouseDown:(NSEvent *) theEvent
|
||||||
{
|
{
|
||||||
NSPoint loc;
|
NSPoint loc;
|
||||||
int i;
|
int i;
|
||||||
int max;
|
int max;
|
||||||
//int oldwindowmask;
|
|
||||||
texpal_t *t;
|
|
||||||
id list;
|
|
||||||
NSRect r;
|
|
||||||
|
|
||||||
//oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask];
|
// int oldwindowmask;
|
||||||
loc = [theEvent locationInWindow];
|
texpal_t *t;
|
||||||
[self convertPoint:loc fromView:NULL];
|
id list;
|
||||||
|
NSRect r;
|
||||||
list = [parent_i getList];
|
|
||||||
max = [list count];
|
// oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask];
|
||||||
for (i = 0;i < max; i++)
|
loc =[theEvent locationInWindow];
|
||||||
{
|
[self convertPoint: loc fromView:NULL];
|
||||||
t = [list elementAt:i];
|
|
||||||
|
list =[parent_i getList];
|
||||||
|
max =[list count];
|
||||||
|
for (i = 0; i < max; i++) {
|
||||||
|
t =[list elementAt:i];
|
||||||
r = t->r;
|
r = t->r;
|
||||||
if (NSPointInRect(loc,r) == YES)
|
if (NSPointInRect (loc, r) == YES) {
|
||||||
{
|
[self deselect];
|
||||||
[self deselect];
|
[parent_i setSelectedTexture:i];
|
||||||
[parent_i setSelectedTexture:i];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//[window setEventMask:oldwindowmask];
|
// [window setEventMask:oldwindowmask];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,222 +6,219 @@
|
||||||
#include "KeypairView.h"
|
#include "KeypairView.h"
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
|
|
||||||
id things_i;
|
id things_i;
|
||||||
|
|
||||||
@implementation Things
|
@implementation Things
|
||||||
|
|
||||||
- init
|
-init
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
|
|
||||||
things_i = self;
|
things_i = self;
|
||||||
lastSelected = 0;
|
lastSelected = 0;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Load the TEXT object with the entity comment
|
// Load the TEXT object with the entity comment
|
||||||
//
|
//
|
||||||
- loadEntityComment:(id)obj
|
-loadEntityComment:(id) obj
|
||||||
{
|
{
|
||||||
[entity_comment_i selectAll:self];
|
[entity_comment_i selectAll:self];
|
||||||
[entity_comment_i replaceCharactersInRange:[entity_comment_i selectedRange] withString:[NSString stringWithCString:[obj comments]]];
|
[entity_comment_i replaceCharactersInRange: [entity_comment_i selectedRange] withString: [NSString stringWithCString:[obj
|
||||||
|
comments]]];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- initEntities
|
-initEntities
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
path = [project_i getProgDirectory];
|
path =[project_i getProgDirectory];
|
||||||
|
|
||||||
[prog_path_i setStringValue: [NSString stringWithCString:path]];
|
[prog_path_i setStringValue: [NSString stringWithCString:path]];
|
||||||
|
|
||||||
[[EntityClassList alloc] initForSourceDirectory: path];
|
|
||||||
|
|
||||||
[self loadEntityComment:[entity_classes_i objectAtIndex:lastSelected]];
|
[[EntityClassList alloc] initForSourceDirectory:path];
|
||||||
|
|
||||||
|
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]];
|
||||||
[entity_browser_i loadColumnZero];
|
[entity_browser_i loadColumnZero];
|
||||||
[[entity_browser_i matrixInColumn:0] selectCellAtRow:lastSelected column:0];
|
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column:0];
|
||||||
|
|
||||||
|
[entity_browser_i setDoubleAction: @selector (doubleClickEntity:)];
|
||||||
|
|
||||||
[entity_browser_i setDoubleAction: @selector(doubleClickEntity:)];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- selectEntity: sender
|
-selectEntity:sender
|
||||||
{
|
{
|
||||||
id matr;
|
id matr;
|
||||||
|
|
||||||
matr = [sender matrixInColumn: 0];
|
matr =[sender matrixInColumn:0];
|
||||||
lastSelected = [matr selectedRow];
|
lastSelected =[matr selectedRow];
|
||||||
[self loadEntityComment:[entity_classes_i objectAtIndex:lastSelected]];
|
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]];
|
||||||
[quakeed_i makeFirstResponder: quakeed_i];
|
[quakeed_i makeFirstResponder:quakeed_i];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- doubleClickEntity: sender
|
-doubleClickEntity:sender
|
||||||
{
|
{
|
||||||
[map_i makeEntity: sender];
|
[map_i makeEntity:sender];
|
||||||
[quakeed_i makeFirstResponder: quakeed_i];
|
[quakeed_i makeFirstResponder:quakeed_i];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char *)spawnName
|
-(char *) spawnName
|
||||||
{
|
{
|
||||||
return [[entity_classes_i objectAtIndex:lastSelected] classname];
|
return[[entity_classes_i objectAtIndex:lastSelected] classname];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Flush entity classes & reload them!
|
// Flush entity classes & reload them!
|
||||||
//
|
//
|
||||||
- reloadEntityClasses: sender
|
-reloadEntityClasses:sender
|
||||||
{
|
{
|
||||||
EntityClass *ent;
|
EntityClass *ent;
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
path = (char *)[prog_path_i stringValue];
|
path = (char *)[prog_path_i stringValue];
|
||||||
if (!path || !path[0])
|
if (!path || !path[0]) {
|
||||||
{
|
path =[project_i getProgDirectory];
|
||||||
path = [project_i getProgDirectory];
|
|
||||||
[prog_path_i setStringValue: [NSString stringWithCString:path]];
|
[prog_path_i setStringValue: [NSString stringWithCString:path]];
|
||||||
}
|
}
|
||||||
|
// Free all entity info in memory...
|
||||||
// Free all entity info in memory...
|
|
||||||
[entity_classes_i removeAllObjects];
|
[entity_classes_i removeAllObjects];
|
||||||
[entity_classes_i release];
|
[entity_classes_i release];
|
||||||
|
|
||||||
// Now, RELOAD!
|
// Now, RELOAD!
|
||||||
[[EntityClassList alloc] initForSourceDirectory: path];
|
[[EntityClassList alloc] initForSourceDirectory:path];
|
||||||
|
|
||||||
lastSelected = 0;
|
lastSelected = 0;
|
||||||
ent = [entity_classes_i objectAtIndex:lastSelected];
|
ent =[entity_classes_i objectAtIndex:lastSelected];
|
||||||
[self loadEntityComment:[entity_classes_i objectAtIndex:lastSelected]];
|
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]];
|
||||||
|
|
||||||
[entity_browser_i loadColumnZero];
|
[entity_browser_i loadColumnZero];
|
||||||
[[entity_browser_i matrixInColumn:0] selectCellAtRow:lastSelected column:0];
|
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column:0];
|
||||||
|
|
||||||
|
[self newCurrentEntity]; // in case flags changed
|
||||||
|
|
||||||
[self newCurrentEntity]; // in case flags changed
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- selectClass: (char *)class
|
-selectClass:(char *) class
|
||||||
{
|
{
|
||||||
id classent;
|
id classent;
|
||||||
|
|
||||||
classent = [entity_classes_i classForName:class];
|
classent =[entity_classes_i classForName:class];
|
||||||
if (!classent)
|
if (!classent)
|
||||||
return self;
|
return self;
|
||||||
lastSelected = [entity_classes_i indexOfObject: classent];
|
lastSelected =[entity_classes_i indexOfObject:classent];
|
||||||
|
|
||||||
if (lastSelected < 0)
|
if (lastSelected < 0)
|
||||||
lastSelected = 0;
|
lastSelected = 0;
|
||||||
|
|
||||||
[self loadEntityComment:classent];
|
[self loadEntityComment:classent];
|
||||||
[[entity_browser_i matrixInColumn:0] selectCellAtRow:lastSelected column:0];
|
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column:0];
|
||||||
[[entity_browser_i matrixInColumn:0] scrollCellToVisibleAtRow:lastSelected column:0];
|
[[entity_browser_i matrixInColumn: 0] scrollCellToVisibleAtRow: lastSelected column:0];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- newCurrentEntity
|
-newCurrentEntity
|
||||||
{
|
{
|
||||||
id ent, classent, cell;
|
id ent, classent, cell;
|
||||||
char *classname;
|
char *classname;
|
||||||
int r, c;
|
int r, c;
|
||||||
char *flagname;
|
char *flagname;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
ent = [map_i currentEntity];
|
ent =[map_i currentEntity];
|
||||||
classname = [ent valueForQKey: "classname"];
|
classname =[ent valueForQKey:"classname"];
|
||||||
if (ent != [map_i objectAtIndex: 0])
|
if (ent !=[map_i objectAtIndex:0])
|
||||||
[self selectClass: classname]; // don't reset for world
|
[self selectClass:classname]; // don't reset for world
|
||||||
classent = [entity_classes_i classForName:classname];
|
classent =[entity_classes_i classForName:classname];
|
||||||
flagname = [ent valueForQKey: "spawnflags"];
|
flagname =[ent valueForQKey:"spawnflags"];
|
||||||
if (!flagname)
|
if (!flagname)
|
||||||
flags = 0;
|
flags = 0;
|
||||||
else
|
else
|
||||||
flags = atoi(flagname);
|
flags = atoi (flagname);
|
||||||
|
|
||||||
[flags_i setAutodisplay: NO];
|
[flags_i setAutodisplay:NO];
|
||||||
for (r=0 ; r<4 ; r++)
|
for (r = 0; r < 4; r++)
|
||||||
for (c=0 ; c<3 ; c++)
|
for (c = 0; c < 3; c++) {
|
||||||
{
|
cell =[flags_i cellAtRow: r column:c];
|
||||||
cell = [flags_i cellAtRow: r column: c];
|
if (c < 2) {
|
||||||
if (c < 2)
|
flagname =[classent flagName:c * 4 + r];
|
||||||
{
|
|
||||||
flagname = [classent flagName: c*4 + r];
|
|
||||||
[cell setTitle: [NSString stringWithCString:flagname]];
|
[cell setTitle: [NSString stringWithCString:flagname]];
|
||||||
}
|
}
|
||||||
[cell setIntValue: (flags & (1<< ((c*4)+r)) ) > 0];
|
[cell setIntValue:(flags & (1 << ((c * 4) + r))) > 0];
|
||||||
}
|
}
|
||||||
[flags_i setAutodisplay: YES];
|
[flags_i setAutodisplay:YES];
|
||||||
[flags_i display];
|
[flags_i display];
|
||||||
|
|
||||||
// [keyInput_i setStringValue: ""];
|
// [keyInput_i setStringValue: ""];
|
||||||
// [valueInput_i setStringValue: ""];
|
// [valueInput_i setStringValue: ""];
|
||||||
|
|
||||||
[keypairview_i calcViewSize];
|
[keypairview_i calcViewSize];
|
||||||
[keypairview_i display];
|
[keypairview_i display];
|
||||||
|
|
||||||
[quakeed_i makeFirstResponder: quakeed_i];
|
[quakeed_i makeFirstResponder:quakeed_i];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clicked in the Keypair view - set as selected
|
// Clicked in the Keypair view - set as selected
|
||||||
//
|
//
|
||||||
- setSelectedKey:(epair_t *)ep;
|
-setSelectedKey:(epair_t *) ep;
|
||||||
{
|
{
|
||||||
[keyInput_i setStringValue:[NSString stringWithCString:ep->key]];
|
[keyInput_i setStringValue: [NSString stringWithCString:ep->key]];
|
||||||
[valueInput_i setStringValue:[NSString stringWithCString:ep->value]];
|
[valueInput_i setStringValue: [NSString stringWithCString:ep->value]];
|
||||||
[valueInput_i selectText:self];
|
[valueInput_i selectText:self];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- clearInputs
|
-clearInputs
|
||||||
{
|
{
|
||||||
// [keyInput_i setStringValue: ""];
|
// [keyInput_i setStringValue: ""];
|
||||||
// [valueInput_i setStringValue: ""];
|
// [valueInput_i setStringValue: ""];
|
||||||
|
|
||||||
[quakeed_i makeFirstResponder: quakeed_i];
|
[quakeed_i makeFirstResponder:quakeed_i];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Action methods
|
// Action methods
|
||||||
//
|
//
|
||||||
|
|
||||||
-addPair:sender
|
-addPair:sender
|
||||||
{
|
{
|
||||||
char *key, *value;
|
char *key, *value;
|
||||||
|
|
||||||
key = (char *)[keyInput_i stringValue];
|
key = (char *)[keyInput_i stringValue];
|
||||||
value = (char *)[valueInput_i stringValue];
|
value = (char *)[valueInput_i stringValue];
|
||||||
|
|
||||||
[ [map_i currentEntity] setKey: key toValue: value ];
|
[[map_i currentEntity] setKey: key toValue:value];
|
||||||
|
|
||||||
[keypairview_i calcViewSize];
|
[keypairview_i calcViewSize];
|
||||||
[keypairview_i display];
|
[keypairview_i display];
|
||||||
|
|
||||||
[self clearInputs];
|
[self clearInputs];
|
||||||
[quakeed_i updateXY];
|
[quakeed_i updateXY];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-delPair:sender
|
-delPair:sender
|
||||||
{
|
{
|
||||||
[quakeed_i makeFirstResponder: quakeed_i];
|
[quakeed_i makeFirstResponder:quakeed_i];
|
||||||
|
|
||||||
[ [map_i currentEntity] removeKeyPair: (char *)[keyInput_i stringValue] ];
|
[[map_i currentEntity] removeKeyPair:(char *)[keyInput_i stringValue]];
|
||||||
|
|
||||||
[keypairview_i calcViewSize];
|
[keypairview_i calcViewSize];
|
||||||
[keypairview_i display];
|
[keypairview_i display];
|
||||||
|
@ -235,58 +232,56 @@ id things_i;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set the key/value fields to "angle <button value>"
|
// Set the key/value fields to "angle <button value>"
|
||||||
//
|
//
|
||||||
- setAngle:sender
|
-setAngle:sender
|
||||||
{
|
{
|
||||||
const char *title;
|
const char *title;
|
||||||
char value[10];
|
char value[10];
|
||||||
|
|
||||||
title = [[[sender selectedCell] title] cString];
|
title =[[[sender selectedCell] title] cString];
|
||||||
if (!strcmp(title,"Up"))
|
if (!strcmp (title, "Up"))
|
||||||
strcpy (value, "-1");
|
strcpy (value, "-1");
|
||||||
else if (!strcmp(title,"Dn"))
|
else if (!strcmp (title, "Dn"))
|
||||||
strcpy (value, "-2");
|
strcpy (value, "-2");
|
||||||
else
|
else
|
||||||
strcpy (value, title);
|
strcpy (value, title);
|
||||||
|
|
||||||
[keyInput_i setStringValue:@"angle"];
|
[keyInput_i setStringValue:@"angle"];
|
||||||
[valueInput_i setStringValue:[NSString stringWithCString:value]];
|
[valueInput_i setStringValue: [NSString stringWithCString:value]];
|
||||||
[self addPair:NULL];
|
[self addPair:NULL];
|
||||||
|
|
||||||
[self clearInputs];
|
[self clearInputs];
|
||||||
|
|
||||||
[quakeed_i updateXY];
|
[quakeed_i updateXY];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- setFlags:sender
|
-setFlags:sender
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
int r, c, i;
|
int r, c, i;
|
||||||
id cell;
|
id cell;
|
||||||
char str[20];
|
char str[20];
|
||||||
|
|
||||||
[self clearInputs];
|
[self clearInputs];
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
for (r=0 ; r<4 ; r++)
|
for (r = 0; r < 4; r++)
|
||||||
for (c=0 ; c<3 ; c++)
|
for (c = 0; c < 3; c++) {
|
||||||
{
|
cell =[flags_i cellAtRow: r column:c];
|
||||||
cell = [flags_i cellAtRow: r column: c];
|
|
||||||
i = ([cell intValue] > 0);
|
i = ([cell intValue] > 0);
|
||||||
flags |= (i<< ((c*4)+r));
|
flags |= (i << ((c * 4) + r));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!flags)
|
if (!flags)
|
||||||
[[map_i currentEntity] removeKeyPair: "spawnflags"];
|
[[map_i currentEntity] removeKeyPair:"spawnflags"];
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
sprintf (str, "%i", flags);
|
sprintf (str, "%i", flags);
|
||||||
[[map_i currentEntity] setKey: "spawnflags" toValue: str];
|
[[map_i currentEntity] setKey: "spawnflags" toValue:str];
|
||||||
}
|
}
|
||||||
|
|
||||||
[keypairview_i calcViewSize];
|
[keypairview_i calcViewSize];
|
||||||
[keypairview_i display];
|
[keypairview_i display];
|
||||||
|
|
||||||
|
@ -295,24 +290,24 @@ id things_i;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fill the Entity browser
|
// Fill the Entity browser
|
||||||
// (Delegate method - delegated in Interface Builder)
|
// (Delegate method - delegated in Interface Builder)
|
||||||
//
|
//
|
||||||
- (int)browser:sender fillMatrix:matrix inColumn:(int)column
|
-(int) browser: sender fillMatrix: matrix inColumn:(int) column
|
||||||
{
|
{
|
||||||
id cell;
|
id cell;
|
||||||
int max;
|
int max;
|
||||||
int i;
|
int i;
|
||||||
id object;
|
id object;
|
||||||
|
|
||||||
max = [entity_classes_i count];
|
max =[entity_classes_i count];
|
||||||
i = 0;
|
i = 0;
|
||||||
while(max--)
|
while (max--) {
|
||||||
{
|
object =[entity_classes_i objectAtIndex:i];
|
||||||
object = [entity_classes_i objectAtIndex:i];
|
|
||||||
[matrix addRow];
|
[matrix addRow];
|
||||||
cell = [matrix cellAtRow:i++ column:0];
|
cell =[matrix cellAtRow: i++ column:0];
|
||||||
[cell setStringValue:[NSString stringWithCString:[object classname]]];
|
[cell setStringValue: [NSString stringWithCString:[object
|
||||||
|
classname]]];
|
||||||
[cell setLeaf:YES];
|
[cell setLeaf:YES];
|
||||||
[cell setLoaded:YES];
|
[cell setLoaded:YES];
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,63 +14,68 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
|
||||||
static NSZone *upZone = NULL;
|
static NSZone *upZone = NULL;
|
||||||
|
|
||||||
NSZone *userPathZone()
|
NSZone *
|
||||||
|
userPathZone ()
|
||||||
/* Creates a unique zone for use by all user paths */
|
/* Creates a unique zone for use by all user paths */
|
||||||
{
|
{
|
||||||
if (!upZone) {
|
if (!upZone) {
|
||||||
upZone = NSCreateZone(vm_page_size, vm_page_size, 1);
|
upZone = NSCreateZone (vm_page_size, vm_page_size, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return upZone;
|
return upZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserPath *newUserPath()
|
UserPath *
|
||||||
|
newUserPath ()
|
||||||
/* Creates a new User Path in the zone returned by userPathZone */
|
/* Creates a new User Path in the zone returned by userPathZone */
|
||||||
{
|
{
|
||||||
UserPath *up;
|
UserPath *up;
|
||||||
|
|
||||||
up = (UserPath *)NSZoneMalloc(userPathZone(), sizeof(UserPath));
|
up = (UserPath *) NSZoneMalloc (userPathZone (), sizeof (UserPath));
|
||||||
up->max = 8192; // JDC
|
up->max = 8192; // JDC
|
||||||
up->points = (float *)NSZoneMalloc(userPathZone(),
|
up->points = (float *) NSZoneMalloc (userPathZone (),
|
||||||
sizeof(float) * up->max);
|
sizeof (float) * up->max);
|
||||||
up->ops = (char *)NSZoneMalloc(userPathZone(),
|
up->ops = (char *) NSZoneMalloc (userPathZone (),
|
||||||
(2 + (up->max / 2)) * sizeof(char));
|
(2 + (up->max / 2)) * sizeof (char));
|
||||||
up->ping = NO;
|
up->ping = NO;
|
||||||
|
|
||||||
return up;
|
return up;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeUserPath(UserPath *up)
|
void
|
||||||
|
freeUserPath (UserPath * up)
|
||||||
/* Frees User Path and its associated buffers */
|
/* Frees User Path and its associated buffers */
|
||||||
{
|
{
|
||||||
free(up->points);
|
free (up->points);
|
||||||
free(up->ops);
|
free (up->ops);
|
||||||
free(up);
|
free (up);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void growUserPath(UserPath *up)
|
void
|
||||||
|
growUserPath (UserPath * up)
|
||||||
/*
|
/*
|
||||||
* grows the associated buffers as necessary. buffer size doubles on each
|
* grows the associated buffers as necessary. buffer size doubles on each
|
||||||
* call. You never need to call grow directly as it is called as needed by the
|
* call. You never need to call grow directly as it is called as needed by the
|
||||||
* methods and functions which add elements into the buffer
|
* methods and functions which add elements into the buffer
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* double the size of the internal buffers */
|
/* double the size of the internal buffers */
|
||||||
printf ("growUserPath\n");
|
printf ("growUserPath\n");
|
||||||
up->max *= 2;
|
up->max *= 2;
|
||||||
up->points = (float *)NSZoneRealloc(userPathZone(), up->points,
|
up->points = (float *) NSZoneRealloc (userPathZone (), up->points,
|
||||||
sizeof(float) * up->max);
|
sizeof (float) * up->max);
|
||||||
up->ops = (char *)NSZoneRealloc(userPathZone(), up->ops,
|
up->ops = (char *) NSZoneRealloc (userPathZone (), up->ops,
|
||||||
(2 + (up->max / 2)) * sizeof(char));
|
(2 + (up->max / 2)) * sizeof (char));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void beginUserPath(UserPath *up, BOOL cache)
|
void
|
||||||
|
beginUserPath (UserPath * up, BOOL cache)
|
||||||
/*
|
/*
|
||||||
* Call this to start generating a user path. The cache argument specifies if
|
* Call this to start generating a user path. The cache argument specifies if
|
||||||
* you want the user path cached at the server (i.e. dps_ucache). In either
|
* you want the user path cached at the server (i.e. dps_ucache). In either
|
||||||
|
@ -78,20 +83,21 @@ void beginUserPath(UserPath *up, BOOL cache)
|
||||||
* the path and add the dps_setbbox operator.
|
* the path and add the dps_setbbox operator.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
up->numberOfPoints = up->numberOfOps = 0;
|
up->numberOfPoints = up->numberOfOps = 0;
|
||||||
up->cp.x = up->cp.y = 0;
|
up->cp.x = up->cp.y = 0;
|
||||||
up->bbox[0] = up->bbox[1] = 1.0e6;
|
up->bbox[0] = up->bbox[1] = 1.0e6;
|
||||||
up->bbox[2] = up->bbox[3] = -1.0e6;
|
up->bbox[2] = up->bbox[3] = -1.0e6;
|
||||||
if (cache) {
|
if (cache) {
|
||||||
up->ops[up->numberOfOps++] = dps_ucache;
|
up->ops[up->numberOfOps++] = dps_ucache;
|
||||||
}
|
}
|
||||||
up->ops[up->numberOfOps++] = dps_setbbox;
|
up->ops[up->numberOfOps++] = dps_setbbox;
|
||||||
up->opForUserPath = 0;
|
up->opForUserPath = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endUserPath(UserPath *up, int op)
|
void
|
||||||
|
endUserPath (UserPath * up, int op)
|
||||||
/*
|
/*
|
||||||
* Call this to stop filling the path. Note this does not send the userpath to
|
* Call this to stop filling the path. Note this does not send the userpath to
|
||||||
* the server -- use sendUserPath. The op argument should be one of the
|
* the server -- use sendUserPath. The op argument should be one of the
|
||||||
|
@ -101,13 +107,14 @@ void endUserPath(UserPath *up, int op)
|
||||||
* These are defined in <dpsclient/dpsNext.h.
|
* These are defined in <dpsclient/dpsNext.h.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
up->opForUserPath = op;
|
up->opForUserPath = op;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UPdebug(UserPath *up, BOOL shouldPing)
|
void
|
||||||
|
UPdebug (UserPath * up, BOOL shouldPing)
|
||||||
/*
|
/*
|
||||||
* Sets ping to YES so that after each time a user path is sent down to the
|
* Sets ping to YES so that after each time a user path is sent down to the
|
||||||
* window server, an NSPing() is sent after. The purpose is to catch PostScript
|
* window server, an NSPing() is sent after. The purpose is to catch PostScript
|
||||||
|
@ -116,12 +123,13 @@ void UPdebug(UserPath *up, BOOL shouldPing)
|
||||||
* ping is NO.
|
* ping is NO.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
up->ping = shouldPing;
|
up->ping = shouldPing;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sendUserPath(UserPath *up)
|
int
|
||||||
|
sendUserPath (UserPath * up)
|
||||||
/*
|
/*
|
||||||
* Call this to send the path down to the server. If ping==YES (set via
|
* Call this to send the path down to the server. If ping==YES (set via
|
||||||
* debug:), the function will send an NSPing() after the Path. In any event,
|
* debug:), the function will send an NSPing() after the Path. In any event,
|
||||||
|
@ -133,77 +141,77 @@ int sendUserPath(UserPath *up)
|
||||||
* server.
|
* server.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
NSHandler exception;
|
NSHandler exception;
|
||||||
|
|
||||||
exception.code = 0;
|
exception.code = 0;
|
||||||
if (up->opForUserPath != 0) {
|
if (up->opForUserPath != 0) {
|
||||||
//NS_DURING
|
// NS_DURING
|
||||||
DPSDoUserPath(up->points, up->numberOfPoints, dps_float, up->ops,
|
DPSDoUserPath (up->points, up->numberOfPoints, dps_float, up->ops,
|
||||||
up->numberOfOps, up->bbox, up->opForUserPath);
|
up->numberOfOps, up->bbox, up->opForUserPath);
|
||||||
if (up->ping) {
|
if (up->ping) {
|
||||||
NSPing();
|
NSPing ();
|
||||||
|
}
|
||||||
|
// NS_HANDLER
|
||||||
|
// exception = NSLocalHandler;
|
||||||
|
// NS_ENDHANDLER
|
||||||
|
if (exception.code) {
|
||||||
|
NSReportError (&exception);
|
||||||
|
if (exception.code == dps_err_ps) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//NS_HANDLER
|
return -1;
|
||||||
// exception = NSLocalHandler;
|
|
||||||
//NS_ENDHANDLER
|
|
||||||
if (exception.code) {
|
|
||||||
NSReportError(&exception);
|
|
||||||
if (exception.code == dps_err_ps) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UPmoveto(UserPath *up, float x, float y)
|
void
|
||||||
|
UPmoveto (UserPath * up, float x, float y)
|
||||||
/* adds <x y moveto> to user path and updates bounding box */
|
/* adds <x y moveto> to user path and updates bounding box */
|
||||||
{
|
{
|
||||||
up->ops[up->numberOfOps++] = dps_moveto;
|
up->ops[up->numberOfOps++] = dps_moveto;
|
||||||
up->points[up->numberOfPoints++] = x;
|
up->points[up->numberOfPoints++] = x;
|
||||||
up->points[up->numberOfPoints++] = y;
|
up->points[up->numberOfPoints++] = y;
|
||||||
|
|
||||||
if (x < up->bbox[0]) {
|
if (x < up->bbox[0]) {
|
||||||
up->bbox[0] = x;
|
up->bbox[0] = x;
|
||||||
}
|
}
|
||||||
if (y < up->bbox[1]) {
|
if (y < up->bbox[1]) {
|
||||||
up->bbox[1] = y;
|
up->bbox[1] = y;
|
||||||
}
|
}
|
||||||
if (x > up->bbox[2]) {
|
if (x > up->bbox[2]) {
|
||||||
up->bbox[2] = x;
|
up->bbox[2] = x;
|
||||||
}
|
}
|
||||||
if (y > up->bbox[3]) {
|
if (y > up->bbox[3]) {
|
||||||
up->bbox[3] = y;
|
up->bbox[3] = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UPlineto(UserPath *up, float x, float y)
|
void
|
||||||
|
UPlineto (UserPath * up, float x, float y)
|
||||||
/* adds <x y lineto> to user path and updates bounding box */
|
/* adds <x y lineto> to user path and updates bounding box */
|
||||||
{
|
{
|
||||||
up->ops[up->numberOfOps++] = dps_lineto;
|
up->ops[up->numberOfOps++] = dps_lineto;
|
||||||
up->points[up->numberOfPoints++] = x;
|
up->points[up->numberOfPoints++] = x;
|
||||||
up->points[up->numberOfPoints++] = y;
|
up->points[up->numberOfPoints++] = y;
|
||||||
|
|
||||||
if (x < up->bbox[0]) {
|
|
||||||
up->bbox[0] = x;
|
|
||||||
}
|
|
||||||
if (y < up->bbox[1]) {
|
|
||||||
up->bbox[1] = y;
|
|
||||||
}
|
|
||||||
if (x > up->bbox[2]) {
|
|
||||||
up->bbox[2] = x;
|
|
||||||
}
|
|
||||||
if (y > up->bbox[3]) {
|
|
||||||
up->bbox[3] = y;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (x < up->bbox[0]) {
|
||||||
|
up->bbox[0] = x;
|
||||||
|
}
|
||||||
|
if (y < up->bbox[1]) {
|
||||||
|
up->bbox[1] = y;
|
||||||
|
}
|
||||||
|
if (x > up->bbox[2]) {
|
||||||
|
up->bbox[2] = x;
|
||||||
|
}
|
||||||
|
if (y > up->bbox[3]) {
|
||||||
|
up->bbox[3] = y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,6 @@
|
||||||
#include "ZScrollView.h"
|
#include "ZScrollView.h"
|
||||||
|
|
||||||
@implementation ZScrollView
|
@implementation ZScrollView
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
initWithFrame: button:
|
initWithFrame: button:
|
||||||
|
@ -9,42 +8,37 @@ initWithFrame: button:
|
||||||
Initizes a scroll view with a button at it's lower right corner
|
Initizes a scroll view with a button at it's lower right corner
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
|
- initWithFrame:(NSRect)
|
||||||
|
frameRect button1:b1 {
|
||||||
|
[super initWithFrame:frameRect];
|
||||||
|
|
||||||
- initWithFrame:(NSRect)frameRect button1:b1
|
[self addSubview:b1];
|
||||||
{
|
|
||||||
[super initWithFrame: frameRect];
|
|
||||||
|
|
||||||
[self addSubview: b1];
|
|
||||||
|
|
||||||
button1 = b1;
|
button1 = b1;
|
||||||
|
|
||||||
[self setHasHorizontalScroller: YES];
|
[self setHasHorizontalScroller:YES];
|
||||||
[self setHasVerticalScroller: YES];
|
[self setHasVerticalScroller:YES];
|
||||||
|
|
||||||
|
[self setBorderType:NSBezelBorder];
|
||||||
|
|
||||||
[self setBorderType: NSBezelBorder];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
tile
|
tile
|
||||||
|
|
||||||
Adjust the size for the pop up scale menu
|
Adjust the size for the pop up scale menu
|
||||||
=================
|
=================
|
||||||
*/
|
*/ -tile
|
||||||
|
|
||||||
- tile
|
|
||||||
{
|
{
|
||||||
NSRect scrollerframe;
|
NSRect scrollerframe;
|
||||||
|
|
||||||
[super tile];
|
[super tile];
|
||||||
scrollerframe = [_horizScroller frame];
|
scrollerframe =[_horizScroller frame];
|
||||||
[button1 setFrame: scrollerframe];
|
[button1 setFrame:scrollerframe];
|
||||||
|
|
||||||
scrollerframe.size.width = 0;
|
scrollerframe.size.width = 0;
|
||||||
[_horizScroller setFrame: scrollerframe];
|
[_horizScroller setFrame:scrollerframe];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -53,8 +47,9 @@ Adjust the size for the pop up scale menu
|
||||||
|
|
||||||
-(BOOL) acceptsFirstResponder
|
-(BOOL) acceptsFirstResponder
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- superviewSizeChanged:(const NSSize *)oldSize
|
- superviewSizeChanged:(const NSSize *)oldSize
|
||||||
{
|
{
|
||||||
|
@ -68,4 +63,3 @@ Adjust the size for the pop up scale menu
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,41 +1,40 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char token[MAXTOKEN];
|
char token[MAXTOKEN];
|
||||||
boolean unget;
|
boolean unget;
|
||||||
char *script_p;
|
char *script_p;
|
||||||
int scriptline;
|
int scriptline;
|
||||||
|
|
||||||
void StartTokenParsing (char *data)
|
void
|
||||||
|
StartTokenParsing (char *data)
|
||||||
{
|
{
|
||||||
scriptline = 1;
|
scriptline = 1;
|
||||||
script_p = data;
|
script_p = data;
|
||||||
unget = false;
|
unget = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean GetToken (boolean crossline)
|
boolean
|
||||||
|
GetToken (boolean crossline)
|
||||||
{
|
{
|
||||||
char *token_p;
|
char *token_p;
|
||||||
|
|
||||||
if (unget) // is a token allready waiting?
|
if (unget) // is a token allready waiting?
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//
|
//
|
||||||
// skip space
|
// skip space
|
||||||
//
|
//
|
||||||
skipspace:
|
skipspace:
|
||||||
while (*script_p <= 32)
|
while (*script_p <= 32) {
|
||||||
{
|
if (!*script_p) {
|
||||||
if (!*script_p)
|
|
||||||
{
|
|
||||||
if (!crossline)
|
if (!crossline)
|
||||||
Error ("Line %i is incomplete",scriptline);
|
Error ("Line %i is incomplete", scriptline);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (*script_p++ == '\n')
|
if (*script_p++ == '\n') {
|
||||||
{
|
|
||||||
if (!crossline)
|
if (!crossline)
|
||||||
Error ("Line %i is incomplete",scriptline);
|
Error ("Line %i is incomplete", scriptline);
|
||||||
scriptline++;
|
scriptline++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,48 +42,44 @@ skipspace:
|
||||||
if (script_p[0] == '/' && script_p[1] == '/') // comment field
|
if (script_p[0] == '/' && script_p[1] == '/') // comment field
|
||||||
{
|
{
|
||||||
if (!crossline)
|
if (!crossline)
|
||||||
Error ("Line %i is incomplete\n",scriptline);
|
Error ("Line %i is incomplete\n", scriptline);
|
||||||
while (*script_p++ != '\n')
|
while (*script_p++ != '\n')
|
||||||
if (!*script_p)
|
if (!*script_p) {
|
||||||
{
|
|
||||||
if (!crossline)
|
if (!crossline)
|
||||||
Error ("Line %i is incomplete",scriptline);
|
Error ("Line %i is incomplete", scriptline);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
goto skipspace;
|
goto skipspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// copy token
|
// copy token
|
||||||
//
|
//
|
||||||
token_p = token;
|
token_p = token;
|
||||||
|
|
||||||
if (*script_p == '"')
|
if (*script_p == '"') {
|
||||||
{
|
|
||||||
script_p++;
|
script_p++;
|
||||||
while ( *script_p != '"' )
|
while (*script_p != '"') {
|
||||||
{
|
|
||||||
if (!*script_p)
|
if (!*script_p)
|
||||||
Error ("EOF inside quoted token");
|
Error ("EOF inside quoted token");
|
||||||
*token_p++ = *script_p++;
|
*token_p++ = *script_p++;
|
||||||
if (token_p == &token[MAXTOKEN])
|
if (token_p == &token[MAXTOKEN])
|
||||||
Error ("Token too large on line %i",scriptline);
|
Error ("Token too large on line %i", scriptline);
|
||||||
}
|
}
|
||||||
script_p++;
|
script_p++;
|
||||||
}
|
} else
|
||||||
else while ( *script_p > 32 )
|
while (*script_p > 32) {
|
||||||
{
|
*token_p++ = *script_p++;
|
||||||
*token_p++ = *script_p++;
|
if (token_p == &token[MAXTOKEN])
|
||||||
if (token_p == &token[MAXTOKEN])
|
Error ("Token too large on line %i", scriptline);
|
||||||
Error ("Token too large on line %i",scriptline);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
*token_p = 0;
|
*token_p = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UngetToken ()
|
void
|
||||||
|
UngetToken ()
|
||||||
{
|
{
|
||||||
unget = true;
|
unget = true;
|
||||||
}
|
}
|
||||||
|
@ -93,18 +88,19 @@ void UngetToken ()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void qprintf (char *fmt, ...) // prints text to cmd_out_i
|
void
|
||||||
|
qprintf (char *fmt, ...) // prints text to cmd_out_i
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
static char string[1024];
|
static char string[1024];
|
||||||
|
|
||||||
va_start (argptr, fmt);
|
va_start (argptr, fmt);
|
||||||
vsprintf (string, fmt,argptr);
|
vsprintf (string, fmt, argptr);
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
|
|
||||||
[g_cmd_out_i setStringValue: [NSString stringWithCString: string]];
|
[g_cmd_out_i setStringValue: [NSString stringWithCString:string]];
|
||||||
//NSPing ();
|
// NSPing ();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,53 +112,55 @@ Error
|
||||||
For abnormal program terminations
|
For abnormal program terminations
|
||||||
=================
|
=================
|
||||||
*/
|
*/
|
||||||
BOOL in_error;
|
BOOL in_error;
|
||||||
void Error (char *error, ...)
|
void
|
||||||
|
Error (char *error, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
static char string[1024];
|
static char string[1024];
|
||||||
|
|
||||||
if (in_error)
|
if (in_error)
|
||||||
[NSApp terminate: NULL];
|
[NSApp terminate:NULL];
|
||||||
in_error = YES;
|
in_error = YES;
|
||||||
|
|
||||||
va_start (argptr,error);
|
va_start (argptr, error);
|
||||||
vsprintf (string,error,argptr);
|
vsprintf (string, error, argptr);
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
|
|
||||||
strcat (string, "\nmap saved to "FN_CRASHSAVE);
|
strcat (string, "\nmap saved to " FN_CRASHSAVE);
|
||||||
|
|
||||||
[map_i writeMapFile: FN_CRASHSAVE useRegion: NO];
|
[map_i writeMapFile: FN_CRASHSAVE useRegion:NO];
|
||||||
NSRunAlertPanel (@"Error", [NSString stringWithCString: string],NULL,NULL,NULL);
|
NSRunAlertPanel (@"Error",[NSString stringWithCString:string], NULL, NULL,
|
||||||
|
NULL);
|
||||||
[NSApp terminate: NULL];
|
|
||||||
|
[NSApp terminate:NULL];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CleanupName (char *in, char *out)
|
void
|
||||||
|
CleanupName (char *in, char *out)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0 ; i< 16 ; i++ )
|
for (i = 0; i < 16; i++) {
|
||||||
{
|
|
||||||
if (!in[i])
|
if (!in[i])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
out[i] = toupper(in[i]);
|
out[i] = toupper (in[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; i< 16 ; i++ )
|
for (; i < 16; i++)
|
||||||
out[i] = 0;
|
out[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrintRect (NSRect *r)
|
void
|
||||||
|
PrintRect (NSRect * r)
|
||||||
{
|
{
|
||||||
printf ("(%4.0f, %4.0f) + (%4.0f, %4.0f) = (%4.0f,%4.0f)\n"
|
printf ("(%4.0f, %4.0f) + (%4.0f, %4.0f) = (%4.0f,%4.0f)\n", r->origin.x,
|
||||||
,r->origin.x,r->origin.y,
|
r->origin.y, r->size.width, r->size.height,
|
||||||
r->size.width, r->size.height, r->origin.x+r->size.width,
|
r->origin.x + r->size.width, r->origin.y + r->size.height);
|
||||||
r->origin.y+r->size.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,13 +171,14 @@ FileTime
|
||||||
returns -1 if not present
|
returns -1 if not present
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
int FileTime (char *path)
|
int
|
||||||
|
FileTime (char *path)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
if (stat (path,&buf) == -1)
|
if (stat (path, &buf) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return buf.st_mtime;
|
return buf.st_mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,49 +187,49 @@ int FileTime (char *path)
|
||||||
CreatePath
|
CreatePath
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void CreatePath (char *path)
|
void
|
||||||
|
CreatePath (char *path)
|
||||||
{
|
{
|
||||||
char *ofs;
|
char *ofs;
|
||||||
|
|
||||||
for (ofs = path+1 ; *ofs ; ofs++)
|
for (ofs = path + 1; *ofs; ofs++) {
|
||||||
{
|
if (*ofs == '/') { // create the directory
|
||||||
if (*ofs == '/')
|
|
||||||
{ // create the directory
|
|
||||||
*ofs = 0;
|
*ofs = 0;
|
||||||
mkdir (path,0777);
|
mkdir (path, 0777);
|
||||||
*ofs = '/';
|
*ofs = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int I_FileOpenRead (char *path, int *handle)
|
int
|
||||||
|
I_FileOpenRead (char *path, int *handle)
|
||||||
{
|
{
|
||||||
int h;
|
int h;
|
||||||
struct stat fileinfo;
|
struct stat fileinfo;
|
||||||
|
|
||||||
|
|
||||||
h = open (path, O_RDONLY, 0666);
|
h = open (path, O_RDONLY, 0666);
|
||||||
*handle = h;
|
*handle = h;
|
||||||
if (h == -1)
|
if (h == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (fstat (h,&fileinfo) == -1)
|
if (fstat (h, &fileinfo) == -1)
|
||||||
Error ("Error fstating %s", path);
|
Error ("Error fstating %s", path);
|
||||||
|
|
||||||
return fileinfo.st_size;
|
return fileinfo.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int I_FileOpenWrite (char *path)
|
int
|
||||||
|
I_FileOpenWrite (char *path)
|
||||||
{
|
{
|
||||||
int handle;
|
int handle;
|
||||||
|
|
||||||
umask (0);
|
umask (0);
|
||||||
|
|
||||||
handle = open(path,O_RDWR | O_CREAT | O_TRUNC
|
handle = open (path, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
||||||
, 0666);
|
|
||||||
|
|
||||||
if (handle == -1)
|
if (handle == -1)
|
||||||
Error ("Error opening %s: %s", path,strerror(errno));
|
Error ("Error opening %s: %s", path, strerror (errno));
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
@ -242,32 +241,31 @@ Sys_UpdateFile
|
||||||
Copies a more recent net file to the local drive
|
Copies a more recent net file to the local drive
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
void Sys_UpdateFile (char *path, char *netpath)
|
void
|
||||||
|
Sys_UpdateFile (char *path, char *netpath)
|
||||||
{
|
{
|
||||||
int ltime, ntime;
|
int ltime, ntime;
|
||||||
int in, out, size;
|
int in, out, size;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
ltime = FileTime (path);
|
ltime = FileTime (path);
|
||||||
ntime = FileTime (netpath);
|
ntime = FileTime (netpath);
|
||||||
|
|
||||||
if (ntime <= ltime)
|
if (ntime <= ltime)
|
||||||
return; // up to date
|
return; // up to date
|
||||||
|
|
||||||
// copy the file
|
// copy the file
|
||||||
printf ("UpdateFile: copying %s to %s...\n", netpath, path);
|
printf ("UpdateFile: copying %s to %s...\n", netpath, path);
|
||||||
|
|
||||||
size = I_FileOpenRead (netpath, &in);
|
size = I_FileOpenRead (netpath, &in);
|
||||||
buf = malloc (size);
|
buf = malloc (size);
|
||||||
if (read (in, buf, size) != size)
|
if (read (in, buf, size) != size)
|
||||||
Error ("UpdateFile: couldn't read all of %s", netpath);
|
Error ("UpdateFile: couldn't read all of %s", netpath);
|
||||||
close (in);
|
close (in);
|
||||||
|
|
||||||
CreatePath (path);
|
CreatePath (path);
|
||||||
out = I_FileOpenWrite (path);
|
out = I_FileOpenWrite (path);
|
||||||
write (out, buf, size);
|
write (out, buf, size);
|
||||||
close (out);
|
close (out);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,44 +1,45 @@
|
||||||
|
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
|
|
||||||
extern vec3_t xy_viewnormal;
|
extern vec3_t xy_viewnormal;
|
||||||
|
|
||||||
//define NOLIGHT
|
//define NOLIGHT
|
||||||
|
|
||||||
vec3_t r_origin, r_matrix[3];
|
vec3_t r_origin, r_matrix[3];
|
||||||
|
|
||||||
int t_width, t_height;
|
int t_width, t_height;
|
||||||
unsigned *t_data;
|
unsigned *t_data;
|
||||||
int t_widthmask, t_heightmask, t_widthshift;
|
int t_widthmask, t_heightmask, t_widthshift;
|
||||||
float t_widthadd, t_heightadd;
|
float t_widthadd, t_heightadd;
|
||||||
|
|
||||||
int r_width, r_height;
|
int r_width, r_height;
|
||||||
float *r_zbuffer;
|
float *r_zbuffer;
|
||||||
unsigned *r_picbuffer;
|
unsigned *r_picbuffer;
|
||||||
|
|
||||||
vec5_t rightside, leftside, rightstep,leftstep;
|
vec5_t rightside, leftside, rightstep, leftstep;
|
||||||
|
|
||||||
face_t *r_face;
|
face_t *r_face;
|
||||||
|
|
||||||
BOOL r_drawflat;
|
BOOL r_drawflat;
|
||||||
|
|
||||||
pixel32_t r_flatcolor;
|
pixel32_t r_flatcolor;
|
||||||
|
|
||||||
int sy[20];
|
int sy[20];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
REN_ClearBuffers
|
REN_ClearBuffers
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
void REN_ClearBuffers (void)
|
void
|
||||||
|
REN_ClearBuffers (void)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
size = r_width * r_height*4;
|
size = r_width * r_height * 4;
|
||||||
|
|
||||||
memset (r_zbuffer, 0, size);
|
memset (r_zbuffer, 0, size);
|
||||||
memset (r_picbuffer, 0, size);
|
memset (r_picbuffer, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,16 +49,17 @@ REN_SetTexture
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void REN_SetTexture (face_t *face)
|
void
|
||||||
|
REN_SetTexture (face_t * face)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int t_heightshift;
|
int t_heightshift;
|
||||||
qtexture_t *q;
|
qtexture_t *q;
|
||||||
|
|
||||||
if (!face->qtexture)
|
if (!face->qtexture)
|
||||||
face->qtexture = TEX_ForName (face->texture.texture); // try to load
|
face->qtexture = TEX_ForName (face->texture.texture); // try to load
|
||||||
q = face->qtexture;
|
q = face->qtexture;
|
||||||
|
|
||||||
t_width = q->width;
|
t_width = q->width;
|
||||||
t_height = q->height;
|
t_height = q->height;
|
||||||
t_data = q->data;
|
t_data = q->data;
|
||||||
|
@ -66,30 +68,28 @@ void REN_SetTexture (face_t *face)
|
||||||
r_flatcolor.chan[0] *= r_face->light;
|
r_flatcolor.chan[0] *= r_face->light;
|
||||||
r_flatcolor.chan[1] *= r_face->light;
|
r_flatcolor.chan[1] *= r_face->light;
|
||||||
r_flatcolor.chan[2] *= r_face->light;
|
r_flatcolor.chan[2] *= r_face->light;
|
||||||
|
|
||||||
t_widthadd = t_width*1024;
|
t_widthadd = t_width * 1024;
|
||||||
t_heightadd = t_height*1024;
|
t_heightadd = t_height * 1024;
|
||||||
|
|
||||||
t_widthmask = t_width-1;
|
t_widthmask = t_width - 1;
|
||||||
t_heightmask = t_height-1;
|
t_heightmask = t_height - 1;
|
||||||
|
|
||||||
t_widthshift = 0;
|
t_widthshift = 0;
|
||||||
i = t_width;
|
i = t_width;
|
||||||
while (i >= 2)
|
while (i >= 2) {
|
||||||
{
|
|
||||||
t_widthshift++;
|
t_widthshift++;
|
||||||
i>>=1;
|
i >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
t_heightshift = 0;
|
t_heightshift = 0;
|
||||||
i = t_width;
|
i = t_width;
|
||||||
while (i >= 2)
|
while (i >= 2) {
|
||||||
{
|
|
||||||
t_heightshift++;
|
t_heightshift++;
|
||||||
i>>=1;
|
i >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (1<<t_widthshift) != t_width || (1<<t_heightshift) != t_height)
|
if ((1 << t_widthshift) != t_width || (1 << t_heightshift) != t_height)
|
||||||
t_widthshift = t_heightshift = 0; // non power of two
|
t_widthshift = t_heightshift = 0; // non power of two
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,82 +98,77 @@ void REN_SetTexture (face_t *face)
|
||||||
REN_DrawSpan
|
REN_DrawSpan
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
void REN_DrawSpan (int y)
|
void
|
||||||
|
REN_DrawSpan (int y)
|
||||||
{
|
{
|
||||||
int x, count;
|
int x, count;
|
||||||
int ofs;
|
int ofs;
|
||||||
int tx, ty;
|
int tx, ty;
|
||||||
int x1, x2;
|
int x1, x2;
|
||||||
float ufrac, vfrac, zfrac, lightfrac, ustep, vstep, zstep;
|
float ufrac, vfrac, zfrac, lightfrac, ustep, vstep, zstep;
|
||||||
pixel32_t *in, *out;
|
pixel32_t *in, *out;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
if (y<0 || y >= r_height)
|
if (y < 0 || y >= r_height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x1 = (leftside[0]);
|
x1 = (leftside[0]);
|
||||||
x2 = (rightside[0]);
|
x2 = (rightside[0]);
|
||||||
|
|
||||||
count = x2 - x1;
|
count = x2 - x1;
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
zfrac = leftside[2];
|
zfrac = leftside[2];
|
||||||
ufrac = leftside[3];
|
ufrac = leftside[3];
|
||||||
vfrac = leftside[4];
|
vfrac = leftside[4];
|
||||||
lightfrac = r_face->light;
|
lightfrac = r_face->light;
|
||||||
|
|
||||||
if (!count)
|
if (!count)
|
||||||
scale = 1;
|
scale = 1;
|
||||||
else
|
else
|
||||||
scale = 1.0/count;
|
scale = 1.0 / count;
|
||||||
|
|
||||||
zstep = (rightside[2] - zfrac)*scale;
|
zstep = (rightside[2] - zfrac) * scale;
|
||||||
ustep = (rightside[3] - ufrac)*scale;
|
ustep = (rightside[3] - ufrac) * scale;
|
||||||
vstep = (rightside[4] - vfrac)*scale;
|
vstep = (rightside[4] - vfrac) * scale;
|
||||||
|
|
||||||
if (x1 < 0)
|
if (x1 < 0) {
|
||||||
{
|
ufrac -= x1 * ustep;
|
||||||
ufrac -= x1*ustep;
|
vfrac -= x1 * vstep;
|
||||||
vfrac -= x1*vstep;
|
zfrac -= x1 * zstep;
|
||||||
zfrac -= x1*zstep;
|
|
||||||
x1 = 0;
|
x1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x2 > r_width)
|
if (x2 > r_width)
|
||||||
x2 = r_width;
|
x2 = r_width;
|
||||||
|
|
||||||
ofs = y*r_width+x1;
|
ofs = y * r_width + x1;
|
||||||
|
|
||||||
// this should be specialized for 1.0 / 0.5 / 0.75 light levels
|
// this should be specialized for 1.0 / 0.5 / 0.75 light levels
|
||||||
for (x=x1 ; x < x2 ; x++)
|
for (x = x1; x < x2; x++) {
|
||||||
{
|
if (r_zbuffer[ofs] <= zfrac) {
|
||||||
if (r_zbuffer[ofs] <= zfrac)
|
scale = 1 / zfrac;
|
||||||
{
|
|
||||||
scale = 1/zfrac;
|
|
||||||
|
|
||||||
r_zbuffer[ofs] = zfrac;
|
r_zbuffer[ofs] = zfrac;
|
||||||
|
|
||||||
if (t_widthshift)
|
if (t_widthshift) {
|
||||||
{
|
tx = (int) ((ufrac * scale)) & t_widthmask;
|
||||||
tx = (int)((ufrac*scale)) & t_widthmask;
|
ty = (int) ((vfrac * scale)) & t_heightmask;
|
||||||
ty = (int)((vfrac*scale)) & t_heightmask;
|
in = (pixel32_t *) & t_data[(ty << t_widthshift) + tx];
|
||||||
in = (pixel32_t *)&t_data [(ty<<t_widthshift)+tx];
|
} else {
|
||||||
|
tx = (int) ((ufrac * scale) + t_widthadd) % t_width;
|
||||||
|
ty = (int) ((vfrac * scale) + t_heightadd) % t_height;
|
||||||
|
in = (pixel32_t *) & t_data[ty * t_width + tx];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
out = (pixel32_t *) & r_picbuffer[ofs];
|
||||||
tx = (int)((ufrac*scale)+t_widthadd) % t_width;
|
|
||||||
ty = (int)((vfrac*scale)+t_heightadd) % t_height;
|
|
||||||
in = (pixel32_t *)&t_data [ty*t_width+tx];
|
|
||||||
}
|
|
||||||
|
|
||||||
out = (pixel32_t *)&r_picbuffer[ofs];
|
|
||||||
#ifdef NOLIGHT
|
#ifdef NOLIGHT
|
||||||
*out = *in;
|
*out = *in;
|
||||||
#else
|
#else
|
||||||
out->chan[0] = in->chan[0]*lightfrac;
|
out->chan[0] = in->chan[0] * lightfrac;
|
||||||
out->chan[1] = in->chan[1]*lightfrac;
|
out->chan[1] = in->chan[1] * lightfrac;
|
||||||
out->chan[2] = in->chan[2]*lightfrac;
|
out->chan[2] = in->chan[2] * lightfrac;
|
||||||
out->chan[3] = 0xff;
|
out->chan[3] = 0xff;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -190,46 +185,44 @@ void REN_DrawSpan (int y)
|
||||||
REN_DrawFlatSpan
|
REN_DrawFlatSpan
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
void REN_DrawFlatSpan (int y)
|
void
|
||||||
|
REN_DrawFlatSpan (int y)
|
||||||
{
|
{
|
||||||
int x, count;
|
int x, count;
|
||||||
int ofs;
|
int ofs;
|
||||||
int x1, x2;
|
int x1, x2;
|
||||||
float zfrac, zstep;
|
float zfrac, zstep;
|
||||||
int *out;
|
int *out;
|
||||||
|
|
||||||
if (y<0 || y >= r_height)
|
if (y < 0 || y >= r_height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x1 = (leftside[0]);
|
x1 = (leftside[0]);
|
||||||
x2 = (rightside[0]);
|
x2 = (rightside[0]);
|
||||||
|
|
||||||
count = x2 - x1;
|
count = x2 - x1;
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
zfrac = leftside[2];
|
zfrac = leftside[2];
|
||||||
|
|
||||||
zstep = (rightside[2] - zfrac)/count;
|
zstep = (rightside[2] - zfrac) / count;
|
||||||
|
|
||||||
if (x1 < 0)
|
if (x1 < 0) {
|
||||||
{
|
zfrac -= x1 * zstep;
|
||||||
zfrac -= x1*zstep;
|
|
||||||
x1 = 0;
|
x1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x2 > r_width)
|
if (x2 > r_width)
|
||||||
x2 = r_width;
|
x2 = r_width;
|
||||||
|
|
||||||
ofs = y*r_width+x1;
|
ofs = y * r_width + x1;
|
||||||
|
|
||||||
// this should be specialized for 1.0 / 0.5 / 0.75 light levels
|
// this should be specialized for 1.0 / 0.5 / 0.75 light levels
|
||||||
for (x=x1 ; x < x2 ; x++)
|
for (x = x1; x < x2; x++) {
|
||||||
{
|
if (r_zbuffer[ofs] <= zfrac) {
|
||||||
if (r_zbuffer[ofs] <= zfrac)
|
|
||||||
{
|
|
||||||
r_zbuffer[ofs] = zfrac;
|
r_zbuffer[ofs] = zfrac;
|
||||||
out = (int *)&r_picbuffer[ofs];
|
out = (int *) &r_picbuffer[ofs];
|
||||||
*out = r_flatcolor.p;
|
*out = r_flatcolor.p;
|
||||||
}
|
}
|
||||||
zfrac += zstep;
|
zfrac += zstep;
|
||||||
|
@ -244,14 +237,15 @@ REN_RasterizeFace
|
||||||
|
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
void REN_RasterizeFace (winding_t *w)
|
void
|
||||||
|
REN_RasterizeFace (winding_t * w)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
int i;
|
int i;
|
||||||
int top, bot;
|
int top, bot;
|
||||||
int leftv, rightv;
|
int leftv, rightv;
|
||||||
int count;
|
int count;
|
||||||
int numvertex;
|
int numvertex;
|
||||||
|
|
||||||
//
|
//
|
||||||
// find top vertex
|
// find top vertex
|
||||||
|
@ -260,74 +254,66 @@ void REN_RasterizeFace (winding_t *w)
|
||||||
top = 0x7fffffff;
|
top = 0x7fffffff;
|
||||||
bot = 0x80000000;
|
bot = 0x80000000;
|
||||||
leftv = 0;
|
leftv = 0;
|
||||||
|
|
||||||
for (i=0 ; i<numvertex ; i++)
|
for (i = 0; i < numvertex; i++) {
|
||||||
{
|
|
||||||
w->points[i][3] *= w->points[i][2];
|
w->points[i][3] *= w->points[i][2];
|
||||||
w->points[i][4] *= w->points[i][2];
|
w->points[i][4] *= w->points[i][2];
|
||||||
|
|
||||||
sy[i] = (int)w->points[i][1];
|
sy[i] = (int) w->points[i][1];
|
||||||
|
|
||||||
if (sy[i] < top)
|
if (sy[i] < top) {
|
||||||
{
|
|
||||||
top = sy[i];
|
top = sy[i];
|
||||||
leftv = i;
|
leftv = i;
|
||||||
}
|
}
|
||||||
if (sy[i] > bot)
|
if (sy[i] > bot)
|
||||||
bot = sy[i];
|
bot = sy[i];
|
||||||
}
|
}
|
||||||
rightv = leftv;
|
rightv = leftv;
|
||||||
|
|
||||||
if (top < 0 || bot > r_height || top > bot)
|
if (top < 0 || bot > r_height || top > bot)
|
||||||
return; // shouldn't have to have this...
|
return; // shouldn't have to have this...
|
||||||
|
|
||||||
//
|
//
|
||||||
// render a trapezoid
|
// render a trapezoid
|
||||||
//
|
//
|
||||||
y = top;
|
y = top;
|
||||||
|
|
||||||
while (y < bot)
|
while (y < bot) {
|
||||||
{
|
if (y >= sy[leftv]) {
|
||||||
if (y >= sy[leftv])
|
do {
|
||||||
{
|
for (i = 0; i < 5; i++)
|
||||||
do
|
|
||||||
{
|
|
||||||
for (i=0 ; i<5 ; i++)
|
|
||||||
leftside[i] = w->points[leftv][i];
|
leftside[i] = w->points[leftv][i];
|
||||||
leftv--;
|
leftv--;
|
||||||
if (leftv == -1)
|
if (leftv == -1)
|
||||||
leftv = numvertex-1;
|
leftv = numvertex - 1;
|
||||||
} while (sy[leftv] <= y);
|
} while (sy[leftv] <= y);
|
||||||
count = sy[leftv]-y;
|
count = sy[leftv] - y;
|
||||||
for (i=0 ; i<5 ; i++)
|
for (i = 0; i < 5; i++)
|
||||||
leftstep[i] = (w->points[leftv][i] - leftside[i])/count;
|
leftstep[i] = (w->points[leftv][i] - leftside[i]) / count;
|
||||||
}
|
}
|
||||||
if (y >= sy[rightv])
|
if (y >= sy[rightv]) {
|
||||||
{
|
do {
|
||||||
do
|
for (i = 0; i < 5; i++)
|
||||||
{
|
|
||||||
for (i=0 ; i<5 ; i++)
|
|
||||||
rightside[i] = w->points[rightv][i];
|
rightside[i] = w->points[rightv][i];
|
||||||
rightv++;
|
rightv++;
|
||||||
if (rightv == numvertex)
|
if (rightv == numvertex)
|
||||||
rightv = 0;
|
rightv = 0;
|
||||||
} while (sy[rightv] <= y);
|
} while (sy[rightv] <= y);
|
||||||
count = sy[rightv]-y;
|
count = sy[rightv] - y;
|
||||||
for (i=0 ; i<5 ; i++)
|
for (i = 0; i < 5; i++)
|
||||||
rightstep[i] = (w->points[rightv][i] - rightside[i])/count;
|
rightstep[i] = (w->points[rightv][i] - rightside[i]) / count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r_drawflat)
|
if (r_drawflat)
|
||||||
REN_DrawFlatSpan (y);
|
REN_DrawFlatSpan (y);
|
||||||
else
|
else
|
||||||
REN_DrawSpan (y);
|
REN_DrawSpan (y);
|
||||||
|
|
||||||
for (i=0 ; i<5 ; i++)
|
for (i = 0; i < 5; i++) {
|
||||||
{
|
|
||||||
leftside[i] += leftstep[i];
|
leftside[i] += leftstep[i];
|
||||||
rightside[i] += rightstep[i];
|
rightside[i] += rightstep[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
y++;
|
y++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,73 +325,68 @@ void REN_RasterizeFace (winding_t *w)
|
||||||
REN_DrawSpanLinear
|
REN_DrawSpanLinear
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
void REN_DrawSpanLinear (int y)
|
void
|
||||||
|
REN_DrawSpanLinear (int y)
|
||||||
{
|
{
|
||||||
int x, count;
|
int x, count;
|
||||||
int ofs;
|
int ofs;
|
||||||
int tx, ty;
|
int tx, ty;
|
||||||
int x1, x2;
|
int x1, x2;
|
||||||
float ufrac, vfrac, zfrac, ustep, vstep, zstep;
|
float ufrac, vfrac, zfrac, ustep, vstep, zstep;
|
||||||
pixel32_t *in, *out;
|
pixel32_t *in, *out;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
if (y<0 || y >= r_height)
|
if (y < 0 || y >= r_height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x1 = (leftside[0]);
|
x1 = (leftside[0]);
|
||||||
x2 = (rightside[0]);
|
x2 = (rightside[0]);
|
||||||
|
|
||||||
count = x2 - x1;
|
count = x2 - x1;
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
zfrac = leftside[2];
|
zfrac = leftside[2];
|
||||||
ufrac = leftside[3];
|
ufrac = leftside[3];
|
||||||
vfrac = leftside[4];
|
vfrac = leftside[4];
|
||||||
|
|
||||||
if (!count)
|
if (!count)
|
||||||
scale = 1;
|
scale = 1;
|
||||||
else
|
else
|
||||||
scale = 1.0/count;
|
scale = 1.0 / count;
|
||||||
|
|
||||||
zstep = (rightside[2] - zfrac)*scale;
|
|
||||||
ustep = (rightside[3] - ufrac)*scale;
|
|
||||||
vstep = (rightside[4] - vfrac)*scale;
|
|
||||||
|
|
||||||
|
zstep = (rightside[2] - zfrac) * scale;
|
||||||
if (x1 < 0)
|
ustep = (rightside[3] - ufrac) * scale;
|
||||||
{
|
vstep = (rightside[4] - vfrac) * scale;
|
||||||
ufrac -= x1*ustep;
|
|
||||||
vfrac -= x1*vstep;
|
|
||||||
zfrac -= x1*zstep;
|
if (x1 < 0) {
|
||||||
|
ufrac -= x1 * ustep;
|
||||||
|
vfrac -= x1 * vstep;
|
||||||
|
zfrac -= x1 * zstep;
|
||||||
x1 = 0;
|
x1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x2 > r_width)
|
if (x2 > r_width)
|
||||||
x2 = r_width;
|
x2 = r_width;
|
||||||
|
|
||||||
ofs = y*r_width+x1;
|
ofs = y * r_width + x1;
|
||||||
|
|
||||||
for (x=x1 ; x < x2 ; x++)
|
for (x = x1; x < x2; x++) {
|
||||||
{
|
if (r_zbuffer[ofs] <= zfrac) {
|
||||||
if (r_zbuffer[ofs] <= zfrac)
|
|
||||||
{
|
|
||||||
r_zbuffer[ofs] = zfrac;
|
r_zbuffer[ofs] = zfrac;
|
||||||
|
|
||||||
if (t_widthshift)
|
if (t_widthshift) {
|
||||||
{
|
tx = (int) ufrac & t_widthmask;
|
||||||
tx = (int)ufrac & t_widthmask;
|
ty = (int) vfrac & t_heightmask;
|
||||||
ty = (int)vfrac & t_heightmask;
|
in = (pixel32_t *) & t_data[(ty << t_widthshift) + tx];
|
||||||
in = (pixel32_t *)&t_data [(ty<<t_widthshift)+tx];
|
} else {
|
||||||
|
tx = (int) (ufrac + t_widthadd) % t_width;
|
||||||
|
ty = (int) (vfrac + t_heightadd) % t_height;
|
||||||
|
in = (pixel32_t *) & t_data[ty * t_width + tx];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
out = (pixel32_t *) & r_picbuffer[ofs];
|
||||||
tx = (int)(ufrac+t_widthadd) % t_width;
|
|
||||||
ty = (int)(vfrac+t_heightadd) % t_height;
|
|
||||||
in = (pixel32_t *)&t_data [ty*t_width+tx];
|
|
||||||
}
|
|
||||||
|
|
||||||
out = (pixel32_t *)&r_picbuffer[ofs];
|
|
||||||
*out = *in;
|
*out = *in;
|
||||||
}
|
}
|
||||||
ufrac += ustep;
|
ufrac += ustep;
|
||||||
|
@ -422,15 +403,16 @@ REN_RasterizeFaceLinear
|
||||||
|
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
void REN_RasterizeFaceLinear (winding_t *w)
|
void
|
||||||
|
REN_RasterizeFaceLinear (winding_t * w)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
int i;
|
int i;
|
||||||
int top, bot;
|
int top, bot;
|
||||||
int leftv, rightv;
|
int leftv, rightv;
|
||||||
int count;
|
int count;
|
||||||
int numvertex;
|
int numvertex;
|
||||||
|
|
||||||
//
|
//
|
||||||
// find top vertex
|
// find top vertex
|
||||||
//
|
//
|
||||||
|
@ -439,67 +421,59 @@ void REN_RasterizeFaceLinear (winding_t *w)
|
||||||
bot = 0x80000000;
|
bot = 0x80000000;
|
||||||
|
|
||||||
leftv = 0;
|
leftv = 0;
|
||||||
for (i=0 ; i<numvertex ; i++)
|
for (i = 0; i < numvertex; i++) {
|
||||||
{
|
sy[i] = (int) w->points[i][1];
|
||||||
sy[i] = (int)w->points[i][1];
|
|
||||||
|
if (sy[i] < top) {
|
||||||
if (sy[i] < top)
|
|
||||||
{
|
|
||||||
top = sy[i];
|
top = sy[i];
|
||||||
leftv = i;
|
leftv = i;
|
||||||
}
|
}
|
||||||
if (sy[i] > bot)
|
if (sy[i] > bot)
|
||||||
bot = sy[i];
|
bot = sy[i];
|
||||||
}
|
}
|
||||||
rightv = leftv;
|
rightv = leftv;
|
||||||
|
|
||||||
if (top < 0 || bot > r_height || top > bot)
|
if (top < 0 || bot > r_height || top > bot)
|
||||||
return; // shouldn't have to have this...
|
return; // shouldn't have to have this...
|
||||||
|
|
||||||
//
|
//
|
||||||
// render a trapezoid
|
// render a trapezoid
|
||||||
//
|
//
|
||||||
y = top;
|
y = top;
|
||||||
|
|
||||||
while (y < bot)
|
while (y < bot) {
|
||||||
{
|
if (y >= sy[leftv]) {
|
||||||
if (y >= sy[leftv])
|
do {
|
||||||
{
|
for (i = 0; i < 5; i++)
|
||||||
do
|
|
||||||
{
|
|
||||||
for (i=0 ; i<5 ; i++)
|
|
||||||
leftside[i] = w->points[leftv][i];
|
leftside[i] = w->points[leftv][i];
|
||||||
leftv--;
|
leftv--;
|
||||||
if (leftv == -1)
|
if (leftv == -1)
|
||||||
leftv = numvertex-1;
|
leftv = numvertex - 1;
|
||||||
} while (sy[leftv] <= y);
|
} while (sy[leftv] <= y);
|
||||||
count = sy[leftv]-y;
|
count = sy[leftv] - y;
|
||||||
for (i=0 ; i<5 ; i++)
|
for (i = 0; i < 5; i++)
|
||||||
leftstep[i] = (w->points[leftv][i] - leftside[i])/count;
|
leftstep[i] = (w->points[leftv][i] - leftside[i]) / count;
|
||||||
}
|
}
|
||||||
if (y >= sy[rightv])
|
if (y >= sy[rightv]) {
|
||||||
{
|
do {
|
||||||
do
|
for (i = 0; i < 5; i++)
|
||||||
{
|
|
||||||
for (i=0 ; i<5 ; i++)
|
|
||||||
rightside[i] = w->points[rightv][i];
|
rightside[i] = w->points[rightv][i];
|
||||||
rightv++;
|
rightv++;
|
||||||
if (rightv == numvertex)
|
if (rightv == numvertex)
|
||||||
rightv = 0;
|
rightv = 0;
|
||||||
} while (sy[rightv] <= y);
|
} while (sy[rightv] <= y);
|
||||||
count = sy[rightv]-y;
|
count = sy[rightv] - y;
|
||||||
for (i=0 ; i<5 ; i++)
|
for (i = 0; i < 5; i++)
|
||||||
rightstep[i] = (w->points[rightv][i] - rightside[i])/count;
|
rightstep[i] = (w->points[rightv][i] - rightside[i]) / count;
|
||||||
}
|
}
|
||||||
|
|
||||||
REN_DrawSpanLinear (y);
|
REN_DrawSpanLinear (y);
|
||||||
|
|
||||||
for (i=0 ; i<5 ; i++)
|
for (i = 0; i < 5; i++) {
|
||||||
{
|
|
||||||
leftside[i] += leftstep[i];
|
leftside[i] += leftstep[i];
|
||||||
rightside[i] += rightstep[i];
|
rightside[i] += rightstep[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
y++;
|
y++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -511,15 +485,16 @@ void REN_RasterizeFaceLinear (winding_t *w)
|
||||||
REN_BeginCamera
|
REN_BeginCamera
|
||||||
===================
|
===================
|
||||||
*/
|
*/
|
||||||
float r_width_2, r_height_3;
|
float r_width_2, r_height_3;
|
||||||
plane_t rfrustum[5];
|
plane_t rfrustum[5];
|
||||||
|
|
||||||
void REN_BeginCamera (void)
|
void
|
||||||
|
REN_BeginCamera (void)
|
||||||
{
|
{
|
||||||
r_width_2 = (float)r_width / 2;
|
r_width_2 = (float) r_width / 2;
|
||||||
r_height_3 = (float)r_height / 3;
|
r_height_3 = (float) r_height / 3;
|
||||||
|
|
||||||
|
|
||||||
// clip to right side
|
// clip to right side
|
||||||
rfrustum[0].normal[0] = -1;
|
rfrustum[0].normal[0] = -1;
|
||||||
rfrustum[0].normal[1] = 0;
|
rfrustum[0].normal[1] = 0;
|
||||||
|
@ -541,7 +516,7 @@ void REN_BeginCamera (void)
|
||||||
// clip to bottom side
|
// clip to bottom side
|
||||||
rfrustum[3].normal[0] = 0;
|
rfrustum[3].normal[0] = 0;
|
||||||
rfrustum[3].normal[1] = 1;
|
rfrustum[3].normal[1] = 1;
|
||||||
rfrustum[3].normal[2] = 2*r_height_3 / r_width_2;
|
rfrustum[3].normal[2] = 2 * r_height_3 / r_width_2;
|
||||||
rfrustum[3].dist = 0;
|
rfrustum[3].dist = 0;
|
||||||
|
|
||||||
// near Z
|
// near Z
|
||||||
|
@ -552,13 +527,14 @@ void REN_BeginCamera (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void REN_BeginXY (void)
|
void
|
||||||
|
REN_BeginXY (void)
|
||||||
{
|
{
|
||||||
rfrustum[0].normal[0] = 1;
|
rfrustum[0].normal[0] = 1;
|
||||||
rfrustum[0].normal[1] = 0;
|
rfrustum[0].normal[1] = 0;
|
||||||
rfrustum[0].normal[2] = 0;
|
rfrustum[0].normal[2] = 0;
|
||||||
rfrustum[0].dist = 0;
|
rfrustum[0].dist = 0;
|
||||||
|
|
||||||
rfrustum[1].normal[0] = -1;
|
rfrustum[1].normal[0] = -1;
|
||||||
rfrustum[1].normal[1] = 0;
|
rfrustum[1].normal[1] = 0;
|
||||||
rfrustum[1].normal[2] = 0;
|
rfrustum[1].normal[2] = 0;
|
||||||
|
@ -580,17 +556,18 @@ void REN_BeginXY (void)
|
||||||
REN_DrawCameraFace
|
REN_DrawCameraFace
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
void REN_DrawCameraFace (face_t *idpol)
|
void
|
||||||
|
REN_DrawCameraFace (face_t * idpol)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
float scale;
|
float scale;
|
||||||
int numvertex;
|
int numvertex;
|
||||||
winding_t *w, *in;
|
winding_t *w, *in;
|
||||||
vec3_t temp;
|
vec3_t temp;
|
||||||
|
|
||||||
if (!idpol->w)
|
if (!idpol->w)
|
||||||
return; // overconstrained plane
|
return; // overconstrained plane
|
||||||
|
|
||||||
r_face = idpol;
|
r_face = idpol;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -607,45 +584,42 @@ void REN_DrawCameraFace (face_t *idpol)
|
||||||
|
|
||||||
w = NewWinding (numvertex);
|
w = NewWinding (numvertex);
|
||||||
w->numpoints = numvertex;
|
w->numpoints = numvertex;
|
||||||
for (i=0 ; i<numvertex ; i++)
|
for (i = 0; i < numvertex; i++) {
|
||||||
{
|
|
||||||
VectorSubtract (in->points[i], r_origin, temp);
|
VectorSubtract (in->points[i], r_origin, temp);
|
||||||
|
|
||||||
w->points[i][0] = DotProduct(temp,r_matrix[0]);
|
w->points[i][0] = DotProduct (temp, r_matrix[0]);
|
||||||
w->points[i][1] = DotProduct(temp,r_matrix[1]);
|
w->points[i][1] = DotProduct (temp, r_matrix[1]);
|
||||||
w->points[i][2] = DotProduct(temp,r_matrix[2]);
|
w->points[i][2] = DotProduct (temp, r_matrix[2]);
|
||||||
|
|
||||||
w->points[i][3] = in->points[i][3];
|
w->points[i][3] = in->points[i][3];
|
||||||
w->points[i][4] = in->points[i][4];
|
w->points[i][4] = in->points[i][4];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// 3D clip
|
// 3D clip
|
||||||
//
|
//
|
||||||
for (i=0 ; i<4 ; i++)
|
for (i = 0; i < 4; i++) {
|
||||||
{
|
|
||||||
w = ClipWinding (w, &rfrustum[i]);
|
w = ClipWinding (w, &rfrustum[i]);
|
||||||
if (!w)
|
if (!w)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// project to 2D
|
// project to 2D
|
||||||
//
|
//
|
||||||
for (i=0 ; i<w->numpoints ; i++)
|
for (i = 0; i < w->numpoints; i++) {
|
||||||
{
|
|
||||||
scale = r_width_2 / w->points[i][2];
|
scale = r_width_2 / w->points[i][2];
|
||||||
w->points[i][0] = r_width_2 + scale*w->points[i][0];
|
w->points[i][0] = r_width_2 + scale * w->points[i][0];
|
||||||
w->points[i][1] = r_height_3 - scale*w->points[i][1];
|
w->points[i][1] = r_height_3 - scale * w->points[i][1];
|
||||||
w->points[i][2] = scale;
|
w->points[i][2] = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// draw it
|
// draw it
|
||||||
//
|
//
|
||||||
REN_SetTexture (idpol);
|
REN_SetTexture (idpol);
|
||||||
|
|
||||||
REN_RasterizeFace (w);
|
REN_RasterizeFace (w);
|
||||||
free (w);
|
free (w);
|
||||||
}
|
}
|
||||||
|
@ -656,19 +630,20 @@ void REN_DrawCameraFace (face_t *idpol)
|
||||||
REN_DrawXYFace
|
REN_DrawXYFace
|
||||||
=====================
|
=====================
|
||||||
*/
|
*/
|
||||||
void REN_DrawXYFace (face_t *idpol)
|
void
|
||||||
|
REN_DrawXYFace (face_t * idpol)
|
||||||
{
|
{
|
||||||
int i, j, numvertex;
|
int i, j, numvertex;
|
||||||
winding_t *w, *in;
|
winding_t *w, *in;
|
||||||
float *dest, *source;
|
float *dest, *source;
|
||||||
float temp;
|
float temp;
|
||||||
|
|
||||||
if (!idpol->w)
|
if (!idpol->w)
|
||||||
return; // overconstrained plane
|
return; // overconstrained plane
|
||||||
w = idpol->w;
|
w = idpol->w;
|
||||||
|
|
||||||
r_face = idpol;
|
r_face = idpol;
|
||||||
|
|
||||||
//
|
//
|
||||||
// back (and side) face cull
|
// back (and side) face cull
|
||||||
//
|
//
|
||||||
|
@ -684,31 +659,29 @@ void REN_DrawXYFace (face_t *idpol)
|
||||||
w = NewWinding (numvertex);
|
w = NewWinding (numvertex);
|
||||||
w->numpoints = numvertex;
|
w->numpoints = numvertex;
|
||||||
|
|
||||||
for (i=0 ; i<numvertex ; i++)
|
for (i = 0; i < numvertex; i++) {
|
||||||
{
|
// using Z as a scale for the 2D projection
|
||||||
// using Z as a scale for the 2D projection
|
w->points[i][0] = (in->points[i][0] - r_origin[0]) * r_origin[2];
|
||||||
w->points[i][0] = (in->points[i][0] - r_origin[0])*r_origin[2];
|
w->points[i][1] =
|
||||||
w->points[i][1] = r_height - (in->points[i][1] - r_origin[1])*r_origin[2];
|
r_height - (in->points[i][1] - r_origin[1]) * r_origin[2];
|
||||||
w->points[i][2] = in->points[i][2] + 3000;
|
w->points[i][2] = in->points[i][2] + 3000;
|
||||||
w->points[i][3] = in->points[i][3];
|
w->points[i][3] = in->points[i][3];
|
||||||
w->points[i][4] = in->points[i][4];
|
w->points[i][4] = in->points[i][4];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// clip
|
// clip
|
||||||
//
|
//
|
||||||
for (i=0 ; i<4 ; i++)
|
for (i = 0; i < 4; i++) {
|
||||||
{
|
|
||||||
w = ClipWinding (w, &rfrustum[i]);
|
w = ClipWinding (w, &rfrustum[i]);
|
||||||
if (!w)
|
if (!w)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// project to 2D
|
// project to 2D
|
||||||
//
|
//
|
||||||
for (i=0 ; i<w->numpoints ; i++)
|
for (i = 0; i < w->numpoints; i++) {
|
||||||
{
|
|
||||||
dest = w->points[i];
|
dest = w->points[i];
|
||||||
if (dest[0] < 0)
|
if (dest[0] < 0)
|
||||||
dest[0] = 0;
|
dest[0] = 0;
|
||||||
|
@ -719,31 +692,27 @@ void REN_DrawXYFace (face_t *idpol)
|
||||||
if (dest[1] > r_height)
|
if (dest[1] > r_height)
|
||||||
dest[1] = r_height;
|
dest[1] = r_height;
|
||||||
if (xy_viewnormal[2] > 0)
|
if (xy_viewnormal[2] > 0)
|
||||||
dest[2] = 4096-dest[2];
|
dest[2] = 4096 - dest[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xy_viewnormal[2] > 0)
|
if (xy_viewnormal[2] > 0) { // flip order when upside down
|
||||||
{ // flip order when upside down
|
for (i = 0; i < w->numpoints / 2; i++) {
|
||||||
for (i=0 ; i<w->numpoints/2 ; i++)
|
|
||||||
{
|
|
||||||
dest = w->points[i];
|
dest = w->points[i];
|
||||||
source = w->points[w->numpoints-1-i];
|
source = w->points[w->numpoints - 1 - i];
|
||||||
for (j=0 ; j<5 ; j++)
|
for (j = 0; j < 5; j++) {
|
||||||
{
|
|
||||||
temp = dest[j];
|
temp = dest[j];
|
||||||
dest[j] = source[j];
|
dest[j] = source[j];
|
||||||
source[j] = temp;
|
source[j] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
REN_SetTexture (idpol);
|
REN_SetTexture (idpol);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// draw it
|
// draw it
|
||||||
//
|
//
|
||||||
REN_RasterizeFaceLinear (w);
|
REN_RasterizeFaceLinear (w);
|
||||||
free (w);
|
free (w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue