コード例 #1
0
ファイル: osd.c プロジェクト: DolceTriade/duke3d-megaton
//
// findsymbol() -- Finds a symbol, possibly partially named
// 
static symbol_t *findsymbol(const char *name, symbol_t *startingat)
{
	if (!startingat) startingat = symbols;
	if (!startingat) return NULL;

	for (; startingat; startingat=startingat->next)
		if (!Bstrncasecmp(name, startingat->name, Bstrlen(name))) return startingat;

	return NULL;
}
コード例 #2
0
ファイル: scriplib.c プロジェクト: jonof/jfmact
boolean SCRIPT_GetBoolean( int32 scripthandle, const char * sectionname, const char * entryname, boolean * boole )
{
	ScriptSectionType *s;
	ScriptEntryType *e;

	if (!SC(scripthandle)) return 1;
	if (!SCRIPT(scripthandle,script)) return 1;

	s = SCRIPT_SectionExists(scripthandle, sectionname);
	e = SCRIPT_EntryExists(s, entryname);
	
	if (!e) return 1;// *boole = 0;
	else {
		if (!Bstrncasecmp(e->value, "true", 4)) *boole = 1;
		else if (!Bstrncasecmp(e->value, "false", 5)) *boole = 0;
		else if (e->value[0] == '1' && (e->value[1] == ' ' || e->value[1] == '\t' || e->value[1] == 0)) *boole = 1;
		else if (e->value[0] == '0' && (e->value[1] == ' ' || e->value[1] == '\t' || e->value[1] == 0)) *boole = 0;
	}

	return 0;
}
コード例 #3
0
ファイル: wad2art.c プロジェクト: SilkyPantsDan/eduke32
void convpalette(void)
{
    int i, fil3;
    short danumshades;

    i = 0;
    while (Bstrncasecmp(wadata[i],"PLAYPAL",7) != 0) i++;
    Blseek(fil1,wadplc[i],BSEEK_SET);
    Bread(fil1,pal,768);
    for(i=0;i<768;i++) pal[i] >>= 2;

    i = 0;
    while (Bstrncasecmp(wadata[i],"COLORMAP",8) != 0) i++;
    Blseek(fil1,wadplc[i],BSEEK_SET);
    Bread(fil1,palookup,8192);

    if ((fil3 = Bopen("palette.dat",BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1)
        { Bprintf("Cannot save palette.dat\n"); exit(0); }
    Bwrite(fil3,pal,768);
    danumshades = 32;
    Bwrite(fil3,&danumshades,2);
    Bwrite(fil3,palookup,8192);
    Bclose(fil3);
}
コード例 #4
0
ファイル: wad2art.c プロジェクト: SilkyPantsDan/eduke32
void showart (char *part)
{
    char yoff;
    short xsiz, ysiz;
    int i, z, zx, x, p, pend, curplc;

    curplc = -1;
    if ((Bstrncasecmp(part,"L_START",7) == 0) || (Bstrncasecmp(part,"S_START",7) == 0) || (Bstrncasecmp(part,"P_START",7) == 0))
    {
        if (Bstrncasecmp(part,"L_START",7) == 0)
            z = 462;
        else
        {
            z = 0;
            while (Bstrncasecmp(wadata[z],part,7) != 0) z++;
            z++;
        }

        do
        {
            if (Bstrncasecmp(wadata[z],"P1_START",8) == 0) z++;
            if (Bstrncasecmp(wadata[z],"P1_END",6) == 0) z++;
            if (Bstrncasecmp(wadata[z],"P2_START",8) == 0) z++;
            if (Bstrncasecmp(wadata[z],"S_START",7) == 0) break;
            if (Bstrncasecmp(wadata[z],"S_END",5) == 0) break;
            if (Bstrncasecmp(wadata[z],"P_END",5) == 0) break;

            if (curplc != wadplc[z]) Blseek(fil1,wadplc[z],BSEEK_SET);
            read(fil1,&tempbuf[0],wadlen[z]);
            curplc = wadplc[z]+wadlen[z];

            xsiz = (int)tempbuf[0]+(((int)tempbuf[1])<<8);
            ysiz = (int)tempbuf[2]+(((int)tempbuf[3])<<8);
            if ((xsiz <= 0) || (ysiz <= 0) || (xsiz > 320) || (ysiz > 200)) goto skipit;
            i = 8;
            for(zx=0;zx<xsiz;zx++)
            {
                xoffses[zx] = ((int)tempbuf[i])+(((int)tempbuf[i+1])<<8)+(((int)tempbuf[i+2])<<16)+(((int)tempbuf[i+3])<<24);
                i += 4;
            }

            clearbuf(screen,ylookup[ysiz]>>2,0xffffffff);

            for(x=0;x<xsiz;x++)
            {
                i = xoffses[x];
                yoff = tempbuf[i++];
                while (yoff != 255)
                {
                    p = ylookup[yoff]+x;
                    pend = p+ylookup[tempbuf[i]];
                    i += 2;
                    for(;p<pend;p+=320)
                        screen[p] = tempbuf[i++];
                    i++;
                    yoff = tempbuf[i++];
                }
            }

            saveart(z,xsiz,ysiz);
skipit:
            z++;
        } while (z < numwads);
    }
    else
    {
コード例 #5
0
ファイル: compat.c プロジェクト: wosigh/duke3d
int Bcorrectfilename(char *filename, int removefn)
{
#ifdef _WIN32
	int r, trailslash=0;
#endif
	char path[256]="", fn[64]="", scratch[256], *ptr, *ptr2, ch;
	char cwd[256], *cwdp = cwd;
	char *tokarr[64];
	int ntok=0, i, j;

	int grpmode = 0;
	
	if (!Bstrncasecmp(filename,"GRP:",4)) {
		grpmode = 1;
		for (ptr=filename; *ptr; ptr++) if (*ptr == '\\') *ptr = '/';
	}
#ifdef _WIN32
	if (!grpmode) {
		// Windows uses backslashes so translate all unix-like forwardslashes
		for (ptr=filename; *ptr; ptr++) if (*ptr == '/') *ptr = '\\';
		if (*(ptr-1) == '\\') trailslash = 1;

		r = GetFullPathName(filename, 256, path, &ptr);
		if (r > 256) return -1;
		if (r == 0) return -1;
		if (!trailslash && removefn && ptr) *ptr=0;
		if (trailslash) {
			if (path[ strlen(path) - 1 ] != '\\')
				strcat(path, "\\");
		}

		for (ptr=path; *ptr; ptr++) if (*ptr == '\\') *ptr = '/';
	
		strcpy(filename,path);
	} else {
#endif
	
#ifndef _WIN32
		if (!grpmode) {
			Bgetcwd(cwd, 256);
			Bstrcat(cwd, "/");
		} else {
#endif
		cwd[0] = '/';
		cwd[1] = 0;
#ifndef _WIN32
		}
#endif

		ptr2 = filename;
		if (grpmode) {
			ptr2 += 3;
			if (ptr2[1] != '/')
				*ptr2 = '/';
			else ptr2++;
		}

		if (removefn) {
			ptr = Bstrrchr(ptr2, '/');
			if (ptr) ptr[1] = 0;
			else if (!grpmode) ptr2[0] = 0;
		}

		// now we have all the bits and pieces, clean it all up
		scratch[0] = 0;

		if (ptr2[0] != '/') {
			// relative path, which means prepend the current dir to the path
			Bstrcat(scratch, cwdp);
		}

		Bstrcat(scratch, ptr2);

		ptr2 = scratch;
		while ((ptr = Bstrtoken(ptr2==scratch?scratch:NULL,"/",&ptr2,1)) != NULL) {
			if (!Bstrcmp(ptr,".")) continue;
			else if (!Bstrcmp(ptr,"..")) {
				if (ntok>0) ntok--;
			} else {
				tokarr[ntok++] = ptr;
			}
		}

		ptr2 = filename;
		if (grpmode) {
			Bstrcpy(filename,"GRP:");
			ptr2 += 4;
		} else filename[0] = 0;
		*(ptr2++) = '/';
		for (i=0; i<ntok; i++) {
			ptr = tokarr[i];
			if (i>0) *(ptr2++) = '/';
			while (*ptr) *(ptr2++) = *(ptr++);
		}
		if (removefn) if (*(ptr2-1) != '/') *(ptr2++) = '/';
		*(ptr2) = 0;

#ifdef _WIN32
	}
#endif

	return 0;
}