From e96c05767e1b13eaaf434e814449d942e063c5e8 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 11 Feb 2007 00:49:03 +0000 Subject: [PATCH] This changes the pistol's autoaim back to how it was in the DOS version of Duke3D. I suspect this behavior was changed during NAM or WW2GI development and just never noticed until now. git-svn-id: https://svn.eduke32.com/eduke32@485 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/astub.c | 6 +- polymer/eduke32/source/duke3d.h | 5 +- polymer/eduke32/source/game.c | 117 ++++++++---------------------- polymer/eduke32/source/gameexec.c | 13 ++-- polymer/eduke32/source/player.c | 56 ++++++++++---- polymer/eduke32/source/premap.c | 11 ++- polymer/eduke32/source/savegame.c | 8 +- 7 files changed, 95 insertions(+), 121 deletions(-) diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 4527b7a30..701c9c76b 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -1542,7 +1542,7 @@ static void ReadGamePalette() static inline void _message(char message[162]) { - Bsprintf(getmessage,message); + Bstrcpy(getmessage,message); getmessageleng = strlen(getmessage); getmessagetimeoff = totalclock+120*5; } @@ -4912,8 +4912,8 @@ static void Keys2d3d(void) begindrawing(); if (tempbuf[charsperline] != 0) { - printext256((xdimgame>>6)+2,((i/charsperline)<<3)+(ydimgame-(ydimgame>>5))-(((getmessageleng-1)/charsperline)<<3)+2,0,-1,tempbuf,xdimgame>640?0:1); - printext256((xdimgame>>6),((i/charsperline)<<3)+(ydimgame-(ydimgame>>5))-(((getmessageleng-1)/charsperline)<<3),whitecol,-1,tempbuf,xdimgame>640?0:1); + printext256((xdimgame>>6)+2,((i/charsperline)<<3)+(ydimgame-(ydimgame>>3))-(((getmessageleng-1)/charsperline)<<3)+2,0,-1,tempbuf,xdimgame>640?0:1); + printext256((xdimgame>>6),((i/charsperline)<<3)+(ydimgame-(ydimgame>>3))-(((getmessageleng-1)/charsperline)<<3),whitecol,-1,tempbuf,xdimgame>640?0:1); } enddrawing(); } diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index d62b3614d..22b8b5a91 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -66,7 +66,7 @@ extern int conversion, shareware, gametype; #define BYTEVERSION_13 27 #define BYTEVERSION_14 116 #define BYTEVERSION_15 117 -#define BYTEVERSION_JF 171 // increase by 3, because atomic GRP adds 1, and Shareware adds 2 +#define BYTEVERSION_JF 174 // increase by 3, because atomic GRP adds 1, and Shareware adds 2 #define BYTEVERSION (BYTEVERSION_JF+(PLUTOPAK?1:(VOLUMEONE<<1))) // JBF 20040116: different data files give different versions @@ -843,7 +843,8 @@ enum projectileflags { PROJECTILE_FLAG_RANDDECALSIZE = 8192, PROJECTILE_FLAG_EXPLODEONTIMER = 16384, PROJECTILE_FLAG_RPG_IMPACT = 32768, - PROJECTILE_FLAG_RADIUS_PICNUM = 65536 + PROJECTILE_FLAG_RADIUS_PICNUM = 65536, + PROJECTILE_FLAG_ACCURATE_AUTOAIM = 131072 }; typedef struct { diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 74a92e19e..a22351945 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -10267,11 +10267,7 @@ static int opendemoread(int which_demo) // 0 = mine OSD_Printf("ud.user_name: %s\n",ud.user_name); if (kread(recfilep,(int32 *)&i,sizeof(int32)) != sizeof(int32)) goto corrupt; - if (ver == BYTEVERSION) - { - if (kread(recfilep,(char *)boardfilename,sizeof(boardfilename)) != sizeof(boardfilename)) goto corrupt; - } - else if (kread(recfilep,(char *)boardfilename,128) != 128) goto corrupt; + if (kread(recfilep,(char *)boardfilename,sizeof(boardfilename)) != sizeof(boardfilename)) goto corrupt; if (boardfilename[0] != 0) { @@ -10279,28 +10275,17 @@ static int opendemoread(int which_demo) // 0 = mine ud.m_volume_number = 0; } + if (kread(recfilep,(int32 *)&ud.m_noexits,sizeof(int32)) != sizeof(int32)) goto corrupt; + for (i=0;i 0 || foundemo == 0) { - if (foundemo) while (totalclock >= (lockclock+TICSPERFRAME)) + if (foundemo) + while (totalclock >= (lockclock+TICSPERFRAME)) { -#if 0 - if (demo_version == 116 || demo_version == 117) + if ((i == 0) || (i >= RECSYNCBUFSIZ)) { - if ((i == 0) || (i >= RECSYNCBUFSIZ)) + i = 0; + l = min(ud.reccnt,RECSYNCBUFSIZ); + if (kdfread(recsync,sizeof(input)*ud.multimode,l/ud.multimode,recfilep) != l/ud.multimode) { - i = 0; - l = min(ud.reccnt,RECSYNCBUFSIZ); - if (kdfread(oldrecsync,sizeof(oldinput)*ud.multimode,l/ud.multimode,recfilep) != l/ud.multimode) - { - OSD_Printf("Demo %d is corrupt.\n", which_demo-1); - foundemo = 0; - ud.reccnt = 0; - kclose(recfilep); - ps[myconnectindex].gm |= MODE_MENU; - goto RECHECK; - } - OSD_Printf("ud.reccnt: %d\n",ud.reccnt); - } - - for (j=connecthead;j>=0;j=connectpoint2[j]) - { - OSD_Printf("ud.reccnt: %d, a:%d, h:%d, s:%d, f:%d, b:%d\n",ud.reccnt,oldrecsync[i].avel,oldrecsync[i].horz,oldrecsync[i].svel,oldrecsync[i].fvel,oldrecsync[i].bits); - clearbufbyte(&inputfifo[movefifoend[j]&(MOVEFIFOSIZ-1)][j],sizeof(input),0L); - copybufbyte(&oldrecsync[i],&inputfifo[movefifoend[j]&(MOVEFIFOSIZ-1)][j],sizeof(oldinput)); - movefifoend[j]++; - i++; - ud.reccnt--; + OSD_Printf("Demo %d is corrupt.\n", which_demo-1); + foundemo = 0; + ud.reccnt = 0; + kclose(recfilep); + ps[myconnectindex].gm |= MODE_MENU; + goto RECHECK; } } - else -#endif - { - if ((i == 0) || (i >= RECSYNCBUFSIZ)) - { - i = 0; - l = min(ud.reccnt,RECSYNCBUFSIZ); - if (kdfread(recsync,sizeof(input)*ud.multimode,l/ud.multimode,recfilep) != l/ud.multimode) - { - OSD_Printf("Demo %d is corrupt.\n", which_demo-1); - foundemo = 0; - ud.reccnt = 0; - kclose(recfilep); - ps[myconnectindex].gm |= MODE_MENU; - goto RECHECK; - } - } - for (j=connecthead;j>=0;j=connectpoint2[j]) - { - copybufbyte(&recsync[i],&inputfifo[movefifoend[j]&(MOVEFIFOSIZ-1)][j],sizeof(input)); - movefifoend[j]++; - i++; - ud.reccnt--; - } + for (j=connecthead;j>=0;j=connectpoint2[j]) + { + copybufbyte(&recsync[i],&inputfifo[movefifoend[j]&(MOVEFIFOSIZ-1)][j],sizeof(input)); + movefifoend[j]++; + i++; + ud.reccnt--; } domovethings(); } diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 2705fb146..6828e800c 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -4648,7 +4648,7 @@ static int parse(void) case CON_EZSHOOTVAR: case CON_ZSHOOTVAR: { - long lIn, lReturn=-1; + long lReturn=-1; insptr++; @@ -4658,10 +4658,10 @@ static int parse(void) if (hittype[g_i].temp_data[9] == 0) hittype[g_i].temp_data[9] = 1; } - lIn=GetGameVarID(*insptr++, g_i, g_p); + j=GetGameVarID(*insptr++, g_i, g_p); if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) { - lReturn = shoot(g_i, lIn); + lReturn = shoot(g_i, j); if (tw == CON_ESHOOTVAR || tw == CON_EZSHOOTVAR) SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); } @@ -4740,11 +4740,14 @@ static int parse(void) if (x1 > x2) swaplong(&x1,&x2); if (y1 > y2) swaplong(&y1,&y2); - + + if (x1 < 0 || y1 < 0 || x2 > xdim-1 || y2 > ydim-1 || x2-x1 < 1 || y2-y1 < 1) + break; + #if defined(USE_OPENGL) && defined(POLYMOST) j = glprojectionhacks; glprojectionhacks = 0; -#endif +#endif setview(x1,y1,x2,y2); drawrooms(x,y,z,a,horiz,sect); display_mirror = 1; animatesprites(x,y,a,65536L); display_mirror = 0; diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 9c41c9111..529791c23 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -579,19 +579,31 @@ int shoot(int i,int atwith) angRange=32; zRange=256; - SetGameVarID(g_iAngRangeVarID,32, i,p); - SetGameVarID(g_iZRangeVarID,256,i,p); + SetGameVarID(g_iAngRangeVarID,angRange, i,p); + SetGameVarID(g_iZRangeVarID,zRange,i,p); OnEvent(EVENT_GETSHOTRANGE, i,p, -1); angRange=GetGameVarID(g_iAngRangeVarID,i,p); zRange=GetGameVarID(g_iZRangeVarID,i,p); - sa += (angRange/2)-(TRAND&(angRange-1)); - if (j == -1) + if (projectile[atwith].workslike & PROJECTILE_FLAG_ACCURATE_AUTOAIM) { - // no target - zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + if (j == -1) + { + sa += (angRange/2)-(TRAND&(angRange-1)); + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + zvel += (zRange/2)-(TRAND&(zRange-1)); + } + } + else + { + sa += (angRange/2)-(TRAND&(angRange-1)); + if (j == -1) + { + // no target + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + } + zvel += (zRange/2)-(TRAND&(zRange-1)); } - zvel += (zRange/2)-(TRAND&(zRange-1)); sz -= (2<<8); } else @@ -1121,19 +1133,35 @@ DOSKIPBULLETHOLE: angRange=32; zRange=256; - SetGameVarID(g_iAngRangeVarID,32, i,p); - SetGameVarID(g_iZRangeVarID,256,i,p); + + SetGameVarID(g_iAngRangeVarID,angRange, i,p); + SetGameVarID(g_iZRangeVarID,zRange,i,p); + OnEvent(EVENT_GETSHOTRANGE, i,p, -1); + angRange=GetGameVarID(g_iAngRangeVarID,i,p); zRange=GetGameVarID(g_iZRangeVarID,i,p); - sa += (angRange/2)-(TRAND&(angRange-1)); - if (j == -1) + if (atwith == SHOTSPARK1__STATIC && !WW2GI && !NAM) { - // no target - zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + if (j == -1) + { + sa += (angRange/2)-(TRAND&(angRange-1)); + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + zvel += (zRange/2)-(TRAND&(zRange-1)); + } } - zvel += (zRange/2)-(TRAND&(zRange-1)); + else + { + sa += (angRange/2)-(TRAND&(angRange-1)); + if (j == -1) + { + // no target + zvel = (100-ps[p].horiz-ps[p].horizoff)<<5; + } + zvel += (zRange/2)-(TRAND&(zRange-1)); + } + sz -= (2<<8); } else diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 1120be8be..8820c390e 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1550,8 +1550,7 @@ static void getlevelfromfilename(const char *fn, char *volume, char *level) int enterlevel(char g) { - short i; - long l; + int i; char levname[BMAX_PATH]; ready2send = 1; // HACK: fetch any leftover p2p sync packets @@ -1688,10 +1687,10 @@ int enterlevel(char g) else { - l = strlen(level_file_names[(ud.volume_number*MAXLEVELS)+ud.level_number]); - copybufbyte(level_file_names[(ud.volume_number*MAXLEVELS)+ud.level_number],&levname[0],l); - levname[l] = 255; - levname[l+1] = 0; + i = strlen(level_file_names[(ud.volume_number*MAXLEVELS)+ud.level_number]); + copybufbyte(level_file_names[(ud.volume_number*MAXLEVELS)+ud.level_number],&levname[0],i); + levname[i] = 255; + levname[i+1] = 0; if (loadboard(levname,1,&ps[0].posx, &ps[0].posy, &ps[0].posz, &ps[0].ang,&ps[0].cursectnum) == -1) { diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index 1e2bce2f9..8d66b34e7 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "duke3d.h" +#define BYTEVERSION_COMPAT (BYTEVERSION-3) + void readsavenames(void) { long dummy,j; @@ -52,7 +54,7 @@ void readsavenames(void) Bfclose(fil); continue; } - if (dummy != BYTEVERSION) + if (dummy != BYTEVERSION && dummy != BYTEVERSION_COMPAT) { Bfclose(fil); continue; @@ -89,7 +91,7 @@ int loadpheader(char spot,struct savehead *saveh) // AddLog(g_szBuf); if (kdfread(&bv,4,1,fil) != 1) goto corrupt; - if (bv != BYTEVERSION) + if (bv != BYTEVERSION && bv != BYTEVERSION_COMPAT) { FTA(114,&ps[myconnectindex]); kclose(fil); @@ -166,7 +168,7 @@ int loadplayer(signed char spot) // AddLog(g_szBuf); if (kdfread(&bv,4,1,fil) != 1) return -1; - if (bv != BYTEVERSION) + if (bv != BYTEVERSION && bv != BYTEVERSION_COMPAT) { FTA(114,&ps[myconnectindex]); kclose(fil);