Skip to content

Commit

Permalink
Removed 99% of the remaining fixed-length file path limitations. The …
Browse files Browse the repository at this point in the history
…only remaining fixed length paths within the engine are; global paths (such as basedir, runtimedir), low-level paths in the early init stages of the system layer and finally, those used by directory_t On game-side its just the saved game related paths.

Refactored directory_t mimicing the interface semantics of it's Qt::Dir counterpart. Behavior is now logically equivalent where existing functionality was present.

I've not yet gotten around to setting up a development environment for any other platform, so I haven't actually been able to verify my changes on anything but Windows. I don't forsee any issues but it could certainly stand some testing.

Now I'm moving on to the larger changes needed to the file system and resource management in order to resolve the texture loading issues (e.g., supporting Zdoom's HI_START/HI_END to stop mods which use it from breaking everything...).
  • Loading branch information
danij-deng committed Apr 24, 2011
1 parent 1e010e2 commit 88fba1b
Show file tree
Hide file tree
Showing 109 changed files with 2,840 additions and 2,728 deletions.
16 changes: 8 additions & 8 deletions doomsday/engine/api/dd_string.h
Expand Up @@ -93,25 +93,25 @@ void Str_Delete(ddstring_t* ds);
void Str_Clear(ddstring_t* ds);

void Str_Reserve(ddstring_t* ds, int length);
void Str_Set(ddstring_t* ds, const char* text);
void Str_Append(ddstring_t* ds, const char* appendText);
void Str_AppendChar(ddstring_t* ds, char ch);
ddstring_t* Str_Set(ddstring_t* ds, const char* text);
ddstring_t* Str_Append(ddstring_t* ds, const char* appendText);
ddstring_t* Str_AppendChar(ddstring_t* ds, char ch);

/**
* Append formated text.
*/
void Str_Appendf(ddstring_t* ds, const char* format, ...) PRINTF_F(2,3);
ddstring_t* Str_Appendf(ddstring_t* ds, const char* format, ...) PRINTF_F(2,3);

/**
* Appends a portion of a string.
*/
void Str_PartAppend(ddstring_t* dest, const char* src, int start, int count);
ddstring_t* Str_PartAppend(ddstring_t* dest, const char* src, int start, int count);

/**
* Prepend is not even a word, is it? It should be 'prefix'?
*/
void Str_Prepend(ddstring_t* ds, const char* prependText);
void Str_PrependChar(ddstring_t* ds, char ch);
ddstring_t* Str_Prepend(ddstring_t* ds, const char* prependText);
ddstring_t* Str_PrependChar(ddstring_t* ds, char ch);

/**
* This is safe for all strings.
Expand All @@ -128,7 +128,7 @@ char* Str_Text(const ddstring_t* ds);
/**
* Makes a true copy.
*/
void Str_Copy(ddstring_t* dest, const ddstring_t* src);
ddstring_t* Str_Copy(ddstring_t* dest, const ddstring_t* src);

