📄 build.c
字号:
if (keystatus[0x1c] == 0) { tilenum = otilenum; } else { if (tilenum < localartlookupnum) { tilenum = localartlookup[tilenum]; if ((tilesizx[tilenum] == 0) || (tilesizy[tilenum] == 0)) tilenum = otilenum; } else tilenum = otilenum; } keystatus[0x1] = 0; keystatus[0x1c] = 0; return(tilenum);}char changechar(char dachar, long dadir, char smooshyalign, char boundcheck){ if (dadir < 0) { if ((dachar > 0) || (boundcheck == 0)) { dachar--; if (smooshyalign > 0) dachar = (dachar&0xf8); } } else if (dadir > 0) { if ((dachar < 255) || (boundcheck == 0)) { dachar++; if (smooshyalign > 0) { if (dachar >= 256-8) dachar = 255; else dachar = ((dachar+7)&0xf8); } } } return(dachar);}static char visited[8192];long GetWallZPeg(long nWall){ long z=0, nSector, nNextSector; nSector = sectorofwall((short)nWall); nNextSector = wall[nWall].nextsector; if (nNextSector == -1) { /* 1-sided wall */ if (wall[nWall].cstat&4) z = sector[nSector].floorz; else z = sector[nSector].ceilingz; } else { /* 2-sided wall */ if (wall[nWall].cstat&4) z = sector[nSector].ceilingz; else { if (sector[nNextSector].ceilingz > sector[nSector].ceilingz) z = sector[nNextSector].ceilingz; /* top step */ if (sector[nNextSector].floorz < sector[nSector].floorz) z = sector[nNextSector].floorz; /* bottom step */ } } return(z);}void AlignWalls(long nWall0, long z0, long nWall1, long z1, long nTile){ long n; /* do the x alignment */ wall[nWall1].cstat &= ~0x0108; /* Set to non-flip */ wall[nWall1].xpanning = (char)((wall[nWall0].xpanning+(wall[nWall0].xrepeat<<3))%tilesizx[nTile]); z1 = GetWallZPeg(nWall1); for(n=(picsiz[nTile]>>4);((1<<n)<tilesizy[nTile]);n++); wall[nWall1].yrepeat = wall[nWall0].yrepeat; wall[nWall1].ypanning = (char)(wall[nWall0].ypanning+(((z1-z0)*wall[nWall0].yrepeat)>>(n+3)));}void AutoAlignWalls(long nWall0, long ply){ long z0, z1, nTile, nWall1, branch, visible, nNextSector, nSector; nTile = wall[nWall0].picnum; branch = 0; if (ply == 0) { /* clear visited bits */ memset(visited,0,sizeof(visited)); visited[nWall0] = 1; } z0 = GetWallZPeg(nWall0); nWall1 = wall[nWall0].point2; /* loop through walls at this vertex in CCW order */ while (1) { /* break if this wall would connect us in a loop */ if (visited[nWall1]) break; visited[nWall1] = 1; /* break if reached back of left wall */ if (wall[nWall1].nextwall == nWall0) break; if (wall[nWall1].picnum == nTile) { z1 = GetWallZPeg(nWall1); visible = 0; nNextSector = wall[nWall1].nextsector; if (nNextSector < 0) visible = 1; else { /* ignore two sided walls that have no visible face */ nSector = wall[wall[nWall1].nextwall].nextsector; if (getceilzofslope((short)nSector,wall[nWall1].x,wall[nWall1].y) < getceilzofslope((short)nNextSector,wall[nWall1].x,wall[nWall1].y)) visible = 1; if (getflorzofslope((short)nSector,wall[nWall1].x,wall[nWall1].y) > getflorzofslope((short)nNextSector,wall[nWall1].x,wall[nWall1].y)) visible = 1; } if (visible) { branch++; AlignWalls(nWall0,z0,nWall1,z1,nTile); /* if wall was 1-sided, no need to recurse */ if (wall[nWall1].nextwall < 0) { nWall0 = nWall1; z0 = GetWallZPeg(nWall0); nWall1 = wall[nWall0].point2; branch = 0; continue; } else AutoAlignWalls(nWall1,ply+1); } } if (wall[nWall1].nextwall < 0) break; nWall1 = wall[wall[nWall1].nextwall].point2; }}#if (defined PLATFORM_DOS)#define statusbar_printext16 printext16#define statusbar_printext16_noupdate printext16#elsevoid statusbar_printext16(long xpos, long ypos, short col, short backcol, char name[82], char fontsize){ printext256(xpos, ypos + 336, col, backcol, name, fontsize);}void statusbar_printext16_noupdate(long xpos, long ypos, short col, short backcol, char name[82], char fontsize){ printext256_noupdate(xpos, ypos + 336, col, backcol, name, fontsize);}#endifvoid printmessage16(char name[82]){ char snotbuf[60]; long i; i = 0; while ((name[i] != 0) && (i < 54)) { snotbuf[i] = name[i]; i++; } while (i < 54) { snotbuf[i] = 32; i++; } snotbuf[54] = 0; statusbar_printext16(200L, 8L, 0, 6, snotbuf, 0);}void printmessage256(char name[82]){ char snotbuf[40]; long i; i = 0; while ((name[i] != 0) && (i < 38)) { snotbuf[i] = name[i]; i++; } while (i < 38) { snotbuf[i] = 32; i++; } snotbuf[38] = 0; printext256(0L,0L,whitecol,0,snotbuf,0);}short getnumber16(char namestart[80], short num, long maxnumber){ char buffer[80]; long j, k, n, danum, oldnum; danum = (long) num; oldnum = danum; while ((keystatus[0x1c] != 2) && (keystatus[0x1] == 0)) { sprintf(buffer, "%s%ld_ ", namestart, danum); printmessage16(buffer); for(j=2;j<=11;j++) if (keystatus[j] > 0) { keystatus[j] = 0; k = j-1; if (k == 10) k = 0; n = (danum*10)+k; if (n < maxnumber) danum = n; } if (keystatus[0xe] > 0) /* backspace */ { danum /= 10; keystatus[0xe] = 0; } if (keystatus[0x1c] == 1) { oldnum = danum; keystatus[0x1c] = 2; asksave = 1; } } keystatus[0x1c] = 0; keystatus[0x1] = 0; return((short)oldnum);}short getnumber256(char namestart[80], short num, long maxnumber){ char buffer[80]; long j, k, n, danum, oldnum; danum = (long)num; oldnum = danum; while ((keystatus[0x1c] != 2) && (keystatus[0x1] == 0)) { drawrooms(posx,posy,posz,ang,horiz,cursectnum); ExtAnalyzeSprites(); drawmasks(); sprintf(buffer,"%s%ld_ ",namestart,danum); printmessage256(buffer); nextpage(); for(j=2;j<=11;j++) if (keystatus[j] > 0) { keystatus[j] = 0; k = j-1; if (k == 10) k = 0; n = (danum*10)+k; if (n < maxnumber) danum = n; } if (keystatus[0xe] > 0) /* backspace */ { danum /= 10; keystatus[0xe] = 0; } if (keystatus[0x1c] == 1) { oldnum = danum; keystatus[0x1c] = 2; asksave = 1; } } keystatus[0x1c] = 0; keystatus[0x1] = 0; lockclock = totalclock; /* Reset timing */ return((short)oldnum);}void updatenumsprites(void){ long i; numsprites = 0; for(i=0;i<MAXSPRITES;i++) if (sprite[i].statnum < MAXSTATUS) numsprites++;}int getfilenames(char kind[6]){/* !!! Visual C? */#if (defined __WATCOMC__) short type; struct find_t fileinfo; if (strcmp(kind,"SUBD") == 0) { strcpy(kind,"*.*"); if (_dos_findfirst(kind,_A_SUBDIR,&fileinfo) != 0) return(-1); type = 1; } else { if (_dos_findfirst(kind,_A_NORMAL,&fileinfo) != 0) return(-1); type = 0; } do { if ((type == 0) || ((fileinfo.attrib&16) > 0)) if ((fileinfo.name[0] != '.') || (fileinfo.name[1] != 0)) { strcpy(menuname[menunamecnt],fileinfo.name); menuname[menunamecnt][16] = type; menunamecnt++; } } while (_dos_findnext(&fileinfo) == 0);#elif (defined PLATFORM_UNIX) DIR *dir; struct dirent *dent; struct stat statbuf; int add_this; char *ptr = NULL; int len = 0; int subdirs = 0; if (strcmp(kind,"SUBD") == 0) subdirs = 1; dir = opendir("."); if (dir == NULL) return(-1); do { add_this = 0; dent = readdir(dir); if (dent != NULL) { if (stat(dent->d_name, &statbuf) == 0) { if (subdirs) { if (S_ISDIR(statbuf.st_mode)) add_this = 1; } /* if */ else { /* need to expand support if this assertion ever fails. */ assert(stricmp(kind, "*.MAP") == 0); len = strlen(dent->d_name); if (len >= 5) { ptr = ((char *) dent->d_name) + len; ptr += strlen(ptr) - 4; if (stricmp(ptr, ".MAP") == 0) add_this = 1; } /* if */ } /* else */ if (add_this) { strcpy(menuname[menunamecnt],dent->d_name); menuname[menunamecnt][16] = subdirs; menunamecnt++; } /* if */ } /* if */ } /* if */ } while (dent != NULL); closedir(dir);#endif return(0);}void sortfilenames(void){ char sortbuffer[17]; long i, j, k; for(i=1;i<menunamecnt;i++) for(j=0;j<i;j++) { k = 0; while ((menuname[i][k] == menuname[j][k]) && (menuname[i][k] != 0) && (menuname[j][k] != 0)) k++; if (menuname[i][k] < menuname[j][k]) { memcpy(&sortbuffer[0],&menuname[i][0],sizeof(menuname[0])); memcpy(&menuname[i][0],&menuname[j][0],sizeof(menuname[0])); memcpy(&menuname[j][0],&sortbuffer[0],sizeof(menuname[0])); } }}int menuselect(void){ long newhighlight, i, j, topplc; char ch, buffer[42]; chdir(menupath); menunamecnt = 0; getfilenames("SUBD"); getfilenames("*.MAP"); sortfilenames(); if (menunamecnt == 0) return(-2); printmessage16("Select .MAP file with arrows&enter.");#ifdef PLATFORM_DOS fillscreen16((399360-pageoffset)>>3,0L,640L*336L);#else fillscreen16(0,0L,640L*336L);#endif if (menuhighlight < 0) menuhighlight = 0; if (menuhighlight >= menunamecnt) menuhighlight = menunamecnt-1; newhighlight = menuhighlight; do { if (menunamecnt <= 36) { topplc = 0; } else { topplc = newhighlight-11; if (topplc < 0) topplc = 0; if (topplc > menunamecnt-37) topplc = menunamecnt-37; } for(i=0;i<menunamecnt;i++) { for(j=0;j<38;j++) buffer[j] = 32; buffer[38] = 0; if (i == newhighlight) { buffer[0] = '-'; buffer[1] = '-'; buffer[2] = '>'; } j = 0; while (menuname[i][j] != 0) { buffer[j+4] = menuname[i][j]; j++; } if ((i-topplc >= 0) && (i-topplc <= 36)) { if (menuname[i][16] == 1) { #ifdef PLATFORM_DOS printext16(0L,((i-topplc)<<3)+16L+((399360-pageoffset)/640),4,0,buffer,0); #else printext16(0L,((i-topplc)<<3)+16L,4,0,buffer,0); #endif } else { #ifdef PLATFORM_DOS printext16(0L,((i-topplc)<<3)+16L+((399360-pageoffset)/640),7,0,buffer,0); #else printext16(0L,((i-topplc)<<3)+16L,7,0,buffer,0); #endif } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -