- color -> colour

- add note on performance in TextureManager.cpp

debug_stl: more fine-grained #if STL_DINKUMWARE (gets this closer to
working on other STL implementations)
vfs.h: improved dox and moved vfs_path public functions here.
cursor: pass g_mouse_x as a parameter (SwEng)

This was SVN commit r2595.
This commit is contained in:
janwas
2005-08-10 01:12:03 +00:00
parent ff97a903b8
commit 622ceeda94
10 changed files with 69 additions and 47 deletions
+2 -2
View File
@@ -77,7 +77,7 @@ void CTextureEntry::LoadTexture()
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BuildBaseColor: calculate the root color of the texture, used for coloring minimap, and store
// BuildBaseColor: calculate the root colour of the texture, used for coloring minimap, and store
// in m_BaseColor member
void CTextureEntry::BuildBaseColor()
{
@@ -91,7 +91,7 @@ void CTextureEntry::BuildBaseColor()
Handle handle=GetHandle();
g_Renderer.BindTexture(0,tex_id(handle));
// get root color for coloring minimap by querying root level of the texture
// get root colour for coloring minimap by querying root level of the texture
// (this should decompress any compressed textures for us),
// then scaling it down to a 1x1 size
// - an alternative approach of just grabbing the top level of the mipmap tree fails
+3
View File
@@ -87,6 +87,9 @@ void CTextureManager::DeleteTexture(CTextureEntry* entry)
// FIXME This could be effectivized by surveying the xml files in the directory
// instead of trial-and-error checking for existence of the xml file through
// the VFS.
// jw: indeed this is inefficient and RecurseDirectory should be implemented
// via VFSUtil::EnumFiles, but it works fine and "only" takes 25ms for
// typical maps. therefore, we'll leave it for now.
void CTextureManager::LoadTextures(CTerrainProperties *props, CStr path, const char* fileext_filter)
{
Handle dir=vfs_dir_open(path.c_str());
+23 -9
View File
@@ -28,14 +28,14 @@
#define REPLACE(what, with)\
else if(!strncmp(src, (what), sizeof(what)-1))\
{\
src += sizeof(what)-1-1; /* see preincrement rationale*/\
strcpy(dst, (with)); /* safe - see above */\
dst += sizeof(with)-1;\
src += sizeof(what)-1-1; /* see preincrement rationale*/\
strcpy(dst, (with)); /* safe - see above */\
dst += sizeof(with)-1;\
}
#define STRIP(what)\
else if(!strncmp(src, (what), sizeof(what)-1))\
{\
src += sizeof(what)-1-1;/* see preincrement rationale*/\
src += sizeof(what)-1-1;/* see preincrement rationale*/\
}
#define STRIP_NESTED(what)\
else if(!strncmp(src, (what), sizeof(what)-1))\
@@ -230,14 +230,19 @@ public:
};
*/
#if !OS_UNIX
//
// standard containers
//
// it is rather difficult to abstract away implementation details of various
// STL versions. we currently only support Dinkumware (that shipped with VC7)
// chiefly due to set/map- (i.e. tree) and string-specific code.
#if STL_DINKUMWARE
class Any_deque : public std::deque<int>
{
#if STL_DINKUMWARE
// being declared as friend isn't enough;
// our iterator still doesn't get access to std::deque.
const u8* get_item(size_t i, size_t el_size) const
@@ -250,14 +255,14 @@ class Any_deque : public std::deque<int>
const u8* p = bucket + idx_in_bucket*el_size;
return p;
}
#endif
public:
bool valid(size_t el_size) const
{
#if STL_DINKUMWARE
if(!container_valid(_Map, _Mysize))
return false;
#if STL_DINKUMWARE != 0
const size_t el_per_bucket = MAX(16 / el_size, 1); // see _DEQUESIZ
// initial element is beyond end of first bucket
if(_Myoff >= el_per_bucket)
@@ -281,8 +286,13 @@ public:
public:
const u8* deref_and_advance(size_t el_size)
{
const u8* p;
#if STL_DINKUMWARE
Any_deque* d = (Any_deque*)_Mycont;
const u8* p = d->get_item(_Myoff, el_size);
p = d->get_item(_Myoff, el_size);
#else
p = (const u8*)&operator*();
#endif
++(*this);
return p;
}
@@ -295,8 +305,10 @@ class Any_list : public std::list<int>
public:
bool valid(size_t UNUSED(el_size)) const
{
#if STL_DINKUMWARE
if(!container_valid(_Myhead, _Mysize))
return false;
#endif
return true;
}
@@ -407,8 +419,10 @@ class Any_vector: public std::vector<int>
public:
bool valid(size_t UNUSED(el_size)) const
{
#if STL_DINKUMWARE
if(!container_valid(_Myfirst, _Mylast-_Myfirst))
return false;
#endif
// more elements reported than reserved
if(size() > capacity())
return false;
@@ -452,7 +466,7 @@ public:
{
if(!container_valid(ptr(el_size), _Mysize))
return false;
#if STL_DINKUMWARE != 0
#if STL_DINKUMWARE
// less than the small buffer reserved - impossible
if(_Myres < (16/el_size)-1)
return false;
+1 -1
View File
@@ -54,7 +54,7 @@ const size_t SECTOR_SIZE = 4096;
// in smaller chunks. this leads to much higher transfer rates.
// - memory: when used with VFS, aio makes better use of a file cache.
// data is generally compressed in an archive. a cache should store the
// decompressed and decoded (e.g. TGA color swapping) data; mmap would
// decompressed and decoded (e.g. TGA colour swapping) data; mmap would
// keep the original, compressed data in memory, which doesn't help.
// we bypass the OS file cache via aio, and store partial blocks here (*);
// higher level routines will cache the actual useful data.
+23 -11
View File
@@ -67,11 +67,11 @@ Since decreases in edit cycle time improve productivity, we want changes to
files to be picked up immediately. To that end, we support hotloading -
as soon as the OS reports changes, all Handle objects that ensued from that
file are reloaded.
Since the file notification backend (currently SGI FAM and a Win32 port)
can only reports events for a single directory (not its subtree), we need
to register a "watch" for each game data directory. The VFS takes care of
this since it must traverse and store data for each of them anyway.
The VFS's part in this is registering "watches" that report changes to
any mounted real directory. Since the file notification backend
(currently SGI FAM and a Win32 port) cannot watch an entire directory tree,
we need to do so for every single directory. Since the VFS traverses and
stores data for them anyway, we do so here.
Modding
@@ -181,7 +181,6 @@ One additional advantage of archives over loose files is that I/O throughput
is increased - since files are compressed, there is less to read from disk.
Decompression is free because it is done in parallel with IOs.
*/
#ifndef __VFS_H__
@@ -201,8 +200,12 @@ extern void vfs_shutdown(void);
// typically triggered via command line param. safe to call before vfs_init.
extern void vfs_enable_file_listing(bool want_enabled);
// write a representation of the VFS tree to stdout.
extern void vfs_display(void);
//
// mount
// paths
//
// the VFS doesn't require this length restriction - VFS internal storage
@@ -210,11 +213,24 @@ extern void vfs_enable_file_listing(bool want_enabled);
// large fixed-size user buffers should be. length includes trailing '\0'.
#define VFS_MAX_PATH 256
// convenience function
extern void vfs_path_copy(char* dst, const char* src);
// combine <path1> and <path2> into one path, and write to <dst>.
// if necessary, a directory separator is added between the paths.
// each may be empty, filenames, or full paths.
// total path length (including '\0') must not exceed VFS_MAX_PATH.
extern int vfs_path_append(char* dst, const char* path1, const char* path2);
// VFS paths are of the form: "(dir/)*file?"
// in English: '/' as path separator; trailing '/' required for dir names;
// no leading '/', since "" is the root dir.
//
// mount
//
enum VfsMountFlags
{
// the directory being mounted (but not its subdirs! see impl) will be
@@ -261,9 +277,6 @@ extern int vfs_unmount(const char* name);
// used when receiving paths from external code.
extern int vfs_make_vfs_path(const char* path, char* vfs_path);
// write a representation of the VFS tree to stdout.
extern void vfs_display(void);
//
// directory entry
@@ -331,7 +344,6 @@ extern int vfs_close(Handle& h);
//
// low-level file routines - no caching or alignment.
//
// begin transferring <size> bytes, starting at <ofs>. get result
// with vfs_wait_read; when no longer needed, free via vfs_discard_io.
+2 -2
View File
@@ -667,7 +667,7 @@ int vfs_make_vfs_path(const char* P_path, char* V_path)
const char* remove = m.P_name.c_str();
const char* replace = m.V_mount_point.c_str();
if(vfs_path_replace(V_path, P_path, remove, replace) == 0)
if(path_replace(V_path, P_path, remove, replace) == 0)
return 0;
}
@@ -732,7 +732,7 @@ int x_realpath(const Mount* m, const char* V_exact_path, char* P_real_path)
const char* remove = m->V_mount_point.c_str();
const char* replace = P_parent_path;
return vfs_path_replace(P_real_path, V_exact_path, remove, replace);
return path_replace(P_real_path, V_exact_path, remove, replace);
}
+3 -3
View File
@@ -26,7 +26,7 @@
// if path is invalid (see source for criteria), print a diagnostic message
// (indicating line number of the call that failed) and
// return a negative error code. used by CHECK_PATH.
int vfs_path_validate(const uint line, const char* path)
int path_validate(const uint line, const char* path)
{
size_t path_len = 0; // counted as we go; checked against max.
@@ -90,7 +90,7 @@ ok:
}
bool vfs_path_component_valid(const char* name)
bool path_component_valid(const char* name)
{
// disallow empty strings
if(*name == '\0')
@@ -157,7 +157,7 @@ int vfs_path_append(char* dst, const char* path1, const char* path2)
// strip <remove> from the start of <src>, prepend <replace>,
// and write to <dst>.
// used when converting VFS <--> real paths.
int vfs_path_replace(char* dst, const char* src, const char* remove, const char* replace)
int path_replace(char* dst, const char* src, const char* remove, const char* replace)
{
// remove doesn't match start of <src>
const size_t remove_len = strlen(remove);
+9 -16
View File
@@ -1,28 +1,21 @@
#ifndef VFS_UTIL_H__
#define VFS_UTIL_H__
#ifndef VFS_PATH_H__
#define VFS_PATH_H__
#include "lib.h"
// internal use only:
// if path is invalid (see source for criteria), print a diagnostic message
// (indicating line number of the call that failed) and
// return a negative error code. used by CHECK_PATH.
extern int vfs_path_validate(const uint line, const char* path);
#define CHECK_PATH(path) CHECK_ERR(vfs_path_validate(__LINE__, path))
extern int path_validate(const uint line, const char* path);
#define CHECK_PATH(path) CHECK_ERR(path_validate(__LINE__, path))
extern bool vfs_path_component_valid(const char* name);
// convenience function
extern void vfs_path_copy(char* dst, const char* src);
// combine <path1> and <path2> into one path, and write to <dst>.
// if necessary, a directory separator is added between the paths.
// each may be empty, filenames, or full paths.
// total path length (including '\0') must not exceed VFS_MAX_PATH.
extern int vfs_path_append(char* dst, const char* path1, const char* path2);
extern bool path_component_valid(const char* name);
// strip <remove> from the start of <src>, prepend <replace>,
// and write to <dst>.
// used when converting VFS <--> real paths.
extern int vfs_path_replace(char* dst, const char* src, const char* remove, const char* replace);
extern int path_replace(char* dst, const char* src, const char* remove, const char* replace);
#endif // #ifndef VFS_UTIL_H__
#endif // #ifndef VFS_PATH_H__
+1 -1
View File
@@ -449,7 +449,7 @@ TNode* TDir::find(const char* name, TNodeType desired_type)
int TDir::add(const char* name, TNodeType new_type, TNode** pnode)
{
if(!vfs_path_component_valid(name))
if(!path_component_valid(name))
return ERR_PATH_INVALID;
// this is legit - when looking up a directory, LF_CREATE_IF_MISSING
+2 -2
View File
@@ -768,7 +768,7 @@ static void Render()
oglCheck();
// Draw the cursor (or set the Windows cursor, on Windows)
cursor_draw(g_CursorName);
cursor_draw(g_CursorName, g_mouse_x, g_mouse_y);
// restore
glMatrixMode(GL_PROJECTION);
@@ -951,7 +951,7 @@ static void psShutdown()
delete g_Console;
// disable the special Windows cursor, or free textures for OGL cursors
cursor_draw(NULL);
cursor_draw(0, g_mouse_x, g_mouse_y);
// close down Xerces if it was loaded
CXeromyces::Terminate();