/**
* Strip whitespace from beginning.
Expand Down
9 changes: 0 additions & 9 deletions doomsday/engine/api/dd_types.h
Expand Up @@ -126,10 +126,6 @@ typedef double timespan_t;
#define LUMPNAME_T_LASTINDEX 8
typedef signed char lumpname_t[LUMPNAME_T_MAXLEN];

#define FILENAME_T_MAXLEN 256
#define FILENAME_T_LASTINDEX 255
typedef char filename_t[FILENAME_T_MAXLEN];

/**
* Resource Class.
*
Expand All @@ -151,11 +147,6 @@ typedef enum {

#define VALID_RESOURCE_CLASS(n) ((n) >= RESOURCECLASS_FIRST && (n) < RESOURCECLASS_COUNT)

typedef struct directory_s {
int drive;
filename_t path;
} directory_t;

typedef struct trigger_s {
timespan_t duration;
timespan_t accum;
Expand Down
34 changes: 19 additions & 15 deletions doomsday/engine/api/doomsday.def
Expand Up @@ -105,27 +105,31 @@ EXPORTS

; Base: File system.
F_Access @245 NONAME
F_FileExists @139 NONAME
F_LastModified @246 NONAME
F_MakePath @138 NONAME

M_ReadFile @134 NONAME
M_WriteFile @135 NONAME
M_ExtractFileBase @136 NONAME
M_FindFileExtension @137 NONAME
M_FileExists @139 NONAME
M_CheckPath @138 NONAME
M_TranslatePath @140 NONAME
M_PrettyPath @421 NONAME

W_CheckNumForName @14 NONAME
W_CheckNumForName2 @45 NONAME
W_GetNumForName @15 NONAME
W_LumpLength @16 NONAME
W_LumpName @17 NONAME

W_CheckLumpNumForName @14 NONAME
W_CheckLumpNumForName2 @45 NONAME
W_GetLumpNumForName @15 NONAME

W_ReadLump @18 NONAME
W_ReadLumpSection @253 NONAME
W_CacheLumpNum @19 NONAME
W_ChangeCacheTag @21 NONAME
W_CacheLump @19 NONAME
W_CacheChangeTag @21 NONAME

W_LumpLength @16 NONAME
W_LumpName @17 NONAME
W_LumpSourceFile @22 NONAME
W_LumpFromIWAD @239 NONAME
W_LumpIsFromIWAD @239 NONAME

F_ExtractFileBase @136 NONAME
F_FindFileExtension @137 NONAME
F_TranslatePath @140 NONAME
F_PrettyPath @421 NONAME

; Base: Zone.
Z_Malloc @24 NONAME
Expand Down
36 changes: 19 additions & 17 deletions doomsday/engine/api/doomsday.h
Expand Up @@ -149,31 +149,33 @@ materialnum_t DD_MaterialForTextureIndex(uint index, texturenamespaceid_t texNam

// Base: File system.
int F_Access(const char* path);
int M_FileExists(const char* file);
boolean M_CheckPath(const char* path);
unsigned int F_LastModified(const char* fileName);
int F_FileExists(const char* path);
unsigned int F_LastModified(const char* path);
boolean F_MakePath(const char* path);

size_t M_ReadFile(const char* name, byte** buffer);
boolean M_WriteFile(const char* name, void* source, size_t length);
size_t M_ReadFile(const char* path, char** buffer);
boolean M_WriteFile(const char* path, const char* source, size_t length);

lumpnum_t W_CheckLumpNumForName(const char* path);
lumpnum_t W_CheckLumpNumForName2(const char* path, boolean silent);
lumpnum_t W_GetLumpNumForName(const char* path);

void W_ReadLump(lumpnum_t lumpNum, char* dest);
void W_ReadLumpSection(lumpnum_t lumpNum, char* dest, size_t startOffset, size_t length);
const char* W_CacheLump(lumpnum_t lumpNum, int tag);
void W_CacheChangeTag(lumpnum_t lumpNum, int tag);

lumpnum_t W_CheckNumForName(const char* name);
lumpnum_t W_CheckNumForName2(const char* name, boolean silent);
lumpnum_t W_GetNumForName(const char* name);
size_t W_LumpLength(lumpnum_t lumpNum);
const char* W_LumpName(lumpnum_t lumpNum);
void W_ReadLump(lumpnum_t lumpNum, void* dest);
void W_ReadLumpSection(lumpnum_t lumpNum, void* dest, size_t startOffset, size_t length);
const void* W_CacheLumpNum(lumpnum_t lumpNum, int tag);
void W_ChangeCacheTag(lumpnum_t lumpNum, int tag);
const char* W_LumpSourceFile(lumpnum_t lumpNum);
boolean W_LumpFromIWAD(lumpnum_t lumpNum);
boolean W_LumpIsFromIWAD(lumpnum_t lumpNum);

// Base: File system path/name utilities.
void M_ExtractFileBase(char* dest, const char* path, size_t len);
char* M_FindFileExtension(char* path);
void F_ExtractFileBase(char* dst, const char* path, size_t len);
const char* F_FindFileExtension(const char* path);

void M_TranslatePath(char* translated, const char* path, size_t len);
const char* M_PrettyPath(const char* path);
boolean F_TranslatePath(ddstring_t* dst, const ddstring_t* src);
const char* F_PrettyPath(const char* path);

// Base: Zone.
void* _DECALL Z_Malloc(size_t size, int tag, void* ptr);
Expand Down
6 changes: 2 additions & 4 deletions doomsday/engine/mac/src/qt.c
Expand Up @@ -334,16 +334,14 @@ static void DM_Mus_Stop(void)
// Not needed.
}

static void *DM_Mus_SongBuffer(int length)
static void* DM_Mus_SongBuffer(int length)
{
return DM_Ext_SongBuffer(length);
}

static int DM_Mus_Play(int looped)
{
char fileName[256];

sprintf(fileName, "%s.mid", BUFFERED_MUSIC_FILE);
const char* fileName = (BUFFERED_MUSIC_FILE".mid");
convertMusToMidi((byte*) song, songSize, fileName);
return playFile(fileName, looped);
}
Expand Down
30 changes: 21 additions & 9 deletions doomsday/engine/portable/include/dam_file.h
@@ -1,9 +1,9 @@
/**\file
/**\file dam_file.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2007-2009 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2007-2011 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -22,17 +22,29 @@
*/

