mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-11 11:51:17 +00:00
Use Qprintf for writing maps, and fileSystemRepresentation to get the path.
This commit is contained in:
parent
dc99bc19c5
commit
d29e8deb0a
7 changed files with 32 additions and 31 deletions
|
@ -4,6 +4,7 @@
|
|||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
#include "QF/quakeio.h"
|
||||
|
||||
typedef struct epair_s {
|
||||
struct epair_s *next;
|
||||
|
@ -30,7 +31,7 @@ typedef struct epair_s {
|
|||
|
||||
- (const char *) targetname;
|
||||
|
||||
- (void) writeToFILE: (FILE *)f region: (BOOL)reg;
|
||||
- (void) writeToFile: (QFile *)file region: (BOOL)reg;
|
||||
|
||||
- (const char *) valueForQKey: (const char *)k;
|
||||
- (void) getVector: (vec3_t)v forKey: (const char *)k;
|
||||
|
|
|
@ -393,7 +393,7 @@ int nument;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) writeToFILE: (FILE *)f
|
||||
- (void) writeToFile: (QFile *)file
|
||||
region: (BOOL)reg;
|
||||
{
|
||||
epair_t *e;
|
||||
|
@ -417,7 +417,7 @@ int nument;
|
|||
}
|
||||
}
|
||||
|
||||
fprintf (f, "{\n");
|
||||
Qprintf (file, "{\n");
|
||||
|
||||
// set an origin epair
|
||||
if (!modifiable) {
|
||||
|
@ -441,15 +441,15 @@ int nument;
|
|||
}
|
||||
|
||||
for (e = epairs; e; e = e->next)
|
||||
fprintf (f, "\"%s\"\t\"%s\"\n", e->key, e->value);
|
||||
Qprintf (file, "\"%s\"\t\"%s\"\n", e->key, e->value);
|
||||
|
||||
// fixed size entities don't save out brushes
|
||||
if (modifiable) {
|
||||
for (i = 0; i < [self count]; i++)
|
||||
[[self objectAtIndex: i] writeToFILE: f region: reg];
|
||||
[[self objectAtIndex: i] writeToFile: file region: reg];
|
||||
}
|
||||
|
||||
fprintf (f, "}\n");
|
||||
Qprintf (file, "}\n");
|
||||
|
||||
if (oldang) {
|
||||
[self setKey: "angle" toValue: oldang];
|
||||
|
|
|
@ -22,7 +22,7 @@ extern id map_i;
|
|||
- (id) writeStats;
|
||||
|
||||
- (id) readMapFile: (NSString *)fname;
|
||||
- (id) writeMapFile: (const char *)fname useRegion: (BOOL)reg;
|
||||
- (id) writeMapFile: (NSString *)fname useRegion: (BOOL)reg;
|
||||
|
||||
- (id) entityConnect: (vec3_t)p1: (vec3_t)p2;
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "QF/quakeio.h"
|
||||
#include "QF/script.h"
|
||||
|
@ -301,22 +304,23 @@ readMapFile
|
|||
writeMapFile
|
||||
=================
|
||||
*/
|
||||
- (id) writeMapFile: (const char *)fname
|
||||
- (id) writeMapFile: (NSString *)fname
|
||||
useRegion: (BOOL)reg
|
||||
{
|
||||
FILE *f;
|
||||
unsigned int i;
|
||||
QFile *file = 0;
|
||||
|
||||
Sys_Printf ("writeMapFile: %s\n", fname);
|
||||
NSLog (@"writeMapFile: %@\n", fname);
|
||||
|
||||
f = fopen (fname, "w");
|
||||
if (!f)
|
||||
Sys_Error ("couldn't write %s", fname);
|
||||
file = Qopen ([fname fileSystemRepresentation], "wb");
|
||||
if (!file) {
|
||||
NSLog (@"couldn't write %@, %s", fname, strerror (errno));
|
||||
return self;
|
||||
}
|
||||
for (i = 0; i < [self count]; i++)
|
||||
[[self objectAtIndex: i] writeToFILE: f region: reg];
|
||||
|
||||
fclose (f);
|
||||
[[self objectAtIndex: i] writeToFile: file region: reg];
|
||||
|
||||
Qclose (file);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -133,8 +133,8 @@ Every five minutes, save a modified map
|
|||
// automatic backup
|
||||
if (autodirty) {
|
||||
autodirty = NO;
|
||||
#define FN_AUTOSAVE "/qcache/AutoSaveMap.map"
|
||||
[map_i writeMapFile: (char *) FN_AUTOSAVE useRegion: NO];
|
||||
#define FN_AUTOSAVE @"/qcache/AutoSaveMap.map"
|
||||
[map_i writeMapFile: FN_AUTOSAVE useRegion: NO];
|
||||
}
|
||||
[map_i writeStats];
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ saveBSP
|
|||
if ([regionbutton_i intValue]) {
|
||||
mappath = [[filename stringByDeletingPathExtension]
|
||||
stringByAppendingPathExtension: @"reg"];
|
||||
[map_i writeMapFile: [mappath cString] useRegion: YES];
|
||||
[map_i writeMapFile: mappath useRegion: YES];
|
||||
wt = YES; // allways pop the dialog on region ops
|
||||
} else {
|
||||
mappath = filename;
|
||||
|
@ -838,7 +838,7 @@ save:
|
|||
stringByAppendingPathExtension: @"bak"];
|
||||
rename ([filename cString], [backup cString]); // copy old to .bak
|
||||
|
||||
[map_i writeMapFile: [filename cString] useRegion: NO];
|
||||
[map_i writeMapFile: filename useRegion: NO];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include "QF/mathlib.h"
|
||||
#include "QF/quakeio.h"
|
||||
|
||||
#include "TexturePalette.h"
|
||||
|
||||
|
@ -75,7 +76,7 @@ winding_t *NewWinding (int points);
|
|||
|
||||
- (id) calcWindings;
|
||||
|
||||
- (void) writeToFILE: (FILE *)f region: (BOOL)reg;
|
||||
- (void) writeToFile: (QFile *)file region: (BOOL)reg;
|
||||
|
||||
- (BOOL) selected;
|
||||
- (BOOL) regioned;
|
||||
|
|
|
@ -778,12 +778,7 @@ ParseVerts (script_t *script, int *n_verts)
|
|||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
writeToFILE
|
||||
===========
|
||||
*/
|
||||
- (void) writeToFILE: (FILE *)f
|
||||
- (void) writeToFile: (QFile *)file
|
||||
region: (BOOL)reg
|
||||
{
|
||||
int i, j;
|
||||
|
@ -792,19 +787,19 @@ writeToFILE
|
|||
|
||||
if (reg && regioned)
|
||||
return;
|
||||
fprintf (f, "{\n");
|
||||
Qprintf (file, "{\n");
|
||||
for (i = 0; i < numfaces; i++) {
|
||||
fa = &faces[i];
|
||||
for (j = 0; j < 3; j++) {
|
||||
fprintf (f, "( %d %d %d ) ", (int) fa->planepts[j][0],
|
||||
Qprintf (file, "( %d %d %d ) ", (int) fa->planepts[j][0],
|
||||
(int) fa->planepts[j][1], (int) fa->planepts[j][2]);
|
||||
}
|
||||
td = &fa->texture;
|
||||
fprintf (f, "%s %d %d %d %f %f\n", td->texture, (int) td->shift[0],
|
||||
Qprintf (file, "%s %d %d %d %f %f\n", td->texture, (int) td->shift[0],
|
||||
(int) td->shift[1], (int) td->rotate, td->scale[0],
|
||||
td->scale[1]);
|
||||
}
|
||||
fprintf (f, "}\n");
|
||||
Qprintf (file, "}\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue