Exemplo n.º 1
0
void texcache_syncmemcache(void)
{
    int32_t len = Bfilelength(texcache.filehandle);

    if (!texcache.memcache.ptr || texcache.filehandle == -1 || len <= (int32_t)texcache.memcache.size)
        return;

    texcache.memcache.ptr = (uint8_t *)Brealloc(texcache.memcache.ptr, len);

    if (!texcache.memcache.ptr)
    {
        texcache_clearmemcache();
        initprintf("Failed syncing memcache to texcache, disabling memcache.\n");
        texcache.memcache.noalloc = 1;
    }
    else
    {
        initprintf("Syncing memcache to texcache\n");
        Blseek(texcache.filehandle, texcache.memcache.size, BSEEK_SET);
        if (Bread(texcache.filehandle, texcache.memcache.ptr + texcache.memcache.size, len - texcache.memcache.size) != (bssize_t)(len-texcache.memcache.size))
        {
            initprintf("polymost_cachesync: Failed reading texcache into memcache!\n");
            texcache_clearmemcache();
            texcache.memcache.noalloc = 1;
        }
        else
        {
            texcache.memcache.size = len;
        }
    }
}
Exemplo n.º 2
0
void texcache_setupmemcache(void)
{
    if (!glusememcache || texcache.memcache.noalloc || !texcache_enabled())
        return;

    texcache.memcache.size = Bfilelength(texcache.filehandle);

    if (texcache.memcache.size <= 0)
        return;

    texcache.memcache.ptr = (uint8_t *)Brealloc(texcache.memcache.ptr, texcache.memcache.size);

    if (!texcache.memcache.ptr)
    {
        initprintf("Failed allocating %d bytes for memcache, disabling memcache.\n", (int)texcache.memcache.size);
        texcache_clearmemcache();
        texcache.memcache.noalloc = 1;
        return;
    }

    if (Bread(texcache.filehandle, texcache.memcache.ptr, texcache.memcache.size) != (bssize_t)texcache.memcache.size)
    {
        initprintf("Failed reading texcache into memcache!\n");
        texcache_clearmemcache();
        texcache.memcache.noalloc = 1;
    }
}
Exemplo n.º 3
0
char testcd( char *fn, long testsiz )
{
	DWORD driveletters;
	int i, fil, dalen;
	char name[32]="x:\\SUPPORT\\",driv[4]="x:\\";

	strcat(name,fn);

	driveletters = GetLogicalDrives();
	for (i=2; i<26; i++) {
		if (!(driveletters & (1ul<<i))) continue;
		driv[0] = 'A'+i;
		if (GetDriveType(driv) != DRIVE_CDROM) continue;

		name[0] = 'A'+i;
		fil = Bopen(name,O_RDONLY,S_IREAD);
		if (fil<0) continue;
		dalen = Bfilelength(fil);
		Bclose(fil);

		if (dalen == testsiz) {
			initprintf("Copy Protection: Found CDROM in drive %c:\n", driv[0]);
			return 0;
		}
	}

	wm_msgbox("Duke Nukem 3D","Copy Protection: Failed to find CDROM");
	return 1;
}
Exemplo n.º 4
0
int32_t SafeFileLength(int32_t handle)
{
    if (handle < 0) return -1;
    return Bfilelength(handle);
}