/**
* dam_file.h: Doomsday Archived Map (DAM), reader/writer.
* Doomsday Archived Map (DAM), reader/writer.
*/

#ifndef __DOOMSDAY_ARCHIVED_MAP_FILE_H__
#define __DOOMSDAY_ARCHIVED_MAP_FILE_H__
#ifndef LIBDENG_ARCHIVED_MAP_FILE_H
#define LIBDENG_ARCHIVED_MAP_FILE_H

#include "de_play.h"
#include "dd_string.h"

boolean DAM_MapIsValid(filename_t cachedMapDataFile, int markerLumpNum);
/**
* Check if a map in the archive is up to date. The source data must not be
* newer than the cached map data.
*/
boolean DAM_MapIsValid(const char* cachedMapPath, lumpnum_t markerLumpNum);

boolean DAM_MapWrite(gamemap_t *map, filename_t path);
boolean DAM_MapRead(gamemap_t *map, filename_t path);
/**
* Write the current state of the map into a Doomsday Archived Map.
*/
boolean DAM_MapWrite(gamemap_t* map, const char* path);

/**
* Load a map from a Doomsday Archived Map.
*/
boolean DAM_MapRead(gamemap_t* map, const char* path);

#endif
#endif /* LIBDENG_ARCHIVED_MAP_FILE_H */
37 changes: 24 additions & 13 deletions doomsday/engine/portable/include/dam_main.h
@@ -1,9 +1,9 @@
/**\file
/**\file dam_main.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2007-2009 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2007-2011 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -22,11 +22,11 @@
*/

/**
* dam_main.h: Doomsday Archived Map (DAM) reader
* Doomsday Archived Map (DAM) reader
*/

#ifndef __DOOMSDAY_ARCHIVED_MAP_MAIN_H__
#define __DOOMSDAY_ARCHIVED_MAP_MAIN_H__
#ifndef LIBDENG_ARCHIVED_MAP_MAIN_H
#define LIBDENG_ARCHIVED_MAP_MAIN_H

enum {
ML_INVALID = -1,
Expand Down Expand Up @@ -73,20 +73,31 @@ typedef struct archivedmap_s {
char identifier[9];
int numLumps;
int *lumpList;
filename_t cachedMapDataFile;
ddstring_t cachedMapPath;
boolean cachedMapFound;
boolean lastLoadAttemptFailed;
} archivedmap_t;

extern byte mapCache;
extern byte mapCache;

void DAM_Register(void);
/// To be called during init to register the cvars and ccmds for this module.
void DAM_Register(void);

void DAM_Init(void);
void DAM_Shutdown(void);
/// Initialize this module.
void DAM_Init(void);

void DAM_GetCachedMapDir(char* dir, int mainLump, size_t len);
/// Shutdown this module.
void DAM_Shutdown(void);

boolean DAM_AttemptMapLoad(const char* mapID);
/**
* Compose the relative path (relative to the runtime directory) to the directory
* within the archived map cache where maps from the specified source will reside.
*
* @param sourcePath Path to the primary resource file for the original map data.
* @return The composed path. Must be destroyed with Str_Delete().
*/
ddstring_t* DAM_ComposeCacheDir(const char* sourcePath);

boolean DAM_AttemptMapLoad(const char* mapID);

#endif
#endif /* LIBDENG_ARCHIVED_MAP_MAIN_H */
3 changes: 2 additions & 1 deletion doomsday/engine/portable/include/dd_main.h
Expand Up @@ -31,6 +31,7 @@

#include "dd_types.h"
#include "gameinfo.h"
#include "sys_direc.h"

// Verbose messages.
#define VERBOSE(code) { if(verbose >= 1) { code; } }
Expand All @@ -40,7 +41,7 @@ extern int verbose;
extern FILE* outFile; // Output file for console messages.

extern filename_t ddBasePath;
extern directory_t ddRuntimeDir, ddBinDir;
extern filename_t ddRuntimePath, ddBinPath;

extern char* gameStartupFiles; // A list of names of files to be autoloaded during startup, whitespace in between (in .cfg).

Expand Down

0 comments on commit 88fba1b

Please sign in to comment.