📄 game.c
字号:
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
This file is NOT part of Duke Nukem 3D version 1.5 - Atomic EditionHowever, it is either an older version of a file that is, or issome test code written during the development of Duke Nukem 3D.This file is provided purely for educational interest.Duke Nukem 3D is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
#include "types.h"
#include "develop.h"
#include "scriplib.h"
#include "file_lib.h"
#include "gamedefs.h"
#include "keyboard.h"
#include "util_lib.h"
#include "function.h"
#include "control.h"
#include "fx_man.h"
#include "sounds.h"
#include "config.h"
#include "sndcards.h"
#include "duke3d.h"
#ifdef VOLUMEONE
#define VERSION "1.5"
#else
#define VERSION "1.5"
#endif
#ifdef UK
#define HEAD2 "Duke Nukem 3D (U.K. Plutonium Edition) v"VERSION
#else
#define HEAD "Duke Nukem 3D Unregistered Shareware v"VERSION" "
#ifdef PLUTOPAK
#define HEAD2 "Duke Nukem 3D v"VERSION" - Atomic Edition"
#else
#define HEAD2 "Duke Nukem 3D Full Version v"VERSION
#endif
#define HEADA "Duke Nukem 3D AUSSIE Unregistered Shareware v"VERSION
#define HEAD2A "Duke Nukem 3D (Parental Lock) Full Version v"VERSION
#endif
#define IDFSIZE 479985668
// #define IDFSIZE 9961476
// #define IDFSIZE 16384
#define IDFILENAME "DUKE3D.IDF"
#define TIMERUPDATESIZ 32
long cameradist = 0, cameraclock = 0;
char eightytwofifty = 0;
char playerswhenstarted;
char qe,cp;
int32 CommandSoundToggleOff = 0;
int32 CommandMusicToggleOff = 0;
char confilename[128] = {"GAME.CON"},boardfilename[128] = {0};
char waterpal[768], slimepal[768], titlepal[768], drealms[768], endingpal[768];
char firstdemofile[80] = { '\0' };
#define patchstatusbar(x1,y1,x2,y2) \
{ \
rotatesprite(0,(200-34)<<16,65536L,0,BOTTOMSTATUSBAR,4,0,10+16+64+128, \
scale(x1,xdim,320),scale(y1,ydim,200), \
scale(x2,xdim,320)-1,scale(y2,ydim,200)-1); \
}
void __interrupt __far newint24( int errval, int ax, int bp, int si );
int recfilep,totalreccnt;
char debug_on = 0,actor_tog = 0,*rtsptr,memorycheckoveride=0;
extern char syncstate;
extern int32 numlumps;
FILE *frecfilep = (FILE *)NULL;
void pitch_test( void );
char restorepalette,screencapt,nomorelogohack;
int sendmessagecommand = -1;
task *TimerPtr=NULL;
extern long lastvisinc;
void timerhandler()
{
totalclock++;
}
void inittimer()
{
TimerPtr = TS_ScheduleTask( timerhandler,TICRATE, 1, NULL );
TS_Dispatch();
}
void uninittimer(void)
{
if (TimerPtr)
TS_Terminate( TimerPtr );
TimerPtr = NULL;
TS_Shutdown();
}
int gametext(int x,int y,char *t,char s,short dabits)
{
short ac,newx;
char centre, *oldt;
centre = ( x == (320>>1) );
newx = 0;
oldt = t;
if(centre)
{
while(*t)
{
if(*t == 32) {newx+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM ) break;
if(*t >= '0' && *t <= '9')
newx += 8;
else newx += tilesizx[ac];
t++;
}
t = oldt;
x = (320>>1)-(newx>>1);
}
while(*t)
{
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM )
break;
rotatesprite(x<<16,y<<16,65536L,0,ac,s,0,dabits,0,0,xdim-1,ydim-1);
if(*t >= '0' && *t <= '9')
x += 8;
else x += tilesizx[ac];
t++;
}
return (x);
}
int gametextpal(int x,int y,char *t,char s,char p)
{
short ac,newx;
char centre, *oldt;
centre = ( x == (320>>1) );
newx = 0;
oldt = t;
if(centre)
{
while(*t)
{
if(*t == 32) {newx+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM ) break;
if(*t >= '0' && *t <= '9')
newx += 8;
else newx += tilesizx[ac];
t++;
}
t = oldt;
x = (320>>1)-(newx>>1);
}
while(*t)
{
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM )
break;
rotatesprite(x<<16,y<<16,65536L,0,ac,s,p,2+8+16,0,0,xdim-1,ydim-1);
if(*t >= '0' && *t <= '9')
x += 8;
else x += tilesizx[ac];
t++;
}
return (x);
}
int gametextpart(int x,int y,char *t,char s,short p)
{
short ac,newx, cnt;
char centre, *oldt;
centre = ( x == (320>>1) );
newx = 0;
oldt = t;
cnt = 0;
if(centre)
{
while(*t)
{
if(cnt == p) break;
if(*t == 32) {newx+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM ) break;
newx += tilesizx[ac];
t++;
cnt++;
}
t = oldt;
x = (320>>1)-(newx>>1);
}
cnt = 0;
while(*t)
{
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + STARTALPHANUM;
if( ac < STARTALPHANUM || ac > ENDALPHANUM ) break;
if(cnt == p)
{
rotatesprite(x<<16,y<<16,65536L,0,ac,s,1,2+8+16,0,0,xdim-1,ydim-1);
break;
}
else
rotatesprite(x<<16,y<<16,65536L,0,ac,s,0,2+8+16,0,0,xdim-1,ydim-1);
x += tilesizx[ac];
t++;
cnt++;
}
return (x);
}
int minitext(int x,int y,char *t,char p,char sb)
{
short ac;
while(*t)
{
*t = toupper(*t);
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + MINIFONT;
rotatesprite(x<<16,y<<16,65536L,0,ac,0,p,sb,0,0,xdim-1,ydim-1);
x += 4; // tilesizx[ac]+1;
t++;
}
return (x);
}
int minitextshade(int x,int y,char *t,char s,char p,char sb)
{
short ac;
while(*t)
{
*t = toupper(*t);
if(*t == 32) {x+=5;t++;continue;}
else ac = *t - '!' + MINIFONT;
rotatesprite(x<<16,y<<16,65536L,0,ac,s,p,sb,0,0,xdim-1,ydim-1);
x += 4; // tilesizx[ac]+1;
t++;
}
return (x);
}
void gamenumber(long x,long y,long n,char s)
{
char b[10];
ltoa(n,b,10);
gametext(x,y,b,s,2+8+16);
}
char recbuf[80];
void allowtimetocorrecterrorswhenquitting(void)
{
long i, j, oldtotalclock;
ready2send = 0;
for(j=0;j<8;j++)
{
oldtotalclock = totalclock;
while (totalclock < oldtotalclock+TICSPERFRAME)
getpackets();
if(KB_KeyPressed(sc_Escape)) return;
packbuf[0] = 127;
for(i=connecthead;i>=0;i=connectpoint2[i])
if (i != myconnectindex)
sendpacket(i,packbuf,1);
}
}
#define MAXUSERQUOTES 4
long quotebot, quotebotgoal;
short user_quote_time[MAXUSERQUOTES];
char user_quote[MAXUSERQUOTES][128];
// char typebuflen,typebuf[41];
adduserquote(char *daquote)
{
long i;
for(i=MAXUSERQUOTES-1;i>0;i--)
{
strcpy(user_quote[i],user_quote[i-1]);
user_quote_time[i] = user_quote_time[i-1];
}
strcpy(user_quote[0],daquote);
user_quote_time[0] = 180;
pub = NUMPAGES;
}
void getpackets(void)
{
long i, j, k, l;
FILE *fp;
short other, packbufleng;
input *osyn, *nsyn;
if(qe == 0 && KB_KeyPressed(sc_LeftControl) && KB_KeyPressed(sc_LeftAlt) && KB_KeyPressed(sc_Delete))
{
qe = 1;
gameexit("Quick Exit.");
}
if (numplayers < 2) return;
while ((packbufleng = getpacket(&other,packbuf)) > 0)
{
switch(packbuf[0])
{
case 126:
multiflag = 2;
multiwhat = 0;
multiwho = other;
multipos = packbuf[1];
loadplayer( multipos );
multiflag = 0;
break;
case 0: //[0] (receive master sync buffer)
j = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -