From dcc3d4c5d91871b8c23699c6417a569057e05f69 Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 6 Aug 2013 10:48:51 +0000 Subject: [PATCH] nacl has a chance of compiling again now. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4454 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_main.c | 146 ------------------------- engine/client/snd_dma.c | 31 +++--- engine/common/bothdefs.h | 1 + engine/common/fs.c | 177 +----------------------------- engine/common/fs.h | 6 +- engine/gl/gl_draw.c | 7 +- engine/gl/gl_vidcommon.c | 4 +- engine/nacl/fs_ppapi.c | 223 +++++++++++++++++++++++--------------- engine/nacl/gl_vidppapi.c | 31 +----- engine/nacl/sys_ppapi.c | 20 ---- 10 files changed, 173 insertions(+), 473 deletions(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 0cce16c89..f02392b2d 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -3805,152 +3805,6 @@ qboolean Host_RunFile(const char *fname, int nlen, vfsfile_t *file) Q_strncpyz(f->ext, ext, sizeof(f->ext)); Host_DoRunFile(f); return true; -#if 0 - - char buffer[MAX_OSPATH]; - char *ext; - if (nlen >= MAX_OSPATH) - { - if (file) - VFS_CLOSE(file); - Con_Printf("Filename too long.\n"); - return true; - } - - memcpy(buffer, fname, nlen); - buffer[nlen] = 0; - fname = buffer; - ext = COM_FileExtension(fname); - if (!strncmp(fname, "qw:", 3)) - { - fname += 3; - if (!strncmp(fname, "//", 2)) - fname += 2; - ext = strchr(fname, '/'); //this also protects us against irc urls, etc. unsure if that's important right now. - if (ext) - *ext = 0; - Con_Printf("QW stream: \"%s\"\n", fname); - Cbuf_AddText(va("connect \"%s\"\n", fname), RESTRICT_LOCAL); - } - else if (!strcmp(ext, "qwd") || !strcmp(ext, "dem") || !strcmp(ext, "mvd")) - Cbuf_AddText(va("playdemo \"#%s\"\n", fname), RESTRICT_LOCAL); - else if (!strcmp(ext, "bsp") || !strcmp(ext, "pak") || !strcmp(ext, "pk3") || !strcmp(ext, "pk4") || !strcmp(ext, "fmf")) - { - extern qboolean waitingformanifest; - //these must all have a valid source file. just recurse if its not set. - if (!file) - { - if (!strncmp(fname, "http://", 7)) - { - if (HTTP_CL_Get(fname, NULL, Host_RunFileNotify)) - { - if (!strcmp(ext, "fmf")) - waitingformanifest = true; - return true; - } - return false; - } - if (!strncmp(fname, "file://", 7)) - fname += 7; - file = VFSOS_Open(fname, "rb"); //input file is a system path, or something. - if (file) - { - Host_RunFile(fname, strlen(fname), file); - return true; - } - return false; - } - - if (!strcmp(ext, "fmf")) - { - CL_Manifest_Parse(file, fname); - waitingformanifest = false; - } - else if (!strcmp(ext, "pak") || !strcmp(ext, "pk3") || !strcmp(ext, "pk4")) - { - //open the archive, look for a *readme.txt - //look for a -game inside that. - //if found, install the pak there. - //if a +map is found, load that map after install. - Con_Printf("Unable to install paks/pk3s at this time\n"); - } - else if (!strcmp(ext, "bsp")) - { - char qname[MAX_QPATH]; - vfsfile_t *qf; - qboolean overwrite = false; - COM_StripExtension(COM_SkipPath(fname), qname, sizeof(qname)); - qf = FS_OpenVFS(va("maps/%s.bsp", qname), "rb", FS_GAME); - if (qf) - { - if (VFS_GETLEN(file) != VFS_GETLEN(qf)) - overwrite = true; - VFS_SEEK(file, 0); - VFS_CLOSE(qf); - } - #ifdef _WIN32 - if (overwrite) - { - switch(MessageBox(mainwindow, va("Overwrite existing map: %s?", qname), "Install And Play", MB_YESNOCANCEL)) - { - case IDYES: - //overwrite it and load it up - overwrite = true; - break; - case IDNO: - //load up the old version - overwrite = false; - break; - default: - case IDCANCEL: - //quit or something - return false; - } - } - else if (!qf) - { - switch(MessageBox(mainwindow, va("Install new map: %s?", qname), "Install And Play", MB_OKCANCEL)) - { - case IDOK: - //overwrite it and load it up - overwrite = true; - break; - default: - case IDCANCEL: - //quit or something - return false; - } - } - - if (overwrite) - { - char buffer[8192]; - int len; - qf = FS_OpenVFS(va("maps/%s.bsp", qname), "wb", FS_GAMEONLY); - if (qf) - { - while(1) - { - len = VFS_READ(file, buffer, sizeof(buffer)); - if (len <= 0) - break; - VFS_WRITE(qf, buffer, len); - } - VFS_CLOSE(qf); - } - } - - Cbuf_AddText(va("map \"%s\"\n", qname), RESTRICT_LOCAL); - #endif - } - } - else - Cbuf_AddText(va("qtvplay \"#%s\"\n", fname), RESTRICT_LOCAL); - - if (file) - VFS_CLOSE(file); - return true; -#endif } /* diff --git a/engine/client/snd_dma.c b/engine/client/snd_dma.c index be390f0f2..86a4d33e5 100644 --- a/engine/client/snd_dma.c +++ b/engine/client/snd_dma.c @@ -1157,6 +1157,7 @@ void S_Voip_Transmit(unsigned char clc, sizebuf_t *buf) SZ_Write(buf, outbuf, outpos); } +#ifdef SUPPORT_ICE switch(s_voip.enccodec) { case VOIP_SPEEX_NARROW: @@ -1168,6 +1169,7 @@ void S_Voip_Transmit(unsigned char clc, sizebuf_t *buf) NET_RTP_Transmit(initseq, inittimestamp, "opus", outbuf, outpos); break; } +#endif if (cl_voip_test.ival) S_Voip_Decode(cl.playerview[0].playernum, s_voip.enccodec, s_voip.generation & 0x0f, initseq, outpos, outbuf); @@ -3093,20 +3095,23 @@ void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels, if (i == si->total_chans) //this one wasn't playing. { channel_t *c = SND_PickChannel(si, -1, 0); - c->flags = CF_ABSVOLUME; - c->entnum = -1; - c->entchannel = 0; - c->dist_mult = 0; - c->looping = false; - c->master_vol = 255 * volume; - c->pos = 0; - c->rate = 1<sfx = &s->sfx; - c->start = 0; - SND_Spatialize(si, c); + if (c) + { + c->flags = CF_ABSVOLUME; + c->entnum = -1; + c->entchannel = 0; + c->dist_mult = 0; + c->looping = false; + c->master_vol = 255 * volume; + c->pos = 0; + c->rate = 1<sfx = &s->sfx; + c->start = 0; + SND_Spatialize(si, c); - if (si->ChannelUpdate) - si->ChannelUpdate(si, &si->channel[i], true); + if (si->ChannelUpdate) + si->ChannelUpdate(si, c, true); + } } } S_UnlockMixer(); diff --git a/engine/common/bothdefs.h b/engine/common/bothdefs.h index 5d89f9398..0fe465f48 100644 --- a/engine/common/bothdefs.h +++ b/engine/common/bothdefs.h @@ -303,6 +303,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #undef TEXTEDITOR #endif #if defined(NACL) + #undef SUPPORT_ICE #undef CL_MASTER //no sockets support #undef SV_MASTER //noone uses this anyway #undef WEBSERVER //no sockets support (certainly no servers) diff --git a/engine/common/fs.c b/engine/common/fs.c index 109987fce..880c9c951 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -2261,179 +2261,6 @@ void FS_PureMode(int puremode, char *packagenames, char *packagecrcs, int purese } } -#if 0 -//if a server is using private pak files then load the same version of those, but deprioritise them -//crcs are not used, but matched only if the server has a different version from a previous file -void FS_ImpurePacks(const char *names, const char *crcs) -{ - int crc; - searchpath_t *sp; - char *pname; - qboolean success; - - while(names) - { - crcs = COM_Parse(crcs); - crc = atoi(com_token); - names = COM_Parse(names); - - if (!crc) - continue; - - pname = com_token; - if (*pname == '*') - pname++; - - for (sp = com_searchpaths; sp; sp = sp->next) - { - if (!stricmp(sp->purepath, pname)) - { - break; - } - } - if (!sp) - { - char local[MAX_OSPATH]; - vfsfile_t *vfs; - - if (FS_GenCachedPakName(pname, va("%i", crc), local, sizeof(local))) - vfs = FS_OpenVFS(local, "rb", FS_ROOT); - else - vfs = NULL; - success = false; - if (vfs) - success = FS_LoadPackageFromFile(vfs, pname, local, NULL, SPF_COPYPROTECTED|SPF_TEMPORARY); - - if (!success) - Con_DPrintf("Unable to load matching package file %s\n", pname); - } - } - - FS_ForceToPure(NULL, NULL, 0); -} - -//space-seperate pk3 names followed by space-seperated crcs -//note that we'll need to reorder and filter out files that don't match the crc. -void FS_ForceToPure(const char *names, const char *crcs, int seed) -{ - //pure files are more important than non-pure. - - searchpath_t *sp; - searchpath_t *lastpure = NULL; - int crc; - qboolean waspure = com_purepaths != NULL; - char *pname; - searchpath_t *oldlist; - - if (!crcs || !*crcs) - { //pure isn't in use. - if (com_purepaths) - { - Con_Printf("Pure FS deactivated\n"); - com_purepaths = NULL; - FS_FlushFSHashReally(); - } - return; - } - - com_purepaths = NULL; - for (sp = com_searchpaths; sp; sp = sp->next) - { - if (sp->handle->GeneratePureCRC) - { - sp->nextpure = (void*)0x1; - sp->crc_check = sp->handle->GeneratePureCRC(sp->handle, seed, 0); - sp->crc_reply = sp->handle->GeneratePureCRC(sp->handle, seed, 1); - } - else - { - sp->nextpure = NULL; - sp->crc_check = 0; - sp->crc_reply = 0; - } - } - - while(crcs) - { - crcs = COM_Parse(crcs); - crc = atoi(com_token); - names = COM_Parse(names); - - if (!crc) - continue; - - pname = com_token; - if (*pname == '*') - pname++; - - for (sp = com_searchpaths; sp; sp = sp->next) - { - if (sp->nextpure == (void*)0x1) //don't add twice. - if (sp->crc_check == crc) - { - if (lastpure) - lastpure->nextpure = sp; - else - com_purepaths = sp; - sp->nextpure = NULL; - lastpure = sp; - break; - } - } - if (!sp) - { - char local[MAX_OSPATH]; - vfsfile_t *vfs; - char *ext = COM_FileExtension(pname); - void *handle; - int i; - - if (FS_GenCachedPakName(pname, va("%i", crc), local, sizeof(local))) - vfs = FS_OpenVFS(local, "rb", FS_ROOT); - else - vfs = NULL; - if (vfs) - { - for (i = 0; i < sizeof(searchpathformats)/sizeof(searchpathformats[0]); i++) - { - if (!searchpathformats[i].extension || !searchpathformats[i].OpenNew) - continue; - if (!strcmp(ext, searchpathformats[i].extension)) - { - handle = searchpathformats[i].OpenNew (vfs, local); - if (!handle) - break; - sp = FS_AddPathHandle(&oldlist, pname, local, handle, SPF_COPYPROTECTED|SPF_TEMPORARY, (unsigned int)-1); - - sp->crc_check = sp->handle->GeneratePureCRC(sp->handle, seed, 0); - sp->crc_reply = sp->handle->GeneratePureCRC(sp->handle, seed, 1); - - if (sp->crc_check == crc) - { - if (lastpure) - lastpure->nextpure = sp; - else - com_purepaths = sp; - sp->nextpure = NULL; - lastpure = sp; - } - break; - } - } - } - - if (!sp) - Con_DPrintf("Pure crc %i wasn't found\n", crc); - } - } - - FS_FlushFSHashReally(); - - if (com_purepaths && !waspure) - Con_Printf("Pure FS activated\n"); -} -#endif - char *FSQ3_GenerateClientPacksList(char *buffer, int maxlen, int basechecksum) { //this is for q3 compatibility. @@ -3554,7 +3381,9 @@ void FS_ChangeGame_f(void) return; } } - Con_Printf("Game unknown\n"); + + if (!Host_RunFile(arg, strlen(arg), NULL)) + Con_Printf("Game unknown\n"); } } void FS_ShowManifest_f(void) diff --git a/engine/common/fs.h b/engine/common/fs.h index e6af9557a..896117a88 100644 --- a/engine/common/fs.h +++ b/engine/common/fs.h @@ -1,6 +1,6 @@ #include "hash.h" -#define FSVER 1 +#define FSVER 2 typedef struct { @@ -30,6 +30,10 @@ struct searchpathfuncs_s vfsfile_t *(QDECL *OpenVFS)(searchpathfuncs_t *handle, flocation_t *loc, const char *mode); qboolean (QDECL *PollChanges)(searchpathfuncs_t *handle); //returns true if there were changes + + qboolean (QDECL *RenameFile)(searchpathfuncs_t *handle, const char *oldname, const char *newname); //returns true on success, false if source doesn't exist, or if dest does. + qboolean (QDECL *RemoveFile)(searchpathfuncs_t *handle, const char *filename); //returns true on success, false if it wasn't found or is readonly. + qboolean (QDECL *MkDir)(searchpathfuncs_t *handle, const char *filename); //is this really needed? }; //searchpathfuncs_t *(QDECL *OpenNew)(vfsfile_t *file, const char *desc); //returns a handle to a new pak/path diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index ebc5d1e88..727b7f632 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -1272,7 +1272,12 @@ void GL_Upload32_Int (char *name, unsigned *data, int width, int height, unsigne else GL_ResampleTexture (data, width, height, scaled, scaled_width, scaled_height); - TRACE(("dbg: GL_Upload32: recaled\n")); + if (scaled_width*scaled_height*4 > sizeofuploadmemorybufferintermediate) + { + sizeofuploadmemorybufferintermediate = scaled_width*scaled_height*4; + uploadmemorybufferintermediate = BZ_Realloc(uploadmemorybufferintermediate, sizeofuploadmemorybufferintermediate); + } + TRACE(("dbg: GL_Upload32: rescaled\n")); if (type == GL_UNSIGNED_SHORT_5_6_5) GL_8888to565(targface, (unsigned char *)scaled, (unsigned short*)uploadmemorybufferintermediate, 0, scaled_width, scaled_height); else if (type == GL_UNSIGNED_SHORT_4_4_4_4) diff --git a/engine/gl/gl_vidcommon.c b/engine/gl/gl_vidcommon.c index d7f9416b6..f97c7a717 100644 --- a/engine/gl/gl_vidcommon.c +++ b/engine/gl/gl_vidcommon.c @@ -210,7 +210,9 @@ FTEPFNGLACTIVESTENCILFACEEXTPROC qglActiveStencilFaceEXT; #define GLchar char -#if defined(_DEBUG) && !defined(DEBUG) +#ifdef NACL +#undef DEBUG +#elif defined(_DEBUG) && !defined(DEBUG) #define DEBUG #endif #if defined(DEBUG) diff --git a/engine/nacl/fs_ppapi.c b/engine/nacl/fs_ppapi.c index 1aec27ee3..4b61cf6d5 100644 --- a/engine/nacl/fs_ppapi.c +++ b/engine/nacl/fs_ppapi.c @@ -36,6 +36,7 @@ extern PP_Instance pp_instance; #define FSPPAPI_OpenTemp FS_OpenTemp #define VFSPPAPI_Open VFSOS_Open +#define FSPPAPI_OpenPath VFSOS_OpenPath typedef struct mfchunk_s { @@ -70,6 +71,13 @@ typedef struct mfchunk_t *cchunk; } vfsmfile_t; +typedef struct +{ + searchpathfuncs_t pub; + int depth; + char rootpath[1]; +} pppath_t; + qboolean FSPPAPI_Init(int *fileid) { return true; /*engine has all the content it needs*/ @@ -209,24 +217,35 @@ static unsigned long VFSMEM_GetSize (struct vfsfile_s *file) vfsmfile_t *f = (vfsmfile_t*)file; return f->file->length; } +static void FSPPAPI_DoUnlink(mfile_t *file) +{ + mfchunk_t *cnk; + //must have no lingering references. + + //free any file chunks. + while (file->chunkhead) + { + cnk = file->chunkhead->next; + free(file->chunkhead); + file->chunkhead = cnk; + } + //unlink the file so nothing else is harmed + if (file->prev) + file->prev->next = file->next; + else if (file == mfiles) + mfiles = file->next; + if (file->next) + file->next->prev = file->prev; + //and finally free the last bit of memory. + free(file); +} static void VFSMEM_Close(vfsfile_t *file) { vfsmfile_t *f = (vfsmfile_t*)file; f->file->refs -= 1; if (!f->file->refs) - { if (f->file->unlinked) - { - mfchunk_t *cnk; - while (f->file->chunkhead) - { - cnk = f->file->chunkhead->next; - free(f->file->chunkhead); - f->file->chunkhead = cnk; - } - free(f->file); - } - } + FSPPAPI_DoUnlink(f->file); free(f); } static void VFSMEM_Flush(struct vfsfile_s *file) @@ -243,7 +262,7 @@ vfsfile_t *FSPPAPI_OpenTemp(void) f = malloc(sizeof(*f)); if (!f) return NULL; - + strcpy(f->name, "some temp file"); f->refs = 0; f->unlinked = true; @@ -272,12 +291,46 @@ vfsfile_t *FSPPAPI_OpenTemp(void) return &r->funcs; } +qboolean Sys_remove (char *path) +{ + mfile_t *f; + for (f = mfiles; f; f = f->next) + { + if (!strcmp(f->name, path)) + { + if (!f->refs) + FSPPAPI_DoUnlink(f); + else + f->unlinked = true; //can't delete it yet, but we can orphan it so we can kill it later. + return true; + } + } + return false; +} +qboolean Sys_Rename (char *oldfname, char *newfname) +{ + mfile_t *f; + for (f = mfiles; f; f = f->next) + { + if (!strcmp(f->name, oldfname)) + { + Q_strncpyz(f->name, newfname, sizeof(f->name)); + return true; + } + } + return false; +} +//no concept of directories. +void Sys_mkdir (char *path) +{ +} + vfsfile_t *VFSPPAPI_Open(const char *osname, const char *mode) { mfile_t *f; vfsmfile_t *r; - if (strlen(osname) >= sizeof(f->name)) + if (strlen(osname) >= sizeof(f->name)) //yay strcpy! return NULL; for (f = mfiles; f; f = f->next) @@ -325,27 +378,24 @@ vfsfile_t *VFSPPAPI_Open(const char *osname, const char *mode) return &r->funcs; } -static vfsfile_t *FSPPAPI_OpenVFS(void *handle, flocation_t *loc, const char *mode) +static vfsfile_t *FSPPAPI_OpenVFS(searchpathfuncs_t *handle, flocation_t *loc, const char *mode) { + pppath_t *sp = (void*)handle; char diskname[MAX_OSPATH]; //path is already cleaned, as anything that gets a valid loc needs cleaning up first. - snprintf(diskname, sizeof(diskname), "%s/%s", (char*)handle, loc->rawname); + snprintf(diskname, sizeof(diskname), "%s/%s", sp->rootpath, loc->rawname); return VFSPPAPI_Open(diskname, mode); } -static void FSPPAPI_GetDisplayPath(void *handle, char *outpath, unsigned int pathsize) -{ - Q_strncpyz(outpath, (char*)handle, pathsize); -} -static void FSPPAPI_ClosePath(void *handle) +static void FSPPAPI_ClosePath(searchpathfuncs_t *handle) { Z_Free(handle); } -int Sys_EnumerateFiles (const char *rootpath, const char *match, int (*func)(const char *, int, void *, void *), void *parm, void *spath) +int Sys_EnumerateFiles (const char *rootpath, const char *match, int (*func)(const char *, int, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath) { int rootlen = strlen(rootpath); char *sub; @@ -368,57 +418,36 @@ int Sys_EnumerateFiles (const char *rootpath, const char *match, int (*func)(con } return true; } -static int FSPPAPI_EnumerateFiles (void *handle, const char *match, int (*func)(const char *, int, void *, void *), void *parm, void *spath) +static int FSPPAPI_EnumerateFiles (searchpathfuncs_t *handle, const char *match, int (*func)(const char *, int, void *, searchpathfuncs_t *), void *parm) { - return Sys_EnumerateFiles((char*)handle, match, func, parm, spath); + pppath_t *sp = (void*)handle; + return Sys_EnumerateFiles(sp->rootpath, match, func, parm, handle); } -static int FSPPAPI_RebuildFSHash(const char *filename, int filesize, void *data, void *handle) +static int FSPPAPI_RebuildFSHash(const char *filename, int filesize, void *data, searchpathfuncs_t *handle) { + pppath_t *sp = (void*)handle; void (QDECL *AddFileHash)(int depth, const char *fname, fsbucket_t *filehandle, void *pathhandle) = data; if (filename[strlen(filename)-1] == '/') { //this is actually a directory char childpath[256]; Q_snprintfz(childpath, sizeof(childpath), "%s*", filename); - Sys_EnumerateFiles((char*)data, childpath, FSPPAPI_RebuildFSHash, data, handle); + Sys_EnumerateFiles(sp->rootpath, childpath, FSPPAPI_RebuildFSHash, data, handle); return true; } AddFileHash(0, filename, NULL, handle); return true; } -static void FSPPAPI_BuildHash(void *handle, int depth, void (QDECL *AddFileHash)(int depth, const char *fname, fsbucket_t *filehandle, void *pathhandle)) +static void FSPPAPI_BuildHash(searchpathfuncs_t *handle, int depth, void (QDECL *AddFileHash)(int depth, const char *fname, fsbucket_t *filehandle, void *pathhandle)) { - Sys_EnumerateFiles(handle, "*", FSPPAPI_RebuildFSHash, AddFileHash, handle); + pppath_t *sp = (void*)handle; + Sys_EnumerateFiles(sp->rootpath, "*", FSPPAPI_RebuildFSHash, AddFileHash, handle); } -/* -void debugfs(void) -{ - static qboolean firstrun = true; - int len; - FILE *f; - vfsfile_t *v; - char *buf; - if (!firstrun) - return; - firstrun = false; - f = fopen("C:/Games/Quake/fte_trunk/pub/id1/pak0.pak", "rb"); - fseek(f, 0, SEEK_END); - len = ftell(f); - fseek(f, 0, SEEK_SET); - buf = malloc(len); - fread(buf, 1, len, f); - fclose(f); - v = VFSPPAPI_Open("C:\\Games\\Quake/id1/pak0.pak", "wb"); - VFS_WRITE(v, buf, len); - free(buf); - VFS_CLOSE(v); -} -*/ - -static qboolean FSPPAPI_FLocate(void *handle, flocation_t *loc, const char *filename, void *hashedresult) +static qboolean FSPPAPI_FLocate(searchpathfuncs_t *handle, flocation_t *loc, const char *filename, void *hashedresult) { + pppath_t *sp = (void*)handle; int len; char netpath[MAX_OSPATH]; @@ -434,7 +463,7 @@ static qboolean FSPPAPI_FLocate(void *handle, flocation_t *loc, const char *file */ // check a file in the directory tree - snprintf (netpath, sizeof(netpath)-1, "%s/%s",(char*)handle, filename); + snprintf (netpath, sizeof(netpath)-1, "%s/%s",sp->rootpath, filename); { vfsfile_t *f = VFSPPAPI_Open(netpath, "rb"); @@ -454,7 +483,7 @@ static qboolean FSPPAPI_FLocate(void *handle, flocation_t *loc, const char *file return true; } -static void FSPPAPI_ReadFile(void *handle, flocation_t *loc, char *buffer) +static void FSPPAPI_ReadFile(searchpathfuncs_t *handle, flocation_t *loc, char *buffer) { vfsfile_t *f; size_t result; @@ -471,33 +500,34 @@ static void FSPPAPI_ReadFile(void *handle, flocation_t *loc, char *buffer) VFS_CLOSE(f); } -static void *FSPPAPI_OpenPath(vfsfile_t *mustbenull, const char *desc) +searchpathfuncs_t *QDECL FSPPAPI_OpenPath(vfsfile_t *mustbenull, const char *desc) { - char *np; + pppath_t *np; int dlen = strlen(desc); if (mustbenull) return NULL; - np = Z_Malloc(dlen+1); + np = Z_Malloc(sizeof(*np) + dlen); if (np) { - memcpy(np, desc, dlen+1); + np->depth = 0; + memcpy(np->rootpath, desc, dlen+1); } - return np; + + np->pub.fsver = FSVER; + np->pub.ClosePath = FSPPAPI_ClosePath; + np->pub.BuildHash = FSPPAPI_BuildHash; + np->pub.FindFile = FSPPAPI_FLocate; + np->pub.ReadFile = FSPPAPI_ReadFile; + np->pub.EnumerateFiles = FSPPAPI_EnumerateFiles; + np->pub.OpenVFS = FSPPAPI_OpenVFS; + //np->pub.PollChanges = FSPPAPI_PollChanges; + return &np->pub; } -searchpathfuncs_t osfilefuncs = { - FSPPAPI_GetDisplayPath, - FSPPAPI_ClosePath, - FSPPAPI_BuildHash, - FSPPAPI_FLocate, - FSPPAPI_ReadFile, - FSPPAPI_EnumerateFiles, - FSPPAPI_OpenPath, - NULL, - FSPPAPI_OpenVFS -}; - #else + +this code is old and won't work. + #define FSPPAPI_OpenTemp FS_OpenTemp #define VFSPPAPI_Open VFSOS_Open @@ -672,11 +702,11 @@ static vfsfile_t *FSPPAPI_OpenVFS(void *handle, flocation_t *loc, const char *mo return VFSPPAPI_Open(diskname, mode); } -static void FSPPAPI_PrintPath(void *handle) +static void FSPPAPI_PrintPath(searchpathfuncs_t *handle) { Con_Printf("%s\n", (char*)handle); } -static void FSPPAPI_ClosePath(void *handle) +static void FSPPAPI_ClosePath(searchpathfuncs_t *handle) { Z_Free(handle); } @@ -705,11 +735,11 @@ static int FSPPAPI_RebuildFSHash(const char *filename, int filesize, void *data) fs_hash_dups++; return true; } -static void FSPPAPI_BuildHash(void *handle) +static void FSPPAPI_BuildHash(searchpathfuncs_t *handle) { Sys_EnumerateFiles(handle, "*", FSPPAPI_RebuildFSHash, handle); } -static qboolean FSPPAPI_FLocate(void *handle, flocation_t *loc, const char *filename, void *hashedresult) +static qboolean FSPPAPI_FLocate(searchpathfuncs_t *handle, flocation_t *loc, const char *filename, void *hashedresult) { int len; char netpath[MAX_OSPATH]; @@ -749,7 +779,7 @@ static qboolean FSPPAPI_FLocate(void *handle, flocation_t *loc, const char *file return true; } -static void FSPPAPI_ReadFile(void *handle, flocation_t *loc, char *buffer) +static void FSPPAPI_ReadFile(searchpathfuncs_t *handle, flocation_t *loc, char *buffer) { vfsfile_t *f; size_t result; @@ -765,20 +795,33 @@ static void FSPPAPI_ReadFile(void *handle, flocation_t *loc, char *buffer) VFS_CLOSE(f); } -static int FSPPAPI_EnumerateFiles (void *handle, const char *match, int (*func)(const char *, int, void *), void *parm) +static int FSPPAPI_EnumerateFiles (searchpathfuncs_t *handle, const char *match, int (*func)(const char *, int, void *), void *parm) { return Sys_EnumerateFiles(handle, match, func, parm); } -searchpathfuncs_t osfilefuncs = { - FSPPAPI_PrintPath, - FSPPAPI_ClosePath, - FSPPAPI_BuildHash, - FSPPAPI_FLocate, - FSPPAPI_ReadFile, - FSPPAPI_EnumerateFiles, - NULL, - NULL, - FSPPAPI_OpenVFS -}; +searchpathfuncs_t *QDECL FSPPAPI_OpenPath(vfsfile_t *mustbenull, const char *desc) +{ + stdiopath_t *np; + int dlen = strlen(desc); + if (mustbenull) + return NULL; + np = Z_Malloc(sizeof(*np) + dlen); + if (np) + { + np->depth = 0; + memcpy(np->rootpath, desc, dlen+1); + } + + np->pub.fsver = FSVER; + np->pub.ClosePath = FSPPAPI_ClosePath; + np->pub.BuildHash = FSPPAPI_BuildHash; + np->pub.FindFile = FSPPAPI_FLocate; + np->pub.ReadFile = FSPPAPI_ReadFile; + np->pub.EnumerateFiles = FSPPAPI_EnumerateFiles; + np->pub.OpenVFS = FSPPAPI_OpenVFS; + //np->pub.PollChanges = FSPPAPI_PollChanges; + return &np->pub; +} + #endif \ No newline at end of file diff --git a/engine/nacl/gl_vidppapi.c b/engine/nacl/gl_vidppapi.c index c383aa167..ad265c81e 100644 --- a/engine/nacl/gl_vidppapi.c +++ b/engine/nacl/gl_vidppapi.c @@ -71,30 +71,9 @@ void GL_DoSwap(void) } } -void GLVID_SetPalette (unsigned char *palette) -{ - qbyte *pal; - unsigned int r,g,b; - int i; - unsigned *table1; - extern qbyte gammatable[256]; - - pal = palette; - table1 = d_8to24rgbtable; - for (i=0 ; i<256 ; i++) - { - r = gammatable[pal[0]]; - g = gammatable[pal[1]]; - b = gammatable[pal[2]]; - pal += 3; - - *table1++ = LittleLong((255<<24) + (r<<0) + (g<<8) + (b<<16)); - } - d_8to24rgbtable[255] &= LittleLong(0xffffff); // 255 is transparent -} - -void GLVID_ShiftPalette (unsigned char *palette) -{ +qboolean GLVID_ApplyGammaRamps (unsigned short *ramps) +{ + return false; } void *PPAPI_GetGLSymbol(char *symname) @@ -306,9 +285,7 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette) // vid.pixelwidth = info->width; // vid.pixelheight = info->height; - GLVID_SetPalette (palette); - GL_Init(PPAPI_GetGLSymbol); - vid.recalc_refdef = 1; + GL_Init(PPAPI_GetGLSymbol); return true; } diff --git a/engine/nacl/sys_ppapi.c b/engine/nacl/sys_ppapi.c index 7e51ae182..91f1fd19f 100644 --- a/engine/nacl/sys_ppapi.c +++ b/engine/nacl/sys_ppapi.c @@ -247,18 +247,6 @@ void Sys_RecentServer(char *command, char *target, char *title, char *desc) { } -void Sys_mkdir (char *path) -{ -} -qboolean Sys_remove (char *path) -{ - return false; -} -qboolean Sys_Rename (char *oldfname, char *newfname) -{ - return false; -} - #include static int secbase; double Sys_DoubleTime(void) @@ -329,14 +317,6 @@ void startquake(char *manif) args[parms.argc++] = manif; } - parms.memsize = 16*1024*1024; - parms.membase = malloc(parms.memsize); - if (!parms.membase) - { - Sys_Printf("Unable to alloc heap\n"); - return; - } - Sys_Printf("Starting up\n"); COM_InitArgv(parms.argc, parms.argv);